Source-Changes-HG archive

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

[src/trunk]: src/bin/mkdir Only call chmod(2) if we create a directory with a...



details:   https://anonhg.NetBSD.org/src/rev/94dfe4765cd7
branches:  trunk
changeset: 473212:94dfe4765cd7
user:      tron <tron%NetBSD.org@localhost>
date:      Tue May 25 00:27:45 1999 +0000

description:
Only call chmod(2) if we create a directory with a mode which isn't
accepted by mkdir(2).

diffstat:

 bin/mkdir/mkdir.c |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (37 lines):

diff -r f71c95ac0334 -r 94dfe4765cd7 bin/mkdir/mkdir.c
--- a/bin/mkdir/mkdir.c Tue May 25 00:16:08 1999 +0000
+++ b/bin/mkdir/mkdir.c Tue May 25 00:27:45 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkdir.c,v 1.21 1998/10/13 20:11:42 scw Exp $   */
+/*     $NetBSD: mkdir.c,v 1.22 1999/05/25 00:27:45 tron Exp $  */
 
 /*
  * Copyright (c) 1983, 1992, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)mkdir.c    8.2 (Berkeley) 1/25/94";
 #else
-__RCSID("$NetBSD: mkdir.c,v 1.21 1998/10/13 20:11:42 scw Exp $");
+__RCSID("$NetBSD: mkdir.c,v 1.22 1999/05/25 00:27:45 tron Exp $");
 #endif
 #endif /* not lint */
 
@@ -125,7 +125,7 @@
                                 * set a mode including the sticky, setuid,
                                 * setgid bits you lose them. So chmod().
                                 */
-                               if (chmod(*argv, mode) == -1) {
+                               if (mode > 0777 && chmod(*argv, mode) == -1) {
                                        warn("%s", *argv);
                                        exitval = 1;
                                }
@@ -172,7 +172,8 @@
                         * nine bits, so if you try to set a mode including the
                         * sticky, setuid, setgid bits you lose them. So chmod().
                          */
-                       if (chmod(path, done ? mode : dir_mode) == -1) {
+                       if (done && mode > 0777 &&
+                           chmod(path, mode) == -1) {
                                warn("%s", path);
                                return (-1);
                         }



Home | Main Index | Thread Index | Old Index