Hi Andrew (or any other developer),

OK to commit the following fix?

Note that chomping after splitting is important because split
drops trailing empty fields.


Hi Denis,

Denis Lapshin wrote on Thu, Mar 26, 2015 at 11:33:16AM +0300:

> Some time ago start getting errors after nightly Secutiry running:
> What problem can be?

Your file /etc/passwd contains two incomplete entries.
Never edit it by hand.  Always use vipw(8) to change
user account information.

Please apply the following patch to the file /usr/libexec/security,
run "sh /etc/daily" (both as root) and report back whether the
error messages you get then make more sense to you.

After that, to repair the damage, run vipw(8), do some trivial
change - like adding a letter to the full name field of some entry
- and try to save and exit vipw(8).  If it works, great (and if you
want, revert the trivial change, using vipw(8) again).  If it denies
saving, your master.passwd(5) file is corrupt, too.  In that case,
choose "re-edit" and fix whatever problems it reports.

Btw., Nick is right that in general, you should note in problem reports
which version of OpenBSD you are running, it's mere luck that it doesn't
matters in the case at hand.

Yours,
  Ingo

> Use of uninitialized value $home in concatenation (.) or string
> at /usr/libexec/security line 356.


Index: security
===================================================================
RCS file: /cvs/src/libexec/security/security,v
retrieving revision 1.32
diff -u -p -r1.32 security
--- security    4 Dec 2014 00:07:21 -0000       1.32
+++ security    26 Mar 2015 14:23:53 -0000
@@ -336,7 +336,16 @@ sub find_homes {
        nag !(open my $fh, '<', $filename),
            "open: $filename: $!"
            and return [];
-       my $homes = [ map [ @{[split /:/]}[0,2,5] ], <$fh> ];
+       my $homes = [];
+       while (<$fh>) {
+               my $entry = [ @{[split /:/]}[0,2,5] ];
+               chomp;
+               nag !defined $entry->[2],
+                   "Incomplete line \"$_\" in $filename."
+                   and next;
+               chomp $entry->[2];
+               push @$homes, $entry;
+       }
        close $fh;
        return $homes;
 }

Reply via email to