supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: "Laurent Bercot" <ska-supervision@skarnet.org>
To: "joaog.bastos" <joaog.bastos@protonmail.ch>,
	supervision <supervision@list.skarnet.org>
Subject: Re: Why are there 3 programs in s6 that do the same thing?
Date: Tue, 29 Dec 2020 19:16:15 +0000	[thread overview]
Message-ID: <emdb200d46-0c10-4f41-9be0-69460d4ca9af@elzian> (raw)
In-Reply-To: <ZtyLiqPMe68NyoEsq_wSWa81yrTy7qJKcrjElgzVSkS5pefLTs7F_A48hV5iT7PJPqmbwzq7ZSkVaCFe4J_87vitgNdRflFp2ZH7nwD0yU0=@protonmail.ch>

>s6 has three programs to set UID / GID of a process: s6-setuidgid, s6-applyuidgid and s6-envuidgid. All three of those seem to do the same thing, with some *slight* differences. Why are all three included in s6?

  Those three programs don't do the same thing at all. They do *related*
things; and one of them is a wrapper around the other two.

  There are two different operations at play here:

  1. get the uid, gid and additional groups from the pwd/grp database
for a given username. It is a data retrieval operation with no impact
on the process state (save the storage of the information in the
environment, for later use by other programs in the chainloaded
command line). This is what s6-envuidgid does.

  2. actually change the current process' uid, gid and additional groups.
There is no data retrieval here, but there is a process state change.
This is what s6-applyuidgid does.

  Those two operations are distinct because you may want to set the
uid, gid and additional groups of a process to something that does not
exist in the current user database: think containers, or 
cross-compiling.
Roughly speaking, s6-envuidgid reads data from the "host", but
s6-applyuidgid performs a process state change on the "target".

  That said, in common cases you want to perform both operations at
once: and this is what s6-setuidgid does.

  Originally, there were only s6-setuidgid and s6-envuidgid, as direct
adaptations from daemontools' setuidgid and envuidgid. However, it
soon appeared that those two programs did not encapsulate the set of
operations that s6 needs to do, and a program was needed that would
only perform the process state change. Which is why s6-applyuidgid
was added; and then, in order to save code, s6-setuidgid was rewritten
as a wrapper around s6-envuidgid and s6-applyuidgid.

--
  Laurent


  reply	other threads:[~2020-12-29 19:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-29 17:12 joaog.bastos
2020-12-29 19:16 ` Laurent Bercot [this message]
2020-12-31 22:59   ` Jonathan de Boyne Pollard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=emdb200d46-0c10-4f41-9be0-69460d4ca9af@elzian \
    --to=ska-supervision@skarnet.org \
    --cc=joaog.bastos@protonmail.ch \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).