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

Petter Reinholdtsen pere at alioth.debian.org
Fri Apr 23 05:38:16 UTC 2010


Author: pere
Date: 2010-04-23 05:38:15 +0000 (Fri, 23 Apr 2010)
New Revision: 1862

Added:
   sysvinit/branches/upstream/current/COPYING
   sysvinit/branches/upstream/current/Makefile
   sysvinit/branches/upstream/current/contrib/notify-pam-dead.patch
   sysvinit/branches/upstream/current/man/fstab-decode.8
   sysvinit/branches/upstream/current/man/utmpdump.1
   sysvinit/branches/upstream/current/src/fstab-decode.c
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/bootlogd.8.todo
   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/man/wall.1
   sysvinit/branches/upstream/current/obsolete/powerd.8
   sysvinit/branches/upstream/current/obsolete/powerd.c
   sysvinit/branches/upstream/current/obsolete/utmpdump.c.OLD
   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/ifdown.c
   sysvinit/branches/upstream/current/src/init.c
   sysvinit/branches/upstream/current/src/init.h
   sysvinit/branches/upstream/current/src/initreq.h
   sysvinit/branches/upstream/current/src/killall5.c
   sysvinit/branches/upstream/current/src/last.c
   sysvinit/branches/upstream/current/src/mesg.c
   sysvinit/branches/upstream/current/src/mountpoint.c
   sysvinit/branches/upstream/current/src/oldutmp.h
   sysvinit/branches/upstream/current/src/paths.h
   sysvinit/branches/upstream/current/src/reboot.h
   sysvinit/branches/upstream/current/src/runlevel.c
   sysvinit/branches/upstream/current/src/set.h
   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
   sysvinit/branches/upstream/current/src/wall.c
Log:
[svn-upgrade] Integrating new upstream version, sysvinit (2.88dsf)

Added: sysvinit/branches/upstream/current/COPYING
===================================================================
--- sysvinit/branches/upstream/current/COPYING	                        (rev 0)
+++ sysvinit/branches/upstream/current/COPYING	2010-04-23 05:38:15 UTC (rev 1862)
@@ -0,0 +1,339 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    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.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.

Modified: sysvinit/branches/upstream/current/COPYRIGHT
===================================================================
--- sysvinit/branches/upstream/current/COPYRIGHT	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/COPYRIGHT	2010-04-23 05:38:15 UTC (rev 1862)
@@ -15,5 +15,15 @@
     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'.
