Subject: bin/4554: version of install that ignore root priveledge needed
To: None <gnats-bugs@gnats.netbsd.org>
From: Michael C. Richardson <mcr@ssh.fi>
List: netbsd-bugs
Date: 11/21/1997 12:30:44
>Number:         4554
>Category:       bin
>Synopsis:       -DMORTAL avoids any need for root
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 21 02:35:08 1997
>Last-Modified:
>Originator:     Michael Richardson
>Organization:
Sandelman Software Works Corp
>Release:        1.2
>Environment:
	
System: NetBSD ovi.ssh.fi 1.2 NetBSD 1.2 (TAULU) #50: Mon Feb 24 21:40:52 EET 1997 kivinen@taulu.ssh.fi:/usr/src/sys/arch/i386/compile/TAULU i386


>Description:
	/usr/bin/install in a build tree wants to set ownership
	and set the immutable flags, etc. This is a pain if one
	isn't root, or is over NFS, and just wants to build.
>How-To-Repeat:
>Fix:
	
*** ../usr/src/usr.bin/xinstall/xinstall.c	Thu Nov 20 11:46:19 1997
--- xinstall.c	Thu Nov 20 12:14:52 1997
***************
*** 220,229 ****
--- 220,231 ----
  		 * off the append/immutable bits -- if we fail, go ahead,
  		 * it might work.
  		 */
+ #ifndef MORTAL		
  #define	NOCHANGEBITS	(UF_IMMUTABLE | UF_APPEND | SF_IMMUTABLE | SF_APPEND)
  		if (to_sb.st_flags & NOCHANGEBITS)
  			(void)chflags(to_name,
  			    to_sb.st_flags & ~(NOCHANGEBITS));
+ #endif		
  		(void)unlink(to_name);
  	}
  	install(*argv, to_name, fset, iflags);
***************
*** 335,343 ****
--- 337,347 ----
  	 * off the append/immutable bits -- if we fail, go ahead,
  	 * it might work.
  	 */
+ #ifndef MORTAL	
  	if (stat(to_name, &to_sb) == 0 &&
  	    to_sb.st_flags & (NOCHANGEBITS))
  		(void)chflags(to_name, to_sb.st_flags & ~(NOCHANGEBITS));
+ #endif	
  	(void)unlink(to_name);
  
  	if (dolink) {
***************
*** 370,375 ****
--- 374,380 ----
  		  err(1, "stripping %s", to_name);
  	}
  
+ #ifndef MORTAL
  	/*
  	 * Set owner, group, mode for target; do the chown first,
  	 * chown may lose the setuid bits.
***************
*** 379,390 ****
--- 384,398 ----
  		(void)unlink(to_name);
  		errx(1, "%s: chown/chgrp: %s", to_name, strerror(serrno));
  	}
+ #endif
+ 	
  	if (fchmod(to_fd, mode)) {
  		serrno = errno;
  		(void)unlink(to_name);
  		errx(1, "%s: chmod: %s", to_name, strerror(serrno));
  	}
  
+ #ifndef MORTAL
  	/*
  	 * If provided a set of flags, set them, otherwise, preserve the
  	 * flags, except for the dump flag.
***************
*** 394,399 ****
--- 402,408 ----
  		if (errno != EOPNOTSUPP || (from_sb.st_flags & ~UF_NODUMP) != 0)
  			warn("%s: chflags", to_name);
  	}
+ #endif
  
  	(void)close(to_fd);
  	if (!docopy && !devnull && unlink(from_name))
>Audit-Trail:
>Unformatted: