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

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Fri Jun 13 20:40:06 UTC 2008


Author: nekral-guest
Date: 2008-06-13 20:40:04 +0000 (Fri, 13 Jun 2008)
New Revision: 2151

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/src/usermod.c
Log:
	* src/usermod.c: Cast dates to time_t, and number of days to a
	long integer.
	* src/usermod.c: Cast UIDs and GIDs to uid_t and gid_t after
	checking the ranges.
	* src/usermod.c: The ID argument of audit_logger is an unsigned
	int.
	* src/usermod.c: read() returns a ssize_t.
	* src/usermod.c: Cast the return value of malloc and make sure it
	receives a size_t.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2008-06-13 20:34:46 UTC (rev 2150)
+++ upstream/trunk/ChangeLog	2008-06-13 20:40:04 UTC (rev 2151)
@@ -1,5 +1,17 @@
 2008-06-13  Nicolas François  <nicolas.francois at centraliens.net>
 
+	* src/usermod.c: Cast dates to time_t, and number of days to a
+	long integer.
+	* src/usermod.c: Cast UIDs and GIDs to uid_t and gid_t after
+	checking the ranges.
+	* src/usermod.c: The ID argument of audit_logger is an unsigned
+	int.
+	* src/usermod.c: read() returns a ssize_t.
+	* src/usermod.c: Cast the return value of malloc and make sure it
+	receives a size_t.
+
+2008-06-13  Nicolas François  <nicolas.francois at centraliens.net>
+
 	* src/logoutd.c: Ignore return value of time() when use with a
 	non NULL argument.
 

Modified: upstream/trunk/src/usermod.c
===================================================================
--- upstream/trunk/src/usermod.c	2008-06-13 20:34:46 UTC (rev 2150)
+++ upstream/trunk/src/usermod.c	2008-06-13 20:40:04 UTC (rev 2151)
@@ -172,7 +172,7 @@
 	if ((negativ != NULL) && (date < 0)) {
 		strncpy (buf, negativ, maxsize);
 	} else {
-		time_t t = date;
+		time_t t = (time_t) date;
 		tp = gmtime (&t);
 #ifdef HAVE_STRFTIME
 		strftime (buf, maxsize, "%Y-%m-%d", tp);
@@ -195,7 +195,7 @@
 
 	val = strtol (grname, &errptr, 10);
 	if (*grname != '\0' && *errptr == '\0' && errno != ERANGE && val >= 0) {
-		return xgetgrgid (val);
+		return xgetgrgid ((gid_t) val);
 	}
 	return xgetgrnam (grname);
 }
@@ -344,8 +344,9 @@
 		char *buf = xmalloc (strlen (pw_pass) + 2);
 
 #ifdef WITH_AUDIT
-		audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "updating passwd",
-			      user_newname, user_newid, 0);
+		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+		              "updating passwd",
+		              user_newname, (unsigned int) user_newid, 0);
 #endif
 		SYSLOG ((LOG_INFO, "lock user `%s' password", user_newname));
 		strcpy (buf, "!");
@@ -363,8 +364,9 @@
 		}
 
 #ifdef WITH_AUDIT
-		audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "updating password",
-			      user_newname, user_newid, 0);
+		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+		              "updating password",
+		              user_newname, (unsigned int) user_newid, 0);
 #endif
 		SYSLOG ((LOG_INFO, "unlock user `%s' password", user_newname));
 		s = pw_pass;
@@ -374,8 +376,9 @@
 		}
 	} else if (pflg) {
 #ifdef WITH_AUDIT
-		audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "changing password",
-			      user_newname, user_newid, 1);
+		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+		              "changing password",
+		              user_newname, (unsigned int) user_newid, 1);
 #endif
 		SYSLOG ((LOG_INFO, "change user `%s' password", user_newname));
 		pw_pass = xstrdup (user_pass);
@@ -393,8 +396,9 @@
 {
 	if (lflg) {
 #ifdef WITH_AUDIT
-		audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "changing name",
-			      user_newname, user_newid, 1);
+		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+		              "changing name",
+		              user_newname, (unsigned int) user_newid, 1);
 #endif
 		SYSLOG ((LOG_INFO, "change user name `%s' to `%s'",
 			 pwent->pw_name, user_newname));