+Public License can be found in `/usr/share/common-licenses/GPL-2'.
 
+Send patches to sysvinit-devel at nongnu.org
+
+The of the start-stop-daemon
+
+ * A rewrite of the original Debian's start-stop-daemon Perl script
+ * in C (faster - it is executed many times during system startup).
+ *
+ * Written by Marek Michalkiewicz <marekm at i17linuxb.ists.pwr.wroc.pl>,
+ * public domain.
+

Added: sysvinit/branches/upstream/current/Makefile
===================================================================
--- sysvinit/branches/upstream/current/Makefile	                        (rev 0)
+++ sysvinit/branches/upstream/current/Makefile	2010-04-23 05:38:15 UTC (rev 1862)
@@ -0,0 +1,2 @@
+all install clean distclean:
+	$(MAKE) -C src $@

Modified: sysvinit/branches/upstream/current/README
===================================================================
--- sysvinit/branches/upstream/current/README	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/README	2010-04-23 05:38:15 UTC (rev 1862)
@@ -5,4 +5,6 @@
 obsolete	Really obsolete stuff ;)
 src		Source code
 
-Send patches to initscripts-ng-devel at lists.alioth.debian.org.
+The project home is on http://savannah.nongnu.org/projects/sysvinit .
+
+Send patches to sysvinit-devel at nongnu.org .

Added: sysvinit/branches/upstream/current/contrib/notify-pam-dead.patch
===================================================================
--- sysvinit/branches/upstream/current/contrib/notify-pam-dead.patch	                        (rev 0)
+++ sysvinit/branches/upstream/current/contrib/notify-pam-dead.patch	2010-04-23 05:38:15 UTC (rev 1862)
@@ -0,0 +1,220 @@
+Index: src/init.sample
+===================================================================
+--- src/init.sample	(revision 0)
++++ src/init.sample	(revision 0)
+@@ -0,0 +1,9 @@
++#%PAM-1.0
++#
++# The PAM configuration file for /sbin/init
++# Used for updating the lastlog logging file
++#
++auth	    sufficient	pam_rootok.so
++account	    include	common-account
++session	    include	common-session
++session	    requisite	pam_lastlog.so silent
+Index: src/init.c
+===================================================================
+--- src/init.c	(revision 56)
++++ src/init.c	(working copy)
+@@ -76,6 +76,10 @@
+ #include "reboot.h"
+ #include "set.h"
+ 
++#ifdef USE_PAM
++extern void notify_pam_dead_session(const char *id);
++#endif
++
+ #ifndef SIGPWR
+ #  define SIGPWR SIGUSR2
+ #endif
+@@ -1129,6 +1133,9 @@
+ 			}
+ 			dup(f);
+ 			dup(f);
++#ifdef USE_PAM
++			notify_pam_dead_session(ch->id);
++#endif
+ 		}
+ 
+ 		/*
+@@ -1548,6 +1555,9 @@
+ 		    INITDBG(L_VB, "Updating utmp for pid %d [id %s]",
+ 				ch->pid, ch->id);
+ 		    ch->flags &= ~RUNNING;
++#ifdef USE_PAM
++		    notify_pam_dead_session(ch->id);
++#endif
+ 		    if (ch->process[0] != '+')
+ 		    	write_utmp_wtmp("", ch->id, ch->pid, DEAD_PROCESS, NULL);
+ 		}
+@@ -2009,6 +2019,9 @@
+ 	    if (ch->flags & ZOMBIE) {
+ 		INITDBG(L_VB, "Child died, PID= %d", ch->pid);
+ 		ch->flags &= ~(RUNNING|ZOMBIE|WAITING);
++#ifdef USE_PAM
++		notify_pam_dead_session(ch->id);
++#endif
+ 		if (ch->process[0] != '+')
+ 			write_utmp_wtmp("", ch->id, ch->pid, DEAD_PROCESS, NULL);
+ 	    }
+@@ -2453,6 +2466,9 @@
+ 	    if (ch->flags & ZOMBIE) {
+ 		INITDBG(L_VB, "Child died, PID= %d", ch->pid);
+ 		ch->flags &= ~(RUNNING|ZOMBIE|WAITING);
++#ifdef USE_PAM
++		notify_pam_dead_session(ch->id);
++#endif
+ 		if (ch->process[0] != '+')
+ 			write_utmp_wtmp("", ch->id, ch->pid, DEAD_PROCESS, NULL);
+ 	    }
+Index: src/utmp.c
+===================================================================
+--- src/utmp.c	(revision 51)
++++ src/utmp.c	(working copy)
+@@ -34,10 +34,18 @@
+ #include <string.h>
+ #include <utmp.h>
+ 
++#if defined(USE_PAM) && defined(INIT_MAIN)
++#  include <security/pam_appl.h>
++#  include <security/pam_misc.h>
++#endif
++
+ #include "init.h"
+ #include "initreq.h"
+ #include "paths.h"
+ 
++#ifndef _PATH_DEV
++# define _PATH_DEV	"/dev/"
++#endif
+ 
+ #if defined(__GLIBC__)
+ #  if (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0) && defined(__powerpc__)
+@@ -127,9 +135,9 @@
+ 	strncpy(utmp.ut_name, user, sizeof(utmp.ut_name));
+ 	strncpy(utmp.ut_id  , id  , sizeof(utmp.ut_id  ));
+ 	strncpy(utmp.ut_line, line, sizeof(utmp.ut_line));
+-        
+-        /* Put the OS version in place of the hostname */
+-        if (uname(&uname_buf) == 0)
++	
++	/* Put the OS version in place of the hostname */
++	if (uname(&uname_buf) == 0)
+ 		strncpy(utmp.ut_host, uname_buf.release, sizeof(utmp.ut_host));
+ 
+ #if HAVE_UPDWTMP
+@@ -262,3 +270,75 @@
+ 	write_wtmp(user, id, pid, type, line && line[0] ? line : oldline);
+ }
+ 
++#if defined(USE_PAM) && defined(INIT_MAIN)
++static pam_handle_t *pamh = NULL;
++# ifdef __GNUC__
++static int
++null_conv(int num_msg, const struct pam_message **msgm,
++	  struct pam_response **response __attribute__((unused)),
++	  void *appdata_ptr __attribute__((unused)))
++# else
++static int
++null_conv(int num_msg, const struct pam_message **msgm,
++	  struct pam_response **response, void *appdata_ptr)
++# endif
++{
++	int i;
++	for (i = 0; i < num_msg; i++) {
++		const struct pam_message *msg = msgm[i];
++		if (msg == (const struct pam_message*)0)
++			continue;
++		if (msg->msg == (char*)0)
++			continue;
++		switch (msg->msg_style) {
++		case PAM_ERROR_MSG:
++		case PAM_TEXT_INFO:
++			initlog(L_VB, "pam_message %s", msg->msg);
++		default:
++			break;
++		}
++	}
++	return 0;
++}
++static const struct pam_conv conv = { null_conv, NULL };
++# define PAM_FAIL_CHECK(func, args...)  \
++	{ \
++		if ((pam_ret = (func)(args)) != PAM_SUCCESS) { \
++			initlog(L_VB, "%s", pam_strerror(pamh, pam_ret)); \
++			goto pam_error; \
++		} \
++	}
++
++void notify_pam_dead_session(const char *id)
++{
++	struct utmp *oldut, ut;
++
++	setutent();
++
++	memset(&ut, 0, sizeof(ut));
++	ut.ut_type = DEAD_PROCESS;
++	strncpy(ut.ut_id, id, sizeof(ut.ut_id));
++
++	if ((oldut = getutid(&ut)) && (oldut->ut_type == USER_PROCESS)) {
++		int pam_ret;
++		char tty[UT_LINESIZE+ strlen(_PATH_DEV) + 1];
++
++		if (strncmp(oldut->ut_line, _PATH_DEV, strlen(_PATH_DEV)))
++			snprintf(tty, sizeof(tty), _PATH_DEV "%.*s",
++				 UT_LINESIZE, oldut->ut_line);
++		else
++			snprintf(tty, sizeof(tty), "%.*s",
++				 UT_LINESIZE, oldut->ut_line);
++
++		PAM_FAIL_CHECK(pam_start, "init", oldut->ut_user, &conv, &pamh);
++		PAM_FAIL_CHECK(pam_set_item, pamh, PAM_TTY, tty);
++		PAM_FAIL_CHECK(pam_set_item, pamh, PAM_RHOST, oldut->ut_host);
++		PAM_FAIL_CHECK(pam_close_session, pamh, PAM_SILENT);
++	pam_error:
++		pam_end(pamh, pam_ret);
++	}
++
++	endutent();
++}
++#endif /* USE_PAM && INIT_MAIN */
++
+Index: src/Makefile
+===================================================================
+--- src/Makefile	(revision 58)
++++ src/Makefile	(working copy)
+@@ -8,7 +8,7 @@
+ # Version:	@(#)Makefile  2.85-13  23-Mar-2004  miquels at cistron.nl
+ #
+ 
+-CPPFLAGS =
++CPPFLAGS = -DUSE_PAM
+ CFLAGS	?= -ansi -O2 -fomit-frame-pointer
+ override CFLAGS += -W -Wall -D_GNU_SOURCE
+ STATIC	=
+@@ -79,6 +79,13 @@
+ endif
+ 
+ # Additional libs for GNU libc.
++ifneq ($(findstring -DUSE_PAM,$(CPPFLAGS)),)
++  INITLIBS	+= -lpam
++  PAMDOTD	= /etc/pam.d
++  PAMINIT	= $(PAMDOTD)/init
++endif
++
++# Additional libs for GNU libc.
+ ifneq ($(wildcard /usr/lib*/libcrypt.a),)
+   SULOGINLIBS	+= -lcrypt
+ endif
+@@ -153,6 +160,11 @@
+ 			$(STRIP) $$i ; \
+ 			$(INSTALL_EXEC) $$i $(ROOT)/usr/bin/ ; \
+ 		done
++ifneq ($(findstring -DUSE_PAM,$(CPPFLAGS)),)
++		$(INSTALL_DIR) $(ROOT)$(PAMDOTD)
++		test -s $(ROOT)$(PAMINIT) || \
++		$(INSTALL_DATA) init.sample $(ROOT)$(PAMINIT)
++endif
+ 		# $(INSTALL_DIR) $(ROOT)/etc/
+ 		# $(INSTALL_EXEC) initscript.sample $(ROOT)/etc/
+ 		ln -sf halt $(ROOT)/sbin/reboot

Modified: sysvinit/branches/upstream/current/doc/Changelog
===================================================================
--- sysvinit/branches/upstream/current/doc/Changelog	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/doc/Changelog	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,97 @@
+sysvinit (2.88dsf) world; urgency=low
+
+  [ Petter Reinholdtsen ]
+  * Mention new home on Savannah in README.
+  * Revert change from Fedora/RedHat where the now obsolete command
+    INIT_CMD_CHANGECONS was introduced.  Based on feedback and patch
+    from Bill Nottingham.
+  * Adjust makefile to make sure the install directories are created
+    before files are copied into them.
+  * Simplify build rules, based on patch from Mike Frysinger and Gentoo.
+  * Fix minor bug in optimizing of argument parsing.  Based on
+    report from jakemus on freshmeat.
+  * Add casts to get rid of compiler warning about signed/unsigned issues.
+  * Change tty handling in init to make sure the UTF-8 flag is not cleared
+    on boot.  Patch from Samuel Thibault.
+  * Add Makefile in toplevel directory.
+  * Print usage information when shutdown is used by non-root user.
+    Patch from Mike Frysinger and Gentoo.
+  * Sync shutdown manual page and usage information.  Patch from Mike
+    Frysinger and Gentoo.
+  * Fix race condition in utmp writing.  Patch from Gil Kloepfer via
+    Mike Frysinger and Gentoo.
+  * Rewrite findtty() in bootlogd to recursively search /dev/ for the
+    correct device, to handle terminal devices for example in /dev/pty/.
+    Patch from Debian.
+  * Make sure bootlogd findpty() returns an error value when it fails to
+    find a usable pty.  Patch from Rob Leslie via Debian.
+  * Make sure bootlogd fflush() every line, even if asked not to flush
+    to disk using fdatasync().  Patch from Scott Gifford via Debian.
+  * Add compatibility code to handle old path "/etc/powerstatus" for a
+    while.
+  * Incude definition for MNT_DETACH which is missing in older GNU libc
+    headers.
+  * Do not strip binaries before installing them, to make it easier to
+    get binaries with debug information installed.
+
+  [ Werner Fink ]
+  * Add the comment from Andrea Arcangeli about the correct
+    place of setting the default childhandler within spawn().
+  * Make sure that newline is printed out for last(1) even
+    if an utmp record entry is truncated.
+  * Check if utmp not only exists but also is writable and delay
+    writing out of the utmp runlevel record if utmp is not writable.
+  * Be able to find libcrypt also on 64 bit based architectures.
+  * Add option -w to the last command to display the full user and
+    domain names in the output.  Patch from Petr Lautrbach.
+  * Add a manual page for utmpdump as this tool is sometimes
+    very useful even if not intended for normal use.
+  * Use paths.h macros for wall
+  * Change path "/etc/powerstatus" to "/var/run/powerstatus"
+  * Detected also removable block devices at halt/reboot to be able
+    to flush data and send them the ATA standby command.  This should
+    avoid data loss on USB sticks and other removable block devices.
+  * Flush block devices on halt/reboot if not done by the kernel.
+  * Set SHELL to /bin/sh in the environmant of shutdown.
+  * Retry to write out shutdown messages if interrupted.
+  * pidof/killall5 - make omit pid list a dynamic one.
+  * pidof - provide '-n' to skip stat(2) syscall on network based FS.
+  * init - avoid compiler warnings
+  * init - initialize console by using the macros from ttydefaults.h
+  * init - add the possiblity to ignore further interrupts from keyboard
+  * init - add the possiblity to set sane terminal line settings
+  * sulogin - add the possibility to reset the terminal io
+  * Fix some minor problems
+  * init - enable is_selinux_enabled() to detect selinuxfs
+  * Add fix for Debian bug #536574 -- Can be enabled by -DACCTON_OFF
+  * Add helper program fstab-decode to make it easier to handle
+    /etc/mtab content. Patch by Miloslav Trmac and Fedora.
+  * Add fix for Debian bug #335023 - Make sure TERM is set on FreeBSD.
+  * Add fix for Debian bug #374038 - Make it clear that shutdown -c can
+    only cancel a waiting shutdown, not an active one.
+  * Add note to pidof manual page about the use of readlink(2). Patch by
+    Bill Nottingham and Fedora.
+  * Add PAM patch contrib/notify-pam-dead.patch based on Debian bug
+    #68621, which will add PAM support for programs spawned by init on
+    the console like sulogin. Based on patch by Topi Miettinen.  This
+    patch is not applied by default yet while we review its
+    usefullness.  It is only helpful for session handling, as sulogin
+    do not use and will not use a PAM conv() function.  The current
+    sulogin is able to handle DES as well as MD5, SHA, and Blowfish
+    encrypted passwords due using getpwnam(3).
+  * Move utmp/wtmp before the execvp() in spawn() to be sure to
+    use the correct pid even on a controlling tty
+  * Remaining problem is that the pid of the second fork() for
+    getting a controlling tty isn't that reported by spawn()
+  * Re-enable writting utmp/wtmp for boot scripts
+  * Extend sulogin to support additional encryption algorithms
+  * Re-enable maintenance message of sulogin
+  * Enable the sulogin fallback password check to handle  MD5, SHA, and
+    Blowfish encrypted passwords in case of getpwnam(3) fails.
+  * sulogin picking the SELinux context was broken. Patch by Daniel Walsh
+
+ -- Petter Reinholdtsen <pere at hungry.com>  Sun Apr 11 11:28:55 CEST 2010
+
 sysvinit (2.87dsf) world; urgency=low
 
   * Fix typos and do minor updates in the manual pages.

Modified: sysvinit/branches/upstream/current/man/bootlogd.8
===================================================================
--- sysvinit/branches/upstream/current/man/bootlogd.8	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/bootlogd.8	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1998-2003 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by 
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .TH BOOTLOGD 8 "Jul 21, 2003" "" "Linux System Administrator's Manual"
 .SH NAME
 bootlogd \- record boot messages

Modified: sysvinit/branches/upstream/current/man/bootlogd.8.todo
===================================================================
--- sysvinit/branches/upstream/current/man/bootlogd.8.todo	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/bootlogd.8.todo	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1998-1999 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .TH BOOTLOGD 8 "Aug 24, 1999" "" "Linux System Administrator's Manual"
 .SH NAME
 bootlogd \- record boot messages

Added: sysvinit/branches/upstream/current/man/fstab-decode.8
===================================================================
--- sysvinit/branches/upstream/current/man/fstab-decode.8	                        (rev 0)
+++ sysvinit/branches/upstream/current/man/fstab-decode.8	2010-04-23 05:38:15 UTC (rev 1862)
@@ -0,0 +1,45 @@
+.\" A man page for fstab-decode(8).
+.\"
+.\" Copyright (C) 2006 Red Hat, Inc. All rights reserved.
+.\"
+.\" This copyrighted material is made available to anyone wishing to use,
+.\" modify, copy, or redistribute it subject to the terms and conditions of the
+.\" GNU General Public License v.2.
+.\"
+.\" This program is distributed in the hope that it will be useful, but WITHOUT
+.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+.\" more details.
+.\"
+.\" 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.,
+.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+.\"
+.\" Author: Miloslav Trmac <mitr at redhat.com>
+.TH fstab-decode 8 "May 2006"
+
+.SH NAME
+fstab-decode \- run a command with fstab-encoded arguments
+
+.SH SYNOPSIS
+\fB fstab-decode\fR \fICOMMAND\fR [\fIARGUMENT\fR]...
+
+.SH DESCRIPTION
+.B fstab-decode
+decodes escapes in the specified \FIARGUMENT\fRs
+and uses them to run \fICOMMAND\fR.
+The argument escaping uses the same rules as path escaping in
+\fB/etc/fstab\fR,
+.B /etc/mtab
+and \fB/proc/mtab\fR.
+
+.SH EXIT STATUS
+.B fstab-decode
+exits with status 127 if
+.I COMMAND
+can't be run.
+Otherwise it exits with the status returned by \fICOMMAND\fR.
+
+.SH EXAMPLES
+
+.B fstab-decode umount $(awk '$3 == "vfat" { print $2 }' /etc/fstab)

Modified: sysvinit/branches/upstream/current/man/halt.8
===================================================================
--- sysvinit/branches/upstream/current/man/halt.8	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/halt.8	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1998-2001 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .\"{{{}}}
 .\"{{{  Title
 .TH HALT 8 "Nov 6, 2001" "" "Linux System Administrator's Manual"

Modified: sysvinit/branches/upstream/current/man/init.8
===================================================================
--- sysvinit/branches/upstream/current/man/init.8	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/init.8	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1998-2004 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .\"{{{}}}
 .\"{{{  Title
 .TH INIT 8 "29 Jul 2004" "" "Linux System Administrator's Manual"

Modified: sysvinit/branches/upstream/current/man/initscript.5
===================================================================
--- sysvinit/branches/upstream/current/man/initscript.5	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/initscript.5	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1998-2003 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .TH INITSCRIPT 5 "July 10, 2003" "" "Linux System Administrator's Manual"
 .SH NAME
 initscript \- script that executes inittab commands.

Modified: sysvinit/branches/upstream/current/man/inittab.5
===================================================================
--- sysvinit/branches/upstream/current/man/inittab.5	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/inittab.5	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1998-2001 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .\"{{{}}}
 .\"{{{  Title
 .TH INITTAB 5 "Dec 4, 2001" "" "Linux System Administrator's Manual"

Modified: sysvinit/branches/upstream/current/man/killall5.8
===================================================================
--- sysvinit/branches/upstream/current/man/killall5.8	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/killall5.8	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1998-2003 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .TH KILLALL5 8 "04 Nov 2003" "" "Linux System Administrator's Manual"
 .SH NAME
 killall5 -- send a signal to all processes.
@@ -5,9 +22,9 @@
 .B killall5
 .RB -signalnumber
 .RB [ \-o
-.IR omitpid ]
+.IR omitpid[,omitpid..]]
 .RB [ \-o
-.IR omitpid.. ]
+.IR omitpid[,omitpid..].. ]
 .SH DESCRIPTION
 .B killall5
 is the SystemV killall command. It sends a signal to all processes except

Modified: sysvinit/branches/upstream/current/man/last.1
===================================================================
--- sysvinit/branches/upstream/current/man/last.1	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/last.1	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1998-2004 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .\"{{{}}}
 .\"{{{  Title
 .TH LAST,LASTB 1 "Jul 31, 2004" "" "Linux System Administrator's Manual"
@@ -12,7 +29,7 @@
 .RB [ \-R ]
 .RB [ \-\fInum\fP ]
 .RB "[ \-\fBn\fP \fInum\fP ]"
-.RB [ \-adFiox ]
+.RB [ \-adFiowx ]
 .RB "[ \-\fBf\fP \fIfile\fP ]"
 .RB "[ \-\fBt\fP \fIYYYYMMDDHHMMSS\fP ]"
 .RI [ name... ]
@@ -23,7 +40,7 @@
 .RB [ \-\fInum\fP ]
 .RB "[ \-\fBn\fP \fInum\fP ]"
 .RB "[ \-\fBf\fP \fIfile\fP ]"
-.RB [ \-adFiox ]
+.RB [ \-adFiowx ]
 .RI [ name... ]
 .RI [ tty... ]
 .\"}}}
@@ -78,6 +95,8 @@
 host, but it displays the IP number in numbers-and-dots notation.
 .IP \fB\-o\fP
 Read an old-type wtmp file (written by linux-libc5 applications).
+.IP \fB\-w\fP
+Display full user and domain names in the output.
 .IP \fB\-x\fP
 Display the system shutdown entries and run level changes.
 .\"}}}

Modified: sysvinit/branches/upstream/current/man/mesg.1
===================================================================
--- sysvinit/branches/upstream/current/man/mesg.1	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/mesg.1	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1998-2001 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .\"{{{}}}
 .\"{{{  Title
 .TH MESG 1 "Feb 26, 2001" "" "Linux User's Manual"

Modified: sysvinit/branches/upstream/current/man/mountpoint.1
===================================================================
--- sysvinit/branches/upstream/current/man/mountpoint.1	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/mountpoint.1	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1998-2004 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .TH MOUNTPOINT 1 "Mar 15, 2004" "" "Linux System Administrator's Manual"
 .SH NAME
 mountpoint \- see if a directory is a mountpoint

Modified: sysvinit/branches/upstream/current/man/pidof.8
===================================================================
--- sysvinit/branches/upstream/current/man/pidof.8	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/pidof.8	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1998 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .TH PIDOF 8 "01 Sep 1998" "" "Linux System Administrator's Manual"
 .SH NAME
 pidof -- find the process ID of a running program.
@@ -5,11 +22,12 @@
 .B pidof
 .RB [ \-s ]
 .RB [ \-c ]
+.RB [ \-n ]
 .RB [ \-x ]
 .RB [ \-o
-.IR omitpid ]
+.IR omitpid[,omitpid..] ]
 .RB [ \-o
-.IR omitpid.. ]
+.IR omitpid[,omitpid..].. ]
 .B program
 .RB [ program.. ]
 .SH DESCRIPTION
@@ -23,13 +41,22 @@
 .B start-stop-daemon
 (8) program that should be used instead.
 .SH OPTIONS
-.IP -s
+.IP \-s
 Single shot - this instructs the program to only return one \fIpid\fP.
-.IP -c
+.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
+.IP \-n
+Avoid
+.BR stat (2)
+system function call on all binaries which are located on network
+based file systems like
+.BR NFS .
+Instead of using this option the the variable
+.B PIDOF_NETFS
+may be set and exported.
+.IP \-x
 Scripts too - this causes the program to also return process id's of
 shells running the named scripts.
 .IP "-o \fIomitpid\fP"
@@ -50,7 +77,11 @@
 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
 that it returns pids of running programs that happen to have the same name
-as the program you're after but are actually other programs.
+as the program you're after but are actually other programs. Note that
+that the executable name of running processes is calculated with
+.BR readlink (2),
+so symbolic links to executables will also match.
+
 .SH SEE ALSO
 .BR shutdown (8),
 .BR init (8),

Modified: sysvinit/branches/upstream/current/man/runlevel.8
===================================================================
--- sysvinit/branches/upstream/current/man/runlevel.8	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/runlevel.8	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1997 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .TH RUNLEVEL 8 "May 27, 1997" "" "Linux System Administrator's Manual"
 .SH NAME
 runlevel -- find the previous and current system runlevel.

Modified: sysvinit/branches/upstream/current/man/shutdown.8
===================================================================
--- sysvinit/branches/upstream/current/man/shutdown.8	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/shutdown.8	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1998-2003 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .\"{{{}}}
 .\"{{{  Title
 .TH SHUTDOWN 8 "November 12, 2003" "" "Linux System Administrator's Manual"
@@ -9,11 +26,11 @@
 .\"{{{  Synopsis
 .SH SYNOPSIS
 .B /sbin/shutdown
+.RB [ \-akrhPHfFnc ]
 .RB [ \-t
 .IR sec ]
-.RB [ \-arkhncfFHP ]
 .I time
-.RI [ warning-message ]
+.RI [ "warning message" ]
 .\"}}}
 .\"{{{  Description
 .SH DESCRIPTION
@@ -39,11 +56,6 @@
 .IP "\fB\-a\fP
 Use \fB/etc/shutdown.allow\fP.
 .\"}}}
-.\"{{{  -t sec
-.IP "\fB\-t\fP \fIsec\fP"
-Tell \fBinit\fP(8) to wait \fIsec\fP seconds between sending processes the 
-warning and the kill signal, before changing to another runlevel.
-.\"}}}
 .\"{{{  -k
 .IP \fB\-k\fP
 Don't really shutdown; only send the warning messages to everybody.
@@ -56,21 +68,15 @@
 .IP \fB\-h\fP
 Halt or power off after shutdown.
 .\"}}}
+.\"{{{  -P
+.IP \fB\-P\fP
+Halt action is to turn off the power.
+.\"}}}
 .\"{{{  -H
 .IP \fB\-H\fP
 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
-Halt action is to turn off the power.
-.\"}}}
-.\"{{{  -n
-.IP \fB\-n\fP
-[DEPRECATED] Don't call \fBinit\fP(8) to do the shutdown but do it ourself.
-The use of this option is discouraged, and its results are not always what
-you'd expect.
-.\"}}}
 .\"{{{  -f
 .IP \fB\-f\fP
 Skip fsck on reboot.
@@ -79,18 +85,30 @@
 .IP \fB\-F\fP
 Force fsck on reboot.
 .\"}}}
+.\"{{{  -n
+.IP \fB\-n\fP
+[DEPRECATED] Don't call \fBinit\fP(8) to do the shutdown but do it ourself.
+The use of this option is discouraged, and its results are not always what
+you'd expect.
+.\"}}}
 .\"{{{  -c
 .IP \fB\-c\fP
-Cancel an already running shutdown. With this option it is of course
-not possible to give the \fBtime\fP argument, but you can enter a
-explanatory message on the command line that will be sent to all users.
+Cancel a waiting shutdown. ("shutdown now" is no longer waiting.) With
+this option it is of course not possible to give the time argument, but
+you can enter explanatory message arguments on the command line that
+will be sent to all users.
 .\"}}}
+.\"{{{  -t sec
+.IP "\fB\-t\fP \fIsec\fP"
+Tell \fBinit\fP(8) to wait \fIsec\fP seconds between sending processes the
+warning and the kill signal, before changing to another runlevel.
+.\"}}}
 .\"{{{  time
 .IP \fItime\fP
 When to shutdown.
 .\"}}}
 .\"{{{  warning-message
-.IP \fIwarning-message\fP
+.IP "\fIwarning message\fP"
 Message to send to all users.
 .\"}}}
 .PP

Modified: sysvinit/branches/upstream/current/man/sulogin.8
===================================================================
--- sysvinit/branches/upstream/current/man/sulogin.8	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/sulogin.8	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1998-2006 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .TH SULOGIN 8 "17 Jan 2006" "" "Linux System Administrator's Manual"
 .SH NAME
 sulogin \- Single-user login

Added: sysvinit/branches/upstream/current/man/utmpdump.1
===================================================================
--- sysvinit/branches/upstream/current/man/utmpdump.1	                        (rev 0)
+++ sysvinit/branches/upstream/current/man/utmpdump.1	2010-04-23 05:38:15 UTC (rev 1862)
@@ -0,0 +1,66 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 2010 Michael Krapp
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by 
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
+.TH UTMPDUMP 1 "Februar 8, 2010" "" "Linux System Administrator's Manual"
+.SH NAME
+utmpdump \- dump UTMP and WTMP files in raw format
+.SH SYNOPSIS
+.B utmpdump
+.RB [ \-froh ]
+.I filename
+.SH DESCRIPTION
+\fButmpdump\fP is a simple program to dump UTMP and WTMP files
+in raw format, so they can be examined.
+.SH OPTIONS
+.IP \fB\-f\fP
+output appended data as the file grows.
+.IP "\fB\-r\fP"
+reverse. Write back edited login information into utmp or wtmp files.
+.IP \fB\-o\fP
+use old libc5 format.
+.IP \fB\-h\fP
+usage information.
+.PP
+utmpdump can be useful in cases of corrupted utmp or wtmp entries.
+It can dump out utmp/wtmp to an ASCII file, then that file can
+be edited to remove bogus entries and reintegrated, using
+.PP 
+.sp 1
+.in +1c
+.nf
+\fButmpdump -r < ascii file > wtmp\fP
+.fi
+.in -1c
+.sp 1
+but be warned as
+.B utmpdump
+was written for debugging purpose only.
+.SH BUGS
+You may
+.B not
+use the option \fB\-r\fP as the format for the
+utmp/wtmp files strongly depends on the
+input format. This tool was
+.B not
+written for normal use but for debugging.
+.SH AUTHOR
+Michael Krapp
+.SH "SEE ALSO"
+.BR last (1),
+.BR w (1),
+.BR who (1),
+.BR utmp (5),

Modified: sysvinit/branches/upstream/current/man/wall.1
===================================================================
--- sysvinit/branches/upstream/current/man/wall.1	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/man/wall.1	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1998-2003 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .TH WALL 1 "15 April 2003" "" "Linux User's Manual"
 
 .SH NAME

Modified: sysvinit/branches/upstream/current/obsolete/powerd.8
===================================================================
--- sysvinit/branches/upstream/current/obsolete/powerd.8	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/obsolete/powerd.8	2010-04-23 05:38:15 UTC (rev 1862)
@@ -1,3 +1,20 @@
+'\" -*- coding: UTF-8 -*-
+.\" Copyright (C) 1994 Miquel van Smoorenburg.
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more details.
+.\"
+.\" 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+.\"
 .TH POWERD 8 "Feb 14, 1994" "" "Linux System Administrator's Manual"
 .SH NAME
 .\" powerd \(em monitor a serial line connected to an UPS.

Modified: sysvinit/branches/upstream/current/obsolete/powerd.c
===================================================================
--- sysvinit/branches/upstream/current/obsolete/powerd.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/obsolete/powerd.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -22,12 +22,21 @@
  *		who has given kind permission to release this program
  *		for general puppose.
  *
- *		Copyright 1991-1996 Cistron Electronics.
+ *		Copyright (C) 1991-1996 Cistron Electronics.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
+ *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /* Use the new way of communicating with init. */

Modified: sysvinit/branches/upstream/current/obsolete/utmpdump.c.OLD
===================================================================
--- sysvinit/branches/upstream/current/obsolete/utmpdump.c.OLD	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/obsolete/utmpdump.c.OLD	2010-04-23 05:38:15 UTC (rev 1862)
@@ -5,12 +5,21 @@
  * Version:	@(#)utmpdump.c  13-Aug-1996  1.00  miquels at cistron.nl
  *
  *		This file is part of the sysvinit suite,
- *		Copyright 1991-1996 Miquel van Smoorenburg.
+ *		Copyright (C) 1991-1996 Miquel van Smoorenburg.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
+ *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include <stdio.h>

Modified: sysvinit/branches/upstream/current/src/Makefile
===================================================================
--- sysvinit/branches/upstream/current/src/Makefile	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/Makefile	2010-04-23 05:38:15 UTC (rev 1862)
@@ -8,30 +8,31 @@
 # Version:	@(#)Makefile  2.85-13  23-Mar-2004  miquels at cistron.nl
 #
 
-CC	= gcc
-CFLAGS	= -ansi -W -Wall -O2 -fomit-frame-pointer -D_GNU_SOURCE
-LDFLAGS	= -s
+CPPFLAGS =
+CFLAGS	?= -ansi -O2 -fomit-frame-pointer
+override CFLAGS += -W -Wall -D_GNU_SOURCE
 STATIC	=
 
 # For some known distributions we do not build all programs, otherwise we do.
 BIN	=
-SBIN	= init halt shutdown runlevel killall5
+SBIN	= init halt shutdown runlevel killall5 fstab-decode
 USRBIN	= last mesg
 
 MAN1	= last.1 lastb.1 mesg.1
 MAN5	= initscript.5 inittab.5
 MAN8	= halt.8 init.8 killall5.8 pidof.8 poweroff.8 reboot.8 runlevel.8
-MAN8	+= shutdown.8 telinit.8
+MAN8	+= shutdown.8 telinit.8 fstab-decode.8
 
 ifeq ($(DISTRO),)
 BIN	+= mountpoint
 SBIN	+= sulogin bootlogd
 USRBIN	+= utmpdump wall
-MAN1	+= mountpoint.1 wall.1
+MAN1	+= utmpdump.1 mountpoint.1 wall.1
 MAN8	+= sulogin.8 bootlogd.8
 endif
 
 ifeq ($(DISTRO),Debian)
+CPPFLAGS+= -DACCTON_OFF
 BIN	+= mountpoint
 SBIN	+= sulogin bootlogd
 MAN1	+= mountpoint.1
@@ -43,77 +44,87 @@
 MAN1	+= wall.1
 endif
 
+ifeq ($(DISTRO),SuSE)
+CPPFLAGS+= -DUSE_SYSFS -DSANE_TIO -DSIGINT_ONLYONCE -DUSE_ONELINE
+BIN	+= mountpoint
+SBIN	+= sulogin
+USRBIN	+= utmpdump
+MAN1	+= utmpdump.1 mountpoint.1
+MAN8	+= sulogin.8
+endif
+
+ID		= $(shell id -u)
 BIN_OWNER	= root
 BIN_GROUP	= root
 BIN_COMBO	= $(BIN_OWNER):$(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
+ifeq ($(ID),0)
+  INSTALL_EXEC	= install -o $(BIN_OWNER) -g $(BIN_GROUP) -m 755
+  INSTALL_DATA	= install -o $(BIN_OWNER) -g $(BIN_GROUP) -m 644
+else
+  INSTALL_EXEC	= install -m 755
+  INSTALL_DATA	= install -m 644
+endif
+INSTALL_DIR	= install -m 755 -d
 MANDIR		= /usr/share/man
 
 ifeq ($(WITH_SELINUX),yes)
-  SELINUX_DEF=-DWITH_SELINUX
-  INIT_SELIBS=-lsepol -lselinux
-  SULOGIN_SELIBS=-lselinux	
+  SELINUX_DEF	=  -DWITH_SELINUX
+  INITLIBS	+= -lsepol -lselinux
+  SULOGINLIBS	= -lselinux	
 else
-  SELINUX_DEF=
-  INIT_SELIBS=
-  SULOGIN_SELIBS=
+  SELINUX_DEF	=
+  INITLIBS	=
+  SULOGINLIBS	=
 endif
 
-
-
 # Additional libs for GNU libc.
-ifneq ($(wildcard /usr/lib/libcrypt.a),)
-LCRYPT		= -lcrypt
+ifneq ($(wildcard /usr/lib*/libcrypt.a),)
+  SULOGINLIBS	+= -lcrypt
 endif
 
 all:		$(BIN) $(SBIN) $(USRBIN)
 
+#%: %.o
+#	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS)
+#%.o: %.c
+#	$(CC) $(CFLAGS) $(CPPFLAGS) -c $^ -o $@
+
+init:		LDLIBS += $(INITLIBS) $(STATIC)
 init:		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
 
 last:		last.o oldutmp.h
-		$(CC) $(LDFLAGS) -o $@ last.o
 
 mesg:		mesg.o
-		$(CC) $(LDFLAGS) -o $@ mesg.o
 
 mountpoint:	mountpoint.o
-		$(CC) $(LDFLAGS) -o $@ mountpoint.o
 
 utmpdump:	utmpdump.o
-		$(CC) $(LDFLAGS) -o $@ utmpdump.o
 
 runlevel:	runlevel.o
-		$(CC) $(LDFLAGS) -o $@ runlevel.o
 
+sulogin:	LDLIBS += $(SULOGINLIBS) $(STATIC)
 sulogin:	sulogin.o
-		$(CC) $(LDFLAGS) $(STATIC) $(SELINUX_DEF) -o $@ $^ $(LCRYPT) $(SULOGIN_SELIBS)
 
 wall:		dowall.o wall.o
-		$(CC) $(LDFLAGS) -o $@ dowall.o wall.o
 
 shutdown:	dowall.o shutdown.o utmp.o reboot.h
-		$(CC) $(LDFLAGS) -o $@ dowall.o shutdown.o utmp.o
 
+bootlogd:	LDLIBS += -lutil
 bootlogd:	bootlogd.o
-		$(CC) $(LDFLAGS) -o $@ bootlogd.o -lutil
 
+sulogin.o:	CPPFLAGS += $(SELINUX_DEF)
 sulogin.o:	sulogin.c 
-		$(CC) -c $(CFLAGS) $(SELINUX_DEF) sulogin.c
 
+init.o:		CPPFLAGS += $(SELINUX_DEF)
 init.o:		init.c init.h set.h reboot.h initreq.h
-		$(CC) -c $(CFLAGS) $(SELINUX_DEF)  init.c
 
 utmp.o:		utmp.c init.h
-		$(CC) -c $(CFLAGS) utmp.c
 
+init_utmp.o:	CPPFLAGS += -DINIT_MAIN
 init_utmp.o:	utmp.c init.h
-		$(CC) -c $(CFLAGS) -DINIT_MAIN utmp.c -o init_utmp.o
+		$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
 
 cleanobjs:
 		rm -f *.o *.bak
@@ -127,19 +138,19 @@
 distclean:	clobber
 
 install:
+		$(INSTALL_DIR) $(ROOT)/bin/ $(ROOT)/sbin/
+		$(INSTALL_DIR) $(ROOT)/usr/bin/
 		for i in $(BIN); do \
-			$(STRIP) $$i ; \
 			$(INSTALL_EXEC) $$i $(ROOT)/bin/ ; \
 		done
 		for i in $(SBIN); do \
-			$(STRIP) $$i ; \
 			$(INSTALL_EXEC) $$i $(ROOT)/sbin/ ; \
 		done
 		for i in $(USRBIN); do \
-			$(STRIP) $$i ; \
 			$(INSTALL_EXEC) $$i $(ROOT)/usr/bin/ ; \
 		done
-		# $(INSTALL_EXEC) etc/initscript.sample $(ROOT)/etc/
+		# $(INSTALL_DIR) $(ROOT)/etc/
+		# $(INSTALL_EXEC) initscript.sample $(ROOT)/etc/
 		ln -sf halt $(ROOT)/sbin/reboot
 		ln -sf halt $(ROOT)/sbin/poweroff
 		ln -sf init $(ROOT)/sbin/telinit
@@ -147,7 +158,11 @@
 		if [ ! -f $(ROOT)/usr/bin/lastb ]; then \
 			ln -sf last $(ROOT)/usr/bin/lastb; \
 		fi
+		$(INSTALL_DIR) $(ROOT)/usr/include/
 		$(INSTALL_DATA) initreq.h $(ROOT)/usr/include/
+		$(INSTALL_DIR) $(ROOT)$(MANDIR)/man1/
+		$(INSTALL_DIR) $(ROOT)$(MANDIR)/man5/
+		$(INSTALL_DIR) $(ROOT)$(MANDIR)/man8/
 		for i in $(MAN1); do \
 			$(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man1/; \
 		done

Modified: sysvinit/branches/upstream/current/src/bootlogd.c
===================================================================
--- sysvinit/branches/upstream/current/src/bootlogd.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/bootlogd.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -8,13 +8,22 @@
  * Bugs:	Uses openpty(), only available in glibc. Sorry.
  *
  *		This file is part of the sysvinit suite,
- *		Copyright 1991-2004 Miquel van Smoorenburg.
+ *		Copyright (C) 1991-2004 Miquel van Smoorenburg.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
  *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
  *				*NOTE* *NOTE* *NOTE*
  *			This is a PROOF OF CONCEPT IMPLEMENTATION
  *
@@ -98,41 +107,60 @@
 
 /*
  *	Scan /dev and find the device name.
- *	Side-effect: directory is changed to /dev
- *
- *	FIXME: scan subdirectories for devfs support ?
  */
-int findtty(char *res, int rlen, dev_t dev)
+static int findtty(char *res, const char *startdir, int rlen, dev_t dev)
 {
 	DIR		*dir;
 	struct dirent	*ent;
 	struct stat	st;
-	int		r = 0;
+	int		r = -1;
+	char *olddir = getcwd(NULL, 0);
 
-	if (chdir("/dev") < 0 || (dir = opendir(".")) == NULL) {
-		perror("bootlogd: /dev");
+	if (chdir(startdir) < 0 || (dir = opendir(".")) == NULL) {
+		int msglen = strlen(startdir) + 11;
+		char *msg = malloc(msglen);
+		snprintf(msg, msglen, "bootlogd: %s", startdir);
+		perror(msg);
+		free(msg);
+		chdir(olddir);
 		return -1;
 	}
 	while ((ent = readdir(dir)) != NULL) {
 		if (lstat(ent->d_name, &st) != 0)
 			continue;
+		if (S_ISDIR(st.st_mode)
+		    && 0 != strcmp(".", ent->d_name)
+		    && 0 != strcmp("..", ent->d_name)) {
+			char *path = malloc(rlen);
+			snprintf(path, rlen, "%s/%s", startdir, ent->d_name);
+			r = findtty(res, path, rlen, dev);
+			free(path);
+			if (0 == r) { /* device found, return */
+				closedir(dir);
+				chdir(olddir);
+				return 0;
+			}
+			continue;
+		}
 		if (!S_ISCHR(st.st_mode))
 			continue;
 		if (st.st_rdev == dev) {
-			break;
+			if ( (int) (strlen(ent->d_name) + strlen(startdir) + 1) >= rlen) {
+				fprintf(stderr, "bootlogd: console device name too long\n");
+				closedir(dir);
+				chdir(olddir);
+				return -1;
+			} else {
+				snprintf(res, rlen, "%s/%s", startdir, ent->d_name);
+				closedir(dir);
+				chdir(olddir);
+				return 0;
+			}
 		}
 	}
-	if (ent == NULL) {
-		fprintf(stderr, "bootlogd: cannot find console device "
-			"%d:%d in /dev\n", major(dev), minor(dev));
-		r = -1;
-	} else if (strlen(ent->d_name) + 5 >= rlen) {
-		fprintf(stderr, "bootlogd: console device name too long\n");
-		r = -1;
-	} else
-		snprintf(res, rlen, "/dev/%s", ent->d_name);
 	closedir(dir);
 
+	chdir(olddir);
 	return r;
 }
 
@@ -170,7 +198,7 @@
 		}
 		if (found) break;
 	}
-	if (found < 0) return -1;
+	if (!found) return -1;
 
 	if (name) strcpy(name, tty);
 
@@ -227,12 +255,24 @@
 		/*
 		 *	Old kernel, can find real device easily.
 		 */
-		return findtty(res, rlen, st.st_rdev);
+		int r = findtty(res, "/dev", rlen, st.st_rdev);
+		if (0 != r)
+			fprintf(stderr, "bootlogd: cannot find console device "
+				"%d:%d under /dev\n", major(st.st_rdev), minor(st.st_rdev));
+		return r;
 	}
 
 #ifdef TIOCGDEV
-	if (ioctl(0, TIOCGDEV, &kdev) == 0)
-		return findtty(res, rlen, (dev_t)kdev);
+# ifndef  ENOIOCTLCMD
+#  define ENOIOCTLCMD	515
+# endif
+	if (ioctl(0, TIOCGDEV, &kdev) == 0) {
+		int r = findtty(res, "/dev", rlen, (dev_t)kdev);
+		if (0 != r)
+			fprintf(stderr, "bootlogd: cannot find console device "
+				"%d:%d under /dev\n", major(kdev), minor(kdev));
+		return r;
+	}
 	if (errno != ENOIOCTLCMD) return -1;
 #endif
 
@@ -338,11 +378,11 @@
 				break;
 			case '\n':
 				didnl = 1;
-				dosync = syncalot;
+				dosync = 1;
 				break;
 			case '\t':
 				line.pos += (line.pos / 8 + 1) * 8;
-				if (line.pos >= sizeof(line.buf))
+				if (line.pos >= (int)sizeof(line.buf))
 					line.pos = sizeof(line.buf) - 1;
 				break;
 			case  32 ... 127:
@@ -358,7 +398,7 @@
 		len--;
 
 		tlen = strlen(tmp);
-		if (tlen && (line.pos + tlen < sizeof(line.buf))) {
+		if (tlen && (line.pos + tlen < (int)sizeof(line.buf))) {
 			memcpy(line.buf + line.pos, tmp, tlen);
 			line.pos += tlen;
 		}
@@ -370,7 +410,9 @@
 
 	if (dosync) {
 		fflush(fp);
-		fdatasync(fileno(fp));
+		if (syncalot) {
+			fdatasync(fileno(fp));
+		}
 	}
 
 	outptr += olen;
@@ -631,7 +673,7 @@
 		else
 			todo = endptr - outptr;
 		if (fp && todo)
-			writelog(fp, outptr, todo);
+			writelog(fp, (unsigned char *)outptr, todo);
 	}
 
 	if (fp) {

Modified: sysvinit/branches/upstream/current/src/dowall.c
===================================================================
--- sysvinit/branches/upstream/current/src/dowall.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/dowall.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -6,12 +6,21 @@
  * Version:	@(#)dowall.c  2.85-5  02-Jul-2003  miquels at cistron.nl
  *
  *		This file is part of the sysvinit suite,
- *		Copyright 1991-2003 Miquel van Smoorenburg.
+ *		Copyright (C) 1991-2003 Miquel van Smoorenburg.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
+ *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -27,14 +36,26 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <setjmp.h>
+#include <paths.h>
 
+#ifndef _PATH_DEV
+# define _PATH_DEV	"/dev/"
+#endif
+#ifndef HOST_NAME_MAX
+# define HOST_NAME_MAX	255
+#endif
+
 static sigjmp_buf jbuf;
 
 /*
  *	Alarm handler
  */
 /*ARGSUSED*/
+# ifdef __GNUC__
+static void handler(int arg __attribute__((unused)))
+# else
 static void handler(int arg)
+# endif
 {
 	siglongjmp(jbuf, 1);
 }
@@ -43,7 +64,7 @@
 /*
  *	Print a text, escape all characters not in Latin-1.
  */
-static void feputs(char *line, FILE *fp)
+static void feputs(const char *line, FILE *fp)
 {
 	unsigned char		*p;
 
@@ -79,9 +100,14 @@
 		}
 
 		if ((tty = ttyname(0)) != NULL) {
-			if (strncmp(tty, "/dev/", 5) == 0)
-				tty += 5;
-			sprintf(ttynm, "(%.28s) ", tty);	
+			const size_t plen = strlen(_PATH_DEV);
+			if (strncmp(tty, _PATH_DEV, plen) == 0) {
+				tty += plen;
+				if (tty[0] == '/')
+					tty++;
+			}
+			snprintf(ttynm, sizeof(ttynm), "(%.*s) ",
+				 UT_LINESIZE, tty);
 		} else
 			ttynm[0] = 0;
 		init++;
@@ -123,15 +149,15 @@
 /*
  *	Wall function.
  */
-void wall(char *text, int fromshutdown, int remote)
+void wall(const char *text, int remote)
 {
 	FILE			*tp;
 	struct sigaction	sa;
 	struct utmp		*utmp;
 	time_t			t;
-	char			term[UT_LINESIZE+6];
+	char			term[UT_LINESIZE+ strlen(_PATH_DEV) + 1];
 	char			line[81];
-	char                    hostname[256]; /* HOST_NAME_MAX+1 */
+	char			hostname[HOST_NAME_MAX+1];
 	char			*date, *p;
 	char			*user, *tty;
 	int			fd, flags;
@@ -189,11 +215,11 @@
 	while ((utmp = getutent()) != NULL) {
 		if(utmp->ut_type != USER_PROCESS ||
 		   utmp->ut_user[0] == 0) continue;
-		if (strncmp(utmp->ut_line, "/dev/", 5) == 0) {
+		if (strncmp(utmp->ut_line, _PATH_DEV, strlen(_PATH_DEV)) == 0) {
 			term[0] = 0;
 			strncat(term, utmp->ut_line, sizeof(term)-1);
 		} else
-			snprintf(term, sizeof(term), "/dev/%.*s",
+			snprintf(term, sizeof(term), _PATH_DEV "%.*s",
 				UT_LINESIZE, utmp->ut_line);
 		if (strstr(term, "/../")) continue;
 

Added: sysvinit/branches/upstream/current/src/fstab-decode.c
===================================================================
--- sysvinit/branches/upstream/current/src/fstab-decode.c	                        (rev 0)
+++ sysvinit/branches/upstream/current/src/fstab-decode.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -0,0 +1,86 @@
+/* fstab-decode(8).
+
+Copyright (c) 2006 Red Hat, Inc. All rights reserved.
+
+This copyrighted material is made available to anyone wishing to use, modify,
+copy, or redistribute it subject to the terms and conditions of the GNU General
+Public License v.2.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+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., 51 Franklin
+Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+Author: Miloslav Trmac <mitr at redhat.com> */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* Decode the fstab-encoded string in place. */
+static void
+decode(char *s)
+{
+	const char *src;
+	char *dest;
+
+	src = s;
+	dest = s;
+	while (*src != '\0') {
+		if (*src != '\\')
+			*dest = *src++;
+		else {
+			static const struct repl {
+				char orig[4];
+				size_t len;
+				char new;
+			} repls[] = {
+#define R(X, Y) { X, sizeof(X) - 1, Y }
+				R("\\", '\\'),
+				R("011", '\t'),
+				R("012", '\n'),
+				R("040", ' '),
+				R("134", '\\')
+#undef R
+			};
+
+			size_t i;
+
+			for (i = 0; i < sizeof (repls) / sizeof (repls[0]);
+			     i++) {
+				if (memcmp(src + 1, repls[i].orig,
+					   repls[i].len) == 0) {
+					*dest = repls[i].new;
+					src += 1 + repls[i].len;
+					goto found;
+				}
+			}
+			*dest = *src++;
+		found:
+			;
+		}
+		dest++;
+	}
+	*dest = '\0';
+}
+
+int
+main (int argc, char *argv[])
+{
+	size_t i;
+
+	if (argc < 2) {
+		fprintf(stderr, "Usage: fstab-decode command [arguments]\n");
+		return EXIT_FAILURE;
+	}
+	for (i = 2; i < (size_t)argc; i++)
+		decode(argv[i]);
+	execvp(argv[1], argv + 1);
+	fprintf(stderr, "fstab-decode: %s: %s\n", argv[1], strerror(errno));
+	return 127;
+}

Modified: sysvinit/branches/upstream/current/src/halt.c
===================================================================
--- sysvinit/branches/upstream/current/src/halt.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/halt.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -26,12 +26,21 @@
  * Version:	2.86,  30-Jul-2004
  *
  *		This file is part of the sysvinit suite,
- *		Copyright 1991-2004 Miquel van Smoorenburg.
+ *		Copyright (C) 1991-2004 Miquel van Smoorenburg.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
+ *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <sys/types.h>
@@ -57,6 +66,7 @@
 
 extern int ifdown(void);
 extern int hddown(void);
+extern int hdflush(void);
 extern void write_wtmp(char *user, char *id, int pid, int type, char *line);
 
 /*
@@ -261,6 +271,8 @@
 
 	if (do_hddown)
 		(void)hddown();
+	else
+		(void)hdflush();
 
 	if (do_nothing) exit(0);
 

Modified: sysvinit/branches/upstream/current/src/hddown.c
===================================================================
--- sysvinit/branches/upstream/current/src/hddown.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/hddown.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -2,6 +2,22 @@
  * hddown.c	Find all disks on the system and
  *		shut them down.
  *
+ * Copyright (C) 2003 Miquel van Smoorenburg.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
  */
 char *v_hddown = "@(#)hddown.c  1.02  22-Apr-2003  miquels at cistron.nl";
 
@@ -20,9 +36,12 @@
 
 #include <sys/ioctl.h>
 #include <linux/hdreg.h>
+#include <linux/fs.h>
 
-#define USE_SYSFS
-#ifdef USE_SYSFS
+#ifndef USE_SYSFS
+# define USE_SYSFS	1
+#endif
+#if defined(USE_SYSFS) && (USE_SYSFS == 1)
 /*
  * sysfs part	Find all disks on the system, list out IDE and unmanaged
  *		SATA disks, flush the cache of those and shut them down.
@@ -47,10 +66,13 @@
 #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() */
+/* Maybe set in list_disks() and used in do_standby_disk() */
 #define DISK_IS_IDE	0x00000001
 #define DISK_IS_SATA	0x00000002
 #define DISK_EXTFLUSH	0x00000004
+#define DISK_REMOVABLE	0x00000008
+#define DISK_MANAGED	0x00000010
+#define DISK_FLUSHONLY	0x00000020
 
 static char *strstrip(char *str);
 static FILE *hdopen(const char* const format, const char* const name);
@@ -64,10 +86,9 @@
 	struct dirent *d;
 
 	while ((d = readdir(blk))) {
-		*flags = 0;
+		(*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;
 
@@ -82,9 +103,12 @@
 			fclose(fp);
 
 			if (ret != '0')
-				continue;		/* not a hard disk */
+				(*flags) |= DISK_REMOVABLE;
 
 			if (d->d_name[0] == 'h') {
+				if ((*flags) & DISK_REMOVABLE)
+					continue;	/* not a hard disk */
+
 				(*flags) |= DISK_IS_IDE;
 				if ((ret = flush_cache_ext(d->d_name))) {
 					if (ret < 0)
@@ -95,11 +119,11 @@
 			}
 
 			ret = snprintf(buf, sizeof(buf), SYS_BLK "/%s/device", d->d_name);
-			if ((ret >= sizeof(buf)) || (ret < 0))
+			if ((ret >= (int)sizeof(buf)) || (ret < 0))
 				goto empty;		/* error */
 
 			ret = readlink(buf, lnk, sizeof(lnk));
-			if (ret >= sizeof(lnk))
+			if (ret >= (int)sizeof(lnk))
 				goto empty;		/* error */
 			if (ret < 0) {
 				if (errno != ENOENT)
@@ -112,17 +136,20 @@
 			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 */
+			fp = hdopen(SYS_CLASS "/%s/manage_start_stop", ptr);
+			if ((long)fp <= 0) {
+				if ((long)fp < 0)
+					goto empty;	/* error */
+			} else {
+				ret = getc(fp);
+				fclose(fp);
 
-			ret = stat(buf, &st);
-			if (ret == 0)
-				continue;		/* disk found but managed by kernel */
+				if (ret != '0') {
+					(*flags) |= DISK_MANAGED;
+					continue;
+				}
+			}
 
-			if (errno != ENOENT)
-				goto empty;		/* error */
-
 			fp = hdopen(SYS_BLK "/%s/device/vendor", d->d_name);
 			if ((long)fp <= 0) {
 				if ((long)fp < 0)
@@ -139,16 +166,28 @@
 			if (*ptr == '\0')
 				continue;		/* should not happen */
 
-			if (strncmp(buf, "ATA", sizeof(buf)))
-				continue;		/* no SATA but a real SCSI disk */
+			if (strncmp(buf, "ATA", sizeof(buf)) == 0) {
+				if ((*flags) & DISK_REMOVABLE)
+					continue;	/* not a hard disk */
 
-			(*flags) |= (DISK_IS_IDE|DISK_IS_SATA);
+				(*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 (((*flags) & DISK_REMOVABLE) == 0)
+				continue;		/* Seems to be a real SCSI disk */
+
 			if ((ret = flush_cache_ext(d->d_name))) {
 				if (ret < 0)
 					goto empty;
 				(*flags) |= DISK_EXTFLUSH;
 			}
-			break;				/* new SATA disk to shutdown, out here */
+			break;				/* Removable disk like USB stick to shutdown */
 		}
 	}
 	if (d == (struct dirent*)0)
@@ -159,10 +198,10 @@
 }
 
 /*
- *	Put an disk in standby mode.
+ *	Put an IDE/SCSI/SATA disk in standby mode.
  *	Code stolen from hdparm.c
  */
-static int do_standby_idedisk(char *device, unsigned int flags)
+static int do_standby_disk(char *device, unsigned int flags)
 {
 #ifndef WIN_STANDBYNOW1
 #define WIN_STANDBYNOW1		0xE0
@@ -184,24 +223,28 @@
 	int fd, ret;
 
 	ret = snprintf(buf, sizeof(buf), DEV_BASE "/%s", device);
-	if ((ret >= sizeof(buf)) || (ret < 0))
+	if ((ret >= (int)sizeof(buf)) || (ret < 0))
 		return -1;
 
-	if ((fd = open(buf, O_RDWR)) < 0)
+	if ((fd = open(buf, O_RDWR|O_NONBLOCK)) < 0)
 		return -1;
 
 	switch (flags & DISK_EXTFLUSH) {
 	case DISK_EXTFLUSH:
-		if (ioctl(fd, HDIO_DRIVE_CMD, &flush1) == 0)
+		if ((ret = ioctl(fd, HDIO_DRIVE_CMD, &flush1)) == 0)
 			break;
 		/* Extend flush rejected, try standard flush */
 	default:
-		ioctl(fd, HDIO_DRIVE_CMD, &flush2);
+		ret = ioctl(fd, HDIO_DRIVE_CMD, &flush2) &&
+		      ioctl(fd, BLKFLSBUF);
 		break;
 	}
 
-	ret = ioctl(fd, HDIO_DRIVE_CMD, &stdby1) &&
-	      ioctl(fd, HDIO_DRIVE_CMD, &stdby2);
+	if ((flags & DISK_FLUSHONLY) == 0x0) {
+		ret = ioctl(fd, HDIO_DRIVE_CMD, &stdby1) &&
+		      ioctl(fd, HDIO_DRIVE_CMD, &stdby2);
+	}
+
 	close(fd);
 
 	if (ret)
@@ -224,12 +267,30 @@
 		return -1;
 
 	while ((disk = list_disks(blk, &flags)))
-		do_standby_idedisk(disk, flags);
+		do_standby_disk(disk, flags);
 
 	return closedir(blk);
 }
 
 /*
+ *	List all disks and cause them to flush their buffers.
+ */
+int hdflush(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_disk(disk, (flags|DISK_FLUSHONLY));
+
+	return closedir(blk);
+}
+
+/*
  * Strip off trailing white spaces
  */
 static char *strstrip(char *str)
@@ -255,7 +316,7 @@
 	int fd, ret;
 	
 	ret = snprintf(buf, sizeof(buf), format, name);
-	if ((ret >= sizeof(buf)) || (ret < 0))
+	if ((ret >= (int)sizeof(buf)) || (ret < 0))
 		goto error;		/* error */
 
 	fd = open(buf, O_RDONLY|O_NOCTTY);
@@ -308,7 +369,7 @@
 		goto out;		/* small disk */
 		
 	ret = snprintf(buf, sizeof(buf), DEV_BASE "/%s", device);
-	if ((ret >= sizeof(buf)) || (ret < 0))
+	if ((ret >= (int)sizeof(buf)) || (ret < 0))
 		return -1;		/* error */
 
 	if ((fd = open(buf, O_RDONLY|O_NONBLOCK)) < 0)
@@ -477,6 +538,12 @@
 
 	return (result1 ? result1 : result2);
 }
+
+int hdflush(void)
+{
+	return 0;
+}
+
 #endif /* ! USE_SYSFS */
 #else /* __linux__ */
 
@@ -485,6 +552,11 @@
 	return 0;
 }
 
+int hdflush(void)
+{
+	return 0;
+}
+
 #endif /* __linux__ */
 
 #ifdef STANDALONE

Modified: sysvinit/branches/upstream/current/src/ifdown.c
===================================================================
--- sysvinit/branches/upstream/current/src/ifdown.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/ifdown.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -2,6 +2,22 @@
  * ifdown.c	Find all network interfaces on the system and
  *		shut them down.
  *
+ * Copyright (C) 1998 Miquel van Smoorenburg.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by 
+ * the Free Software Foundation; either version 2 of the License, or 
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, 
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
  */
 char *v_ifdown = "@(#)ifdown.c  1.11  02-Jun-1998  miquels at cistron.nl";
 
@@ -61,15 +77,33 @@
 				continue;
 			if (strchr(ifr[i].ifr_name, ':') != NULL)
 				continue;
-			ifr[i].ifr_flags &= ~(IFF_UP);
-			if (ioctl(fd, SIOCSIFFLAGS, &ifr[i]) < 0) {
+
+			/* Read interface flags */
+			if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) < 0) {
 				fprintf(stderr, "ifdown: shutdown ");
 				perror(ifr[i].ifr_name);
+				continue;
 			}
+			/*
+			 * Expected in <net/if.h> according to
+			 * "UNIX Network Programming".
+			 */
+#ifdef ifr_flags
+# define IRFFLAGS	ifr_flags
+#else	/* Present on kFreeBSD */
+# define IRFFLAGS	ifr_flagshigh
+#endif
+			if (ifr[i].IRFFLAGS & IFF_UP) {
+				ifr[i].IRFFLAGS &= ~(IFF_UP);
+				if (ioctl(fd, SIOCSIFFLAGS, &ifr[i]) < 0) {
+					fprintf(stderr, "ifdown: shutdown ");
+					perror(ifr[i].ifr_name);
+				}
+			}
+#undef IRFFLAGS
 		}
 	}
 	close(fd);
 
 	return 0;
 }
-

Modified: sysvinit/branches/upstream/current/src/init.c
===================================================================
--- sysvinit/branches/upstream/current/src/init.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/init.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -7,17 +7,26 @@
  *
  * Version:	@(#)init.c  2.86  30-Jul-2004  miquels at cistron.nl
  */
-#define VERSION "2.86"
-#define DATE    "31-Jul-2004"
+#define VERSION "2.88"
+#define DATE    "26-Mar-2010"
 /*
  *		This file is part of the sysvinit suite,
- *		Copyright 1991-2004 Miquel van Smoorenburg.
+ *		Copyright (C) 1991-2004 Miquel van Smoorenburg.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
  *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
  */
 
 #include <sys/types.h>
@@ -44,17 +53,22 @@
 #include <sys/time.h>
 
 #ifdef WITH_SELINUX
-#include <selinux/selinux.h>
+#  include <selinux/selinux.h>
+#  include <sys/mount.h>
+#  ifndef MNT_DETACH /* present in glibc 2.10, missing in 2.7 */
+#    define MNT_DETACH 2
+#  endif
 #endif
 
-
 #ifdef __i386__
-#  if (__GLIBC__ >= 2)
+#  ifdef __GLIBC__
      /* GNU libc 2.x */
 #    define STACK_DEBUG 1
 #    if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0)
        /* Only glibc 2.0 needs this */
 #      include <sigcontext.h>
+#    elif ( __GLIBC__ > 2) && ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))
+#      include <bits/sigcontext.h>
 #    endif
 #  endif
 #endif
@@ -112,11 +126,12 @@
 int emerg_shell = 0;		/* Start emergency shell? */
 int wrote_wtmp_reboot = 1;	/* Set when we wrote the reboot record */
 int wrote_utmp_reboot = 1;	/* Set when we wrote the reboot record */
+int wrote_wtmp_rlevel = 1;	/* Set when we wrote the runlevel record */
+int wrote_utmp_rlevel = 1;	/* Set when we wrote the runlevel record */
 int sltime = 5;			/* Sleep time between TERM and KILL */
 char *argv0;			/* First arguments; show up in ps listing */
 int maxproclen;			/* Maximal length of argv[0] with \0 */
 struct utmp utproto;		/* Only used for sizeof(utproto.ut_id) */
-char *user_console = NULL;	/* User console device */
 char *console_dev;		/* Console device. */
 int pipe_fd = -1;		/* /dev/initctl */
 int did_boot = 0;		/* Did we already do BOOT* stuff? */
@@ -181,6 +196,8 @@
   { "-WU",	   D_WROTE_UTMP_REBOOT},
   { "-ST",	   D_SLTIME	},
   { "-DB",	   D_DIDBOOT	},
+  { "-LW",	   D_WROTE_WTMP_RLEVEL},
+  { "-LU",	   D_WROTE_UTMP_RLEVEL},
   { "",	   	   0		}
 };
 struct {
@@ -204,6 +221,7 @@
  *	This only works correctly because the linux select updates
  *	the elapsed time in the struct timeval passed to select!
  */
+static
 void do_sleep(int sec)
 {
 	struct timeval tv;
@@ -219,6 +237,7 @@
 /*
  *	Non-failing allocation routines (init cannot fail).
  */
+static
 void *imalloc(size_t size)
 {
 	void	*m;
@@ -231,7 +250,7 @@
 	return m;
 }
 
-
+static
 char *istrdup(char *s)
 {
 	char	*m;
@@ -248,6 +267,7 @@
  *	Send the state info of the previous running init to
  *	the new one, in a version-independant way.
  */
+static
 void send_state(int fd)
 {
 	FILE	*fp;
@@ -377,6 +397,12 @@
 			case D_DIDBOOT:
 				fscanf(f, "%d\n", &did_boot);
 				break;
+			case D_WROTE_WTMP_RLEVEL:
+				fscanf(f, "%d\n", &wrote_wtmp_rlevel);
+				break;
+			case D_WROTE_UTMP_RLEVEL:
+				fscanf(f, "%d\n", &wrote_utmp_rlevel);
+				break;
 			default:
 				if (cmd > 0 || cmd == C_EOF) {
 					oops_error = -1;
@@ -434,6 +460,7 @@
  *	Read the complete state info from the state pipe.
  *	Returns 0 on success
  */
+static
 int receive_state(int fd)
 {
 	FILE	*f;
@@ -481,6 +508,7 @@
 /*
  *	Set console_dev to a working console.
  */
+static
 void console_init(void)
 {
 	int fd;
@@ -488,9 +516,7 @@
 	int tried_vtmaster = 0;
 	char *s;
 
-	if (user_console) {
-		console_dev = user_console;
-	} else if ((s = getenv("CONSOLE")) != NULL)
+	if ((s = getenv("CONSOLE")) != NULL)
 		console_dev = s;
 	else {
 		console_dev = CONSOLE;
@@ -520,6 +546,7 @@
 /*
  *	Open the console with retries.
  */
+static
 int console_open(int mode)
 {
 	int f, fd = -1;
@@ -535,7 +562,7 @@
 	 */
 	for(f = 0; f < 5; f++) {
 		if ((fd = open(console_dev, m)) >= 0) break;
-		usleep(100);
+		usleep(10000);
 	}
 
 	if (fd < 0) return fd;
@@ -551,6 +578,7 @@
 /*
  *	We got a signal (HUP PWR WINCH ALRM INT)
  */
+static
 void signal_handler(int sig)
 {
 	ADDSET(got_signals, sig);
@@ -559,7 +587,12 @@
 /*
  *	SIGCHLD: one of our children has died.
  */
-void chld_handler()
+static
+# ifdef __GNUC__
+void chld_handler(int sig __attribute__((unused)))
+# else
+void chld_handler(int sig)
+# endif
 {
 	CHILD		*ch;
 	int		pid, st;
@@ -599,7 +632,12 @@
  *
  *	The SIGCONT handler
  */
-void cont_handler()
+static
+# ifdef __GNUC__
+void cont_handler(int sig __attribute__((unused)))
+# else
+void cont_handler(int sig)
+# endif
 {
 	got_cont = 1;
 }
@@ -607,6 +645,7 @@
 /*
  *	Fork and dump core in /.
  */
+static
 void coredump(void)
 {
 	static int		dumped = 0;
@@ -640,8 +679,13 @@
  *	If we have the info, print where it occured.
  *	Then sleep 30 seconds and try to continue.
  */
+static
 #if defined(STACK_DEBUG) && defined(__linux__)
+# ifdef __GNUC__
+void segv_handler(int sig __attribute__((unused)), struct sigcontext ctx)
+# else
 void segv_handler(int sig, struct sigcontext ctx)
+# endif
 {
 	char	*p = "";
 	int	saved_errno = errno;
@@ -656,7 +700,11 @@
 	errno = saved_errno;
 }
 #else
-void segv_handler()
+# ifdef __GNUC__
+void segv_handler(int sig __attribute__((unused)))
+# else
+void segv_handler(int sig)
+# endif
 {
 	int	saved_errno = errno;
 
@@ -671,7 +719,12 @@
 /*
  *	The SIGSTOP & SIGTSTP handler
  */
-void stop_handler()
+static
+# ifdef __GNUC__
+void stop_handler(int sig __attribute__((unused)))
+# else
+void stop_handler(int sig)
+# endif
 {
 	int	saved_errno = errno;
 
@@ -684,6 +737,7 @@
 /*
  *	Set terminal settings to reasonable defaults
  */
+static
 void console_stty(void)
 {
 	struct termios tty;
@@ -694,30 +748,59 @@
 		return;
 	}
 
+#ifdef __FreeBSD_kernel__
+	/*
+	 * The kernel of FreeBSD expects userland to set TERM.  Usually, we want
+	 * "cons25".  Later, gettys might disagree on this (i.e. we're not using
+	 * syscons) but some boot scripts, like /etc/init.d/xserver-xorg, still
+	 * need a non-dumb terminal.
+	 */
+	putenv ("TERM=cons25");
+#endif
+
 	(void) tcgetattr(fd, &tty);
 
 	tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD;
 	tty.c_cflag |= HUPCL|CLOCAL|CREAD;
 
-	tty.c_cc[VINTR]  = 3;	/* ctrl('c') */
-	tty.c_cc[VQUIT]  = 28;	/* ctrl('\\') */
-	tty.c_cc[VERASE] = 127;
-	tty.c_cc[VKILL]  = 24;	/* ctrl('x') */
-	tty.c_cc[VEOF]   = 4;	/* ctrl('d') */
-	tty.c_cc[VTIME]  = 0;
-	tty.c_cc[VMIN]   = 1;
-	tty.c_cc[VSTART] = 17;	/* ctrl('q') */
-	tty.c_cc[VSTOP]  = 19;	/* ctrl('s') */
-	tty.c_cc[VSUSP]  = 26;	/* ctrl('z') */
+	tty.c_cc[VINTR]	    = CINTR;
+	tty.c_cc[VQUIT]	    = CQUIT;
+	tty.c_cc[VERASE]    = CERASE; /* ASCII DEL (0177) */
+	tty.c_cc[VKILL]	    = CKILL;
+	tty.c_cc[VEOF]	    = CEOF;
+	tty.c_cc[VTIME]	    = 0;
+	tty.c_cc[VMIN]	    = 1;
+	tty.c_cc[VSWTC]	    = _POSIX_VDISABLE;
+	tty.c_cc[VSTART]    = CSTART;
+	tty.c_cc[VSTOP]	    = CSTOP;
+	tty.c_cc[VSUSP]	    = CSUSP;
+	tty.c_cc[VEOL]	    = _POSIX_VDISABLE;
+	tty.c_cc[VREPRINT]  = CREPRINT;
+	tty.c_cc[VDISCARD]  = CDISCARD;
+	tty.c_cc[VWERASE]   = CWERASE;
+	tty.c_cc[VLNEXT]    = CLNEXT;
+	tty.c_cc[VEOL2]	    = _POSIX_VDISABLE;
 
 	/*
 	 *	Set pre and post processing
 	 */
 	tty.c_iflag = IGNPAR|ICRNL|IXON|IXANY;
+#ifdef IUTF8 /* Not defined on FreeBSD */
+	tty.c_iflag |= IUTF8;
+#endif /* IUTF8 */
 	tty.c_oflag = OPOST|ONLCR;
 	tty.c_lflag = ISIG|ICANON|ECHO|ECHOCTL|ECHOPRT|ECHOKE;
 
+#if defined(SANE_TIO) && (SANE_TIO == 1)
 	/*
+	 *	Disable flow control (-ixon), ignore break (ignbrk),
+	 *	and make nl/cr more usable (sane).
+	 */
+	tty.c_iflag |=  IGNBRK;
+	tty.c_iflag &= ~(BRKINT|INLCR|IGNCR|IXON);
+	tty.c_oflag &= ~(OCRNL|ONLRET);
+#endif
+	/*
 	 *	Now set the terminal line.
 	 *	We don't care about non-transmitted output data
 	 *	and non-read input data.
@@ -788,25 +871,30 @@
 	char		i_lvl[] = "RUNLEVEL=x";
 	char		i_prev[] = "PREVLEVEL=x";
 	char		i_cons[32];
+	char		i_shell[] = "SHELL=" SHELL;
 	char		**e;
 	int		n, i;
 
 	for (n = 0; environ[n]; n++)
 		;
-	n += NR_EXTRA_ENV + 8;
+	n += NR_EXTRA_ENV;
+	if (child)
+		n += 8;
 	e = calloc(n, sizeof(char *));
 
 	for (n = 0; environ[n]; n++)
 		e[n] = istrdup(environ[n]);
 
-	for (i = 0; i < NR_EXTRA_ENV; i++)
+	for (i = 0; i < NR_EXTRA_ENV; i++) {
 		if (extra_env[i])
 			e[n++] = istrdup(extra_env[i]);
+	}
 
 	if (child) {
 		snprintf(i_cons, sizeof(i_cons), "CONSOLE=%s", console_dev);
 		i_lvl[9]   = thislevel;
 		i_prev[10] = prevlevel;
+		e[n++] = istrdup(i_shell);
 		e[n++] = istrdup(i_lvl);
 		e[n++] = istrdup(i_prev);
 		e[n++] = istrdup(i_cons);
@@ -835,11 +923,12 @@
  *	This function is too long and indents too deep.
  *
  */
-int spawn(CHILD *ch, int *res)
+static
+pid_t spawn(CHILD *ch, int *res)
 {
   char *args[16];		/* Argv array */
   char buf[136];		/* Line buffer */
-  int f, st, rc;		/* Scratch variables */
+  int f, st;			/* Scratch variables */
   char *ptr;			/* Ditto */
   time_t t;			/* System time */
   int oldAlarm;			/* Previous alarm value */
@@ -975,6 +1064,14 @@
   				dup(f);
   				dup(f);
 			}
+
+			/*
+			 * 4 Sep 2001, Andrea Arcangeli:
+			 * Fix a race in spawn() that is used to deadlock init in a
+			 * waitpid() loop: must set the childhandler as default before forking
+			 * off the child or the chld_handler could run before the waitpid loop
+			 * has a chance to find its zombie-child.
+			 */
 			SETSIG(sa, SIGCHLD, SIG_DFL, SA_RESTART);
 			if ((pid = fork()) < 0) {
   				initlog(L_VB, "cannot fork: %s",
@@ -982,6 +1079,7 @@
 				exit(1);
 			}
 			if (pid > 0) {
+				pid_t rc;
 				/*
 				 *	Ignore keyboard signals etc.
 				 *	Then wait for child to exit.
@@ -1036,6 +1134,25 @@
 			dup(f);
 		}
 
+		/*
+		 * Update utmp/wtmp file prior to starting
+		 * any child.  This MUST be done right here in
+		 * the child process in order to prevent a race
+		 * condition that occurs when the child
+		 * process' time slice executes before the
+		 * parent (can and does happen in a uniprocessor
+		 * environment).  If the child is a getty and
+		 * the race condition happens, then init's utmp
+		 * update will happen AFTER the getty runs
+		 * and expects utmp to be updated already!
+		 *
+		 * Do NOT log if process field starts with '+'
+		 * FIXME: that's for compatibility with *very*
+		 * old getties - probably it can be taken out.
+		 */
+		if (ch->process[0] != '+')
+			write_utmp_wtmp("", ch->id, getpid(), INIT_PROCESS, "");
+
   		/* Reset all the signals, set up environment */
   		for(f = 1; f < NSIG; f++) SETSIG(sa, f, SIG_DFL, SA_RESTART);
 		environ = init_buildenv(1);
@@ -1055,6 +1172,9 @@
 			execvp(args[1], args + 1);
 		}
   		initlog(L_VB, "cannot execute \"%s\"", args[1]);
+
+		if (ch->process[0] != '+')
+			write_utmp_wtmp("", ch->id, getpid(), DEAD_PROCESS, NULL);
   		exit(1);
   	}
 	*res = pid;
@@ -1074,6 +1194,7 @@
 /*
  *	Start a child running!
  */
+static
 void startup(CHILD *ch)
 {
 	/*
@@ -1099,15 +1220,7 @@
 		case ONDEMAND:
 		case RESPAWN:
   			ch->flags |= RUNNING;
-  			if (spawn(ch, &(ch->pid)) < 0) break;
-			/*
-			 *	Do NOT log if process field starts with '+'
-			 *	FIXME: that's for compatibility with *very*
-			 *	old getties - probably it can be taken out.
-			 */
-  			if (ch->process[0] != '+')
-				write_utmp_wtmp("", ch->id, ch->pid,
-					INIT_PROCESS, "");
+  			(void)spawn(ch, &(ch->pid));
   			break;
 	}
 }
@@ -1116,6 +1229,7 @@
 /*
  *	Read the inittab file.
  */
+static
 void read_inittab(void)
 {
   FILE		*fp;			/* The INITTAB file */
@@ -1248,7 +1362,7 @@
 	strncpy(ch->id, id, sizeof(utproto.ut_id) + 1); /* Hack for different libs. */
 	strncpy(ch->process, process, sizeof(ch->process) - 1);
 	if (rlevel[0]) {
-		for(f = 0; f < sizeof(rlevel) - 1 && rlevel[f]; f++) {
+		for(f = 0; f < (int)sizeof(rlevel) - 1 && rlevel[f]; f++) {
 			ch->rlevel[f] = rlevel[f];
 			if (ch->rlevel[f] == 's') ch->rlevel[f] = 'S';
 		}
@@ -1496,6 +1610,7 @@
  *	The entries that do not belong here at all are removed
  *	from the list.
  */
+static
 void start_if_needed(void)
 {
 	CHILD *ch;		/* Pointer to child */
@@ -1541,6 +1656,7 @@
 /*
  *	Ask the user on the console for a runlevel
  */
+static
 int ask_runlevel(void)
 {
 	const char	prompt[] = "\nEnter runlevel: ";
@@ -1569,6 +1685,7 @@
  *	Search the INITTAB file for the 'initdefault' field, with the default
  *	runlevel. If this fails, ask the user to supply a runlevel.
  */
+static
 int get_init_default(void)
 {
 	CHILD *ch;
@@ -1617,6 +1734,7 @@
  *	the "old" INITLVL and arg == 0, try to read the new
  *	runlevel from that file first.
  */
+static
 int read_level(int arg)
 {
 	CHILD		*ch;			/* Walk through list */
@@ -1685,7 +1803,14 @@
 		  	initlog(L_VB, "Switching to runlevel: %c", foo);
 	}
 
-	if (foo == 'Q') return runlevel;
+	if (foo == 'Q') {
+#if defined(SIGINT_ONLYONCE) && (SIGINT_ONLYONCE == 1)
+		/* Re-enable signal from keyboard */
+		struct sigaction sa;
+		SETSIG(sa, SIGINT, signal_handler, 0);
+#endif
+		return runlevel;
+	}
 
 	/* Check if this is a runlevel a, b or c */
 	if (strchr("ABC", foo)) {
@@ -1708,6 +1833,8 @@
 	}
 
 	/* Store both the old and the new runlevel. */
+	wrote_utmp_rlevel = 0;
+	wrote_wtmp_rlevel = 0;
 	write_utmp_wtmp("runlevel", "~~", foo + 256*runlevel, RUN_LVL, "~");
 	thislevel = foo;
 	prevlevel = runlevel;
@@ -1722,6 +1849,7 @@
  *	longer than 5 minutes, or inittab was read again due
  *	to user interaction.
  */
+static
 void fail_check(void)
 {
 	CHILD	*ch;			/* Pointer to child structure */
@@ -1754,6 +1882,7 @@
 }
 
 /* Set all 'Fail' timers to 0 */
+static
 void fail_cancel(void)
 {
 	CHILD *ch;
@@ -1768,6 +1897,7 @@
 /*
  *	Start up powerfail entries.
  */
+static
 void do_power_fail(int pwrstat)
 {
 	CHILD *ch;
@@ -1801,6 +1931,7 @@
 /*
  *	Check for state-pipe presence
  */
+static
 int check_pipe(int fd)
 {
 	struct timeval	t;
@@ -1821,6 +1952,7 @@
 /*
  *	 Make a state-pipe.
  */
+static
 int make_pipe(int fd)
 {
 	int fds[2];
@@ -1838,6 +1970,7 @@
 /*
  *	Attempt to re-exec.
  */
+static
 void re_exec(void)
 {
 	CHILD		*ch;
@@ -1908,11 +2041,31 @@
 	initlog(L_CO, "Attempt to re-exec failed");
 }
 
+/*
+ *	Redo utmp/wtmp entries if required or requested
+ *	Check for written records and size of utmp
+ */
+static
+void redo_utmp_wtmp(void)
+{
+	struct stat ustat;
+	const int ret = stat(UTMP_FILE, &ustat);
 
+	if ((ret < 0) || (ustat.st_size == 0))
+		wrote_utmp_rlevel = wrote_utmp_reboot = 0;
+
+	if ((wrote_wtmp_reboot == 0) || (wrote_utmp_reboot == 0))
+		write_utmp_wtmp("reboot", "~~", 0, BOOT_TIME, "~");
+
+	if ((wrote_wtmp_rlevel == 0) || (wrote_wtmp_rlevel == 0))
+		write_utmp_wtmp("runlevel", "~~", thislevel + 256 * prevlevel, RUN_LVL, "~");
+}
+
 /*
  *	We got a change runlevel request through the
  *	init.fifo. Process it.
  */
+static
 void fifo_new_level(int level)
 {
 #if CHANGE_WAIT
@@ -1939,9 +2092,10 @@
 			if (oldlevel != 'S' && runlevel == 'S') console_stty();
 			if (runlevel == '6' || runlevel == '0' ||
 			    runlevel == '1') console_stty();
+			if (runlevel  > '1' && runlevel  < '6') redo_utmp_wtmp();
 			read_inittab();
 			fail_cancel();
-			setproctitle("init [%c]", runlevel);
+			setproctitle("init [%c]", (int)runlevel);
 		}
 	}
 }
@@ -1952,6 +2106,7 @@
  *	encoded as KEY=VAL\0KEY=VAL\0\0. With "=VAL" it means
  *	setenv, without it means unsetenv.
  */
+static
 void initcmd_setenv(char *data, int size)
 {
 	char		*env, *p, *e, *eq;
@@ -2009,6 +2164,7 @@
  *		the 2.2 kernel credential stuff to see who we're talking to.
  *	
  */
+static
 void check_init_fifo(void)
 {
   struct init_request	request;
@@ -2133,18 +2289,6 @@
 		case INIT_CMD_SETENV:
 			initcmd_setenv(request.i.data, sizeof(request.i.data));
 			break;
-		case INIT_CMD_CHANGECONS:
-			if (user_console) {
-				free(user_console);
-				user_console = NULL;
-			}
-			if (!request.i.bsd.reserved[0])
-				user_console = NULL;
-			else
-				user_console = strdup(request.i.bsd.reserved);
-			console_init();
-			quit = 1;
-			break;
 		default:
 			initlog(L_VB, "got unimplemented initrequest.");
 			break;
@@ -2163,6 +2307,7 @@
  *	This function is used in the transition
  *	sysinit (-> single user) boot -> multi-user.
  */
+static
 void boot_transitions()
 {
   CHILD		*ch;
@@ -2234,10 +2379,12 @@
 	}
 	if (loglevel > 0) {
 		initlog(L_VB, "Entering runlevel: %c", runlevel);
+		wrote_utmp_rlevel = 0;
+		wrote_wtmp_rlevel = 0;
 		write_utmp_wtmp("runlevel", "~~", runlevel + 256 * oldlevel, RUN_LVL, "~");
 		thislevel = runlevel;
 		prevlevel = oldlevel;
-		setproctitle("init [%c]", runlevel);
+		setproctitle("init [%c]", (int)runlevel);
 	}
   }
 }
@@ -2246,6 +2393,7 @@
  *	Init got hit by a signal. See which signal it is,
  *	and act accordingly.
  */
+static
 void process_signals()
 {
   CHILD		*ch;
@@ -2264,12 +2412,26 @@
 		pwrstat = c;
 		close(fd);
 		unlink(PWRSTAT);
-	}
+	} else if ((fd = open(PWRSTAT_OLD, O_RDONLY)) >= 0) {
+		/* Path changed 2010-03-20.  Look for the old path for a while. */
+		initlog(L_VB, "warning: found obsolete path %s, use %s instead",
+			PWRSTAT_OLD, PWRSTAT);
+		c = 0;
+		read(fd, &c, 1);
+		pwrstat = c;
+		close(fd);
+		unlink(PWRSTAT_OLD);
+        }
 	do_power_fail(pwrstat);
 	DELSET(got_signals, SIGPWR);
   }
 
   if (ISMEMBER(got_signals, SIGINT)) {
+#if defined(SIGINT_ONLYONCE) && (SIGINT_ONLYONCE == 1)
+	/* Ignore any further signal from keyboard */
+	struct sigaction sa;
+	SETSIG(sa, SIGINT, SIG_IGN, SA_RESTART);
+#endif
 	INITDBG(L_VB, "got SIGINT");
 	/* Tell ctrlaltdel entry to start up */
 	for(ch = family; ch; ch = ch->next)
@@ -2332,7 +2494,7 @@
 			    runlevel == '1') console_stty();
 			read_inittab();
 			fail_cancel();
-			setproctitle("init [%c]", runlevel);
+			setproctitle("init [%c]", (int)runlevel);
 			DELSET(got_signals, SIGHUP);
 		}
 	}
@@ -2351,12 +2513,12 @@
 /*
  *	The main loop
  */ 
-int init_main()
+static
+void init_main(void)
 {
   CHILD			*ch;
   struct sigaction	sa;
   sigset_t		sgt;
-  pid_t			rc;
   int			f, st;
 
   if (!reload) {
@@ -2412,6 +2574,7 @@
   console_init();
 
   if (!reload) {
+	int fd;
 
   	/* Close whatever files are open, and reset the console. */
 	close(0);
@@ -2429,7 +2592,8 @@
 	 *	Initialize /var/run/utmp (only works if /var is on
 	 *	root and mounted rw)
 	 */
-  	(void) close(open(UTMP_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0644));
+	if ((fd = open(UTMP_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0644)) >= 0)
+		close(fd);
 
   	/*
 	 *	Say hello to the world
@@ -2440,6 +2604,7 @@
 	 *	See if we have to start an emergency shell.
 	 */
 	if (emerg_shell) {
+		pid_t rc;
 		SETSIG(sa, SIGCHLD, SIG_DFL, SA_RESTART);
 		if (spawn(&ch_emerg, &f) > 0) {
 			while((rc = wait(&st)) != f)
@@ -2509,12 +2674,14 @@
 /*
  * Tell the user about the syntax we expect.
  */
+static
 void usage(char *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);
 }
 
+static
 int telinit(char *progname, int argc, char **argv)
 {
 #ifdef TELINIT_USES_INITLVL
@@ -2566,12 +2733,28 @@
 		request.sleeptime = sltime;
 	}
 
+	/* Change to the root directory. */
+	chdir("/");
+
 	/* Open the fifo and write a command. */
 	/* Make sure we don't hang on opening /dev/initctl */
 	SETSIG(sa, SIGALRM, signal_handler, 0);
 	alarm(3);
-	if ((fd = open(INIT_FIFO, O_WRONLY)) >= 0 &&
-	    write(fd, &request, sizeof(request)) == sizeof(request)) {
+	if ((fd = open(INIT_FIFO, O_WRONLY)) >= 0) {
+		ssize_t p = 0;
+		size_t s  = sizeof(request);
+		void *ptr = &request;
+
+		while (s > 0) {
+			p = write(fd, ptr, s);
+			if (p < 0) {
+				if (errno == EINTR || errno == EAGAIN)
+					continue;
+				break;
+			}
+			ptr += p;
+			s -= p;
+		}
 		close(fd);
 		alarm(0);
 		return 0;
@@ -2615,13 +2798,17 @@
 	char			*p;
 	int			f;
 	int			isinit;
+#ifdef WITH_SELINUX
 	int			enforce = 0;
+#endif
 
 	/* Get my own name */
 	if ((p = strrchr(argv[0], '/')) != NULL)
   		p++;
 	else
   		p = argv[0];
+
+	/* Common umask */
 	umask(022);
 
 	/* Quick check */
@@ -2635,9 +2822,10 @@
 	 */
 	isinit = (getpid() == 1);
 	for (f = 1; f < argc; f++) {
-		if (!strcmp(argv[f], "-i") || !strcmp(argv[f], "--init"))
+		if (!strcmp(argv[f], "-i") || !strcmp(argv[f], "--init")) {
 			isinit = 1;
 			break;
+		}
 	}
 	if (!isinit) exit(telinit(p, argc, argv));
 
@@ -2654,7 +2842,7 @@
 		for (f = 0; f < argc; f++)
 			maxproclen += strlen(argv[f]) + 1;
 		reload = 1;
-		setproctitle("init [%c]",runlevel);
+		setproctitle("init [%c]", (int)runlevel);
 
 		init_main();
 	}
@@ -2680,25 +2868,30 @@
 	}
 
 #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);
+	if (getenv("SELINUX_INIT") == NULL) {
+	  const int rc = mount("proc", "/proc", "proc", 0, 0);
+	  if (is_selinux_enabled() > 0) {
+	    putenv("SELINUX_INIT=YES");
+	    if (rc == 0) umount2("/proc", MNT_DETACH);
+	    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);
+	      }
 	    }
 	  }
+	  if (rc == 0) umount2("/proc", MNT_DETACH);
 	}
 #endif  
 	/* Start booting. */
 	argv0 = argv[0];
 	argv[1] = NULL;
 	setproctitle("init boot");
-	init_main(dfl_level);
+	init_main();
 
 	/*NOTREACHED*/
 	return 0;

Modified: sysvinit/branches/upstream/current/src/init.h
===================================================================
--- sysvinit/branches/upstream/current/src/init.h	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/init.h	2010-04-23 05:38:15 UTC (rev 1862)
@@ -4,6 +4,22 @@
  *
  * Version:	@(#)init.h  2.85-5  02-Jul-2003  miquels at cistron.nl
  *
+ * Copyright (C) 1998-2003 Miquel van Smoorenburg.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
  */
 
 /* Standard configuration */
@@ -37,6 +53,9 @@
 void set_term(int how);
 void print(char *fmt);
 
+/* from dowall.c */
+void wall(const char *text, int remote);
+
 #if DEBUG
 #  define INITDBG(level, fmt, args...) initlog(level, fmt, ##args)
 #else
@@ -99,6 +118,10 @@
 extern CHILD *family;
 extern int wrote_wtmp_reboot;
 extern int wrote_utmp_reboot;
+extern int wrote_wtmp_rlevel;
+extern int wrote_utmp_rlevel;
+extern char thislevel;
+extern char prevlevel;
 
 /* Tokens in state parser */
 #define C_VER		1
@@ -120,4 +143,6 @@
 #define D_WROTE_UTMP_REBOOT -7
 #define D_SLTIME       -8
 #define D_DIDBOOT      -9
+#define D_WROTE_WTMP_RLEVEL -16
+#define D_WROTE_UTMP_RLEVEL -17
 

Modified: sysvinit/branches/upstream/current/src/initreq.h
===================================================================
--- sysvinit/branches/upstream/current/src/initreq.h	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/initreq.h	2010-04-23 05:38:15 UTC (rev 1862)
@@ -3,11 +3,20 @@
  *
  *		Copyright (C) 1995-2004 Miquel van Smoorenburg
  *
- *		This library is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU Lesser General Public
- *		License as published by the Free Software Foundation; either
- *		version 2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
  *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
  * Version:     @(#)initreq.h  1.28  31-Mar-2004 MvS
  *
  */
@@ -32,8 +41,6 @@
 #define INIT_CMD_SETENV		6
 #define INIT_CMD_UNSETENV	7
 
-#define INIT_CMD_CHANGECONS	12345
-
 #ifdef MAXHOSTNAMELEN
 #  define INITRQ_HLEN	MAXHOSTNAMELEN
 #else

Modified: sysvinit/branches/upstream/current/src/killall5.c
===================================================================
--- sysvinit/branches/upstream/current/src/killall5.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/killall5.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -19,32 +19,48 @@
  *		- syslog() only if not a connected to controlling terminal
  *		- swapped out programs pids are caught now
  *
+ *		Werner Fink
+ *		- make omit dynamic
+ *		- provide '-n' to skip stat(2) syscall on network based FS
+ *
  *		This file is part of the sysvinit suite,
- *		Copyright 1991-2004 Miquel van Smoorenburg.
+ *		Copyright (C) 1991-2004 Miquel van Smoorenburg.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
+ *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
-#include <sys/types.h>
+#include <dirent.h>
+#include <errno.h>
+#include <getopt.h>
+#include <mntent.h>
+#include <stdarg.h>
 #include <stdio.h>
-#include <string.h>
-#include <errno.h>
 #include <stdlib.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
 #include <signal.h>
-#include <dirent.h>
+#include <string.h>
 #include <syslog.h>
-#include <getopt.h>
-#include <stdarg.h>
 #include <sys/mman.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
 
 char *Version = "@(#)killall5 2.86 31-Jul-2004 miquels at cistron.nl";
 
 #define STATNAMELEN	15
+#define DO_NETFS 2
 #define DO_STAT 1
 #define NO_STAT 0
 
@@ -58,8 +74,9 @@
 	ino_t ino;		/* Inode number			  */
 	dev_t dev;		/* Device it is on		  */
 	pid_t pid;		/* Process ID.			  */
-	int sid;		/* Session ID.			  */
-	int kernel;		/* Kernel thread or zombie.	  */
+	pid_t sid;		/* Session ID.			  */
+	char kernel;		/* Kernel thread or zombie.	  */
+	char nfs;		/* Name found on network FS.	  */
 	struct proc *next;	/* Pointer to next struct. 	  */
 } PROC;
 
@@ -76,9 +93,38 @@
 	PIDQ		*next;
 } PIDQ_HEAD;
 
+typedef struct _s_omit {
+	struct _s_omit *next;
+	struct _s_omit *prev;
+	pid_t pid;
+} OMIT;
+
+typedef struct _s_shadow
+{
+	struct _s_shadow *next;
+	struct _s_shadow *prev;
+	size_t nlen;
+	char * name;
+} SHADOW;
+
+typedef struct _s_nfs
+{
+	struct _s_nfs *next;	/* Pointer to next struct. */
+	struct _s_nfs *prev;	/* Pointer to previous st. */
+	SHADOW *shadow;		/* Pointer to shadows      */
+	char * name;
+	size_t nlen;
+} NFS;
+
 /* List of processes. */
 PROC *plist;
 
+/* List of processes to omit. */
+OMIT *omit;
+
+/* List of NFS mountes partitions. */
+NFS *nlist;
+
 /* Did we stop all processes ? */
 int sent_sigstop;
 
@@ -90,10 +136,23 @@
 #endif
 void nsyslog(int pri, char *fmt, ...);
 
+#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
+# ifndef  inline
+#  define inline	__inline__
+# endif
+# ifndef  restrict
+#  define restrict	__restrict__
+# endif
+#endif
+#define alignof(type)	((sizeof(type)+(sizeof(void*)-1)) & ~(sizeof(void*)-1))
+
 /*
  *	Malloc space, barf if out of memory.
  */
-void *xmalloc(int bytes)
+#ifdef __GNUC__
+static void *xmalloc(size_t) __attribute__ ((__malloc__));
+#endif
+static void *xmalloc(size_t bytes)
 {
 	void *p;
 
@@ -105,6 +164,18 @@
 	return p;
 }
 
+#ifdef __GNUC__
+static inline void xmemalign(void **, size_t, size_t) __attribute__ ((__nonnull__ (1)));
+#endif
+static inline void xmemalign(void **memptr, size_t alignment, size_t size)
+{
+	if ((posix_memalign(memptr, alignment, size)) < 0) {
+		if (sent_sigstop) kill(-1, SIGCONT);
+		nsyslog(LOG_ERR, "out of memory");
+		exit(1);
+	}
+}
+
 /*
  *	See if the proc filesystem is there. Mount if needed.
  */
@@ -155,6 +226,212 @@
 	return did_mount;
 }
 
+static inline int isnetfs(const char * type)
+{
+	static const char* netfs[] = {"nfs", "nfs4", "smbfs", "cifs", "afs", "ncpfs", (char*)0};
+	int n;
+	for (n = 0; netfs[n]; n++) {
+		if (!strcasecmp(netfs[n], type))
+			return 1;
+	}
+	return 0;
+}
+
+/*
+ *     Remember all NFS typed partitions.
+ */
+void init_nfs(void)
+{
+        struct stat st;
+        struct mntent * ent;
+	FILE * mnt;
+
+	nlist = (NFS*)0;
+
+	if (stat("/proc/version", &st) < 0)
+		return;
+	if ((mnt = setmntent("/proc/mounts", "r")) == (FILE*)0)
+		return;
+
+	while ((ent = getmntent(mnt))) {
+		if (isnetfs(ent->mnt_type)) {
+			size_t nlen = strlen(ent->mnt_dir);
+			NFS *restrict p;
+			xmemalign((void*)&p, sizeof(void*), alignof(NFS)+(nlen+1));
+			p->name = ((char*)p)+alignof(NFS);
+			p->nlen = nlen;
+			p->shadow = (SHADOW*)0;
+
+			strcpy(p->name, ent->mnt_dir);
+			if (nlist)
+				nlist->prev = p;
+			p->next = nlist;
+			p->prev = (NFS*)0;
+			nlist = p;
+		}
+	}
+	endmntent(mnt);
+
+	if ((mnt = setmntent("/proc/mounts", "r")) == (FILE*)0)
+		return;
+
+	while ((ent = getmntent(mnt))) {
+		NFS *p;
+
+		for (p = nlist; p; p = p->next) {
+			SHADOW * restrict s;
+			size_t nlen;
+
+			if (strcmp(ent->mnt_dir, p->name) == 0)
+				continue;
+			if (strncmp(ent->mnt_dir, p->name, p->nlen) != 0)
+				continue;
+
+			nlen = strlen(ent->mnt_dir);
+			xmemalign((void*)&s, sizeof(void*), alignof(SHADOW)+(nlen+1));
+			s->name = ((char*)s)+alignof(SHADOW);
+			s->nlen = nlen;
+
+			strcpy(s->name, ent->mnt_dir);
+			if (p->shadow)
+			    p->shadow->prev = s;
+			s->next = p->shadow;
+			s->prev = (SHADOW*)0;
+			p->shadow = s;
+		}
+	}
+	endmntent(mnt);
+}
+
+static void clear_shadow(SHADOW *restrict shadow)
+{
+	SHADOW *s, *n, *l;
+
+	n = shadow;
+	l = (SHADOW*)0;
+	for (s = shadow; n; s = n) {
+		l = s->prev;
+		n = s->next;
+		if (s == shadow) {
+			if (n) n->prev = (SHADOW*)0;
+			shadow = n;
+		} else if (l) {
+			if (n) n->prev = l;
+			l->next = n;
+		}
+		free(s);
+	}
+}
+
+static void clear_mnt(void)
+{
+	NFS *p, *n, *l;
+
+	n = nlist;
+	l = (NFS*)0;
+	for (p = nlist; n; p = n) {
+		l = p->prev;
+		n = p->next;
+		if (p == nlist) {
+			if (n) n->prev = (NFS*)0;
+			nlist = n;
+		} else if (l) {
+			if (n) n->prev = l;
+			l->next = n;
+		}
+		if (p->shadow)
+			clear_shadow(p->shadow);
+		free(p);
+	}
+}
+
+/*
+ *     Check if path is ia shadow off a NFS partition.
+ */
+static int shadow(SHADOW *restrict this, const char *restrict name, const size_t nlen)
+{
+	SHADOW *s;
+
+	if (!this)
+		goto out;
+	for (s = this; s; s = s->next) {
+		if (nlen < s->nlen)
+			continue;
+		if (name[s->nlen] != '\0' && name[s->nlen] != '/')
+			continue;
+		if (strncmp(name, s->name, s->nlen) == 0)
+			return 1;
+	}
+out:
+	return 0;
+}
+
+/*
+ *     Check path is located on a network based partition.
+ */
+int check4nfs(const char * path, char * real)
+{
+	char buf[PATH_MAX+1];
+	const char *curr;
+	int deep = MAXSYMLINKS;
+
+	if (!nlist) return 0;
+
+	curr = path;
+	do {
+		const char *prev;
+		int len;
+
+		if ((prev = strdupa(curr)) == NULL) {
+			nsyslog(LOG_ERR, "strdupa(): %s\n", strerror(errno));
+			return 0;
+		}
+
+		errno = 0;
+		if ((len = readlink(curr, buf, PATH_MAX)) < 0)
+			break;
+		buf[len] = '\0';
+
+		if (buf[0] != '/') {
+			const char *slash;
+
+			if ((slash = strrchr(prev, '/'))) {
+				size_t off = slash - prev + 1;
+
+				if (off + len > PATH_MAX)
+					len = PATH_MAX - off;
+
+				memmove(&buf[off], &buf[0], len + 1);
+				memcpy(&buf[0], prev, off);
+			}
+		}
+		curr = &buf[0];
+
+		if (deep-- <= 0) return 0;
+
+	} while (1);
+
+	if (real) strcpy(real, curr);
+
+	if (errno == EINVAL) {
+		const size_t nlen = strlen(curr);
+		NFS *p;
+		for (p = nlist; p; p = p->next) {
+			if (nlen < p->nlen)
+				continue;
+			if (curr[p->nlen] != '\0' && curr[p->nlen] != '/')
+				continue;
+			if (!strncmp(curr, p->name, p->nlen)) {
+				if (shadow(p->shadow, curr, nlen))
+					continue;
+				return 1;
+			}
+		}
+	}
+
+	return 0;
+}
+
 int readarg(FILE *fp, char *buf, int sz)
 {
 	int		c = 0, f = 0;
@@ -177,8 +454,8 @@
 	PROC		*p, *n;
 	struct dirent	*d;
 	struct stat	st;
-	char		path[256];
-	char		buf[256];
+	char		path[PATH_MAX+1];
+	char		buf[PATH_MAX+1];
 	char		*s, *q;
 	unsigned long	startcode, endcode;
 	int		pid, f;
@@ -199,6 +476,7 @@
 		n = p->next;
 		if (p->argv0) free(p->argv0);
 		if (p->argv1) free(p->argv1);
+		if (p->statname) free(p->statname);
 		free(p);
 	}
 	plist = NULL;
@@ -233,6 +511,9 @@
 					nsyslog(LOG_ERR,
 					"can't get program name from /proc/%s\n",
 						path);
+					if (p->argv0) free(p->argv0);
+					if (p->argv1) free(p->argv1);
+					if (p->statname) free(p->statname);
 					free(p);
 					continue;
 				}
@@ -256,6 +537,9 @@
 				p->sid = 0;
 				nsyslog(LOG_ERR, "can't read sid from %s\n",
 					path);
+				if (p->argv0) free(p->argv0);
+				if (p->argv1) free(p->argv1);
+				if (p->statname) free(p->statname);
 				free(p);
 				continue;
 			}
@@ -264,6 +548,9 @@
 			fclose(fp);
 		} else {
 			/* Process disappeared.. */
+			if (p->argv0) free(p->argv0);
+			if (p->argv1) free(p->argv1);
+			if (p->statname) free(p->statname);
 			free(p);
 			continue;
 		}
@@ -308,15 +595,29 @@
 
 		} else {
 			/* Process disappeared.. */
+			if (p->argv0) free(p->argv0);
+			if (p->argv1) free(p->argv1);
+			if (p->statname) free(p->statname);
 			free(p);
 			continue;
 		}
 
 		/* Try to stat the executable. */
 		snprintf(path, sizeof(path), "/proc/%s/exe", d->d_name);
-		if (do_stat && stat(path, &st) == 0) {
+
+		p->nfs = 0;
+
+		switch (do_stat) {
+		case DO_NETFS:
+			if ((p->nfs = check4nfs(path, buf)))
+				break;
+		case DO_STAT:
+			if (stat(path, &st) != 0)
+				break;
 			p->dev = st.st_dev;
 			p->ino = st.st_ino;
+		default:
+			break;
 		}
 
 		/* Link it into the list. */
@@ -382,13 +683,29 @@
 	PIDQ_HEAD	*q;
 	struct stat	st;
 	char		*s;
+	int		nfs = 0;
 	int		dostat = 0;
 	int		foundone = 0;
 	int		ok = 0;
+	char		real[PATH_MAX+1];
 
 	if (! prog)
 		return NULL;
 
+	/* Try to stat the executable. */
+	if (prog[0] == '/') {
+		memset(&real[0], 0, sizeof(real));
+
+		if (check4nfs(prog, real))
+			nfs++;
+
+		if (real[0] != '\0')
+			prog = &real[0];	/* Binary located on network FS. */
+
+		if ((nfs == 0) && (stat(prog, &st) == 0))
+			dostat++;		/* Binary located on a local FS. */
+	}
+
 	/* Get basename of program. */
 	if ((s = strrchr(prog, '/')) == NULL)
 		s = prog;
@@ -401,13 +718,11 @@
 	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) {
+	if (dostat && !nfs) {
 		for (p = plist; p; p = p->next) {
+			if (p->nfs)
+				continue;
 			if (p->dev == st.st_dev && p->ino == st.st_ino) {
 				add_pid_to_q(q, p);
 				foundone++;
@@ -415,6 +730,26 @@
 		}
 	}
 
+	/* Second try to find a match based on full path name on
+	 * network FS located binaries */
+	if (!foundone && nfs) {
+		for (p = plist; p; p = p->next) {
+			char exe [PATH_MAX+1];
+			char path[PATH_MAX+1];
+			int len;
+			if (!p->nfs)
+				continue;
+			snprintf(exe, sizeof(exe), "/proc/%d/exe", p->pid);
+			if ((len = readlink(exe, path, PATH_MAX)) < 0)
+				    continue;
+			path[len] = '\0';
+			if (strcmp(prog, path) != 0)
+				continue;
+			add_pid_to_q(q, p);
+			foundone++;
+		}
+	}
+
 	/* If we didn't find a match based on dev/ino, try the name. */
 	if (!foundone) for (p = plist; p; p = p->next) {
 		ok = 0;
@@ -460,10 +795,22 @@
 		     strchr(p->argv0, ' '))) {
 			ok |= (strcmp(p->statname, s) == 0);
 		}
+
+		/*
+		 *	if we have a `-' as the first character, process
+		 *	probably used as a login shell
+		 */
+		if (strlen(s) <= STATNAMELEN &&
+		    p->argv1 == NULL &&
+		    (p->argv0 != NULL &&
+		     p->argv0[0] == '-')) {
+			ok |= (strcmp(p->statname, s) == 0);
+		}
+
 		if (ok) add_pid_to_q(q, p);
 	}
 
