Forum: Cfengine Help Subject: Reporting on expired password Author: JarleB Link to topic: https://cfengine.com/forum/read.php?3,17956,17956#msg-17956
I ended up with the following code, which works, in order to set a class i a password had expired (in this case the root user) I found no way of doing aritmhetic operations, hence the uglish perl oneliner. Suggestions for more elegant/readable/cfengine-ish way of solving the problem is very welcome. bundle agent main { vars: "rootpw_limit" int => "90"; "cmd" string => "/usr/bin/perl -nle \'use integer; print ((time()/86400) - ->[2]) if /^root:.+/\' /tmp/shadow"; "rootpw_age_string" string => execresult($(cmd),"noshell"); "root_pw_age" int => $(rootpw_age_string); #"rootpw_secs" int => "rootpw_days" * 86400; classes: "rootpw_expired" expression => isgreaterthan($(root_pw_age),$(rootpw_limit)); reports: rootpw_expired:: "Rootpassword expired. Limit: $(rootpw_limit) Actual age: $(root_pw_age) "; } I found no way of doing arithmetic operations, hence the uglish perl oneliner. Suggestions for more elegant/readable/cfengine-ish way of solving the problem is very welcome. _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine