Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/user Modifications from Brian Poole <raj%cerias.pur@localhost...



details:   https://anonhg.NetBSD.org/src/rev/53442a062bf1
branches:  trunk
changeset: 526421:53442a062bf1
user:      agc <agc%NetBSD.org@localhost>
date:      Fri May 03 08:07:02 2002 +0000

description:
Modifications from Brian Poole <raj%cerias.purdue.edu@localhost>, via OpenBSD:

+ if the cd built-in fails, don't try to copy the directory hierarchy
  with pax - s/;/&&/ in a shell command
+ clean up after ourselves if a rename fails - remove the newly-created
  group file.

diffstat:

 usr.sbin/user/user.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (51 lines):

diff -r 90f138cef4ca -r 53442a062bf1 usr.sbin/user/user.c
--- a/usr.sbin/user/user.c      Fri May 03 07:31:23 2002 +0000
+++ b/usr.sbin/user/user.c      Fri May 03 08:07:02 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: user.c,v 1.47 2002/03/31 21:31:10 agc Exp $ */
+/* $NetBSD: user.c,v 1.48 2002/05/03 08:07:02 agc 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.47 2002/03/31 21:31:10 agc Exp $");
+__RCSID("$NetBSD: user.c,v 1.48 2002/05/03 08:07:02 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -391,7 +391,7 @@
        if (n == 0) {
                warnx("No \"dot\" initialisation files found");
        } else {
-               (void) asystem("cd %s; %s -rw -pe %s . %s", 
+               (void) asystem("cd %s && %s -rw -pe %s . %s", 
                                skeldir, PAX, (verbose) ? "-v" : "", dir);
        }
        (void) asystem("%s -R -h %d:%d %s", CHOWN, uid, gid, dir);
@@ -449,6 +449,7 @@
        (void) fclose(from);
        (void) fclose(to);
        if (rename(f, _PATH_GROUP) < 0) {
+               (void) unlink(f);
                warn("can't create gid: can't rename `%s' to `%s'", f, _PATH_GROUP);
                return 0;
        }
@@ -519,6 +520,7 @@
        (void) fclose(from);
        (void) fclose(to);
        if (rename(f, _PATH_GROUP) < 0) {
+               (void) unlink(f);
                warn("can't create gid: can't rename `%s' to `%s'", f, _PATH_GROUP);
                return 0;
        }
@@ -611,6 +613,7 @@
        (void) fclose(from);
        (void) fclose(to);
        if (rename(f, _PATH_GROUP) < 0) {
+               (void) unlink(f);
                warn("can't create gid: can't rename `%s' to `%s'", f, _PATH_GROUP);
                return 0;
        }



Home | Main Index | Thread Index | Old Index