-	 return q;
+	return q;
 }
 
 /* Give usage message and exit. */
@@ -497,9 +844,8 @@
 
 #define PIDOF_SINGLE	0x01
 #define PIDOF_OMIT	0x02
+#define PIDOF_NETFS	0x04
 
-#define PIDOF_OMITSZ	5
-
 /*
  *	Pidof functionality.
  */
@@ -507,19 +853,22 @@
 {
 	PIDQ_HEAD	*q;
 	PROC		*p;
-	pid_t		opid[PIDOF_OMITSZ], spid;
+	char		*token, *here;
 	int		f;
 	int		first = 1;
-	int		i, oind, opt, flags = 0;
+	int		opt, flags = 0;
 	int		chroot_check = 0;
 	struct stat	st;
 	char		tmp[512];
 
-	for (oind = PIDOF_OMITSZ-1; oind > 0; oind--)
-		opid[oind] = 0;
+	omit = (OMIT*)0;
+	nlist = (NFS*)0;
 	opterr = 0;
 
-	while ((opt = getopt(argc,argv,"hco:sx")) != EOF) switch (opt) {
+	if ((token = getenv("PIDOF_NETFS")) && (strcmp(token,"no") != 0))
+		flags |= PIDOF_NETFS;
+
+	while ((opt = getopt(argc,argv,"hco:sxn")) != EOF) switch (opt) {
 		case '?':
 			nsyslog(LOG_ERR,"invalid options on command line!\n");
 			closelog();
@@ -528,22 +877,28 @@
 			if (geteuid() == 0) chroot_check = 1;
 			break;
 		case 'o':
-			if (oind >= PIDOF_OMITSZ -1) {
-				nsyslog(LOG_ERR,"omit pid buffer size %d "
-					"exceeded!\n", PIDOF_OMITSZ);
-				closelog();
-				exit(1);
+			here = optarg;
+			while ((token = strsep(&here, ",;:"))) {
+				OMIT *restrict optr;
+				pid_t opid;
+
+				if (strcmp("%PPID", token) == 0)
+					opid = getppid();
+				else
+					opid = (pid_t)atoi(token);
+
+				if (opid < 1) {
+					nsyslog(LOG_ERR,
+						"illegal omit pid value "
+						"(%s)!\n", token);
+					continue;
+				}
+				xmemalign((void*)&optr, sizeof(void*), alignof(OMIT));
+				optr->next = omit;
+				optr->prev = (OMIT*)0;
+				optr->pid  = opid;
+				omit = optr;
 			}
-			if (strcmp("%PPID",optarg) == 0)
-				opid[oind] = getppid();
-			else if ((opid[oind] = atoi(optarg)) < 1) {
-				nsyslog(LOG_ERR,
-					"illegal omit pid value (%s)!\n",
-					optarg);
-				closelog();
-				exit(1);
-			}
-			oind++;
 			flags |= PIDOF_OMIT;
 			break;
 		case 's':
@@ -552,6 +907,9 @@
 		case 'x':
 			scripts_too++;
 			break;
+		case 'n':
+			flags |= PIDOF_NETFS;
+			break;
 		default:
 			/* Nothing */
 			break;
@@ -569,21 +927,28 @@
 		}
 	}
 
+	if (flags & PIDOF_NETFS)
+		init_nfs();		/* Which network based FS are online? */
+
 	/* Print out process-ID's one by one. */
-	readproc(DO_STAT);
+	readproc((flags & PIDOF_NETFS) ? DO_NETFS : DO_STAT);
+
 	for(f = 0; f < argc; f++) {
 		if ((q = pidof(argv[f])) != NULL) {
-			spid = 0;
+			pid_t spid = 0;
 			while ((p = get_next_from_pid_q(q))) {
-				if (flags & PIDOF_OMIT) {
-					for (i = 0; i < oind; i++)
-						if (opid[i] == p->pid)
+				if ((flags & PIDOF_OMIT) && omit) {
+					OMIT * optr;
+					for (optr = omit; optr; optr = optr->next) {
+						if (optr->pid == p->pid)
 							break;
+					}
+
 					/*
 					 *	On a match, continue with
 					 *	the for loop above.
 					 */
-					if (i < oind)
+					if (optr)
 						continue;
 				}
 				if (flags & PIDOF_SINGLE) {
@@ -611,22 +976,20 @@
 	}
 	if (!first)
 		printf("\n");
+
+	clear_mnt();
+
 	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;
+	int		c;
 
 	/* return non-zero if no process was killed */
 	int		retval = 2;
@@ -645,30 +1008,34 @@
 		return main_pidof(argc, argv);
 
 	/* Right, so we are "killall". */
-	for (oind = KILLALL_OMITSZ-1; oind > 0; oind--)
-		opid[oind] = 0;
+	omit = (OMIT*)0;
 
 	if (argc > 1) {
-		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);
+		for (c = 1; c < argc; c++) {
+			if (argv[c][0] == '-') (argv[c])++;
+			if (argv[c][0] == 'o') {
+				char * token, * here;
+
+				if (++c >= argc)
+					usage();
+
+				here = argv[c];
+				while ((token = strsep(&here, ",;:"))) {
+					OMIT *restrict optr;
+					pid_t opid = (pid_t)atoi(token);
+
+					if (opid < 1) {
+						nsyslog(LOG_ERR,
+							"illegal omit pid value "
+							"(%s)!\n", token);
+						continue;
+					}
+					xmemalign((void*)&optr, sizeof(void*), alignof(OMIT));
+					optr->next = omit;
+					optr->prev = (OMIT*)0;
+					optr->pid  = opid;
+					omit = optr;
 				}
-				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();
@@ -707,14 +1074,19 @@
 	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)
+			OMIT * optr;
+			for (optr = omit; optr; optr = optr->next) {
+				if (optr->pid == p->pid)
 					break;
+			}
+
 			/* On a match, continue with the for loop above. */
-			if (i < oind)
+			if (optr)
 				continue;
 		}
+
 		kill(p->pid, sig);
 		retval = 0;
 	}

Modified: sysvinit/branches/upstream/current/src/last.c
===================================================================
--- sysvinit/branches/upstream/current/src/last.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/last.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -9,12 +9,21 @@
  * Version:	@(#)last  2.85  30-Jul-2004  miquels at cistron.nl
  *
  *		This file is part of the sysvinit suite,
- *		Copyright 1991-2004 Miquel van Smoorenburg.
+ *		Copyright (C) 1991-2004 Miquel van Smoorenburg.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
+ *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <sys/types.h>
@@ -71,6 +80,8 @@
 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 name_len = 8;	/* Default print 8 characters of name */
+int domain_len = 16;	/* Default print 16 characters of domain */
 int oldfmt = 0;		/* Use old libc5 format? */
 char **show = NULL;	/* What do they want us to show */
 char *ufile;		/* Filename of this file */
@@ -322,7 +333,7 @@
 	 *
 	 *	Ugly.
 	 */
-	if (a[0] == 0 && a[1] == 0 && a[2] == htonl (0xffff))
+	if (a[0] == 0 && a[1] == 0 && a[2] == (int32_t)htonl (0xffff))
 		mapped = 1;
 	topnibble = ntohl((unsigned int)a[0]) >> 28;
 
@@ -359,7 +370,7 @@
 	char		logintime[32];
 	char		logouttime[32];
 	char		length[32];
-	char		final[128];
+	char		final[512];
 	char		utline[UT_LINESIZE+1];
 	char		domain[256];
 	char		*s, **walk;
@@ -453,7 +464,7 @@
 		r = dns_lookup(domain, sizeof(domain), useip, p->ut_addr_v6);
 	if (r < 0) {
 		len = UT_HOSTSIZE;
-		if (len >= sizeof(domain)) len = sizeof(domain) - 1;
+		if (len >= (int)sizeof(domain)) len = sizeof(domain) - 1;
 		domain[0] = 0;
 		strncat(domain, p->ut_host, len);
 	}
@@ -467,28 +478,34 @@
 		     strcmp(s + 1, domainname) == 0) *s = 0;
 #endif
 		if (!altlist) {
-			snprintf(final, sizeof(final),
+			len = snprintf(final, sizeof(final),
 				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);
+				"%-8.*s %-12.12s %-16.*s %-24.24s %-26.26s %-12.12s\n" :
+				"%-8.*s %-12.12s %-16.*s %-16.16s %-7.7s %-12.12s\n",
+				name_len, p->ut_name, utline,
+				domain_len, domain, logintime, logouttime, length);
 		} else {
-			snprintf(final, sizeof(final), 
+			len = 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,
+				"%-8.*s %-12.12s %-24.24s %-26.26s %-12.12s %s\n" :
+				"%-8.*s %-12.12s %-16.16s %-7.7s %-12.12s %s\n",
+				name_len, p->ut_name, utline,
 				logintime, logouttime, length, domain);
 		}
 	} else
-		snprintf(final, sizeof(final),
+		len = 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,
+			"%-8.*s %-12.12s %-24.24s %-26.26s %-12.12s\n" :
+			"%-8.*s %-12.12s %-16.16s %-7.7s %-12.12s\n",
+			name_len, p->ut_name, utline,
 			logintime, logouttime, length);
 
+#if defined(__GLIBC__)
+#  if (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
+	final[sizeof(final)-1] = '\0';
+#  endif
+#endif
+
 	/*
 	 *	Print out "final" string safely.
 	 */
@@ -499,6 +516,9 @@
 			putchar('*');
 	}
 
+	if (len < 0 || (size_t)len >= sizeof(final))
+		putchar('\n');
+
 	recsdone++;
 	if (maxrecs && recsdone >= maxrecs)
 		return 1;
@@ -514,7 +534,7 @@
 {
 	fprintf(stderr, "Usage: %s [-num | -n num] [-f file] "
 			"[-t YYYYMMDDHHMMSS] "
-			"[-R] [-adioxF] [username..] [tty..]\n", s);
+			"[-R] [-adioxFw] [username..] [tty..]\n", s);
 	exit(1);
 }
 
@@ -585,7 +605,7 @@
   progname = mybasename(argv[0]);
 
   /* Process the arguments. */
-  while((c = getopt(argc, argv, "f:n:RxadFiot:0123456789")) != EOF)
+  while((c = getopt(argc, argv, "f:n:RxadFiot:0123456789w")) != EOF)
     switch(c) {
 	case 'R':
 		showhost = 0;
@@ -626,6 +646,12 @@
 			usage(progname);
 		}
 		break;
+	case 'w':
+		if (UT_NAMESIZE > name_len)
+			name_len = UT_NAMESIZE;
+		if (UT_HOSTSIZE > domain_len)
+			domain_len = UT_HOSTSIZE;
+		break;
 	case '0': case '1': case '2': case '3': case '4':
 	case '5': case '6': case '7': case '8': case '9':
 		maxrecs = 10*maxrecs + c - '0';

Modified: sysvinit/branches/upstream/current/src/mesg.c
===================================================================
--- sysvinit/branches/upstream/current/src/mesg.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/mesg.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -6,12 +6,21 @@
  *		Without arguments prints out the current settings.
  *
  *		This file is part of the sysvinit suite,
- *		Copyright 1991-2001 Miquel van Smoorenburg.
+ *		Copyright (C) 1991-2001 Miquel van Smoorenburg.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
+ *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include <sys/types.h>
 #include <sys/stat.h>

Modified: sysvinit/branches/upstream/current/src/mountpoint.c
===================================================================
--- sysvinit/branches/upstream/current/src/mountpoint.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/mountpoint.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -6,12 +6,21 @@
  * Version:	@(#)mountpoint  2.85-12  17-Mar-2004	 miquels at cistron.nl
  *
  *		This file is part of the sysvinit suite,
- *		Copyright 1991-2004 Miquel van Smoorenburg.
+ *		Copyright (C) 1991-2004 Miquel van Smoorenburg.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
+ *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <sys/stat.h>

Modified: sysvinit/branches/upstream/current/src/oldutmp.h
===================================================================
--- sysvinit/branches/upstream/current/src/oldutmp.h	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/oldutmp.h	2010-04-23 05:38:15 UTC (rev 1862)
@@ -3,6 +3,22 @@
  *
  * Version:	@(#)oldutmp.h  1.00  29-Mar-1998  miquels at cistron.nl
  *
+ * Copyright (C) 1991-2000 Miquel van Smoorenburg.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
  */
 #ifndef OLD_UTMP_H
 #define OLD_UTMP_H

Modified: sysvinit/branches/upstream/current/src/paths.h
===================================================================
--- sysvinit/branches/upstream/current/src/paths.h	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/paths.h	2010-04-23 05:38:15 UTC (rev 1862)
@@ -6,12 +6,21 @@
  * Author:	Miquel van Smoorenburg, <miquels at cistron.nl>
  *
  *		This file is part of the sysvinit suite,
- *		Copyright 1991-2001 Miquel van Smoorenburg.
+ *		Copyright (C) 1991-2001 Miquel van Smoorenburg.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
+ *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #define VT_MASTER	"/dev/tty0"		/* Virtual console master */
 #define CONSOLE		"/dev/console"		/* Logical system console */
@@ -26,7 +35,8 @@
 #define SHELL		"/bin/sh"		/* Default shell */
 #define SULOGIN		"/sbin/sulogin"		/* Sulogin */
 #define INITSCRIPT	"/etc/initscript"	/* Initscript. */
-#define PWRSTAT		"/etc/powerstatus"	/* COMPAT: SIGPWR reason (OK/BAD) */
+#define PWRSTAT_OLD	"/etc/powerstatus"	/* COMPAT: SIGPWR reason (OK/BAD) */
+#define PWRSTAT		"/var/run/powerstatus"	/* COMPAT: SIGPWR reason (OK/BAD) */
 
 #if 0
 #define INITLVL		"/etc/initrunlvl"	/* COMPAT: New runlevel */

Modified: sysvinit/branches/upstream/current/src/reboot.h
===================================================================
--- sysvinit/branches/upstream/current/src/reboot.h	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/reboot.h	2010-04-23 05:38:15 UTC (rev 1862)
@@ -4,6 +4,21 @@
  *
  * Version:	@(#)reboot.h  2.85-17  04-Jun-2004  miquels at cistron.nl
  *
+ * Copyright (C) (C) 1991-2004 Miquel van Smoorenburg.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <sys/reboot.h>

Modified: sysvinit/branches/upstream/current/src/runlevel.c
===================================================================
--- sysvinit/branches/upstream/current/src/runlevel.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/runlevel.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -4,12 +4,21 @@
  * Version:	@(#)runlevel  1.20  16-Apr-1997  MvS
  *
  *		This file is part of the sysvinit suite,
- *		Copyright 1991-1997 Miquel van Smoorenburg.
+ *		Copyright (C) 1991-1997 Miquel van Smoorenburg.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
+ *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <stdio.h>

Modified: sysvinit/branches/upstream/current/src/set.h
===================================================================
--- sysvinit/branches/upstream/current/src/set.h	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/set.h	2010-04-23 05:38:15 UTC (rev 1862)
@@ -2,7 +2,25 @@
  * set.h	Macros that look like sigaddset et al. but
  *		aren't. They are used to manipulate bits in
  *		an integer, to do our signal bookeeping.
+ *
+ * Copyright (C) 2005 Miquel van Smoorenburg.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
  */
+
 #define ISMEMBER(set, val) ((set) & (1 << (val)))
 #define DELSET(set, val)   ((set) &= ~(1 << (val)))
 #define ADDSET(set, val)   ((set) |=  (1 << (val)))

Modified: sysvinit/branches/upstream/current/src/shutdown.c
===================================================================
--- sysvinit/branches/upstream/current/src/shutdown.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/shutdown.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -16,18 +16,34 @@
  * Version:	@(#)shutdown  2.86-1  31-Jul-2004  miquels at cistron.nl
  *
  *		This file is part of the sysvinit suite,
- *		Copyright 1991-2004 Miquel van Smoorenburg.
+ *		Copyright (C) 1991-2004 Miquel van Smoorenburg.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
+ *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE	/* otherwise `extern char **environ' is missed */
+#endif
+#ifndef ACCTON_OFF
+# define ACCTON_OFF	0
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <time.h>
 #include <string.h>
+#include <errno.h>
 #include <unistd.h>
 #include <errno.h>
 #include <stdlib.h>
@@ -40,7 +56,9 @@
 #include "paths.h"
 #include "reboot.h"
 #include "initreq.h"
+#include "init.h"
 
+
 char *Version = "@(#) shutdown 2.86-1 31-Jul-2004 miquels at cistron.nl";
 
 #define MESSAGELEN	256
@@ -60,12 +78,10 @@
 	"HOME=/",
 	"PATH=/bin:/usr/bin:/sbin:/usr/sbin",
 	"TERM=dumb",
+	"SHELL=/bin/sh",
 	NULL,
 };
 
-/* From "wall.c" */
-extern void wall(char *, int, int);
-
 /* From "utmp.c" */
 extern void write_wtmp(char *user, char *id, int pid, int type, char *line);
 
@@ -86,7 +102,12 @@
 /*
  *	Break off an already running shutdown.
  */
+# ifdef __GNUC__
+void stopit(int sig __attribute__((unused)))
+# else
 void stopit(int sig)
+# endif
+
 {
 	unlink(NOLOGIN);
 	unlink(FASTBOOT);
@@ -102,7 +123,7 @@
 void usage(void)
 {
 	fprintf(stderr,
-	"Usage:\t  shutdown [-akrhHPfnc] [-t secs] time [warning message]\n"
+	"Usage:\t  shutdown [-akrhPHfFnc] [-t sec] time [warning message]\n"
 	"\t\t  -a:      use /etc/shutdown.allow\n"
 	"\t\t  -k:      don't really shutdown, only warn.\n"
 	"\t\t  -r:      reboot after shutdown.\n"
@@ -141,7 +162,7 @@
 	nl = strlen(name);
 	vl = value ? strlen(value) : 0;
 
-	if (nl + vl + 3 >= sizeof(request.i.data))
+	if (nl + vl + 3 >= (int)sizeof(request.i.data))
 		return -1;
 
 	memcpy(request.i.data, name, nl);
@@ -158,22 +179,34 @@
 	sa.sa_handler = alrm_handler;
 	sigaction(SIGALRM, &sa, NULL);
 	got_alrm = 0;
-        alarm(3);
-        if ((fd = open(INIT_FIFO, O_WRONLY)) >= 0 &&
-            write(fd, &request, sizeof(request)) == sizeof(request)) {
-                close(fd);
-                alarm(0);
-                return 0;
-        }
+	alarm(3);
+	if ((fd = open(INIT_FIFO, O_WRONLY)) >= 0) {
+		ssize_t p = 0;
+		size_t s  = sizeof(request);
+		void *ptr = &request;
+		while (s > 0) {
+			p = write(fd, ptr, s);
+			if (p < 0) {
+				if (errno == EINTR || errno == EAGAIN)
+					continue;
+				break;
+			}
+			ptr += p;
+			s -= p;
+		}
+		close(fd);
+		alarm(0);
+		return 0;
+	}
                                                                                 
-        fprintf(stderr, "shutdown: ");
-        if (got_alrm) {
-                fprintf(stderr, "timeout opening/writing control channel %s\n",
-                        INIT_FIFO);
-        } else {
-                perror(INIT_FIFO);
-        }
-        return -1;
+	fprintf(stderr, "shutdown: ");
+	if (got_alrm) {
+		fprintf(stderr, "timeout opening/writing control channel %s\n",
+			INIT_FIFO);
+	} else {
+		perror(INIT_FIFO);
+	}
+	return -1;
 }
 
 
@@ -197,7 +230,7 @@
   		snprintf(buf + len, sizeof(buf) - len,
 			"\rThe system is going DOWN %s in %d minute%s!\r\n",
 				newstate, mins, mins == 1 ? "" : "s");
-	wall(buf, 1, 0);
+	wall(buf, 0);
 }
 
 /*
@@ -304,7 +337,7 @@
 
 	/* First idle init. */
 	if (kill(1, SIGTSTP) < 0) {
-		fprintf(stderr, "shutdown: can't idle init.\r\n");
+		fprintf(stderr, "shutdown: can't idle init: %s.\r\n", strerror(errno));
 		exit(1);
 	}
 
@@ -331,7 +364,17 @@
 	write_wtmp("shutdown", "~~", 0, RUN_LVL, "~~");
 
 	/* This is for those who have quota installed. */
+#if defined(ACCTON_OFF)
+# if (ACCTON_OFF > 1) && (_BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500))
+	/* This is an alternative way to disable accounting, saving a fork() */
+	if (acct(NULL))
+		fprintf(stderr, "shutdown: can not stop process accounting: %s.\r\n", strerror(errno));
+# elif (ACCTON_OFF > 0)
+	spawn(1, "accton", "off", NULL);
+# else
 	spawn(1, "accton", NULL);
+# endif
+#endif
 	spawn(1, "quotaoff", "-a", NULL);
 
 	sync();
@@ -460,6 +503,7 @@
 
 	if (getuid() != 0) {
   		fprintf(stderr, "shutdown: you must be root to do that!\n");
+		usage();
   		exit(1);
 	}
 	strcpy(down_level, "1");
@@ -609,7 +653,7 @@
 			fprintf(stderr, "shutdown: not running.\n");
 			exit(1);
 		}
-		if (message[0]) wall(message, 1, 0);
+		if (message[0]) wall(message, 0);
 		exit(0);
 	}
   

Modified: sysvinit/branches/upstream/current/src/sulogin.c
===================================================================
--- sysvinit/branches/upstream/current/src/sulogin.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/sulogin.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -10,6 +10,22 @@
  *
  * Version:	@(#)sulogin 2.85-3 23-Apr-2003 miquels at cistron.nl
  *
+ * Copyright (C) 1998-2003 Miquel van Smoorenburg.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
  */
 
 #include <sys/types.h>
@@ -23,6 +39,7 @@
 #include <pwd.h>
 #include <shadow.h>
 #include <termios.h>
+#include <sys/ttydefaults.h>
 #include <errno.h>
 #include <sys/ioctl.h>
 #if defined(__GLIBC__)
@@ -44,49 +61,83 @@
 
 char *Version = "@(#)sulogin 2.85-3 23-Apr-2003 miquels at cistron.nl";
 
-int timeout = 0;
-int profile = 0;
+static int timeout;
+static int profile;
 
+static void (*saved_sigint)  = SIG_DFL;
+static void (*saved_sigtstp) = SIG_DFL;
+static void (*saved_sigquit) = SIG_DFL;
+
 #ifndef IUCLC
 #  define IUCLC	0
 #endif
 
-#if 0
+#if defined(SANE_TIO) && (SANE_TIO == 1)
 /*
  *	Fix the tty modes and set reasonable defaults.
  *	(I'm not sure if this is needed under Linux, but..)
  */
+static
 void fixtty(void)
 {
 	struct termios tty;
+	int serial;
 
+	/* Skip serial console */
+	if (ioctl (0, TIOCMGET, (char*)&serial) == 0)
+		goto out;
+	/* Expected error */
+	serial = errno = 0;
+
 	tcgetattr(0, &tty);
 
-	/*
-	 *	Set or adjust tty modes.
+	/* Use defaults of <sys/ttydefaults.h> for base settings */
+	tty.c_iflag |= TTYDEF_IFLAG;
+	tty.c_oflag |= TTYDEF_OFLAG;
+	tty.c_lflag |= TTYDEF_LFLAG;
+	tty.c_cflag |= (TTYDEF_SPEED | TTYDEF_CFLAG);
+
+	/* Sane setting, allow eight bit characters, no carriage return delay
+	 * the same result as `stty sane cr0 pass8'
 	 */
-	tty.c_iflag &= ~(INLCR|IGNCR|IUCLC);
-	tty.c_iflag |= ICRNL;
-	tty.c_oflag &= ~(OCRNL|OLCUC|ONOCR|ONLRET|OFILL);
-	tty.c_oflag |= OPOST|ONLCR;
-	tty.c_cflag |= CLOCAL;
-	tty.c_lflag  = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOKE;
+	tty.c_iflag |=  (BRKINT | ICRNL | IMAXBEL);
+#ifdef IUTF8 /* Not defined on FreeBSD */
+	tty.c_iflag |= IUTF8;
+#endif /* IUTF8 */
+	tty.c_iflag &= ~(IGNBRK | INLCR | IGNCR | IXOFF | IUCLC | IXANY | ISTRIP);
+	tty.c_oflag |=  (OPOST | ONLCR | NL0 | CR0 | TAB0 | BS0 | VT0 | FF0);
+	tty.c_oflag &= ~(OLCUC | OCRNL | ONOCR | ONLRET | OFILL | OFDEL |\
+			 NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY);
+	tty.c_lflag |=  (ISIG | ICANON | IEXTEN | ECHO|ECHOE|ECHOK|ECHOCTL|ECHOKE);
+	tty.c_lflag &= ~(ECHONL | NOFLSH | XCASE | TOSTOP | ECHOPRT);
+	tty.c_cflag |=  (CREAD | CS8 | B9600);
+	tty.c_cflag &= ~(PARENB);
 
-	/*
-	 *	Set the most important characters */
+	/* VTIME and VMIN can overlap with VEOF and VEOL since they are
+	 * only used for non-canonical mode. We just set the at the
+	 * beginning, so nothing bad should happen.
 	 */
-	tty.c_cc[VINTR]  = 3;
-	tty.c_cc[VQUIT]  = 28;
-	tty.c_cc[VERASE] = 127;
-	tty.c_cc[VKILL]  = 24;
-	tty.c_cc[VEOF]   = 4;
-	tty.c_cc[VTIME]  = 0;
-	tty.c_cc[VMIN]   = 1;
-	tty.c_cc[VSTART] = 17;
-	tty.c_cc[VSTOP]  = 19;
-	tty.c_cc[VSUSP]  = 26;
- 
+	tty.c_cc[VTIME]    = 0;
+	tty.c_cc[VMIN]     = 1;
+	tty.c_cc[VINTR]    = CINTR;
+	tty.c_cc[VQUIT]    = CQUIT;
+	tty.c_cc[VERASE]   = CERASE; /* ASCII DEL (0177) */
+	tty.c_cc[VKILL]    = CKILL;
+	tty.c_cc[VEOF]     = CEOF;
+	tty.c_cc[VSWTC]    = _POSIX_VDISABLE;
+	tty.c_cc[VSTART]   = CSTART;
+	tty.c_cc[VSTOP]    = CSTOP;
+	tty.c_cc[VSUSP]    = CSUSP;
+	tty.c_cc[VEOL]     = _POSIX_VDISABLE;
+	tty.c_cc[VREPRINT] = CREPRINT;
+	tty.c_cc[VDISCARD] = CDISCARD;
+	tty.c_cc[VWERASE]  = CWERASE;
+	tty.c_cc[VLNEXT]   = CLNEXT;
+	tty.c_cc[VEOL2]    = _POSIX_VDISABLE;
+
 	tcsetattr(0, TCSANOW, &tty);
+out:
+	return;
 }
 #endif
 
@@ -94,7 +145,12 @@
 /*
  *	Called at timeout.
  */
-void alrm_handler()
+static
+# ifdef __GNUC__
+void alrm_handler(int sig __attribute__((unused)))
+# else
+void alrm_handler(int sig)
+# endif
 {
 }
 
@@ -103,28 +159,58 @@
  *	password is checked for traditional-style DES and
  *	FreeBSD-style MD5 encryption.
  */
-int valid(char *pass)
+static
+int valid(const char *pass)
 {
-	char *s;
-	int len;
+	const char *s;
+	char id[5];
+	size_t len;
+	off_t off;
 
 	if (pass[0] == 0) return 1;
 #if CHECK_MD5
+	if (pass[0] != '$') goto check_des;
+
 	/*
-	 *	3 bytes for the signature $1$
-	 *	up to 8 bytes for the salt
-	 *	$
+	 *	up to 4 bytes for the signature e.g. $1$
+	 */
+	for(s = pass+1; *s && *s != '$'; s++)
+		;
+	if (*s++ != '$') return 0;
+	if ((off = (off_t)(s-pass)) > 4 || off < 3) return 0;
+
+	memset(id, '\0', sizeof(id));
+	strncpy(id, pass, off);
+
+	/*
+	 *	up to 16 bytes for the salt
+	 */
+	for(; *s && *s != '$'; s++)
+		;
+	if (*s++ != '$') return 0;
+	if ((off_t)(s-pass) > 16) return 0;
+	len = strlen(s);
+
+	/*
 	 *	the MD5 hash (128 bits or 16 bytes) encoded in base64 = 22 bytes
 	 */
-	if (strncmp(pass, "$1$", 3) == 0) {
-		for(s = pass + 3; *s && *s != '$'; s++)
-			;
-		if (*s++ != '$') return 0;
-		len = strlen(s);
-		if (len < 22 || len > 24) return 0;
+	if ((strcmp(id, "$1$") == 0) && (len < 22 || len > 24)) return 0;
 
-		return 1;
-	}
+	/*
+	 *	the SHA-256 hash 43 bytes
+	 */
+	if ((strcmp(id, "$5$") == 0) && (len < 42 || len > 44)) return 0;
+
+	/*
+	 *      the SHA-512 hash 86 bytes
+	 */
+	if ((strcmp(id, "$6$") == 0) && (len < 85 || len > 87)) return 0;
+
+	/*
+	 *	e.g. Blowfish hash
+	 */
+	return 1;
+check_des:
 #endif
 #if CHECK_DES
 	if (strlen(pass) != 13) return 0;
@@ -141,6 +227,7 @@
 /*
  *	Set a variable if the value is not NULL.
  */
+static
 void set(char **var, char *val)
 {
 	if (val) *var = val;
@@ -149,6 +236,7 @@
 /*
  *	Get the root password entry.
  */
+static
 struct passwd *getrootpwent(int try_manually)
 {
 	static struct passwd pwd;
@@ -251,6 +339,7 @@
  *	Ask for the password. Note that there is no
  *	default timeout as we normally skip this during boot.
  */
+static
 char *getpasswd(char *crypted)
 {
 	struct sigaction sa;
@@ -258,12 +347,18 @@
 	static char pass[128];
 	char *ret = pass;
 	int i;
-
+#if defined(USE_ONELINE)
 	if (crypted[0])
+		printf("Give root password for login: ");
+	else
+		printf("Press enter for login: ");
+#else
+	if (crypted[0])
 		printf("Give root password for maintenance\n");
 	else
-		printf("Press enter for maintenance\n");
+		printf("Press enter for maintenance");
 	printf("(or type Control-D to continue): ");
+#endif
 	fflush(stdout);
 
 	tcgetattr(0, &old);
@@ -282,7 +377,7 @@
 	if (read(0, pass, sizeof(pass) - 1) <= 0)
 		ret = NULL;
 	else {
-		for(i = 0; i < sizeof(pass) && pass[i]; i++)
+		for(i = 0; i < (int)sizeof(pass) && pass[i]; i++)
 			if (pass[i] == '\r' || pass[i] == '\n') {
 				pass[i] = 0;
 				break;
@@ -298,6 +393,7 @@
 /*
  *	Password was OK, execute a shell.
  */
+static
 void sushell(struct passwd *pwd)
 {
 	char shell[128];
@@ -339,16 +435,16 @@
 	 *	Try to execute a shell.
 	 */
 	setenv("SHELL", sushell, 1);
-	signal(SIGINT, SIG_DFL);
-	signal(SIGTSTP, SIG_DFL);
-	signal(SIGQUIT, SIG_DFL);
+	signal(SIGINT,  saved_sigint);
+	signal(SIGTSTP, saved_sigtstp);
+	signal(SIGQUIT, saved_sigquit);
 #ifdef WITH_SELINUX
-	if (is_selinux_enabled > 0) {
+	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 (get_default_context_with_level(seuser, level, 0, &scon) == 0) {
 			  if (setexeccon(scon) != 0) 
 				  fprintf(stderr, "setexeccon faile\n");
 			  freecon(scon);
@@ -371,6 +467,7 @@
 	perror(STATICSH);
 }
 
+static
 void usage(void)
 {
 	fprintf(stderr, "Usage: sulogin [-e] [-p] [-t timeout] [tty device]\n");
@@ -413,14 +510,19 @@
 	/*
 	 *	See if we need to open an other tty device.
 	 */
-	signal(SIGINT, SIG_IGN);
-	signal(SIGQUIT, SIG_IGN);
-	signal(SIGTSTP, SIG_IGN);
+	saved_sigint  = signal(SIGINT,  SIG_IGN);
+	saved_sigtstp = signal(SIGQUIT, SIG_IGN);
+	saved_sigquit = signal(SIGTSTP, SIG_IGN);
 	if (optind < argc) tty = argv[optind];
-	if (tty) {
+
+	if (tty || (tty = getenv("CONSOLE"))) {
+
 		if ((fd = open(tty, O_RDWR)) < 0) {
 			perror(tty);
-		} else if (!isatty(fd)) {
+			fd = dup(0);
+		}
+
+		if (!isatty(fd)) {
 			fprintf(stderr, "%s: not a tty\n", tty);
 			close(fd);
 		} else {
@@ -432,7 +534,7 @@
 			pid = getpid();
 			pgrp = getpgid(0);
 			ppgrp = getpgid(getppid());
-			ioctl(fd, TIOCGPGRP, &ttypgrp);
+			ttypgrp = tcgetpgrp(fd);
 
 			if (pgrp != ttypgrp && ppgrp != ttypgrp) {
 				if (pid != getsid(0)) {
@@ -442,18 +544,28 @@
 				}
 
 				signal(SIGHUP, SIG_IGN);
-				ioctl(0, TIOCNOTTY, (char *)1);
+				if (ttypgrp > 0)
+					ioctl(0, TIOCNOTTY, (char *)1);
 				signal(SIGHUP, SIG_DFL);
 				close(0);
 				close(1);
 				close(2);
-				close(fd);
-				fd = open(tty, O_RDWR);
-				ioctl(0, TIOCSCTTY, (char *)1);
-				dup(fd);
-				dup(fd);
+				if (fd > 2)
+					close(fd);
+				if ((fd = open(tty, O_RDWR|O_NOCTTY)) < 0) {
+					perror(tty);
+				} else {
+					ioctl(0, TIOCSCTTY, (char *)1);
+					tcsetpgrp(fd, ppgrp);
+					dup2(fd, 0);
+					dup2(fd, 1);
+					dup2(fd, 2);
+					if (fd > 2)
+						close(fd);
+				}
 			} else
-				close(fd);
+				if (fd > 2)
+					close(fd);
 		}
 	} else if (getpid() == 1) {
 		/* We are init. We hence need to set a session anyway */
@@ -462,6 +574,10 @@
 			perror("ioctl(TIOCSCTTY)");
 	}
 
+#if defined(SANE_TIO) && (SANE_TIO == 1)
+	fixtty();
+#endif
+
 	/*
 	 *	Get the root password.
 	 */
@@ -478,6 +594,9 @@
 		if (pwd->pw_passwd[0] == 0 ||
 		    strcmp(crypt(p, pwd->pw_passwd), pwd->pw_passwd) == 0)
 			sushell(pwd);
+		saved_sigquit = signal(SIGQUIT, SIG_IGN);
+		saved_sigtstp = signal(SIGTSTP, SIG_IGN);
+		saved_sigint  = signal(SIGINT,  SIG_IGN);
 		printf("Login incorrect.\n");
 	}
 
@@ -486,4 +605,3 @@
 	 */
 	return 0;
 }
-

Modified: sysvinit/branches/upstream/current/src/utmp.c
===================================================================
--- sysvinit/branches/upstream/current/src/utmp.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/utmp.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -4,6 +4,22 @@
  *
  * Version:	@(#)utmp.c  2.77  09-Jun-1999  miquels at cistron.nl
  *
+ * Copyright (C) 1999 Miquel van Smoorenburg.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by 
+ * the Free Software Foundation; either version 2 of the License, or 
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, 
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
  */
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -50,6 +66,12 @@
 	struct timeval tv;
 	
 	/*
+	 *	Can't do much if WTMP_FILE is not present or not writable.
+	 */
+	if (access(WTMP_FILE, W_OK) < 0)
+		return;
+
+	/*
 	 *	Try to open the wtmp file. Note that we even try
 	 *	this if we have updwtmp() so we can see if the
 	 *	wtmp file is accessible.
@@ -70,6 +92,23 @@
 	 */
 	if (wrote_wtmp_reboot == 0 && type != BOOT_TIME)
   		write_wtmp("reboot", "~~", 0, BOOT_TIME, "~");
+
+	/*
+	 *	Note if we are going to write a runlevel record.
+	 */
+	if (type == RUN_LVL) wrote_wtmp_rlevel++;
+
+	/*
+	 *	See if we need to write a runlevel record. The reason that
+	 *	we are being so paranoid is that when we first tried to
+	 *	write the reboot record, /var was possibly not mounted
+	 *	yet. As soon as we can open WTMP we write a delayed runlevel record.
+	 */
+	if (wrote_wtmp_rlevel == 0 && type != RUN_LVL) {
+		int runlevel = thislevel;
+		int oldlevel = prevlevel;
+		write_wtmp("runlevel", "~~", runlevel + 256 * oldlevel, RUN_LVL, "~");
+	}
 #endif
 
 	/*
@@ -119,9 +158,9 @@
 	struct timeval tv;
 
 	/*
-	 *	Can't do much if UTMP_FILE is not present.
+	 *	Can't do much if UTMP_FILE is not present or not writable.
 	 */
-	if (access(UTMP_FILE, F_OK) < 0)
+	if (access(UTMP_FILE, W_OK) < 0)
 		return;
 
 #ifdef INIT_MAIN
@@ -134,10 +173,27 @@
 	 *	See if we need to write a reboot record. The reason that
 	 *	we are being so paranoid is that when we first tried to
 	 *	write the reboot record, /var was possibly not mounted
-	 *	yet. As soon as we can open WTMP we write a delayed boot record.
+	 *	yet. As soon as we can open UTMP we write a delayed boot record.
 	 */
 	if (wrote_utmp_reboot == 0 && type != BOOT_TIME)
   		write_utmp("reboot", "~~", 0, BOOT_TIME, "~", NULL);
+
+	/*
+	 *	Note if we are going to write a runlevel record.
+	 */
+	if (type == RUN_LVL) wrote_utmp_rlevel++;
+
+	/*
+	 *	See if we need to write a runlevel record. The reason that
+	 *	we are being so paranoid is that when we first tried to
+	 *	write the reboot record, /var was possibly not mounted
+	 *	yet. As soon as we can open UTMP we write a delayed runlevel record.
+	 */
+	if (wrote_utmp_rlevel == 0 && type != RUN_LVL) {
+		int runlevel = thislevel;
+		int oldlevel = prevlevel;
+		write_utmp("runlevel", "~~", runlevel + 256 * oldlevel, RUN_LVL, "~", NULL);
+	}
 #endif
 
 	/*

Modified: sysvinit/branches/upstream/current/src/utmpdump.c
===================================================================
--- sysvinit/branches/upstream/current/src/utmpdump.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/utmpdump.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -8,14 +8,23 @@
  * Version:	@(#)utmpdump  2.79  12-Sep-2000
  *
  *		This file is part of the sysvinit suite,
- *		Copyright 1991-2000 Miquel van Smoorenburg.
+ *		Copyright (C) 1991-2000 Miquel van Smoorenburg.
  *
  *		Additional Copyright on this file 1998 Danek Duvall.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
+ *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <stdio.h>
@@ -191,7 +200,11 @@
 }
 
 void
+# ifdef __GNUC__
+undump(FILE *fp, int forever __attribute__((unused)), int oldfmt)
+#else
 undump(FILE *fp, int forever, int oldfmt)
+#endif
 {
 	struct utmp ut;
 	struct oldutmp uto;

Modified: sysvinit/branches/upstream/current/src/wall.c
===================================================================
--- sysvinit/branches/upstream/current/src/wall.c	2010-04-11 09:14:46 UTC (rev 1861)
+++ sysvinit/branches/upstream/current/src/wall.c	2010-04-23 05:38:15 UTC (rev 1862)
@@ -6,12 +6,21 @@
  * Version:	@(#)wall  2.79  12-Sep-2000  miquels at cistron.nl
  *
  *		This file is part of the sysvinit suite,
- *		Copyright 1991-2000 Miquel van Smoorenburg.
+ *		Copyright (C) 1991-2000 Miquel van Smoorenburg.
  *
- *		This program is free software; you can redistribute it and/or
- *		modify it under the terms of the GNU General Public License
- *		as published by the Free Software Foundation; either version
- *		2 of the License, or (at your option) any later version.
+ *		This program is free software; you can redistribute it and/or modify
+ *		it under the terms of the GNU General Public License as published by
+ *		the Free Software Foundation; either version 2 of the License, or
+ *		(at your option) any later version.
+ *
+ *		This program is distributed in the hope that it will be useful,
+ *		but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *		GNU General Public License for more details.
+ *
+ *		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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <stdio.h>
@@ -20,14 +29,13 @@
 #include <unistd.h>
 #include <pwd.h>
 #include <syslog.h>
+#include "init.h"
 
 
 char *Version = "@(#) wall 2.79 12-Sep-2000 miquels at cistron.nl";
 #define MAXLEN 4096
 #define MAXLINES 20
 
-extern void wall(char *, int, int);
-
 int main(int argc, char **argv)
 {
   char buf[MAXLEN];
@@ -106,7 +114,7 @@
   closelog();
 
   unsetenv("TZ");
-  wall(buf, 0, remote);
+  wall(buf, remote);
 
   /*NOTREACHED*/
   return 0;




More information about the Pkg-sysvinit-commits mailing list