Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 01 Jun 2021 01:19:28 +0000
From:      bugzilla-noreply@freebsd.org
To:        ports-bugs@FreeBSD.org
Subject:   [Bug 256233] security/doas: target user's login class gets ignored
Message-ID:  <bug-256233-7788-reQY8dmap9@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-256233-7788@https.bugs.freebsd.org/bugzilla/>
References:  <bug-256233-7788@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D256233

--- Comment #6 from bugs.freebsd@scourger.nl ---
Calling doas with the keepenv flag should indeed keep the language settings
from the caller intact. In the same vein, when a locale is explicitly provi=
ded
though the setenv flag, it should be used.

We also seem to agree that the caller doesn't want 'unexpected' language
changes.
But this is where it gets murky: if no language is passed to doas (by keepe=
nv
or setenv), the language is going to change nonetheless. Without keepenv, I=
 see
two possible outcomes:
1. The environment is cleared, and the command is executed using the "C"
locale. This happens in the current situation (*). I'm not sure if this is =
what
most people would expect.
2. The language from the target user's login class gets used. This is what
initially made more sense to me, because I wasn't expecting the C locale.

(*) Initially, I thought it used the language defined in the default login
class. In reality, it always seems to apply the C locale.


Now that I have given all this a bit more thought, this whole conundrum ste=
ms
from the fact that specifying lang in login.conf is just a way to set a reg=
ular
environment variable. Conversely, doas clears virtually all environment
variables by design. But some essential environment variables will allways =
be
set (regardless of keepenv and setenv), such as DOAS_USER, HOME, TERM, PATH=
 and
SHELL.
Now the big question is: should LANG also be in that list (i.e. considered
essential)?

The way it is now, you'd have to explicitly specify "setenv { LANG }" to ke=
ep
the caller's language or use "setenv { LANG=3Den_US.UTF-8 }" to match bob's
language. When nothing is specified, you'll get the C locale.
Consider if the same thing happened with HOME or SHELL. My guess is that mo=
st
people would argue those shouldn't be reset to the system default, but inst=
ead
use the target user's shell.
Should or shouldn't LANG be handled in the same way as SHELL, TERM or HOME?=
 I'm
not saying it should, but it would definitely make sense to me.=20


Another thing I noticed is that the default PATH is hardcoded in doas (on
FreeBSD). I've checked how this is handled on OpenBSD, and there "doas -u b=
ob
printenv" yields the PATH as defined for bob's login class in /etc/login.co=
nf.
Do you know the reason why is's hardcoded on FreeBSD?

When I look at the behaviour of the original doas on OpenBSD, it appears th=
at
the environment from the target login class is always applied (with the cav=
eat
that OpenBSD lets you specify less options in login.conf compared to FreeBS=
D,
"lang" being one of the missing ones). My guess is that the original design=
 of
doas was to respect environment variables defined in login classes, except
where it really doesn't make sense. Maybe is's a good idea to ask upstream
about this?

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-256233-7788-reQY8dmap9>