[Pkg-shadow-commits] r3181 - in upstream/trunk: . lib libmisc

Nicolas FRANÇOIS nekral-guest at alioth.debian.org
Tue Mar 23 08:56:52 UTC 2010


Author: nekral-guest
Date: 2010-03-23 08:56:52 +0000 (Tue, 23 Mar 2010)
New Revision: 3181

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/lib/groupmem.c
   upstream/trunk/lib/shadow.c
   upstream/trunk/lib/utent.c
   upstream/trunk/libmisc/copydir.c
   upstream/trunk/libmisc/find_new_gid.c
   upstream/trunk/libmisc/find_new_uid.c
   upstream/trunk/libmisc/limits.c
   upstream/trunk/libmisc/loginprompt.c
Log:
	* lib/utent.c (getutline): Remove getutline(). This function is
	no more used.
	* lib/groupmem.c: Limit the scope of variable i.
	* lib/shadow.c: Avoid implicit conversion of pointers and integers
	to booleans.
	* lib/shadow.c: Added brackets.
	* libmisc/limits.c: Limit the scope of variable tmpmask.
	* libmisc/copydir.c: Close opened file on failure.
	* libmisc/loginprompt.c: Limit the scope of variable envc.
	* libmisc/find_new_uid.c, libmisc/find_new_gid.c: Limit the scope
	of variable id.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2010-03-21 01:20:50 UTC (rev 3180)
+++ upstream/trunk/ChangeLog	2010-03-23 08:56:52 UTC (rev 3181)
@@ -1,3 +1,17 @@
+2010-03-22  Nicolas François  <nicolas.francois at centraliens.net>
+
+	* lib/utent.c (getutline): Remove getutline(). This function is
+	no more used.
+	* lib/groupmem.c: Limit the scope of variable i.
+	* lib/shadow.c: Avoid implicit conversion of pointers and integers
+	to booleans.
+	* lib/shadow.c: Added brackets.
+	* libmisc/limits.c: Limit the scope of variable tmpmask.
+	* libmisc/copydir.c: Close opened file on failure.
+	* libmisc/loginprompt.c: Limit the scope of variable envc.
+	* libmisc/find_new_uid.c, libmisc/find_new_gid.c: Limit the scope
+	of variable id.
+
 2010-03-21  Nicolas François  <nicolas.francois at centraliens.net>
 
 	* libmisc/find_new_gid.c, libmisc/find_new_uid.c: Detect some
@@ -7,6 +21,8 @@
 2010-03-20  Nicolas François  <nicolas.francois at centraliens.net>
 
 	* NEWS, configure.in: Next version will be 4.1.5.
