OpenBSD Journal

Package building without sudo (part 2)

Contributed by jj on from the working-with-uid-thousand-plus dept.

Christian Weisgerber (naddy@) writes in:
As of September 23, all OpenBSD ports can be individually built without sudo(1).

Back at the g2k14 hackathon, I worked on removing the need to run the fake install step as root. Afterwards, Marc Espie picked up my prototype, identified the remaining problems in the ports tree, and finished the implementation. One missing piece was a small wrapper script around install(1) that is placed into ${WRKDIR}/bin at the front of PATH and simply throws away the -o and -g arguments, so we won't need to patch build frameworks that try to enforce a particular ownership. On September 16, the default was switched to building without sudo(1), and within a week the remaining ports that had required special treatment were fixed. Note that this only applies to building the port itself.

Root permissions are still needed to pkg_add(1) dependencies and, during dpb(1) bulk builds, to pkg_delete(1) them again.

The central knob that governs how the fake install step runs is FAKE_AS_ROOT. There are three valid settings:
  • "No". The default: the fake install is run as the same user as the rest of the build. This avoids the risk that a build problem could splatter files all over the directory hierarchy and corrupt the system. When the package is created, the user's UID and GID are replaced with root:bin in the archive. For files that require different IDs, these can be set with @owner and @group annotations in the PLIST, along with @mode for the rare setuid or setgid executable.
  • "Always-wrap". This is a special setting used by a very few ports (PostgresQL, Ruby). Their build framework embeds the full path of the install(1) executable into the package, and that path is then used by dependent ports. We make sure that it points to the permanent location of our install wrapper script.
  • "Yes". This is the historical behavior: the fake install is run as root. It may still come in handy when creating a new port, in particular one that chown(1)s components to special users.

(Comments are closed)


Comments
  1. By David Gwynne (dlg) dlg@openbsd.org on

    very cool.

    could you log what the owner and group arguments given to the install wrapper are? then there would be less need for root when writing ports and figuring out the right things for the plist.

Credits

Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original deadly.org with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]