Traditionally, we'd install packages like these into /usr/local, which is set up with mode 2775 and gid set to the group of users who are allowed to install software. Subdirectories also have the same setup.
Software is actually installed below /usr/local/DIR
, and then symlinked into /usr/local/{bin,sbin,lib,...}
using GNU Stow. If you want split responsibility for "compiling" and "actually making available", you can also give a separate gid to /usr/local/DIR
.
Then for the actual installation, no root permissions are necessary.
If you have two groups, "software" and "install", one-time setup is
# mkdir -p /usr/local/DIR
# chgrp -R install /usr/local
# chgrp -R software /usr/local/DIR
# find /usr/local -exec chmod 664 {} \; -type d -exec chmod 2775 {} \;
Then, any user in the software
group can compile and install to the staging area:
$ ./configure
$ make
$ make install prefix=/usr/local/DIR/package-1.0
Any user in the install
group can make a package from the staging area available:
$ cd /usr/local/DIR
$ stow package-1.0
From a security point of view, this is not an absolute barrier -- any user in the software
group can modify software after it has been installed, and it is likely that root will occasionally run stuff from /usr/local
, so this is more a protection against stupid mistakes and a way to have non-root users provide software for others.
So this isn't a protection against inside threats. Look at your threat model and see where on the risk vs convenience axis you want to be.