With the current code the return value of the function 
syslog_circular_buffer is 1 instead of 0!

It looks like return 0 does not break the loops!

So what I did:
syslog_circular_buffer() {
    local pid
    local tty
    local flags
    local time
    local path
    local args
    local arg

    ps w 2> /dev/null | while read pid tty stat time path args; do
        case $path in
            syslogd|*/syslogd)
                for arg in $args; do
                    case $arg in
                        -C*)
                            return 0
                            ;;
                    esac
                done
                ;;
            logd|*/logd)
                for arg in $args; do
                    case $arg in
                        -S*)
return 0
                            ;;
*)
return 1
;;
                    esac
                done
                ;;
        esac
done

if [ $? -ne 0 ]; then
return 1
fi
}

Basicly it needs to break first from the loop and then the function 
needs to return 0 if there is a match and 1 if there is no match!

Hopefully you will understant what I am trying to say!!!:)

-Matt

On 2 Nov 2015 at 7:45, Tom Eastep wrote:

> On 11/02/2015 03:21 AM, matt darfeuille wrote:
> > Hi Tom, sorry for not having tested the function 
> > syslog_circular_buffer with a return value of 1!
> > 
> > The return 1 in the function syslog_circular_buffer is always 
> > executed instead of the return 0 in the case statement in the for 
> > loop; adding in that case statement the following works:
> > *)
> > return 1
> > ;;
> > esac
> > ...
> > 
> > if [ $? -ne 0 ]; then
> > return1
> > fi
> > }
> > 
> 
> I don't think that is right. We execute the case statement once for
> every running process. With the first hunk of your change, the first
> running process that isn't syslogd or klogd will cause the function to
> return 1.
> 
> And the 'return 1' at the end is there because it means that we didn't
> find a syslogd or klogd with the appropriate option specified.
> 
> What am I missing?
> 
> -Tom
> -- 
> Tom Eastep        \ When I die, I want to go like my Grandfather who
> Shoreline,         \ died peacefully in his sleep. Not screaming like
> Washington, USA     \ all of the passengers in his car
> http://shorewall.net \________________________________________________
> 
> 



------------------------------------------------------------------------------
_______________________________________________
Shorewall-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/shorewall-users

Reply via email to