+	* po/shadow.pot, man/po/shadow-man-pages.pot: Regenerated.
+	* po/*.po, man/po/*.po: Updated PO files.
 
 2010-03-20  Nicolas François  <nicolas.francois at centraliens.net>
 

Modified: upstream/trunk/lib/groupmem.c
===================================================================
--- upstream/trunk/lib/groupmem.c	2010-03-21 01:20:50 UTC (rev 3180)
+++ upstream/trunk/lib/groupmem.c	2010-03-23 08:56:52 UTC (rev 3181)
@@ -90,13 +90,13 @@
 
 void gr_free (/*@out@*/ /*@only@*/struct group *grent)
 {
-	size_t i;
 	free (grent->gr_name);
 	if (NULL != grent->gr_passwd) {
 		memzero (grent->gr_passwd, strlen (grent->gr_passwd));
 		free (grent->gr_passwd);
 	}
 	if (NULL != grent->gr_mem) {
+		size_t i;
 		for (i = 0; NULL != grent->gr_mem[i]; i++) {
 			free (grent->gr_mem[i]);
 		}

Modified: upstream/trunk/lib/shadow.c
===================================================================
--- upstream/trunk/lib/shadow.c	2010-03-21 01:20:50 UTC (rev 3180)
+++ upstream/trunk/lib/shadow.c	2010-03-23 08:56:52 UTC (rev 3181)
@@ -42,10 +42,10 @@
 #include "defines.h"
 #include <stdio.h>
 #ifdef	USE_NIS
-static int nis_used;
-static int nis_ignore;
+static bool nis_used;
+static bool nis_ignore;
 static enum { native, start, middle, native2 } nis_state;
-static int nis_bound;
+static bool nis_bound;
 static char *nis_domain;
 static char *nis_key;
 static int nis_keylen;
@@ -66,12 +66,12 @@
  * __setspNIS - turn on or off NIS searches
  */
 
-void __setspNIS (int flag)
+void __setspNIS (bool flag)
 {
 	nis_ignore = !flag;
 
 	if (nis_ignore) {
-		nis_used = 0;
+		nis_used = false;
 	}
 }
 
@@ -81,10 +81,11 @@
 
 static int bind_nis (void)
 {
-	if (yp_get_default_domain (&nis_domain))
+	if (yp_get_default_domain (&nis_domain)) {
 		return -1;
+	}
 
-	nis_bound = 1;
+	nis_bound = true;
 	return 0;
 }
 #endif
@@ -95,10 +96,11 @@
 
 void setspent (void)
 {
-	if (shadow)
+	if (NULL != shadow) {
 		rewind (shadow);
-	else
+	}else {
 		shadow = fopen (SHADOW_FILE, "r");
+	}
 
 #ifdef	USE_NIS
 	nis_state = native;
@@ -111,8 +113,9 @@
 
 void endspent (void)
 {
-	if (shadow)
+	if (NULL != shadow) {
 		(void) fclose (shadow);
+	}
 
 	shadow = (FILE *) 0;
 }
@@ -172,8 +175,9 @@
 
 	spwd.sp_namp = fields[0];
 #ifdef	USE_NIS
-	if (IS_NISCHAR (fields[0][0]))
-		nis_used = 1;
+	if (IS_NISCHAR (fields[0][0])) {
+		nis_used = true;
+	}
 #endif
 	spwd.sp_pwdp = fields[1];
 
@@ -211,7 +215,9 @@
 				spwd.sp_min = -1;
 			} else
 #endif
+			{
 				return 0;
+			}
 		} else if (spwd.sp_min < 0) {
 			return 0;
 		}
@@ -263,7 +269,9 @@
 				spwd.sp_warn = -1;
 			} else
 #endif
+			{
 				return 0;
+			}
 		} else if (spwd.sp_warn < 0) {
 			return 0;
 		}
@@ -283,7 +291,9 @@
 				spwd.sp_inact = -1;
 			} else
 #endif
+			{
 				return 0;
+			}
 		} else if (spwd.sp_inact < 0) {
 			return 0;
 		}
@@ -303,7 +313,9 @@
 				spwd.sp_expire = -1;
 			} else
 #endif
+			{
 				return 0;
+			}
 		} else if (spwd.sp_expire < 0) {
 			return 0;
 		}
@@ -324,7 +336,9 @@
 				spwd.sp_flag = SHADOW_SP_FLAG_UNSET;
 			} else
 #endif
+			{
 				return 0;
+			}
 		} else if (spwd.sp_flag < 0) {
 			return 0;
 		}
@@ -377,8 +391,9 @@
 	struct spwd *val;
 	char buf[BUFSIZ];
 #endif
-	if (!shadow)
+	if (NULL == shadow) {
 		setspent ();
+	}
 
 #ifdef	USE_NIS
       again:
