From 7a06a9247d52008c1dcf520ee61f316a6c8bdd19 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Thu, 31 Jan 2013 16:04:40 +0000 Subject: [PATCH] When in -U mode do avoid setting SUID bits, but do not modify the mode variable so the intended mode can be logged correctly if -M is specified. Sponsored by: DARPA, AFRL --- usr.bin/xinstall/xinstall.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index a173873be195..15b115abfcc1 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -953,9 +953,8 @@ install(const char *from_name, const char *to_name, u_long fset, u_int flags) } if (mode != (to_sb.st_mode & ALLPERMS)) { - if (dounpriv) - mode &= S_IRWXU|S_IRWXG|S_IRWXO; - if (fchmod(to_fd, mode)) { + if (fchmod(to_fd, + dounpriv ? mode & (S_IRWXU|S_IRWXG|S_IRWXO) : mode)) { serrno = errno; (void)unlink(to_name); errno = serrno;