From 2c31a7a90151487ef197a30a3fa12129d9b68d2f Mon Sep 17 00:00:00 2001 From: root Date: Tue, 4 Jun 1996 22:53:56 +0000 Subject: [PATCH] fixed chmod(symlink) bug CVS patchset: 605 CVS date: 1996/06/04 22:53:56 --- lib/install.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/install.c b/lib/install.c index 465967f..f567415 100644 --- a/lib/install.c +++ b/lib/install.c @@ -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; -- 2.7.4