Bug 55219

Summary: /sbin/nologin kills "easy" setuid with like 'su - nobody -c "command"
Product: [Retired] Red Hat Linux Reporter: Pekka Savola <pekkas>
Component: setupAssignee: Bill Nottingham <notting>
Status: CLOSED WONTFIX QA Contact: David Lawrence <dkl>
Severity: high Docs Contact:
Priority: medium    
Version: 7.2CC: nalin, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-01-28 06:44:28 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 136921    

Description Pekka Savola 2001-10-27 12:57:41 UTC
As 'nobody' was changed to use /sbin/nologin, instead of empty, certain things broke badly.

You can no longer build "cheap" setuid solutions with constructs like:

su - nobody -c "command"

This may break very many local daemon initializations (typically from /etc/rc.d/rc.local), as only this is printed:

This account is currently not available.

Possible courses of action:

1) change nobody's shell to empty, or

2) create a small wrapper binary with c (e.g. /usr/bin/setid or /bin/setid) to perform basically the following (about 10-20 lines):
 * takes arguments and one option
 * first argument is always the userid to change the identity to
 * the rest of the arguments would be stored as a command.
 * the option, if present, could toggle whether the command is run through exec or system (default to exec?).
 * setuid, setgid and initgroups to the specified user
 * exec or system the command

as far as I can see, this could provide a scalable and nice way to get the similar behaviour.  Optionally, it could also take an option for 
additional chroot.  The permissions would be 0750 root.root.

3) ignore the problem

Comment 1 Bill Nottingham 2002-01-25 05:06:57 UTC
Nalin, any opinions?

Comment 2 Daniel Reed 2004-10-25 20:58:19 UTC
It is now the case that "su nobody -c command" (as opposed to "su - nobody -c
command") fails with the same error message. This causes root wrappers, such as
the one used by FreeCiv, to silently fail in X.

I last successfully used FreeCiv's root wrapper within the past month or so, but
I just recently noticed the failure. Changing nobody's shell to /bin/true causes
"su nobody -c command" to silently noop (no error message at all, but "command"
is not executed). Changing nobody's shell to /bin/bash allows "su nobody -
command" (and I can confirm it restores FreeCiv's root wrapper).

Comment 3 Bill Nottingham 2005-01-28 06:44:28 UTC
At this point, I don't think this behavior will be changed; it's been
this way for too many releases. Note that running multiple things as
nobody does not allow protections between them; best practices is to
allocate separate UIDs for each different setuid situation needed.