* [PATCH] bash-completion: Fix su
@ 2020-10-08 6:50 Stanislav Brabec
2020-10-08 7:53 ` Karel Zak
0 siblings, 1 reply; 5+ messages in thread
From: Stanislav Brabec @ 2020-10-08 6:50 UTC (permalink / raw)
To: Util-Linux; +Cc: jun wang
Fix su -s <tab> that reports invalid chsh -l.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Reported-by: jun wang <junguo.wang@suse.com>
---
bash-completion/su | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bash-completion/su b/bash-completion/su
index 309505085..9049b4888 100644
--- a/bash-completion/su
+++ b/bash-completion/su
@@ -14,7 +14,7 @@ _su_module()
return 0
;;
'-s'|'--shell')
- COMPREPLY=( $(compgen -W "$(chsh -l)" -- $cur) )
+ COMPREPLY=( $(compgen -W "$(</etc/shells)" -- $cur) )
return 0
;;
'-h'|'--help'|'-V'|'--version')
--
2.28.0
--
Best Regards / S pozdravem,
Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o. e-mail: sbrabec@suse.com
Křižíkova 148/34 (Corso IIa) tel: +420 284 084 060
186 00 Praha 8-Karlín fax: +420 284 084 001
Czech Republic http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] bash-completion: Fix su
2020-10-08 6:50 [PATCH] bash-completion: Fix su Stanislav Brabec
@ 2020-10-08 7:53 ` Karel Zak
2020-10-08 21:50 ` Sami Kerola
2020-10-13 15:15 ` Stanislav Brabec
0 siblings, 2 replies; 5+ messages in thread
From: Karel Zak @ 2020-10-08 7:53 UTC (permalink / raw)
To: Stanislav Brabec; +Cc: Util-Linux, jun wang
On Thu, Oct 08, 2020 at 08:50:39AM +0200, Stanislav Brabec wrote:
> Fix su -s <tab> that reports invalid chsh -l.
"cat /etc/shells" and "chsh -l" get the same output on my system, why
"chsh -l" is invalid?
chsh -l uses getusershell() glibc function.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bash-completion: Fix su
2020-10-08 7:53 ` Karel Zak
@ 2020-10-08 21:50 ` Sami Kerola
2020-10-13 15:15 ` Stanislav Brabec
1 sibling, 0 replies; 5+ messages in thread
From: Sami Kerola @ 2020-10-08 21:50 UTC (permalink / raw)
To: Karel Zak; +Cc: Stanislav Brabec, Util-Linux, jun wang
On Thu, 8 Oct 2020 at 08:55, Karel Zak <kzak@redhat.com> wrote:
> On Thu, Oct 08, 2020 at 08:50:39AM +0200, Stanislav Brabec wrote:
> > Fix su -s <tab> that reports invalid chsh -l.
>
> "cat /etc/shells" and "chsh -l" get the same output on my system, why
> "chsh -l" is invalid?
>
> chsh -l uses getusershell() glibc function.
I guess "$(</etc/shells)" was done to avoid exec, but it is not the
same as "$(chsh -l)"
because the chsh will not list comment lines. What I get is:
$ x=$(</etc/shells); echo $x
# Pathnames of valid login shells. # See shells(5) for details.
/bin/sh /bin/bash /usr/bin/git-shell /bin/dash /bin/zsh /usr/bin/zsh
Compared to:
$ chsh --list-shells
/bin/sh
/bin/bash
/usr/bin/git-shell
/bin/dash
/bin/zsh
/usr/bin/zsh
I hope it is obvious why cat(1) or bash memory mapping that $(<file)
is isn't the best way to read /etc/shells when using output as
completion options.
--
Sami Kerola
http://www.iki.fi/kerolasa/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bash-completion: Fix su
2020-10-08 7:53 ` Karel Zak
2020-10-08 21:50 ` Sami Kerola
@ 2020-10-13 15:15 ` Stanislav Brabec
2020-10-14 8:19 ` Karel Zak
1 sibling, 1 reply; 5+ messages in thread
From: Stanislav Brabec @ 2020-10-13 15:15 UTC (permalink / raw)
To: Karel Zak; +Cc: Util-Linux, jun wang
Karel Zak wrote:
> On Thu, Oct 08, 2020 at 08:50:39AM +0200, Stanislav Brabec wrote:
>> Fix su -s <tab> that reports invalid chsh -l.
>
> "cat /etc/shells" and "chsh -l" get the same output on my system, why
> "chsh -l" is invalid?
>
> chsh -l uses getusershell() glibc function.
>
> Karel
>
Oops. SUSE uses chsh from shadow package, which is not fully compatible with util-linux one.
So the patch is unappropriate for the upstream util-linux.
--
Best Regards / S pozdravem,
Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o. e-mail: sbrabec@suse.com
Křižíkova 148/34 (Corso IIa) tel: +420 284 084 060
186 00 Praha 8-Karlín fax: +420 284 084 001
Czech Republic http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] bash-completion: Fix su
2020-10-13 15:15 ` Stanislav Brabec
@ 2020-10-14 8:19 ` Karel Zak
0 siblings, 0 replies; 5+ messages in thread
From: Karel Zak @ 2020-10-14 8:19 UTC (permalink / raw)
To: Stanislav Brabec; +Cc: Util-Linux, jun wang
On Tue, Oct 13, 2020 at 05:15:45PM +0200, Stanislav Brabec wrote:
> Karel Zak wrote:
> > On Thu, Oct 08, 2020 at 08:50:39AM +0200, Stanislav Brabec wrote:
> >> Fix su -s <tab> that reports invalid chsh -l.
> >
> > "cat /etc/shells" and "chsh -l" get the same output on my system, why
> > "chsh -l" is invalid?
> >
> > chsh -l uses getusershell() glibc function.
> >
> > Karel
> >
> Oops. SUSE uses chsh from shadow package, which is not fully compatible with util-linux one.
>
> So the patch is unappropriate for the upstream util-linux.
So, now you have motivation to use our wonderful chsh and chfn in SUSE
distros ;-)
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-10-14 8:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-08 6:50 [PATCH] bash-completion: Fix su Stanislav Brabec
2020-10-08 7:53 ` Karel Zak
2020-10-08 21:50 ` Sami Kerola
2020-10-13 15:15 ` Stanislav Brabec
2020-10-14 8:19 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).