[Pkg-sysvinit-commits] r1483 - in sysvinit/branches/upstream/current: . doc man src

Petter Reinholdtsen pere at alioth.debian.org
Fri Jul 24 09:26:08 UTC 2009


Author: pere
Date: 2009-07-24 09:26:07 +0000 (Fri, 24 Jul 2009)
New Revision: 1483

Removed:
   sysvinit/branches/upstream/current/build
   sysvinit/branches/upstream/current/doc/sysvinit-2.85.lsm
Modified:
   sysvinit/branches/upstream/current/COPYRIGHT
   sysvinit/branches/upstream/current/README
   sysvinit/branches/upstream/current/doc/Changelog
   sysvinit/branches/upstream/current/man/bootlogd.8
   sysvinit/branches/upstream/current/man/halt.8
   sysvinit/branches/upstream/current/man/init.8
   sysvinit/branches/upstream/current/man/initscript.5
   sysvinit/branches/upstream/current/man/inittab.5
   sysvinit/branches/upstream/current/man/killall5.8
   sysvinit/branches/upstream/current/man/last.1
   sysvinit/branches/upstream/current/man/mesg.1
   sysvinit/branches/upstream/current/man/mountpoint.1
   sysvinit/branches/upstream/current/man/pidof.8
   sysvinit/branches/upstream/current/man/runlevel.8
   sysvinit/branches/upstream/current/man/shutdown.8
   sysvinit/branches/upstream/current/man/sulogin.8
   sysvinit/branches/upstream/current/src/Makefile
   sysvinit/branches/upstream/current/src/bootlogd.c
   sysvinit/branches/upstream/current/src/dowall.c
   sysvinit/branches/upstream/current/src/halt.c
   sysvinit/branches/upstream/current/src/hddown.c
   sysvinit/branches/upstream/current/src/init.c
   sysvinit/branches/upstream/current/src/init.h
   sysvinit/branches/upstream/current/src/killall5.c
   sysvinit/branches/upstream/current/src/last.c
   sysvinit/branches/upstream/current/src/shutdown.c
   sysvinit/branches/upstream/current/src/sulogin.c
   sysvinit/branches/upstream/current/src/utmp.c
   sysvinit/branches/upstream/current/src/utmpdump.c
Log:
[svn-upgrade] Integrating new upstream version, sysvinit (2.87dsf)

