Forum: Cfengine Help Subject: ppid check's irange not inclusive? Author: sauer Link to topic: https://cfengine.com/forum/read.php?3,21692,21692#msg-21692
In a promise to select only processes which are disassociated daemons, I wanted to select only processes with a parent PID of 0 or 1. So, I used this: body process_select my_checkuser(u) { process_owner => { "$(u)" }; ppid => irange("-1","2"); process_result => "ppid&process_owner"; } Originally, I used irange("0","1"), but I was getting no matches. The process was running as the correct user, and its PPID was 1. Using just the process_owner worked fine, but I had to increase the range to catch the PPID=1. It also doesn't work for me with the ppid=>"0,1" syntax, nor does it work if I use irange(1,2). So, the delimiter isn't being included in the case of either the upper or lower bound. The documentation doesn't explicitly say whether or not the irange() function or the comparisons agains ranges are inclusive of the end delimiters, but it seems to be implicitly the case that the delimiters areincluded in the range. I didn't see a bug for this, but I didn't search very hard. Is this a bug in the case where a range includes only two values, or am I making an invalid assumption with my code? In either case, given this problem, I can't ever find processes whose ppid is 0 (which happens on either AIX or HP-UX occasionally, I forget which). When I specify a range of -1,2, I get this: Validation: Int range item on rhs of lval 'ppid' given as {-1,2 => -1} is out of bounds (should be in [0,99999999999]) Validation: Int range item on rhs of lval 'ppid' given as {-1,2 => -1} is out of bounds (should be in [0,99999999999]) That's actually a valid error in terms of bounds checking, at least. But it indicates to me that this might actually be a bug in the ppid checking code (probably someone used a less than/greater than instead of "less than or equal to"), since the irange function seems to be passing the negative lower bound in. But before I submit it as a bug, it'd be cool to have confirmation that I'm not just doing something wrong. :) _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine