Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 548334

Summary: net-misc/openssh-6.7_p1 makes /sbin/depscan.sh failing/freezing w/baselayout-1
Product: Gentoo Linux Reporter: Georges A. <garnould>
Component: [OLD] baselayoutAssignee: Gentoo's Team for Core System packages <base-system>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: emerge --info

Description Georges A. 2015-05-01 13:51:10 UTC
Created attachment 402392 [details]
emerge --info

Hi there,

I have just upgraded my openssh to 6.7_p1.

After install, I restarted the service (/etc/init.d/sshd restart) and the script froze on " * Caching service dependencies ...", never exiting.

After some strace, it appeared that /sbin/depscan.sh was stuck in some gawk commande line (last lines of "/sbin/depscan.sh -d") :

    + echo -ne ' * Caching service dependencies ...'
     * Caching service dependencies ...+ LAST_E_CMD=einfon
    + return 0
    + [[ yes == \y\e\s ]]
    + echo

    + LAST_E_LEN=35
    + LAST_E_CMD=ebegin
    + return 0
    + rm -rf /var/lib/init.d/depcache /var/lib/init.d/deptree '/var/lib/init.d/broken/*' '/var/lib/init.d/snapshot/*'
    + retval=0
    + SVCDIR=/var/lib/init.d
    + DEPTYPES='need use'
    + ORDTYPES='before after'
    + export SVCDIR DEPTYPES ORDTYPES
    + cd /etc/init.d
    + /bin/gawk -f /lib/rcscripts/awk/functions.awk -f /lib/rcscripts/awk/cachedepends.awk
    + bash /var/lib/init.d/depcache
    + /bin/gawk -f /lib/rcscripts/awk/functions.awk -f /lib/rcscripts/awk/gendepends.awk
    ^C

When removing /etc/init.d/sshd, depscan.sh worked properly. When reinstalling the newly installed /etc/init.d/sshd, depscan.sh stalled again.

I commented a big part of the depend() function of /etc/init.d/sshd script, from:

    depend() {
           use logger dns
           if [ "${rc_need+set}" = "set" ]; then
                   : # Do nothing, the user has explicitly set rc_need
           else
                   warn_addr=''
                   for x in $(awk '/^ListenAddress/{ print $2 }' "$SSHD_CONFIG" 2>/dev/null) ; do
                           case "$x" in
                                   0.0.0.0|0.0.0.0:*) ;;
                                   ::|\[::\]*) ;;
                                   *) warn_addr="${warn_addr} $x" ;;
                           esac
                   done
                   unset x
                   if [ "${warn_addr:+set}" = "set" ]; then
                           need net
                           ewarn "You are binding an interface in ListenAddress statement in your sshd_config!"
                           ewarn "You must add rc_need=\"net.FOO\" to your /etc/conf.d/sshd"
                           ewarn "where FOO is the interface(s) providing the following address(es):"
                           ewarn "${warn_addr}"
                   fi
                   unset warn_addr
           fi
    }

to:

    depend() {
            use logger dns
    #       if [ "${rc_need+set}" = "set" ]; then
    #               : # Do nothing, the user has explicitly set rc_need
    #       else
    #               warn_addr=''
    #               for x in $(awk '/^ListenAddress/{ print $2 }' "$SSHD_CONFIG" 2>/dev/null) ; do
    #                       case "$x" in
    #                               0.0.0.0|0.0.0.0:*) ;;
    #                               ::|\[::\]*) ;;
    #                               *) warn_addr="${warn_addr} $x" ;;
    #                       esac
    #               done
    #               unset x
    #               if [ "${warn_addr:+set}" = "set" ]; then
    #                       need net
    #                       ewarn "You are binding an interface in ListenAddress statement in your sshd_config!"
    #                       ewarn "You must add rc_need=\"net.FOO\" to your /etc/conf.d/sshd"
    #                       ewarn "where FOO is the interface(s) providing the following address(es):"
    #                       ewarn "${warn_addr}"
    #               fi
    #               unset warn_addr
    #       fi
    }

This "commenting session" led to /sbin/depscan.sh working properly. I suppose it could be caused by this depend() function making use of "awk" (hypothesis) : the depend() function is cached into /var/lib/init.d/depcache by depscan.sh, and /var/lib/init.d/depcache is then used by /bin/gawk -f /lib/rcscripts/awk/functions.awk -f /lib/rcscripts/awk/gendepends.awk (the stalled command).

