[bug #68587] Prefer runuser over su

Andreas Metzler <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
Follow-up Comment #2, bug #68587 (group findutils):

Hello,

thank you for review and enhancements.
[comment #1 Kommentar #1:]
[...]
>> # figure out if su supports the -s option
>> select_shell() {
>> -    if su "$1" -s $SHELL -c false < /dev/null  ; then
>> +    if [ "$updatedbuserchange" = "runuser" ] ; then
>> +       echo "-s $SHELL"
>> +    elif su "$1" -s $SHELL -c false < /dev/null  ; then
>> # No.
>> echo ""

> This does not test whether runuser(1) actually works or not.

Afaict your version of the patch does not check that either. It adds a test
for whether runuser -s $SHELL ... works or not. The outcome of this tests
changes whether runsuser is invoked with -s $SHELL later. It does not test
whether runuser works, if it is available it is used.

To my knowledge there is no alternative implementation, no other binary called
runuser. That is why I intentionally left out testing whether -s was supported
for the runuser case. - If we find runuser it is the one
from util-linux and even in the very first incarnation it had the -s option. I
*think* the case for su is different. - It has been around forever with
multiple possibly incompatible implementations.

> E.g. if some regular user's PATH includes /sbin, then which(1) below would
> find the tool, but it still would not work.

> $ /sbin/runuser someuser - true
> runuser: may not be used by non-root users

Perhaps this might be handled by additionally checking whether $(id -u) is 0?

if which runuser >/dev/null 2>&1 && [ "$(id -u)" = "0" ] ; then
    updatedbuserchange=runuser
else
    updatedbuserchange=su
fi

[...]
>> +if which runuser 2>&1 ; then
>> +    updatedbuserchange=runuser
>> +else
>> +    updatedbuserchange=su
>> +fi
>> +


> I'm not sure about this redirection of stderr to stdout.
> Did you mean

> if which runuser >/dev/null 2>&1 ; then

> ?
[...]
Yes exactly.
cu Andreas


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68587>

_______________________________________________
Nachricht gesendet über Savannah
https://savannah.gnu.org/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaniuuwAKCRCqLAuaBUf3
TiySAP9o2FwLNWWxvJ3ry+vSdv1PwCqTxI+XZ3+ZAd1agOK6egD/V+Tu4x/1T9L1
cjMVF41j6IeXFxvjTIQH43rI6ii0UgI=
=7jRr
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.