Bug 104062 - Using /sbin/reboot as the shell of a special account does not work as expected
Using /sbin/reboot as the shell of a special account does not work as expected
Product: Fedora
Classification: Fedora
Component: sysvinit (Show other bugs)
i386 Linux
medium Severity low
: ---
: ---
Assigned To: Bill Nottingham
David Lawrence
Depends On:
  Show dependency treegraph
Reported: 2003-09-09 11:42 EDT by Dale R. Worley
Modified: 2014-03-16 22:38 EDT (History)
1 user (show)

See Also:
Fixed In Version: 2.86-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2005-12-20 15:08:45 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
Patch to halt.c to improve its detection of "what name it was invoked using", and thus select the correct action to take. (746 bytes, patch)
2003-09-09 11:44 EDT, Dale R. Worley
no flags Details | Diff

  None (edit)
Description Dale R. Worley 2003-09-09 11:42:38 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.2) Gecko/20030716

Description of problem:

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:


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.


/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[0].

However, when the binary is invoked by login(?) via the 'reboot' entry in
/etc/passwd shown above, argv[0] 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[0] 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[0] 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):

How reproducible:

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
Comment 1 Dale R. Worley 2003-09-09 11:44:35 EDT
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 15:08:45 EST
Added in 2.86-1.
Comment 3 David Lawrence 2007-06-21 22:10:55 EDT
Package name is now sysvinit in Fedora.

Note You need to log in before you can comment on or make changes to this bug.