Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/usr.sbin/user Pull up revision 1.36 (requested by wiz):



details:   https://anonhg.NetBSD.org/src/rev/615bbcf64895
branches:  netbsd-1-5
changeset: 490659:615bbcf64895
user:      he <he%NetBSD.org@localhost>
date:      Mon Feb 26 15:15:51 2001 +0000

description:
Pull up revision 1.36 (requested by wiz):
  Improve handling of ``-l'' with ``-m'', and update documentation.
  Fixes PR#11707.

diffstat:

 usr.sbin/user/user.c |  19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diffs (54 lines):

diff -r d400b07e83bf -r 615bbcf64895 usr.sbin/user/user.c
--- a/usr.sbin/user/user.c      Sun Feb 04 20:34:38 2001 +0000
+++ b/usr.sbin/user/user.c      Mon Feb 26 15:15:51 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: user.c,v 1.20.4.6 2001/01/25 14:30:23 jhawk Exp $ */
+/* $NetBSD: user.c,v 1.20.4.7 2001/02/26 15:15:51 he Exp $ */
 
 /*
  * Copyright (c) 1999 Alistair G. Crooks.  All rights reserved.
@@ -35,7 +35,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1999 \
                The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: user.c,v 1.20.4.6 2001/01/25 14:30:23 jhawk Exp $");
+__RCSID("$NetBSD: user.c,v 1.20.4.7 2001/02/26 15:15:51 he Exp $");
 #endif
 
 #include <sys/types.h>
@@ -1006,6 +1006,7 @@
        struct group    *grp;
        struct tm       tm;
        const char      *homedir;
+       char            newdir[MaxFileNameLen];
        size_t          colonc, len, loginc;
        FILE            *master;
        char            *buf, *colon, *line;
@@ -1047,6 +1048,15 @@
                                errx(EXIT_FAILURE, "already a `%s' user", newlogin);
                        }
                        pwp->pw_name = newlogin;
+
+                       /*
+                        * Provide a new directory name in case the
+                        * home directory is to be moved.
+                        */
+                       if (up->u_flags & F_MKDIR) {
+                               snprintf(newdir, sizeof(newdir), "%s/%s", up->u_basedir, newlogin);
+                               pwp->pw_dir = newdir;
+                       }
                }
                if (up->u_flags & F_PASSWORD) {
                        if (up->u_password != NULL && strlen(up->u_password) == PasswordLength)
@@ -1442,8 +1452,9 @@
 #endif
                }
        }
-       if ((u.u_flags & F_MKDIR) && !(u.u_flags & F_HOMEDIR)) {
-               warnx("option 'm' useless without 'd' -- ignored");
+       if ((u.u_flags & F_MKDIR) && !(u.u_flags & F_HOMEDIR) &&
+           !(u.u_flags & F_USERNAME)) {
+               warnx("option 'm' useless without 'd' or 'l' -- ignored");
                u.u_flags &= !F_MKDIR;
        }
 



Home | Main Index | Thread Index | Old Index