From 7b0116c5b441d785dd7ad68ae3be612e3c2dae07 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Sun, 18 Sep 2011 17:29:52 +0000 Subject: [PATCH] * src/newusers.c: Initially set the passwd's password to '*' instead of 'x'. Only when it is confirmed that a shadow entry is (will be) added, set the passwd's password to 'x'. * src/newusers.c: An invalid line is an error. A failure needs to be reported. --- ChangeLog | 8 ++++++++ src/newusers.c | 14 ++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index d73d55ba..1ae91212 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-09-18 Nicolas François + + * src/newusers.c: Initially set the passwd's password to '*' + instead of 'x'. Only when it is confirmed that a shadow entry is + (will be) added, set the passwd's password to 'x'. + * src/newusers.c: An invalid line is an error. A failure needs to + be reported. + 2011-09-18 Nicolas François * src/gpasswd.c: Remove log_gpasswd_success_gshadow(). Writing in diff --git a/src/newusers.c b/src/newusers.c index fc90b2db..f9e84999 100644 --- a/src/newusers.c +++ b/src/newusers.c @@ -2,7 +2,7 @@ * Copyright (c) 1990 - 1993, Julianne Frances Haugh * Copyright (c) 1996 - 2000, Marek Michałkiewicz * Copyright (c) 2000 - 2006, Tomasz Kłoczko - * Copyright (c) 2007 - 2009, Nicolas François + * Copyright (c) 2007 - 2011, Nicolas François * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -268,7 +268,7 @@ static int add_group (const char *name, const char *gid, gid_t *ngid, uid_t uid) return -1; } - grent.gr_passwd = "x"; /* XXX warning: const */ + grent.gr_passwd = "*"; /* XXX warning: const */ members[0] = NULL; grent.gr_mem = members; @@ -287,16 +287,13 @@ static int add_group (const char *name, const char *gid, gid_t *ngid, uid_t uid) } #endif - if (gr_update (&grent) == 0) { - return -1; - } - #ifdef SHADOWGRP if (is_shadow_grp) { struct sgrp sgrent; char *admins[1]; sgrent.sg_name = grent.gr_name; sgrent.sg_passwd = "*"; /* XXX warning: const */ + grent.gr_passwd = "x"; /* XXX warning: const */ admins[0] = NULL; sgrent.sg_adm = admins; sgrent.sg_mem = members; @@ -307,6 +304,10 @@ static int add_group (const char *name, const char *gid, gid_t *ngid, uid_t uid) } #endif + if (gr_update (&grent) == 0) { + return -1; + } + return 0; } @@ -890,6 +891,7 @@ int main (int argc, char **argv) if (nfields != 6) { fprintf (stderr, _("%s: line %d: invalid line\n"), Prog, line); + errors++ continue; }