[Midnightbsd-cvs] src [6846] trunk/lib/libmport/bundle_read_install_pkg.c: only set permissions on a real file and not a symlink.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Fri Oct 10 08:37:45 EDT 2014


Revision: 6846
          http://svnweb.midnightbsd.org/src/?rev=6846
Author:   laffer1
Date:     2014-10-10 08:37:45 -0400 (Fri, 10 Oct 2014)
Log Message:
-----------
only set permissions on a real file and not a symlink. this was causing an error condition and a failed install. while here, fix ASSET_DIR so that it is handled like dirrm

Modified Paths:
--------------
    trunk/lib/libmport/bundle_read_install_pkg.c

Modified: trunk/lib/libmport/bundle_read_install_pkg.c
===================================================================
--- trunk/lib/libmport/bundle_read_install_pkg.c	2014-10-10 10:58:45 UTC (rev 6845)
+++ trunk/lib/libmport/bundle_read_install_pkg.c	2014-10-10 12:37:45 UTC (rev 6846)
@@ -200,21 +200,27 @@
         if (mport_bundle_read_extract_next_file(bundle, entry) != MPORT_OK) 
           goto ERROR;
 
-	/* Set the owner and group */
-	if (chown(file, owner, group) == -1)
+	if (lstat(file, &sb))
 		goto ERROR;
 
-	/* Set the file permissions, assumes non NFSv4 */
-	if (mode != NULL)
+	if (S_ISREG(sb.st_mode))
 	{
-		if (stat(file, &sb))
+		/* Set the owner and group */
+		if (chown(file, owner, group) == -1)
 			goto ERROR;
-		if ((set = setmode(mode)) == NULL)
-			goto ERROR;
-		newmode = getmode(set, sb.st_mode);
-		free(set);
-		if (chmod(file, newmode))
-			goto ERROR;
+
+		/* Set the file permissions, assumes non NFSv4 */
+		if (mode != NULL)
+		{
+			if (stat(file, &sb))
+				goto ERROR;
+			if ((set = setmode(mode)) == NULL)
+				goto ERROR;
+			newmode = getmode(set, sb.st_mode);
+			free(set);
+			if (chmod(file, newmode))
+				goto ERROR;
+		}
 	}
 
         (mport->progress_step_cb)(++file_count, file_total, file);
@@ -240,7 +246,7 @@
         SET_ERROR(MPORT_ERR_FATAL, sqlite3_errmsg(db));
         goto ERROR;
       }
-    } else if (type == ASSET_DIRRM || type == ASSET_DIRRMTRY) {
+    } else if (type == ASSET_DIR || type == ASSET_DIRRM || type == ASSET_DIRRMTRY) {
       (void)snprintf(dir, FILENAME_MAX, "%s/%s", cwd, data);
       if (sqlite3_bind_text(insert, 2, dir, -1, SQLITE_STATIC) != SQLITE_OK) {
         SET_ERROR(MPORT_ERR_FATAL, sqlite3_errmsg(db));



More information about the Midnightbsd-cvs mailing list