More generally, the stalled/frozen /sbin/depscan.sh problem receive generates a lot of questions on the web and it looks like it could be often linked to the depend() function cached and the re-used by gawk.

Don't hesitate to ask for more spec/details and tests if needed.

Regards
Comment 1 SpanKY gentoo-dev 2015-05-04 02:55:44 UTC
(In reply to Georges A. from comment #0)

try commenting out just the for loop.  if that works, add some debugging info:
  ewarn "SSHD_CONFIG = $SSHD_CONFIG"

then run the awk command manually on your system:
  awk '/^ListenAddress/{ print $2 }' "$SSHD_CONFIG"

what is /usr/bin/awk pointing to ?  gawk ?  what version of that package do you have installed ?
Comment 2 Georges A. 2015-05-04 07:47:04 UTC
(In reply to SpanKY from comment #1)
> (In reply to Georges A. from comment #0)
> 
> try commenting out just the for loop.  if that works, add some debugging
> info:
>   ewarn "SSHD_CONFIG = $SSHD_CONFIG"
> 
> then run the awk command manually on your system:
>   awk '/^ListenAddress/{ print $2 }' "$SSHD_CONFIG"
> 
> what is /usr/bin/awk pointing to ?  gawk ?  what version of that package do
> you have installed ?

Hi,

Commenting out the for loop makes the script stall/freeze.

Manually running
  awk '/^ListenAddress/{ print $2 }' "$SSHD_CONFIG"
equivalent to
  awk '/^ListenAddress/{ print $2 }' /etc/ssh/sshd_config

works properly

Info:

  # which awk
  /usr/bin/awk
  # ls -la /usr/bin/awk
  lrwxrwxrwx 1 root root 15 2011-04-04 15:15 /usr/bin/awk -> /bin/gawk-3.1.6
  # equery belongs /bin/gawk-3.1.6
  [ Searching for file(s) /bin/gawk-3.1.6 in *... ]
  sys-apps/gawk-3.1.6 (/bin/gawk-3.1.6)

Regards,

G.
Comment 3 SpanKY gentoo-dev 2015-05-04 08:31:30 UTC
(In reply to Georges A. from comment #2)

put a `set -x` at the top of depend func then and see what tracing output you get.  the fact that it hangs on a few variable checks is suspicious.
Comment 4 Georges A. 2015-05-04 08:40:07 UTC
(In reply to SpanKY from comment #3)
> (In reply to Georges A. from comment #2)
> 
> put a `set -x` at the top of depend func then and see what tracing output
> you get.  the fact that it hangs on a few variable checks is suspicious.

Here is the output:

  # /etc/init.d/sshd restart
   * Caching service dependencies ...
  + use logger dns
  + echo 'USE logger dns'
  + return 0
  + '[' '' = set ']'
  + warn_addr=
  ++ awk '/^ListenAddress/{ print $2 }' ''
  ^C * ERROR:  sshd caught an interrupt
Comment 5 SpanKY gentoo-dev 2015-05-04 09:14:42 UTC
you're running a pretty old set of packages.  what version of openrc do you have exactly ?
Comment 6 Georges A. 2015-05-04 09:22:28 UTC
(In reply to SpanKY from comment #5)
> you're running a pretty old set of packages.  what version of openrc do you
> have exactly ?

I am running baselayout-1 and, I suppose, no openrc :(
Comment 7 SpanKY gentoo-dev 2015-05-04 10:25:47 UTC
sorry, but baselayout-1 hasn't been supported for a long time.  looks like a change in the depscan logic doesn't work here -- namely that vars initialized in the global scope aren't preserved for the depend function.

feel free to keep that hack locally, but we dropped support for baselayout-1 in the tree a while ago.
Comment 8 Georges A. 2015-05-06 16:02:12 UTC
(In reply to SpanKY from comment #7)
> sorry, but baselayout-1 hasn't been supported for a long time.  looks like a
> change in the depscan logic doesn't work here -- namely that vars
> initialized in the global scope aren't preserved for the depend function.
> 
> feel free to keep that hack locally, but we dropped support for baselayout-1
> in the tree a while ago.

Big thank you for your help & feedback !

Regards,

G.