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 Pullup 1.31 and 1.33 [simonb]:
details: https://anonhg.NetBSD.org/src/rev/895771236ffb
branches: netbsd-1-5
changeset: 490152:895771236ffb
user: tv <tv%NetBSD.org@localhost>
date: Sun Nov 05 01:18:41 2000 +0000
description:
Pullup 1.31 and 1.33 [simonb]:
Run a "chmod -R u+w <newhomedir>" after copying files from skeldir.
Problem noted by Hubert Feyrer in private mail.
Fix behaviour of 'useradd -m': it is now a fatal error if the target home
directory already exists. Previously new skel files from /etc/skel were
copied and permissions/ownerships changed even if the directory already
existed.
diffstat:
usr.sbin/user/user.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diffs (56 lines):
diff -r 71a58a4cb568 -r 895771236ffb usr.sbin/user/user.c
--- a/usr.sbin/user/user.c Sun Nov 05 01:14:39 2000 +0000
+++ b/usr.sbin/user/user.c Sun Nov 05 01:18:41 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: user.c,v 1.20.4.3 2000/11/03 20:56:38 tv Exp $ */
+/* $NetBSD: user.c,v 1.20.4.4 2000/11/05 01:18:41 tv 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.3 2000/11/03 20:56:38 tv Exp $");
+__RCSID("$NetBSD: user.c,v 1.20.4.4 2000/11/05 01:18:41 tv Exp $");
#endif
#include <sys/types.h>
@@ -166,6 +166,7 @@
};
/* Full paths of programs used here */
+#define CHMOD "/bin/chmod"
#define CHOWN "/usr/sbin/chown"
#define MKDIR "/bin/mkdir"
#define MV "/bin/mv"
@@ -388,6 +389,7 @@
skeldir, PAX, (verbose) ? "-v" : "", dir);
}
(void) asystem("%s -R -h %d:%d %s", CHOWN, uid, gid, dir);
+ (void) asystem("%s -R u+w %s", CHMOD, dir);
return n;
}
@@ -964,12 +966,18 @@
err(EXIT_FAILURE, "can't add `%s'", buf);
}
if (up->u_flags & F_MKDIR) {
- if (lstat(home, &st) < 0 && asystem("%s -p %s", MKDIR, home) != 0) {
+ if (lstat(home, &st) == 0) {
(void) close(ptmpfd);
(void) pw_abort();
- err(EXIT_FAILURE, "can't mkdir `%s'", home);
+ errx(EXIT_FAILURE, "home directory `%s' already exists", home);
+ } else {
+ if (asystem("%s -p %s", MKDIR, home) != 0) {
+ (void) close(ptmpfd);
+ (void) pw_abort();
+ err(EXIT_FAILURE, "can't mkdir `%s'", home);
+ }
+ (void) copydotfiles(up->u_skeldir, up->u_uid, gid, home);
}
- (void) copydotfiles(up->u_skeldir, up->u_uid, gid, home);
}
if (strcmp(up->u_primgrp, "=uid") == 0 &&
getgrnam(login) == NULL &&
Home |
Main Index |
Thread Index |
Old Index