[Pkg-shadow-commits] r2157 - in upstream/trunk: . src

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Fri Jun 13 21:06:05 UTC 2008


Author: nekral-guest
Date: 2008-06-13 21:06:04 +0000 (Fri, 13 Jun 2008)
New Revision: 2157

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/src/useradd.c
Log:
	* src/useradd.c: The ID argument of audit_logger is an unsigned
	int. Use AUDIT_NO_ID instead of -1.
	* src/useradd.c: Cast the parsed GID/UID to a gid_t/uid_t.
	* src/useradd.c: The size argument of fgets is an int, not a
	size_t.
	* src/useradd.c: Cast number of days to a long integer.
	* src/useradd.c: Use SHADOW_SP_FLAG_UNSET for the initial
	value of spent.sp_flag.
	* src/useradd.c: Use a %lu format and cast group and user IDs to
	unsigned long integers.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2008-06-13 21:02:26 UTC (rev 2156)
+++ upstream/trunk/ChangeLog	2008-06-13 21:06:04 UTC (rev 2157)
@@ -1,5 +1,18 @@
 2008-06-13  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* src/useradd.c: The ID argument of audit_logger is an unsigned
+	int. Use AUDIT_NO_ID instead of -1.
+	* src/useradd.c: Cast the parsed GID/UID to a gid_t/uid_t.
+	* src/useradd.c: The size argument of fgets is an int, not a
+	size_t.
+	* src/useradd.c: Cast number of days to a long integer.
+	* src/useradd.c: Use SHADOW_SP_FLAG_UNSET for the initial
+	value of spent.sp_flag.
+	* src/useradd.c: Use a %lu format and cast group and user IDs to
+	unsigned long integers.
+
+2008-06-13  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* src/su.c: fork() and waitpid() return a pid_t, not an int.
 	* src/su.c: Add brackets and parenthesis.
 	* src/su.c: Ignore the return value of signal().

Modified: upstream/trunk/src/useradd.c
===================================================================
--- upstream/trunk/src/useradd.c	2008-06-13 21:02:26 UTC (rev 2156)
+++ upstream/trunk/src/useradd.c	2008-06-13 21:06:04 UTC (rev 2157)
@@ -213,8 +213,9 @@
 #endif
 
 #ifdef WITH_AUDIT
-	audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "adding user", user_name, -1,
-		      0);
+	audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+	              "adding user",
+	              user_name, AUDIT_NO_ID, 0);
 #endif
 	SYSLOG ((LOG_INFO, "failed adding user `%s', data deleted", user_name));
 	exit (code);
@@ -226,8 +227,9 @@
 	char *errptr;
 
 	gid = strtol (grname, &errptr, 10);
-	if (*grname != '\0' && *errptr == '\0' && errno != ERANGE && gid >= 0)
-		return xgetgrgid (gid);
+	if (*grname != '\0' && *errptr == '\0' && errno != ERANGE && gid >= 0) {
+		return xgetgrgid ((gid_t) gid);
+	}
 	return xgetgrnam (grname);
 }
 
@@ -257,7 +259,7 @@
 			 uidstr);
 		exit (E_BAD_ARG);
 	}
-	return val;
+	return (uid_t) val;
 }
 
 #define MATCH(x,y) (strncmp((x),(y),strlen(y)) == 0)
@@ -288,7 +290,7 @@
 	 * Read the file a line at a time. Only the lines that have relevant
 	 * values are used, everything else can be ignored.
 	 */