Modified: sysvinit/branches/upstream/current/COPYRIGHT
===================================================================
--- sysvinit/branches/upstream/current/COPYRIGHT	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/COPYRIGHT	2009-07-24 09:26:07 UTC (rev 1483)
@@ -12,7 +12,7 @@
 
     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
 On Debian GNU/Linux systems, the complete text of the GNU General
 Public License can be found in `/usr/share/common-licenses/GPL'.

Modified: sysvinit/branches/upstream/current/README
===================================================================
--- sysvinit/branches/upstream/current/README	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/README	2009-07-24 09:26:07 UTC (rev 1483)
@@ -5,3 +5,4 @@
 obsolete	Really obsolete stuff ;)
 src		Source code
 
+Send patches to initscripts-ng-devel at lists.alioth.debian.org.

Modified: sysvinit/branches/upstream/current/doc/Changelog
===================================================================
--- sysvinit/branches/upstream/current/doc/Changelog	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/doc/Changelog	2009-07-24 09:26:07 UTC (rev 1483)
@@ -1,3 +1,91 @@
+sysvinit (2.87dsf) world; urgency=low
+
+  * Fix typos and do minor updates in the manual pages.
+  * Correct section of mountpoint(1).
+  * Document -e and -t options for telinit in init(8).
+  * Update address of FSF in the COPYRIGHT file.
+  * Document in halt(8) that -n might not disable all syncing.
+    Patch by Bill Nottingham and Fedora
+  * Adjust output from "last -x".  In reboot lines, print endpoint
+    of uptime too.  In shutdown lines print downtimes rather than
+    the time between downs.  Fix typo in string compare in last.c.
+    Patch by Thomas Hood.
+  * Improve handling of IPv6 addresses in last.  Patch from Fedora.
+  * Document last options in usage information, previously only
+    mentioned in the manual page.
+  * Add new option -F to last, to output full date string instead
+    of the short form provided by default.  Patch from Olaf Dabrunz
+    and SuSe.
+  * Adjust build rules to make sure the installed binaries
+    are stripped.
+  * Increase the compiler warning level when building.
+  * Fix utmp/wtmp updating on 64-bit platforms.  Patch by Bill
+    Nottingham and Fedora.
+  * Avoid unchecked return value from malloc() in utmpdump.
+    Patch from Christian 'Dr. Disk' Hechelmann and Fedora.
+  * Make sure to use execle and no execl when passing environment to
+    the new process.  Patch from RedHat.
+  * Correct init to make sure the waiting status is preserved across
+    re-exec.  Patch from RedHat.
+  * Correct init to avoid race condition when starting programs during
+    boot.  Patch from SuSe.
+  * Allow 'telinit u' in runlevels 0 and 6.  Patch from Thomas Hood.
+  * Change install rules to make pidof an absolute symlink.  Patch from
+    Thomas Hood.
+  * Improve error message from init if fork() fail.  Patch found in Suse.
+  * Add support for SE Linux capability handling.  Patch from Manoj
+    Srivastava, adjusted to avoid aborting if SE policy was loaded in
+    the initrd with patch from Bill Nottingham and Fedora.
+  * Add -c option to pidof for only matching processes with the same
+    process root.  Ignore -c when not running as root.  Patch from
+    Thomas Woerner and Fedora.
+  * Adjust init to terminate argv0 with one 0 rather than two so that
+    process name can be one character longer.  Patch by Kir Kolyshkin.
+  * Make sure bootlogd exit with non-error exit code when forking of
+    the child successfully.
+  * Add bootlogd option -s to make it possible to control the use of
+    fdatasync().  Patch from Thomas Hood.
+  * Add bootlogd option -c to tell it to create the log file if it does
+    not exist.  Patch from Thomas Hood.
+  * Let bootlogd also look at ttyB* devices to work on HPPA.  Patch
+    from Thomas Hood.
+  * Change init to use setenv() instead of putenv, make sure the PATH
+    value is usable on re-exec.  Patch from Thomas Hood.
+  * Add usleep in killall5 after killing processes, to force the kernel
+    to reschedule.  Patch from SuSe.
+  * Modify pidof to not print empty line if no pid was found.
+  * Modify init and sulogin to fix emergency mode's tty, making sure ^C
+    and ^Z work when booting with 'emergency' kernel option.  Patch from
+    Samuel Thibault.
+  * Modify init to allow some time for failed opens to resolve themselves.
+    Patch from Bill Nottingham and Fedora.
+  * Modify init to shut down IDE, SCSI and SATA disks properly.  Patches
+    from Sebastian Reichelt, Werner Fink and SuSe.
+  * Modify wall to use UT_LINESIZE from <utmp.h> instead of hardcoded
+    string lengths.  Patch from SuSe.
+  * Change wall to make halt include hostname in output.
+  * Change killall to avoid killing init by mistake.  Patch from SuSe.
+  * Change killall5 to use the exit value to report if it found any
+    processes to kill.  Patch from Debian.
+  * Add option -o opmitpid to killall5, to make it possible to skip
+    some pids during shutdown.  Based on patch from Colin Watson and
+    Ubuntu.
+  * Add references between killall5 and pidof manual pages.  Patch from Debian.
+  * Modify killall to work better with user space file system, by
+    changing cwd to /proc when stopping and killing processes, and
+    avoiding stat() when the value isn't used.  Also, lock process
+    pages in memory to avoid paging when user processes are stopped.
+    Patch from Debian and Goswin von Brederlow with changes by Kel
+    Modderman.
+  * Change shutdown to only accept flags -H and -P with the -h flag,
+    and document this requirement in the manual page.
+  * Change reboot/halt to work properly when used as a login shell.
+    Patch by Dale R. Worley and Fedora.
+  * Let sulogin fall back to the staticly linked /bin/sash if both roots
+    shell and /bin/sh fail to execute.
+
+ -- Petter Reinholdtsen <pere at hungry.com>  Sun, 12 Jul 2009 19:58:10 +0200
+
 sysvinit (2.86) cistron; urgency=low
 
   * Fixed up bootlogd to read /proc/cmdline. Also keep an internal

Deleted: sysvinit/branches/upstream/current/doc/sysvinit-2.85.lsm
===================================================================
--- sysvinit/branches/upstream/current/doc/sysvinit-2.85.lsm	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/doc/sysvinit-2.85.lsm	2009-07-24 09:26:07 UTC (rev 1483)
@@ -1,14 +0,0 @@
-Begin3
-Title:		sysvinit and utilities
-Version:	2.85
-Entered-Date:	15APR2003
-Description:	This is the Linux System V init.
-		This version can be compiled with glibc 2.0.6 and up.
-Author:		miquels at cistron.nl (Miquel van Smoorenburg)
-Primary-Site:	ftp.cistron.nl /pub/people/miquels/software
-		92K sysvinit-2.85.tar.gz
-Alternate-Site:	sunsite.unc.edu /pub/Linux/system/daemons/init
-		92K sysvinit-2.85.tar.gz
-Copying-Policy:	GPL
-Keywords:	init shutdown halt reboot
-End

Modified: sysvinit/branches/upstream/current/man/bootlogd.8
===================================================================
--- sysvinit/branches/upstream/current/man/bootlogd.8	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/man/bootlogd.8	2009-07-24 09:26:07 UTC (rev 1483)
@@ -3,37 +3,53 @@
 bootlogd \- record boot messages
 .SH SYNOPSIS
 .B /sbin/bootlogd
+.RB [ \-c ]
 .RB [ \-d ]
 .RB [ \-r ]
+.RB [ \-s ]
 .RB [ \-v ]
 .RB [ " -l logfile " ]
 .RB [ " -p pidfile " ]
 .SH DESCRIPTION
 \fBBootlogd\fP runs in the background and copies all strings sent to the
 \fI/dev/console\fP device to a logfile. If the logfile is not accessible,
-the messages will be buffered in-memory until it is.
+the messages will be kept in memory until it is.
 .SH OPTIONS
 .IP \fB\-d\fP
 Do not fork and run in the background.
+.IP \fB\-c\fP
+Attempt to write to the logfile even if it does not yet exist.
+Without this option,
+.B bootlogd
+will wait for the logfile to appear before attempting to write to it.
+This behavior prevents bootlogd from creating logfiles under mount points.
 .IP \fB\-r\fP
 If there is an existing logfile called \fIlogfile\fP rename it to
 \fIlogfile~\fP unless \fIlogfile~\fP already exists.
+.IP \fB\-s\fP
+Ensure that the data is written to the file after each line by calling
+.BR fdatasync (3).
+This will slow down a
+.BR fsck (8)
+process running in parallel.
 .IP \fB\-v\fP
 Show version.
-.IP \fB\-l logfile\fP
+.IP "\fB\-l\fP \fIlogfile\fP"
 Log to this logfile. The default is \fI/var/log/boot\fP.
-.IP \fB\-p pidfile\fP
+.IP "\fB\-p\fP \fIpidfile\fP"
 Put process-id in this file. The default is no pidfile.
 .SH BUGS
-Bootlogd works by redirecting the console output from the console
-device. It copies that output to the real console device and a
-logfile. There is no standard way to find out the real console device
-if you have a new-style \fI/dev/console\fP device (major 5, minor 1).
-\fBBootlogd\fP tries to parse the kernel command line, looking for
-console= lines and deducts the real console device from that. If that
-syntax is ever changed by the kernel, or a console-type is used
-bootlogd does not know about, bootlogd will not work.
+Bootlogd works by redirecting the console output from the console device.
+(Consequently \fBbootlogd\fP requires PTY support in the kernel configuration.)
+It copies that output to the real console device and to a log file.
+There is no standard way of ascertaining the real console device
+if you have a new-style \fI/dev/console\fP device (major 5, minor 1)
+so \fBbootlogd\fP parses the kernel command line looking for
+\fBconsole=...\fP lines and deduces the real console device from that.
+If that syntax is ever changed by the kernel, or a console type is used that
+\fBbootlogd\fP does not know about then \fBbootlogd\fP will not work.
+
 .SH AUTHOR
 Miquel van Smoorenburg, miquels at cistron.nl
 .SH "SEE ALSO"
-.BR dmesg (8)
+.BR dmesg (8),  fdatasync (3).

Modified: sysvinit/branches/upstream/current/man/halt.8
===================================================================
--- sysvinit/branches/upstream/current/man/halt.8	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/man/halt.8	2009-07-24 09:26:07 UTC (rev 1483)
@@ -36,7 +36,7 @@
 .SH DESCRIPTION
 \fBHalt\fP notes that the system is being brought down in the file
 \fI/var/log/wtmp\fP, and then either tells the kernel to halt, reboot or
-poweroff the system.
+power-off the system.
 .PP
 If \fBhalt\fP or \fBreboot\fP is called when the system is
 \fInot\fP in runlevel \fB0\fP or \fB6\fP, in other words when it's running
@@ -50,7 +50,8 @@
 .\"{{{  Options
 .SH OPTIONS
 .IP \fB\-n\fP
-Don't sync before reboot or halt.
+Don't sync before reboot or halt. Note that the kernel and storage
+drivers may still sync.
 .IP \fB\-w\fP
 Don't actually reboot or halt but only write the wtmp record
 (in the \fI/var/log/wtmp\fP file).
@@ -61,9 +62,9 @@
 .IP \fB\-i\fP
 Shut down all network interfaces just before halt or reboot.
 .IP \fB\-h\fP
-Put all harddrives on the system in standby mode just before halt or poweroff.
+Put all hard drives on the system in stand-by mode just before halt or power-off.
 .IP \fB\-p\fP
-When halting the system, do a poweroff. This is the default when halt is
+When halting the system, switch off the power. This is the default when halt is
 called as \fBpoweroff\fP.
 .\"}}}
 .\"{{{  Diagnostics
@@ -80,14 +81,14 @@
 correctly) \fBshutdown\fP will be called, which might not be what you want.
 Use the \fB-f\fP flag if you want to do a hard \fBhalt\fP or \fBreboot\fP.
 .PP
-The \fB-h\fP flag puts all harddisks in standby mode just before halt
-or poweroff. Right now this is only implemented for IDE drives. A side
-effect of putting the drive in standby mode is that the write cache
+The \fB-h\fP flag puts all hard disks in standby mode just before halt
+or power-off. Right now this is only implemented for IDE drives. A side
+effect of putting the drive in stand-by mode is that the write cache
 on the disk is flushed. This is important for IDE drives, since the
-kernel doesn't flush the write-cache itself before poweroff.
+kernel doesn't flush the write cache itself before power-off.
 .PP
 The \fBhalt\fP program uses /proc/ide/hd* to find all IDE disk devices,
-which means that /proc needs to be mounted when \fBhalt\fP or
+which means that \fI/proc\fP needs to be mounted when \fBhalt\fP or
 \fBpoweroff\fP is called or the \fB-h\fP switch will do nothing.
 .PP
 .\"}}}

Modified: sysvinit/branches/upstream/current/man/init.8
===================================================================
--- sysvinit/branches/upstream/current/man/init.8	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/man/init.8	2009-07-24 09:26:07 UTC (rev 1483)
@@ -12,12 +12,15 @@
 .RB [ " -a " ]
 .RB [ " -s " ]
 .RB [ " -b " ]
-.RB [ " -z xxx " ]
+[ \fB\-z\fP \fIxxx\fP ]
 .RB [ " 0123456Ss " ]
 .br
 .B /sbin/telinit
-.RB [ " \-t sec " ]
+[ \fB\-t\fP \fISECONDS\fP ]
 .RB [ " 0123456sSQqabcUu " ]
+.br
+.B /sbin/telinit
+[ \fB\-e\fP \fIVAR\fP[\fB=\fP\fIVAL\fP] ]
 .\"}}}
 .\"{{{  Description
 .SH DESCRIPTION
@@ -141,13 +144,22 @@
 tell \fBinit\fP to switch to single user mode.
 .IP "\fBU\fP or \fBu\fP"
 tell \fBinit\fP to re-execute itself (preserving the state). No re-examining of 
-\fB/etc/inittab\fP file happens. Run level should be one of \fBSs12345\fP,
+\fB/etc/inittab\fP file happens. Run level should be one of
+\fBSs0123456\fP
 otherwise request would be silently ignored.
 .PP
-\fBtelinit\fP can also tell \fBinit\fP how long it should wait
+\fBtelinit\fP can tell \fBinit\fP how long it should wait
 between sending processes the SIGTERM and SIGKILL signals.  The default
-is 5 seconds, but this can be changed with the \fB-t sec\fP option.
+is 5 seconds, but this can be changed with the \fB-t\fP option.
 .PP
+\fBtelinit -e\fP tells \fBinit\fP to change the environment
+for processes it spawns.
+The argument of \fB-e\fP is either of the form \fIVAR\fP=\fIVAL\fP
+which sets variable \fIVAR\fP to value \fIVAL\fP,
+or of the form \fIVAR\fP
+(without an equality sign)
+which unsets variable \fIVAR\fP.
+.PP
 \fBtelinit\fP can be invoked only by users with appropriate
 privileges.
 .PP
@@ -198,8 +210,8 @@
 command line manually.
 .PP
 .TP 0.5i
-.B -z xxx
-The argument to -z is ignored. You can use this to expand the command
+.BI "-z " xxx
+The argument to \fB-z\fP is ignored. You can use this to expand the command
 line a bit, so that it takes some more space on the stack. \fBInit\fP
 can then manipulate the command line so that \fBps\fP(1) shows
 the current runlevel.

Modified: sysvinit/branches/upstream/current/man/initscript.5
===================================================================
--- sysvinit/branches/upstream/current/man/initscript.5	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/man/initscript.5	2009-07-24 09:26:07 UTC (rev 1483)
@@ -29,9 +29,9 @@
   PATH=/bin:/sbin:/usr/bin:/usr/sbin
   export PATH
 
-  # Increase the hard filedescriptor limit for all processes
-  # to 8192.  The soft limit is still 1024, but any unpriviliged
-  # process can increase it's soft limit up to the hardlimit
+  # Increase the hard file descriptor limit for all processes
+  # to 8192.  The soft limit is still 1024, but any unprivileged
+  # process can increase its soft limit up to the hard limit
   # with "ulimit -Sn xxx" (needs a 2.2.13 or later Linux kernel).
   ulimit -Hn 8192
 

Modified: sysvinit/branches/upstream/current/man/inittab.5
===================================================================
--- sysvinit/branches/upstream/current/man/inittab.5	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/man/inittab.5	2009-07-24 09:26:07 UTC (rev 1483)
@@ -128,7 +128,7 @@
 .\"}}}
 .\"{{{  powerokwait
 .IP \fBpowerokwait\fP
-This process will be executed as soon as \fBinit\fP is informormed that the
+This process will be executed as soon as \fBinit\fP is informed that the
 power has been restored.
 .\"}}}
 .\"{{{  powerfailnow

Modified: sysvinit/branches/upstream/current/man/killall5.8
===================================================================
--- sysvinit/branches/upstream/current/man/killall5.8	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/man/killall5.8	2009-07-24 09:26:07 UTC (rev 1483)
@@ -4,14 +4,29 @@
 .SH SYNOPSIS
 .B killall5
 .RB -signalnumber
+.RB [ \-o
+.IR omitpid ]
+.RB [ \-o
+.IR omitpid.. ]
 .SH DESCRIPTION
 .B killall5
 is the SystemV killall command. It sends a signal to all processes except
 kernel threads and the processes in its own session, so it won't kill
 the shell that is running the script it was called from. Its primary
 (only) use is in the \fBrc\fP scripts found in the /etc/init.d directory.
+.SH OPTIONS
+.IP "-o \fIomitpid\fP"
+Tells \fIkillall5\fP to omit processes with that process id.
+.SH NOTES
+\fIkillall5\fP can also be invoked as pidof, which is simply a
+(symbolic) link to the \fIkillall5\fP program.
+.SH EXIT STATUS
+The program return zero if it killed processes.  It return 2 if no
+process were killed, and 1 if it was unable to find any processes
+(/proc/ is missing).
 .SH SEE ALSO
 .BR halt (8),
-.BR reboot (8)
+.BR reboot (8),
+.BR pidof (8)
 .SH AUTHOR
 Miquel van Smoorenburg, miquels at cistron.nl

Modified: sysvinit/branches/upstream/current/man/last.1
===================================================================
--- sysvinit/branches/upstream/current/man/last.1	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/man/last.1	2009-07-24 09:26:07 UTC (rev 1483)
@@ -12,7 +12,7 @@
 .RB [ \-R ]
 .RB [ \-\fInum\fP ]
 .RB "[ \-\fBn\fP \fInum\fP ]"
-.RB [ \-adiox ]
+.RB [ \-adFiox ]
 .RB "[ \-\fBf\fP \fIfile\fP ]"
 .RB "[ \-\fBt\fP \fIYYYYMMDDHHMMSS\fP ]"
 .RI [ name... ]
@@ -23,7 +23,7 @@
 .RB [ \-\fInum\fP ]
 .RB "[ \-\fBn\fP \fInum\fP ]"
 .RB "[ \-\fBf\fP \fIfile\fP ]"
-.RB [ \-adiox ]
+.RB [ \-adFiox ]
 .RI [ name... ]
 .RI [ tty... ]
 .\"}}}
@@ -51,6 +51,8 @@
 .\"}}}
 .\"{{{  Options
 .SH OPTIONS
+.IP "\fB\-f\fP \fIfile\fP"
+Tells \fBlast\fP to use a specific file instead of \fB/var/log/wtmp\fP.
 .IP \fB\-\fP\fInum\fP
 This is a count telling \fBlast\fP how many lines to show.
 .IP "\fB\-n\fP \fInum\fP"
@@ -69,6 +71,8 @@
 For non-local logins, Linux stores not only the host name of the remote
 host but its IP number as well. This option translates the IP number
 back into a hostname.
+.IP \fB\-F\fP
+Print full login and logout times and dates.
 .IP \fB\-i\fP
 This option is like \fB-d\fP in that it displays the IP number of the remote
 host, but it displays the IP number in numbers-and-dots notation.

Modified: sysvinit/branches/upstream/current/man/mesg.1
===================================================================
--- sysvinit/branches/upstream/current/man/mesg.1	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/man/mesg.1	2009-07-24 09:26:07 UTC (rev 1483)
@@ -26,7 +26,9 @@
 .PP
 If no option is given, \fBmesg\fP prints out the current access state of your
 terminal.
-.PP NOTES
+.\"}}}
+.\"{{{  Notes
+.SH NOTES
 \fBMesg\fP assumes that its standard input is connected to your
 terminal. That also means that if you are logged in multiple times,
 you can get/set the mesg status of other sessions by using redirection.

Modified: sysvinit/branches/upstream/current/man/mountpoint.1
===================================================================
--- sysvinit/branches/upstream/current/man/mountpoint.1	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/man/mountpoint.1	2009-07-24 09:26:07 UTC (rev 1483)
@@ -1,4 +1,4 @@
-.TH MOUNTPOINT 8 "Mar 15, 2004" "" "Linux System Administrator's Manual"
+.TH MOUNTPOINT 1 "Mar 15, 2004" "" "Linux System Administrator's Manual"
 .SH NAME
 mountpoint \- see if a directory is a mountpoint
 .SH SYNOPSIS

Modified: sysvinit/branches/upstream/current/man/pidof.8
===================================================================
--- sysvinit/branches/upstream/current/man/pidof.8	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/man/pidof.8	2009-07-24 09:26:07 UTC (rev 1483)
@@ -4,6 +4,7 @@
 .SH SYNOPSIS
 .B pidof
 .RB [ \-s ]
+.RB [ \-c ]
 .RB [ \-x ]
 .RB [ \-o
 .IR omitpid ]
@@ -24,16 +25,27 @@
 .SH OPTIONS
 .IP -s
 Single shot - this instructs the program to only return one \fIpid\fP.
+.IP -c
+Only return process ids that are running with the same root directory.
+This option is ignored for non-root users, as they will be unable to check
+the current root directory of processes they do not own.
 .IP -x
 Scripts too - this causes the program to also return process id's of
 shells running the named scripts.
-.IP -o \fIomitpid\fP
+.IP "-o \fIomitpid\fP"
 Tells \fIpidof\fP to omit processes with that process id. The special
 pid \fB%PPID\fP can be used to name the parent process of the \fIpidof\fP
 program, in other words the calling shell or shell script.
+.SH "EXIT STATUS"
+.TP
+.B 0
+At least one program was found with the requested name.
+.TP
+.B 1
+No program was found with the requested name.
 .SH NOTES
-\fIpidof\fP is simply a (symbolic) link to the \fIkillall5\fP program,
-which should also be located in \fP/sbin\fP.
+\fIpidof\fP is actually the same program as \fIkillall5\fP;
+the program behaves according to the name under which it is called.
 .PP
 When \fIpidof\fP is invoked with a full pathname to the program it
 should find the pid of, it is reasonably safe. Otherwise it is possible
@@ -43,6 +55,7 @@
 .BR shutdown (8),
 .BR init (8),
 .BR halt (8),
-.BR reboot (8)
+.BR reboot (8),
+.BR killall5 (8)
 .SH AUTHOR
 Miquel van Smoorenburg, miquels at cistron.nl

Modified: sysvinit/branches/upstream/current/man/runlevel.8
===================================================================
--- sysvinit/branches/upstream/current/man/runlevel.8	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/man/runlevel.8	2009-07-24 09:26:07 UTC (rev 1483)
@@ -1,6 +1,6 @@
 .TH RUNLEVEL 8 "May 27, 1997" "" "Linux System Administrator's Manual"
 .SH NAME
-runlevel -- find the current and previous system runlevel.
+runlevel -- find the previous and current system runlevel.
 .SH SYNOPSIS
 .B runlevel 
 .RI [ utmp ]

Modified: sysvinit/branches/upstream/current/man/shutdown.8
===================================================================
--- sysvinit/branches/upstream/current/man/shutdown.8	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/man/shutdown.8	2009-07-24 09:26:07 UTC (rev 1483)
@@ -54,12 +54,12 @@
 .\"}}}
 .\"{{{  -h
 .IP \fB\-h\fP
-Halt or poweroff after shutdown.
+Halt or power off after shutdown.
 .\"}}}
 .\"{{{  -H
 .IP \fB\-H\fP
-Halt action is to halt or drop into boot monitor on systems that
-support it.
+Modifier to the -h flag.  Halt action is to halt or drop into boot
+monitor on systems that support it.  Must be used with the -h flag.
 .\"}}}
 .\"{{{  -P
 .IP \fB\-P\fP
@@ -100,10 +100,11 @@
 Second, it can be in the format \fB+\fP\fIm\fP, in which \fIm\fP is the
 number of minutes to wait.  The word \fBnow\fP is an alias for \fB+0\fP.
 .PP
-If shutdown is called with a delay, it creates the advisory file
+If shutdown is called with a delay, it will create the advisory file
 .I /etc/nologin
 which causes programs such as \fIlogin(1)\fP to not allow new user
-logins. Shutdown removes this file if it is stopped before it
+logins. This file is created five minutes before the shutdown sequence
+starts. Shutdown removes this file if it is stopped before it
 can signal init (i.e. it is cancelled or something goes wrong).
 It also removes it before calling init to change the runlevel.
 .PP
@@ -117,13 +118,13 @@
 file \fI/forcefsck\fP which can be tested by the system when it comes
 up again.  The boot rc file can test if this file is present, and decide
 to run \fBfsck\fP(1) with a special `force' flag so that even properly
