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

nekral-guest at alioth.debian.org nekral-guest at alioth.debian.org
Thu Dec 27 23:40:00 UTC 2007


Author: nekral-guest
Date: 2007-12-27 23:40:00 +0000 (Thu, 27 Dec 2007)
New Revision: 1517

Modified:
   upstream/trunk/ChangeLog
   upstream/trunk/libmisc/copydir.c
Log:
Avoid implicit brackets.


Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog	2007-12-27 23:32:47 UTC (rev 1516)
+++ upstream/trunk/ChangeLog	2007-12-27 23:40:00 UTC (rev 1517)
@@ -9,6 +9,7 @@
 	end.
 	* libmisc/copydir.c: Avoid assignment in comparisons.
 	* libmisc/copydir.c: Document selinux_file_context.
+	* libmisc/copydir.c: Avoid implicit brackets.
 
 2007-12-27  Nicolas François  <nicolas.francois at centraliens.net>
 

Modified: upstream/trunk/libmisc/copydir.c
===================================================================
--- upstream/trunk/libmisc/copydir.c	2007-12-27 23:32:47 UTC (rev 1516)
+++ upstream/trunk/libmisc/copydir.c	2007-12-27 23:40:00 UTC (rev 1517)
@@ -86,15 +86,22 @@
 {
 	security_context_t scontext = NULL;
 
-	if (selinux_enabled < 0)
+	if (selinux_enabled < 0) {
 		selinux_enabled = is_selinux_enabled () > 0;
+	}
 	if (selinux_enabled) {
-		if (matchpathcon (dst_name, 0, &scontext) < 0)
-			if (security_getenforce ())
+		/* Get the default security context for this file */
+		if (matchpathcon (dst_name, 0, &scontext) < 0) {
+			if (security_getenforce ()) {
 				return 1;
-		if (setfscreatecon (scontext) < 0)
-			if (security_getenforce ())
+			}
+		}
+		/* Set the security context for the next created file */
+		if (setfscreatecon (scontext) < 0) {
+			if (security_getenforce ()) {
 				return 1;
+			}
+		}
 		freecon (scontext);
 	}
 	return 0;
@@ -114,12 +121,15 @@
 		free (ln);
 		return;
 	}
-	for (lp = links; lp; lp = lp->ln_next)
-		if (lp->ln_next == ln)
+	for (lp = links; lp; lp = lp->ln_next) {
+		if (lp->ln_next == ln) {
 			break;
+		}
+	}
 
-	if (!lp)
+	if (!lp) {
 		return;
+	}
 
 	lp->ln_next = lp->ln_next->ln_next;
 	free (ln->ln_name);
@@ -138,12 +148,15 @@
 	int name_len;
 	int len;
 
-	for (lp = links; lp; lp = lp->ln_next)
-		if (lp->ln_dev == sb->st_dev && lp->ln_ino == sb->st_ino)
+	for (lp = links; lp; lp = lp->ln_next) {
+		if (lp->ln_dev == sb->st_dev && lp->ln_ino == sb->st_ino) {
 			return lp;
+		}
+	}
 
-	if (sb->st_nlink == 1)
+	if (sb->st_nlink == 1) {
 		return 0;
+	}
 
 	lp = (struct link_name *) xmalloc (sizeof *lp);
 	src_len = strlen (src_orig);
@@ -167,7 +180,6 @@
  *	copy_tree() walks a directory tree and copies ordinary files
  *	as it goes.
  */
-
 int copy_tree (const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
 {
 	char src_name[1024];
@@ -183,8 +195,9 @@
 	 * target is created.  It assumes the target directory exists.
 	 */
 
-	if (access (src_root, F_OK) != 0 || access (dst_root, F_OK) != 0)
+	if (access (src_root, F_OK) != 0 || access (dst_root, F_OK) != 0) {
 		return -1;
+	}
 
 	/*
 	 * Open the source directory and read each entry.  Every file
@@ -194,8 +207,9 @@
 	 * is made set-ID.
 	 */
 	dir = opendir (src_root);
-	if (NULL == dir)
+	if (NULL == dir) {
 		return -1;
+	}
 
 	if (src_orig == 0) {
 		src_orig = src_root;
@@ -209,8 +223,9 @@
 		 */
 
 		if (strcmp (ent->d_name, ".") == 0 ||
-		    strcmp (ent->d_name, "..") == 0)
+		    strcmp (ent->d_name, "..") == 0) {
 			continue;
+		}
 
 		/*
 		 * Make the filename for both the source and the
@@ -357,9 +372,8 @@
 	 * destination directory name.
 	 */
 
-	if ((len =
-	     readlink (src, oldlink,
-		       sizeof (oldlink) - 1)) < 0) {
+	len = readlink (src, oldlink, sizeof (oldlink) - 1);
+	if (len < 0) {
 		return -1;
 	}
 	oldlink[len] = '\0';	/* readlink() does not NUL-terminate */
@@ -401,8 +415,9 @@
 	if (unlink (src)) {
 		return -1;
 	}
-	if (--lp->ln_count <= 0)
+	if (--lp->ln_count <= 0) {
 		remove_link (lp);
+	}
 
 	return 0;
 }
@@ -494,8 +509,9 @@
 	 * Make certain the directory exists.
 	 */
 
-	if (access (root, F_OK) != 0)
+	if (access (root, F_OK) != 0) {
 		return -1;
+	}
 
 	/*
 	 * Open the source directory and read each entry.  Every file
@@ -505,8 +521,9 @@
 	 * is made set-ID.
 	 */
 	dir = opendir (root);
-	if (NULL == dir)
+	if (NULL == dir) {
 		return -1;
+	}
 
 	while ((ent = readdir (dir))) {
 
@@ -515,8 +532,9 @@
 		 */
 
 		if (strcmp (ent->d_name, ".") == 0 ||
-		    strcmp (ent->d_name, "..") == 0)
+		    strcmp (ent->d_name, "..") == 0) {
 			continue;
+		}
 
 		/*
 		 * Make the filename for the current entry.
@@ -528,8 +546,9 @@
 		}
 		snprintf (new_name, sizeof new_name, "%s/%s", root,
 			  ent->d_name);
-		if (LSTAT (new_name, &sb) == -1)
+		if (LSTAT (new_name, &sb) == -1) {
 			continue;
+		}
 
 		if (S_ISDIR (sb.st_mode)) {
 
@@ -553,3 +572,4 @@
 
 	return err;
 }
+




More information about the Pkg-shadow-commits mailing list