Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/user Enhancements from Hubert Feyrer:



details:   https://anonhg.NetBSD.org/src/rev/edf9a71a0562
branches:  trunk
changeset: 480061:edf9a71a0562
user:      agc <agc%NetBSD.org@localhost>
date:      Fri Dec 31 21:58:14 1999 +0000

description:
Enhancements from Hubert Feyrer:

+ copy all files and directories in <skeldir> to new user's home
directory, not just if they begin with a '.'
+ use pax to copy files from <skeldir>, as this will allow <skeldir>
to contain directory trees as well as regular files
+ use -h arg to chown(1) in case any symlinks have been created in the
new user's home directory
+ getpwnam(3) does not set errno, so use errx(3) and warnx(3)
+ use nologin(8) in preference to false(1) when deleting users but
preserving information
+ in usage messages, specify [-r lowuid..highuid] rather than a simple
[-r range]

diffstat:

 usr.sbin/user/user.c |  25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)

diffs (82 lines):

diff -r a3457b094b1a -r edf9a71a0562 usr.sbin/user/user.c
--- a/usr.sbin/user/user.c      Fri Dec 31 19:40:19 1999 +0000
+++ b/usr.sbin/user/user.c      Fri Dec 31 21:58:14 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: user.c,v 1.9 1999/12/24 09:08:50 agc Exp $ */
+/* $NetBSD: user.c,v 1.10 1999/12/31 21:58:14 agc Exp $ */
 
 /*
  * Copyright (c) 1999 Alistair G. Crooks.  All rights reserved.
@@ -151,10 +151,10 @@
 
 /* Full paths of programs used here */
 #define CHOWN          "/usr/sbin/chown"
-#define CP             "/bin/cp"
-#define FALSE_PROG     "/usr/bin/false"
 #define MKDIR          "/bin/mkdir"
 #define MV             "/bin/mv"
+#define NOLOGIN                "/sbin/nologin"
+#define PAX            "/bin/pax"
 #define RM             "/bin/rm"
 
 #define UNSET_EXPIRY   "Null (unset)"
@@ -254,17 +254,16 @@
                    strcmp(dp->d_name, "..") == 0) {
                        continue;
                }
-               if (dp->d_name[0] == '.' && isalnum(dp->d_name[1])) {
-                       n = 1;
-               }
+               n = 1;
        }
        (void) closedir(dirp);
        if (n == 0) {
                warnx("No \"dot\" initialisation files found");
        } else {
-               (void) asystem("%s -p -R %s/.[A-z]* %s", CP, skeldir, dir);
+               (void) asystem("cd %s; %s -rw -pe %s . %s", 
+                               skeldir, PAX, (verbose) ? "-v" : "", dir);
        }
-       (void) asystem("%s -R %d:%d %s", CHOWN, uid, gid, dir);
+       (void) asystem("%s -R -h %d:%d %s", CHOWN, uid, gid, dir);
        return n;
 }
 
@@ -783,7 +782,7 @@
                errx(EXIT_FAILURE, "`%s' is not a valid login name", login);
        }
        if ((pwp = getpwnam(login)) == (struct passwd *) NULL) {
-               err(EXIT_FAILURE, "No such user `%s'", login);
+               errx(EXIT_FAILURE, "No such user `%s'", login);
        }
        if ((masterfd = open(MASTER, O_RDONLY)) < 0) {
                err(EXIT_FAILURE, "can't open `%s'", MASTER);
@@ -947,8 +946,8 @@
 usermgmt_usage(char *prog)
 {
        if (strcmp(prog, "useradd") == 0) {
-               (void) fprintf(stderr, "Usage: %s -D [-b basedir] [-e expiry] [-f inactive] [-g group] [-r range] [-s shell]\n", prog);
-               (void) fprintf(stderr, "Usage: %s [-G group] [-b basedir] [-c comment] [-d homedir] [-e expiry] [-f inactive]\n\t[-g group] [-k skeletondir] [-m] [-o] [-p password] [-r range] [-s 
shell]\n\t[-u uid] [-v] user\n", prog);
+               (void) fprintf(stderr, "Usage: %s -D [-b basedir] [-e expiry] [-f inactive] [-g group] [-r lowuid..highuid] [-s shell]\n", prog);
+               (void) fprintf(stderr, "Usage: %s [-G group] [-b basedir] [-c comment] [-d homedir] [-e expiry] [-f inactive]\n\t[-g group] [-k skeletondir] [-m] [-o] [-p password] [-r 
lowuid..highuid] [-s shell]\n\t[-u uid] [-v] user\n", prog);
        } else if (strcmp(prog, "usermod") == 0) {
                (void) fprintf(stderr, "Usage: %s [-G group] [-c comment] [-d homedir] [-e expire] [-f inactive] [-g group] [-l newname] [-m] [-o] [-p password] [-s shell] [-u uid] [-v] user\n", 
prog);
        } else if (strcmp(prog, "userdel") == 0) {
@@ -1232,7 +1231,7 @@
        }
        checkeuid();
        if ((pwp = getpwnam(argv[optind])) == (struct passwd *) NULL) {
-               warn("No such user `%s'", argv[optind]);
+               warnx("No such user `%s'", argv[optind]);
                return EXIT_FAILURE;
        }
        if (rmhome) {
@@ -1243,7 +1242,7 @@
                (void) asystem("%s -rf %s", RM, pwp->pw_dir);
        }
        if (u.u_preserve) {
-               memsave(&u.u_shell, FALSE_PROG, strlen(FALSE_PROG));
+               memsave(&u.u_shell, NOLOGIN, strlen(NOLOGIN));
                (void) memset(password, '*', PasswordLength);
                password[PasswordLength] = 0;
                memsave(&u.u_password, password, PasswordLength);



Home | Main Index | Thread Index | Old Index