@@ -407,8 +411,9 @@
 
 	if (uflg) {
 #ifdef WITH_AUDIT
-		audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "changing uid",
-			      user_newname, user_newid, 1);
+		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+		              "changing uid",
+		              user_newname, (unsigned int) user_newid, 1);
 #endif
 		SYSLOG ((LOG_INFO,
 			 "change user `%s' UID from `%d' to `%d'",
@@ -418,8 +423,8 @@
 	if (gflg) {
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			      "changing primary group", user_newname,
-			      user_newid, 1);
+		              "changing primary group",
+		              user_newname, (unsigned int) user_newid, 1);
 #endif
 		SYSLOG ((LOG_INFO,
 			 "change user `%s' GID from `%d' to `%d'",
@@ -428,8 +433,9 @@
 	}
 	if (cflg) {
 #ifdef WITH_AUDIT
-		audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "changing comment",
-			      user_newname, user_newid, 1);
+		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+		              "changing comment",
+		              user_newname, (unsigned int) user_newid, 1);
 #endif
 		pwent->pw_gecos = user_newcomment;
 	}
@@ -437,8 +443,8 @@
 	if (dflg) {
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			      "changing home directory", user_newname,
-			      user_newid, 1);
+		              "changing home directory",
+		              user_newname, (unsigned int) user_newid, 1);
 #endif
 		SYSLOG ((LOG_INFO,
 			 "change user `%s' home from `%s' to `%s'",
@@ -447,8 +453,9 @@
 	}
 	if (sflg) {
 #ifdef WITH_AUDIT
-		audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "changing user shell",
-			      user_newname, user_newid, 1);
+		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+		              "changing user shell",
+		              user_newname, (unsigned int) user_newid, 1);
 #endif
 		SYSLOG ((LOG_INFO, "change user `%s' shell from `%s' to `%s'",
 			 pwent->pw_name, pwent->pw_shell, user_newshell));
@@ -471,8 +478,8 @@
 	if (fflg) {
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			      "changing inactive days", user_newname,
-			      user_newid, 1);
+		              "changing inactive days",
+		              user_newname, (unsigned int) user_newid, 1);
 #endif
 		SYSLOG ((LOG_INFO,
 			 "change user `%s' inactive from `%ld' to `%ld'",
@@ -488,8 +495,8 @@
 		             user_expire * DAY, "never");
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-		              "changing expiration date", user_newname,
-		              user_newid, 1);
+		              "changing expiration date",
+		              user_newname, (unsigned int) user_newid, 1);
 #endif
 		SYSLOG ((LOG_INFO,
 			 "change user `%s' expiration from `%s' to `%s'",
@@ -498,7 +505,7 @@
 	}
 	spent->sp_pwdp = new_pw_passwd (spent->sp_pwdp);
 	if (pflg) {
-		spent->sp_lstchg = time ((time_t *) 0) / SCALE;
+		spent->sp_lstchg = (long) time ((time_t *) 0) / SCALE;
 	}
 }
 
@@ -523,8 +530,9 @@
 	}
 
 #ifdef WITH_AUDIT
-	audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "modifying account",
-		      user_name, -1, 0);
+	audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
+	              "modifying account",
+	              user_name, AUDIT_NO_ID, 0);
 #endif
 	exit (code);
 }
@@ -574,8 +582,8 @@
 				changed = true;
 #ifdef WITH_AUDIT
 				audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-					      "changing group member",
-					      user_newname, -1, 1);
+				              "changing group member",
+				              user_newname, AUDIT_NO_ID, 1);
 #endif
 				SYSLOG ((LOG_INFO,
 					 "change `%s' to `%s' in group `%s'",
@@ -587,8 +595,8 @@
 			changed = true;
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-				      "removing group member", user_name, -1,
-				      1);
+			              "removing group member",
+			              user_name, AUDIT_NO_ID, 1);
 #endif
 			SYSLOG ((LOG_INFO, "delete `%s' from group `%s'",
 				 user_name, ngrp->gr_name));
@@ -597,7 +605,8 @@
 			changed = true;
 #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_newname, ngrp->gr_name));