-unmounted filesystems get checked.
+unmounted file systems get checked.
 After that, the boot process should remove \fI/forcefsck\fP.
 .PP
 The \fB-n\fP flag causes \fBshutdown\fP not to call \fBinit\fP, 
 but to kill all running processes itself. 
 \fBshutdown\fP will then turn off quota, accounting, and swapping
-and unmount all filesystems.
+and unmount all file systems.
 .\"}}}
 .\"{{{  Files
 .SH ACCESS CONTROL

Modified: sysvinit/branches/upstream/current/man/sulogin.8
===================================================================
--- sysvinit/branches/upstream/current/man/sulogin.8	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/man/sulogin.8	2009-07-24 09:26:07 UTC (rev 1483)
@@ -1,61 +1,68 @@
-.TH SULOGIN 8 "04 Nov 2003" "" "Linux System Administrator's Manual"
+.TH SULOGIN 8 "17 Jan 2006" "" "Linux System Administrator's Manual"
 .SH NAME
-sulogin -- Single-user login
+sulogin \- Single-user login
 .SH SYNOPSIS
 .B sulogin
-.RB [ " -e " ]
-.RB [ " -p " ]
-.RB [ " -t timeout " ]
-.RB [ " tty-device " ]
+[ \fB\-e\fP ]
+[ \fB\-p\fP ]
+[ \fB\-t\fP \fISECONDS\fP ]
+[ \fITTY\fP ]
 .SH DESCRIPTION
 .I sulogin
-is invoked by \fBinit(8)\fP when the system goes into single user mode
-(this is done through an entry in \fIinittab(5)\fP). \fBInit\fP also
-tries to execute \fIsulogin\fP when it is passed the \fB-b\fP flag
-from the bootmonitor (eg, LILO).
+is invoked by \fBinit(8)\fP when the system goes into single user mode.
+(This is done through an entry in \fIinittab(5)\fP.)
+\fBInit\fP also
+tries to execute \fIsulogin\fP when
+the boot loader (e.g., \fBgrub\fP(8))
+passes it the \fB\-b\fP option.
 .PP
 The user is prompted
 .IP "" .5i
 Give root password for system maintenance
 .br
-(or type Control-D for normal startup):
+(or type Control\-D for normal startup):
 .PP
 \fIsulogin\fP will be connected to the current terminal, or to the
 optional device that can be specified on the command line
 (typically \fB/dev/console\fP).
 .PP
-If the \fB-p\fP flag was set, the single-user shell will be invoked
-with a \fIdash\fP as the first character in \fIargv[0]\fP. That will
-cause most shells to behave as a login shell. The default is \fInot\fP
-to do this, so that the shell will \fInot\fP read \fB/etc/profile\fP
+If the \fB\-t\fP option is used then the program only waits
+the given number of seconds for user input.
+.PP
+If the \fB\-p\fP option is used then the single-user shell is invoked
+with a \fIdash\fP as the first character in \fIargv[0]\fP.
+This causes the shell process to behave as a login shell.
+The default is \fInot\fP to do this,
+so that the shell will \fInot\fP read \fB/etc/profile\fP
 or \fB$HOME/.profile\fP at startup.
 .PP
-After the user exits the single-user shell, or presses control-d at the
-prompt, the system will (continue to) boot to the default runlevel.
+After the user exits the single-user shell,
+or presses control\-D at the prompt,
+the system will (continue to) boot to the default runlevel.
 .SH ENVIRONMENT VARIABLES
 \fIsulogin\fP looks for the environment variable \fBSUSHELL\fP or
 \fBsushell\fP to determine what shell to start. If the environment variable
 is not set, it will try to execute root's shell from /etc/passwd. If that
 fails it will fall back to \fB/bin/sh\fP.
 .PP
-This is very valuable together with the \fB-b\fP flag to init. To boot
+This is very valuable together with the \fB\-b\fP option to init. To boot
 the system into single user mode, with the root file system mounted read/write,