@@ -432,7 +447,7 @@
 
 		return 0;
 	} else {
-		if (nis_bound == 0) {
+		if (!nis_bound) {
 			if (bind_nis ()) {
 				nis_state = native2;
 				goto again;
@@ -440,15 +455,15 @@
 		}
 		if (nis_state == start) {
 			if (yp_first (nis_domain, "shadow.bynam", &nis_key,
-				      &nis_keylen, &nis_val, &nis_vallen)) {
+			              &nis_keylen, &nis_val, &nis_vallen)) {
 				nis_state = native2;
 				goto again;
 			}
 			nis_state = middle;
 		} else if (nis_state == middle) {
 			if (yp_next (nis_domain, "shadow.bynam", nis_key,
-				     nis_keylen, &nis_key, &nis_keylen,
-				     &nis_val, &nis_vallen)) {
+			             nis_keylen, &nis_key, &nis_keylen,
+			             &nis_val, &nis_vallen)) {
 				nis_state = native2;
 				goto again;
 			}
@@ -471,7 +486,7 @@
 #ifdef	USE_NIS
 	char buf[BUFSIZ];
 	static char save_name[16];
-	int nis_disabled = 0;
+	bool nis_disabled = false;
 #endif
 
 	setspent ();
@@ -481,18 +496,20 @@
 	 * Search the shadow.byname map for this user.
 	 */
 
-	if (!nis_ignore && !nis_bound)
+	if (!nis_ignore && !nis_bound) {
 		bind_nis ();
+	}
 
 	if (!nis_ignore && nis_bound) {
 		char *cp;
 
 		if (yp_match (nis_domain, "shadow.byname", name,
-			      strlen (name), &nis_val, &nis_vallen) == 0) {
+		              strlen (name), &nis_val, &nis_vallen) == 0) {
 
 			cp = strchr (nis_val, '\n');
-			if (NULL != cp)
+			if (NULL != cp) {
 				*cp = '\0';
+			}
 
 			nis_state = middle;
 			sp = my_sgetspent (nis_val);
@@ -503,8 +520,9 @@
 			}
 			endspent ();
 			return sp;
-		} else
+		} else {
 			nis_state = native2;
+		}
 	}
 #endif
 #ifdef	USE_NIS
@@ -516,17 +534,19 @@
 	 */
 
 	if (nis_used) {
-		nis_ignore++;
-		nis_disabled++;
+		nis_ignore = true;
+		nis_disabled = true;
 	}
 #endif
 	while ((sp = getspent ()) != (struct spwd *) 0) {
-		if (strcmp (name, sp->sp_namp) == 0)
+		if (strcmp (name, sp->sp_namp) == 0) {
 			break;
+		}
 	}
 #ifdef	USE_NIS
-	if (nis_disabled)
-		nis_ignore--;
+	if (nis_disabled) {
+		nis_ignore = false;
+	}
 #endif
 	endspent ();
 	return (sp);

Modified: upstream/trunk/lib/utent.c
===================================================================
--- upstream/trunk/lib/utent.c	2010-03-21 01:20:50 UTC (rev 3180)
+++ upstream/trunk/lib/utent.c	2010-03-23 08:56:52 UTC (rev 3181)
@@ -88,25 +88,6 @@
 
 	return &utmp_buf;
 }
-
-/*
- * getutline - get the utmp entry matching ut_line
- */
-
-struct utmp *getutline (const struct utmp *utent)
-{
-	struct utmp save;
-	struct utmp *new;
-
-	save = *utent;
-	while (new = getutent ())
-		if (strncmp (new->ut_line, save.ut_line, sizeof new->ut_line))
-			continue;
-		else
-			return new;
-
-	return (struct utmp *) 0;
-}
 #else
 extern int errno;		/* warning: ANSI C forbids an empty source file */
 #endif

Modified: upstream/trunk/libmisc/copydir.c
===================================================================
--- upstream/trunk/libmisc/copydir.c	2010-03-21 01:20:50 UTC (rev 3180)
+++ upstream/trunk/libmisc/copydir.c	2010-03-23 08:56:52 UTC (rev 3181)
@@ -635,6 +635,7 @@
 
 	while ((cnt = read (ifd, buf, sizeof buf)) > 0) {
 		if (write (ofd, buf, (size_t)cnt) != cnt) {
+			(void) close (ifd);
 			return -1;
 		}
 	}

