Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] Bookworm: sudo ifup / sudo ifdown no longer tab completes

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
jaimet
Posts: 19
Joined: 2019-07-19 08:38

[Solved] Bookworm: sudo ifup / sudo ifdown no longer tab completes

#1 Post by jaimet »

I'm reasonably certain that under bullseye (v11), I could sudo ifdown <tabComplete> / sudo ifup <tabComplete>.

On bookworm (v12):
sudo ifdown <tabComplete> does not "work"
sudo -i ; ifdown <tabComplete> does "work"
su -i ; ifdown <tabComplete> does "work"

Does anyone know where I should log this bug? sudo or ifupdown?

Aki
Global Moderator
Global Moderator
Posts: 3084
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 76 times
Been thanked: 418 times

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#2 Post by Aki »

Hello,

Is the bash-completion package installed ?

Code: Select all

apt list bash-completion 
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

User avatar
wizard10000
Global Moderator
Global Moderator
Posts: 668
Joined: 2019-04-16 23:15
Location: southeastern us
Has thanked: 88 times
Been thanked: 110 times

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#3 Post by wizard10000 »

Deleted my post because my theory that bash completion had to do with a path was completely wrong.

I will say that tab completion works as OP expects in Sid but Bookworm uses an earlier version of bash-completion than Trixie or Sid does.

You could try this just for fun -

Code: Select all

apt-get -o Dpkg::Options::='--force-confnew' install --reinstall bash-completion
That will reinstall bash-completion and force an overwrite of any local changes in /etc. Not that you've made any changes, but it'll give you a clean config just in case.
we see things not as they are, but as we are.
-- anais nin

jaimet
Posts: 19
Joined: 2019-07-19 08:38

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#4 Post by jaimet »

Aki wrote: 2024-04-11 14:10 Hello,
Is the bash-completion package installed ?
Hi! Yes
Aki wrote: 2024-04-11 14:10

Code: Select all

apt list bash-completion 

Code: Select all

$ apt list bash-completion 
Listing... Done
bash-completion/stable,now 1:2.11-6 all [installed]

jaimet
Posts: 19
Joined: 2019-07-19 08:38

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#5 Post by jaimet »

wizard10000 wrote: 2024-04-11 15:45 You could try this just for fun -

Code: Select all

apt-get -o Dpkg::Options::='--force-confnew' install --reinstall bash-completion
I tried that, but the problem persists after the re-install.

jaimet
Posts: 19
Joined: 2019-07-19 08:38

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#6 Post by jaimet »

I've just noticed something else strange w.r.t. sudo and bash tab completion. Again on bookworm (v12):

sudo md5sum /root<tabComplete> does not "work"
sudo -i ; md5sum /root<tabComplete> does "work"
su -i ; md5sum /root<tabComplete> does "work"

Could anyone running anything other than bookworm (v12) please try sudo md5sum /root<tabComplete> and tell me whether this provides tab completion on the files in /root? (I am reasonably certain that this worked under bullseye (v11), but I would appreciate a second opinion.)

User avatar
fabien
Forum Helper
Forum Helper
Posts: 737
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 67 times
Been thanked: 173 times

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#7 Post by fabien »

jaimet wrote: 2024-04-11 12:37 I'm reasonably certain that under bullseye (v11), I could sudo ifdown <tabComplete> / sudo ifup <tabComplete>.

On bookworm (v12):
sudo ifdown <tabComplete> does not "work"
I just tested in a freshly installed Bookworm VM and it works for me. I provide you with the listing of set -x so that you can compare.

Code: Select all

