[rb-general] Remaining reprotest variations

Ed Maste emaste at freebsd.org
Mon Aug 22 17:20:20 CEST 2016


On 27 July 2016 at 17:18, Ceridwen <ceridwen.mailing.lists at gmail.com> wrote:
>
> 1. user_group.  The POSIX standard includes the notion of user/group
> ids, but the only ways it defines to change the uid/gid of processes
> are C functions.  Unfortunately, there's also nothing in the POSIX
> standard for creating users, though at least `chown` is.  At the
> moment, my plan is to use `useradd`, `groupadd`, `userdel`,
> `groupdel`, and `su`.  (Using 'sudo' like prebuilder does is more
> complicated and less likely to be supported everywhere.)  I'm going to
> set the ids to something like 20000.  This page,
> http://bhami.com/rosetta.html, indicates that this won't work on
> FreeBSD or MacOS X, and thatis supported by these pages,
> http://www.math.utah.edu/~beebe/unix/g/groupadd.html and
> http://www.math.utah.edu/~beebe/unix/u/useradd.html.
>     - What works on FreeBSD/MacOS X?

On FreeBSD these are subcommands of pw(8), and shell scripts are
included to provide a slightly more convenient user interface (e.g.
adduser, rmuser). useradd, groupadd, userdel, groupdel are supported
subcommands. Usage details are in the man page, online at
https://www.freebsd.org/cgi/man.cgi?pw(8)
 rmuser [-yv] [-f file] [username ...]

> The prebuilder script also modifies `/etc/hosts`.
>     - Is modifying /etc/hosts necessary in general?
>     - If so, is it portable?

I think it will work fine on FreeBSD.

> 3. bin_sh.  prebuilder uses dpkg-reconfigure here, which doesn't work
> for reprotest.
>     - Is it safe to assume that /bin/sh is a symlink?

It's safe to assume that /bin/sh exists, but not that it's a symlink.
On FreeBSD /bin/sh is a minimal Bourne shell, similar to what's
installed as dash on Debian.

>     - What shells should be available on most POSIX systems?

For the purpose of scripts I think you want to count on only a minimal
/bin/sh. The FreeBSD base system also includes tcsh; no other shells
are installed by default, although many systems will also have bash
installed as a lot of third party scripts include bashisms.

>     - If so, Is there a portable way to determine what shells are
> available?

On FreeBSD all of the shells are listed in /etc/shells; I'm not sure
what other systems do.

> 4. user_shell: prebuilder uses `usermod`, but there's also `chsh`.
> `chsh` looks a little more common:
> http://www.math.utah.edu/~beebe/unix/c/chsh.html
> vs. http://www.math.utah.edu/~beebe/unix/u/usermod.html.  I also don't
> know if all versions of `usermod` support the -s option.
>     - Will `chsh` work here?
>     - If not, has `usermod`'s portability improved?

As above, FreeBSD has a usermod subcommand in pw(8). chsh opens an
editor for interactive editing.

> 5. kernel: While `uname` is in the POSIX standard, mechanisms for
> altering its output aren't.  `setarch`, what prebuilder uses and what
> reprotest uses at the moment, is Linux-specific.
>     - What methods of changing `uname` will work on other OSes?

On FreeBSD uname output can be overridden with UNAME_<flag>
environment variables. For example:

% uname -s
FreeBSD
% UNAME_s=Debian uname -s
Debian


More information about the rb-general mailing list