<?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="envgid">

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

<refnamediv>
<refname>envgid</refname>
<refpurpose>add GID environment variable then chain</refpurpose>
</refnamediv>

<refsynopsisdiv>
<cmdsynopsis>
<command>envgid</command>
<arg choice='req'><replaceable>groupname</replaceable></arg>
<arg choice='req'><replaceable>next-prog</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<refsection><title>Description</title>

<para>
<command>envgid</command> is a chain-loading utility that sets the <envar>GID</envar> environment variable to the value for <replaceable>groupname</replaceable> in the system groups database and then chain loads to <replaceable>next-prog</replaceable> with the <citerefentry><refentrytitle>execvp</refentrytitle><manvolnum>3</manvolnum></citerefentry> function.
</para>

<para>
It unsets the <envar>GIDLIST</envar> environment variable entirely.
</para>

<para>
If it cannot set the environment variables, or cannot find a group named <replaceable>groupname</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>envgid</command> will ignore.
</para>

<para>
The main purpose of <command>envgid</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 groups database.
Instead of running a <citerefentry><refentrytitle>setgid</refentrytitle><manvolnum>1</manvolnum></citerefentry> command and thus forcing the need for a copy of the system password database inside the changed root environment, a chain runs <command>envgid</command> and can obtain the group information from the environment (or run <citerefentry><refentrytitle>setgid-fromenv</refentrytitle><manvolnum>1</manvolnum></citerefentry>) later.
</para>

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

<itemizedlist>
<listitem><para>
<citerefentry><refentrytitle>getuidgid</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para></listitem>
<listitem><para>
<citerefentry><refentrytitle>envuidgid</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para></listitem>
<listitem><para>
<citerefentry><refentrytitle>setuidgid-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>
