|Summary:||Using /sbin/reboot as the shell of a special account does not work as expected|
|Product:||[Fedora] Fedora||Reporter:||Dale R. Worley <worley>|
|Component:||sysvinit||Assignee:||Bill Nottingham <notting>|
|Status:||CLOSED RAWHIDE||QA Contact:||David Lawrence <dkl>|
|Fixed In Version:||2.86-1||Doc Type:||Bug Fix|
|Doc Text:||Story Points:||---|
|Last Closed:||2005-12-20 20:08:45 UTC||Type:||---|
|oVirt Team:||---||RHEL 7.3 requirements from Atomic Host:|
Description Dale R. Worley 2003-09-09 15:42:38 UTC
From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20030716 Description of problem: Description: I have created accounts so that one can halt or reboot the system without first logging into 'root', by putting these entries in /etc/passwd: shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown halt:x:7:0:halt:/sbin:/sbin/halt reboot:x:0:0:reboot:/sbin:/sbin/reboot The first two are standard in the RH 8.0 distribution; I have added 'reboot'. All three logins have the same password as 'root', thus providing security. However, the 'reboot' login halts the system, rather than rebooting it. To the best of my memory, the 'reboot' login worked as expected in RH 7.2. Diagnosis: /sbin/reboot is a symbolic link to /sbin/halt. The binary determines whether it is supposed to "shut down and halt" or "shut down and reboot" by examining the name under with it was invoked, which is pointed to by argv. However, when the binary is invoked by login(?) via the 'reboot' entry in /etc/passwd shown above, argv has the value "-reboot". The binary does not recognize this as meaning that it was invoked as "reboot", and so performs its default action, "shut down and halt." The logic for these tests is at lines 168 to 181 in sysvinit-2.84/src/halt.c in sysvinit-2.84.tar.gz in SysVinit-2.84-5.src.rpm. The value of argv provided by login was determined by inserting "sleep(60);" at the beginning of main() in halt.c, logging into 'reboot' on another VC, attaching to the sleeping reboot process using GDB, and using the usual GDB commands to determine the value of argv and the action of the logic in halt.c in processing it. Suggested fix: Augment the "Find out who we are" logic in halt.c by adding logic to detect and remove any leading "-" on the program name. A patch to do this is attached. Version-Release number of selected component (if applicable): SysVinit-2.84-5 How reproducible: Always Steps to Reproduce: 1.Add this entry to /etc/passwd: reboot:x:0:0:reboot:/sbin:/sbin/reboot 2.Log in as 'reboot', thus initiating system shutdown. Actual Results: System shuts down and halts. Expected Results: Systen should shut down and then reboot. Additional info: This bug can be worked around by having the "shell" of login 'reboot' be a short shell script invoking /sbin/reboot, rather than having the shell be /sbin/reboot itself.
Comment 1 Dale R. Worley 2003-09-09 15:44:35 UTC
Created attachment 94331 [details] Patch to halt.c to improve its detection of "what name it was invoked using", and thus select the correct action to take.
Comment 2 Bill Nottingham 2005-12-20 20:08:45 UTC
Added in 2.86-1.
Comment 3 David Lawrence 2007-06-22 02:10:55 UTC
Package name is now sysvinit in Fedora.