<?xml version="1.0" encoding="UTF-8"?>
<!-- **************************************************************************
.... For copyright and licensing terms, see the file named COPYING.
.... **************************************************************************
.-->
<?xml-stylesheet href="docbook-xml.css" type="text/css"?>

<refentry id="envuidgid">

<refmeta xmlns:xi="http://www.w3.org/2001/XInclude">
<refentrytitle>envuidgid</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="manual">user commands</refmiscinfo>
<refmiscinfo class="source">nosh</refmiscinfo>
<xi:include href="version.xml" />
</refmeta>

<refnamediv>
<refname>envuidgid</refname>
<refpurpose>set UID, GID, and GIDLIST environment variables then chain</refpurpose>
</refnamediv>

<refsynopsisdiv>
<cmdsynopsis>
<command>envuidgid</command>
<arg choice='opt'>--primary-group <replaceable>group</replaceable></arg>
<arg choice='opt'>--supplementary</arg>
<arg choice='req'><replaceable>account</replaceable></arg>
<arg choice='req'><replaceable>next-prog</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<refsection><title>Description</title>

<para>
<command>envuidgid</command> is a chain-loading utility that sets the <envar>UID</envar> and <envar>GID</envar> environment variables to the values for <replaceable>account</replaceable> in the system account database and then chain loads to <replaceable>next-prog</replaceable> with the <citerefentry><refentrytitle>execvp</refentrytitle><manvolnum>3</manvolnum></citerefentry> function.
</para>

<note>
<command>envuidgid</command> intentionally does not set the <envar>LOGNAME</envar> environment variable.
It does not deal in login sessions, and is not altering the "login name".
</note>

<para>
If the <arg choice='plain'>--primary-group</arg> option is used, <command>envuidgid</command> will use <replaceable>group</replaceable> instead of the primary GID of <replaceable>account</replaceable> as the <envar>GID</envar> value.
</para>

<para>
If the <arg choice='plain'>--supplementary</arg> option is used, it will also set the <envar>GIDLIST</envar> environment variable to the (comma-separated) list of supplementary GIDs for the groups to which account belongs, as listed in the groups database.
Without that option, it ignores the group database and unsets the <envar>GIDLIST</envar> environment variable entirely.
</para>

<para>
If it cannot set the environment variables, or cannot find an account named <replaceable>account</replaceable> in the database, it does not chain and exits with status code 111.
</para>

<para>
<replaceable>next-prog</replaceable> may contain its own command line options, which <command>envuidgid</command> will ignore.
</para>

<para>
The main purpose of <command>envuidgid</command> is to eliminate the need for a process that has run <citerefentry><refentrytitle>chroot</refentrytitle><manvolnum>1</manvolnum></citerefentry> to read from the system account database.
Instead of running <citerefentry><refentrytitle>setuidgid</refentrytitle><manvolnum>1</manvolnum></citerefentry> and thus forcing the need for a copy of the system password database inside the changed root environment, a chain runs <command>envuidgid</command> and can obtain the account information from the environment (or run <citerefentry><refentrytitle>setuidgid-fromenv</refentrytitle><manvolnum>1</manvolnum></citerefentry>) later.
</para>

</refsection><refsection><title>See also</title>

<itemizedlist>
<listitem><para>
<citerefentry><refentrytitle>envgid</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para></listitem>
<listitem><para>
<citerefentry><refentrytitle>setgid-fromenv</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para></listitem>
</itemizedlist>

</refsection><refsection><title>Author</title>
<para><author><personname><firstname>Jonathan</firstname> <surname>de Boyne Pollard</surname></personname></author></para>
</refsection>

</refentry>
