fixed chmod(symlink) bug
authorroot <devnull@localhost>
Tue, 4 Jun 1996 22:53:56 +0000 (22:53 +0000)
committerroot <devnull@localhost>
Tue, 4 Jun 1996 22:53:56 +0000 (22:53 +0000)
CVS patchset: 605
CVS date: 1996/06/04 22:53:56

lib/install.c

index 465967f..f567415 100644 (file)
@@ -767,7 +767,7 @@ static int setFileOwner(char * prefix, char * file, char * owner,
     }
        
     message(MESS_DEBUG, "%s owned by %s (%d), group %s (%d) mode %o\n",
-               filespec, owner, uid, group, gid, mode);
+               filespec, owner, uid, group, gid, mode & 07777);
     if (chown(filespec, uid, gid)) {
        error(RPMERR_CHOWN, "cannot set owner and group for %s - %s\n",
                filespec, strerror(errno));
@@ -776,12 +776,14 @@ static int setFileOwner(char * prefix, char * file, char * owner,
        return 1;
     }
     /* Also set the mode according to what is stored in the header */
-    if (chmod(filespec, mode)) {
-       error(RPMERR_CHOWN, "cannot change mode for %s - %s\n",
-               filespec, strerror(errno));
-       /* screw with the permissions so it's not SUID and 0.0 */
-       chmod(filespec, 0644);
-       return 1;
+    if (! S_ISLNK(mode)) {
+       if (chmod(filespec, mode & 07777)) {
+           error(RPMERR_CHOWN, "cannot change mode for %s - %s\n",
+                 filespec, strerror(errno));
+           /* screw with the permissions so it's not SUID and 0.0 */
+           chmod(filespec, 0644);
+           return 1;
+       }
     }
 
     return 0;