Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 475006

Summary: shutdown ignores requested halt action
Product: Red Hat Enterprise Linux 5 Reporter: Vadym Chepkov <vchepkov>
Component: initscriptsAssignee: initscripts Maintenance Team <initscripts-maint-list>
Status: CLOSED ERRATA QA Contact: BaseOS QE <qe-baseos-auto>
Severity: medium Docs Contact:
Priority: low    
Version: 5.3CC: ajb, harald, jturner, notting
Target Milestone: rcKeywords: Regression, Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 501487 (view as bug list) Environment:
Last Closed: 2009-09-02 11:14:22 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:
Bug Depends On: 475609    
Bug Blocks: 501487    
Attachments:
Description Flags
create /halt file if halt action was requested
none
patch none

Description Vadym Chepkov 2008-12-06 16:29:02 UTC
Created attachment 326004 [details]
create /halt file if halt action was requested

When you request a halt action
/sbin/shutdown -h -H now
instead of halting system gets powered down

The problem comes from SysVinit-2.86-14

/etc/init.d/halt from initscripts-8.45.19.1.EL-1 has this line of code

[ -f /poweroff -o ! -f /halt ] && HALTARGS="$HALTARGS -p"

Which makes poweroff a default action in absence of /halt file. In my opinion this assumption is questionable for servers. Usually, after a power failure if a system BIOS has "Power recovery: LAST" setting, system can start automatically after power returns. If the action during shutdown was poweroff it would never happen, somebody would have to go to the server and press the power button. 

But back to shutdown problem. 
when /sbin/halt is called it properly creates /halt file if -p switch (power off) was not passed, so for /sbin/halt halt is default action, proper behavior, in my opinion. But when /sbin/shutdown called with -H switch it doesn't create /halt file, which it should.

Proposed patch is attached. I removed "usage" comment because it is not in sync with the actual source code

Comment 1 Vadym Chepkov 2008-12-06 22:10:41 UTC
Unfortunately, the approach doesn't work on kernel-xen. 
First, strcmp(halttype,HALT) code causes segmentation fault, because halttype
is uninitialized. But even after I fixed that, still kernel-xen powers down.

so, to reiterate the problem

/sbin/shutdown -h -H now doesn't halt the system

if on plain kernel you do touch /halt first, system halts as expected. No
workaround for kernel-xen

Comment 2 Bill Nottingham 2008-12-08 15:46:55 UTC
I'm cloning this bug for our development stream, to be considered for the next major Red Hat Enterprise Linux release.

As this change would change behavior that's been in all prior versions of Red Hat Enterprise Linux releases, this isn't really something suitable for fixing in an update to RHEL 5, where we try and maintain as stable a base as possible. Ergo, closing as WONTFIX for RHEL 5.

Comment 3 Vadym Chepkov 2008-12-09 07:05:42 UTC
I think, I was misunderstood. I didn't ask to change the behavior.
The subject of the bug report stands.

man shutdown says:

       -h     Halt or poweroff after shutdown.

       -H     Halt action is to halt or drop into boot monitor on systems that
              support it.

#  /sbin/shutdown -? shows:
                  -h:      halt after shutdown.
                  -P:      halt action is to turn off power.
                  -H:      halt action is to just halt.

and command
shutdown -h -H now does not halt the system

Comment 4 Bill Nottingham 2008-12-09 15:16:59 UTC
Created attachment 326330 [details]
patch

Whoops, misread that as you wanted to change the default for -h to halt w/o poweroff.

Does the attached fix it for you?

Comment 5 Vadym Chepkov 2008-12-09 15:58:43 UTC
It did only for plain kernel, not for kernel-xen and on kernel-xen shutdown coredumps with my patch, so I don't think it's a proper way to handle the situation.

Comment 6 Bill Nottingham 2008-12-09 17:04:22 UTC
Please try the patch I posted, not your patch.

Comment 7 Vadym Chepkov 2008-12-09 17:22:32 UTC
Whoops :)

After a small correction (space is missing before first closing bracket)

The patch halts normal kernel, but not kernel-xen.

Comment 8 Bill Nottingham 2008-12-09 18:23:04 UTC
Does a manual invocation of 'halt -f' also poweroff?

Comment 9 Bill Nottingham 2008-12-09 18:31:22 UTC
Poweroff the xen kernel, that is.

Comment 10 Vadym Chepkov 2008-12-09 18:36:57 UTC
/sbin/halt -f halts system with normal kernel and poweroffs kernel-xen

Comment 11 Bill Nottingham 2008-12-09 18:44:28 UTC
OK. Can you open a separate bug against kernel-xen for that? This patch fixes the general case, and once kernel-xen is fixed, it should work there too.

Comment 12 Vadym Chepkov 2008-12-09 19:12:55 UTC
Bug 475609 has been submitted, I am not sure if we should link them together or not.

Comment 13 Vadym Chepkov 2008-12-15 15:07:18 UTC
Do I need to submit duplicates for Fedora? It has the same issue.

Comment 14 Bill Nottingham 2008-12-16 15:03:10 UTC
http://git.fedorahosted.org/git/?p=initscripts.git;a=commitdiff;h=b7b6cb4ce32ba749f5f7b786ddc3bafd37442a89 was committed to the Fedora upstream; it hasn't been built yet, though.

Comment 16 Harald Hoyer 2009-05-05 12:51:59 UTC
Please test the erratum candidate:
http://people.redhat.com/harald/downloads/initscripts/initscripts-8.45.26.1.el5/

Comment 18 Vadym Chepkov 2009-05-06 20:13:14 UTC
I only can see people.redhat.com Logo

Comment 19 Harald Hoyer 2009-05-07 08:17:11 UTC
works for me from outside connections

Comment 20 Vadym Chepkov 2009-05-07 11:20:54 UTC
Hmm, must have been temporary issue.

Anyway, /etc/init.d/halt has a syntax error in line 220, unmatching ]

-[ "$INIT_HALT" != "HALT"] && HALTARGS="$HALTARGS -p"
+[ "$INIT_HALT" != "HALT" ] && HALTARGS="$HALTARGS -p"

Comment 21 Vadym Chepkov 2009-05-07 11:24:53 UTC
After I fixed the error above the system did halt as requested.

Comment 22 Harald Hoyer 2009-05-07 12:12:19 UTC
I should have double checked the patch from comment #14

Thank you!

Comment 24 Jay Turner 2009-05-13 12:04:46 UTC
I'm kicking this back to assigned to pick up the typo identified in comment 20.

Comment 25 Jay Turner 2009-05-19 14:07:59 UTC
Fix confirmed with initscripts-8.45.28-1.el5.  Looks like the advisory has been updated as well so moving this to Verified.

[root@dyno /etc/rc.d/rc0.d]# rpm -q initscripts
initscripts-8.45.28-1.el5.x86_64
[root@dyno /etc/rc.d/rc0.d]# diff -Nru S01halt.orig S01halt
--- S01halt.orig        2009-05-13 07:18:11.000000000 -0400
+++ S01halt     2009-05-14 13:57:05.000000000 -0400
@@ -217,6 +217,6 @@
 [ -n "$kexec_command" ] && $kexec_command -e -x >& /dev/null
 
 HALTARGS="-d"
-[ "$INIT_HALT" != "HALT"] && HALTARGS="$HALTARGS -p"
+[ "$INIT_HALT" != "HALT" ] && HALTARGS="$HALTARGS -p"
 
 exec $command $HALTARGS

Comment 27 errata-xmlrpc 2009-09-02 11:14:22 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2009-1344.html