Bug 49172

Summary: do_netreport() hangs if ifup is run by non-root user
Product: [Retired] Red Hat Linux Reporter: Need Real Name <derrell.lipman>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED RAWHIDE QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2001-07-16 18:31:32 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Need Real Name 2001-07-16 14:51:07 UTC
Description of Problem:
The function do_netreport in /etc/sysconfig/network-scripts/network-
functions uses 'su' to try to become the correct user to send the SIGIO 
signal to processes awaiting notification that the network has come up.  
That works find as long as ifup was run by root.  If a non-root user 
brings the network up then this su command hangs (awaiting a password, but 
input and output are redirected to /dev/null so that's not evident).

How Reproducible:

Steps to Reproduce:
1. Run something that places a file in /var/run/netreport requesting a 
signal when the network comes up.
2. Run ifup as a non-root user.

Actual Results:
do_netreport() will hang.

Expected Results:
Attempt to send signal fails (or no attempt is made to send signals) if 
the caller of do_netreport() is not root.

Additional Information:
	
This modification to the function should solve the problem:

do_netreport ()
{
  # No notifications if not root
  uid=`id | sed -e 's/^uid=//' -e 's/(.*//'`
  if [ "${uid}" = "0" ] ; then
    # Notify programs that have requested notification
    ( cd /var/run/netreport || exit
      for i in * ; do
	if [ -f $i ]; then
	  OWNER=`ls -l $i | awk '{ print $3 }'`
	  su $OWNER -c "kill -SIGIO $i >/dev/null 2>&1" > /dev/null 2>&1 
|| \
	     rm -f $i >/dev/null 2>&1
	  fi
      done
    )
  fi
}

Comment 1 Bill Nottingham 2001-07-16 18:37:10 UTC
actually, you still need to run the 'kill' if you're non-root, so for that
case you just want to take the 'su' out (it will silently fail if it's
the wrong process.)

Will be fixed in 6.03-1.