Module Name:    src
Committed By:   dholland
Date:           Thu Dec  1 00:34:05 UTC 2011

Modified Files:
        src/usr.sbin/user: user.c
Added Files:
        src/usr.sbin/user: pathnames.h

Log Message:
Move path names to pathnames.h per conventions


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/usr.sbin/user/pathnames.h
cvs rdiff -u -r1.128 -r1.129 src/usr.sbin/user/user.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/user/user.c
diff -u src/usr.sbin/user/user.c:1.128 src/usr.sbin/user/user.c:1.129
--- src/usr.sbin/user/user.c:1.128	Thu Dec  1 00:26:45 2011
+++ src/usr.sbin/user/user.c	Thu Dec  1 00:34:05 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: user.c,v 1.128 2011/12/01 00:26:45 dholland Exp $ */
+/* $NetBSD: user.c,v 1.129 2011/12/01 00:34:05 dholland Exp $ */
 
 /*
  * Copyright (c) 1999 Alistair G. Crooks.  All rights reserved.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1999\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: user.c,v 1.128 2011/12/01 00:26:45 dholland Exp $");
+__RCSID("$NetBSD: user.c,v 1.129 2011/12/01 00:34:05 dholland Exp $");
 #endif
 
 #include <sys/types.h>
@@ -49,7 +49,6 @@ __RCSID("$NetBSD: user.c,v 1.128 2011/12
 #ifdef EXTENSIONS
 #include <login_cap.h>
 #endif
-#include <paths.h>
 #include <pwd.h>
 #include <regex.h>
 #include <stdarg.h>
@@ -62,6 +61,7 @@ __RCSID("$NetBSD: user.c,v 1.128 2011/12
 #include <util.h>
 #include <errno.h>
 
+#include "pathnames.h"
 #include "defs.h"
 #include "usermgmt.h"
 
@@ -142,8 +142,6 @@ enum {
 #define LOCK		1
 #define LOCKED		"*LOCKED*"
 
-#define	PATH_LOGINCONF	"/etc/login.conf"
-
 #ifndef DEF_GROUP
 #define DEF_GROUP	"users"
 #endif
@@ -208,15 +206,6 @@ enum {
 	DES_Len = 13,
 };
 
-/* Full paths of programs used here */
-#define CHMOD		"/bin/chmod"
-#define CHOWN		"/usr/sbin/chown"
-#define MKDIR		"/bin/mkdir"
-#define MV		"/bin/mv"
-#define NOLOGIN		"/sbin/nologin"
-#define PAX		"/bin/pax"
-#define RM		"/bin/rm"
-
 #define UNSET_INACTIVE	"Null (unset)"
 #define UNSET_EXPIRY	"Null (unset)"
 
@@ -308,7 +297,8 @@ removehomedir(struct passwd *pwp)
 
 	(void)seteuid(pwp->pw_uid);
 	/* we add the "|| true" to keep asystem() quiet if there is a non-zero exit status. */
-	(void)asystem("%s -rf %s > /dev/null 2>&1 || true", RM, pwp->pw_dir);
+	(void)asystem("%s -rf %s > /dev/null 2>&1 || true", _PATH_RM,
+		      pwp->pw_dir);
 	(void)seteuid(0);
 	if (rmdir(pwp->pw_dir) < 0) {
 		warn("Unable to remove all files in `%s'", pwp->pw_dir);
@@ -365,12 +355,12 @@ copydotfiles(char *skeldir, int uid, int
 		warnx("No \"dot\" initialisation files found");
 	} else {
 		(void)asystem("cd %s && %s -rw -pe %s . %s",
-				skeldir, PAX, (verbose) ? "-v" : "", dir);
+			skeldir, _PATH_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);
+	(void)asystem("%s -R -h %d:%d %s", _PATH_CHOWN, uid, gid, dir);
+	(void)asystem("%s -R u+w %s", _PATH_CHMOD, dir);
 #ifdef EXTENSIONS
-	(void)asystem("%s 0%o %s", CHMOD, homeperm, dir);
+	(void)asystem("%s 0%o %s", _PATH_CHMOD, homeperm, dir);
 #endif
 	return n;
 }