user@debvirt12:~$ head -n1 /etc/apt/sources.list
#deb cdrom:[Debian GNU/Linux 12.5.0 _Bookworm_ - Official amd64 NETINST with firmware 20240210-11:27]/ bookworm contrib main non-free-firmware
user@debvirt12:~$ sudo ifdown <TabTab>
enp1s0  lo      
user@debvirt12:~$ 
user@debvirt12:~$ set -x
user@debvirt12:~$ sudo ifdown + local cur prev words cword split
+ _init_completion -s
+ local exclude= flag outx errx inx OPTIND=1
+ getopts n:e:o:i:s flag -s
+ case $flag in
+ split=false
+ exclude+==
+ getopts n:e:o:i:s flag -s
+ COMPREPLY=()
+ local 'redir=@(?([0-9])<|?([0-9&])>?(>)|>&)'
+ _get_comp_words_by_ref -n '=<>&' cur prev words cword
+ local exclude flag i OPTIND=1
+ words=()
+ local cur cword words
+ upargs=()
+ upvars=()
+ local upargs upvars vcur vcword vprev vwords
+ getopts c:i:n:p:w: flag -n '=<>&' cur prev words cword
+ case $flag in
+ exclude='=<>&'
+ getopts c:i:n:p:w: flag -n '=<>&' cur prev words cword
+ [[ 6 -ge 3 ]]
+ case ${!OPTIND} in
+ vcur=cur
+ (( OPTIND += 1 ))
+ [[ 6 -ge 4 ]]
+ case ${!OPTIND} in
+ vprev=prev
+ (( OPTIND += 1 ))
+ [[ 6 -ge 5 ]]
+ case ${!OPTIND} in
+ vwords=words
+ (( OPTIND += 1 ))
+ [[ 6 -ge 6 ]]
+ case ${!OPTIND} in
+ vcword=cword
+ (( OPTIND += 1 ))
+ [[ 6 -ge 7 ]]
+ __get_cword_at_cursor_by_ref '=<>&' words cword cur
+ words=()
+ local cword words
+ __reassemble_comp_words_by_ref '=<>&' words cword
+ local exclude i j line ref
+ [[ -n =<>& ]]
+ exclude='[=<>&]'
+ printf -v cword %s 2
+ [[ -v exclude ]]
+ line='sudo ifdown '
+ (( i = 0, j = 0 ))
+ (( i < 3 ))
+ [[ 0 -gt 0 ]]
+ ref='words[0]'
+ printf -v 'words[0]' %s sudo
+ line=' ifdown '
+ (( i == COMP_CWORD ))
+ (( i++, j++ ))
+ (( i < 3 ))
+ [[ 1 -gt 0 ]]
+ [[ ifdown == +([=<>&]) ]]
+ ref='words[1]'
+ printf -v 'words[1]' %s ifdown
+ line=' '
+ (( i == COMP_CWORD ))
+ (( i++, j++ ))
+ (( i < 3 ))
+ [[ 2 -gt 0 ]]
+ [[ '' == +([=<>&]) ]]
+ ref='words[2]'
+ printf -v 'words[2]' %s ''
+ line=' '
+ (( i == COMP_CWORD ))
+ printf -v cword %s 2
+ (( i++, j++ ))
+ (( i < 3 ))
+ (( i == COMP_CWORD ))
+ local i cur= index=12 'lead=sudo ifdown '
+ [[ 12 -gt 0 ]]
+ [[ -n sudo ifdown  ]]
+ [[ -n sudoifdown ]]
+ cur='sudo ifdown '
+ (( i = 0 ))
+ (( i <= cword ))
+ [[ 12 -ge 4 ]]
+ [[ sudo != \s\u\d\o ]]
+ (( i < cword ))
+ local old_size=12
+ cur=' ifdown '
+ local new_size=8
+ (( index -= old_size - new_size ))
+ (( ++i ))
+ (( i <= cword ))
+ [[ 8 -ge 6 ]]
+ [[  ifdow != \i\f\d\o\w\n ]]
+ cur='ifdown '
+ (( index > 0 ))
+ (( index-- ))
+ [[ 7 -ge 6 ]]
+ [[ ifdown != \i\f\d\o\w\n ]]
+ (( i < cword ))
+ local old_size=7
+ cur=' '
+ local new_size=1
+ (( index -= old_size - new_size ))
+ (( ++i ))
+ (( i <= cword ))
+ [[ 1 -ge 0 ]]
+ [[ '' != '' ]]
+ (( i < cword ))
+ (( ++i ))
+ (( i <= cword ))
+ [[ -n   ]]
+ [[ ! -n '' ]]
+ cur=
+ (( index < 0 ))
+ local words cword cur
+ _upvars -a3 words sudo ifdown '' -v cword 2 -v cur ''
+ (( 11 ))
+ (( 11 ))
+ case $1 in
+ [[ -n 3 ]]
+ printf %d 3
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:3}")'
++ words=("${@:3:3}")
+ shift 5
+ (( 6 ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
++ cword=2
+ shift 3
+ (( 3 ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
++ cur=
+ shift 3
+ (( 0 ))
+ [[ -v vcur ]]
+ upvars+=("$vcur")
+ upargs+=(-v $vcur "$cur")
+ [[ -v vcword ]]
+ upvars+=("$vcword")
+ upargs+=(-v $vcword "$cword")
+ [[ -v vprev ]]
+ [[ 2 -ge 1 ]]
+ upvars+=("$vprev")
+ upargs+=(-v $vprev "${words[cword - 1]}")
+ [[ -v vwords ]]
+ upvars+=("$vwords")
+ upargs+=(-a${#words[@]} $vwords ${words+"${words[@]}"})
+ (( 4 ))
+ local cur cword prev words
+ _upvars -v cur '' -v cword 2 -v prev ifdown -a3 words sudo ifdown ''
+ (( 14 ))
+ (( 14 ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
++ cur=
+ shift 3
+ (( 11 ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
++ cword=2
+ shift 3
+ (( 8 ))
+ case $1 in
+ [[ -n prev ]]
+ unset -v prev
+ eval 'prev="$3"'
++ prev=ifdown
+ shift 3
+ (( 5 ))
+ case $1 in
+ [[ -n 3 ]]
+ printf %d 3
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:3}")'
++ words=("${@:3:3}")
+ shift 5
+ (( 0 ))
+ _variables
+ [[ '' =~ ^(\$(\{[!#]?)?)([A-Za-z0-9_]*)$ ]]
+ [[ '' =~ ^(\$\{[#!]?)([A-Za-z0-9_]*)\[([^]]*)$ ]]
+ [[ '' =~ ^\$\{[#!]?[A-Za-z0-9_]*\[.*]$ ]]
+ return 1
+ [[ '' == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ [[ ifdown == @(?([0-9])<|?([0-9&])>?(>)|>&) ]]
+ local i skip
+ (( i = 1 ))
+ (( i < 3 ))
+ [[ ifdown == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ (( i++ ))
+ (( 1 ))
+ (( i < 3 ))
+ [[ '' == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ (( i++ ))
+ (( 1 ))
+ (( i < 3 ))
+ (( cword <= 0 ))
+ prev=ifdown
+ [[ -n false ]]
+ _split_longopt
+ [[ '' == --?*=* ]]
+ return 1
+ return 0
+ local i mode=normal
+ [[ sudo == *sudoedit ]]
+ [[ normal == normal ]]
+ (( i = 1 ))
+ (( i <= cword ))
+ [[ ifdown != -* ]]
+ local PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/sbin:/usr/sbin:/usr/local/sbin
+ local root_command=ifdown
+ _command_offset 1
+ local word_offset=1 i j
+ (( i = 0 ))
+ (( i < word_offset ))
+ (( j = 0 ))
+ (( j <= 12 ))
+ [[ sudo ifdown  == \s\u\d\o* ]]
+ break
+ COMP_LINE=' ifdown '
+ (( COMP_POINT -= 4 ))
+ (( i++ ))
+ (( i < word_offset ))
+ (( i = 0 ))
+ (( i <= COMP_CWORD - word_offset ))
+ COMP_WORDS[i]=ifdown
+ (( i++ ))
+ (( i <= COMP_CWORD - word_offset ))
+ COMP_WORDS[i]=
+ (( i++ ))
+ (( i <= COMP_CWORD - word_offset ))
+ (( i ))
+ (( i <= COMP_CWORD ))
+ unset 'COMP_WORDS[i]'
+ (( i++ ))
+ (( i <= COMP_CWORD ))
+ (( COMP_CWORD -= word_offset ))
+ COMPREPLY=()
+ local cur
+ _get_comp_words_by_ref cur
+ local exclude flag i OPTIND=1
+ words=()
+ local cur cword words
+ upargs=()
+ upvars=()
+ local upargs upvars vcur vcword vprev vwords
+ getopts c:i:n:p:w: flag cur
+ [[ 1 -ge 1 ]]
+ case ${!OPTIND} in
+ vcur=cur
+ (( OPTIND += 1 ))
+ [[ 1 -ge 2 ]]
+ __get_cword_at_cursor_by_ref '' words cword cur
+ words=()
+ local cword words
+ __reassemble_comp_words_by_ref '' words cword
+ local exclude i j line ref
+ [[ -n '' ]]
+ printf -v cword %s 1
+ [[ -v exclude ]]
+ for i in "${!COMP_WORDS[@]}"
+ printf -v 'words[i]' %s ifdown
+ for i in "${!COMP_WORDS[@]}"
+ printf -v 'words[i]' %s ''
+ local i cur= index=8 'lead= ifdown '
+ [[ 8 -gt 0 ]]
+ [[ -n  ifdown  ]]
+ [[ -n ifdown ]]
+ cur=' ifdown '
+ (( i = 0 ))
+ (( i <= cword ))
+ [[ 8 -ge 6 ]]
+ [[  ifdow != \i\f\d\o\w\n ]]
+ cur='ifdown '
+ (( index > 0 ))
+ (( index-- ))
+ [[ 7 -ge 6 ]]
+ [[ ifdown != \i\f\d\o\w\n ]]
+ (( i < cword ))
+ local old_size=7
+ cur=' '
+ local new_size=1
+ (( index -= old_size - new_size ))
+ (( ++i ))
+ (( i <= cword ))
+ [[ 1 -ge 0 ]]
+ [[ '' != '' ]]
+ (( i < cword ))
+ (( ++i ))
+ (( i <= cword ))
+ [[ -n   ]]
+ [[ ! -n '' ]]
+ cur=
+ (( index < 0 ))
+ local words cword cur
+ _upvars -a2 words ifdown '' -v cword 1 -v cur ''
+ (( 10 ))
+ (( 10 ))
+ case $1 in
+ [[ -n 2 ]]
+ printf %d 2
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:2}")'
++ words=("${@:3:2}")
+ shift 4
+ (( 6 ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
++ cword=1
+ shift 3
+ (( 3 ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
++ cur=
+ shift 3
+ (( 0 ))
+ [[ -v vcur ]]
+ upvars+=("$vcur")
+ upargs+=(-v $vcur "$cur")
+ [[ -v vcword ]]
+ [[ -v vprev ]]
+ [[ -v vwords ]]
+ (( 1 ))
+ local cur
+ _upvars -v cur ''
+ (( 3 ))
+ (( 3 ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
++ cur=
+ shift 3
+ (( 0 ))
+ (( COMP_CWORD == 0 ))
+ local cmd=ifdown compcmd=ifdown
++ complete -p ifdown
+ local 'cspec=complete -F _ifupdown ifdown'
+ [[ ! -n complete -F _ifupdown ifdown ]]
+ [[ ! -n complete -F _ifupdown ifdown ]]
+ [[ -n complete -F _ifupdown ifdown ]]
+ [[ _ifupdown ifdown != \c\o\m\p\l\e\t\e\ \-\F\ \_\i\f\u\p\d\o\w\n\ \i\f\d\o\w\n ]]
+ local 'func=_ifupdown ifdown'
+ func=_ifupdown
+ (( 2 >= 2 ))
+ _ifupdown ifdown '' ifdown
+ local cur prev words cword
+ _init_completion
+ local exclude= flag outx errx inx OPTIND=1
+ getopts n:e:o:i:s flag
+ COMPREPLY=()
+ local 'redir=@(?([0-9])<|?([0-9&])>?(>)|>&)'
+ _get_comp_words_by_ref -n '<>&' cur prev words cword
+ local exclude flag i OPTIND=1
+ words=()
+ local cur cword words
+ upargs=()
+ upvars=()
+ local upargs upvars vcur vcword vprev vwords
+ getopts c:i:n:p:w: flag -n '<>&' cur prev words cword
+ case $flag in
+ exclude='<>&'
+ getopts c:i:n:p:w: flag -n '<>&' cur prev words cword
+ [[ 6 -ge 3 ]]
+ case ${!OPTIND} in
+ vcur=cur
+ (( OPTIND += 1 ))
+ [[ 6 -ge 4 ]]
+ case ${!OPTIND} in
+ vprev=prev
+ (( OPTIND += 1 ))
+ [[ 6 -ge 5 ]]
+ case ${!OPTIND} in
+ vwords=words
+ (( OPTIND += 1 ))
+ [[ 6 -ge 6 ]]
+ case ${!OPTIND} in
+ vcword=cword
+ (( OPTIND += 1 ))
+ [[ 6 -ge 7 ]]
+ __get_cword_at_cursor_by_ref '<>&' words cword cur
+ words=()
+ local cword words
+ __reassemble_comp_words_by_ref '<>&' words cword
+ local exclude i j line ref
+ [[ -n <>& ]]
+ exclude='[<>&]'
+ printf -v cword %s 1
+ [[ -v exclude ]]
+ line=' ifdown '
+ (( i = 0, j = 0 ))
+ (( i < 2 ))
+ [[ 0 -gt 0 ]]
+ ref='words[0]'
+ printf -v 'words[0]' %s ifdown
+ line=' '
+ (( i == COMP_CWORD ))
+ (( i++, j++ ))
+ (( i < 2 ))
+ [[ 1 -gt 0 ]]
+ [[ '' == +([<>&]) ]]
+ ref='words[1]'
+ printf -v 'words[1]' %s ''
+ line=' '
+ (( i == COMP_CWORD ))
+ printf -v cword %s 1
+ (( i++, j++ ))
+ (( i < 2 ))
+ (( i == COMP_CWORD ))
+ local i cur= index=8 'lead= ifdown '
+ [[ 8 -gt 0 ]]
+ [[ -n  ifdown  ]]
+ [[ -n ifdown ]]
+ cur=' ifdown '
+ (( i = 0 ))
+ (( i <= cword ))
+ [[ 8 -ge 6 ]]
+ [[  ifdow != \i\f\d\o\w\n ]]
+ cur='ifdown '
+ (( index > 0 ))
+ (( index-- ))
+ [[ 7 -ge 6 ]]
+ [[ ifdown != \i\f\d\o\w\n ]]
+ (( i < cword ))
+ local old_size=7
+ cur=' '
+ local new_size=1
+ (( index -= old_size - new_size ))
+ (( ++i ))
+ (( i <= cword ))
+ [[ 1 -ge 0 ]]
+ [[ '' != '' ]]
+ (( i < cword ))
+ (( ++i ))
+ (( i <= cword ))
+ [[ -n   ]]
+ [[ ! -n '' ]]
+ cur=
+ (( index < 0 ))
+ local words cword cur
+ _upvars -a2 words ifdown '' -v cword 1 -v cur ''
+ (( 10 ))
+ (( 10 ))
+ case $1 in
+ [[ -n 2 ]]
+ printf %d 2
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:2}")'
++ words=("${@:3:2}")
+ shift 4
+ (( 6 ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
++ cword=1
+ shift 3
+ (( 3 ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
++ cur=
+ shift 3
+ (( 0 ))
+ [[ -v vcur ]]
+ upvars+=("$vcur")
+ upargs+=(-v $vcur "$cur")
+ [[ -v vcword ]]
+ upvars+=("$vcword")
+ upargs+=(-v $vcword "$cword")
+ [[ -v vprev ]]
+ [[ 1 -ge 1 ]]
+ upvars+=("$vprev")
+ upargs+=(-v $vprev "${words[cword - 1]}")
+ [[ -v vwords ]]
+ upvars+=("$vwords")
+ upargs+=(-a${#words[@]} $vwords ${words+"${words[@]}"})
+ (( 4 ))
+ local cur cword prev words
+ _upvars -v cur '' -v cword 1 -v prev ifdown -a2 words ifdown ''
+ (( 13 ))
+ (( 13 ))
+ case $1 in
+ [[ -n cur ]]
+ unset -v cur
+ eval 'cur="$3"'
++ cur=
+ shift 3
+ (( 10 ))
+ case $1 in
+ [[ -n cword ]]
+ unset -v cword
+ eval 'cword="$3"'
++ cword=1
+ shift 3
+ (( 7 ))
+ case $1 in
+ [[ -n prev ]]
+ unset -v prev
+ eval 'prev="$3"'
++ prev=ifdown
+ shift 3
+ (( 4 ))
+ case $1 in
+ [[ -n 2 ]]
+ printf %d 2
+ [[ -n words ]]
+ unset -v words
+ eval 'words=("${@:3:2}")'
++ words=("${@:3:2}")
+ shift 4
+ (( 0 ))
+ _variables
+ [[ '' =~ ^(\$(\{[!#]?)?)([A-Za-z0-9_]*)$ ]]
+ [[ '' =~ ^(\$\{[#!]?)([A-Za-z0-9_]*)\[([^]]*)$ ]]
+ [[ '' =~ ^\$\{[#!]?[A-Za-z0-9_]*\[.*]$ ]]
+ return 1
+ [[ '' == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ [[ ifdown == @(?([0-9])<|?([0-9&])>?(>)|>&) ]]
+ local i skip
+ (( i = 1 ))
+ (( i < 2 ))
+ [[ '' == @(?([0-9])<|?([0-9&])>?(>)|>&)* ]]
+ (( i++ ))
+ (( 1 ))
+ (( i < 2 ))
+ (( cword <= 0 ))
+ prev=ifdown
+ [[ -n false ]]
+ _split_longopt
+ [[ '' == --?*=* ]]
+ return 1
+ return 0
+ case $prev in
+ [[ '' == -* ]]
+ local args
+ _count_args '' '@(--allow|-i|--interfaces|--state-dir|-X|--exclude|-o)'
+ local i cword words
+ __reassemble_comp_words_by_ref '' words cword
+ local exclude i j line ref
+ [[ -n '' ]]
+ printf -v cword %s 1
+ [[ -v exclude ]]
+ for i in "${!COMP_WORDS[@]}"
+ printf -v 'words[i]' %s ifdown
+ for i in "${!COMP_WORDS[@]}"
+ printf -v 'words[i]' %s ''
+ args=1
+ (( i = 1 ))
+ (( i < cword ))
+ (( args == 1 ))
+ _configured_interfaces
+ [[ -f /etc/debian_version ]]
+ COMPREPLY=($(compgen -W "$(command sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p' /etc/network/interfaces /etc/network/interfaces.d/* 2> /dev/null)" -- "$cur"))
+++ command sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p' /etc/network/interfaces '/etc/network/interfaces.d/*'
++ compgen -W 'lo
enp1s0' -- ''
+ COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur"))
++ compgen -W '${COMPREPLY[@]}' -- ''
+ local opt
+ [[ complete -F _ifupdown ifdown == *\ \-\o\ * ]]
+ return
The most important part is at the end

Code: Select all

+ [[ -f /etc/debian_version ]]
+ COMPREPLY=($(compgen -W "$(command sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p' /etc/network/interfaces /etc/network/interfaces.d/* 2> /dev/null)" -- "$cur"))
+++ command sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p' /etc/network/interfaces '/etc/network/interfaces.d/*'
In my case I can test if it works like this:

Code: Select all

user@debvirt12:~$ command sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p' /etc/network/interfaces '/etc/network/interfaces.d/*'
lo
enp1s0
sed: can't read /etc/network/interfaces.d/*: No such file or directory
Works for me, does it work for you?
jaimet wrote: 2024-04-12 10:07 I've just noticed something else strange w.r.t. sudo and bash tab completion. Again on bookworm (v12):

sudo md5sum /root<tabComplete> does not "work"
Is /root/ readable as simple user?

Code: Select all

user@debvirt12:~$ ls -ld /root/
drwx------ 3 root root 4096 Mar 29 13:45 /root/
ImageShare your Debian SCRIPTS
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots

jaimet
Posts: 19
Joined: 2019-07-19 08:38

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#8 Post by jaimet »

fabien wrote: 2024-04-12 10:43 In my case I can test if it works like this:

Code: Select all

user@debvirt12:~$ command sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p' /etc/network/interfaces '/etc/network/interfaces.d/*'
lo
enp1s0
sed: can't read /etc/network/interfaces.d/*: No such file or directory
Works for me, does it work for you?
Interesting. To make sure that my problem is not due to "modifications since installation", I have just reformatted and reinstalled this box using the netboot installer. Here is what I get:

Code: Select all

$ command sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p' /etc/network/interfaces '/etc/network/interfaces.d/*'
sed: can't read /etc/network/interfaces: Permission denied
sed: can't read /etc/network/interfaces.d/*: No such file or directory
$ stat -c '%a %n' /etc/network/interfaces
600 /etc/network/interfaces
$
I also have access to an old Bullseye (v11) box, which returns the following:

Code: Select all

$ stat -c '%a %n' /etc/network/interfaces
644 /etc/network/interfaces
$
So it appears that some installation methods leave /e/n/i as 600 while other installation methods leave /e/n/i as 644. To install bookworm, I use just the following 2 files:
http://http.us.debian.org/debian/dists/ ... md64/linux md5sum: d404548ca0fdc6df89f38b36494d73b4
http://http.us.debian.org/debian/dists/ ... /initrd.gz md5sum: 59ca31c729349207c8561a63ab6ad7ae

I have tried to work out which installer medium you use. Is it the following file?
https://cdimage.debian.org/debian-cd/cu ... etinst.iso
If the above file is how you install bookworm, I will try to install using the same file and I can then log a bug against the installer.
fabien wrote: 2024-04-12 10:43 Is /root/ readable as simple user?

Code: Select all

user@debvirt12:~$ ls -ld /root/
drwx------ 3 root root 4096 Mar 29 13:45 /root/
No, it isn't (same as for you):

Code: Select all

~$ ls -ld /root/
drwx------ 3 root root 4096 24-04-12T09:32 /root/
nonroot@elite[0]:~$
I now think that this is a completely different problem to the above problem, and I think that this problem is simply caused by my incorrect memory - I thought that "sudo mdsum /root<tabComplete" listed the files in /root, but I need to do some more research.

@fabien Thank you so much for your help with this - your explanations and insight are très bien appréciées.

User avatar
fabien
Forum Helper
Forum Helper
Posts: 737
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 67 times
Been thanked: 173 times

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#9 Post by fabien »

jaimet wrote: 2024-04-12 21:39 I have tried to work out which installer medium you use. Is it the following file?
https://cdimage.debian.org/debian-cd/cu ... etinst.iso
Yes, this one, sha256sum 013f5b44670d81280b5b1bc02455842b250df2f0c6763398feb69af1a805a14f
jaimet wrote: 2024-04-12 21:39 If the above file is how you install bookworm, I will try to install using the same file and I can then log a bug against the installer.
If you do, it might be worth comparing the two systems to see if there are any other differences in permissions. You can use this command to find files and directories for which "others" does not have read permission:

Code: Select all

#> find /etc/ \! -perm /o=r -printf '%m %p\n'
Don't forget to report the link to the bug if applicable.
I think you can mark your topic as [Solved].
jaimet wrote: 2024-04-12 21:39 @fabien Thank you so much for your help with this - your explanations and insight are très bien appréciées.
Merci beaucoup ^^
ImageShare your Debian SCRIPTS
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots

jaimet
Posts: 19
Joined: 2019-07-19 08:38

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#10 Post by jaimet »

fabien wrote: 2024-04-12 23:52 Yes, this one, sha256sum 013f5b44670d81280b5b1bc02455842b250df2f0c6763398feb69af1a805a14f
@fabien Ok, this is very strange. I have just now done a fresh installation using the netinst iso (sha256sum: 013f5b44...) and immediately after first boot, I get:

Code: Select all

$ stat -c '%a %n' /etc/network/interfaces
600 /etc/network/interfaces
$
I know that this sounds crazy, but I just want to double-check: are you sure that you are not making any changes that could modify this file to 644 after installation? Also, I install using a (real) wireless network card whereas perhaps you install using a (virtual) wired ethernet connection - perhaps this is why we get different permissions on /e/n/i ?! (I will try to install over a real ethernet connection and report back.) I am confused!

User avatar
fabien
Forum Helper
Forum Helper
Posts: 737
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 67 times
Been thanked: 173 times

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#11 Post by fabien »

jaimet wrote: 2024-04-13 10:00 I know that this sounds crazy, but I just want to double-check: are you sure that you are not making any changes that could modify this file to 644 after installation?
Yes, I'm sure.
jaimet wrote: 2024-04-13 10:00 Also, I install using a (real) wireless network card whereas perhaps you install using a (virtual) wired ethernet connection - perhaps this is why we get different permissions on /e/n/i ?! (I will try to install over a real ethernet connection and report back.) I am confused!
Yes, in my case the host uses a wired Ethernet connection. The permissions are the same on the host (which was installed in 2017) and in the VM:

Code: Select all

$> stat -c '%a %n' /etc/network/interfaces
644 /etc/network/interfaces
But you are right to mention that you are installing via WIFI. It might make sense to have the permissions set as they are in your case if the installer is likely to write for example a WIFI password or other information that might be sensitive, like even the SSID, to this file. I have never installed via WIFI, it would be interesting to have feedback from other users on this point.

If passwords are indeed stored in /etc/network/interfaces I would suggest keeping those permissions, otherwise you can change them.
ImageShare your Debian SCRIPTS
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots

jaimet
Posts: 19
Joined: 2019-07-19 08:38

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#12 Post by jaimet »

jaimet wrote: 2024-04-13 10:00 (I will try to install over a real ethernet connection and report back.) I am confused!
Same laptop, same (destination) partition, same installer iso:
Install over wi-fi, /etc/network/interfaces is 600.
Install over (wired) ethernet, /etc/network/interfaces is 644.

This must be a "hide wireless passwords from other users" thing, in which case the bug is in the (lack of) documentation.
(As I am the only user on each and every one of my boxes, this "security" has no value for me so I can now change my interfaces file to 644 and regain "sudo ifup/ifdown tab completion"!)

Aki
Global Moderator
Global Moderator
Posts: 3084
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 76 times
Been thanked: 418 times

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#13 Post by Aki »

Hello,
fabien wrote: 2024-04-13 12:12 It might make sense to have the permissions set as they are in your case if the installer is likely to write for example a WIFI password or other information that might be sensitive, like even the SSID, to this file. I have never installed via WIFI, it would be interesting to have feedback from other users on this point.

If passwords are indeed stored in /etc/network/interfaces I would suggest keeping those permissions, otherwise you can change them.
I would like to thank you @fabien for the in-depth analysis.

Searching the ifupdown source, the file /etc/network/interfaces is created when the ifupdown package is installed (and the postinst [1] package script is called as the last stage of package install process [2]):

Code: Select all

#!/bin/sh
set -e

MYNAME="${0##*/}"

report() { echo "${MYNAME}: $*" ; }
report_warn() { report "Warning: $*" >&2 ; }
report_err() { report "Error: $*" >&2 ; }

if [ "$1" = configure ]; then
  addgroup --quiet --system netdev || true
fi

# Generic stuff done on all configurations
if [ "$1" = "configure" ] ; then
  # We don't need loopback interface definition anymore as
  # ifupdown handles loopback interface on its own from now
  if [ ! -f /etc/network/interfaces ] ; then
    if [ -z "$2" ]; then
      echo "Creating /etc/network/interfaces."
      echo "# interfaces(5) file used by ifup(8) and ifdown(8)" > /etc/network/interfaces
      echo "# Include files from /etc/network/interfaces.d:" >> /etc/network/interfaces
      echo "source /etc/network/interfaces.d/*" >> /etc/network/interfaces
    else
      report_warn "/etc/network/interfaces does not exist"
    fi
  fi
fi

#DEBHELPER#
Therefore, the file /etc/network/interfaces is created by the root user with the standard umask [3], therefore the read-write-execute file privileges are 0644 (octal):

Code: Select all

$ ls -la /etc/network/interfaces
-rw-r--r-- 1 root root 722 17 Oct 21.34 /etc/network/interfaces
When Debian is installed using the Debian Installer (as with a netinst ISO), the Debian Installer component involved in the network configuration is the netcfg udeb package [4].

When the netcfg program has completed the configuration (after the network has been configured), the following postinst script is executed [5]:

Code: Select all

[..]

    $CONFIG_INTERFACES)
	# Files are copied by the base-installer hook already, beware of secrets:
	if [ "$NETCFG_CONNECTION_TYPE" = wireless ] && [ "$NETCFG_CONNECTION_SECURITY" = secured ]; then
		logger -t netcfg "setting $FILE_INTERFACES mode to 600 since it contains secrets"
		chmod 600 /target/$FILE_INTERFACES
	fi
	;;
[..]
As you can see, if a wireless network has been configured using a secure connection, the file permissions will be changed to 0600.

It is nice to see how much care the Debian developers have put into the details.

--
[0] https://sources.debian.org/src/ifupdown/0.8.41/
[1] https://sources.debian.org/src/ifupdown/0.8.41/debian/postinst/
[2] Debian Policy Manual - 6.5. Summary of ways maintainer scripts are called
[3] Debian Reference Guide: 1.2.4. Control of permissions for newly created files: umask
[4] https://packages.debian.org/bookworm/netcfg
[5] https://sources.debian.org/src/netcfg/1.187/finish-install.d/55netcfg-copy-config/#L62
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

CwF
Global Moderator
Global Moderator
Posts: 2741
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 45 times
Been thanked: 206 times

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#14 Post by CwF »

Interesting. Maybe this answers this old thread...?
viewtopic.php?t=157546

User avatar
fabien
Forum Helper
Forum Helper
Posts: 737
Joined: 2019-12-03 12:51
Location: Anarres (Toulouse, France actually)
Has thanked: 67 times
Been thanked: 173 times

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#15 Post by fabien »

Aki wrote: 2024-04-13 14:28 I would like to thank you @fabien for the in-depth analysis.
I would like to thank you @Aki for the much more than mine in-depth analysis :)

The Debian Wiki recommends either keeping the permissions at 600, or using a dedicated file in /etc/network/interfaces.d/ with these same restricted permissions.
Restrict the permissions of /etc/network/interfaces, to prevent pre-shared key (PSK) disclosure (alternatively use a separate config file such as /etc/network/interfaces.d/wlan0 on newer Debian versions):

Code: Select all

# chmod 0600 /etc/network/interfaces
ImageShare your Debian SCRIPTS
There will be neither barrier nor walls, neither official nor guard, there will be no more desert and the entire world will become a garden. — Anacharsis Cloots

Aki
Global Moderator
Global Moderator
Posts: 3084
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 76 times
Been thanked: 418 times

Re: Bookworm: sudo ifup / sudo ifdown no longer tab completes

#16 Post by Aki »

EDIT Sun Apr 21 17:12:09 CEST 2024: added [Solved] tag to the first post.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

Post Reply