Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Mark Hatle <mark.hatle@windriver.com>
To: <julian.pidancet@gmail.com>,
	<openembedded-core@lists.openembedded.org>,
	Scott Garman <scott.a.garman@intel.com>,
	<pkg-shadow-devel@lists.alioth.debian.org>
Subject: Re: --root option in upstream shadow
Date: Wed, 26 Oct 2011 16:04:09 -0500	[thread overview]
Message-ID: <4EA875C9.6020400@windriver.com> (raw)
In-Reply-To: <20111026205113.GB25451@nekral.nekral.homelinux.net>

On 10/26/11 3:51 PM, Nicolas François wrote:
> Hi,
> 
> On Mon, Oct 24, 2011 at 01:06:11AM +0100, julian.pidancet@gmail.com wrote:
>> On Sat, Oct 22, 2011 at 12:54 PM, Nicolas François
>> <nicolas.francois@centraliens.net> wrote:
>>>
>>> What is the expected behavior when the utility authenticates the caller?
>>>  1] authenticate the caller in the caller's chroot
>>>  2] authenticate the caller in the target's chroot
>>>  3] both
>>>
>>> I currently think that 3] would be the right behavior: the caller needs to
>>> be authenticated to make sure it is allowed to use the tool, then it
>>> should be authenticated on the target to make sure the operation is
>>> allowed.
>>> ...But this is much more complex.
>>>
>>> If this is fine for you, I would prefer to disable this feature when the
>>> utility is setuid and not executed by root.
>>>
>>
>> I'm affraid this patch does not do what you think it does. The --root
>> option does not apply to login, but only to the various administrative
>> tools that comes with it (gpasswd, groupadd, groupdel, groupmod,
>> grpconv, grpunconv, passwd, pwconv, pwunconv, useradd, userdel).
> 
> I understand this correctly.
> 
> Lets take the passwd use case.
> passwd usually authenticates the caller (when UID==0, this authentication
> is usually skipped), then asks for the new password, then update the
> password databases.
> passwd is suid and can be used by non root users to change the caller's
> password. What should be the behavior of passwd is such case?
> With the current patch, an user with UID 1000 will be allowed to change the
> password of the user from the target chroot with the same UID 1000. 

The existing behavior we use in OpenEmbedded-core is emulate root user (we do
this by call intercepting, and avoiding suid/sgid)..  But under the hood, it all
comes down to file permissions.  If we have permission to modify the file we do
-- otherwise it fails.  This is equivalent to the root user.

There are reasonable cases where a non-root user (with permission to modify the
passwd/group file within a chroot) will want to do so..  This sounds like a
security flaw, but it's not because the permissions are added to the chroot
after the filesystem is finished being constructed.

> In the patched tools you indicated, gpasswd is also suid.
> And all the others can be suid when configured with
> --enable-account-tools-setuid
> 
> My proposal is to only support --root for root. For non suid utils,
> regular users will be denied chroot anyway, hence: "disable this feature
> when the utility is setuid and not executed by root."

I agree, with setuid it doesn't make sense to allow --root functionality.  Would
it be reasonable to drop the setuid/gid if the user attempts --root
functionality.  Internally act as if the user is root and then simply allow the
filesystem dictate success or failure?

> In your use case (for packaging), I assume the tools are always called by
> root. Then this restriction should not affect you.

The tool THINKS it's called as root, but it's actually called as a user.  (We
use a utility called pseudo that intercepts calls and emulated root capabilities.)

But some of our embedded requirements are unique to our build environments.  So
if the default action is only root can perform the --root command, we can easily
remove the check -- or change it that it doesn't function if setuid for our
purposes.  (but with pseudo I don't think this will be an issue.)

>> It allows OE to manipulate passwd and group files that are located in
>> a sysroot by chrooting into it, because all these programs have their
>> path to /etc/passwd and friends hardcoded.
> 
> The advantage is not only that the destination user/group files are
> changed, but also that they are changed considering the configuration of
> the target system (e.g. PAM, /etc/login.defs, ...)

Absolutely!

Thanks.  Anything we can do to get this upstream will make it much easier for us
in the long term.

--Mark

> Best Regards,




      reply	other threads:[~2011-10-26 21:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20111022115412.GM16703@nekral.nekral.homelinux.net>
2011-10-24  0:06 ` --root option in upstream shadow Julian Pidancet
2011-10-26 20:51   ` Nicolas François
2011-10-26 21:04     ` Mark Hatle [this message]

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=4EA875C9.6020400@windriver.com \
    --to=mark.hatle@windriver.com \
    --cc=julian.pidancet@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=pkg-shadow-devel@lists.alioth.debian.org \
    --cc=scott.a.garman@intel.com \
    /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