runuser(1) and su(1) -g/-G
Karel Zak
maintainerHi,
I did some changes to the su(1):
- add --group= option to specify the primary group
- add --supp-group= option to specify a supplemental group
the both options are based on Fedora runuser(1) patch and it's available for root only (non-root cannot specify any groups).
I have also added new command runuser(1) -- it's completely based on su(1) code. The difference is that runuser does not ask for password, has to be executed by root and it uses different PAM configuration (/etc/pam.d/runuser[-l]).
The changes should be available in v2.23 (or easily backported to 2.22, I'll do that for Fedora).
See master branch and "git whatchanged login-utils/".
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Quoted 8 lines · Karel Zak
Hi,
I did some changes to the su(1):
- add --group= option to specify the primary group
- add --supp-group= option to specify a supplemental group
Quoted 8 lines
the both options are based on Fedora runuser(1) patch and it's available for root only (non-root cannot specify any groups).
I have also added new command runuser(1) -- it's completely based on su(1) code. The difference is that runuser does not ask for password, has to be executed by root and it uses different PAM configuration (/etc/pam.d/runuser[-l]).
Thanks for doing all that Karel.
I've not time to look now,
but will note that many were looking for a lightweight option that didn't need PAM. Perhaps PAM support could be easily compiled out?
cheers,
Pádraig.
Quoted 8 lines
The changes should be available in v2.23 (or easily backported to 2.22, I'll do that for Fedora).
See master branch and "git whatchanged login-utils/".
Karel
Karel Zak
maintainerQuoted 4 lines · Pádraig Brady
Thanks for doing all that Karel. I've not time to look now,
but will note that many were looking for a lightweight option that didn't need PAM.
I know, it should be the second step.
Quoted 1 line
Perhaps PAM support could be easily compiled out?
Not yet. The patch will be pretty simple, all we need is to add something like #ifdef BUILD_LIGHTWEIGHT_RUNUSER to create_watching_parent() and authenticate().
Volunteers? (I'm going to spend this week with coverity scanner...)
Note that we will support PAM-only su(1), maintain alternative authentication code in utils like su(1), login(1), ... is nonsense.
If you don't like modular PAM then you can rebuild libpam with statically linked modules (result is still shared library, but without dlopen()).
The command runuser(1) is different as there is no authentication at all -- it's just wrapper around setuid/gid, and it uses PAM for session setup only.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Quoted 17 lines · Karel Zak
Hi,
I did some changes to the su(1):
- add --group= option to specify the primary group
- add --supp-group= option to specify a supplemental groupthe both options are based on Fedora runuser(1) patch and it's available for root only (non-root cannot specify any groups).
I have also added new command runuser(1) -- it's completely based on su(1) code. The difference is that runuser does not ask for password, has to be executed by root and it uses different PAM configuration (/etc/pam.d/runuser[-l]).
Quoted 7 lines
The changes should be available in v2.23 (or easily backported to 2.22, I'll do that for Fedora).
See master branch and "git whatchanged login-utils/".
Karel
Hi Karel,
I think we're missing out on an opportunity with runuser. su insists on starting a shell which, among other subtle problems, leads to the largeer problem of quoting and escaping the command passed to the -c flag. I think we should do something like this:
- separate out argument parsing to runuser and su
- remove most of the flags from runuser (-f, -c, -l, -, -s), add a -u flag (optional, for user)
- create a single common entry point for creating a session
- separate out the run command logic
With a name like runuser, I would expect that its purpose would be to simply run commands (and not necessarily get a shell for a user, as is done with su). runuser could take non-option arguments as argv for the new command so that we'd have examples like this:
runuser -u notroot vi /etc/fstab
runuser notroot foocmd embedded '"quotes"' runuser -u notroot foocmd has args "with spaces" sometimes
If you still desperately want to abuse the command to create a shell for a user, then you just do that:
runuser -u notroot -- /bin/sh -
I can't make any guarantees that I'll be able to offers patches for this myself, but I'll definitely be taking a look if I have some free time. Just thought I'd bring up the idea, since it's always been a pet peeve of mine to fix if ever there were an opportunity for a mulligan on su (and this is it!).
Cheers,
Dave
Quoted 53 lines · Dave Reisner
Quoted 17 lines · Karel Zak
Hi,
I did some changes to the su(1):
- add --group= option to specify the primary group
- add --supp-group= option to specify a supplemental groupthe both options are based on Fedora runuser(1) patch and it's available for root only (non-root cannot specify any groups).
I have also added new command runuser(1) -- it's completely based on su(1) code. The difference is that runuser does not ask for password, has to be executed by root and it uses different PAM configuration (/etc/pam.d/runuser[-l]).
Quoted 7 lines
The changes should be available in v2.23 (or easily backported to 2.22, I'll do that for Fedora).
See master branch and "git whatchanged login-utils/".
Karel
Hi Karel,
I think we're missing out on an opportunity with runuser. su insists on starting a shell which, among other subtle problems, leads to the largeer problem of quoting and escaping the command passed to the -c flag. I think we should do something like this:
- separate out argument parsing to runuser and su
- remove most of the flags from runuser (-f, -c, -l, -, -s), add a -u flag (optional, for user)
- create a single common entry point for creating a session
- separate out the run command logicWith a name like runuser, I would expect that its purpose would be to simply run commands (and not necessarily get a shell for a user, as is done with su). runuser could take non-option arguments as argv for the new command so that we'd have examples like this:
runuser -u notroot vi
/etc/fstab
runuser notroot foocmd embedded '"quotes"' runuser -u notroot foocmd has args "with spaces" sometimesIf you still desperately want to abuse the command to create a shell for a user, then you just do that:
runuser -u notroot --
/bin/sh-
Quoted 8 lines
I can't make any guarantees that I'll be able to offers patches for this myself, but I'll definitely be taking a look if I have some free time. Just thought I'd bring up the idea, since it's always been a pet peeve of mine to fix if ever there were an opportunity for a mulligan on su (and this is it!).
Cheers,
Dave
Hrmm... I had no idea that runuser was an existing command in the RedHat world, which makes my idea of a "mulligan" less feasible. Boo.
Karel Zak
maintainerQuoted 4 lines · Dave Reisner
Quoted 4 lines
I think we're missing out on an opportunity with runuser. su insists on starting a shell which, among other subtle problems, leads to the largeer problem of quoting and escaping the command passed to the -c flag. I think we should do something like this:
good point
Quoted 5 lines
Quoted 5 lines
- separate out argument parsing to runuser and su
- remove most of the flags from runuser (-f, -c, -l, -, -s), add a -u flag (optional, for user)
- create a single common entry point for creating a session
- separate out the run command logic
well, we still need to initialize the session and it would be also to have independent PAM setting for "login-like-session" (-l - options).
Quoted 5 lines
Quoted 5 lines
With a name like runuser, I would expect that its purpose would be to simply run commands (and not necessarily get a shell for a user, as is done with su). runuser could take non-option arguments as argv for the new command so that we'd have examples like this:
Quoted 8 lines
Quoted 8 lines
runuser -u notroot vi
/etc/fstab
runuser notroot foocmd embedded '"quotes"' runuser -u notroot foocmd has args "with spaces" sometimesIf you still desperately want to abuse the command to create a shell for a user, then you just do that:
runuser -u notroot --
/bin/sh-
well, but it will NOT use /etc/pam.d/runuser-l
I agree that -f -s -c are unnecessary (and -c is wrong at all...). It would be probably better to support:
runuser [-u] notroot [<command> [arg]]
and if <command> is not specified then start a shell, and if -l is specified create a login-like session.
Quoted 2 lines
Hrmm... I had no idea that runuser was an existing command in the RedHat world, which makes my idea of a "mulligan" less feasible. Boo.
Well, that's question if we (upstream) have to care about one crazy distro specific command. Maybe we can introduce a new command (with a different name) and ignore the original runuser. For good reason the command has not been accepted by coreutils upstream.
Any suggestion for the new name?
runuid
runid
execuser
I have no problem to revert the runuser patch, really ;-) It was probably too hasty decision to merge whole my su branch.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com
Quoted 51 lines · Karel Zak
Quoted 4 lines · Dave Reisner
Quoted 4 lines
I think we're missing out on an opportunity with runuser. su insists on starting a shell which, among other subtle problems, leads to the largeer problem of quoting and escaping the command passed to the -c flag. I think we should do something like this:
good point
Quoted 5 lines
Quoted 5 lines
- separate out argument parsing to runuser and su
- remove most of the flags from runuser (-f, -c, -l, -, -s), add a -u flag (optional, for user)
- create a single common entry point for creating a session
- separate out the run command logicwell, we still need to initialize the session and it would be also to have independent PAM setting for "login-like-session" (-l - options).
Quoted 5 lines
Quoted 5 lines
With a name like runuser, I would expect that its purpose would be to simply run commands (and not necessarily get a shell for a user, as is done with su). runuser could take non-option arguments as argv for the new command so that we'd have examples like this:
Quoted 8 lines
Quoted 8 lines
runuser -u notroot vi
/etc/fstab
runuser notroot foocmd embedded '"quotes"' runuser -u notroot foocmd has args "with spaces" sometimesIf you still desperately want to abuse the command to create a shell for a user, then you just do that:
runuser -u notroot --
/bin/sh-well, but it will NOT use
/etc/pam.d/runuser-lI agree that -f -s -c are unnecessary (and -c is wrong at all...). It would be probably better to support:
runuser [-u] notroot [<command> [arg]]
and if<command> is not specified then start a shell, and if -l is specified create a login-like session.
Quoted 2 lines
Hrmm... I had no idea that runuser was an existing command in the RedHat world, which makes my idea of a "mulligan" less feasible. Boo.
Well, that's question if we (upstream) have to care about one crazy distro specific command. Maybe we can introduce a new command (with a different name) and ignore the original runuser. For good reason the command has not been accepted by coreutils upstream.
Any suggestion for the new name?
Quoted 9 lines
runuid
runid
execuserI have no problem to revert the runuser patch, really ;-) It was probably too hasty decision to merge whole my su branch.
Karel
I'd not really studied the runuser interface to be honest, and yes I agree that it's quite crufty.
Maybe we could keep the runuser name and say
the prefered form is to specify -u $USER, which will _not_ start a shell. The old interface without -u being retained for backwards compat?
For reference, I'm copying in below some info from the coreutils list from when we were discussing the transition of su to util-linux, which references other utils in this space.
==== info from coreutils ===
Note Fedora and Suse use su from coreutils
while debian use their own:
http://pkg-shadow.alioth.debian.org/
Note also Fedora has runuser which is based on su:
http://pkgs.fedoraproject.org/gitweb/?p=coreutils.git;a=blob;f=coreutils-8.7-runuser.patch;hb=HEAD
There was also a very related request for runuser like functionality to be generally available:
http://bugs.gnu.org/8700
It's probably worth bringing runuser with su,
no matter where they end up. So with su being removed in favor of the util-linux implementation, runuser is being implemented there too. I.E. it will be available outside of redhat/fedora/centos/... in util-linux >= 2.23, and so should address http://bugs.gnu.org/8700
[well maybe not given the above discussion]
Note from previous comments in this thread,
it seems like allowing runser to be built (as an option?) without requiring PAM, would be useful.
For reference, here are utils with similar functionality:
chid,really
Mentioned in feature request from debian
http://bugs.gnu.org/8700
chroot --userspec=U:G --groups=G1,G2,G3 /
since coreutils v7.4-16-gc45c51f
beware of CVE-2005-4890
setuidgid
coreutils internal only
http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/setuidgid.c;hb=HEAD
sg from pwdutils
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/newgrp.html
sudo -u -g
runas from titantools
cheers,
Pádraig.
Quoted 33 lines · Karel Zak
Quoted 4 lines · Dave Reisner
Quoted 4 lines
I think we're missing out on an opportunity with runuser. su insists on starting a shell which, among other subtle problems, leads to the largeer problem of quoting and escaping the command passed to the -c flag. I think we should do something like this:
good point
Quoted 5 lines
Quoted 5 lines
- separate out argument parsing to runuser and su
- remove most of the flags from runuser (-f, -c, -l, -, -s), add a -u flag (optional, for user)
- create a single common entry point for creating a session
- separate out the run command logicwell, we still need to initialize the session and it would be also to have independent PAM setting for "login-like-session" (-l - options).
Quoted 5 lines
Quoted 5 lines
With a name like runuser, I would expect that its purpose would be to simply run commands (and not necessarily get a shell for a user, as is done with su). runuser could take non-option arguments as argv for the new command so that we'd have examples like this:
Quoted 8 lines
Quoted 8 lines
runuser -u notroot vi
/etc/fstab
runuser notroot foocmd embedded '"quotes"' runuser -u notroot foocmd has args "with spaces" sometimesIf you still desperately want to abuse the command to create a shell for a user, then you just do that:
runuser -u notroot --
/bin/sh-well, but it will NOT use
/etc/pam.d/runuser-l
Quoted 7 lines
I agree that -f -s -c are unnecessary (and -c is wrong at all...). It would be probably better to support:
runuser [-u] notroot [<command> [arg]]
and if <command> is not specified then start a shell, and if -l is specified create a login-like session.
I like all this.
Quoted 9 lines
Quoted 3 lines
Hrmm... I had no idea that runuser was an existing command in the RedHat world, which makes my idea of a "mulligan" less feasible. Boo.
Well, that's question if we (upstream) have to care about one crazy distro specific command. Maybe we can introduce a new command (with a different name) and ignore the original runuser. For good reason the command has not been accepted by coreutils upstream.
Quoted 5 lines
Any suggestion for the new name?
runuid
runid
execuser
I'm digging deep, back to my windows admin days -- perhaps 'runas'? Maybe something shorter? Could we use 'ru' (a step back!) for irony? ;P
Quoted 12 lines
I have no problem to revert the runuser patch, really ;-) It was probably too hasty decision to merge whole my su branch.
Karel
Signature · 6 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Pádraig Brady
setuidgid
coreutils internal only
The name setuidgid for this tool was introduced by daemontools, and various other projects have have their own versions of it:
http://cr.yp.to/daemontools/setuidgid.html
http://www.skarnet.org/software/s6/s6-setuidgid.html
http://b0llix.net/perp/site.cgi?page=runuid.8
http://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=blob;f=src/setuidgid.c
http://offog.org/darcs/freedt/setuidgid.c
(It would often be helpful for the tool to do a bit more than just setting the uid and gids -- e.g. setting $HOME...)
perp has a suite of "runtools" like this that do some sort of environment setup before execing another program:
http://b0llix.net/perp/site.cgi?page=manual
The most useful ones (for me!) have equivalents in util-linux already:
- runsession is setsid;
- runlimit is prlimit;
- runlock is flock -- but flock only has an su-style -c argument, so it would probably be worth fixing that at the same time as runuser?
Thanks,
Signature · 1 line
Adam Sampson <[email protected]> <http://offog.org/>
Karel Zak
maintainerQuoted 4 lines · Pádraig Brady
Maybe we could keep the runuser name and say the prefered form is to specify -u $USER, which will _not_ start a shell. The old interface without -u being retained for backwards compat?
Good idea. Implemented, see below. The su-like options -c/C, -l and -f are mutually exclusive to -u.
(and sorry for coding style. I'm absolutely incompatible with the
original code -- when all the changes will be in master branch we'll use indent to make it readable for lovers of the kernel-style ...)
Karel
Quoted 1 line
From
6ec71facf066ade0c42b98b274d041c6e0ed6d8cMon Sep 17 00:00:00 2001
From: Karel Zak <[email protected]>
Date: Thu, 13 Sep 2012 11:58:00 +0200
Subject: [PATCH] runuser: add -u to not execute shell
--- login-utils/runuser.1 | 20 +++++--- login-utils/su-common.c | 138 +++++++++++++++++++++++++++++++---------------- login-utils/su.1 | 1 + 3 files changed, 105 insertions(+), 54 deletions(-)
login-utils/runuser.1 +13 -7
@@ -3,10 +3,21 @@ runuser \- run a command with substitute user and group ID .SH SYNOPSIS .B runuser -[options...] [\-] [user [args...]] +[options] -u +.IR user +.IR "command " [ argument ...] +.LP +.B runuser +[options] [-] +[ +.IR "user " [ argument ...] +] .SH DESCRIPTION .B runuser allows to run commands with substitute user and group ID. +If the option \fB\-u\fR not given, fallback to +.B su +compatible semantic and shell is executed. The difference between the commands .B runuser and
@@ -37,12 +48,7 @@ and .B LOGNAME if the target .I user -is not root). It is recommended to always use the -.B \-\-login -option (instead it's shortcut -.BR \- ) -to avoid side effects caused by mixing environments. -.PP +is not root). This version of .B runuser uses PAM for session management.
login-utils/su-common.c +91 -47
199 lines not on this page · raw message
login-utils/su.1 +1 -0
@@ -216,6 +216,7 @@ command specific logindef config file global logindef config file .PD 1 .SH "SEE ALSO" +.BR runuser (8), .BR pam (8), .BR shells (5), .BR login.defs (5)
Signature · 1 line
1.7.7.6