@@ -994,9 +984,9 @@ valid_class(char *class)
 	 * user the actual login class does not exist.
 	 */
 
-	if (access(PATH_LOGINCONF, R_OK) == -1) {
+	if (access(_PATH_LOGINCONF, R_OK) == -1) {
 		warn("Access failed for `%s'; will not validate class `%s'",
-		    PATH_LOGINCONF, class);
+		    _PATH_LOGINCONF, class);
 		return 1;
 	}
 
@@ -1021,7 +1011,7 @@ valid_shell(const char *shellname)
 	} 
 
 	/* if nologin is used as a shell, consider it a valid shell */
-	if (strcmp(shellname, NOLOGIN) == 0)
+	if (strcmp(shellname, _PATH_SBIN_NOLOGIN) == 0)
 		return 1;
 
 	while ((shellp = getusershell()) != NULL)
@@ -1262,7 +1252,7 @@ adduser(char *login_name, user_t *up)
 			    "Can't add user `%s': home directory `%s' "
 			    "already exists", login_name, home);
 		} else {
-			if (asystem("%s -p %s", MKDIR, home) != 0) {
+			if (asystem("%s -p %s", _PATH_MKDIR, home) != 0) {
 				(void)close(ptmpfd);
 				(void)pw_abort();
 				errx(EXIT_FAILURE, "Can't add user `%s': "
@@ -1704,7 +1694,7 @@ moduser(char *login_name, char *newlogin
 	}
 	if (up != NULL) {
 		if ((up->u_flags & F_MKDIR) &&
-		    asystem("%s %s %s", MV, homedir, pwp->pw_dir) != 0) {
+		    asystem("%s %s %s", _PATH_MV, homedir, pwp->pw_dir) != 0) {
 			(void)close(ptmpfd);
 			(void)pw_abort();
 			errx(EXIT_FAILURE, "Can't modify user `%s': "
@@ -2210,7 +2200,8 @@ userdel(int argc, char **argv)
 	}
 	if (up->u_preserve) {
 		up->u_flags |= F_SHELL;
-		memsave(&up->u_shell, NOLOGIN, strlen(NOLOGIN));
+		memsave(&up->u_shell, _PATH_SBIN_NOLOGIN,
+			strlen(_PATH_SBIN_NOLOGIN));
 		(void)memset(password, '*', DES_Len);
 		password[DES_Len] = 0;
 		memsave(&up->u_password, password, strlen(password));

Added files:

Index: src/usr.sbin/user/pathnames.h
diff -u /dev/null src/usr.sbin/user/pathnames.h:1.1
--- /dev/null	Thu Dec  1 00:34:05 2011
+++ src/usr.sbin/user/pathnames.h	Thu Dec  1 00:34:05 2011
@@ -0,0 +1,44 @@
+/* $NetBSD: pathnames.h,v 1.1 2011/12/01 00:34:05 dholland Exp $ */
+
+/*
+ * Copyright (c) 1999 Alistair G. Crooks.  All rights reserved.
+ * Copyright (c) 2005 Liam J. Foy.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior written
+ *    permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <paths.h>
+
+/* Full paths of programs used here */
+#define _PATH_CHMOD		"/bin/chmod"
+#define _PATH_CHOWN		"/usr/sbin/chown"
+#define	_PATH_LOGINCONF		"/etc/login.conf"
+#define _PATH_MKDIR		"/bin/mkdir"
+#define _PATH_MV		"/bin/mv"
+/* note that there's a _PATH_NOLOGIN in <paths.h> that's for /etc/nologin */
+#define _PATH_SBIN_NOLOGIN	"/sbin/nologin"
+#define _PATH_PAX		"/bin/pax"
+#define _PATH_RM		"/bin/rm"
+

Reply via email to