Modified: upstream/trunk/libmisc/find_new_gid.c
===================================================================
--- upstream/trunk/libmisc/find_new_gid.c	2010-03-21 01:20:50 UTC (rev 3180)
+++ upstream/trunk/libmisc/find_new_gid.c	2010-03-23 08:56:52 UTC (rev 3181)
@@ -52,7 +52,7 @@
                   /*@null@*/gid_t const *preferred_gid)
 {
 	const struct group *grp;
-	gid_t gid_min, gid_max, group_id, id;
+	gid_t gid_min, gid_max, group_id;
 	bool *used_gids;
 
 	assert (gid != NULL);
@@ -100,6 +100,7 @@
 	 * some groups were created but the changes were not committed yet.
 	 */
 	if (sys_group) {
+		gid_t id;
 		/* setgrent / getgrent / endgrent can be very slow with
 		 * LDAP configurations (and many accounts).
 		 * Since there is a limited amount of IDs to be tested

Modified: upstream/trunk/libmisc/find_new_uid.c
===================================================================
--- upstream/trunk/libmisc/find_new_uid.c	2010-03-21 01:20:50 UTC (rev 3180)
+++ upstream/trunk/libmisc/find_new_uid.c	2010-03-23 08:56:52 UTC (rev 3181)
@@ -52,7 +52,7 @@
                   /*@null@*/uid_t const *preferred_uid)
 {
 	const struct passwd *pwd;
-	uid_t uid_min, uid_max, user_id, id;
+	uid_t uid_min, uid_max, user_id;
 	bool *used_uids;
 
 	assert (uid != NULL);
@@ -100,6 +100,7 @@
 	 * some users were created but the changes were not committed yet.
 	 */
 	if (sys_user) {
+		uid_t id;
 		/* setpwent / getpwent / endpwent can be very slow with
 		 * LDAP configurations (and many accounts).
 		 * Since there is a limited amount of IDs to be tested

Modified: upstream/trunk/libmisc/limits.c
===================================================================
--- upstream/trunk/libmisc/limits.c	2010-03-21 01:20:50 UTC (rev 3180)
+++ upstream/trunk/libmisc/limits.c	2010-03-23 08:56:52 UTC (rev 3181)
@@ -507,7 +507,6 @@
 static void setup_usergroups (const struct passwd *info)
 {
 	const struct group *grp;
-	mode_t tmpmask;
 
 /*
  *	if not root, and UID == GID, and username is the same as primary
@@ -519,6 +518,7 @@
 		grp = getgrgid (info->pw_gid);
 		if (   (NULL != grp)
 		    && (strcmp (info->pw_name, grp->gr_name) == 0)) {
+			mode_t tmpmask;
 			tmpmask = umask (0777);
 			tmpmask = (tmpmask & ~070) | ((tmpmask >> 3) & 070);
 			(void) umask (tmpmask);

Modified: upstream/trunk/libmisc/loginprompt.c
===================================================================
--- upstream/trunk/libmisc/loginprompt.c	2010-03-21 01:20:50 UTC (rev 3180)
+++ upstream/trunk/libmisc/loginprompt.c	2010-03-23 08:56:52 UTC (rev 3181)
@@ -60,7 +60,6 @@
 
 #define MAX_ENV 32
 	char *envp[MAX_ENV];
-	int envc;
 	char *cp;
 	int i;
 	FILE *fp;
@@ -148,6 +147,7 @@
 	if ('\0' != *cp) {	/* process new variables */
 		char *nvar;
 		int count = 1;
+		int envc;
 
 		for (envc = 0; envc < MAX_ENV; envc++) {
 			nvar = strtok ((0 != envc) ? (char *) 0 : cp, " \t,");




More information about the Pkg-shadow-commits mailing list