At 06:38 PM 3/25/02, you wrote:
>Jeremy Salch <[EMAIL PROTECTED]> writes:
>
> > I have been running a www / ftp / mail server using cooker / mandrake 
> 8.2 for
> > a while now.. and just today out of the blue msec gave this error on 
> its job
> > in /etc/cron.hourly
> >
> > msec: unable to parse chage output
> >
> > now the only thing that has changed befor this ran and gave me the 
> error was
> > I added a user using webmin  and uploaded some stuff to their public_html
> > directory..
>
>Could you send me the output of chage -l <user> for the new user ?

Fred,

I've been looking into this one...

When webmin adds a user, the entry in /etc/shadow looks like:

         num1:$3$37105428$38J/slmiH0OJ6iRnZKZp9.:11772::::::

/usr/share/msec/libmsec.py expects to have a number as the maximum field, 
as in:

         num2:$3$37105428$38J/slmiH0OJ6iRnZKZp9.:11772::99999::::

Here's the output from chage for these two users:

         [root@osage samba]# /usr/bin/chage -l num1
         Minimum:        -1
         Maximum:        -1
         Warning:        -1
         Inactive:       -1
         Last Change:            Mar 26, 2002
         Password Expires:       Never
         Password Inactive:      Never
         Account Expires:        Never

         [root@osage samba]# /usr/bin/chage -l num2
         Minimum:        -1
         Maximum:        99999
         Warning:        -1
         Inactive:       -1
         Last Change:            Mar 26, 2002
         Password Expires:       Never
         Password Inactive:      Never
         Account Expires:        Never

The line "Maximum:...99999" is recognized by object maximum_regex.  Adding 
a regular expression to recognize "Maximum:...-1" allows libmsec.py to 
successfully process the lines in /etc/shadow generated by webmin.

I've made this change to my copy of libmsec.py and msec is happy.  Here's 
the patch:

[root@osage msec]# diff -u libmsec.py.orig libmsec.py
--- libmsec.py.orig     Fri Mar  8 13:41:21 2002
+++ libmsec.py  Mon Mar 25 23:35:08 2002
@@ -544,6 +544,7 @@
          atallow.replace_line_matching('root', 'root', 1)

  maximum_regex = re.compile('^Maximum:\s*([0-9]+)', re.MULTILINE)
+minimum_regex = re.compile('^Maximum:\s*(-1)', re.MULTILINE)
  inactive_regex = re.compile('^Inactive:\s*(-?[0-9]+)', re.MULTILINE)

  # TODO FL Sat Dec 29 20:18:20 2001
@@ -577,7 +578,7 @@
                  ret = commands.getstatusoutput(cmd)
                  _interactive and log(_('got current maximum password 
aging for user %s with command \'%s\'') % (entry[0], cmd))
                  if ret[0] == 0:
-                    res = maximum_regex.search(ret[1])
+                    res = maximum_regex.search(ret[1]) or 
minimum_regex.search(ret[1])
                      res2 = inactive_regex.search(ret[1])
                      if res and res2:
                          current_max = int(res.group(1))


Reply via email to