-using a special "failsafe" shell that is statically linked (this example
+using a special "fail safe" shell that is statically linked (this example
 is valid for the LILO bootprompt)
 .PP
-boot: linux -b rw sushell=/sbin/sash
+boot: linux \-b rw sushell=/sbin/sash
 .SH FALLBACK METHODS
 \fIsulogin\fP checks the root password using the standard method (getpwnam)
 first.
-Then, if the \fB-e\fP option was specified,
+Then, if the \fB\-e\fP option was specified,
 \fIsulogin\fP examines these files directly to find the root password:
 .PP
 /etc/passwd,
 .br
 /etc/shadow (if present)
 .PP
-If they are damaged or non-existant, sulogin will start a root shell
-without asking for a password. Only use the \fB-e\fP option if you
+If they are damaged or nonexistent, sulogin will start a root shell
+without asking for a password. Only use the \fB\-e\fP option if you
 are sure the console is physically protected against unauthorized access.
 .SH AUTHOR
 Miquel van Smoorenburg <miquels at cistron.nl>

Modified: sysvinit/branches/upstream/current/src/Makefile
===================================================================
--- sysvinit/branches/upstream/current/src/Makefile	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/src/Makefile	2009-07-24 09:26:07 UTC (rev 1483)
@@ -9,7 +9,7 @@
 #
 
 CC	= gcc
-CFLAGS	= -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE
+CFLAGS	= -ansi -W -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE
 LDFLAGS	= -s
 STATIC	=
 
@@ -46,9 +46,23 @@
 BIN_OWNER	= root
 BIN_GROUP	= root
 BIN_COMBO	= $(BIN_OWNER):$(BIN_GROUP)
-INSTALL		= install -o $(BIN_OWNER) -g $(BIN_GROUP)
+STRIP		= strip -s -R .comment
+INSTALL_EXEC	= install -o $(BIN_OWNER) -g $(BIN_GROUP) -m 755
+INSTALL_DATA	= install -o $(BIN_OWNER) -g $(BIN_GROUP) -m 644
 MANDIR		= /usr/share/man
 
+ifeq ($(WITH_SELINUX),yes)
+  SELINUX_DEF=-DWITH_SELINUX
+  INIT_SELIBS=-lsepol -lselinux
+  SULOGIN_SELIBS=-lselinux	
+else
+  SELINUX_DEF=
+  INIT_SELIBS=
+  SULOGIN_SELIBS=
+endif
+
+
+
 # Additional libs for GNU libc.
 ifneq ($(wildcard /usr/lib/libcrypt.a),)
 LCRYPT		= -lcrypt
@@ -57,7 +71,7 @@
 all:		$(BIN) $(SBIN) $(USRBIN)
 
 init:		init.o init_utmp.o
-		$(CC) $(LDFLAGS) $(STATIC) -o $@ init.o init_utmp.o
+		$(CC) $(LDFLAGS) $(STATIC) -o $@ init.o init_utmp.o $(INIT_SELIBS)
 
 halt:		halt.o ifdown.o hddown.o utmp.o reboot.h
 		$(CC) $(LDFLAGS) -o $@ halt.o ifdown.o hddown.o utmp.o
@@ -78,7 +92,7 @@
 		$(CC) $(LDFLAGS) -o $@ runlevel.o
 
 sulogin:	sulogin.o
-		$(CC) $(LDFLAGS) $(STATIC) -o $@ sulogin.o $(LCRYPT)
+		$(CC) $(LDFLAGS) $(STATIC) $(SELINUX_DEF) -o $@ $^ $(LCRYPT) $(SULOGIN_SELIBS)
 
 wall:		dowall.o wall.o
 		$(CC) $(LDFLAGS) -o $@ dowall.o wall.o
@@ -89,8 +103,11 @@
 bootlogd:	bootlogd.o
 		$(CC) $(LDFLAGS) -o $@ bootlogd.o -lutil
 
+sulogin.o:	sulogin.c 
+		$(CC) -c $(CFLAGS) $(SELINUX_DEF) sulogin.c
+
 init.o:		init.c init.h set.h reboot.h initreq.h
-		$(CC) -c $(CFLAGS) init.c
+		$(CC) -c $(CFLAGS) $(SELINUX_DEF)  init.c
 
 utmp.o:		utmp.c init.h
 		$(CC) -c $(CFLAGS) utmp.c
@@ -111,31 +128,34 @@
 
 install:
 		for i in $(BIN); do \
-			$(INSTALL) -m 755 $$i $(ROOT)/bin/; \
+			$(STRIP) $$i ; \
+			$(INSTALL_EXEC) $$i $(ROOT)/bin/ ; \
 		done
 		for i in $(SBIN); do \
-			$(INSTALL) -m 755 $$i $(ROOT)/sbin/; \
+			$(STRIP) $$i ; \
+			$(INSTALL_EXEC) $$i $(ROOT)/sbin/ ; \
 		done
 		for i in $(USRBIN); do \
-			$(INSTALL) -m 755 $$i $(ROOT)/usr/bin/; \
+			$(STRIP) $$i ; \
+			$(INSTALL_EXEC) $$i $(ROOT)/usr/bin/ ; \
 		done
-		# $(INSTALL) -m 755 etc/initscript.sample $(ROOT)/etc/
+		# $(INSTALL_EXEC) etc/initscript.sample $(ROOT)/etc/
 		ln -sf halt $(ROOT)/sbin/reboot
 		ln -sf halt $(ROOT)/sbin/poweroff
 		ln -sf init $(ROOT)/sbin/telinit
-		ln -sf ../sbin/killall5 $(ROOT)/bin/pidof
+		ln -sf /sbin/killall5 $(ROOT)/bin/pidof
 		if [ ! -f $(ROOT)/usr/bin/lastb ]; then \
 			ln -sf last $(ROOT)/usr/bin/lastb; \
 		fi
-		$(INSTALL) -m 644 initreq.h $(ROOT)/usr/include/
+		$(INSTALL_DATA) initreq.h $(ROOT)/usr/include/
 		for i in $(MAN1); do \
-			$(INSTALL) -m 644 ../man/$$i $(ROOT)$(MANDIR)/man1/; \
+			$(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man1/; \
 		done
 		for i in $(MAN5); do \
-			$(INSTALL) -m 644 ../man/$$i $(ROOT)$(MANDIR)/man5/; \
+			$(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man5/; \
 		done
 		for i in $(MAN8); do \
-			$(INSTALL) -m 644 ../man/$$i $(ROOT)$(MANDIR)/man8/; \
+			$(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man8/; \
 		done
 ifeq ($(ROOT),)
 		#

Modified: sysvinit/branches/upstream/current/src/bootlogd.c
===================================================================
--- sysvinit/branches/upstream/current/src/bootlogd.c	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/src/bootlogd.c	2009-07-24 09:26:07 UTC (rev 1483)
@@ -56,6 +56,8 @@
 
 int got_signal = 0;
 int didnl = 1;
+int createlogfile = 0;
+int syncalot = 0;
 
 struct line {
 	char buf[256];
@@ -71,6 +73,7 @@
 	char	*dev1;
 	char	*dev2;
 } consdev[] = {
+	{ "ttyB",	"/dev/ttyB%s",		NULL		},
 	{ "ttySC",	"/dev/ttySC%s",		"/dev/ttsc/%s"	},
 	{ "ttyS",	"/dev/ttyS%s",		"/dev/tts/%s"	},
 	{ "tty",	"/dev/tty%s",		"/dev/vc/%s"	},
@@ -82,7 +85,7 @@
  *	Devices to try as console if not found on kernel command line.
  *	Tried from left to right (as opposed to kernel cmdline).
  */
-char *defcons[] = { "tty0", "hvc0", "ttyS0", "ttySC0", NULL };
+char *defcons[] = { "tty0", "hvc0", "ttyS0", "ttySC0", "ttyB0", NULL };
 
 /*
  *	Catch signals.
@@ -269,8 +272,6 @@
 	/*
 	 *	OK, so find console= in /proc/cmdline.
 	 *	Parse in reverse, opening as we go.
-	 *
-	 *	Valid console devices: ttySC, ttyS, tty, hvc.
 	 */
 	p = buf + n;
 	*p-- = 0;
@@ -337,7 +338,7 @@
 				break;
 			case '\n':
 				didnl = 1;
-				dosync = 1;
+				dosync = syncalot;
 				break;
 			case '\t':
 				line.pos += (line.pos / 8 + 1) * 8;
@@ -384,7 +385,7 @@
  */
 void usage(void)
 {
-	fprintf(stderr, "Usage: bootlogd [-v] [-r] [-d] [-p pidfile] [-l logfile]\n");
+	fprintf(stderr, "Usage: bootlogd [-v] [-r] [-d] [-s] [-c] [-p pidfile] [-l logfile]\n");
 	exit(1);
 }
 
@@ -446,7 +447,7 @@
 	rotate = 0;
 	dontfork = 0;
 
-	while ((i = getopt(argc, argv, "dl:p:rv")) != EOF) switch(i) {
+	while ((i = getopt(argc, argv, "cdsl:p:rv")) != EOF) switch(i) {
 		case 'l':
 			logfile = optarg;
 			break;
@@ -460,9 +461,15 @@
 		case 'p':
 			pidfile = optarg;
 			break;
+		case 'c':
+			createlogfile = 1;
+			break;
 		case 'd':
 			dontfork = 1;
 			break;
+		case 's':
+			syncalot = 1;
+			break;
 		default:
 			usage();
 			break;
@@ -523,8 +530,19 @@
 	 *	Fork and write pidfile if needed.
 	 */
 	if (!dontfork) {
-		if (fork())
+		pid_t child_pid = fork();
+		switch (child_pid) {
+		case -1: /* I am parent and the attempt to create a child failed */
+			fprintf(stderr, "bootlogd: fork failed: %s\n",
+				strerror(errno));
 			exit(1);
+			break;
+		case 0: /* I am the child */
+			break;
+		default: /* I am parent and got child's pid */
+			exit(0);
+			break;
+		}
 		setsid();
 	}
 	if (pidfile) {
@@ -598,12 +616,16 @@
 		/*
 		 *	Perhaps we need to open the logfile.
 		 */
-		if (fp == NULL && rotate && access(logfile, F_OK) == 0) {
-			snprintf(buf, sizeof(buf), "%s~", logfile);
-			rename(logfile, buf);
+		if (fp == NULL && access(logfile, F_OK) == 0) {
+			if (rotate) {
+				snprintf(buf, sizeof(buf), "%s~", logfile);
+				rename(logfile, buf);
+			}
+			fp = fopen(logfile, "a");
 		}
-		if (fp == NULL)
+		if (fp == NULL && createlogfile)
 			fp = fopen(logfile, "a");
+
 		if (inptr >= outptr)
 			todo = inptr - outptr;
 		else

Modified: sysvinit/branches/upstream/current/src/dowall.c
===================================================================
--- sysvinit/branches/upstream/current/src/dowall.c	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/src/dowall.c	2009-07-24 09:26:07 UTC (rev 1483)
@@ -65,7 +65,7 @@
 	uid_t			uid;
 	char			*tty;
 	static char		uidbuf[32];
-	static char		ttynm[32];
+	static char		ttynm[UT_LINESIZE + 4];
 	static int		init = 0;
 
 	if (!init) {
@@ -131,6 +131,7 @@
 	time_t			t;
 	char			term[UT_LINESIZE+6];
 	char			line[81];
+	char                    hostname[256]; /* HOST_NAME_MAX+1 */
 	char			*date, *p;
 	char			*user, *tty;
 	int			fd, flags;
@@ -144,6 +145,16 @@
 
 	getuidtty(&user, &tty);
 
+	/* Get and report current hostname, to make it easier to find
+	   out which machine is being shut down. */
+	if (0 != gethostname(hostname, sizeof(hostname))) {
+		strncpy(hostname, "[unknown]", sizeof(hostname)-1);
+	}
+	/* If hostname is truncated, it is unspecified if the string
+	   is null terminated or not.  Make sure we know it is null
+	   terminated. */
+	hostname[sizeof(hostname)-1] = 0;
+
 	/* Get the time */
 	time(&t);
 	date = ctime(&t);
@@ -157,8 +168,8 @@
 			date);
 	} else {
 		snprintf(line, sizeof(line),
-			"\007\r\nBroadcast message from %s %s(%s):\r\n\r\n",
-			user, tty, date);
+			"\007\r\nBroadcast message from %s@%s %s(%s):\r\n\r\n",
+			user, hostname, tty, date);
 	}
 
 	/*
@@ -180,7 +191,7 @@
 		   utmp->ut_user[0] == 0) continue;
 		if (strncmp(utmp->ut_line, "/dev/", 5) == 0) {
 			term[0] = 0;
-			strncat(term, utmp->ut_line, UT_LINESIZE);
+			strncat(term, utmp->ut_line, sizeof(term)-1);
 		} else
 			snprintf(term, sizeof(term), "/dev/%.*s",
 				UT_LINESIZE, utmp->ut_line);

Modified: sysvinit/branches/upstream/current/src/halt.c
===================================================================
--- sysvinit/branches/upstream/current/src/halt.c	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/src/halt.c	2009-07-24 09:26:07 UTC (rev 1483)
@@ -178,6 +178,8 @@
 	/*
 	 *	Find out who we are
 	 */
+	/* Remove dash passed on in argv[0] when used as login shell. */
+	if (argv[0][0] == '-') argv[0]++;
 	if ((progname = strrchr(argv[0], '/')) != NULL)
 		progname++;
 	else

Modified: sysvinit/branches/upstream/current/src/hddown.c
===================================================================
--- sysvinit/branches/upstream/current/src/hddown.c	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/src/hddown.c	2009-07-24 09:26:07 UTC (rev 1483)
@@ -5,6 +5,9 @@
  */
 char *v_hddown = "@(#)hddown.c  1.02  22-Apr-2003  miquels at cistron.nl";
 
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -18,6 +21,326 @@
 #include <sys/ioctl.h>
 #include <linux/hdreg.h>
 
+#define USE_SYSFS
+#ifdef USE_SYSFS
+/*
+ * sysfs part	Find all disks on the system, list out IDE and unmanaged
+ *		SATA disks, flush the cache of those and shut them down.
+ * Author:	Werner Fink <werner at suse.de>, 2007/06/12
+ *
+ */
+#include <limits.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#ifdef WORDS_BIGENDIAN
+#include <byteswap.h>
+#endif
+
+#define SYS_BLK		"/sys/block"
+#define SYS_CLASS	"/sys/class/scsi_disk"
+#define DEV_BASE	"/dev"
+#define ISSPACE(c)	(((c)==' ')||((c)=='\n')||((c)=='\t')||((c)=='\v')||((c)=='\r')||((c)=='\f'))
+
+/* Used in flush_cache_ext(), compare with <linux/hdreg.h> */
+#define IDBYTES		512
+#define MASK_EXT	0xE000		/* Bit 15 shall be zero, bit 14 shall be one, bit 13 flush cache ext */
+#define TEST_EXT	0x6000
+
+/* Maybe set in list_disks() and used in do_standby_idedisk() */
+#define DISK_IS_IDE	0x00000001
+#define DISK_IS_SATA	0x00000002
+#define DISK_EXTFLUSH	0x00000004
+
+static char *strstrip(char *str);
+static FILE *hdopen(const char* const format, const char* const name);
+static int flush_cache_ext(const char *device);
+
+/*
+ *	Find all disks through /sys/block.
+ */
+static char *list_disks(DIR* blk, unsigned int* flags)
+{
+	struct dirent *d;
+
+	while ((d = readdir(blk))) {
+		*flags = 0;
+		if (d->d_name[1] == 'd' && (d->d_name[0] == 'h' || d->d_name[0] == 's')) {
+			char buf[NAME_MAX+1], lnk[NAME_MAX+1], *ptr;
+			struct stat st;
+			FILE *fp;
+			int ret;
+
+			fp = hdopen(SYS_BLK "/%s/removable", d->d_name);
+			if ((long)fp <= 0) {
+				if ((long)fp < 0)
+					goto empty;	/* error */
+				continue;		/* no entry `removable' */
+			}
+
+			ret = getc(fp);
+			fclose(fp);
+
+			if (ret != '0')
+				continue;		/* not a hard disk */
+
+			if (d->d_name[0] == 'h') {
+				(*flags) |= DISK_IS_IDE;
+				if ((ret = flush_cache_ext(d->d_name))) {
+					if (ret < 0)
+						goto empty;
+					(*flags) |= DISK_EXTFLUSH;
+				}
+				break;			/* old IDE disk not managed by kernel, out here */
+			}
+
+			ret = snprintf(buf, sizeof(buf), SYS_BLK "/%s/device", d->d_name);
+			if ((ret >= sizeof(buf)) || (ret < 0))
+				goto empty;		/* error */
+
+			ret = readlink(buf, lnk, sizeof(lnk));
+			if (ret >= sizeof(lnk))
+				goto empty;		/* error */
+			if (ret < 0) {
+				if (errno != ENOENT)
+					goto empty;	/* error */
+				continue;		/* no entry `device' */
+			}
+			lnk[ret] = '\0';
+
+			ptr = basename(lnk);
+			if (!ptr || !*ptr)
+				continue;		/* should not happen */
+
+			ret = snprintf(buf, sizeof(buf), SYS_CLASS "/%s/manage_start_stop", ptr);
+			if ((ret >= sizeof(buf)) || (ret < 0))
+				goto empty;		/* error */
+
+			ret = stat(buf, &st);
+			if (ret == 0)
+				continue;		/* disk found but managed by kernel */
+
+			if (errno != ENOENT)
+				goto empty;		/* error */
+
+			fp = hdopen(SYS_BLK "/%s/device/vendor", d->d_name);
+			if ((long)fp <= 0) {
+				if ((long)fp < 0)
+					goto empty;	/* error */
+				continue;		/* no entry `device/vendor' */
+			}
+
+			ptr = fgets(buf, sizeof(buf), fp);
+			fclose(fp);
+			if (ptr == (char*)0)
+				continue;		/* should not happen */
+
+			ptr = strstrip(buf);
+			if (*ptr == '\0')
+				continue;		/* should not happen */
+
+			if (strncmp(buf, "ATA", sizeof(buf)))
+				continue;		/* no SATA but a real SCSI disk */
+
+			(*flags) |= (DISK_IS_IDE|DISK_IS_SATA);
+			if ((ret = flush_cache_ext(d->d_name))) {
+				if (ret < 0)
+					goto empty;
+				(*flags) |= DISK_EXTFLUSH;
+			}
+			break;				/* new SATA disk to shutdown, out here */
+		}
+	}
+	if (d == (struct dirent*)0)
+		goto empty;
+	return d->d_name;
+empty:
+	return (char*)0;
+}
+
+/*
+ *	Put an disk in standby mode.
+ *	Code stolen from hdparm.c
+ */
+static int do_standby_idedisk(char *device, unsigned int flags)
+{
+#ifndef WIN_STANDBYNOW1
+#define WIN_STANDBYNOW1		0xE0
+#endif
+#ifndef WIN_STANDBYNOW2
+#define WIN_STANDBYNOW2		0x94
+#endif
+#ifndef WIN_FLUSH_CACHE_EXT
+#define WIN_FLUSH_CACHE_EXT	0xEA
+#endif
+#ifndef WIN_FLUSH_CACHE
+#define WIN_FLUSH_CACHE		0xE7
+#endif
+	unsigned char flush1[4] = {WIN_FLUSH_CACHE_EXT,0,0,0};
+	unsigned char flush2[4] = {WIN_FLUSH_CACHE,0,0,0};
+	unsigned char stdby1[4] = {WIN_STANDBYNOW1,0,0,0};
+	unsigned char stdby2[4] = {WIN_STANDBYNOW2,0,0,0};
+	char buf[NAME_MAX+1];
+	int fd, ret;
+
+	ret = snprintf(buf, sizeof(buf), DEV_BASE "/%s", device);
+	if ((ret >= sizeof(buf)) || (ret < 0))
+		return -1;
+
+	if ((fd = open(buf, O_RDWR)) < 0)
+		return -1;
+
+	switch (flags & DISK_EXTFLUSH) {
+	case DISK_EXTFLUSH:
+		if (ioctl(fd, HDIO_DRIVE_CMD, &flush1) == 0)
+			break;
+		/* Extend flush rejected, try standard flush */
+	default:
+		ioctl(fd, HDIO_DRIVE_CMD, &flush2);
+		break;
+	}
+
+	ret = ioctl(fd, HDIO_DRIVE_CMD, &stdby1) &&
+	      ioctl(fd, HDIO_DRIVE_CMD, &stdby2);
+	close(fd);
+
+	if (ret)
+		return -1;
+	return 0;
+}
+
+/*
+ *	List all disks and put them in standby mode.
+ *	This has the side-effect of flushing the writecache,
+ *	which is exactly what we want on poweroff.
+ */
+int hddown(void)
+{
+	unsigned int flags;
+	char *disk;
+	DIR *blk;
+
+	if ((blk = opendir(SYS_BLK)) == (DIR*)0)
+		return -1;
+
+	while ((disk = list_disks(blk, &flags)))
+		do_standby_idedisk(disk, flags);
+
+	return closedir(blk);
+}
+
+/*
+ * Strip off trailing white spaces
+ */
+static char *strstrip(char *str)
+{
+	const size_t len = strlen(str);
+	if (len) {
+		char* end = str + len - 1;
+		while ((end != str) && ISSPACE(*end))
+			end--;
+		*(end + 1) = '\0';			/* remove trailing white spaces */
+	}
+	return str;
+}
+
+/*
+ * Open a sysfs file without getting a controlling tty
+ * and return FILE* pointer.
+ */
+static FILE *hdopen(const char* const format, const char* const name)
+{
+	char buf[NAME_MAX+1];
+	FILE *fp = (FILE*)-1;
+	int fd, ret;
+	
+	ret = snprintf(buf, sizeof(buf), format, name);
+	if ((ret >= sizeof(buf)) || (ret < 0))
+		goto error;		/* error */
+
+	fd = open(buf, O_RDONLY|O_NOCTTY);
+	if (fd < 0) {
+		if (errno != ENOENT)
+			goto error;	/* error */
+		fp = (FILE*)0;
+		goto error;		/* no entry `removable' */
+	}
+
+	fp = fdopen(fd, "r");
+	if (fp == (FILE*)0)
+		close(fd);		/* should not happen */
+error:
+	return fp;
+}
+
+/*
+ * Check IDE/(S)ATA hard disk identity for
+ * the FLUSH CACHE EXT bit set.
+ */
+static int flush_cache_ext(const char *device)
+{
+#ifndef WIN_IDENTIFY
+#define WIN_IDENTIFY		0xEC
+#endif
+	unsigned char args[4+IDBYTES];
+	unsigned short *id = (unsigned short*)(&args[4]);
+	char buf[NAME_MAX+1], *ptr;
+	int fd = -1, ret = 0;
+	FILE *fp;
+
+	fp = hdopen(SYS_BLK "/%s/size", device);
+	if ((long)fp <= 0) {
+		if ((long)fp < 0)
+			return -1;	/* error */
+		goto out;		/* no entry `size' */
+	}
+
+	ptr = fgets(buf, sizeof(buf), fp);
+	fclose(fp);
+	if (ptr == (char*)0)
+		goto out;		/* should not happen */
+
+	ptr = strstrip(buf);
+	if (*ptr == '\0')
+		goto out;		/* should not happen */
+
+	if ((size_t)atoll(buf) < (1<<28))
+		goto out;		/* small disk */
+		
+	ret = snprintf(buf, sizeof(buf), DEV_BASE "/%s", device);
+	if ((ret >= sizeof(buf)) || (ret < 0))
+		return -1;		/* error */
+
+	if ((fd = open(buf, O_RDONLY|O_NONBLOCK)) < 0)
+		goto out;
+
+	memset(&args[0], 0, sizeof(args));
+	args[0] = WIN_IDENTIFY;
+	args[3] = 1;
+	if (ioctl(fd, HDIO_DRIVE_CMD, &args))
+		goto out;
+#ifdef WORDS_BIGENDIAN
+# if 0
+	{
+		const unsigned short *end = id + IDBYTES/2;
+		const unsigned short *from = id;
+		unsigned short *to = id;
+
+		while (from < end)
+			*to++ = bswap_16(*from++);
+	}
+# else
+	id[83] = bswap_16(id[83]);
+# endif
+#endif
+	if ((id[83] & MASK_EXT) == TEST_EXT)
+		ret = 1;
+out:
+	if (fd >= 0)
+		close(fd);
+	return ret;
+}
+#else /* ! USE_SYSFS */
 #define MAX_DISKS	64
 #define PROC_IDE	"/proc/ide"
 #define DEV_BASE	"/dev"
@@ -25,18 +348,17 @@
 /*
  *	Find all IDE disks through /proc.
  */
-static int find_idedisks(char **dev, int maxdev)
+static int find_idedisks(const char **dev, int maxdev, int *count)
 {
 	DIR *dd;
 	FILE *fp;
 	struct dirent *d;
 	char buf[256];
-	int i = 0;
 
 	if ((dd = opendir(PROC_IDE)) == NULL)
 		return -1;
 
-	while ((d = readdir(dd)) != NULL) {
+	while (*count < maxdev && (d = readdir(dd)) != NULL) {
 		if (strncmp(d->d_name, "hd", 2) != 0)
 			continue;
 		buf[0] = 0;
@@ -50,21 +372,58 @@
 		}
 		fclose(fp);
 		snprintf(buf, sizeof(buf), DEV_BASE "/%s", d->d_name);
-		dev[i++] = strdup(buf);
-		if (i >= maxdev)
-			break;
+		dev[(*count)++] = strdup(buf);
 	}
 	closedir(dd);
-	if (i < maxdev) dev[i] = NULL;
 
 	return 0;
 }
 
 /*
- *	Put an IDE disk in standby mode.
+ *	Find all SCSI/SATA disks.
+ */
+static int find_scsidisks(const char **dev, int maxdev, int *count)
+{
+	if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sda";
+	if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sdb";
+	if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sdc";
+	if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sdd";
+	if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sde";
+	if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sdf";
+	if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sdg";
+	if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sdh";
+
+	return 0;
+}
+
+/*
+ *	Open the device node of a disk.
+ */
+static int open_disk(const char *device)
+{
+	return open(device, O_RDWR);
+}
+
+/*
+ *	Open device nodes of all disks, and store the file descriptors in fds.
+ *	This has to be done in advance because accessing the device nodes
+ *	might cause a disk to spin back up.
+ */
+static int open_disks(const char **disks, int *fds, int count)
+{
+	int i;
+
+	for (i = 0; i < count; i++)
+		fds[i] = open_disk(disks[i]);
+
+	return 0;
+}
+
+/*
+ *	Put an IDE/SCSI/SATA disk in standby mode.
  *	Code stolen from hdparm.c
  */
-static int do_standby_idedisk(char *device)
+static int do_standby_disk(int fd)
 {
 #ifndef WIN_STANDBYNOW1
 #define WIN_STANDBYNOW1 0xE0
@@ -74,9 +433,8 @@
 #endif
 	unsigned char args1[4] = {WIN_STANDBYNOW1,0,0,0};
 	unsigned char args2[4] = {WIN_STANDBYNOW2,0,0,0};
-	int fd;
 
-	if ((fd = open(device, O_RDWR)) < 0)
+	if (fd < 0)
 		return -1;
 
 	if (ioctl(fd, HDIO_DRIVE_CMD, &args1) &&
@@ -87,24 +445,39 @@
 }
 
 /*
- *	First find all IDE disks, then put them in standby mode.
+ *	Put all specified disks in standby mode.
+ */
+static int do_standby_disks(const int *fds, int count)
+{
+	int i;
+
+	for (i = 0; i < count; i++)
+		do_standby_disk(fds[i]);
+
+	return 0;
+}
+
+/*
+ *	First find all IDE/SCSI/SATA disks, then put them in standby mode.
  *	This has the side-effect of flushing the writecache,
  *	which is exactly what we want on poweroff.
  */
 int hddown(void)
 {
-	char *disks[MAX_DISKS+1];
-	int i;
+	const char *disks[MAX_DISKS];
+	int fds[MAX_DISKS];
+	int count = 0;
+	int result1, result2;
 
-	if (find_idedisks(disks, MAX_DISKS) < 0)
-		return -1;
+	result1 = find_idedisks(disks, MAX_DISKS, &count);
+	result2 = find_scsidisks(disks, MAX_DISKS, &count);
 
-	for (i = 0; disks[i] && i < MAX_DISKS; i++)
-		do_standby_idedisk(disks[i]);
+	open_disks(disks, fds, count);
+	do_standby_disks(fds, count);
 
-	return 0;
+	return (result1 ? result1 : result2);
 }
-
+#endif /* ! USE_SYSFS */
 #else /* __linux__ */
 
 int hddown(void)

Modified: sysvinit/branches/upstream/current/src/init.c
===================================================================
--- sysvinit/branches/upstream/current/src/init.c	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/src/init.c	2009-07-24 09:26:07 UTC (rev 1483)
@@ -43,6 +43,11 @@
 #include <sys/syslog.h>
 #include <sys/time.h>
 
+#ifdef WITH_SELINUX
+#include <selinux/selinux.h>
+#endif
+
+
 #ifdef __i386__
 #  if (__GLIBC__ >= 2)
      /* GNU libc 2.x */
@@ -89,7 +94,7 @@
 CHILD *newFamily = NULL;	/* The list after inittab re-read */
 
 CHILD ch_emerg = {		/* Emergency shell */
-	0, 0, 0, 0, 0,
+	WAITING, 0, 0, 0, 0,
 	"~~",
 	"S",
 	3,
@@ -185,6 +190,7 @@
 	{"RU",RUNNING},
 	{"DE",DEMAND},
 	{"XD",XECUTED},
+	{"WT",WAITING},
 	{NULL,0}
 };
 
@@ -464,9 +470,9 @@
 	len = vsnprintf(buf, sizeof(buf), fmt, ap);
 	va_end(ap);
 
-	if (maxproclen > 2) {
+	if (maxproclen > 1) {
 		memset(argv0, 0, maxproclen);
-		strncpy(argv0, buf, maxproclen - 2);
+		strncpy(argv0, buf, maxproclen - 1);
 	}
 
 	return len;
@@ -527,8 +533,10 @@
 	/*
 	 *	Retry the open five times.
 	 */
-	for(f = 0; f < 5; f++)
+	for(f = 0; f < 5; f++) {
 		if ((fd = open(console_dev, m)) >= 0) break;
+		usleep(100);
+	}
 
 	if (fd < 0) return fd;
 
@@ -576,9 +584,10 @@
 				}
 				break;
 			}
-		if (ch == NULL)
+		if (ch == NULL) {
 			INITDBG(L_VB, "chld_handler: unknown child %d exited.",
 				pid);
+		}
 	}
 	errno = saved_errno;
 }
@@ -966,8 +975,10 @@
   				dup(f);
   				dup(f);
 			}
+			SETSIG(sa, SIGCHLD, SIG_DFL, SA_RESTART);
 			if ((pid = fork()) < 0) {
-  				initlog(L_VB, "cannot fork");
+  				initlog(L_VB, "cannot fork: %s",
+					strerror(errno));
 				exit(1);
 			}
 			if (pid > 0) {
@@ -978,7 +989,6 @@
 				SETSIG(sa, SIGINT, SIG_IGN, SA_RESTART);
 				SETSIG(sa, SIGTSTP, SIG_IGN, SA_RESTART);
 				SETSIG(sa, SIGQUIT, SIG_IGN, SA_RESTART);
-				SETSIG(sa, SIGCHLD, SIG_DFL, SA_RESTART);
 
 				while ((rc = waitpid(pid, &st, 0)) != pid)
 					if (rc < 0 && errno == ECHILD)
@@ -997,7 +1007,8 @@
 				 *	this with a temporary process.
 				 */
 				if ((pid = fork()) < 0) {
-  					initlog(L_VB, "cannot fork");
+  					initlog(L_VB, "cannot fork: %s",
+						strerror(errno));
 					exit(1);
 				}
 				if (pid == 0) {
@@ -1835,7 +1846,7 @@
 	char		**env;
 	int		fd;
 
-	if (strchr("S12345",runlevel) == NULL)
+	if (strchr("S0123456",runlevel) == NULL)
 		return;
 
 	/*
@@ -1884,7 +1895,7 @@
 	 *	The existing init process execs a new init binary.
 	 */
 	env = init_buildenv(0);
-	execl(myname, myname, "--init", NULL, env);
+	execle(myname, myname, "--init", NULL, env);
 
 	/*
 	 *	We shouldn't be here, something failed. 
@@ -2412,7 +2423,7 @@
   	/*
 	 *	Set default PATH variable.
 	 */
-  	putenv(PATH_DFL);
+  	setenv("PATH", PATH_DEFAULT, 1 /* Overwrite */);
 
   	/*
 	 *	Initialize /var/run/utmp (only works if /var is on
@@ -2451,6 +2462,11 @@
 	initlog(L_CO, bootmsg, "reloading");
 	sigfillset(&sgt);
 	sigprocmask(SIG_UNBLOCK, &sgt, NULL);
+
+  	/*
+	 *	Set default PATH variable.
+	 */
+  	setenv("PATH", PATH_DEFAULT, 0 /* Don't overwrite */);
   }
   start_if_needed();
 
@@ -2495,7 +2511,7 @@
  */
 void usage(char *s)
 {
-	fprintf(stderr, "Usage: %s 0123456SsQqAaBbCcUu\n", s);
+	fprintf(stderr, "Usage: %s {-e VAR[=VAL] | [-t SECONDS] {0|1|2|3|4|5|6|S|s|Q|q|A|a|B|b|C|c|U|u}}\n", s);
 	exit(1);
 }
 
@@ -2599,6 +2615,7 @@
 	char			*p;
 	int			f;
 	int			isinit;
+	int			enforce = 0;
 
 	/* Get my own name */
 	if ((p = strrchr(argv[0], '/')) != NULL)
@@ -2662,6 +2679,21 @@
 		maxproclen += strlen(argv[f]) + 1;
 	}
 
+#ifdef WITH_SELINUX
+  	if (getenv("SELINUX_INIT") == NULL && !is_selinux_enabled()) {
+	  putenv("SELINUX_INIT=YES");
+	  if (selinux_init_load_policy(&enforce) == 0 ) {
+	    execv(myname, argv);
+	  } else {
+	    if (enforce > 0) {
+	      /* SELinux in enforcing mode but load_policy failed */
+	      /* At this point, we probably can't open /dev/console, so log() won't work */
+		    fprintf(stderr,"Unable to load SELinux Policy. Machine is in enforcing mode. Halting now.\n");
+	      exit(1);
+	    }
+	  }
+	}
+#endif  
 	/* Start booting. */
 	argv0 = argv[0];
 	argv[1] = NULL;

Modified: sysvinit/branches/upstream/current/src/init.h
===================================================================
--- sysvinit/branches/upstream/current/src/init.h	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/src/init.h	2009-07-24 09:26:07 UTC (rev 1483)
@@ -24,7 +24,7 @@
 #define SLEEPTIME  300			/* Disable time */
 
 /* Default path inherited by every child. */
-#define PATH_DFL   "PATH=/bin:/usr/bin:/sbin:/usr/sbin"
+#define PATH_DEFAULT   "/sbin:/usr/sbin:/bin:/usr/bin"
 
 
 /* Prototypes. */

Modified: sysvinit/branches/upstream/current/src/killall5.c
===================================================================
--- sysvinit/branches/upstream/current/src/killall5.c	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/src/killall5.c	2009-07-24 09:26:07 UTC (rev 1483)
@@ -40,10 +40,13 @@
 #include <syslog.h>
 #include <getopt.h>
 #include <stdarg.h>
+#include <sys/mman.h>
 
 char *Version = "@(#)killall5 2.86 31-Jul-2004 miquels at cistron.nl";
 
 #define STATNAMELEN	15
+#define DO_STAT 1
+#define NO_STAT 0
 
 /* Info about a process. */
 typedef struct proc {
@@ -165,8 +168,9 @@
 
 /*
  *	Read the proc filesystem.
+ *	CWD must be /proc to avoid problems if / is affected by the killing (ie depend on fuse).
  */
-int readproc()
+int readproc(int do_stat)
 {
 	DIR		*dir;
 	FILE		*fp;
@@ -180,7 +184,11 @@
 	int		pid, f;
 
 	/* Open the /proc directory. */
-	if ((dir = opendir("/proc")) == NULL) {
+	if (chdir("/proc") == -1) {
+		nsyslog(LOG_ERR, "chdir /proc failed");
+		return -1;
+	}
+	if ((dir = opendir(".")) == NULL) {
 		nsyslog(LOG_ERR, "cannot opendir(/proc)");
 		return -1;
 	}
@@ -206,10 +214,10 @@
 		memset(p, 0, sizeof(PROC));
 
 		/* Open the status file. */
-		snprintf(path, sizeof(path), "/proc/%s/stat", d->d_name);
+		snprintf(path, sizeof(path), "%s/stat", d->d_name);
 
 		/* Read SID & statname from it. */
- 		if ((fp = fopen(path, "r")) != NULL) {
+		if ((fp = fopen(path, "r")) != NULL) {
 			buf[0] = 0;
 			fgets(buf, sizeof(buf), fp);
 
@@ -223,7 +231,7 @@
 				if (q == NULL) {
 					p->sid = 0;
 					nsyslog(LOG_ERR,
-					"can't get program name from %s\n",
+					"can't get program name from /proc/%s\n",
 						path);
 					free(p);
 					continue;
@@ -260,7 +268,7 @@
 			continue;
 		}
 
-		snprintf(path, sizeof(path), "/proc/%s/cmdline", d->d_name);
+		snprintf(path, sizeof(path), "%s/cmdline", d->d_name);
 		if ((fp = fopen(path, "r")) != NULL) {
 
 			/* Now read argv[0] */
@@ -306,7 +314,7 @@
 
 		/* Try to stat the executable. */
 		snprintf(path, sizeof(path), "/proc/%s/exe", d->d_name);
-		if (stat(path, &st) == 0) {
+		if (do_stat && stat(path, &st) == 0) {
 			p->dev = st.st_dev;
 			p->ino = st.st_ino;
 		}
@@ -378,8 +386,8 @@
 	int		foundone = 0;
 	int		ok = 0;
 
-	/* Try to stat the executable. */
-	if (prog[0] == '/' && stat(prog, &st) == 0) dostat++;
+	if (! prog)
+		return NULL;
 
 	/* Get basename of program. */
 	if ((s = strrchr(prog, '/')) == NULL)
@@ -387,9 +395,16 @@
 	else
 		s++;
 
+	if (! *s)
+		return NULL;
+
 	q = (PIDQ_HEAD *)xmalloc(sizeof(PIDQ_HEAD));
 	q = init_pid_q(q);
 
+	/* Try to stat the executable. */
+	if (prog[0] == '/' && stat(prog, &st) == 0)
+		dostat++;
+
 	/* First try to find a match based on dev/ino pair. */
 	if (dostat) {
 		for (p = plist; p; p = p->next) {
@@ -404,15 +419,35 @@
 	if (!foundone) for (p = plist; p; p = p->next) {
 		ok = 0;
 
-		/* Compare name (both basename and full path) */
-		ok += (p->argv0 && strcmp(p->argv0, prog) == 0);
-		ok += (p->argv0 && strcmp(p->argv0base, s) == 0);
+		/*             matching        nonmatching
+		 * proc name   prog name       prog name
+		 * ---         -----------     ------------
+		 *   b         b, p/b, q/b
+		 * p/b         b, p/b          q/b
+		 *
+		 * Algorithm: Match if:
+		 *    cmd = arg
+		 * or cmd = base(arg)
+		 * or base(cmd) = arg
+		 *
+		 * Specifically, do not match just because base(cmd) = base(arg)
+		 * as was done in earlier versions of this program, since this
+		 * allows /aaa/foo to match /bbb/foo .
+		 */
+		ok |=
+			(p->argv0 && strcmp(p->argv0, prog) == 0)
+			|| (p->argv0 && s != prog && strcmp(p->argv0, s) == 0)
+			|| (p->argv0base && strcmp(p->argv0base, prog) == 0);
 
 		/* For scripts, compare argv[1] as well. */
-		if (scripts_too && p->argv1 &&
-		    !strncmp(p->statname, p->argv1base, STATNAMELEN)) {
-			ok += (strcmp(p->argv1, prog) == 0);
-			ok += (strcmp(p->argv1base, s) == 0);
+		if (
+			scripts_too && p->statname && p->argv1base
+			&& !strncmp(p->statname, p->argv1base, STATNAMELEN)
+		) {
+			ok |=
+				(p->argv1 && strcmp(p->argv1, prog) == 0)
+				|| (p->argv1 && s != prog && strcmp(p->argv1, s) == 0)
+				|| (p->argv1base && strcmp(p->argv1base, prog) == 0);
 		}
 
 		/*
@@ -423,7 +458,7 @@
 		    (p->argv0 == NULL ||
 		     p->argv0[0] == 0 ||
 		     strchr(p->argv0, ' '))) {
-			ok += (strcmp(p->statname, s) == 0);
+			ok |= (strcmp(p->statname, s) == 0);
 		}
 		if (ok) add_pid_to_q(q, p);
 	}
@@ -476,16 +511,22 @@
 	int		f;
 	int		first = 1;
 	int		i, oind, opt, flags = 0;
+	int		chroot_check = 0;
+	struct stat	st;
+	char		tmp[512];
 
 	for (oind = PIDOF_OMITSZ-1; oind > 0; oind--)
 		opid[oind] = 0;
 	opterr = 0;
 
-	while ((opt = getopt(argc,argv,"ho:sx")) != EOF) switch (opt) {
+	while ((opt = getopt(argc,argv,"hco:sx")) != EOF) switch (opt) {
 		case '?':
 			nsyslog(LOG_ERR,"invalid options on command line!\n");
 			closelog();
 			exit(1);
+		case 'c':
+			if (geteuid() == 0) chroot_check = 1;
+			break;
 		case 'o':
 			if (oind >= PIDOF_OMITSZ -1) {
 				nsyslog(LOG_ERR,"omit pid buffer size %d "
@@ -518,8 +559,18 @@
 	argc -= optind;
 	argv += optind;
 
+	/* Check if we are in a chroot */
+	if (chroot_check) {
+		snprintf(tmp, 512, "/proc/%d/root", getpid());
+		if (stat(tmp, &st) < 0) {
+			nsyslog(LOG_ERR, "stat failed for %s!\n", tmp);
+			closelog();
+			exit(1);
+		}
+	}
+
 	/* Print out process-ID's one by one. */
-	readproc();
+	readproc(DO_STAT);
 	for(f = 0; f < argc; f++) {
 		if ((q = pidof(argv[f])) != NULL) {
 			spid = 0;
@@ -541,6 +592,16 @@
 					else
 						spid = 1;
 				}
+				if (chroot_check) {
+					struct stat st2;
+					snprintf(tmp, 512, "/proc/%d/root",
+						 p->pid);
+					if (stat(tmp, &st2) < 0 ||
+					    st.st_dev != st2.st_dev ||
+					    st.st_ino != st2.st_ino) {
+						continue;
+					}
+				}
 				if (!first)
 					printf(" ");
 				printf("%d", p->pid);
@@ -548,20 +609,28 @@
 			}
 		}
 	}
-	printf("\n");
+	if (!first)
+		printf("\n");
 	closelog();
 	return(first ? 1 : 0);
 }
 
 
 
+#define KILLALL_OMITSZ	16
+
 /* Main for either killall or pidof. */
 int main(int argc, char **argv)
 {
 	PROC		*p;
 	int		pid, sid = -1;
+	pid_t		opid[KILLALL_OMITSZ];
+	int		i, oind, omit = 0;
 	int		sig = SIGKILL;
 
+	/* return non-zero if no process was killed */
+	int		retval = 2;
+
 	/* Get program name. */
 	if ((progname = strrchr(argv[0], '/')) == NULL)
 		progname = argv[0];
@@ -576,10 +645,34 @@
 		return main_pidof(argc, argv);
 
 	/* Right, so we are "killall". */
+	for (oind = KILLALL_OMITSZ-1; oind > 0; oind--)
+		opid[oind] = 0;
+
 	if (argc > 1) {
-		if (argc != 2) usage();
-		if (argv[1][0] == '-') (argv[1])++;
-		if ((sig = atoi(argv[1])) <= 0 || sig > 31) usage();
+		for (i = 1; i < argc; i++) {
+			if (argv[i][0] == '-') (argv[i])++;
+			if (argv[i][0] == 'o') {
+				if (++i >= argc) usage();
+				if (oind >= KILLALL_OMITSZ -1) {
+					nsyslog(LOG_ERR,"omit pid buffer size "
+						"%d exceeded!\n",
+						KILLALL_OMITSZ);
+					closelog();
+					exit(1);
+				}
+				if ((opid[oind] = atoi(argv[i])) < 1) {
+					nsyslog(LOG_ERR,
+						"illegal omit pid value "
+						"(%s)!\n", argv[i]);
+					closelog();
+					exit(1);
+				}
+				oind++;
+				omit = 1;
+			}
+			else if ((sig = atoi(argv[1])) <= 0 || sig > 31)
+				usage();
+		}
 	}
 
 	/* First get the /proc filesystem online. */
@@ -595,22 +688,36 @@
 	signal(SIGSTOP, SIG_IGN);
 	signal(SIGKILL, SIG_IGN);
 
+	/* lock us into memory */
+	mlockall(MCL_CURRENT | MCL_FUTURE);
+
 	/* Now stop all processes. */
 	kill(-1, SIGSTOP);
 	sent_sigstop = 1;
 
 	/* Read /proc filesystem */
-	if (readproc() < 0) {
+	if (readproc(NO_STAT) < 0) {
 		kill(-1, SIGCONT);
-		exit(1);
+		return(1);
 	}
 
-	/* Now kill all processes except our session. */
+	/* Now kill all processes except init (pid 1) and our session. */
 	sid = (int)getsid(0);
 	pid = (int)getpid();
-	for (p = plist; p; p = p->next)
-		if (p->pid != pid && p->sid != sid && !p->kernel)
-			kill(p->pid, sig);
+	for (p = plist; p; p = p->next) {
+		if (p->pid == 1 || p->pid == pid || p->sid == sid || p->kernel)
+			continue;
+		if (omit) {
+			for (i = 0; i < oind; i++)
+				if (opid[i] == p->pid)
+					break;
+			/* On a match, continue with the for loop above. */
+			if (i < oind)
+				continue;
+		}
+		kill(p->pid, sig);
+		retval = 0;
+	}
 
 	/* And let them continue. */
 	kill(-1, SIGCONT);
@@ -618,5 +725,8 @@
 	/* Done. */
 	closelog();
 
-	return 0;
+	/* Force the kernel to run the scheduler */
+	usleep(1);
+
+	return retval;
 }

Modified: sysvinit/branches/upstream/current/src/last.c
===================================================================
--- sysvinit/branches/upstream/current/src/last.c	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/src/last.c	2009-07-24 09:26:07 UTC (rev 1483)
@@ -70,6 +70,7 @@
 int altlist = 0;	/* Show hostname at the end. */
 int usedns = 0;		/* Use DNS to lookup the hostname. */
 int useip = 0;		/* Print IP address in number format */
+int fulltime = 0;	/* Print full dates and times */
 int oldfmt = 0;		/* Use old libc5 format? */
 char **show = NULL;	/* What do they want us to show */
 char *ufile;		/* Filename of this file */
@@ -307,14 +308,15 @@
 	struct sockaddr		*sa;
 	int			salen, flags;
 	unsigned int		topnibble;
+	unsigned int		azero = 0, sitelocal = 0;
 	int			mapped = 0;
 
 	flags = useip ? NI_NUMERICHOST : 0;
 
 	/*
 	 *	IPv4 or IPv6 ? We use 2 heuristics:
-	 *	1. Current IPv6 range uses 2000-3fff. Outside of
-	 *	   that is illegal and must be IPv4.
+	 *	1. Current IPv6 range uses 2000-3fff or fec0-feff.
+	 *	   Outside of that is illegal and must be IPv4.
 	 *	2. If last 3 bytes are 0, must be IPv4
 	 *	3. If IPv6 in IPv4, handle as IPv4
 	 *
@@ -323,7 +325,11 @@
 	if (a[0] == 0 && a[1] == 0 && a[2] == htonl (0xffff))
 		mapped = 1;
 	topnibble = ntohl((unsigned int)a[0]) >> 28;
-	if (topnibble < 2 || topnibble > 3 || mapped ||
+
+	azero = ntohl((unsigned int)a[0]) >> 16;
+	sitelocal = (azero >= 0xfec0 && azero <= 0xfeff) ? 1 : 0;
+	
+	if (((topnibble < 2 || topnibble > 3) && (!sitelocal)) || mapped ||
 	    (a[1] == 0 && a[2] == 0 && a[3] == 0)) {
 		/* IPv4 */
 		sin.sin_family = AF_INET;
@@ -388,9 +394,13 @@
 	 */
 	tmp = (time_t)p->ut_time;
 	strcpy(logintime, ctime(&tmp));
-	logintime[16] = 0;
-	sprintf(logouttime, "- %s", ctime(&t) + 11);
-	logouttime[7] = 0;
+	if (fulltime)
+		sprintf(logouttime, "- %s", ctime(&t));
+	else {
+		logintime[16] = 0;
+		sprintf(logouttime, "- %s", ctime(&t) + 11);
+		logouttime[7] = 0;
+	}
 	secs = t - p->ut_time;
 	mins  = (secs / 60) % 60;
 	hours = (secs / 3600) % 24;
@@ -409,16 +419,23 @@
 			break;
 		case R_NOW:
 			length[0] = 0;
-			sprintf(logouttime, "  still");
-			sprintf(length, "logged in");
+			if (fulltime)
+				sprintf(logouttime, "  still logged in");
+			else {
+				sprintf(logouttime, "  still");
+				sprintf(length, "logged in");
+			}
 			break;
 		case R_PHANTOM:
 			length[0] = 0;
-			sprintf(logouttime, "   gone");
-			sprintf(length, "- no logout");
+			if (fulltime)
+				sprintf(logouttime, "  gone - no logout");
+			else {
+				sprintf(logouttime, "   gone");
+				sprintf(length, "- no logout");
+			}
 			break;
 		case R_REBOOT:
-			logouttime[0] = 0;      /* Print machine uptime */
 			break;
 		case R_TIMECHANGE:
 			logouttime[0] = 0;
@@ -451,18 +468,23 @@
 #endif
 		if (!altlist) {
 			snprintf(final, sizeof(final),
-				"%-8.8s %-12.12s %-16.16s "
-				"%-16.16s %-7.7s %-12.12s\n",
+				fulltime ?
+				"%-8.8s %-12.12s %-16.16s %-24.24s %-26.26s %-12.12s\n" :
+				"%-8.8s %-12.12s %-16.16s %-16.16s %-7.7s %-12.12s\n",
 				p->ut_name, utline,
 				domain, logintime, logouttime, length);
 		} else {
 			snprintf(final, sizeof(final), 
+				fulltime ?
+				"%-8.8s %-12.12s %-24.24s %-26.26s %-12.12s %s\n" :
 				"%-8.8s %-12.12s %-16.16s %-7.7s %-12.12s %s\n",
 				p->ut_name, utline,
 				logintime, logouttime, length, domain);
 		}
 	} else
 		snprintf(final, sizeof(final),
+			fulltime ?
+			"%-8.8s %-12.12s %-24.24s %-26.26s %-12.12s\n" :
 			"%-8.8s %-12.12s %-16.16s %-7.7s %-12.12s\n",
 			p->ut_name, utline,
 			logintime, logouttime, length);
@@ -492,15 +514,17 @@
 {
 	fprintf(stderr, "Usage: %s [-num | -n num] [-f file] "
 			"[-t YYYYMMDDHHMMSS] "
-			"[-R] [-x] [-o] [username..] [tty..]\n", s);
+			"[-R] [-adioxF] [username..] [tty..]\n", s);
 	exit(1);
 }
 
 time_t parsetm(char *ts)
 {
-	struct tm	u = {0}, origu;
+	struct tm	u, origu;
 	time_t		tm;
 
+	memset(&tm, 0, sizeof(tm));
+
 	if (sscanf(ts, "%4d%2d%2d%2d%2d%2d", &u.tm_year,
 	    &u.tm_mon, &u.tm_mday, &u.tm_hour, &u.tm_min,
 	    &u.tm_sec) != 6)
@@ -561,7 +585,7 @@
   progname = mybasename(argv[0]);
 
   /* Process the arguments. */
-  while((c = getopt(argc, argv, "f:n:Rxadiot:0123456789")) != EOF)
+  while((c = getopt(argc, argv, "f:n:RxadFiot:0123456789")) != EOF)
     switch(c) {
 	case 'R':
 		showhost = 0;
@@ -592,6 +616,9 @@
 	case 'a':
 		altlist++;
 		break;
+	case 'F':
+		fulltime++;
+		break;
 	case 't':
 		if ((until = parsetm(optarg)) == (time_t)-1) {
 			fprintf(stderr, "%s: Invalid time value \"%s\"\n",
@@ -717,7 +744,7 @@
 			ut.ut_type = SHUTDOWN_TIME;
 		else if (strncmp(ut.ut_user, "reboot", 6) == 0)
 			ut.ut_type = BOOT_TIME;
-		else if (strncmp(ut.ut_user, "runlevel", 7) == 0)
+		else if (strncmp(ut.ut_user, "runlevel", 8) == 0)
 			ut.ut_type = RUN_LVL;
 	}
 #if 1 /*def COMPAT*/
@@ -752,7 +779,7 @@
 		case SHUTDOWN_TIME:
 			if (extended) {
 				strcpy(ut.ut_line, "system down");
-				quit = list(&ut, lastdown, R_NORMAL);
+				quit = list(&ut, lastboot, R_NORMAL);
 			}
 			lastdown = lastrch = ut.ut_time;
 			down = 1;
@@ -769,6 +796,7 @@
 		case BOOT_TIME:
 			strcpy(ut.ut_line, "system boot");
 			quit = list(&ut, lastdown, R_REBOOT);
+			lastboot = ut.ut_time;
 			down = 1;
 			break;
 		case RUN_LVL:

Modified: sysvinit/branches/upstream/current/src/shutdown.c
===================================================================
--- sysvinit/branches/upstream/current/src/shutdown.c	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/src/shutdown.c	2009-07-24 09:26:07 UTC (rev 1483)
@@ -521,6 +521,12 @@
   		}
 	}
 
+	if (NULL != halttype && down_level[0] != '0') {
+		fprintf(stderr, "shutdown: -H and -P flags can only be used along with -h flag.\n");
+		usage();
+  		exit(1);
+	}
+
 	/* Do we need to use the shutdown.allow file ? */
 	if (useacl && (fp = fopen(SDALLOW, "r")) != NULL) {
 

Modified: sysvinit/branches/upstream/current/src/sulogin.c
===================================================================
--- sysvinit/branches/upstream/current/src/sulogin.c	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/src/sulogin.c	2009-07-24 09:26:07 UTC (rev 1483)
@@ -23,17 +23,24 @@
 #include <pwd.h>
 #include <shadow.h>
 #include <termios.h>
+#include <errno.h>
 #include <sys/ioctl.h>
 #if defined(__GLIBC__)
 #  include <crypt.h>
 #endif
 
+#ifdef WITH_SELINUX
+#  include <selinux/selinux.h>
+#  include <selinux/get_context_list.h>
+#endif
+
 #define CHECK_DES	1
 #define CHECK_MD5	1
 
 #define F_PASSWD	"/etc/passwd"
 #define F_SHADOW	"/etc/shadow"
 #define BINSH		"/bin/sh"
+#define STATICSH	"/bin/sash"
 
 char *Version = "@(#)sulogin 2.85-3 23-Apr-2003 miquels at cistron.nl";
 
@@ -335,12 +342,33 @@
 	signal(SIGINT, SIG_DFL);
 	signal(SIGTSTP, SIG_DFL);
 	signal(SIGQUIT, SIG_DFL);
+#ifdef WITH_SELINUX
+	if (is_selinux_enabled > 0) {
+	  security_context_t scon=NULL;
+	  char *seuser=NULL;
+	  char *level=NULL;
+	  if (getseuserbyname("root", &seuser, &level) == 0)
+		  if (get_default_context_with_level(seuser, level, 0, &scon) > 0) {
+			  if (setexeccon(scon) != 0) 
+				  fprintf(stderr, "setexeccon faile\n");
+			  freecon(scon);
+		  }
+		free(seuser);
+		free(level);
+	}
+#endif
 	execl(sushell, shell, NULL);
 	perror(sushell);
 
 	setenv("SHELL", BINSH, 1);
 	execl(BINSH, profile ? "-sh" : "sh", NULL);
 	perror(BINSH);
+
+	/* Fall back to staticly linked shell if both the users shell
+	   and /bin/sh failed to execute. */
+	setenv("SHELL", STATICSH, 1);
+	execl(STATICSH, STATICSH, NULL);
+	perror(STATICSH);
 }
 
 void usage(void)
@@ -427,6 +455,11 @@
 			} else
 				close(fd);
 		}
+	} else if (getpid() == 1) {
+		/* We are init. We hence need to set a session anyway */
+		setsid();
+		if (ioctl(0, TIOCSCTTY, (char *)1))
+			perror("ioctl(TIOCSCTTY)");
 	}
 
 	/*

Modified: sysvinit/branches/upstream/current/src/utmp.c
===================================================================
--- sysvinit/branches/upstream/current/src/utmp.c	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/src/utmp.c	2009-07-24 09:26:07 UTC (rev 1483)
@@ -47,7 +47,8 @@
 	int fd;
 	struct utmp utmp;
 	struct utsname uname_buf;
-
+	struct timeval tv;
+	
 	/*
 	 *	Try to open the wtmp file. Note that we even try
 	 *	this if we have updwtmp() so we can see if the
@@ -76,7 +77,9 @@
 	 */
 	memset(&utmp, 0, sizeof(utmp));
 #if defined(__GLIBC__)
-	gettimeofday(&utmp.ut_tv, NULL);
+	gettimeofday(&tv, NULL);
+	utmp.ut_tv.tv_sec = tv.tv_sec;
+	utmp.ut_tv.tv_usec = tv.tv_usec;
 #else
 	time(&utmp.ut_time);
 #endif
@@ -113,6 +116,7 @@
 	struct utmp utmp;
 	struct utmp tmp;
 	struct utmp *utmptr;
+	struct timeval tv;
 
 	/*
 	 *	Can't do much if UTMP_FILE is not present.
@@ -144,7 +148,9 @@
 	utmp.ut_pid = pid;
 	strncpy(utmp.ut_id, id, sizeof(utmp.ut_id));
 #if defined(__GLIBC__)
-	gettimeofday(&utmp.ut_tv, NULL);
+	gettimeofday(&tv, NULL);
+	utmp.ut_tv.tv_sec = tv.tv_sec;
+	utmp.ut_tv.tv_usec = tv.tv_usec;
 #else
 	time(&utmp.ut_time);
 #endif

Modified: sysvinit/branches/upstream/current/src/utmpdump.c
===================================================================
--- sysvinit/branches/upstream/current/src/utmpdump.c	2009-07-24 08:53:13 UTC (rev 1482)
+++ sysvinit/branches/upstream/current/src/utmpdump.c	2009-07-24 09:26:07 UTC (rev 1483)
@@ -81,18 +81,20 @@
 time_t
 strtotime(const char *s_time)
 {
-	struct tm *tm = malloc(sizeof(*tm));
+	struct tm tm;
+	
+	memset(&tm, '\0', sizeof(struct tm));
 
 	if (s_time[0] == ' ' || s_time[0] == '\0')
 		return (time_t)0;
 
-	strptime(s_time, "%a %b %d %T %Y", tm);
+	strptime(s_time, "%a %b %d %T %Y", &tm);
 
 	/* Cheesy way of checking for DST */
 	if (s_time[26] == 'D')
-		tm->tm_isdst = 1;
+		tm.tm_isdst = 1;
 
-	return mktime(tm);
+	return mktime(&tm);
 }
 
 #define cleanse(x) xcleanse(x, sizeof(x))




More information about the Pkg-sysvinit-commits mailing list