@@ -669,8 +678,8 @@
 			changed = true;
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-				      "changing admin name in shadow group",
-				      user_name, -1, 1);
+			              "changing admin name in shadow group",
+			              user_name, AUDIT_NO_ID, 1);
 #endif
 			SYSLOG ((LOG_INFO,
 				 "change admin `%s' to `%s' in shadow group `%s'",
@@ -685,8 +694,8 @@
 				changed = true;
 #ifdef WITH_AUDIT
 				audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-					      "changing member in shadow group",
-					      user_name, -1, 1);
+				              "changing member in shadow group",
+				              user_name, AUDIT_NO_ID, 1);
 #endif
 				SYSLOG ((LOG_INFO,
 					 "change `%s' to `%s' in shadow group `%s'",
@@ -698,8 +707,8 @@
 			changed = true;
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-				      "removing user from shadow group",
-				      user_name, -1, 1);
+			              "removing user from shadow group",
+			              user_name, AUDIT_NO_ID, 1);
 #endif
 			SYSLOG ((LOG_INFO,
 				 "delete `%s' from shadow group `%s'",
@@ -709,8 +718,8 @@
 			changed = true;
 #ifdef WITH_AUDIT
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-				      "adding user to shadow group",
-				      user_newname, -1, 1);
+			              "adding user to shadow group",
+			              user_newname, AUDIT_NO_ID, 1);
 #endif
 			SYSLOG ((LOG_INFO, "add `%s' to shadow group `%s'",
 			         user_newname, nsgrp->sg_name));
@@ -775,7 +784,7 @@
 			 uidstr);
 		exit (E_BAD_ARG);
 	}
-	return val;
+	return (uid_t) val;
 }
 
 /*
@@ -1320,10 +1329,11 @@
 					}
 #ifdef WITH_AUDIT
 					audit_logger (AUDIT_USER_CHAUTHTOK,
-						      Prog,
-						      "moving home directory",
-						      user_newname, user_newid,
-						      1);
+					              Prog,
+					              "moving home directory",
+					              user_newname,
+					              (unsigned int) user_newid,
+					              1);
 #endif
 					return;
 				}
@@ -1340,15 +1350,15 @@
 		}
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			      "moving home directory", user_newname, user_newid,
-			      1);
+		              "moving home directory",
+		              user_newname, (unsigned int) user_newid, 1);
 #endif
 	}
 	if (uflg || gflg) {
 #ifdef WITH_AUDIT
 		audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-			      "changing home directory owner", user_newname,
-			      user_newid, 1);
+		              "changing home directory owner",
+		              user_newname, (unsigned int) user_newid, 1);
 #endif
 		chown (dflg ? user_newhome : user_home,
 		       uflg ? user_newid : user_id,
@@ -1373,7 +1383,7 @@
 	fd = open (LASTLOG_FILE, O_RDWR);
 	if (-1 != fd) {
 		lseek (fd, (off_t) user_id * sizeof ll, SEEK_SET);
-		if (read (fd, (char *) &ll, sizeof ll) == sizeof ll) {
+		if (read (fd, (char *) &ll, sizeof ll) == (ssize_t) sizeof ll) {
 			lseek (fd, (off_t) user_newid * sizeof ll, SEEK_SET);
 			write (fd, (char *) &ll, sizeof ll);
 		}
@@ -1386,7 +1396,7 @@
 	fd = open (FAILLOG_FILE, O_RDWR);
 	if (-1 != fd) {
 		lseek (fd, (off_t) user_id * sizeof fl, SEEK_SET);
-		if (read (fd, (char *) &fl, sizeof fl) == sizeof fl) {
+		if (read (fd, (char *) &fl, sizeof fl) == (ssize_t) sizeof fl) {
 			lseek (fd, (off_t) user_newid * sizeof fl, SEEK_SET);
 			write (fd, (char *) &fl, sizeof fl);
 		}
@@ -1452,8 +1462,8 @@
 #ifdef WITH_AUDIT
 		else {
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-				      "changing mail file owner", user_newname,
-				      user_newid, 1);
+			              "changing mail file owner",
+			              user_newname, (unsigned int) user_newid, 1);
 		}
 #endif
 	}
@@ -1470,8 +1480,8 @@
 #ifdef WITH_AUDIT
 		else {
 			audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
-				      "changing mail file name", user_newname,
-				      user_newid, 1);
+			              "changing mail file name",
+			              user_newname, (unsigned int) user_newid, 1);
 		}
 #endif
 	}
@@ -1502,7 +1512,7 @@
 	(void) textdomain (PACKAGE);
 
 	sys_ngroups = sysconf (_SC_NGROUPS_MAX);
-	user_groups = malloc ((1 + sys_ngroups) * sizeof (char *));
+	user_groups = (char **) malloc (sizeof (char *) * (1 + sys_ngroups));
 	user_groups[0] = (char *) 0;
 
 	OPENLOG ("usermod");




More information about the Pkg-shadow-commits mailing list