-	while (fgets (buf, sizeof buf, fp) == buf) {
+	while (fgets (buf, (int) sizeof buf, fp) == buf) {
 		cp = strrchr (buf, '\n');
 		if (NULL != cp) {
 			*cp = '\0';
@@ -455,7 +457,7 @@
 		goto skip;
 	}
 
-	while (fgets (buf, sizeof buf, ifp) == buf) {
+	while (fgets (buf, (int) sizeof buf, ifp) == buf) {
 		cp = strrchr (buf, '\n');
 		if (NULL != cp) {
 			*cp = '\0';
@@ -541,8 +543,9 @@
 		return -1;
 	}
 #ifdef WITH_AUDIT
-	audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "changing user defaults",
-		      NULL, -1, 1);
+	audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+	              "changing user defaults",
+	              NULL, AUDIT_NO_ID, 1);
 #endif
 	SYSLOG ((LOG_INFO,
 		 "useradd defaults: GROUP=%u, HOME=%s, SHELL=%s, INACTIVE=%ld, "
@@ -731,7 +734,7 @@
 	memzero (spent, sizeof *spent);
 	spent->sp_namp = (char *) user_name;
 	spent->sp_pwdp = (char *) user_pass;
-	spent->sp_lstchg = time ((time_t *) 0) / SCALE;
+	spent->sp_lstchg = (long) time ((time_t *) 0) / SCALE;
 	if (!rflg) {
 		spent->sp_min = scale_age (getdef_num ("PASS_MIN_DAYS", -1));
 		spent->sp_max = scale_age (getdef_num ("PASS_MAX_DAYS", -1));
@@ -745,7 +748,7 @@
 		spent->sp_inact = scale_age (-1);
 		spent->sp_expire = scale_age (-1);
 	}
-	spent->sp_flag = -1;
+	spent->sp_flag = SHADOW_SP_FLAG_UNSET;
 }
 
 /*
@@ -806,7 +809,8 @@
 		}
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			      "adding user to group", user_name, -1, 1);
+		              "adding user to group",
+		              user_name, AUDIT_NO_ID, 1);
 #endif
 		SYSLOG ((LOG_INFO, "add `%s' to group `%s'",
 			 user_name, ngrp->gr_name));
@@ -857,7 +861,8 @@
 		}
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			      "adding user to shadow group", user_name, -1, 1);
+		              "adding user to shadow group",
+		              user_name, AUDIT_NO_ID, 1);
 #endif
 		SYSLOG ((LOG_INFO, "add `%s' to shadow group `%s'",
 			 user_name, nsgrp->sg_name));
@@ -1152,8 +1157,9 @@
 				 ("%s: invalid user name '%s'\n"),
 				 Prog, user_name);
 #ifdef WITH_AUDIT
-			audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "adding user",
-				      user_name, -1, 0);
+			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+			              "adding user",
+			              user_name, AUDIT_NO_ID, 0);
 #endif
 			exit (E_BAD_ARG);
 		}
@@ -1242,7 +1248,8 @@
 		fprintf (stderr, _("%s: unable to lock password file\n"), Prog);
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			      "locking password file", user_name, user_id, 0);
+		              "locking password file",
+		              user_name, (unsigned int) user_id, 0);
 #endif
 		exit (E_PW_UPDATE);
 	}
@@ -1251,7 +1258,8 @@
 		fprintf (stderr, _("%s: unable to open password file\n"), Prog);
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			      "opening password file", user_name, user_id, 0);
+		              "opening password file",
+		              user_name, (unsigned int) user_id, 0);
 #endif
 		fail_exit (E_PW_UPDATE);
 	}
@@ -1262,8 +1270,8 @@
 			         Prog);
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			              "locking shadow password file", user_name,
-			              user_id, 0);
+			              "locking shadow password file",
+			              user_name, (unsigned int) user_id, 0);
 #endif
 			fail_exit (E_PW_UPDATE);
 		}
@@ -1274,8 +1282,8 @@
 			         Prog);
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			              "opening shadow password file", user_name,
-			              user_id, 0);
+			              "opening shadow password file",
+			              user_name, (unsigned int) user_id, 0);
 #endif
 			fail_exit (E_PW_UPDATE);
 		}
@@ -1477,13 +1485,15 @@
 			 Prog);
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			      "adding shadow password", user_name, user_id, 0);
+		              "adding shadow password",
+		              user_name, (unsigned int) user_id, 0);
 #endif
 		fail_exit (E_PW_UPDATE);
 	}
 #ifdef WITH_AUDIT
-	audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "adding user", user_name,
-		      user_id, 1);
+	audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+	              "adding user",
+	              user_name, (unsigned int) user_id, 1);
 #endif
 
 	/*
@@ -1512,8 +1522,8 @@
 				 Prog, user_home);
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-				      "adding home directory", user_name,
-				      user_id, 0);
+			              "adding home directory",
+			              user_name, (unsigned int) user_id, 0);
 #endif
 			fail_exit (E_HOMEDIR);
 		}
@@ -1523,7 +1533,8 @@
 		home_added = true;
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			      "adding home directory", user_name, user_id, 1);
+		              "adding home directory",
+		              user_name, (unsigned int) user_id, 1);
 #endif
 	}
 }
@@ -1673,8 +1684,9 @@
 	if (getpwnam (user_name) != NULL) { /* local, no need for xgetpwnam */
 		fprintf (stderr, _("%s: user %s exists\n"), Prog, user_name);
 #ifdef WITH_AUDIT
-		audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "adding user",
-			      user_name, -1, 0);
+		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+		              "adding user",
+		              user_name, AUDIT_NO_ID, 0);
 #endif
 		fail_exit (E_NAME_IN_USE);
 	}
@@ -1694,7 +1706,8 @@
 				 Prog, user_name);
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-				      "adding group", user_name, -1, 0);
+			              "adding group",
+			              user_name, AUDIT_NO_ID, 0);
 #endif
 			fail_exit (E_NAME_IN_USE);
 		}
@@ -1722,9 +1735,13 @@
 			}
 		} else {
 			if (getpwuid (user_id) != NULL) {
-				fprintf (stderr, _("%s: UID %u is not unique\n"), Prog, (unsigned int) user_id);
+				fprintf (stderr,
+				         _("%s: UID %lu is not unique\n"),
+				         Prog, (unsigned long) user_id);
 #ifdef WITH_AUDIT
-				audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "adding user", user_name, user_id, 0);
+				audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+				              "adding user",
+				              user_name, (unsigned int) user_id, 0);
 #endif
 				fail_exit (E_UID_IN_USE);
 			}




More information about the Pkg-shadow-commits mailing list