Re: [PATCH] bash-completion: Fix su

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 8 Oct 2020 at 08:55, Karel Zak <kzak@xxxxxxxxxx> 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/



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux