Subject: Using su in bsd.pkg.mk
To: None <tech-pkg@netbsd.org>
From: Alistair G. Crooks <agc@ftp.netbsd.org>
List: tech-pkg
Date: 03/31/1999 03:27:55
I've just committed some changes to bsd.pkg.mk which make it possible
to run as non-root user during fetching, configuration, and building
of packages. At "make install" time, if the user's effective UID is not
zero, then ${SU_CMD} is called, (it defaults to "su - root -c"), and
the "make install" is done with an euid of zero. This only happens
during interactive builds/installations - ${BATCH} builds are the same
as before.

Prior to calling ${SU_CMD}, there's a hook called ${PRE_ROOT_CMD},
which can be used to assign write-access to root on -noroot mounted
NFS filesystems, for example.

This modification also allows pre-req packages (the DEPENDS ones) to
be installed whilst building the original package as non-root.

I don't envisage any problems, and this has been running fine for
me for a number of days.  However, if anything untoward should
occur, please send-pr as usual.

Example output follows.

Thanks,
Alistair

% bmake install FORCE_PKG_REGISTER=1
*** WARNING *** Running: /usr/bin/chmod -R o+w /u/crooksa/NetBSD/pkgsrc/graphics/jpeg/work
Becoming root to install jpeg-6b.
Password:
===>  Warning: your umask is "02".
      If this is not desired, set it to an appropriate value (0022)
      and install this port again by ``/usr/local/bsd/bin/bmake deinstall reinstall''.
/usr/ucb/install -c -o root -g sys -m 644 jconfig.h /usr/local/include/jconfig.h
/usr/ucb/install -c -o root -g sys -m 644 ./jpeglib.h /usr/local/include/jpeglib.h
/usr/ucb/install -c -o root -g sys -m 644 ./jmorecfg.h /usr/local/include/jmorecfg.h
/usr/ucb/install -c -o root -g sys -m 644 ./jerror.h /usr/local/include/jerror.h
...