From 441dd93e8311c8869c56a7550ce86df87f04bfde Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 25 Apr 2010 17:56:47 +0000 Subject: Import sysvinit_2.88dsf.orig.tar.gz [dgit import orig sysvinit_2.88dsf.orig.tar.gz] --- COPYING | 339 +++++ COPYRIGHT | 29 + Makefile | 2 + README | 10 + contrib/TODO | 16 + contrib/alexander.viro | 29 + contrib/notify-pam-dead.patch | 220 +++ contrib/start-stop-daemon.README | 45 + contrib/start-stop-daemon.c | 430 ++++++ contrib/zefram-patches | 120 ++ doc/Changelog | 729 ++++++++++ doc/Install | 56 + doc/Propaganda | 81 ++ doc/bootlogd.README | 19 + doc/sysvinit-2.86.lsm | 14 + man/bootlogd.8 | 72 + man/bootlogd.8.todo | 52 + man/fstab-decode.8 | 45 + man/halt.8 | 120 ++ man/init.8 | 313 ++++ man/initscript.5 | 72 + man/inittab.5 | 265 ++++ man/killall5.8 | 49 + man/last.1 | 124 ++ man/lastb.1 | 1 + man/mesg.1 | 61 + man/mountpoint.1 | 54 + man/pidof.8 | 92 ++ man/poweroff.8 | 1 + man/reboot.8 | 1 + man/runlevel.8 | 56 + man/shutdown.8 | 215 +++ man/sulogin.8 | 87 ++ man/telinit.8 | 1 + man/utmpdump.1 | 66 + man/wall.1 | 75 + obsolete/README.RIGHT.NOW | 58 + obsolete/bootlogd.init | 67 + obsolete/powerd.8 | 73 + obsolete/powerd.README | 36 + obsolete/powerd.c | 201 +++ obsolete/powerd.cfg | 58 + obsolete/utmpdump.c.OLD | 70 + src/Makefile | 183 +++ src/bootlogd.c | 690 +++++++++ src/dowall.c | 253 ++++ src/fstab-decode.c | 86 ++ src/halt.c | 315 +++++ src/hddown.c | 568 ++++++++ src/ifdown.c | 109 ++ src/init.c | 2898 ++++++++++++++++++++++++++++++++++++++ src/init.h | 148 ++ src/initreq.h | 84 ++ src/initscript.sample | 25 + src/killall5.c | 1104 +++++++++++++++ src/last.c | 928 ++++++++++++ src/mesg.c | 124 ++ src/mountpoint.c | 128 ++ src/oldutmp.h | 41 + src/paths.h | 50 + src/reboot.h | 51 + src/runlevel.c | 53 + src/set.h | 28 + src/shutdown.c | 762 ++++++++++ src/sulogin.c | 607 ++++++++ src/utmp.c | 264 ++++ src/utmpdump.c | 302 ++++ src/wall.c | 122 ++ 68 files changed, 14447 insertions(+) create mode 100644 COPYING create mode 100644 COPYRIGHT create mode 100644 Makefile create mode 100644 README create mode 100644 contrib/TODO create mode 100644 contrib/alexander.viro create mode 100644 contrib/notify-pam-dead.patch create mode 100644 contrib/start-stop-daemon.README create mode 100644 contrib/start-stop-daemon.c create mode 100644 contrib/zefram-patches create mode 100644 doc/Changelog create mode 100644 doc/Install create mode 100644 doc/Propaganda create mode 100644 doc/bootlogd.README create mode 100644 doc/sysvinit-2.86.lsm create mode 100644 man/bootlogd.8 create mode 100644 man/bootlogd.8.todo create mode 100644 man/fstab-decode.8 create mode 100644 man/halt.8 create mode 100644 man/init.8 create mode 100644 man/initscript.5 create mode 100644 man/inittab.5 create mode 100644 man/killall5.8 create mode 100644 man/last.1 create mode 100644 man/lastb.1 create mode 100644 man/mesg.1 create mode 100644 man/mountpoint.1 create mode 100644 man/pidof.8 create mode 100644 man/poweroff.8 create mode 100644 man/reboot.8 create mode 100644 man/runlevel.8 create mode 100644 man/shutdown.8 create mode 100644 man/sulogin.8 create mode 100644 man/telinit.8 create mode 100644 man/utmpdump.1 create mode 100644 man/wall.1 create mode 100644 obsolete/README.RIGHT.NOW create mode 100755 obsolete/bootlogd.init create mode 100644 obsolete/powerd.8 create mode 100644 obsolete/powerd.README create mode 100644 obsolete/powerd.c create mode 100644 obsolete/powerd.cfg create mode 100644 obsolete/utmpdump.c.OLD create mode 100644 src/Makefile create mode 100644 src/bootlogd.c create mode 100644 src/dowall.c create mode 100644 src/fstab-decode.c create mode 100644 src/halt.c create mode 100644 src/hddown.c create mode 100644 src/ifdown.c create mode 100644 src/init.c create mode 100644 src/init.h create mode 100644 src/initreq.h create mode 100755 src/initscript.sample create mode 100644 src/killall5.c create mode 100644 src/last.c create mode 100644 src/mesg.c create mode 100644 src/mountpoint.c create mode 100644 src/oldutmp.h create mode 100644 src/paths.h create mode 100644 src/reboot.h create mode 100644 src/runlevel.c create mode 100644 src/set.h create mode 100644 src/shutdown.c create mode 100644 src/sulogin.c create mode 100644 src/utmp.c create mode 100644 src/utmpdump.c create mode 100644 src/wall.c diff --git a/COPYING b/COPYING new file mode 100644 index 00000000..d511905c --- /dev/null +++ b/COPYING @@ -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. + + + Copyright (C) + + 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. + + , 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. diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 00000000..d44645b1 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,29 @@ +Sysvinit is 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 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 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-2'. + +Send patches to sysvinit-devel@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 , + * public domain. + diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..db0e2f2d --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +all install clean distclean: + $(MAKE) -C src $@ diff --git a/README b/README new file mode 100644 index 00000000..d91f961e --- /dev/null +++ b/README @@ -0,0 +1,10 @@ + +contrib Unofficial stuff +doc Documentation, mostly obsolete +man Manual pages, not obsolete +obsolete Really obsolete stuff ;) +src Source code + +The project home is on http://savannah.nongnu.org/projects/sysvinit . + +Send patches to sysvinit-devel@nongnu.org . diff --git a/contrib/TODO b/contrib/TODO new file mode 100644 index 00000000..6ec13120 --- /dev/null +++ b/contrib/TODO @@ -0,0 +1,16 @@ + +There are several things on the wishlist. See also the "wishlist" bugs filed +against sysvinit in the debian bugs system (http://www.debian.org/Bugs/). + +1. A special target for kbrequest, so that extra CHILDs are + created (each one needs its own utmp/wtmp bookkeeping) +2. Extend the initreq.h interface? +3. Add GNU last long options to last + +4. Write all boot messages to a logfile + Problem: TIOCCONS ioctl redirects console output, it doesn't copy it. + I think this is not easily possible without kernel support. + I do not like the idea of booting with a pseudo tty as console and + a redirect process behind it writing to both the real console and a + logfile - too fragile. + diff --git a/contrib/alexander.viro b/contrib/alexander.viro new file mode 100644 index 00000000..976d09bb --- /dev/null +++ b/contrib/alexander.viro @@ -0,0 +1,29 @@ +I proposed moving some stuff to a seperate file, such as the +re-exec routines. Alexander wrote: + + +According to Alexander Viro : +> As for the code separation - I think it's nice. Actually, read_inittab() +> with get_part() and newFamily are also pretty separatable. Another good +> set is any(), spawn(), startup(), spawn_emerg() and start_if_needed(). +> BTW, fail_check();process_signals(); is equivalent to process_signal(); +> fail_check();. I think that swapping them (in main loop) would be a good +> idea - then we can move fail_check() into start_if_needed(). And one more +> - I'ld propose to move start_if_needed to the beginning of the main loop, +> as in +> foo(); +> while(1) { bar();foo(); +> #if 0 +> baz(); +> #endif +> } +> to +> while(1) { foo();bar(); +> #if 0 +> baz(); +> #endif +> } +> +> +> What do you think about it? + diff --git a/contrib/notify-pam-dead.patch b/contrib/notify-pam-dead.patch new file mode 100644 index 00000000..ce53ffed --- /dev/null +++ b/contrib/notify-pam-dead.patch @@ -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 + #include + ++#if defined(USE_PAM) && defined(INIT_MAIN) ++# include ++# include ++#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@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 diff --git a/contrib/start-stop-daemon.README b/contrib/start-stop-daemon.README new file mode 100644 index 00000000..fb69c08f --- /dev/null +++ b/contrib/start-stop-daemon.README @@ -0,0 +1,45 @@ +Start-stop-daemon is the program that is used by the DEBIAN style init +scripts to start and stop services. This program is part of the "dpkg" +package by Ian Jackson. However there is also a seperate C version (the +original is in perl) available written by Marek Michalkiewicz. I'm including +it for your convinience. + +Note that the latest debian dpkg packages (4.0.18 and later) contain +a much improved update-rc.d. This code is almost a year old. + +The original announcement follows: + + +From: Marek Michalkiewicz +Message-Id: <199606060324.FAA19493@i17linuxb.ists.pwr.wroc.pl> +Subject: Fast start-stop-daemon in C +To: debian-devel@lists.debian.org +Date: Thu, 6 Jun 1996 05:24:18 +0200 (MET DST) + +Some time ago I wrote a faster C replacement for the start-stop-daemon +perl script. I use it for some time now (the most recent changes were +just a nicer help screen; the code is quite stable). + +This makes the system boot faster (especially on low end machines), +and important system startup scripts no longer depend on another big +package (perl). Maybe in the future we can get to the point where +a minimal system will work without perl installed at all (packages +which need it in {pre,post}{inst,rm} scripts would depend on perl). + +The only problem known so far to me is that I have to reinstall this +program after every dpkg upgrade which overwrites it with that nice +slooow perl script :-). + +Just compile this program and drop the binary in /usr/sbin instead +of the original /usr/sbin/start-stop-daemon perl script (make a copy +of it first, just in case). See below for source code. I placed it +in the public domain, but if it has to be GPL-ed to be included in +dpkg, just tell me. Including it in dpkg would close Bug#1670. + +I am posting it here so that it can be tested by more people than +just me. Bugs are unlikely though. + +Have fun, + +Marek + diff --git a/contrib/start-stop-daemon.c b/contrib/start-stop-daemon.c new file mode 100644 index 00000000..ce286a25 --- /dev/null +++ b/contrib/start-stop-daemon.c @@ -0,0 +1,430 @@ +/* + * 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 , + * public domain. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define VERSION "version 0.3, 1996-06-05" + +static int testmode = 0; +static int quietmode = 0; +static int exitnodo = 1; +static int start = 0; +static int stop = 0; +static int signal_nr = 15; +static int user_id = -1; +static const char *userspec = NULL; +static const char *cmdname = NULL; +static char *execname = NULL; +static char *startas = NULL; +static const char *pidfile = NULL; +static const char *progname = ""; + +static struct stat exec_stat; + +struct pid_list { + struct pid_list *next; + int pid; +}; + +static struct pid_list *found = NULL; +static struct pid_list *killed = NULL; + +static void *xmalloc(int size); +static void push(struct pid_list **list, int pid); +static void do_help(void); +static void parse_options(int argc, char * const *argv); +static int pid_is_exec(int pid, const struct stat *esb); +static int pid_is_user(int pid, int uid); +static int pid_is_cmd(int pid, const char *name); +static void check(int pid); +static void do_pidfile(const char *name); +static void do_procfs(void); +static void do_stop(void); + +#ifdef __GNUC__ +static void fatal(const char *format, ...) + __attribute__((noreturn, format(printf, 1, 2))); +static void badusage(const char *msg) + __attribute__((noreturn)); +#else +static void fatal(const char *format, ...); +static void badusage(const char *msg); +#endif + +static void +fatal(const char *format, ...) +{ + va_list arglist; + + fprintf(stderr, "%s: ", progname); + va_start(arglist, format); + vfprintf(stderr, format, arglist); + va_end(arglist); + putc('\n', stderr); + exit(2); +} + + +static void * +xmalloc(int size) +{ + void *ptr; + + ptr = malloc(size); + if (ptr) + return ptr; + fatal("malloc(%d) failed", size); +} + + +static void +push(struct pid_list **list, int pid) +{ + struct pid_list *p; + + p = xmalloc(sizeof(*p)); + p->next = *list; + p->pid = pid; + *list = p; +} + + +static void +do_help(void) +{ + printf("\ +start-stop-daemon for Debian Linux - small and fast C version written by\n\ +Marek Michalkiewicz , public domain.\n" +VERSION "\n\ +\n\ +Usage: + start-stop-daemon -S|--start options ... -- arguments ...\n\ + start-stop-daemon -K|--stop options ...\n\ + start-stop-daemon -H|--help\n\ + start-stop-daemon -V|--version\n\ +\n\ +Options (at least one of --exec|--pidfile|--user is required): + -x|--exec program to start/check if it is running\n\ + -p|--pidfile pid file to check\n\ + -u|--user | stop this user's processes\n\ + -n|--name stop processes with this name\n\ + -s|--signal signal to send (default 15)\n\ + -a|--startas program to start (default )\n\ + -t|--test test mode, don't do anything\n\ + -o|--oknodo exit status 0 (not 1) if nothing done\n\ + -q|--quiet | -v, --verbose\n\ +\n\ +Exit status: 0 = done 1 = nothing done (=> 0 if --oknodo) 2 = trouble\n"); +} + + +static void +badusage(const char *msg) +{ + if (msg && *msg) + fprintf(stderr, "%s: %s\n", progname, msg); + fprintf(stderr, "Try `%s --help' for more information.\n", progname); + exit(2); +} + + +static void +parse_options(int argc, char * const *argv) +{ + static struct option longopts[] = { + { "help", 0, NULL, 'H'}, + { "stop", 0, NULL, 'K'}, + { "start", 0, NULL, 'S'}, + { "version", 0, NULL, 'V'}, + { "startas", 1, NULL, 'a'}, + { "name", 1, NULL, 'n'}, + { "oknodo", 0, NULL, 'o'}, + { "pidfile", 1, NULL, 'p'}, + { "quiet", 0, NULL, 'q'}, + { "signal", 1, NULL, 's'}, + { "test", 0, NULL, 't'}, + { "user", 1, NULL, 'u'}, + { "verbose", 0, NULL, 'v'}, + { "exec", 1, NULL, 'x'}, + { NULL, 0, NULL, 0} + }; + int c; + + for (;;) { + c = getopt_long(argc, argv, "HKSVa:n:op:qs:tu:vx:", + longopts, (int *) 0); + if (c == -1) + break; + switch (c) { + case 'H': /* --help */ + do_help(); + exit(0); + case 'K': /* --stop */ + stop = 1; + break; + case 'S': /* --start */ + start = 1; + break; + case 'V': /* --version */ + printf("start-stop-daemon " VERSION "\n"); + exit(0); + case 'a': /* --startas */ + startas = optarg; + break; + case 'n': /* --name */ + cmdname = optarg; + break; + case 'o': /* --oknodo */ + exitnodo = 0; + break; + case 'p': /* --pidfile */ + pidfile = optarg; + break; + case 'q': /* --quiet */ + quietmode = 1; + break; + case 's': /* --signal */ + if (sscanf(optarg, "%d", &signal_nr) != 1) + badusage("--signal takes a numeric argument"); + break; + case 't': /* --test */ + testmode = 1; + break; + case 'u': /* --user | */ + userspec = optarg; + break; + case 'v': /* --verbose */ + quietmode = -1; + break; + case 'x': /* --exec */ + execname = optarg; + break; + default: + badusage(""); /* message printed by getopt */ + } + } + + if (start == stop) + badusage("need one of --start or --stop"); + + if (!execname && !pidfile && !userspec) + badusage("need at least one of --exec, --pidfile or --user"); + + if (!startas) + startas = execname; + + if (start && !startas) + badusage("--start needs --exec or --startas"); +} + + +static int +pid_is_exec(int pid, const struct stat *esb) +{ + struct stat sb; + char buf[32]; + + sprintf(buf, "/proc/%d/exe", pid); + if (stat(buf, &sb) != 0) + return 0; + return (sb.st_dev == esb->st_dev && sb.st_ino == esb->st_ino); +} + + +static int +pid_is_user(int pid, int uid) +{ + struct stat sb; + char buf[32]; + + sprintf(buf, "/proc/%d", pid); + if (stat(buf, &sb) != 0) + return 0; + return (sb.st_uid == uid); +} + + +static int +pid_is_cmd(int pid, const char *name) +{ + char buf[32]; + FILE *f; + int c; + + sprintf(buf, "/proc/%d/stat", pid); + f = fopen(buf, "r"); + if (!f) + return 0; + while ((c = getc(f)) != EOF && c != '(') + ; + if (c != '(') { + fclose(f); + return 0; + } + /* this hopefully handles command names containing ')' */ + while ((c = getc(f)) != EOF && c == *name) + name++; + fclose(f); + return (c == ')' && *name == '\0'); +} + + +static void +check(int pid) +{ + if (execname && !pid_is_exec(pid, &exec_stat)) + return; + if (userspec && !pid_is_user(pid, user_id)) + return; + if (cmdname && !pid_is_cmd(pid, cmdname)) + return; + push(&found, pid); +} + + +static void +do_pidfile(const char *name) +{ + FILE *f; + int pid; + + f = fopen(name, "r"); + if (f) { + if (fscanf(f, "%d", &pid) == 1) + check(pid); + fclose(f); + } +} + + +static void +do_procfs(void) +{ + DIR *procdir; + struct dirent *entry; + int foundany, pid; + + procdir = opendir("/proc"); + if (!procdir) + fatal("opendir /proc: %s", strerror(errno)); + + foundany = 0; + while ((entry = readdir(procdir)) != NULL) { + if (sscanf(entry->d_name, "%d", &pid) != 1) + continue; + foundany++; + check(pid); + } + closedir(procdir); + if (!foundany) + fatal("nothing in /proc - not mounted?"); +} + + +static void +do_stop(void) +{ + char what[1024]; + struct pid_list *p; + + if (cmdname) + strcpy(what, cmdname); + else if (execname) + strcpy(what, execname); + else if (pidfile) + sprintf(what, "process in pidfile `%s'", pidfile); + else if (userspec) + sprintf(what, "process(es) owned by `%s'", userspec); + else + fatal("internal error, please report"); + + if (!found) { + if (quietmode <= 0) + printf("no %s found; none killed.\n", what); + exit(exitnodo); + } + for (p = found; p; p = p->next) { + if (testmode) + printf("would send signal %d to %d.\n", + signal_nr, p->pid); + else if (kill(p->pid, signal_nr) == 0) + push(&killed, p->pid); + else + printf("%s: warning: failed to kill %d: %s\n", + progname, p->pid, strerror(errno)); + } + if (quietmode < 0 && killed) { + printf("stopped %s (pid", what); + for (p = killed; p; p = p->next) + printf(" %d", p->pid); + printf(").\n"); + } +} + + +int +main(int argc, char **argv) +{ + progname = argv[0]; + + parse_options(argc, argv); + argc -= optind; + argv += optind; + + if (execname && stat(execname, &exec_stat)) + fatal("stat %s: %s", execname, strerror(errno)); + + if (userspec && sscanf(userspec, "%d", &user_id) != 1) { + struct passwd *pw; + + pw = getpwnam(userspec); + if (!pw) + fatal("user `%s' not found\n", userspec); + + user_id = pw->pw_uid; + } + + if (pidfile) + do_pidfile(pidfile); + else + do_procfs(); + + if (stop) { + do_stop(); + exit(0); + } + + if (found) { + if (quietmode <= 0) + printf("%s already running.\n", execname); + exit(exitnodo); + } + if (testmode) { + printf("would start %s ", startas); + while (argc-- > 0) + printf("%s ", *argv++); + printf(".\n"); + exit(0); + } + if (quietmode < 0) + printf("starting %s ...\n", startas); + *--argv = startas; + execv(startas, argv); + fatal("unable to start %s: %s", startas, strerror(errno)); +} + diff --git a/contrib/zefram-patches b/contrib/zefram-patches new file mode 100644 index 00000000..9bdf98a1 --- /dev/null +++ b/contrib/zefram-patches @@ -0,0 +1,120 @@ +Date: Mon, 14 Apr 1997 15:39:08 +0100 (BST) +From: Zefram +Message-Id: <25042.199704141439@stone.dcs.warwick.ac.uk> +Subject: SysVinit patch +To: miquels@drinkel.cistron.nl + +Hi. Enclosed is a patch for SysVinit that I am finding tiresome to +keep updating; you might like to fold it into your official releases. +It does the following: + +* shutdown: use /etc/shutdown.allow if an option -s is given instead + of testing for a controlling tty. The tty check was inflexible and + unreliable. + +* sulogin(8): refer to inittab(5) instead of inittab(4). + +* sulogin: use libc passwd/shadow functions instead of home-grown ones + (there's just no point in using the special version). + +* shutdown/sulogin: don't rely on the username "root" -- it's the UID + that counts. + +-zefram + +begin 644 initdiffs.gz +M'XL(``IG43,"`^T[:U/;R+*?E5_1>&L3&\G&#Y[FD%H")/%9)U"8G-0](44) +M>62KD"6M1K+7)YO_?KM[1K)DFP"[V:T]=2^5`FFFIZ??W=.C##W7A;H3@YS+ +MJ1=X2;W=V#W8DN,T&8:SH+%?GC`+,\\V-S?O76:\CCWX9QI`:QO_=3N[W68; +M6@<'N\_J]?K].(T!+CF.8FAUH-WI-G>Z.QU:MD>;%7]X\U;+:NT!OP(T7L&6 +MO/6"'!N-7;Z"3W!=3^BY=PE2./#YV48^'M^-`\?%(9J&Q)L(7M3#R9D=!UXP +MJD^$E/9(*)CKRM>O7YD#M34^U?_0UO*I>Z\3P^Z!M;>MQ$"DX>M^*R--_!KY +M-DHZC.>0H0L#2,8"G'`RL8,A^%X@<,!.8.;Y/MP*I#5((`G!]GU$D4H1R\:" +M!),>OGSY`E"7]-*[@&OWU75=7KL7^'X6R#36"&U>#'::C,/8DV)(6$E(0%)B +M*M`4$C$!3X(?CD8(X04-Q'(UQA'\%X3Q!,F8$Z(AS,8BH,TR.>..!.0@!,[> +MSFF.[`K'J_LU"_'PBI,D]NO'?E(_%3[!1S%*0@P;``,A%!7"2;R0.'0=G +MX20,DCCT%4^WP@]GX(8Q3$+DS0M<(HM6-)0X2"Z0RR53)DNF1V^$!N`C$:,E +MP/:^WJJ;.U9K8=?(TLG59;]^W+^JGY[UB64;:=`\6,2U$PLD)AB!'8`=17$8 +MQ9Z="$`UHMJ]@+'TMD3B;)%T$OL6L324C"?"#J32EIB*>!ZB,H@4#IM:!2YA"N0B)URA:%^UGH`DL* +MI+7.6#AW+!I4B.>[^A +MN'$X*9@*T>0EB@99(((0NQZRF0DOUQNB"6<:)RD"N2,'Z3'_`7E6A#J2C`&) +M1H(#&[V/*&=),]:9EXP5A"<38B028>23X2C?B46)872F)2ZAJAGI;4WM>"M. +M@ZTTF41(5ZT!YX$_)[[SL+ +M8O_O`FM=@#1+;O![7"`W/H10D1L11131K/^[OE"2+QLWBF+5]%6X^%.,?_A` +M.>;<6SHYWRK''.,J%7"`*J8BJ9!,<_B$\KG$S81OSS%Y)S.!ECCHO;DZNWP'5//@\\^]?I]3.A%` +M:5POQG43^PY=F*J8A1/*=4ZH]N1?*%V"ZQKOO%]2I'2*2P>3$,N%X#:-1Q9, +M>%S^-(R]X$[X#0[M9(3`-/2(!C:Q:P]6243B@/4];'O6TZ%VU`E6J$ZTJ`>:Q2PT6(I'9( +M1H7')R^IMOAE_=FKO;MOM?<*XF^CS[;1:;/(AT1A:/.&08A$PA$T#_-1+_PPVW4B].6,[ADV2.R>33YWVY\+$;>I^:K7W<6@M +MZ?O;5J=SD(47XI!^8U1RHGF5<-[X6+7X%E1:2A[/ZCB_M1C]5-T+.W3`2075P>MSOGW]$:N)*C9&\_]#OU]#[ZT28@72]#]=28A&E +M,X%2+-;_'/85C8:GY*NP7&)Z@34U3@8\&V/%4G61:EE%"5N`(K8P_M04+89! +M#)/HFY^)H1<_O(#??H/"P'7PHL:$>D$J#O,E'KR$3FMY!C-459(4$,$A;,KH +M$&1DFC46ZR;-9!CY1;-A+$S",TWD_RH&'C:) +M-$'?K*Y3KK&PND1W!G1O@'JYOWQN[-![]]GN>NL$EZD7!DM_Q+!4%M+ +MP3`U-VP7,UMFO.1>3H1I_$5?+4:9D_/W@_/^&4IUMA)EJ#S,ZPPW0ICK^)&U +M?>,Z5DDEPU+R*\V8D6<;S26%9&0.5-2]T)9.&4T=U91/T;1RJJJC_`AGJYCJ +M'(L2WA3I='[!JB=PYTEWU/6ZFK&S\]*&IV'6"DSQ5#PI9CTI,)EOE1_&">X99*B>.+)#A@U7- +M)B'`DT7IY*O/NPU0D6(8"LD5':X/J27I<%VJ?C($O^!!V7/G%J%@&7LJQ#AT +M@D9HW#X-T*ZG:$2TD^TX81HDFOQH/CT[FO=F1_/W94?SP>QH +MDG68#V5'LYP=V8[^8'8TGYP=U:Y/RX[FT[*C^>CL:#XJ.V90&X.;WN#D[:7. +MDN05M75P3\BB]TMC35XSGY#7S#^2U\SEO&86\YJI0F5F<\6\EIO4M_*:N9K7 +MS"?E-?.[Y#5S-:^9H!E;Y#7-I8Z[.J]Q1*%S3^BNG"95J6ZK)J'.=J=KHB\&>5?B&4OS].,0#?8Y[H-TW-=F2[E!N>;2,YM8UV3+YOC*W._3VV?-636FS[>8L-H#%X"Z=G@Y/+WL55[_R]ND?4>/&%+#^8AG>E +MB['J?HU:M7PK5NA3CT)NR%*[%Z6/HF93(Y=\1J=C[47#D"\*551#E\IZZ]1U +MU4WUZG9-M5QQOYZZ74%KE2$U(A,V!)JB7,@GY8A.J8F1!O]<_K_$MY86Z0V!191>T?T=1[?PM1/6` +M*SCW&:[S#5=PC(](U#]3']K;T-KIMMK=SNZ#KN`8[T+M"MO01`=J=EO?<(7V +M-E:HA;[+MM5I9OK^P0LPSN66%SJ+[5RXN7GS_L--O_?J\OCR?VYNX.41[*XOISO6=C-S[!^P +MD*4[^9.W9R<_WZ#=&JV5T7>G.SR*YX-LXN)X,/AX:E2X."/#F`TKA>G!V^/3 +M\X]Z6C%6*:!]U7L_>(NSZC,&FGF6M9?^A2&?+L>/H/)3]8>:UA>T&GO0VJ^C +MFNND6G@W'30JA^HP@,HXN/_P0"5A>]%Y^JHVV]JD(\^F,1#TX0`639Y]Z^>7 +M3U/;3X7Z(B#A$-]@:#K8<3M8BJ2JR-W$I98F'5?1J?1+=ORC=QJ-D1E\II.6 +M/@YOJ3:^\4:H&SPZ5+-[S<)XJ/Q7=?LI"6$5D#IZ>@B;6)P1>#3CQ,T=Z0T\ +M4R54CB_!HI$=TN2BC;>`9)*IEOK4WMG]O#(CRU.*0>X#4JIC^K'8-UY3.S7$ +MHE&&$P'Z3,37;?9P2AW'A@+<(B1D\]'LAF[D2+W<23@L3&BJ<:HT/!).*&ET +MD$88_3Y@""S-#ST2<&6K-"C'PO=74*59P[.`?3%$H\OY7MEYEO"/%@D?80TD +M)\:B3L'4&*L18^TQ%-E116R-X8Q%$[!J2)^UNM]Z(N`J.#'@+'*RX!4+M8R+H_8 +MW-6;KHK4WU("8\"A:N'B81:$I +M,RAJD[03+5O0TD42%HZ2BV"5PMWL8XD`57B_E65<8%$(<"H^EG?,6U&L#7@?)OKKPMP5@E`MT,F. +M[W,I`^)1>286GQ#*.R]2+8%A&M,IDRKC+*EOZ(J!+J.8SOQJV=`97)=]$/KD +M9,G\4,TM$C2M^]3:58U-A0T91,.F"1ZD"SWO4*!9S-Q;\RQ` +MRF7/8GRI\EE,%(N?PDYKZI^(B2+CG.&B:O,1D?G$I@\5N-EHPX?>*30S$;,2 +ME5$5XW*FDE*)!`]GVSRU%D)8'E'J+]=DO;\BZ97W5G/#0@#^6\9?]D8$TVKE[?F[,R113;:4.61S_?,WU):N9!?&*P!T +M`;`T6T`]>'O6[^.P3'51K^:U"ZL.S+;5WLG_Y\%W)+AHX_>1O0KS:.+7-F3V +M]ZW.P4XN_3Q,K76*0MA1]6RK6*UR<5NH*PJA.[^_5)!K8A8&+?CM-X;(OL[! +MPI=C<35:L*TC[,J`^BI`W;1J[FF7FN[3=':LSO9"94_D7)7O2-``` +` +end + diff --git a/doc/Changelog b/doc/Changelog new file mode 100644 index 00000000..557aef00 --- /dev/null +++ b/doc/Changelog @@ -0,0 +1,729 @@ +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 Sun Apr 11 11:28:55 CEST 2010 + +sysvinit (2.87dsf) world; urgency=low + + * Fix typos and do minor updates in the manual pages. + * Correct section of mountpoint(1). + * Document -e and -t options for telinit in init(8). + * Update address of FSF in the COPYRIGHT file. + * Document in halt(8) that -n might not disable all syncing. + Patch by Bill Nottingham and Fedora + * Adjust output from "last -x". In reboot lines, print endpoint + of uptime too. In shutdown lines print downtimes rather than + the time between downs. Fix typo in string compare in last.c. + Patch by Thomas Hood. + * Improve handling of IPv6 addresses in last. Patch from Fedora. + * Document last options in usage information, previously only + mentioned in the manual page. + * Add new option -F to last, to output full date string instead + of the short form provided by default. Patch from Olaf Dabrunz + and SuSe. + * Adjust build rules to make sure the installed binaries + are stripped. + * Increase the compiler warning level when building. + * Fix utmp/wtmp updating on 64-bit platforms. Patch by Bill + Nottingham and Fedora. + * Avoid unchecked return value from malloc() in utmpdump. + Patch from Christian 'Dr. Disk' Hechelmann and Fedora. + * Make sure to use execle and no execl when passing environment to + the new process. Patch from RedHat. + * Correct init to make sure the waiting status is preserved across + re-exec. Patch from RedHat. + * Correct init to avoid race condition when starting programs during + boot. Patch from SuSe. + * Allow 'telinit u' in runlevels 0 and 6. Patch from Thomas Hood. + * Change install rules to make pidof an absolute symlink. Patch from + Thomas Hood. + * Improve error message from init if fork() fail. Patch found in Suse. + * Add support for SE Linux capability handling. Patch from Manoj + Srivastava, adjusted to avoid aborting if SE policy was loaded in + the initrd with patch from Bill Nottingham and Fedora. + * Add -c option to pidof for only matching processes with the same + process root. Ignore -c when not running as root. Patch from + Thomas Woerner and Fedora. + * Adjust init to terminate argv0 with one 0 rather than two so that + process name can be one character longer. Patch by Kir Kolyshkin. + * Make sure bootlogd exit with non-error exit code when forking of + the child successfully. + * Add bootlogd option -s to make it possible to control the use of + fdatasync(). Patch from Thomas Hood. + * Add bootlogd option -c to tell it to create the log file if it does + not exist. Patch from Thomas Hood. + * Let bootlogd also look at ttyB* devices to work on HPPA. Patch + from Thomas Hood. + * Change init to use setenv() instead of putenv, make sure the PATH + value is usable on re-exec. Patch from Thomas Hood. + * Add usleep in killall5 after killing processes, to force the kernel + to reschedule. Patch from SuSe. + * Modify pidof to not print empty line if no pid was found. + * Modify init and sulogin to fix emergency mode's tty, making sure ^C + and ^Z work when booting with 'emergency' kernel option. Patch from + Samuel Thibault. + * Modify init to allow some time for failed opens to resolve themselves. + Patch from Bill Nottingham and Fedora. + * Modify init to shut down IDE, SCSI and SATA disks properly. Patches + from Sebastian Reichelt, Werner Fink and SuSe. + * Modify wall to use UT_LINESIZE from instead of hardcoded + string lengths. Patch from SuSe. + * Change wall to make halt include hostname in output. + * Change killall to avoid killing init by mistake. Patch from SuSe. + * Change killall5 to use the exit value to report if it found any + processes to kill. Patch from Debian. + * Add option -o opmitpid to killall5, to make it possible to skip + some pids during shutdown. Based on patch from Colin Watson and + Ubuntu. + * Add references between killall5 and pidof manual pages. Patch from Debian. + * Modify killall to work better with user space file system, by + changing cwd to /proc when stopping and killing processes, and + avoiding stat() when the value isn't used. Also, lock process + pages in memory to avoid paging when user processes are stopped. + Patch from Debian and Goswin von Brederlow with changes by Kel + Modderman. + * Change shutdown to only accept flags -H and -P with the -h flag, + and document this requirement in the manual page. + * Change reboot/halt to work properly when used as a login shell. + Patch by Dale R. Worley and Fedora. + * Let sulogin fall back to the staticly linked /bin/sash if both roots + shell and /bin/sh fail to execute. + + -- Petter Reinholdtsen Sun, 12 Jul 2009 19:58:10 +0200 + +sysvinit (2.86) cistron; urgency=low + + * Fixed up bootlogd to read /proc/cmdline. Also keep an internal + linebuffer to process \r, \t and ^H. It is becoming useable. + * Applied trivial OWL patches + * Block signals in syslog(), since syslog() is not re-entrant + (James Olin Oden , redhat bug #97534) + * Minor adjustements so that sysvinit compiles on the Hurd + * killall5 now skips kernel threads + * Inittab entries with both 'S' and other runlevels were broken. + Fix by Bryan Kadzban + * Changed initreq.h to be more flexible and forwards-compatible. + * You can now through /dev/initctl set environment variables in + init that will be inherited by its children. For now, only + variables prefixed with INIT_ can be set and the maximum is + 16 variables. There's also a length limit due to the size + of struct init_request, so it should be safe from abuse. + * Option -P and -H to shutdown set INIT_HALT=POWERDOWN and + INIT_HALT=HALT as environment variables as described above + * Add "mountpoint" utility. + * Slightly better algorithm in killall5.c:pidof() + * Added some patches from fedora-core (halt-usage, last -t, + sulogin-message, user-console) + + -- Miquel van Smoorenburg Fri, 30 Jul 2004 14:14:58 +0200 + +sysvinit (2.85) cistron; urgency=low + + * Add IPv6 support in last(1) + * Sulogin: even if the root password is empty, ask for a password- + otherwise there is no way to set a timeout. + * Removed support for ioctl.save. + * Turned of support for /etc/initrunlvl and /var/run/initrunlvl + * Fixed warts in dowall.c ("Dmitry V. Levin" ) + * Fix init.c::spawn(). The "f" variable was used both as file descriptor + and waitpid(2) return code. In certain circumstances, this leads to + TIOCSCTTY with wrong file descriptor (Vladimir N. Oleynik). + * Fix fd leak in sulogin (Dmitry V. Levin). + * More error checking in all wait() calling code (Dmitry V. Levin). + * Fix argv[] initialization in spawn() (Dmitry V. Levin). + * Change strncpy to strncat in most places (Dmitry V. Levin). + + -- Miquel van Smoorenburg Tue, 15 Apr 2003 16:37:57 +0200 + +sysvinit (2.84) cistron; urgency=low + + * Don't use /etc/initlvl interface for telinit; only use /dev/initctl, + and give a clear error when that fails. + * Add -i/--init command line flag to init - this tells init + 'behave as system init even if you're not PID#1'. Useful for + testing in chroot/jail type environments. + + -- Miquel van Smoorenburg Tue, 27 Nov 2001 13:10:08 +0100 + +sysvinit (2.83) cistron; urgency=low + + * Fix bug in shutdown where it didn't check correctly for a + virtual console when checking /etc/shutdown.allow + * Fix race condition in waitpid() [Andrea Arcangeli] + * Call closelog() after openlog()/syslog() since recent libc's + keep the logging fd open and that is fd#0 aka stdin. + + -- Miquel van Smoorenburg Tue, 2 Oct 2001 23:27:06 +0200 + +sysvinit (2.82) cistron; urgency=low + + * Print out correct version number at startup. + * Fix spelling of initttab in init(8) + + -- Miquel van Smoorenburg Thu, 23 Aug 2001 17:50:44 +0200 + +sysvinit (2.81) cistron; urgency=low + + * Fix typo/bug in killall5/pidof, -o option failed to work since 2.79. + Reformatted source code to prevent this from happening again. + * shutdown.8: applied redhat manpage update + * sulogin: applied redhat sysvinit-2.78-sulogin-nologin.patch + * sulogin: applied redhat sysvinit-2.78-notty.patch + * sulogin: applied redhat sysvinit-2.78-sigint.patch + +sysvinit (2.80) cistron; urgency=low + + * Grammar/spelling fixes in shutdown.c (Christian Steinrueck) + * Don't set controlling tty for non-(sysinit,boot,single) runlevels + + -- Miquel van Smoorenburg Thu, 26 Jul 2001 13:26:56 +0200 + +sysvinit (2.79) cistron; urgency=low + + * New upstream version + * several fixes to wall by Tim Robbins + * Several extra boundary checks by Solar Designer + * Make /dev/console controlling tty + * Stricter checks on ownership of tty by mesg(1) + * Documented and restricted -n option to wall(1) + * Make it compile with glibc 2.2.2 + * Document IO redirection in wall manpage (closes: #79491) + * Update README (closes: #85650) + * Fix init.8 manpage (closes: #75268) + * Fix typo in halt(8) manpage (closes: #67875) + * Check time argument of shutdown(8) for correctness (closes: #67825) + * Check for stale sessions in last(1) (Chris Wolf ) + + -- Miquel van Smoorenburg Wed, 4 Jul 2001 15:04:36 +0200 + +sysvinit (2.78-2) frozen unstable; urgency=high + + * Change "booting" to "reloading" message at reload + * Add "-z xxx" dummy command line argument (closes: #54717) + + -- Miquel van Smoorenburg Fri, 11 Feb 2000 12:17:54 +0100 + +sysvinit (2.78-1) unstable; urgency=low + + * 2.78 will be the new upstream version, I'm skipping 2.77 + * Shutdown now calls sync before switching the runlevel to 0 or 6, + or before unmounting filesystems if -n was used (closes: #46461) + * Some cosmetic changes to init.c (closes: #32079) + + -- Miquel van Smoorenburg Thu, 30 Dec 1999 20:40:23 +0100 + +sysvinit (2.77-2) unstable; urgency=low + + * Fix last -i option + + -- Miquel van Smoorenburg Tue, 5 Oct 1999 21:51:50 +0200 + +sysvinit (2.77-1) unstable; urgency=low + + * Write reboot record into utmp file as well to make rms happy + * Fork and dump core in / if SIGSEGV is received for debugging purposes + * Patch by Craig Sanders for "last" -i option + + -- Miquel van Smoorenburg Wed, 4 Aug 1999 11:16:23 +0200 + +sysvinit (2.76-4) unstable; urgency=low + + * Change dowall.c to handle Unix98 ptys correctly + * Add comment in rcS about usage of setup.sh and unconfigured.sh + * Shutdown now removes nologin file just before calling telinit + * SEGV handler now tries to continue after sleep of 30 seconds. + On a 386-class processor it also prints out the value of EIP. + * Fix for racecondition in check_init_fifo() by Richard Gooch + + -- Miquel van Smoorenburg Sat, 8 May 1999 17:22:57 +0200 + +sysvinit (2.76-3) frozen unstable; urgency=high + + * Small bugfix to last.c courtesy of Danek Duvall + + -- Miquel van Smoorenburg Tue, 12 Jan 1999 12:12:44 +0100 + +sysvinit (2.76-1) frozen unstable; urgency=high + + * Fix bug in check_pipe() which crashes init on the Alpha. + + -- Miquel van Smoorenburg Tue, 3 Nov 1998 11:09:13 +0100 + +sysvinit (2.75-4) unstable; urgency=low + + * Change sulogin password buffer to 128 characters. + * Don't print control characters in dowall.c + * Try to open getenv ("CONSOLE"), /dev/console and /dev/tty0 in order. + For backwards compatibility when you try to boot a 2.0.x kernel + with a linux > 2.1.70 /dev/console device. + * Change src/Makefile for non-debian systems (mainly, RedHat) + * Try to create /dev/initctl if not present; check every time to see + if the dev/ino of /dev/initctl has changed and re-open it. This should + help devfs a bit. + * Send SIGUSR1 to init at bootup to let it re-open /dev/initctl; + again in support of devfs. + * Moved pidof to /bin (it's only a link to killall5 anyway) + + -- Miquel van Smoorenburg Mon, 5 Oct 1998 14:03:14 +0200 + +sysvinit (2.75-2) frozen unstable; urgency=medium + + * Fix last.c again. + * Add check to see if /dev/initctl is really a FIFO + * In ifdown.c first down all shaper devices then the real devices + + -- Miquel van Smoorenburg Tue, 2 Jun 1998 22:43:01 +0200 + +sysvinit (2.75-1) frozen unstable; urgency=low + + * Rewrote last.c to be much more memory friendly and correct, + thanks to Nick Andrew and + David Parrish + * Fixes bugs: + #21616: sysvinit: sulogin thinks md5 root password is bad + #21765: sysvinit: Typo in `killall5.c' + #21775: sysvinit: sysvinit does not support MD5 hashed passwords + #21990: /usr/bin/last: unnecessary memset and off-by-one bug + #22084: sysvinit 2.74-4: SIGPWR missing on sparc + #21900: init, powerfail events, and shutdown.allow + #21702: init 0 does not work as expected... + #21728: sysvinit: Typo in `init.c' + #22363: sysvinit: discrepance btw. manpage and /sbin/init + + -- Miquel van Smoorenburg Tue, 19 May 1998 11:02:29 +0200 + +sysvinit (2.74-4) frozen unstable; urgency=medium + + * Add -o option to last to process libc5 utmp files. + * Buffer overflow fixed in init.c (not very serious; only exploitable + by root). Thanks to Chris Evans + + -- Miquel van Smoorenburg Wed, 15 Apr 1998 17:04:33 +0200 + +sysvinit (2.74-1) unstable; urgency=low + + * Should compile with glibc 1.99 :) + * Change behaviour of reboot(1) and halt(1) so that the default when + the runlevel can't be determined is to call shutdown. + * Added re-exec patch from Al Viro (21 Feb 1998): + 'U' flag added to telinit. It forces init to re-exec itself + (passing its state through exec, certainly). + May be useful for smoother (heh) upgrades. + 24 Feb 1998, AV: + did_boot made global and added to state - thanks, Miquel. + Yet another file descriptors leak - close state pipe if + re_exec fails. + + -- Miquel van Smoorenburg Thu, 12 Mar 1998 17:42:46 +0100 + +sysvinit (2.73-2) unstable; urgency=low + + * Change _NSIG to NSIG for 2.1.x kernel includes. + + -- Miquel van Smoorenburg Thu, 8 Jan 1998 16:01:02 +0100 + +sysvinit (2.73-1) unstable; urgency=low + + * Use siginterrupt, now that system calls are restarted by default. + Main symptom was that the sulogin timeout didn't work but there + might have been more hidden problems. + * Kill process immidiately if turned off in inittab + * Fixed sulogin check on tty arg. + * Use strerror() instead of sys_errlist + * wall now supports a '-n' option to suppress [most of] the banner. + Debian doesn't use sysvinit's wall, but apparently Redhat does. + * Add '-F' (forcefsck) option to shutdown + * Close and reopen /dev/initctl on SIGUSR1 (mainly for a /dev in ram) + + -- Miquel van Smoorenburg Sat, 3 Jan 1998 16:32:39 +0100 + +sysvinit (2.72-3) unstable; urgency=low + + * Add extra fork() in dowall.c to avoid hanging in rare cases + + -- Miquel van Smoorenburg Wed, 22 Oct 1997 14:44:00 +0200 + +sysvinit (2.72) unstable; urgency=low + + * Applied manual page patches by Bill Hawes . Thanks Bill! + * Applied patches to the sample Slackware scripts by + "Jonathan I. Kamens" + * Fix halt and reboot runlevels 0 & 6 check. + * Only say "no more processes left in runlevel x" once + * Fix race condition with SIGCHLD in spawn() + (thanks to Alon Ziv ) + * Compress all manpages (missed 2) + * Compiled for libc6 + * Added poweroff patch by Roderich Schupp + + -- Miquel van Smoorenburg Sun, 12 Oct 1997 17:20:17 +0200 + +sysvinit (2.71-2) frozen unstable; urgency=low + + * Print 2.71 instead of 2.70 on startup :) + + -- Miquel van Smoorenburg Mon, 5 May 1997 12:45:25 +0200 + +sysvinit (2.71-1) frozen unstable; urgency=high + + * Added code for updwtmp() in utmp.c for glibc (2.0.3) + * Fixed all programs to use functions from utmp.c and getutent() + * Do not try to clean up utmp in init itself (Bug#9022) + * Removed sync() from main loop. + * Hopefully fixes bug #8657 (shutdown signal handling) + + -- Miquel van Smoorenburg Sat, 26 Apr 1997 19:57:27 +0200 + +sysvinit (2.70-1) unstable; urgency=low + + * Respawn fix + * Removed StUdLy CaPs from source code + * Moved files in source archive around + * Fixes for glibc (utmp handling, signal handling). + * Fixed '-d' option to last (now also works without '-a'). + * Added extra checking in last.c to prevent showing dead entries + + -- Miquel van Smoorenburg Fri, 7 Feb 1997 15:31:30 +0100 + +sysvinit (2.69-1) frozen unstable; urgency=medium + + * Fixed bug that can throw X in a loop (or any other app that reads from + /dev/tty0) + + -- Miquel van Smoorenburg Sun, 1 Dec 1996 15:32:24 +0100 + +sysvinit (2.67-1) frozen unstable; urgency=high + + * Fixes problem with /dev/console being controlling terminal of some + daemons + * Puts copyright file in the right place + + -- Miquel van Smoorenburg Fri, 15 Nov 1996 12:23:33 +0100 + +sysvinit (2.66-1) unstable; urgency=medium + + * Skipped 2.65. A development 2.65 got out by accident and is apparently + being used.. + * Also compiles and runs with GNU libc (and on the Alpha) + * Fixed dowall.c not to exit when getpwuid() fails and uid == 0. + * Fixed init panic'ing on empty lines in /etc/inittab + * Changed default PATH to include /usr/local/sbin + * Set /dev/console as controlling terminal for sysinit,bootwait,wait,powerwait + This allows using ^C to interrupt some parts of eg the boot process. + * Remove old symlink in /var/log/initlvl; let init check both + /var/log and /etc itself. + + -- Miquel van Smoorenburg Tue, 29 Oct 1996 13:46:54 +0100 + +2.66 29-Oct-1996 +- Skipped 2.65. A development 2.65 got out by accident and is apparently + being used.. +- Fixed dowall.c not to exit when getpwuid() fails and uid == 0. +- Fixed init panic'ing on empty lines in /etc/inittab +- Changed default PATH to include /usr/local/sbin +- Ported to Linux/Alpha and GNU libc. +- Set /dev/console as controlling terminal for sysinit,bootwait,wait,powerwait. + This allows using ^C to interrupt some parts of eg the boot process. +- Remove old symlink in /var/log/initlvl; let init check both + /var/log and /etc itself. + +2.64 28-Jun-1996 +- Init checks CONSOLE environment variable on startup (overrides /dev/console) +- Init sets CONSOLE variable for all its children. +- Wtmp(): when zeroing out old utmp entries, keep ut_id field +- Wtmp(): try to re-use ut_id field if possible. +- SetTerm(): only read from /etc/ioctl.save if written once. +- Included start-stop-daemon, C version (source only). +- Fixed wait() for the emergency shell. +- killall5: ignore signal before doing kill(-1, pid). + +2.63 14-Jun-1996 +- Fixed preinst script for Debian +- Fixed init.c to become init daemon if name is init.new +- Fixed pidof to not return PIDs of shell scripts + +2.62-2 09-Jun-1996 +- Changed debian /etc/init.d/boot script to create a nologin file + at boot and to remove it just before going multiuser. + +2.62 31-May-1996 +- Decided to release a 2.62 version with a BIG WARNING about upgrading + init in it. Will send a patch to Linus for the linux/Documentation/Changes + file so that 2.62 or later is mentioned as the version to upgrade to. +- Added docs for Slackware + +2.61-3 29-May-1996 +- Fixed debian/etc/init.d/network for the lo device. +- Added "-xdev" to the cd /tmp && find in debian/etc/init.d/boot +- Made remove time for files in /tmp configurable. + +2.61 29-Apr-1996 +- Changed /etc/init.d/boot script again +- Fixed problem in init.c with trailing whitespace after entries in inittab +- Fixed killall5 problems +- Added manpage for lastb +- Added SHELL= environment variable to sulogin +- Fixed sulogin & shadow problems +- Added timeout option to sulogin + +2.60-2 16-Apr-1996 +- Fixed sulogin (didn't work if root wasn't first entry in shadow file) +- Fixed mesg for systems with "tty" group (such as Debian) +- Fixed nsyslog() in killall5.c + +2.60 01-Apr-1996 +- Fixed race condition in init.c, resulting in hanging shutdowns. + Courtesy of Max Neunhoeffer . +- Fixed debian/etc/init.d/boot for swapon and mdadd +- Added architecture to debian.control +- Added manpages for rc.boot and rc.local +- Updated inittab manpage for 4-character runlevel field +- Added debian replaces for bsdutils < version_without_mesg +- Fixed init.c so that it also works with kernels 1.3.81 and up + +2.59 10-Mar-1996 +- Init logs less to syslog (suspected to hang in syslog() or openlog() ) +- removed closelog() from init.c +- removed time check of runlevel record in halt. +- Added options to last to get hostname from ut_addr field +- Added last and mesg to installation targets +- rewrote /etc/init.d/boot a bit. + +2.58-2 04-Jan-1996 +- Changed etc/init.d/rc to do a stty onlcr +- Added /var/log/initrunlvl symlink + +2.58-1 31-Dec-1995 +- Added the latest debian files. +- Added support for 4-character id fields (if you have libc5). +- Fixed pidof (in killall5) parsing of /proc/.../stat +- Save restore GMT setting in /etc/init.d/boot + +2.57d 03-Dec-1995 +- Added sulogin +- Added "-b" flag to init, gives a shell before + anything else (in case the startup scripts are screwed) +- Moved fastboot to /fastboot +- Folded in Debian patches. +- Removed old scripts +- Added debian /etc/directory. + +2.57c 08-Oct-1995 +- Changed over to init_request (with initreq.h) +- Processes no longer killed when "process" field + changes, change takes effect after next respawn. + +2.57b xx-Aug-1995 +- Bugfix release for Debian and Slackware 3.0 + +2.57a 10-Jul-1995 +- Fixed race condition init init.c wrt got_chld +- Fixed one-off for malloc in killall5.c +- Changed dowall.c +- Console code: no relink to /dev/systty on CTRL-ALT-DEL) + +2.57 22-May-1995 +- Changed a few things here and there, didn't + really document it :) + +2.55 17-Jan-1995 +- Added option to shutdown to run standalone. + +2.54 12-Jan-1995 +- Added GNU copyrigh to all *.[ch] files. +- added /etc/initscript +- reboot and halt now call shutdown in runlevels 1-5 +- Can run from read-only root (CDROM) + +2.53 10-Oct-1994 +- Renamed pidof to killall5, updated all scripts to + use killall5 instead of kill -1 .... +- Rewrote scripts to use this, and some general changes. +- Added SysV command line compatibility to shutdown. + +2.52 30-Aug-1994 +- Added `powerfailnow' keyword, for when UPS battery is low. +- Updated `last'. +- Fixed utmp handling (wrt. CLEAN_UTMP) +TODO: +* Make last compatible with GNU/BSD (long options?) +* update powerd +* remote SIGPWR broadcast? in powerd? (with priv. port) +* remote shutdown + +2.50 14-Feb-1994 +- Ignores unknown command line arguments. +- Modelled more after the "real" sysVinit +- Lots of changes all over the place. + (like showing runlevel in "ps" listing, logging + runlevel into utmp file etc) +- now using "reliable" signals instead of V7 style. +- Updated all scripts. Examples are in two directories: + etc (normal) and etc-sysv (sysv style scripts). +- runlevel 0 = halt, 1 = single user, 6 = reboot. +- added support for serial console. +- updated Propaganda, manpages. +- added shutdown access control. + +2.4 24-May-93 +- Send out the official version into the world as + SysVinit-2.4.tar.z. + +2.4g 15-May-93 +- Changed init to really catch SIGPWR 'cause we + hooked up an UPS to the Linux machine. The + keyword for catching the TreeFingerSalute is + now "ctrlaltdel" instead of "power{wait,fail}". + +2.4a 22-Apr-93 +- Fixed last to reckognize BSD style wtmp logging. +- Changed init to write wtmp records that are + SysV compliant but are also reckognized by the + BSD last. Added a '+' option to the 'process' + field of inittab, for getties that want to do + their own utmp/wtmp housekeeping (kludge!). +- Now accepts a runlevel on the command line, + and reckognizes the 'auto' argument. (Sets the + environment variable AUTOBOOT to YES) + +2.2.3 24-Mar-93 +- Ripped out the 'leave' action. To difficult, and + unneeded. +- Going single user now kills _all_ processes. +- Added '-t secs' option to all commands. +- This version is stable enough to post. + +2.2 02-Mar-93 +- Made wait()'s asynchronous +- Changed whole thing to one big state machine +- Now using 'pseudo levels' # & * for SYSINIT & BOOT +- Added a new type of 'action', called leave. This + process will be executed when the system goes from a + runlevel specified in it's runlevel field to a + level that's not. Nice to bring down NFS and the like. + +2.1 28-Jan-93 +- Fixed a bug with 'boot' and 'once'. +- Check 'initdefault' for validity. +- Reckognizes "single" as command line argument. +- Retries execvp with 'sh -c exec ..' if command + is a shell script. (shouldn't execvp do this?) +- Added patches to use syslog if defined. + +2.0 08-Dec-92 +- Rewrote the code totally, so started with a new + version number. +- Dropped Minix support, this code now is Linux - specific. +- With TEST switch on, this init & telinit can + run standalone for test purposes. + +1.3, 05-Jul-92 +- Got a 386, so installed Linux. Added 'soft' reboot + to be default under linux. Fixed some typos. + +1.2, 16-Jun-92 +- Bugreport from Michael Haardt ; removed deadlock + and added 'waitpid' instead of 'wait' for SYSV. + +1.1, 30-Apr-92 +- Read manual wrong: there is no 'action' field called + process, but all entries are of type process. Every + 'process' get exec'ed by /bin/sh -c 'exec command'. +- Rapidly respawning processes are caught in the act. +- _SYSV support is really Linux support, + done by poe@daimi.aau.dk on 25-Mar-92. + + 1.0, 01-Feb-92 +- Initial version, very primitive for the Minix + operating system. Required some mods. to the + kernel. + diff --git a/doc/Install b/doc/Install new file mode 100644 index 00000000..05f23a29 --- /dev/null +++ b/doc/Install @@ -0,0 +1,56 @@ + + README for the System V style init, version 2.86 + +init, shutdown, halt, reboot, wall, last, mesg, runlevel, +killall5, pidof, sulogin. + +All programs, files and scripts in this package are covered by +the Gnu Public License, and copyrighted by me. + +If you are not using Debian and the debianized package, +you will have to install the new init by hand. You should +be able to drop the binaries into a Slackware or Redhat +system, I think. + +Here is a list of preferred directories to install the progs & manpages: + +wall.1, last.1, mesg.1 /usr/man/man1 +inittab.5, initscript.5 /usr/man/man5 +init.8, halt.8, reboot.8, +shutdown.8, powerd.8, +killall5.8, pidof.8, +runlevel.8, sulogin.8 /usr/man/man8 + +init /sbin/init +inittab /etc/inittab +initscript.sample /etc/initscript.sample +telinit a link (with ln(1) ) to init, either + in /bin or in /sbin. +halt /sbin/halt +reboot a link to /sbin/halt in the same directory +killall5 /sbin/killall5 +pidof a link to /sbin/killall5 in the same directory. +runlevel /sbin/runlevel +shutdown /sbin/shutdown. +wall /usr/bin/wall +mesg /usr/bin/mesg +last /usr/bin/last +sulogin /sbin/sulogin +bootlogd /sbin/bootlogd +utmpdump don't install, it's just a debug thingy. + +If you already _have_ a "wall" in /bin (the SLS release had, for example) +do _not_ install this wall. Chances are that the wall you are already +using is linked to /bin/write. Either first _remove_ /bin/wall before +installing the new one, or don't install the new one at all. + +You might want to create a file called "/etc/shutdown.allow". Read the +manual page on shutdown to find out more about this. + +Running from a read-only file system (CDROM?): +o All communication to init goes through the FIFO /dev/initctl. + There should be no problem using a read-only root file system + IF you use a Linux kernel > 1.3.66. Older kernels don't allow + writing to a FIFO on a read-only file system. + +Miquel van Smoorenburg diff --git a/doc/Propaganda b/doc/Propaganda new file mode 100644 index 00000000..072aa13b --- /dev/null +++ b/doc/Propaganda @@ -0,0 +1,81 @@ + + + Propaganda for version 2.58 of sysvinit & utilities + ================================================== + +NOTE: If you use a standard distribution like Slackware, Debian +or Redhat there probably is no need to upgrade. Installing sysvinit +is only for those that upgrade their system by hand or for people +that create Linux distributions. + +Sysvinit is probably the most widely used init package for Linux. +Most distributions use it. sysvinit 2.4 is really a good package, +and it was not the need for bugfixes but the need for more features +that made me work on sysvinit again. + +Sysvinit is now a debian package. Debian source packages are not +special in any way -- in fact you can just unpack and compile +it on any other Linux distribution. + +There was a 2.50 release of sysvinit but that was not very popular- +some of the included scripts broke with certain shells and other +minor things like that. Unfortunately I was not able to fix this +at the time because I was abroad for some time. Therefore the +description below is a comparison of 2.4 and 2.58 (actually the +same blurb as from the 2.50 announce but updated). + +Wrt 2.4, some of the code has been made simpler. Everything, from +halt to reboot to single user mode is now done by shell scripts +that are executed directly by init (from /etc/inittab), so shutdown +does not kill processes anymore and then calls reboot - it merely +does some wall's to the logged in users and then switches to +runlevel 0 (halt), 1 (single user) or 6 (reboot). + +I have removed support for the old style scripts; the included +example scripts are the Debian GNU/Linux distribution scripts. +This does not mean that eg the Slackware scripts stop to work; +you can probably drop this init into Slackware 3.0 without problems. + +Most people have an entry in inittab to run shutdown when CTRL-ALT-DEL +is pressed; a feature has been added to shutdown to check if a +authorized user is logged in on one of the consoles to see if a +shutdown is allowed. This can be configured with an access file. + +Some other general changes: +- utility "runlevel" to read the current and previous runlevel from + /var/run/utmp (it's also shown on the command line if you do a "ps"). +- unreckognized options are silently ignored (such as the infamous + "ro" - mount root file system read only). +- if the file /etc/initscript is present it will be used to launch + all programs that init starts (so that you can set a generic + umask, ulimit eg for ALL processes - see initscript.sample). +- A "sulogin" program added that always asks for the root + passsword before entering single user mode. +- A "-b" flag to init that starts a shell at boot time before + _any_ other processing. +- I moved /etc/fastboot to /fastboot - wonder what that's gonna break :) +- I even updated the manpages! + +Right, now some boring stuff you already know since it's the same +as in the 2.4 release: + +The sysvinit package includes + +* a sysv compatible /sbin/init program +* a telinit program (er, just a link to /sbin/init) to change runlevels +* a featureful shutdown +* halt and reboot to assist shutdown +* a very forgiving last utility +* the wall & mesg programs (not installed by default) +* manpages for everything + +The new sysv init can be found on: + +tsx-11.mit.edu:/pub/linux/sources/sbin as sysvinit-2.58-1.tar.gz +sunsite.unc.edu:/pub/Linux/system/Daemons as sysvinit-2.58-1.tar.gz + +It will be moved there in a few days, in the mean time it is +probably in the Incoming directory. + +Mike. (02-Jan-1996) + diff --git a/doc/bootlogd.README b/doc/bootlogd.README new file mode 100644 index 00000000..52f96388 --- /dev/null +++ b/doc/bootlogd.README @@ -0,0 +1,19 @@ + +bootlogd: a way to capture all console output during bootup + in a logfile. + +- bootlogd opens /dev/console and finds out what the real console is + with an ioctl() if TIOCCONS is available +- otherwise bootlogd tries to parse /proc/cmdline for console= + kernel command line arguments +- then opens the (most probable) real console +- allocates a pty pair +- redirects console I/O to the pty pair +- then goes in a loop reading from the pty, writing to the real + console and a logfile as soon as a r/w partition is available, + buffering in memory until then. + +As soon as bootlogd exits or gets killed, the pty is closed and the +redirection will be automatically undone by the kernel. So that's +pretty safe. + diff --git a/doc/sysvinit-2.86.lsm b/doc/sysvinit-2.86.lsm new file mode 100644 index 00000000..3b985a54 --- /dev/null +++ b/doc/sysvinit-2.86.lsm @@ -0,0 +1,14 @@ +Begin3 +Title: sysvinit and utilities +Version: 2.86 +Entered-Date: 30JUL2004 +Description: This is the Linux System V init. + This version can be compiled with glibc 2.0.6 and up. +Author: miquels@cistron.nl (Miquel van Smoorenburg) +Primary-Site: ftp.cistron.nl /pub/people/miquels/software + 92K sysvinit-2.86.tar.gz +Alternate-Site: sunsite.unc.edu /pub/Linux/system/daemons/init + 92K sysvinit-2.86.tar.gz +Copying-Policy: GPL +Keywords: init shutdown halt reboot +End diff --git a/man/bootlogd.8 b/man/bootlogd.8 new file mode 100644 index 00000000..cab345bc --- /dev/null +++ b/man/bootlogd.8 @@ -0,0 +1,72 @@ +'\" -*- 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 +.SH SYNOPSIS +.B /sbin/bootlogd +.RB [ \-c ] +.RB [ \-d ] +.RB [ \-r ] +.RB [ \-s ] +.RB [ \-v ] +.RB [ " -l logfile " ] +.RB [ " -p pidfile " ] +.SH DESCRIPTION +\fBBootlogd\fP runs in the background and copies all strings sent to the +\fI/dev/console\fP device to a logfile. If the logfile is not accessible, +the messages will be kept in memory until it is. +.SH OPTIONS +.IP \fB\-d\fP +Do not fork and run in the background. +.IP \fB\-c\fP +Attempt to write to the logfile even if it does not yet exist. +Without this option, +.B bootlogd +will wait for the logfile to appear before attempting to write to it. +This behavior prevents bootlogd from creating logfiles under mount points. +.IP \fB\-r\fP +If there is an existing logfile called \fIlogfile\fP rename it to +\fIlogfile~\fP unless \fIlogfile~\fP already exists. +.IP \fB\-s\fP +Ensure that the data is written to the file after each line by calling +.BR fdatasync (3). +This will slow down a +.BR fsck (8) +process running in parallel. +.IP \fB\-v\fP +Show version. +.IP "\fB\-l\fP \fIlogfile\fP" +Log to this logfile. The default is \fI/var/log/boot\fP. +.IP "\fB\-p\fP \fIpidfile\fP" +Put process-id in this file. The default is no pidfile. +.SH BUGS +Bootlogd works by redirecting the console output from the console device. +(Consequently \fBbootlogd\fP requires PTY support in the kernel configuration.) +It copies that output to the real console device and to a log file. +There is no standard way of ascertaining the real console device +if you have a new-style \fI/dev/console\fP device (major 5, minor 1) +so \fBbootlogd\fP parses the kernel command line looking for +\fBconsole=...\fP lines and deduces the real console device from that. +If that syntax is ever changed by the kernel, or a console type is used that +\fBbootlogd\fP does not know about then \fBbootlogd\fP will not work. + +.SH AUTHOR +Miquel van Smoorenburg, miquels@cistron.nl +.SH "SEE ALSO" +.BR dmesg (8), fdatasync (3). diff --git a/man/bootlogd.8.todo b/man/bootlogd.8.todo new file mode 100644 index 00000000..4f24cfc4 --- /dev/null +++ b/man/bootlogd.8.todo @@ -0,0 +1,52 @@ +'\" -*- 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 +.SH SYNOPSIS +.B /sbin/bootlogd +.RB [ \-d ] +.RB [ \-r ] +.RB [ \-v ] +.RB [ " -l logfile " ] +.RB [ " -p pidfile " ] +.SH DESCRIPTION +\fBBootlogd\fP runs in the background and copies all strings sent to the +\fI/dev/console\fP device to a logfile. If the logfile is not accessible, +the messages will be buffered in-memory until it is. +.SH OPTIONS +.IP \fB\-d\fP +Do not fork and run in the background. +.IP \fB\-r\fP +If there is an existing logfile called \fIlogfile\fP rename it to +\fIlogfile~\fP unless \fIlogfile~\fP already exists. +.IP \fB\-v\fP +Show version. +.IP \fB\-l logfile\fP +Log to this logfile. The default is \fI/var/log/boot.log\fP. +.IP \fB\-p pidfile\fP +Put process-id in this file. The default is no pidfile. +.SH NOTES +There is no standard way to find out the real console device if you have +a new-style \fI/dev/console\fP device (major 5, minor 1). \fBBootlogd\fP +might have some difficulties to do this, especially under very old +or very new kernels. +.SH AUTHOR +Miquel van Smoorenburg, miquels@cistron.nl +.SH "SEE ALSO" +.BR dmesg (8) diff --git a/man/fstab-decode.8 b/man/fstab-decode.8 new file mode 100644 index 00000000..6e800214 --- /dev/null +++ b/man/fstab-decode.8 @@ -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 +.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) diff --git a/man/halt.8 b/man/halt.8 new file mode 100644 index 00000000..8ae3c636 --- /dev/null +++ b/man/halt.8 @@ -0,0 +1,120 @@ +'\" -*- 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" +.\"}}} +.\"{{{ Name +.SH NAME +halt, reboot, poweroff \- stop the system. +.\"}}} +.\"{{{ Synopsis +.SH SYNOPSIS +.B /sbin/halt +.RB [ \-n ] +.RB [ \-w ] +.RB [ \-d ] +.RB [ \-f ] +.RB [ \-i ] +.RB [ \-p ] +.RB [ \-h ] +.br +.B /sbin/reboot +.RB [ \-n ] +.RB [ \-w ] +.RB [ \-d ] +.RB [ \-f ] +.RB [ \-i ] +.br +.B /sbin/poweroff +.RB [ \-n ] +.RB [ \-w ] +.RB [ \-d ] +.RB [ \-f ] +.RB [ \-i ] +.RB [ \-h ] +.\"}}} +.\"{{{ Description +.SH DESCRIPTION +\fBHalt\fP notes that the system is being brought down in the file +\fI/var/log/wtmp\fP, and then either tells the kernel to halt, reboot or +power-off the system. +.PP +If \fBhalt\fP or \fBreboot\fP is called when the system is +\fInot\fP in runlevel \fB0\fP or \fB6\fP, in other words when it's running +normally, \fBshutdown\fP will be invoked instead (with the \fB-h\fP +or \fB-r\fP flag). For more info see the \fBshutdown\fP(8) +manpage. +.PP +The rest of this manpage describes the behaviour in runlevels 0 +and 6, that is when the systems shutdown scripts are being run. +.\"}}} +.\"{{{ Options +.SH OPTIONS +.IP \fB\-n\fP +Don't sync before reboot or halt. Note that the kernel and storage +drivers may still sync. +.IP \fB\-w\fP +Don't actually reboot or halt but only write the wtmp record +(in the \fI/var/log/wtmp\fP file). +.IP \fB\-d\fP +Don't write the wtmp record. The \fB\-n\fP flag implies \fB\-d\fP. +.IP \fB\-f\fP +Force halt or reboot, don't call \fBshutdown\fP(8). +.IP \fB\-i\fP +Shut down all network interfaces just before halt or reboot. +.IP \fB\-h\fP +Put all hard drives on the system in stand-by mode just before halt or power-off. +.IP \fB\-p\fP +When halting the system, switch off the power. This is the default when halt is +called as \fBpoweroff\fP. +.\"}}} +.\"{{{ Diagnostics +.SH DIAGNOSTICS +If you're not the superuser, you will get the message `must be superuser'. +.\"}}} +.\"{{{ Notes +.SH NOTES +Under older \fBsysvinit\fP releases , \fBreboot\fP and \fBhalt\fP should +never be called directly. From release 2.74 on \fBhalt\fP and \fBreboot\fP +invoke \fBshutdown\fP(8) if the system is not in runlevel 0 or 6. This +means that if \fBhalt\fP or \fBreboot\fP cannot find out the current +runlevel (for example, when \fI/var/run/utmp\fP hasn't been initialized +correctly) \fBshutdown\fP will be called, which might not be what you want. +Use the \fB-f\fP flag if you want to do a hard \fBhalt\fP or \fBreboot\fP. +.PP +The \fB-h\fP flag puts all hard disks in standby mode just before halt +or power-off. Right now this is only implemented for IDE drives. A side +effect of putting the drive in stand-by mode is that the write cache +on the disk is flushed. This is important for IDE drives, since the +kernel doesn't flush the write cache itself before power-off. +.PP +The \fBhalt\fP program uses /proc/ide/hd* to find all IDE disk devices, +which means that \fI/proc\fP needs to be mounted when \fBhalt\fP or +\fBpoweroff\fP is called or the \fB-h\fP switch will do nothing. +.PP +.\"}}} +.\"{{{ Author +.SH AUTHOR +Miquel van Smoorenburg, miquels@cistron.nl +.\"}}} +.\"{{{ See also +.SH "SEE ALSO" +.BR shutdown (8), +.BR init (8) +.\"}}} diff --git a/man/init.8 b/man/init.8 new file mode 100644 index 00000000..d106a164 --- /dev/null +++ b/man/init.8 @@ -0,0 +1,313 @@ +'\" -*- 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" +.\"}}} +.\"{{{ Name +.SH NAME +init, telinit \- process control initialization +.\"}}} +.\"{{{ Synopsis +.SH SYNOPSIS +.B /sbin/init +.RB [ " -a " ] +.RB [ " -s " ] +.RB [ " -b " ] +[ \fB\-z\fP \fIxxx\fP ] +.RB [ " 0123456Ss " ] +.br +.B /sbin/telinit +[ \fB\-t\fP \fISECONDS\fP ] +.RB [ " 0123456sSQqabcUu " ] +.br +.B /sbin/telinit +[ \fB\-e\fP \fIVAR\fP[\fB=\fP\fIVAL\fP] ] +.\"}}} +.\"{{{ Description +.SH DESCRIPTION +.\"{{{ init +.SS Init +.B Init +is the parent of all processes. Its primary role is to create processes +from a script stored in the file \fB/etc/inittab\fP (see +\fIinittab\fP(5)). This file usually has entries which cause \fBinit\fP +to spawn \fBgetty\fPs on each line that users can log in. It also +controls autonomous processes required by any particular system. +.PP +.\"{{{ Runlevels +.SH RUNLEVELS +A \fIrunlevel\fP is a software configuration of the system which allows +only a selected group of processes to exist. The processes spawned by +\fBinit\fP for each of these runlevels are defined in the +\fB/etc/inittab\fP file. \fBInit\fP can be in one of eight runlevels: +\fB0\(en6\fP and \fBS\fP or \fBs\fP. The runlevel is +changed by having a privileged user run \fBtelinit\fP, which sends +appropriate signals to \fBinit\fP, telling it which runlevel to change +to. +.PP +Runlevels \fB0\fP, \fB1\fP, and \fB6\fP are reserved. Runlevel 0 is used to +halt the system, runlevel 6 is used to reboot the system, and runlevel +1 is used to get the system down into single user mode. Runlevel \fBS\fP +is not really meant to be used directly, but more for the scripts that are +executed when entering runlevel 1. For more information on this, +see the manpages for \fBshutdown\fP(8) and \fBinittab\fP(5). +.PP +Runlevels 7-9 are also valid, though not really documented. This is +because "traditional" Unix variants don't use them. +In case you're curious, runlevels \fIS\fP and \fIs\fP are in fact the same. +Internally they are aliases for the same runlevel. +.\"}}} +.PP +.SH BOOTING +After \fBinit\fP is invoked as the last step of the kernel boot sequence, +it looks for the file \fB/etc/inittab\fP to see if there is an entry of the +type \fBinitdefault\fP (see \fIinittab\fP(5)). The \fBinitdefault\fP entry +determines the initial runlevel of the system. If there is no such +entry (or no \fB/etc/inittab\fP at all), a runlevel must be +entered at the system console. +.PP +Runlevel \fBS\fP or \fBs\fP bring the system to single user mode +and do not require an \fB/etc/inittab\fP file. In single user mode, +\fB/sbin/sulogin\fP is invoked on \fB/dev/console\fP. +.PP +When entering single user mode, \fBinit\fP initializes the consoles +\fBstty\fP settings to sane values. Clocal mode is set. Hardware +speed and handshaking are not changed. +.PP +When entering a multi-user mode for the first time, \fBinit\fP performs the +\fBboot\fP and \fBbootwait\fP entries to allow file systems to be +mounted before users can log in. Then all entries matching the runlevel +are processed. +.PP +When starting a new process, \fBinit\fP first checks whether the file +\fI/etc/initscript\fP exists. If it does, it uses this script to +start the process. +.PP +Each time a child terminates, \fBinit\fP records the fact and the reason +it died in \fB/var/run/utmp\fP and \fB/var/log/wtmp\fP, +provided that these files exist. +.SH CHANGING RUNLEVELS +After it has spawned all of the processes specified, \fBinit\fP waits +for one of its descendant processes to die, a powerfail signal, or until +it is signaled by \fBtelinit\fP to change the system's runlevel. +When one of the above three conditions occurs, it re-examines +the \fB/etc/inittab\fP file. New entries can be added to this file at +any time. However, \fBinit\fP still waits for one of the above three +conditions to occur. To provide for an instantaneous response, the +\fBtelinit Q\fP or \fBq\fP command can wake up \fBinit\fP to re-examine the +\fB/etc/inittab\fP file. +.PP +If \fBinit\fP is not in single user mode and receives a powerfail +signal (SIGPWR), it reads the file \fB/etc/powerstatus\fP. It then starts +a command based on the contents of this file: +.IP F(AIL) +Power is failing, UPS is providing the power. Execute the \fBpowerwait\fP +and \fBpowerfail\fP entries. +.IP O(K) +The power has been restored, execute the \fBpowerokwait\fP entries. +.IP L(OW) +The power is failing and the UPS has a low battery. Execute the +\fBpowerfailnow\fP entries. +.PP +If /etc/powerstatus doesn't exist or contains anything else then the +letters \fBF\fP, \fBO\fP or \fBL\fP, init will behave as if it has read +the letter \fBF\fP. +.PP +Usage of \fBSIGPWR\fP and \fB/etc/powerstatus\fP is discouraged. Someone +wanting to interact with \fBinit\fP should use the \fB/dev/initctl\fP +control channel - see the source code of the \fBsysvinit\fP package +for more documentation about this. +.PP +When \fBinit\fP is requested to change the runlevel, it sends the +warning signal \s-1\fBSIGTERM\fP\s0 to all processes that are undefined +in the new runlevel. It then waits 5 seconds before forcibly +terminating these processes via the \s-1\fBSIGKILL\fP\s0 signal. +Note that \fBinit\fP assumes that all these processes (and their +descendants) remain in the same process group which \fBinit\fP +originally created for them. If any process changes its process group +affiliation it will not receive these signals. Such processes need to +be terminated separately. +.\"}}} +.\"{{{ telinit +.SH TELINIT +\fB/sbin/telinit\fP is linked to \fB/sbin/init\fP. It takes a +one-character argument and signals \fBinit\fP to perform the appropriate +action. The following arguments serve as directives to +\fBtelinit\fP: +.IP "\fB0\fP,\fB1\fP,\fB2\fP,\fB3\fP,\fB4\fP,\fB5\fP or \fB6\fP" +tell \fBinit\fP to switch to the specified run level. +.IP \fBa\fP,\fBb\fP,\fBc\fP +tell \fBinit\fP to process only those \fB/etc/inittab\fP file +entries having runlevel \fBa\fP,\fBb\fP or \fBc\fP. +.IP "\fBQ\fP or \fBq\fP" +tell \fBinit\fP to re-examine the \fB/etc/inittab\fP file. +.IP "\fBS\fP or \fBs\fP" +tell \fBinit\fP to switch to single user mode. +.IP "\fBU\fP or \fBu\fP" +tell \fBinit\fP to re-execute itself (preserving the state). No re-examining of +\fB/etc/inittab\fP file happens. Run level should be one of +\fBSs0123456\fP +otherwise request would be silently ignored. +.PP +\fBtelinit\fP can tell \fBinit\fP how long it should wait +between sending processes the SIGTERM and SIGKILL signals. The default +is 5 seconds, but this can be changed with the \fB-t\fP option. +.PP +\fBtelinit -e\fP tells \fBinit\fP to change the environment +for processes it spawns. +The argument of \fB-e\fP is either of the form \fIVAR\fP=\fIVAL\fP +which sets variable \fIVAR\fP to value \fIVAL\fP, +or of the form \fIVAR\fP +(without an equality sign) +which unsets variable \fIVAR\fP. +.PP +\fBtelinit\fP can be invoked only by users with appropriate +privileges. +.PP +The \fBinit\fP binary checks if it is \fBinit\fP or \fBtelinit\fP by looking +at its \fIprocess id\fP; the real \fBinit\fP's process id is always \fB1\fP. +From this it follows that instead of calling \fBtelinit\fP one can also +just use \fBinit\fP instead as a shortcut. +.\"}}} +.\"}}} +.SH ENVIRONMENT +\fBInit\fP sets the following environment variables for all its children: +.IP \fBPATH\fP +\fI/bin:/usr/bin:/sbin:/usr/sbin\fP +.IP \fBINIT_VERSION\fP +As the name says. Useful to determine if a script runs directly from \fBinit\fP. +.IP \fBRUNLEVEL\fP +The current system runlevel. +.IP \fBPREVLEVEL\fP +The previous runlevel (useful after a runlevel switch). +.IP \fBCONSOLE\fP +The system console. This is really inherited from the kernel; however +if it is not set \fBinit\fP will set it to \fB/dev/console\fP by default. +.SH BOOTFLAGS +It is possible to pass a number of flags to \fBinit\fP from the +boot monitor (eg. LILO). \fBInit\fP accepts the following flags: +.TP 0.5i +.B -s, S, single +Single user mode boot. In this mode \fI/etc/inittab\fP is +examined and the bootup rc scripts are usually run before +the single user mode shell is started. +.PP +.TP 0.5i +.B 1-5 +Runlevel to boot into. +.PP +.TP 0.5i +.B -b, emergency +Boot directly into a single user shell without running any +other startup scripts. +.PP +.TP 0.5i +.B -a, auto +The LILO boot loader adds the word "auto" to the command line if it +booted the kernel with the default command line (without user intervention). +If this is found \fBinit\fP sets the "AUTOBOOT" environment +variable to "yes". Note that you cannot use this for any security +measures - of course the user could specify "auto" or \-a on the +command line manually. +.PP +.TP 0.5i +.BI "-z " xxx +The argument to \fB-z\fP is ignored. You can use this to expand the command +line a bit, so that it takes some more space on the stack. \fBInit\fP +can then manipulate the command line so that \fBps\fP(1) shows +the current runlevel. +.PP +.SH INTERFACE +Init listens on a \fIfifo\fP in /dev, \fI/dev/initctl\fP, for messages. +\fBTelinit\fP uses this to communicate with init. The interface is not +very well documented or finished. Those interested should study the +\fIinitreq.h\fP file in the \fIsrc/\fP subdirectory of the \fBinit\fP +source code tar archive. +.SH SIGNALS +Init reacts to several signals: +.TP 0.5i +.B SIGHUP +Has the same effect as \fBtelinit q\fP. +.PP +.TP 0.5i +.B SIGUSR1 +On receipt of this signals, init closes and re-opens its control fifo, +\fB/dev/initctl\fP. Useful for bootscripts when /dev is remounted. +.TP 0.5i +.B SIGINT +Normally the kernel sends this signal to init when CTRL-ALT-DEL is +pressed. It activates the \fIctrlaltdel\fP action. +.TP 0.5i +.B SIGWINCH +The kernel sends this signal when the \fIKeyboardSignal\fP key is hit. +It activates the \fIkbrequest\fP action. +\"{{{ Conforming to +.SH CONFORMING TO +\fBInit\fP is compatible with the System V init. It works closely +together with the scripts in the directories +\fI/etc/init.d\fP and \fI/etc/rc{runlevel}.d\fP. +If your system uses this convention, there should be a \fIREADME\fP +file in the directory \fI/etc/init.d\fP explaining how these scripts work. +.\"}}} +.\"{{{ Files +.SH FILES +.nf +/etc/inittab +/etc/initscript +/dev/console +/var/run/utmp +/var/log/wtmp +/dev/initctl +.fi +.\"}}} +.\"{{{ Warnings +.SH WARNINGS +\fBInit\fP assumes that processes and descendants of processes +remain in the same process group which was originally created +for them. If the processes change their group, \fBinit\fP can't +kill them and you may end up with two processes reading from one +terminal line. +.\"}}} +.\"{{{ Diagnostics +.SH DIAGNOSTICS +If \fBinit\fP finds that it is continuously respawning an entry +more than 10 times in 2 minutes, it will assume that there is an error +in the command string, generate an error message on the system console, +and refuse to respawn this entry until either 5 minutes has elapsed or +it receives a signal. This prevents it from eating up system resources +when someone makes a typographical error in the \fB/etc/inittab\fP file +or the program for the entry is removed. +.\"}}} +.\"{{{ Author +.SH AUTHOR +Miquel van Smoorenburg (miquels@cistron.nl), initial manual +page by Michael Haardt (u31b3hs@pool.informatik.rwth-aachen.de). +.\"}}} +.\"{{{ See also +.SH "SEE ALSO" +.BR getty (1), +.BR login (1), +.BR sh (1), +.BR runlevel (8), +.BR shutdown(8), +.BR kill (1), +.BR inittab (5), +.BR initscript (5), +.BR utmp (5) +.\"}}} diff --git a/man/initscript.5 b/man/initscript.5 new file mode 100644 index 00000000..875879cd --- /dev/null +++ b/man/initscript.5 @@ -0,0 +1,72 @@ +'\" -*- 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. +.SH SYNOPSIS +/bin/sh /etc/initscript id runlevels action process +.SH DESCRIPTION +When the shell script \fI/etc/initscript\fP is present, \fBinit\fP +will use it to execute the commands from \fIinittab\fP. +This script can be used to set things like \fBulimit\fP and +\fBumask\fP default values for every process. +.SH EXAMPLES +This is a sample initscript, which might be installed on your +system as \fI/etc/initscript.sample\fP. +.RS +.sp +.nf +.ne 7 + +# +# initscript Executed by init(8) for every program it +# wants to spawn like this: +# +# /bin/sh /etc/initscript +# + + # Set umask to safe level, and enable core dumps. + umask 022 + ulimit -c 2097151 + PATH=/bin:/sbin:/usr/bin:/usr/sbin + export PATH + + # Increase the hard file descriptor limit for all processes + # to 8192. The soft limit is still 1024, but any unprivileged + # process can increase its soft limit up to the hard limit + # with "ulimit -Sn xxx" (needs a 2.2.13 or later Linux kernel). + ulimit -Hn 8192 + + # Execute the program. + eval exec "$4" + +.sp +.RE +.SH NOTES +This script is not meant as startup script for daemons or somesuch. +It has nothing to do with a \fIrc.local\fP style script. It's just +a handler for things executed from \fB/etc/inittab\fP. Experimenting +with this can make your system un(re)bootable. +.RE +.SH FILES +/etc/inittab, +/etc/initscript. +.SH AUTHOR +Miquel van Smoorenburg , +.SH "SEE ALSO" +init(8), inittab(5). diff --git a/man/inittab.5 b/man/inittab.5 new file mode 100644 index 00000000..e1d739d4 --- /dev/null +++ b/man/inittab.5 @@ -0,0 +1,265 @@ +'\" -*- 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" +.\"}}} +.\"{{{ Name +.SH NAME +inittab \- format of the inittab file used by the sysv-compatible init +process +.\"}}} +.\"{{{ Description +.SH DESCRIPTION +The \fBinittab\fP file describes which processes are started at bootup and +during normal operation (e.g.\& /etc/init.d/boot, /etc/init.d/rc, gettys...). +.BR Init (8) +distinguishes multiple \fIrunlevels\fP, each of which can have its own set of +processes that are started. Valid runlevels are \fB0\fP\-\fB6\fP plus +\fBA\fP, \fBB\fP, and \fBC\fP for \fBondemand\fP entries. An entry in the +\fBinittab\fP file has the following format: +.RS +.sp +\fIid\fP:\fIrunlevels\fP:\fIaction\fP:\fIprocess\fP +.sp +.RE +Lines beginning with `#' are ignored. +.\"{{{ id +.IP \fIid\fP +is a unique sequence of 1-4 characters which identifies an entry in +.B inittab +(for versions of sysvinit compiled with the \fIold\fP libc5 (< 5.2.18) or +a.out libraries the limit is 2 characters). +.sp +Note: traditionally, for getty and other login processes, the value of the +\fIid\fP field is kept the same as the suffix of the corresponding tty, e.g.\& +\fB1\fP for \fBtty1\fP. Some ancient login accounting programs might +expect this, though I can't think of any. +.\"}}} +.\"{{{ runlevels +.IP \fIrunlevels\fP +lists the runlevels for which the specified action should be taken. +.\"}}} +.\"{{{ action +.IP \fIaction\fP +describes which action should be taken. +.\"}}} +.\"{{{ process +.IP \fIprocess\fP +specifies the process to be executed. If the process field starts with +a `+' character, +.B init +will not do utmp and wtmp accounting for that process. This is needed for +gettys that insist on doing their own utmp/wtmp housekeeping. This is also +a historic bug. +.\"}}} +.PP +The \fIrunlevels\fP field may contain multiple characters for different +runlevels. For example, \fB123\fP specifies that the process should be +started in runlevels 1, 2, and 3. +The \fIrunlevels\fP for \fBondemand\fP entries may contain an \fBA\fP, +\fBB\fP, or \fBC\fP. The \fIrunlevels\fP field of \fBsysinit\fP, +\fBboot\fP, and \fBbootwait\fP entries are ignored. +.PP +When the system runlevel is changed, any running processes that are not +specified for the new runlevel are killed, first with \s-2SIGTERM\s0, +then with \s-2SIGKILL\s0. +.PP +Valid actions for the \fIaction\fP field are: +.\"{{{ respawn +.IP \fBrespawn\fP +The process will be restarted whenever it terminates (e.g.\& getty). +.\"}}} +.\"{{{ wait +.IP \fBwait\fP +The process will be started once when the specified runlevel is entered and +.B init +will wait for its termination. +.\"}}} +.\"{{{ once +.IP \fBonce\fP +The process will be executed once when the specified runlevel is +entered. +.\"}}} +.\"{{{ boot +.IP \fBboot\fP +The process will be executed during system boot. The \fIrunlevels\fP +field is ignored. +.\"}}} +.\"{{{ bootwait +.IP \fBbootwait\fP +The process will be executed during system boot, while +.B init +waits for its termination (e.g.\& /etc/rc). +The \fIrunlevels\fP field is ignored. +.\"}}} +.\"{{{ off +.IP \fBoff\fP +This does nothing. +.\"}}} +.\"{{{ ondemand +.IP \fBondemand\fP +A process marked with an \fBondemand\fP runlevel will be executed +whenever the specified \fBondemand\fP runlevel is called. However, no +runlevel change will occur (\fBondemand\fP runlevels are `a', `b', +and `c'). +.\"}}} +.\"{{{ initdefault +.IP \fBinitdefault\fP +An \fBinitdefault\fP entry specifies the runlevel which should be +entered after system boot. If none exists, +.B init +will ask for a runlevel on the console. The \fIprocess\fP field is ignored. +.\"}}} +.\"{{{ sysinit +.IP \fBsysinit\fP +The process will be executed during system boot. It will be +executed before any \fBboot\fP or \fB bootwait\fP entries. +The \fIrunlevels\fP field is ignored. +.\"}}} +.\"{{{ powerwait +.IP \fBpowerwait\fP +The process will be executed when the power goes down. Init is usually +informed about this by a process talking to a UPS connected to the computer. +\fBInit\fP will wait for the process to finish before continuing. +.\"}}} +.\"{{{ powerfail +.IP \fBpowerfail\fP +As for \fBpowerwait\fP, except that \fBinit\fP does not wait for the process's +completion. +.\"}}} +.\"{{{ powerokwait +.IP \fBpowerokwait\fP +This process will be executed as soon as \fBinit\fP is informed that the +power has been restored. +.\"}}} +.\"{{{ powerfailnow +.IP \fBpowerfailnow\fP +This process will be executed when \fBinit\fP is told that the battery of +the external UPS is almost empty and the power is failing (provided that the +external UPS and the monitoring process are able to detect this condition). +.\"}}} +.\"{{{ ctrlaltdel +.IP \fBctrlaltdel\fP +The process will be executed when \fBinit\fP receives the SIGINT signal. +This means that someone on the system console has pressed the +\fBCTRL\-ALT\-DEL\fP key combination. Typically one wants to execute some +sort of \fBshutdown\fP either to get into single\-user level or to +reboot the machine. +.\"}}} +.\"{{{ kbrequest +.IP \fBkbrequest\fP +The process will be executed when \fBinit\fP receives a signal from the +keyboard handler that a special key combination was pressed on the +console keyboard. +.sp +The documentation for this function is not complete yet; more documentation +can be found in the kbd-x.xx packages (most recent was kbd-0.94 at +the time of this writing). Basically you want to map some keyboard +combination to the "KeyboardSignal" action. For example, to map Alt-Uparrow +for this purpose use the following in your keymaps file: +.RS +.sp +alt keycode 103 = KeyboardSignal +.sp +.RE +.\"}}} +.\"}}} +.\"{{{ Examples +.SH EXAMPLES +This is an example of a inittab which resembles the old Linux inittab: +.RS +.sp +.nf +.ne 7 +# inittab for linux +id:1:initdefault: +rc::bootwait:/etc/rc +1:1:respawn:/etc/getty 9600 tty1 +2:1:respawn:/etc/getty 9600 tty2 +3:1:respawn:/etc/getty 9600 tty3 +4:1:respawn:/etc/getty 9600 tty4 +.fi +.sp +.RE +This inittab file executes \fB/etc/rc\fP during boot and starts gettys +on tty1\-tty4. +.PP +A more elaborate \fBinittab\fP with different runlevels (see the comments +inside): +.RS +.sp +.nf +.ne 19 +# Level to run in +id:2:initdefault: + +# Boot-time system configuration/initialization script. +si::sysinit:/etc/init.d/rcS + +# What to do in single-user mode. +~:S:wait:/sbin/sulogin + +# /etc/init.d executes the S and K scripts upon change +# of runlevel. +# +# Runlevel 0 is halt. +# Runlevel 1 is single-user. +# Runlevels 2-5 are multi-user. +# Runlevel 6 is reboot. + +l0:0:wait:/etc/init.d/rc 0 +l1:1:wait:/etc/init.d/rc 1 +l2:2:wait:/etc/init.d/rc 2 +l3:3:wait:/etc/init.d/rc 3 +l4:4:wait:/etc/init.d/rc 4 +l5:5:wait:/etc/init.d/rc 5 +l6:6:wait:/etc/init.d/rc 6 + +# What to do at the "3 finger salute". +ca::ctrlaltdel:/sbin/shutdown -t1 -h now + +# Runlevel 2,3: getty on virtual consoles +# Runlevel 3: getty on terminal (ttyS0) and modem (ttyS1) +1:23:respawn:/sbin/getty tty1 VC linux +2:23:respawn:/sbin/getty tty2 VC linux +3:23:respawn:/sbin/getty tty3 VC linux +4:23:respawn:/sbin/getty tty4 VC linux +S0:3:respawn:/sbin/getty -L 9600 ttyS0 vt320 +S1:3:respawn:/sbin/mgetty -x0 -D ttyS1 + +.fi +.sp +.RE +.\"}}} +.\"{{{ Files +.SH FILES +/etc/inittab +.\"}}} +.\"{{{ Author +.SH AUTHOR +\fBInit\fP was written by Miquel van Smoorenburg +(miquels@cistron.nl). This manual page was written by +Sebastian Lederer (lederer@francium.informatik.uni-bonn.de) and modified +by Michael Haardt (u31b3hs@pool.informatik.rwth-aachen.de). +.\"}}} +.\"{{{ See also +.SH "SEE ALSO" +.BR init (8), +.BR telinit (8) +.\"}}} diff --git a/man/killall5.8 b/man/killall5.8 new file mode 100644 index 00000000..24b819fa --- /dev/null +++ b/man/killall5.8 @@ -0,0 +1,49 @@ +'\" -*- 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. +.SH SYNOPSIS +.B killall5 +.RB -signalnumber +.RB [ \-o +.IR omitpid[,omitpid..]] +.RB [ \-o +.IR omitpid[,omitpid..].. ] +.SH DESCRIPTION +.B killall5 +is the SystemV killall command. It sends a signal to all processes except +kernel threads and the processes in its own session, so it won't kill +the shell that is running the script it was called from. Its primary +(only) use is in the \fBrc\fP scripts found in the /etc/init.d directory. +.SH OPTIONS +.IP "-o \fIomitpid\fP" +Tells \fIkillall5\fP to omit processes with that process id. +.SH NOTES +\fIkillall5\fP can also be invoked as pidof, which is simply a +(symbolic) link to the \fIkillall5\fP program. +.SH EXIT STATUS +The program return zero if it killed processes. It return 2 if no +process were killed, and 1 if it was unable to find any processes +(/proc/ is missing). +.SH SEE ALSO +.BR halt (8), +.BR reboot (8), +.BR pidof (8) +.SH AUTHOR +Miquel van Smoorenburg, miquels@cistron.nl diff --git a/man/last.1 b/man/last.1 new file mode 100644 index 00000000..20655e6f --- /dev/null +++ b/man/last.1 @@ -0,0 +1,124 @@ +'\" -*- 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" +.\"}}} +.\"{{{ Name +.SH NAME +last, lastb \- show listing of last logged in users +.\"}}} +.\"{{{ Synopsis +.SH SYNOPSIS +.B last +.RB [ \-R ] +.RB [ \-\fInum\fP ] +.RB "[ \-\fBn\fP \fInum\fP ]" +.RB [ \-adFiowx ] +.RB "[ \-\fBf\fP \fIfile\fP ]" +.RB "[ \-\fBt\fP \fIYYYYMMDDHHMMSS\fP ]" +.RI [ name... ] +.RI [ tty... ] +.br +.B lastb +.RB [ \-R ] +.RB [ \-\fInum\fP ] +.RB "[ \-\fBn\fP \fInum\fP ]" +.RB "[ \-\fBf\fP \fIfile\fP ]" +.RB [ \-adFiowx ] +.RI [ name... ] +.RI [ tty... ] +.\"}}} +.\"{{{ Description +.SH DESCRIPTION +.B Last +searches back through the file \fB/var/log/wtmp\fP (or the file +designated by the \fB\-f\fP flag) and displays a list of all +users logged in (and out) since that file was created. Names of users +and tty's can be given, in which case \fBlast\fP will show only those entries +matching the arguments. Names of ttys can be abbreviated, thus \fBlast +0\fP is the same as \fBlast tty0\fP. +.PP +When \fBlast\fP catches a \s-2SIGINT\s0 signal (generated by the interrupt key, +usually control-C) or a \s-2SIGQUIT\s0 signal (generated by the quit key, +usually control-\e), \fBlast\fP will show how far it has searched through the +file; in the case of the \s-2SIGINT\s0 signal \fBlast\fP will then terminate. +.PP +The pseudo user \fBreboot\fP logs in each time the system is rebooted. +Thus \fBlast reboot\fP will show a log of all reboots since the log file +was created. +.PP +\fBLastb\fP is the same as \fBlast\fP, except that by default it shows a log +of the file \fB/var/log/btmp\fP, which contains all the bad login attempts. +.\"}}} +.\"{{{ Options +.SH OPTIONS +.IP "\fB\-f\fP \fIfile\fP" +Tells \fBlast\fP to use a specific file instead of \fB/var/log/wtmp\fP. +.IP \fB\-\fP\fInum\fP +This is a count telling \fBlast\fP how many lines to show. +.IP "\fB\-n\fP \fInum\fP" +The same. +.IP "\fB\-t\fP \fIYYYYMMDDHHMMSS\fP" +Display the state of logins as of the specified time. This is +useful, e.g., to determine easily who was logged in at a particular +time -- specify that time with \fB\-t\fP and look for "still logged +in". +.IP \fB\-R\fP +Suppresses the display of the hostname field. +.IP \fB\-a\fP +Display the hostname in the last column. Useful in combination +with the next flag. +.IP \fB\-d\fP +For non-local logins, Linux stores not only the host name of the remote +host but its IP number as well. This option translates the IP number +back into a hostname. +.IP \fB\-F\fP +Print full login and logout times and dates. +.IP \fB\-i\fP +This option is like \fB-d\fP in that it displays the IP number of the remote +host, but it displays the IP number in numbers-and-dots notation. +.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. +.\"}}} +.SH NOTES +The files \fIwtmp\fP and \fIbtmp\fP might not be found. The system only +logs information in these files if they are present. This is a local +configuration issue. If you want the files to be used, they can be +created with a simple \fBtouch\fP(1) command (for example, +\fItouch /var/log/wtmp\fP). +.\"{{{ Files +.SH FILES +/var/log/wtmp +.br +/var/log/btmp +.\"}}} +.\"{{{ Author +.SH AUTHOR +Miquel van Smoorenburg, miquels@cistron.nl +.\"}}} +.\"{{{ See also +.SH "SEE ALSO" +.BR shutdown (8), +.BR login (1), +.BR init (8) +.\"}}} diff --git a/man/lastb.1 b/man/lastb.1 new file mode 100644 index 00000000..f57c02a6 --- /dev/null +++ b/man/lastb.1 @@ -0,0 +1 @@ +.so man1/last.1 diff --git a/man/mesg.1 b/man/mesg.1 new file mode 100644 index 00000000..e33c348e --- /dev/null +++ b/man/mesg.1 @@ -0,0 +1,61 @@ +'\" -*- 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" +.\"}}} +.\"{{{ Name +.SH NAME +mesg \- control write access to your terminal +.\"}}} +.\"{{{ Synopsis +.SH SYNOPSIS +.B mesg +.RB [ y | n ] +.\"}}} +.\"{{{ Description +.SH DESCRIPTION +.B Mesg +controls the access to your terminal by others. It's typically used to +allow or disallow other users to write to your terminal (see \fBwrite\fP(1)). +.\"}}} +.\"{{{ Options +.SH OPTIONS +.IP \fBy\fP +Allow write access to your terminal. +.IP \fBn\fP +Disallow write access to your terminal. +.PP +If no option is given, \fBmesg\fP prints out the current access state of your +terminal. +.\"}}} +.\"{{{ Notes +.SH NOTES +\fBMesg\fP assumes that its standard input is connected to your +terminal. That also means that if you are logged in multiple times, +you can get/set the mesg status of other sessions by using redirection. +For example "mesg n < /dev/pts/46". +.SH AUTHOR +Miquel van Smoorenburg (miquels@cistron.nl) +.\"}}} +.\"{{{ See also +.SH "SEE ALSO" +.BR talk (1), +.BR write (1), +.BR wall (1) +.\"}}} diff --git a/man/mountpoint.1 b/man/mountpoint.1 new file mode 100644 index 00000000..e873e786 --- /dev/null +++ b/man/mountpoint.1 @@ -0,0 +1,54 @@ +'\" -*- 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 +.SH SYNOPSIS +.B /bin/mountpoint +.RB [ \-q ] +.RB [ \-d ] +.I /path/to/directory +.br +.B /bin/mountpoint +.RB \-x +.I /dev/device +.SH DESCRIPTION +\fBMountpoint\fP checks if the directory is a mountpoint. + +.SH OPTIONS +.IP \fB\-q\fP +Be quiet - don't print anything. +.IP \fB\-d\fP +Print major/minor device number of the filesystem on stdout. +.IP \fB\-x\fP +Print major/minor device number of the blockdevice on stdout. +.SH EXIT STATUS +Zero if the directory is a mountpoint, non-zero if not. +.SH NOTES +Symbolic links are not followed, except when the \fB-x\fP option is +used. To force following symlinks, add a trailing slash to the +path of the directory. +.PP +The name of the command is misleading when the -x option is used, +but the option is useful for comparing if a directory and a device +match up, and there is no other command that can print the info easily. +.PP +.SH AUTHOR +Miquel van Smoorenburg, miquels@cistron.nl +.SH "SEE ALSO" +.BR stat (1) diff --git a/man/pidof.8 b/man/pidof.8 new file mode 100644 index 00000000..276a93cc --- /dev/null +++ b/man/pidof.8 @@ -0,0 +1,92 @@ +'\" -*- 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. +.SH SYNOPSIS +.B pidof +.RB [ \-s ] +.RB [ \-c ] +.RB [ \-n ] +.RB [ \-x ] +.RB [ \-o +.IR omitpid[,omitpid..] ] +.RB [ \-o +.IR omitpid[,omitpid..].. ] +.B program +.RB [ program.. ] +.SH DESCRIPTION +.B Pidof +finds the process id's (pids) of the named programs. It prints those +id's on the standard output. This program is on some systems used in +run-level change scripts, especially when the system has a +\fISystem-V\fP like \fIrc\fP structure. In that case these scripts are +located in /etc/rc?.d, where ? is the runlevel. If the system has +a +.B start-stop-daemon +(8) program that should be used instead. +.SH OPTIONS +.IP \-s +Single shot - this instructs the program to only return one \fIpid\fP. +.IP \-c +Only return process ids that are running with the same root directory. +This option is ignored for non-root users, as they will be unable to check +the current root directory of processes they do not own. +.IP \-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" +Tells \fIpidof\fP to omit processes with that process id. The special +pid \fB%PPID\fP can be used to name the parent process of the \fIpidof\fP +program, in other words the calling shell or shell script. +.SH "EXIT STATUS" +.TP +.B 0 +At least one program was found with the requested name. +.TP +.B 1 +No program was found with the requested name. +.SH NOTES +\fIpidof\fP is actually the same program as \fIkillall5\fP; +the program behaves according to the name under which it is called. +.PP +When \fIpidof\fP is invoked with a full pathname to the program it +should find the pid of, it is reasonably safe. Otherwise it is possible +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. 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), +.BR halt (8), +.BR reboot (8), +.BR killall5 (8) +.SH AUTHOR +Miquel van Smoorenburg, miquels@cistron.nl diff --git a/man/poweroff.8 b/man/poweroff.8 new file mode 100644 index 00000000..41c02c13 --- /dev/null +++ b/man/poweroff.8 @@ -0,0 +1 @@ +.so man8/halt.8 diff --git a/man/reboot.8 b/man/reboot.8 new file mode 100644 index 00000000..41c02c13 --- /dev/null +++ b/man/reboot.8 @@ -0,0 +1 @@ +.so man8/halt.8 diff --git a/man/runlevel.8 b/man/runlevel.8 new file mode 100644 index 00000000..1e4ea771 --- /dev/null +++ b/man/runlevel.8 @@ -0,0 +1,56 @@ +'\" -*- 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. +.SH SYNOPSIS +.B runlevel +.RI [ utmp ] +.SH DESCRIPTION +.B Runlevel +reads the system +.I utmp +file (typically +.IR /var/run/utmp ) +to locate the runlevel record, and then +prints the previous and current system runlevel on its standard output, +separated by a single space. If there is no previous system +runlevel, the letter \fBN\fP will be printed instead. +.PP +If no +.I utmp +file exists, or if no runlevel record can be found, +.B runlevel +prints the word \fBunknown\fP and exits with an error. +.PP +.B Runlevel +can be used in \fIrc\fP scripts as a substitute for the System-V +\fBwho -r\fP command. +However, in newer versions of \fBinit\fP(8) this information +is also available in the environment variables \fBRUNLEVEL\fP and +\fBPREVLEVEL\fP. +.SH OPTIONS +.\"{{{ utmp +.IP \fIutmp\fP +The name of the \fIutmp\fP file to read. +.\"}}} +.SH SEE ALSO +.BR init (8), +.BR utmp (5) +.SH AUTHOR +Miquel van Smoorenburg, miquels@cistron.nl diff --git a/man/shutdown.8 b/man/shutdown.8 new file mode 100644 index 00000000..919a77e4 --- /dev/null +++ b/man/shutdown.8 @@ -0,0 +1,215 @@ +'\" -*- 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" +.\"}}} +.\"{{{ Name +.SH NAME +shutdown \- bring the system down +.\"}}} +.\"{{{ Synopsis +.SH SYNOPSIS +.B /sbin/shutdown +.RB [ \-akrhPHfFnc ] +.RB [ \-t +.IR sec ] +.I time +.RI [ "warning message" ] +.\"}}} +.\"{{{ Description +.SH DESCRIPTION +\fBshutdown\fP brings the system down in a secure way. All logged-in users are +notified that the system is going down, and \fBlogin\fP(1) is blocked. +It is possible to shut the system down immediately or after a specified delay. +All processes are first notified that the system is going down by the +signal \s-2SIGTERM\s0. This gives programs like \fBvi\fP(1) +the time to save the file being edited, +mail and news processing programs a chance to exit cleanly, etc. +\fBshutdown\fP does its job by signalling the \fBinit\fP process, +asking it to change the runlevel. +Runlevel \fB0\fP is used to halt the system, runlevel \fB6\fP is used +to reboot the system, and runlevel \fB1\fP is used to put to system into +a state where administrative tasks can be performed; this is the default +if neither the \fI-h\fP or \fI-r\fP flag is given to \fBshutdown\fP. +To see which actions are taken on halt or reboot see the appropriate +entries for these runlevels in the file \fI/etc/inittab\fP. +.\"}}} +.\"{{{ Options +.SH OPTIONS +.\"{{{ -a +.IP "\fB\-a\fP +Use \fB/etc/shutdown.allow\fP. +.\"}}} +.\"{{{ -k +.IP \fB\-k\fP +Don't really shutdown; only send the warning messages to everybody. +.\"}}} +.\"{{{ -r +.IP \fB\-r\fP +Reboot after shutdown. +.\"}}} +.\"{{{ -h +.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. +.\"}}} +.\"{{{ -f +.IP \fB\-f\fP +Skip fsck on reboot. +.\"}}} +.\"{{{ -F +.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 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" +Message to send to all users. +.\"}}} +.PP +The \fItime\fP argument can have different formats. First, it can be an +absolute time in the format \fIhh:mm\fP, in which \fIhh\fP is the hour +(1 or 2 digits) and \fImm\fP is the minute of the hour (in two digits). +Second, it can be in the format \fB+\fP\fIm\fP, in which \fIm\fP is the +number of minutes to wait. The word \fBnow\fP is an alias for \fB+0\fP. +.PP +If shutdown is called with a delay, it will create the advisory file +.I /etc/nologin +which causes programs such as \fIlogin(1)\fP to not allow new user +logins. This file is created five minutes before the shutdown sequence +starts. Shutdown removes this file if it is stopped before it +can signal init (i.e. it is cancelled or something goes wrong). +It also removes it before calling init to change the runlevel. +.PP +The \fB\-f\fP flag means `reboot fast'. This only creates an advisory +file \fI/fastboot\fP which can be tested by the system when it comes +up again. The boot rc file can test if this file is present, and decide not +to run \fBfsck\fP(1) since the system has been shut down in the proper way. +After that, the boot process should remove \fI/fastboot\fP. +.PP +The \fB\-F\fP flag means `force fsck'. This only creates an advisory +file \fI/forcefsck\fP which can be tested by the system when it comes +up again. The boot rc file can test if this file is present, and decide +to run \fBfsck\fP(1) with a special `force' flag so that even properly +unmounted file systems get checked. +After that, the boot process should remove \fI/forcefsck\fP. +.PP +The \fB-n\fP flag causes \fBshutdown\fP not to call \fBinit\fP, +but to kill all running processes itself. +\fBshutdown\fP will then turn off quota, accounting, and swapping +and unmount all file systems. +.\"}}} +.\"{{{ Files +.SH ACCESS CONTROL +\fBshutdown\fP can be called from \fBinit\fP(8) when the magic keys +\fBCTRL-ALT-DEL\fP are pressed, by creating an appropriate entry in +\fI/etc/inittab\fP. This means that everyone who has physical access +to the console keyboard can shut the system down. To prevent this, +\fBshutdown\fP can check to see if an authorized user is logged in on +one of the virtual consoles. If \fBshutdown\fP is called with the \fB-a\fP +argument (add this to the invocation of shutdown in /etc/inittab), +it checks to see if the file \fI/etc/shutdown.allow\fP is present. +It then compares the login names in that file with the list of people +that are logged in on a virtual console (from \fI/var/run/utmp\fP). Only +if one of those authorized users \fBor root\fP is logged in, it will +proceed. Otherwise it will write the message +.sp 1 +.nf +\fBshutdown: no authorized users logged in\fP +.fi +.sp 1 +to the (physical) system console. The format of \fI/etc/shutdown.allow\fP +is one user name per line. Empty lines and comment lines (prefixed by a +\fB#\fP) are allowed. Currently there is a limit of 32 users in this file. +.sp 1 +Note that if \fI/etc/shutdown.allow\fP is not present, the \fB-a\fP +argument is ignored. +.SH HALT OR POWEROFF +The \fB-H\fP option just sets the \fIinit\fP environment variable +\fIINIT_HALT\fP to \fIHALT\fP, and the \fB-P\fP option just sets +that variable to \fIPOWEROFF\fP. The shutdown script that calls +\fBhalt\fP(8) as the last thing in the shutdown sequence should +check these environment variables and call \fBhalt\fP(8) with +the right options for these options to actually have any effect. +Debian 3.1 (sarge) supports this. +.SH FILES +.nf +/fastboot +/etc/inittab +/etc/init.d/halt +/etc/init.d/reboot +/etc/shutdown.allow +.fi +.\"}}} +.SH NOTES +A lot of users forget to give the \fItime\fP argument +and are then puzzled by the error message \fBshutdown\fP produces. The +\fItime\fP argument is mandatory; in 90 percent of all cases this argument +will be the word \fBnow\fP. +.PP +Init can only capture CTRL-ALT-DEL and start shutdown in console mode. +If the system is running the X window System, the X server processes +all key strokes. Some X11 environments make it possible to capture +CTRL-ALT-DEL, but what exactly is done with that event depends on +that environment. +.PP +Shutdown wasn't designed to be run setuid. /etc/shutdown.allow is +not used to find out who is executing shutdown, it ONLY checks who +is currently logged in on (one of the) console(s). +.\"{{{ Author +.SH AUTHOR +Miquel van Smoorenburg, miquels@cistron.nl +.\"}}} +.\"{{{ See also +.SH "SEE ALSO" +.BR fsck (8), +.BR init (8), +.BR halt (8), +.BR poweroff (8), +.BR reboot (8) +.\"}}} diff --git a/man/sulogin.8 b/man/sulogin.8 new file mode 100644 index 00000000..4b5d1539 --- /dev/null +++ b/man/sulogin.8 @@ -0,0 +1,87 @@ +'\" -*- 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 +.SH SYNOPSIS +.B sulogin +[ \fB\-e\fP ] +[ \fB\-p\fP ] +[ \fB\-t\fP \fISECONDS\fP ] +[ \fITTY\fP ] +.SH DESCRIPTION +.I sulogin +is invoked by \fBinit(8)\fP when the system goes into single user mode. +(This is done through an entry in \fIinittab(5)\fP.) +\fBInit\fP also +tries to execute \fIsulogin\fP when +the boot loader (e.g., \fBgrub\fP(8)) +passes it the \fB\-b\fP option. +.PP +The user is prompted +.IP "" .5i +Give root password for system maintenance +.br +(or type Control\-D for normal startup): +.PP +\fIsulogin\fP will be connected to the current terminal, or to the +optional device that can be specified on the command line +(typically \fB/dev/console\fP). +.PP +If the \fB\-t\fP option is used then the program only waits +the given number of seconds for user input. +.PP +If the \fB\-p\fP option is used then the single-user shell is invoked +with a \fIdash\fP as the first character in \fIargv[0]\fP. +This causes the shell process to behave as a login shell. +The default is \fInot\fP to do this, +so that the shell will \fInot\fP read \fB/etc/profile\fP +or \fB$HOME/.profile\fP at startup. +.PP +After the user exits the single-user shell, +or presses control\-D at the prompt, +the system will (continue to) boot to the default runlevel. +.SH ENVIRONMENT VARIABLES +\fIsulogin\fP looks for the environment variable \fBSUSHELL\fP or +\fBsushell\fP to determine what shell to start. If the environment variable +is not set, it will try to execute root's shell from /etc/passwd. If that +fails it will fall back to \fB/bin/sh\fP. +.PP +This is very valuable together with the \fB\-b\fP option to init. To boot +the system into single user mode, with the root file system mounted read/write, +using a special "fail safe" shell that is statically linked (this example +is valid for the LILO bootprompt) +.PP +boot: linux \-b rw sushell=/sbin/sash +.SH FALLBACK METHODS +\fIsulogin\fP checks the root password using the standard method (getpwnam) +first. +Then, if the \fB\-e\fP option was specified, +\fIsulogin\fP examines these files directly to find the root password: +.PP +/etc/passwd, +.br +/etc/shadow (if present) +.PP +If they are damaged or nonexistent, sulogin will start a root shell +without asking for a password. Only use the \fB\-e\fP option if you +are sure the console is physically protected against unauthorized access. +.SH AUTHOR +Miquel van Smoorenburg +.SH SEE ALSO +init(8), inittab(5). diff --git a/man/telinit.8 b/man/telinit.8 new file mode 100644 index 00000000..a12cb4fa --- /dev/null +++ b/man/telinit.8 @@ -0,0 +1 @@ +.so man8/init.8 diff --git a/man/utmpdump.1 b/man/utmpdump.1 new file mode 100644 index 00000000..1b5730d9 --- /dev/null +++ b/man/utmpdump.1 @@ -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), diff --git a/man/wall.1 b/man/wall.1 new file mode 100644 index 00000000..2fe8301d --- /dev/null +++ b/man/wall.1 @@ -0,0 +1,75 @@ +'\" -*- 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 +wall -- send a message to everybody's terminal. + +.SH SYNOPSIS +.B wall +.RB [ \-n ] +.RB [ " message " ] + +.SH DESCRIPTION +.B Wall +sends a message to everybody logged in with their +.IR mesg (1) +permission +set to +.BR yes . +The message can be given as an argument to +.IR wall , +or it can be sent to +.IR wall 's +standard input. When using the standard input from a terminal, +the message should be terminated with the +.B EOF +key (usually Control-D). +.PP +The length of the message is limited to 20 lines. +For every invocation of +.I wall +a notification will be written to syslog, with facility +.B LOG_USER +and level +.BR LOG_INFO . + +.SH OPTIONS +.IP \fB\-n\fn +Suppresses the normal banner printed by +.IR wall , +changing it to "Remote broadcast message". +This option is only available for root if +.I wall +is installed set-group-id, and is used by +.IR rpc.walld (8). +.PP + +.SH ENVIRONMENT +.I Wall +ignores the +.B TZ +variable - the time printed in the banner is based on the system's +local time. + +.SH SEE ALSO +.IR mesg (1), +.IR rpc.rwalld (8). + +.SH AUTHOR +Miquel van Smoorenburg, miquels@cistron.nl diff --git a/obsolete/README.RIGHT.NOW b/obsolete/README.RIGHT.NOW new file mode 100644 index 00000000..7a6fb1d0 --- /dev/null +++ b/obsolete/README.RIGHT.NOW @@ -0,0 +1,58 @@ +WARNING: + + This version of sysvinit is really different from the 2.50 and + earlier version. + + Shutdown now puts the system into runlevel 6 (reboot), 0 (halt) + or 1 (single user). This can cause unexpected results if you + install the binaries from this release into Slackware distributions + older than Slackware 3.0. + +SUPPORTED DISTRIBUTIONS: + + The binaries from this package can be installed in: + + o Debian 1.3 and later + o RedHat 3.x and later + o Slackware 3.0 (UNTESTED but it might work - no complaints yet). + Also read the INIT.README in the slackware/ directory. + o Slackware 2.x: see the slackware/ directory + + Do not install any of the scripts from the debian/ directory unless + you know what you are doing. + +UNSUPPORTED DISTRIBUTIONS: + + o The rest :) + + If you have a non-supported system, please upgrade to the latest version + of your distribution that supports the Linux 2.0.x kernel (probably + the reason why you are installing this newer sysvinit). + + You might get away by installing *just* the "init" binary, and nothing + else. Do _not_ replace your existing halt, reboot or shutdown programs. + +HOW TO NON DESTRUCTIVELY TEST THE NEW INIT: + + Install *just* the init binary as /sbin/init.new. Now reboot the system, + and stop your bootloader so you can give arguments on the command line. + With LILO you can usually achieve this by keeping the SHIFT key + pressed during boot up. Enter the name of the kernel image (for LILO, + TAB shows a list) followed by the argument "init=/sbin/init.new". + The name "init.new" is special, do not use something like "init.test". + + For example: + + boot: linux init=/sbin/init.new + + YOU CANNOT SHUTDOWN IN A CLEAN WAY AFTER THIS. Your best bet is to use + the "-n" flag to shutdown. This is because init is not running as process #1 + if you use this method. Anyway, if this works, you can remove the old init + and copy the new init into place. + +DISCLAIMER: + + If it breaks you get to keep both pieces. If you want to run the latest + Linux 2.0.x kernel and you can't get init to work just upgrade your entire + distribution to a newer version that supports the 2.0.x kernel properly. + diff --git a/obsolete/bootlogd.init b/obsolete/bootlogd.init new file mode 100755 index 00000000..cf7b9ebb --- /dev/null +++ b/obsolete/bootlogd.init @@ -0,0 +1,67 @@ +#! /bin/sh +# +# bootlogd One of the first scripts to be executed. Starts or stops +# the bootlogd log program. If this script is called as +# "stop-bootlogd", it will stop the daemon instead of +# starting it even when called with the "start" argument. +# +# Version: @(#)bootlogd 2.77 24-Aug-1999 miquels@cistron.nl +# + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=/sbin/bootlogd +NAME=bootlogd +DESC="Bootlog daemon" +PIDFILE=/var/run/$NAME.pid + +test -f $DAEMON || exit 0 + +## set -e # not needed + +. /etc/default/rcS + +case "$0" in + *stop-bootlog*) + stopper=yes + ;; +esac + +case "$1" in + start|stop) + if [ "$stopper" ] || [ "$1" = "stop" ] + then + echo -n "Stopping $DESC: " + start-stop-daemon --stop --quiet --exec $DAEMON + else + echo -n "Starting $DESC: " + start-stop-daemon --start --quiet --exec $DAEMON -- -r + fi + if [ "$stopper" ] && [ -f /var/log/boot.log ] && \ + [ -f /var/log/boot.log~ ] + then + cd /var/log + savelog -p -c 5 boot.log > /dev/null 2>&1 + mv boot.log.0 boot.log + mv boot.log~ boot.log.0 + fi + echo "$NAME." + ;; + restart|force-reload) + echo -n "Restarting $DESC: " + start-stop-daemon --stop --quiet --pidfile \ + $PIDFILE --exec $DAEMON -- -p $PIDFILE + sleep 1 + start-stop-daemon --start --quiet --pidfile \ + $PIDFILE --exec $DAEMON -- -p $PIDFILE + echo "$NAME." + ;; + *) + N=${0##*/} + N=${N#[SK]??} + echo "Usage: $N {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 + diff --git a/obsolete/powerd.8 b/obsolete/powerd.8 new file mode 100644 index 00000000..c1c27e3b --- /dev/null +++ b/obsolete/powerd.8 @@ -0,0 +1,73 @@ +'\" -*- 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. +powerd -- monitor a serial line connected to an UPS. +.SH SYNOPSIS +.B /sbin/powerd +.RB " serial-device " +.SH DESCRIPTION +.B Powerd +is a daemon process that sits in the background and monitors the state +of the DCD line of the serial device. This line is meant to be +connected to a UPS (Uninterruptible Power Supply) so that \fBpowerd\fP knows +about the state of the UPS. As soon as \fBpowerd\fP senses that the +power is failing (it sees that DCD goes low) it notifies \fBinit\fP(8), +and \fBinit\fP then executes the \fBpowerwait\fP and \fBpowerfail\fP entries. +If \fBpowerd\fP senses that the power has been restored, it notifies \fBinit\fP +again and \fBinit\fP will execute the \fBpowerokwait\fP entries. +.SH ARGUMENTS +.IP serial-device +Some serial port that is not being used by some other device, and does not +share an interrupt with any other serial port. +.SH DIAGNOSTICS +\fBPowerd\fP regularly checks the \fBDSR\fP line to see if it's high. +\fBDSR\fP should be directly connected to \fBDTR\fP and \fBpowerd\fP +keeps that line high, so if \fBDSR\fP is low then something is wrong +with the connection. \fBPowerd\fP will notify you about this fact every +two minutes. When it sees that the connection has been restored it +will say so. +.SH HOWTO +It's pretty simple to connect your UPS to the Linux machine. The steps +are easy: +.TP 0.5i +.B 1. +Make sure you have an UPS with a simple relay output: it should +close its connections (make) if the power is gone, and it should +open its connections (break) if the power is good. +.TP 0.5i +.B 2. +Buy a serial plug. Connect the DTR line to the DSR line directly. +Connect the DTR line and the DCD line with a \fB10 kilo ohm\fP +resistor. Now connect the relay output of the UPS to GROUND +and the DCD line. If you don't know what pins DSR, DTR, DCD and +GROUND are you can always ask at the store where you bought the plug. +.TP 0.5i +.B 3. +You're all set. +.SH BUGS +Well, not a real bug but \fBpowerd\fP should be able to do a broadcast or +something on the ethernet in case more Linux-boxes are connected to +the same UPS and only one of them is connected to the UPS status line. +.SH SEE ALSO +.BR shutdown (8), +.BR init (8), +.BR inittab (5) +.SH AUTHOR +Miquel van Smoorenburg, miquels@cistron.nl diff --git a/obsolete/powerd.README b/obsolete/powerd.README new file mode 100644 index 00000000..dd0563c0 --- /dev/null +++ b/obsolete/powerd.README @@ -0,0 +1,36 @@ +There are 2 *much* better powerd's than the one that is included as +an example with sysvinit. The powerd.c in this distribution is just ment +as a programming example, not to be used in a real life situation. + +1. GENPOWERD. + +This is a powerd written by Tom Webster . It's a +nice package, you can find info at http://www.kaiwan.com/~webster/genpower.html + +2. POWERD-2.0. + +This is another powerd, written by rubini@ipvvis.unipv.it (Alessandro Rubini). +The main advantage over genpowerd is that it can signal other machines over +the network. + +This LSM may be out of date. Please check if a newer version exists. + +Begin3 +Title: powerd +Version: 2.0 +Entered-date: Sep 26 1995 +Description: A daemon to shut down and up computers connected to ups's. + Network-aware: server-mode and client-mode allowed. +Keywords: ups, powerd, init +Author: Alessandro Rubini (based on Miquel van Smoorenburg's work). +Maintained-by: rubini@ipvvis.unipv.it (Alessandro Rubini) +Primary-site: sunsite.unc.edu /pub/Linux/system/UPS/powerd-2.0.tar.gz + 25kB powerd-2.0.tar.gz + 1kB powerd-2.0.lsm +Alternate-site: +Original-site: iride.unipv.it /pub/linux + 25kB powerd-2.0.tar.gz + 1kB powerd-2.0.lsm +Platform: Linux. Porting is foreseeable. +Copying-policy: GPL +End diff --git a/obsolete/powerd.c b/obsolete/powerd.c new file mode 100644 index 00000000..fdd31d8e --- /dev/null +++ b/obsolete/powerd.c @@ -0,0 +1,201 @@ +/* + * powerd Monitor the DCD line of a serial port connected to + * an UPS. If the power goes down, notify init. + * If the power comes up again, notify init again. + * As long as the power is OK, the DCD line should be + * "HIGH". When the power fails, DCD should go "LOW". + * Powerd keeps DTR high so that you can connect + * DCD and DTR with a resistor of 10 Kilo Ohm and let the + * UPS or some relais pull the DCD line to ground. + * You also need to connect DTR and DSR together. This + * way, powerd can check now and then if DSR is high + * so it knows the UPS is connected!! + * + * Usage: powerd /dev/cua4 (or any other serial device). + * + * Author: Miquel van Smoorenburg, . + * + * Version: 1.31, 29-Feb-1996. + * + * This program was originally written for my employer, + * ** Cistron Electronics ** + * who has given kind permission to release this program + * for general puppose. + * + * 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 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. */ +#define NEWINIT + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "paths.h" +#ifdef NEWINIT +#include "initreq.h" +#endif + +#ifndef SIGPWR +# define SIGPWR SIGUSR1 +#endif + +#ifdef NEWINIT +void alrm_handler() +{ +} +#endif + +/* Tell init the power has either gone or is back. */ +void powerfail(ok) +int ok; +{ + int fd; +#ifdef NEWINIT + struct init_request req; + + /* Fill out the request struct. */ + memset(&req, 0, sizeof(req)); + req.magic = INIT_MAGIC; + req.cmd = ok ? INIT_CMD_POWEROK : INIT_CMD_POWERFAIL; + + /* Open the fifo (with timeout) */ + signal(SIGALRM, alrm_handler); + alarm(3); + if ((fd = open(INIT_FIFO, O_WRONLY)) >= 0 + && write(fd, &req, sizeof(req)) == sizeof(req)) { + close(fd); + return; + } + /* Fall through to the old method.. */ +#endif + + /* Create an info file for init. */ + unlink(PWRSTAT); + if ((fd = open(PWRSTAT, O_CREAT|O_WRONLY, 0644)) >= 0) { + if (ok) + write(fd, "OK\n", 3); + else + write(fd, "FAIL\n", 5); + close(fd); + } + kill(1, SIGPWR); +} + +/* Main program. */ +int main(int argc, char **argv) +{ + int fd; + int dtr_bit = TIOCM_DTR; + int flags; + int status, oldstat = -1; + int count = 0; + int tries = 0; + + if (argc < 2) { + fprintf(stderr, "Usage: powerd \n"); + exit(1); + } + + /* Start syslog. */ + openlog("powerd", LOG_CONS|LOG_PERROR, LOG_DAEMON); + + /* Open monitor device. */ + if ((fd = open(argv[1], O_RDWR | O_NDELAY)) < 0) { + syslog(LOG_ERR, "%s: %s", argv[1], sys_errlist[errno]); + closelog(); + exit(1); + } + + /* Line is opened, so DTR is high. Force it anyway to be sure. */ + ioctl(fd, TIOCMBIS, &dtr_bit); + + /* Daemonize. */ + switch(fork()) { + case 0: /* Child */ + closelog(); + setsid(); + break; + case -1: /* Error */ + syslog(LOG_ERR, "can't fork."); + closelog(); + exit(1); + default: /* Parent */ + closelog(); + exit(0); + } + + /* Restart syslog. */ + openlog("powerd", LOG_CONS, LOG_DAEMON); + + /* Now sample the DCD line. */ + while(1) { + /* Get the status. */ + ioctl(fd, TIOCMGET, &flags); + + /* Check the connection: DSR should be high. */ + tries = 0; + while((flags & TIOCM_DSR) == 0) { + /* Keep on trying, and warn every two minutes. */ + if ((tries % 60) == 0) + syslog(LOG_ALERT, "UPS connection error"); + sleep(2); + tries++; + ioctl(fd, TIOCMGET, &flags); + } + if (tries > 0) + syslog(LOG_ALERT, "UPS connection OK"); + + /* Calculate present status. */ + status = (flags & TIOCM_CAR); + + /* Did DCD drop to zero? Then the power has failed. */ + if (oldstat != 0 && status == 0) { + count++; + if (count > 3) + powerfail(0); + else { + sleep(1); + continue; + } + } + /* Did DCD come up again? Then the power is back. */ + if (oldstat == 0 && status > 0) { + count++; + if (count > 3) + powerfail(1); + else { + sleep(1); + continue; + } + } + /* Reset count, remember status and sleep 2 seconds. */ + count = 0; + oldstat = status; + sleep(2); + } + /* Never happens */ + return(0); +} diff --git a/obsolete/powerd.cfg b/obsolete/powerd.cfg new file mode 100644 index 00000000..65a76f0a --- /dev/null +++ b/obsolete/powerd.cfg @@ -0,0 +1,58 @@ +# Example configuration for power daemon. +# NOTE: this is not implemented yet, just a design. +# +# @(#) powerd.cfg 1.01 01-Oct-1994 MvS +# + +# This is the setup section. It sets up the default line +# signals that your UPS likes to see. +[ setup ] +dtr = 1 +rts = 1 +baud = 2400 +send "AAAA" + +# Now: how to tell UPS to turn off the power. +[ powerdown ] +dtr = 0 +send "BYE" + +# How to monitor the UPS, or a remote UPS. +# Possible line signals: dcd cts dsr ring +# +# Comment out the parts you don't want. +# +# All of this (1, 2, 3) can be combined. +[ monitor ] + +# First, do we want to broadcast the UPS status +# on ethernet when something happens? +# Comment out to disable. +# Syntax: address, portnumber +# address: broadcast adress on ethernet +# portnumber: unused priviliged port (under 1024) +broadcast = 10.0.33.255,15 + +# monitor type 1. This tells powerd to monitor line signals. +ok = dcd +fail = !dcd +lowbat = rts + +# Monitor type 2. Tell powerd to look for data. +ok = "OK" +fail = "!" + +# Monitor type 3. Listen to the ethernet. +# +# Warn_host is the hostname of the system with the UPS +# This is for security, so that someone on a DOS box +# can't spoof the powerd broadcast. The number after it +# is the portnumber to listen to (see above: broadcast). +# +# Note: if the broadcast address set above is enabled +# and we receive a message from a remote powerd, we check +# the received broadcast address. If this is the same +# as from the broadcast we just received, +# it will not be repeated (guess why). +remote = warn_host,15 + diff --git a/obsolete/utmpdump.c.OLD b/obsolete/utmpdump.c.OLD new file mode 100644 index 00000000..91613969 --- /dev/null +++ b/obsolete/utmpdump.c.OLD @@ -0,0 +1,70 @@ +/* + * utmpdump Simple program to dump UTMP and WTMP files in + * raw format, so they can be examined. + * + * Version: @(#)utmpdump.c 13-Aug-1996 1.00 miquels@cistron.nl + * + * This file is part of the sysvinit suite, + * 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 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 +#include +#include + +void dump(fp) +FILE *fp; +{ + struct utmp ut; + int f; + time_t tm; + + while (fread(&ut, sizeof(struct utmp), 1, fp) == 1) { + for(f = 0; f < 12; f++) if (ut.ut_line[f] == ' ') ut.ut_line[f] = '_'; + for(f = 0; f < 8; f++) if (ut.ut_name[f] == ' ') ut.ut_name[f] = '_'; + tm = ut.ut_time; + printf("[%d] [%05d] [%-4.4s] [%-8.8s] [%-12.12s] [%-15.15s]\n", + ut.ut_type, ut.ut_pid, ut.ut_id, ut.ut_user, + ut.ut_line, 4 + ctime(&tm)); + } +} + +int main(argc, argv) +int argc; +char **argv; +{ + int f; + FILE *fp; + + if (argc < 2) { + argc = 2; + argv[1] = UTMP_FILE; + } + + for(f = 1; f < argc; f++) { + if (strcmp(argv[f], "-") == 0) { + printf("Utmp dump of stdin\n"); + dump(stdin); + } else if ((fp = fopen(argv[f], "r")) != NULL) { + printf("Utmp dump of %s\n", argv[f]); + dump(fp); + fclose(fp); + } else + perror(argv[f]); + } + return(0); +} diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 00000000..e2b8028c --- /dev/null +++ b/src/Makefile @@ -0,0 +1,183 @@ +# +# Makefile Makefile for the systemV init suite. +# Targets: all compiles everything +# install installs the binaries (not the scripts) +# clean cleans up object files +# clobber really cleans up +# +# Version: @(#)Makefile 2.85-13 23-Mar-2004 miquels@cistron.nl +# + +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 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 fstab-decode.8 + +ifeq ($(DISTRO),) +BIN += mountpoint +SBIN += sulogin bootlogd +USRBIN += utmpdump wall +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 +MAN8 += sulogin.8 bootlogd.8 +endif + +ifeq ($(DISTRO),Owl) +USRBIN += wall +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) +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 + INITLIBS += -lsepol -lselinux + SULOGINLIBS = -lselinux +else + SELINUX_DEF = + INITLIBS = + SULOGINLIBS = +endif + +# Additional libs for GNU libc. +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 + +halt: halt.o ifdown.o hddown.o utmp.o reboot.h + +last: last.o oldutmp.h + +mesg: mesg.o + +mountpoint: mountpoint.o + +utmpdump: utmpdump.o + +runlevel: runlevel.o + +sulogin: LDLIBS += $(SULOGINLIBS) $(STATIC) +sulogin: sulogin.o + +wall: dowall.o wall.o + +shutdown: dowall.o shutdown.o utmp.o reboot.h + +bootlogd: LDLIBS += -lutil +bootlogd: bootlogd.o + +sulogin.o: CPPFLAGS += $(SELINUX_DEF) +sulogin.o: sulogin.c + +init.o: CPPFLAGS += $(SELINUX_DEF) +init.o: init.c init.h set.h reboot.h initreq.h + +utmp.o: utmp.c init.h + +init_utmp.o: CPPFLAGS += -DINIT_MAIN +init_utmp.o: utmp.c init.h + $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< + +cleanobjs: + rm -f *.o *.bak + +clean: cleanobjs + @echo Type \"make clobber\" to really clean up. + +clobber: cleanobjs + rm -f $(BIN) $(SBIN) $(USRBIN) + +distclean: clobber + +install: + $(INSTALL_DIR) $(ROOT)/bin/ $(ROOT)/sbin/ + $(INSTALL_DIR) $(ROOT)/usr/bin/ + for i in $(BIN); do \ + $(INSTALL_EXEC) $$i $(ROOT)/bin/ ; \ + done + for i in $(SBIN); do \ + $(INSTALL_EXEC) $$i $(ROOT)/sbin/ ; \ + done + for i in $(USRBIN); do \ + $(INSTALL_EXEC) $$i $(ROOT)/usr/bin/ ; \ + done + # $(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 + ln -sf /sbin/killall5 $(ROOT)/bin/pidof + 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 + for i in $(MAN5); do \ + $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man5/; \ + done + for i in $(MAN8); do \ + $(INSTALL_DATA) ../man/$$i $(ROOT)$(MANDIR)/man8/; \ + done +ifeq ($(ROOT),) + # + # This part is skipped on Debian systems, the + # debian.preinst script takes care of it. + @if [ ! -p /dev/initctl ]; then \ + echo "Creating /dev/initctl"; \ + rm -f /dev/initctl; \ + mknod -m 600 /dev/initctl p; fi +endif diff --git a/src/bootlogd.c b/src/bootlogd.c new file mode 100644 index 00000000..570d3822 --- /dev/null +++ b/src/bootlogd.c @@ -0,0 +1,690 @@ +/* + * bootlogd.c Store output from the console during bootup into a file. + * The file is usually located on the /var partition, and + * gets written (and fsynced) as soon as possible. + * + * Version: @(#)bootlogd 2.86pre 12-Jan-2004 miquels@cistron.nl + * + * Bugs: Uses openpty(), only available in glibc. Sorry. + * + * This file is part of the sysvinit suite, + * 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 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 + * + * I have bigger plans for Debian, but for now + * this has to do ;) + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef __linux__ +#include +#endif + +char *Version = "@(#) bootlogd 2.86 03-Jun-2004 miquels@cistron.nl"; + +#define LOGFILE "/var/log/boot" + +char ringbuf[32768]; +char *endptr = ringbuf + sizeof(ringbuf); +char *inptr = ringbuf; +char *outptr = ringbuf; + +int got_signal = 0; +int didnl = 1; +int createlogfile = 0; +int syncalot = 0; + +struct line { + char buf[256]; + int pos; +} line; + +/* + * Console devices as listed on the kernel command line and + * the mapping to actual devices in /dev + */ +struct consdev { + char *cmdline; + char *dev1; + char *dev2; +} consdev[] = { + { "ttyB", "/dev/ttyB%s", NULL }, + { "ttySC", "/dev/ttySC%s", "/dev/ttsc/%s" }, + { "ttyS", "/dev/ttyS%s", "/dev/tts/%s" }, + { "tty", "/dev/tty%s", "/dev/vc/%s" }, + { "hvc", "/dev/hvc%s", "/dev/hvc/%s" }, + { NULL, NULL, NULL }, +}; + +/* + * Devices to try as console if not found on kernel command line. + * Tried from left to right (as opposed to kernel cmdline). + */ +char *defcons[] = { "tty0", "hvc0", "ttyS0", "ttySC0", "ttyB0", NULL }; + +/* + * Catch signals. + */ +void handler(int sig) +{ + got_signal = sig; +} + + +/* + * Scan /dev and find the device name. + */ +static int findtty(char *res, const char *startdir, int rlen, dev_t dev) +{ + DIR *dir; + struct dirent *ent; + struct stat st; + int r = -1; + char *olddir = getcwd(NULL, 0); + + 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) { + 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; + } + } + } + closedir(dir); + + chdir(olddir); + return r; +} + +/* + * For some reason, openpty() in glibc sometimes doesn't + * work at boot-time. It must be a bug with old-style pty + * names, as new-style (/dev/pts) is not available at that + * point. So, we find a pty/tty pair ourself if openpty() + * fails for whatever reason. + */ +int findpty(int *master, int *slave, char *name) +{ + char pty[16]; + char tty[16]; + int i, j; + int found; + + if (openpty(master, slave, name, NULL, NULL) >= 0) + return 0; + + found = 0; + + for (i = 'p'; i <= 'z'; i++) { + for (j = '0'; j <= 'f'; j++) { + if (j == '9' + 1) j = 'a'; + sprintf(pty, "/dev/pty%c%c", i, j); + sprintf(tty, "/dev/tty%c%c", i, j); + if ((*master = open(pty, O_RDWR|O_NOCTTY)) >= 0) { + *slave = open(tty, O_RDWR|O_NOCTTY); + if (*slave >= 0) { + found = 1; + break; + } + } + } + if (found) break; + } + if (!found) return -1; + + if (name) strcpy(name, tty); + + return 0; +} +/* + * See if a console taken from the kernel command line maps + * to a character device we know about, and if we can open it. + */ +int isconsole(char *s, char *res, int rlen) +{ + struct consdev *c; + int l, sl, i, fd; + char *p, *q; + + sl = strlen(s); + + for (c = consdev; c->cmdline; c++) { + l = strlen(c->cmdline); + if (sl <= l) continue; + p = s + l; + if (strncmp(s, c->cmdline, l) != 0 || !isdigit(*p)) + continue; + for (i = 0; i < 2; i++) { + snprintf(res, rlen, i ? c->dev1 : c->dev2, p); + if ((q = strchr(res, ',')) != NULL) *q = 0; + if ((fd = open(res, O_RDONLY|O_NONBLOCK)) >= 0) { + close(fd); + return 1; + } + } + } + return 0; +} + +/* + * Find out the _real_ console. Assume that stdin is connected to + * the console device (/dev/console). + */ +int consolename(char *res, int rlen) +{ +#ifdef TIOCGDEV + unsigned int kdev; +#endif + struct stat st, st2; + char buf[256]; + char *p; + int didmount = 0; + int n, r; + int fd; + + fstat(0, &st); + if (major(st.st_rdev) != 5 || minor(st.st_rdev) != 1) { + /* + * Old kernel, can find real device easily. + */ + 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 +# 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 + +#ifdef __linux__ + /* + * Read /proc/cmdline. + */ + stat("/", &st); + if (stat("/proc", &st2) < 0) { + perror("bootlogd: /proc"); + return -1; + } + if (st.st_dev == st2.st_dev) { + if (mount("proc", "/proc", "proc", 0, NULL) < 0) { + perror("bootlogd: mount /proc"); + return -1; + } + didmount = 1; + } + + n = 0; + r = -1; + if ((fd = open("/proc/cmdline", O_RDONLY)) < 0) { + perror("bootlogd: /proc/cmdline"); + } else { + buf[0] = 0; + if ((n = read(fd, buf, sizeof(buf) - 1)) >= 0) + r = 0; + else + perror("bootlogd: /proc/cmdline"); + close(fd); + } + if (didmount) umount("/proc"); + + if (r < 0) return r; + + /* + * OK, so find console= in /proc/cmdline. + * Parse in reverse, opening as we go. + */ + p = buf + n; + *p-- = 0; + r = -1; + while (p >= buf) { + if (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n') { + *p-- = 0; + continue; + } + if (strncmp(p, "console=", 8) == 0 && + isconsole(p + 8, res, rlen)) { + r = 0; + break; + } + p--; + } + + if (r == 0) return r; +#endif + + /* + * Okay, no console on the command line - + * guess the default console. + */ + for (n = 0; defcons[n]; n++) + if (isconsole(defcons[n], res, rlen)) + return 0; + + fprintf(stderr, "bootlogd: cannot deduce real console device\n"); + + return -1; +} + + +/* + * Write data and make sure it's on disk. + */ +void writelog(FILE *fp, unsigned char *ptr, int len) +{ + time_t t; + char *s; + char tmp[8]; + int olen = len; + int dosync = 0; + int tlen; + + while (len > 0) { + tmp[0] = 0; + if (didnl) { + time(&t); + s = ctime(&t); + fprintf(fp, "%.24s: ", s); + didnl = 0; + } + switch (*ptr) { + case 27: /* ESC */ + strcpy(tmp, "^["); + break; + case '\r': + line.pos = 0; + break; + case 8: /* ^H */ + if (line.pos > 0) line.pos--; + break; + case '\n': + didnl = 1; + dosync = 1; + break; + case '\t': + line.pos += (line.pos / 8 + 1) * 8; + if (line.pos >= (int)sizeof(line.buf)) + line.pos = sizeof(line.buf) - 1; + break; + case 32 ... 127: + case 161 ... 255: + tmp[0] = *ptr; + tmp[1] = 0; + break; + default: + sprintf(tmp, "\\%03o", *ptr); + break; + } + ptr++; + len--; + + tlen = strlen(tmp); + if (tlen && (line.pos + tlen < (int)sizeof(line.buf))) { + memcpy(line.buf + line.pos, tmp, tlen); + line.pos += tlen; + } + if (didnl) { + fprintf(fp, "%s\n", line.buf); + memset(&line, 0, sizeof(line)); + } + } + + if (dosync) { + fflush(fp); + if (syncalot) { + fdatasync(fileno(fp)); + } + } + + outptr += olen; + if (outptr >= endptr) + outptr = ringbuf; + +} + + +/* + * Print usage message and exit. + */ +void usage(void) +{ + fprintf(stderr, "Usage: bootlogd [-v] [-r] [-d] [-s] [-c] [-p pidfile] [-l logfile]\n"); + exit(1); +} + +int open_nb(char *buf) +{ + int fd, n; + + if ((fd = open(buf, O_WRONLY|O_NONBLOCK|O_NOCTTY)) < 0) + return -1; + n = fcntl(fd, F_GETFL); + n &= ~(O_NONBLOCK); + fcntl(fd, F_SETFL, n); + + return fd; +} + +/* + * We got a write error on the real console. If its an EIO, + * somebody hung up our filedescriptor, so try to re-open it. + */ +int write_err(int pts, int realfd, char *realcons, int e) +{ + int fd; + + if (e != EIO) { +werr: + close(pts); + fprintf(stderr, "bootlogd: writing to console: %s\n", + strerror(e)); + return -1; + } + close(realfd); + if ((fd = open_nb(realcons)) < 0) + goto werr; + + return fd; +} + +int main(int argc, char **argv) +{ + FILE *fp; + struct timeval tv; + fd_set fds; + char buf[1024]; + char realcons[1024]; + char *p; + char *logfile; + char *pidfile; + int rotate; + int dontfork; + int ptm, pts; + int realfd; + int n, m, i; + int todo; + + fp = NULL; + logfile = LOGFILE; + pidfile = NULL; + rotate = 0; + dontfork = 0; + + while ((i = getopt(argc, argv, "cdsl:p:rv")) != EOF) switch(i) { + case 'l': + logfile = optarg; + break; + case 'r': + rotate = 1; + break; + case 'v': + printf("%s\n", Version); + exit(0); + break; + case 'p': + pidfile = optarg; + break; + case 'c': + createlogfile = 1; + break; + case 'd': + dontfork = 1; + break; + case 's': + syncalot = 1; + break; + default: + usage(); + break; + } + if (optind < argc) usage(); + + signal(SIGTERM, handler); + signal(SIGQUIT, handler); + signal(SIGINT, handler); + signal(SIGTTIN, SIG_IGN); + signal(SIGTTOU, SIG_IGN); + signal(SIGTSTP, SIG_IGN); + + /* + * Open console device directly. + */ + if (consolename(realcons, sizeof(realcons)) < 0) + return 1; + + if (strcmp(realcons, "/dev/tty0") == 0) + strcpy(realcons, "/dev/tty1"); + if (strcmp(realcons, "/dev/vc/0") == 0) + strcpy(realcons, "/dev/vc/1"); + + if ((realfd = open_nb(realcons)) < 0) { + fprintf(stderr, "bootlogd: %s: %s\n", buf, strerror(errno)); + return 1; + } + + /* + * Grab a pty, and redirect console messages to it. + */ + ptm = -1; + pts = -1; + buf[0] = 0; + if (findpty(&ptm, &pts, buf) < 0) { + fprintf(stderr, + "bootlogd: cannot allocate pseudo tty: %s\n", + strerror(errno)); + return 1; + } + + (void)ioctl(0, TIOCCONS, NULL); +#if 1 + /* Work around bug in 2.1/2.2 kernels. Fixed in 2.2.13 and 2.3.18 */ + if ((n = open("/dev/tty0", O_RDWR)) >= 0) { + (void)ioctl(n, TIOCCONS, NULL); + close(n); + } +#endif + if (ioctl(pts, TIOCCONS, NULL) < 0) { + fprintf(stderr, "bootlogd: ioctl(%s, TIOCCONS): %s\n", + buf, strerror(errno)); + return 1; + } + + /* + * Fork and write pidfile if needed. + */ + if (!dontfork) { + pid_t child_pid = fork(); + switch (child_pid) { + case -1: /* I am parent and the attempt to create a child failed */ + fprintf(stderr, "bootlogd: fork failed: %s\n", + strerror(errno)); + exit(1); + break; + case 0: /* I am the child */ + break; + default: /* I am parent and got child's pid */ + exit(0); + break; + } + setsid(); + } + if (pidfile) { + unlink(pidfile); + if ((fp = fopen(pidfile, "w")) != NULL) { + fprintf(fp, "%d\n", (int)getpid()); + fclose(fp); + } + fp = NULL; + } + + /* + * Read the console messages from the pty, and write + * to the real console and the logfile. + */ + while (!got_signal) { + + /* + * We timeout after 5 seconds if we still need to + * open the logfile. There might be buffered messages + * we want to write. + */ + tv.tv_sec = 0; + tv.tv_usec = 500000; + FD_ZERO(&fds); + FD_SET(ptm, &fds); + if (select(ptm + 1, &fds, NULL, NULL, &tv) == 1) { + /* + * See how much space there is left, read. + */ + if ((n = read(ptm, inptr, endptr - inptr)) >= 0) { + /* + * Write data (in chunks if needed) + * to the real output device. + */ + m = n; + p = inptr; + while (m > 0) { + i = write(realfd, p, m); + if (i >= 0) { + m -= i; + p += i; + continue; + } + /* + * Handle EIO (somebody hung + * up our filedescriptor) + */ + realfd = write_err(pts, realfd, + realcons, errno); + if (realfd >= 0) continue; + got_signal = 1; /* Not really */ + break; + } + + /* + * Increment buffer position. Handle + * wraps, and also drag output pointer + * along if we cross it. + */ + inptr += n; + if (inptr - n < outptr && inptr > outptr) + outptr = inptr; + if (inptr >= endptr) + inptr = ringbuf; + if (outptr >= endptr) + outptr = ringbuf; + } + } + + /* + * Perhaps we need to open the logfile. + */ + if (fp == NULL && access(logfile, F_OK) == 0) { + if (rotate) { + snprintf(buf, sizeof(buf), "%s~", logfile); + rename(logfile, buf); + } + fp = fopen(logfile, "a"); + } + if (fp == NULL && createlogfile) + fp = fopen(logfile, "a"); + + if (inptr >= outptr) + todo = inptr - outptr; + else + todo = endptr - outptr; + if (fp && todo) + writelog(fp, (unsigned char *)outptr, todo); + } + + if (fp) { + if (!didnl) fputc('\n', fp); + fclose(fp); + } + + close(pts); + close(ptm); + close(realfd); + + return 0; +} + diff --git a/src/dowall.c b/src/dowall.c new file mode 100644 index 00000000..85645c03 --- /dev/null +++ b/src/dowall.c @@ -0,0 +1,253 @@ +/* + * dowall.c Write to all users on the system. + * + * Author: Miquel van Smoorenburg, miquels@cistron.nl + * + * Version: @(#)dowall.c 2.85-5 02-Jul-2003 miquels@cistron.nl + * + * This file is part of the sysvinit suite, + * 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 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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); +} + + +/* + * Print a text, escape all characters not in Latin-1. + */ +static void feputs(const char *line, FILE *fp) +{ + unsigned char *p; + + for (p = (unsigned char *)line; *p; p++) { + if (strchr("\t\r\n", *p) || + (*p >= 32 && *p <= 127) || (*p >= 160)) { + fputc(*p, fp); + } else { + fprintf(fp, "^%c", (*p & 0x1f) + 'A' - 1); + } + } + fflush(fp); +} + + +static void getuidtty(char **userp, char **ttyp) +{ + struct passwd *pwd; + uid_t uid; + char *tty; + static char uidbuf[32]; + static char ttynm[UT_LINESIZE + 4]; + static int init = 0; + + if (!init) { + + uid = getuid(); + if ((pwd = getpwuid(uid)) != NULL) { + uidbuf[0] = 0; + strncat(uidbuf, pwd->pw_name, sizeof(uidbuf) - 1); + } else { + sprintf(uidbuf, uid ? "uid %d" : "root", (int)uid); + } + + if ((tty = ttyname(0)) != NULL) { + 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++; + } + + *userp = uidbuf; + *ttyp = ttynm; +} + +/* + * Check whether given filename looks like tty device. + */ +static int file_isatty(const char *fname) +{ + struct stat st; + int major; + + if (stat(fname, &st) < 0) + return 0; + + if (st.st_nlink != 1 || !S_ISCHR(st.st_mode)) + return 0; + + /* + * It would be an impossible task to list all major/minors + * of tty devices here, so we just exclude the obvious + * majors of which just opening has side-effects: + * printers and tapes. + */ + major = major(st.st_dev); + if (major == 1 || major == 2 || major == 6 || major == 9 || + major == 12 || major == 16 || major == 21 || major == 27 || + major == 37 || major == 96 || major == 97 || major == 206 || + major == 230) return 0; + + return 1; +} + +/* + * Wall function. + */ +void wall(const char *text, int remote) +{ + FILE *tp; + struct sigaction sa; + struct utmp *utmp; + time_t t; + char term[UT_LINESIZE+ strlen(_PATH_DEV) + 1]; + char line[81]; + char hostname[HOST_NAME_MAX+1]; + char *date, *p; + char *user, *tty; + int fd, flags; + + /* + * Make sure tp and fd aren't in a register. Some versions + * of gcc clobber those after longjmp (or so I understand). + */ + (void) &tp; + (void) &fd; + + getuidtty(&user, &tty); + + /* Get and report current hostname, to make it easier to find + out which machine is being shut down. */ + if (0 != gethostname(hostname, sizeof(hostname))) { + strncpy(hostname, "[unknown]", sizeof(hostname)-1); + } + /* If hostname is truncated, it is unspecified if the string + is null terminated or not. Make sure we know it is null + terminated. */ + hostname[sizeof(hostname)-1] = 0; + + /* Get the time */ + time(&t); + date = ctime(&t); + for(p = date; *p && *p != '\n'; p++) + ; + *p = 0; + + if (remote) { + snprintf(line, sizeof(line), + "\007\r\nRemote broadcast message (%s):\r\n\r\n", + date); + } else { + snprintf(line, sizeof(line), + "\007\r\nBroadcast message from %s@%s %s(%s):\r\n\r\n", + user, hostname, tty, date); + } + + /* + * Fork to avoid us hanging in a write() + */ + if (fork() != 0) + return; + + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = handler; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sigaction(SIGALRM, &sa, NULL); + + setutent(); + + while ((utmp = getutent()) != NULL) { + if(utmp->ut_type != USER_PROCESS || + utmp->ut_user[0] == 0) continue; + 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), _PATH_DEV "%.*s", + UT_LINESIZE, utmp->ut_line); + if (strstr(term, "/../")) continue; + + fd = -1; + tp = NULL; + + /* + * Open it non-delay + */ + if (sigsetjmp(jbuf, 1) == 0) { + alarm(2); + flags = O_WRONLY|O_NDELAY|O_NOCTTY; + if (file_isatty(term) && + (fd = open(term, flags)) >= 0) { + if (isatty(fd) && + (tp = fdopen(fd, "w")) != NULL) { + fputs(line, tp); + feputs(text, tp); + fflush(tp); + } + } + } + alarm(0); + if (fd >= 0) close(fd); + if (tp != NULL) fclose(tp); + } + endutent(); + + exit(0); +} + diff --git a/src/fstab-decode.c b/src/fstab-decode.c new file mode 100644 index 00000000..4a162dfe --- /dev/null +++ b/src/fstab-decode.c @@ -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 */ + +#include +#include +#include +#include +#include + +/* 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; +} diff --git a/src/halt.c b/src/halt.c new file mode 100644 index 00000000..499e9734 --- /dev/null +++ b/src/halt.c @@ -0,0 +1,315 @@ +/* + * Halt Stop the system running. + * It re-enables CTRL-ALT-DEL, so that a hard reboot can + * be done. If called as reboot, it will reboot the system. + * + * If the system is not in runlevel 0 or 6, halt will just + * execute a "shutdown -h" to halt the system, and reboot will + * execute an "shutdown -r". This is for compatibility with + * sysvinit 2.4. + * + * Usage: halt [-n] [-w] [-d] [-f] [-h] [-i] [-p] + * -n: don't sync before halting the system + * -w: only write a wtmp reboot record and exit. + * -d: don't write a wtmp record. + * -f: force halt/reboot, don't call shutdown. + * -h: put harddisks in standby mode + * -i: shut down all network interfaces. + * -p: power down the system (if possible, otherwise halt). + * + * Reboot and halt are both this program. Reboot + * is just a link to halt. Invoking the program + * as poweroff implies the -p option. + * + * Author: Miquel van Smoorenburg, miquels@cistron.nl + * + * Version: 2.86, 30-Jul-2004 + * + * This file is part of the sysvinit suite, + * 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 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "reboot.h" + +char *Version = "@(#)halt 2.86 31-Jul-2004 miquels@cistron.nl"; +char *progname; + +#define KERNEL_MONITOR 1 /* If halt() puts you into the kernel monitor. */ +#define RUNLVL_PICKY 0 /* Be picky about the runlevel */ + +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); + +/* + * Send usage message. + */ +void usage(void) +{ + fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i]%s\n", + progname, strcmp(progname, "halt") ? "" : " [-p]"); + fprintf(stderr, "\t-n: don't sync before halting the system\n"); + fprintf(stderr, "\t-w: only write a wtmp reboot record and exit.\n"); + fprintf(stderr, "\t-d: don't write a wtmp record.\n"); + fprintf(stderr, "\t-f: force halt/reboot, don't call shutdown.\n"); + fprintf(stderr, "\t-h: put harddisks in standby mode.\n"); + fprintf(stderr, "\t-i: shut down all network interfaces.\n"); + if (!strcmp(progname, "halt")) + fprintf(stderr, "\t-p: power down the system (if possible, otherwise halt).\n"); + exit(1); +} + +/* + * See if we were started directly from init. + * Get the runlevel from /var/run/utmp or the environment. + */ +int get_runlevel(void) +{ + struct utmp *ut; + char *r; +#if RUNLVL_PICKY + time_t boottime; +#endif + + /* + * First see if we were started directly from init. + */ + if (getenv("INIT_VERSION") && (r = getenv("RUNLEVEL")) != NULL) + return *r; + + /* + * Hmm, failed - read runlevel from /var/run/utmp.. + */ +#if RUNLVL_PICKY + /* + * Get boottime from the kernel. + */ + time(&boottime); + boottime -= (times(NULL) / HZ); +#endif + + /* + * Find runlevel in utmp. + */ + setutent(); + while ((ut = getutent()) != NULL) { +#if RUNLVL_PICKY + /* + * Only accept value if it's from after boottime. + */ + if (ut->ut_type == RUN_LVL && ut->ut_time > boottime) + return (ut->ut_pid & 255); +#else + if (ut->ut_type == RUN_LVL) + return (ut->ut_pid & 255); +#endif + } + endutent(); + + /* This should not happen but warn the user! */ + fprintf(stderr, "WARNING: could not determine runlevel" + " - doing soft %s\n", progname); + fprintf(stderr, " (it's better to use shutdown instead of %s" + " from the command line)\n", progname); + + return -1; +} + +/* + * Switch to another runlevel. + */ +void do_shutdown(char *fl, char *tm) +{ + char *args[8]; + int i = 0; + + args[i++] = "shutdown"; + args[i++] = fl; + if (tm) { + args[i++] = "-t"; + args[i++] = tm; + } + args[i++] = "now"; + args[i++] = NULL; + + execv("/sbin/shutdown", args); + execv("/etc/shutdown", args); + execv("/bin/shutdown", args); + + perror("shutdown"); + exit(1); +} + +/* + * Main program. + * Write a wtmp entry and reboot cq. halt. + */ +int main(int argc, char **argv) +{ + int do_reboot = 0; + int do_sync = 1; + int do_wtmp = 1; + int do_nothing = 0; + int do_hard = 0; + int do_ifdown = 0; + int do_hddown = 0; + int do_poweroff = 0; + int c; + char *tm = NULL; + + /* + * Find out who we are + */ + /* Remove dash passed on in argv[0] when used as login shell. */ + if (argv[0][0] == '-') argv[0]++; + if ((progname = strrchr(argv[0], '/')) != NULL) + progname++; + else + progname = argv[0]; + + if (!strcmp(progname, "reboot")) do_reboot = 1; + if (!strcmp(progname, "poweroff")) do_poweroff = 1; + + /* + * Get flags + */ + while((c = getopt(argc, argv, ":ihdfnpwt:")) != EOF) { + switch(c) { + case 'n': + do_sync = 0; + do_wtmp = 0; + break; + case 'w': + do_nothing = 1; + break; + case 'd': + do_wtmp = 0; + break; + case 'f': + do_hard = 1; + break; + case 'i': + do_ifdown = 1; + break; + case 'h': + do_hddown = 1; + break; + case 'p': + do_poweroff = 1; + break; + case 't': + tm = optarg; + break; + default: + usage(); + } + } + if (argc != optind) usage(); + + if (geteuid() != 0) { + fprintf(stderr, "%s: must be superuser.\n", progname); + exit(1); + } + + (void)chdir("/"); + + if (!do_hard && !do_nothing) { + /* + * See if we are in runlevel 0 or 6. + */ + c = get_runlevel(); + if (c != '0' && c != '6') + do_shutdown(do_reboot ? "-r" : "-h", tm); + } + + /* + * Record the fact that we're going down + */ + if (do_wtmp) + write_wtmp("shutdown", "~~", 0, RUN_LVL, "~~"); + + /* + * Exit if all we wanted to do was write a wtmp record. + */ + if (do_nothing && !do_hddown && !do_ifdown) exit(0); + + if (do_sync) { + sync(); + sleep(2); + } + + if (do_ifdown) + (void)ifdown(); + + if (do_hddown) + (void)hddown(); + else + (void)hdflush(); + + if (do_nothing) exit(0); + + if (do_reboot) { + init_reboot(BMAGIC_REBOOT); + } else { + /* + * Turn on hard reboot, CTRL-ALT-DEL will reboot now + */ +#ifdef BMAGIC_HARD + init_reboot(BMAGIC_HARD); +#endif + + /* + * Stop init; it is insensitive to the signals sent + * by the kernel. + */ + kill(1, SIGTSTP); + + /* + * Halt or poweroff. + */ + if (do_poweroff) + init_reboot(BMAGIC_POWEROFF); + /* + * Fallthrough if failed. + */ + init_reboot(BMAGIC_HALT); + } + + /* + * If we return, we (c)ontinued from the kernel monitor. + */ +#ifdef BMAGIC_SOFT + init_reboot(BMAGIC_SOFT); +#endif + kill(1, SIGCONT); + + exit(0); +} diff --git a/src/hddown.c b/src/hddown.c new file mode 100644 index 00000000..45e6630c --- /dev/null +++ b/src/hddown.c @@ -0,0 +1,568 @@ +/* + * 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@cistron.nl"; + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif +#include +#include +#include +#include +#include +#include +#include + +#ifdef __linux__ + +#include +#include +#include + +#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. + * Author: Werner Fink , 2007/06/12 + * + */ +#include +#include +#include +#include +#ifdef WORDS_BIGENDIAN +#include +#endif + +#define SYS_BLK "/sys/block" +#define SYS_CLASS "/sys/class/scsi_disk" +#define DEV_BASE "/dev" +#define ISSPACE(c) (((c)==' ')||((c)=='\n')||((c)=='\t')||((c)=='\v')||((c)=='\r')||((c)=='\f')) + +/* Used in flush_cache_ext(), compare with */ +#define IDBYTES 512 +#define MASK_EXT 0xE000 /* Bit 15 shall be zero, bit 14 shall be one, bit 13 flush cache ext */ +#define TEST_EXT 0x6000 + +/* Maybe set in list_disks() and used in do_standby_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); +static int flush_cache_ext(const char *device); + +/* + * Find all disks through /sys/block. + */ +static char *list_disks(DIR* blk, unsigned int* flags) +{ + struct dirent *d; + + while ((d = readdir(blk))) { + (*flags) = 0; + if (d->d_name[1] == 'd' && (d->d_name[0] == 'h' || d->d_name[0] == 's')) { + char buf[NAME_MAX+1], lnk[NAME_MAX+1], *ptr; + FILE *fp; + int ret; + + fp = hdopen(SYS_BLK "/%s/removable", d->d_name); + if ((long)fp <= 0) { + if ((long)fp < 0) + goto empty; /* error */ + continue; /* no entry `removable' */ + } + + ret = getc(fp); + fclose(fp); + + if (ret != '0') + (*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) + goto empty; + (*flags) |= DISK_EXTFLUSH; + } + break; /* old IDE disk not managed by kernel, out here */ + } + + ret = snprintf(buf, sizeof(buf), SYS_BLK "/%s/device", d->d_name); + if ((ret >= (int)sizeof(buf)) || (ret < 0)) + goto empty; /* error */ + + ret = readlink(buf, lnk, sizeof(lnk)); + if (ret >= (int)sizeof(lnk)) + goto empty; /* error */ + if (ret < 0) { + if (errno != ENOENT) + goto empty; /* error */ + continue; /* no entry `device' */ + } + lnk[ret] = '\0'; + + ptr = basename(lnk); + if (!ptr || !*ptr) + continue; /* should not happen */ + + 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); + + if (ret != '0') { + (*flags) |= DISK_MANAGED; + continue; + } + } + + fp = hdopen(SYS_BLK "/%s/device/vendor", d->d_name); + if ((long)fp <= 0) { + if ((long)fp < 0) + goto empty; /* error */ + continue; /* no entry `device/vendor' */ + } + + ptr = fgets(buf, sizeof(buf), fp); + fclose(fp); + if (ptr == (char*)0) + continue; /* should not happen */ + + ptr = strstrip(buf); + if (*ptr == '\0') + continue; /* should not happen */ + + if (strncmp(buf, "ATA", sizeof(buf)) == 0) { + if ((*flags) & DISK_REMOVABLE) + continue; /* not a hard disk */ + + (*flags) |= (DISK_IS_IDE|DISK_IS_SATA); + if ((ret = flush_cache_ext(d->d_name))) { + if (ret < 0) + goto empty; + (*flags) |= DISK_EXTFLUSH; + } + break; /* new SATA disk to shutdown, out here */ + } + + if (((*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; /* Removable disk like USB stick to shutdown */ + } + } + if (d == (struct dirent*)0) + goto empty; + return d->d_name; +empty: + return (char*)0; +} + +/* + * Put an IDE/SCSI/SATA disk in standby mode. + * Code stolen from hdparm.c + */ +static int do_standby_disk(char *device, unsigned int flags) +{ +#ifndef WIN_STANDBYNOW1 +#define WIN_STANDBYNOW1 0xE0 +#endif +#ifndef WIN_STANDBYNOW2 +#define WIN_STANDBYNOW2 0x94 +#endif +#ifndef WIN_FLUSH_CACHE_EXT +#define WIN_FLUSH_CACHE_EXT 0xEA +#endif +#ifndef WIN_FLUSH_CACHE +#define WIN_FLUSH_CACHE 0xE7 +#endif + unsigned char flush1[4] = {WIN_FLUSH_CACHE_EXT,0,0,0}; + unsigned char flush2[4] = {WIN_FLUSH_CACHE,0,0,0}; + unsigned char stdby1[4] = {WIN_STANDBYNOW1,0,0,0}; + unsigned char stdby2[4] = {WIN_STANDBYNOW2,0,0,0}; + char buf[NAME_MAX+1]; + int fd, ret; + + ret = snprintf(buf, sizeof(buf), DEV_BASE "/%s", device); + if ((ret >= (int)sizeof(buf)) || (ret < 0)) + return -1; + + if ((fd = open(buf, O_RDWR|O_NONBLOCK)) < 0) + return -1; + + switch (flags & DISK_EXTFLUSH) { + case DISK_EXTFLUSH: + if ((ret = ioctl(fd, HDIO_DRIVE_CMD, &flush1)) == 0) + break; + /* Extend flush rejected, try standard flush */ + default: + ret = ioctl(fd, HDIO_DRIVE_CMD, &flush2) && + ioctl(fd, BLKFLSBUF); + break; + } + + if ((flags & DISK_FLUSHONLY) == 0x0) { + ret = ioctl(fd, HDIO_DRIVE_CMD, &stdby1) && + ioctl(fd, HDIO_DRIVE_CMD, &stdby2); + } + + close(fd); + + if (ret) + return -1; + return 0; +} + +/* + * List all disks and put them in standby mode. + * This has the side-effect of flushing the writecache, + * which is exactly what we want on poweroff. + */ +int hddown(void) +{ + unsigned int flags; + char *disk; + DIR *blk; + + if ((blk = opendir(SYS_BLK)) == (DIR*)0) + return -1; + + while ((disk = list_disks(blk, &flags))) + do_standby_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) +{ + const size_t len = strlen(str); + if (len) { + char* end = str + len - 1; + while ((end != str) && ISSPACE(*end)) + end--; + *(end + 1) = '\0'; /* remove trailing white spaces */ + } + return str; +} + +/* + * Open a sysfs file without getting a controlling tty + * and return FILE* pointer. + */ +static FILE *hdopen(const char* const format, const char* const name) +{ + char buf[NAME_MAX+1]; + FILE *fp = (FILE*)-1; + int fd, ret; + + ret = snprintf(buf, sizeof(buf), format, name); + if ((ret >= (int)sizeof(buf)) || (ret < 0)) + goto error; /* error */ + + fd = open(buf, O_RDONLY|O_NOCTTY); + if (fd < 0) { + if (errno != ENOENT) + goto error; /* error */ + fp = (FILE*)0; + goto error; /* no entry `removable' */ + } + + fp = fdopen(fd, "r"); + if (fp == (FILE*)0) + close(fd); /* should not happen */ +error: + return fp; +} + +/* + * Check IDE/(S)ATA hard disk identity for + * the FLUSH CACHE EXT bit set. + */ +static int flush_cache_ext(const char *device) +{ +#ifndef WIN_IDENTIFY +#define WIN_IDENTIFY 0xEC +#endif + unsigned char args[4+IDBYTES]; + unsigned short *id = (unsigned short*)(&args[4]); + char buf[NAME_MAX+1], *ptr; + int fd = -1, ret = 0; + FILE *fp; + + fp = hdopen(SYS_BLK "/%s/size", device); + if ((long)fp <= 0) { + if ((long)fp < 0) + return -1; /* error */ + goto out; /* no entry `size' */ + } + + ptr = fgets(buf, sizeof(buf), fp); + fclose(fp); + if (ptr == (char*)0) + goto out; /* should not happen */ + + ptr = strstrip(buf); + if (*ptr == '\0') + goto out; /* should not happen */ + + if ((size_t)atoll(buf) < (1<<28)) + goto out; /* small disk */ + + ret = snprintf(buf, sizeof(buf), DEV_BASE "/%s", device); + if ((ret >= (int)sizeof(buf)) || (ret < 0)) + return -1; /* error */ + + if ((fd = open(buf, O_RDONLY|O_NONBLOCK)) < 0) + goto out; + + memset(&args[0], 0, sizeof(args)); + args[0] = WIN_IDENTIFY; + args[3] = 1; + if (ioctl(fd, HDIO_DRIVE_CMD, &args)) + goto out; +#ifdef WORDS_BIGENDIAN +# if 0 + { + const unsigned short *end = id + IDBYTES/2; + const unsigned short *from = id; + unsigned short *to = id; + + while (from < end) + *to++ = bswap_16(*from++); + } +# else + id[83] = bswap_16(id[83]); +# endif +#endif + if ((id[83] & MASK_EXT) == TEST_EXT) + ret = 1; +out: + if (fd >= 0) + close(fd); + return ret; +} +#else /* ! USE_SYSFS */ +#define MAX_DISKS 64 +#define PROC_IDE "/proc/ide" +#define DEV_BASE "/dev" + +/* + * Find all IDE disks through /proc. + */ +static int find_idedisks(const char **dev, int maxdev, int *count) +{ + DIR *dd; + FILE *fp; + struct dirent *d; + char buf[256]; + + if ((dd = opendir(PROC_IDE)) == NULL) + return -1; + + while (*count < maxdev && (d = readdir(dd)) != NULL) { + if (strncmp(d->d_name, "hd", 2) != 0) + continue; + buf[0] = 0; + snprintf(buf, sizeof(buf), PROC_IDE "/%s/media", d->d_name); + if ((fp = fopen(buf, "r")) == NULL) + continue; + if (fgets(buf, sizeof(buf), fp) == 0 || + strcmp(buf, "disk\n") != 0) { + fclose(fp); + continue; + } + fclose(fp); + snprintf(buf, sizeof(buf), DEV_BASE "/%s", d->d_name); + dev[(*count)++] = strdup(buf); + } + closedir(dd); + + return 0; +} + +/* + * Find all SCSI/SATA disks. + */ +static int find_scsidisks(const char **dev, int maxdev, int *count) +{ + if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sda"; + if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sdb"; + if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sdc"; + if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sdd"; + if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sde"; + if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sdf"; + if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sdg"; + if (*count < maxdev) dev[(*count)++] = DEV_BASE "/sdh"; + + return 0; +} + +/* + * Open the device node of a disk. + */ +static int open_disk(const char *device) +{ + return open(device, O_RDWR); +} + +/* + * Open device nodes of all disks, and store the file descriptors in fds. + * This has to be done in advance because accessing the device nodes + * might cause a disk to spin back up. + */ +static int open_disks(const char **disks, int *fds, int count) +{ + int i; + + for (i = 0; i < count; i++) + fds[i] = open_disk(disks[i]); + + return 0; +} + +/* + * Put an IDE/SCSI/SATA disk in standby mode. + * Code stolen from hdparm.c + */ +static int do_standby_disk(int fd) +{ +#ifndef WIN_STANDBYNOW1 +#define WIN_STANDBYNOW1 0xE0 +#endif +#ifndef WIN_STANDBYNOW2 +#define WIN_STANDBYNOW2 0x94 +#endif + unsigned char args1[4] = {WIN_STANDBYNOW1,0,0,0}; + unsigned char args2[4] = {WIN_STANDBYNOW2,0,0,0}; + + if (fd < 0) + return -1; + + if (ioctl(fd, HDIO_DRIVE_CMD, &args1) && + ioctl(fd, HDIO_DRIVE_CMD, &args2)) + return -1; + + return 0; +} + +/* + * Put all specified disks in standby mode. + */ +static int do_standby_disks(const int *fds, int count) +{ + int i; + + for (i = 0; i < count; i++) + do_standby_disk(fds[i]); + + return 0; +} + +/* + * First find all IDE/SCSI/SATA disks, then put them in standby mode. + * This has the side-effect of flushing the writecache, + * which is exactly what we want on poweroff. + */ +int hddown(void) +{ + const char *disks[MAX_DISKS]; + int fds[MAX_DISKS]; + int count = 0; + int result1, result2; + + result1 = find_idedisks(disks, MAX_DISKS, &count); + result2 = find_scsidisks(disks, MAX_DISKS, &count); + + open_disks(disks, fds, count); + do_standby_disks(fds, count); + + return (result1 ? result1 : result2); +} + +int hdflush(void) +{ + return 0; +} + +#endif /* ! USE_SYSFS */ +#else /* __linux__ */ + +int hddown(void) +{ + return 0; +} + +int hdflush(void) +{ + return 0; +} + +#endif /* __linux__ */ + +#ifdef STANDALONE +int main(int argc, char **argv) +{ + return (hddown() == 0); +} +#endif + diff --git a/src/ifdown.c b/src/ifdown.c new file mode 100644 index 00000000..3048a359 --- /dev/null +++ b/src/ifdown.c @@ -0,0 +1,109 @@ +/* + * 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@cistron.nl"; + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#define MAX_IFS 64 + +/* + * First, we find all shaper devices and down them. Then we + * down all real interfaces. This is because the comment in the + * shaper driver says "if you down the shaper device before the + * attached inerface your computer will follow". + */ +int ifdown(void) +{ + struct ifreq ifr[MAX_IFS]; + struct ifconf ifc; + int i, fd; + int numif; + int shaper; + + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + fprintf(stderr, "ifdown: "); + perror("socket"); + return -1; + } + ifc.ifc_len = sizeof(ifr); + ifc.ifc_req = ifr; + + if (ioctl(fd, SIOCGIFCONF, &ifc) < 0) { + fprintf(stderr, "ifdown: "); + perror("SIOCGIFCONF"); + close(fd); + return -1; + } + numif = ifc.ifc_len / sizeof(struct ifreq); + + for (shaper = 1; shaper >= 0; shaper--) { + for (i = 0; i < numif; i++) { + + if ((strncmp(ifr[i].ifr_name, "shaper", 6) == 0) + != shaper) continue; + + if (strcmp(ifr[i].ifr_name, "lo") == 0) + continue; + if (strchr(ifr[i].ifr_name, ':') != NULL) + continue; + + /* Read interface flags */ + if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) < 0) { + fprintf(stderr, "ifdown: shutdown "); + perror(ifr[i].ifr_name); + continue; + } + /* + * Expected in 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; +} diff --git a/src/init.c b/src/init.c new file mode 100644 index 00000000..27532ade --- /dev/null +++ b/src/init.c @@ -0,0 +1,2898 @@ +/* + * Init A System-V Init Clone. + * + * Usage: /sbin/init + * init [0123456SsQqAaBbCc] + * telinit [0123456SsQqAaBbCc] + * + * Version: @(#)init.c 2.86 30-Jul-2004 miquels@cistron.nl + */ +#define VERSION "2.88" +#define DATE "26-Mar-2010" +/* + * This file is part of the sysvinit suite, + * 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 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 +#include +#include +#include +#ifdef __linux__ +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef WITH_SELINUX +# include +# include +# ifndef MNT_DETACH /* present in glibc 2.10, missing in 2.7 */ +# define MNT_DETACH 2 +# endif +#endif + +#ifdef __i386__ +# ifdef __GLIBC__ + /* GNU libc 2.x */ +# define STACK_DEBUG 1 +# if (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0) + /* Only glibc 2.0 needs this */ +# include +# elif ( __GLIBC__ > 2) && ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1)) +# include +# endif +# endif +#endif + +#include "init.h" +#include "initreq.h" +#include "paths.h" +#include "reboot.h" +#include "set.h" + +#ifndef SIGPWR +# define SIGPWR SIGUSR2 +#endif + +#ifndef CBAUD +# define CBAUD 0 +#endif +#ifndef CBAUDEX +# define CBAUDEX 0 +#endif + +/* Set a signal handler. */ +#define SETSIG(sa, sig, fun, flags) \ + do { \ + sa.sa_handler = fun; \ + sa.sa_flags = flags; \ + sigemptyset(&sa.sa_mask); \ + sigaction(sig, &sa, NULL); \ + } while(0) + +/* Version information */ +char *Version = "@(#) init " VERSION " " DATE " miquels@cistron.nl"; +char *bootmsg = "version " VERSION " %s"; +#define E_VERSION "INIT_VERSION=sysvinit-" VERSION + +CHILD *family = NULL; /* The linked list of all entries */ +CHILD *newFamily = NULL; /* The list after inittab re-read */ + +CHILD ch_emerg = { /* Emergency shell */ + WAITING, 0, 0, 0, 0, + "~~", + "S", + 3, + "/sbin/sulogin", + NULL, + NULL +}; + +char runlevel = 'S'; /* The current run level */ +char thislevel = 'S'; /* The current runlevel */ +char prevlevel = 'N'; /* Previous runlevel */ +int dfl_level = 0; /* Default runlevel */ +sig_atomic_t got_cont = 0; /* Set if we received the SIGCONT signal */ +sig_atomic_t got_signals; /* Set if we received a signal. */ +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 *console_dev; /* Console device. */ +int pipe_fd = -1; /* /dev/initctl */ +int did_boot = 0; /* Did we already do BOOT* stuff? */ +int main(int, char **); + +/* Used by re-exec part */ +int reload = 0; /* Should we do initialization stuff? */ +char *myname="/sbin/init"; /* What should we exec */ +int oops_error; /* Used by some of the re-exec code. */ +const char *Signature = "12567362"; /* Signature for re-exec fd */ + +/* Macro to see if this is a special action */ +#define ISPOWER(i) ((i) == POWERWAIT || (i) == POWERFAIL || \ + (i) == POWEROKWAIT || (i) == POWERFAILNOW || \ + (i) == CTRLALTDEL) + +/* ascii values for the `action' field. */ +struct actions { + char *name; + int act; +} actions[] = { + { "respawn", RESPAWN }, + { "wait", WAIT }, + { "once", ONCE }, + { "boot", BOOT }, + { "bootwait", BOOTWAIT }, + { "powerfail", POWERFAIL }, + { "powerfailnow",POWERFAILNOW }, + { "powerwait", POWERWAIT }, + { "powerokwait", POWEROKWAIT }, + { "ctrlaltdel", CTRLALTDEL }, + { "off", OFF }, + { "ondemand", ONDEMAND }, + { "initdefault", INITDEFAULT }, + { "sysinit", SYSINIT }, + { "kbrequest", KBREQUEST }, + { NULL, 0 }, +}; + +/* + * State parser token table (see receive_state) + */ +struct { + char name[4]; + int cmd; +} cmds[] = { + { "VER", C_VER }, + { "END", C_END }, + { "REC", C_REC }, + { "EOR", C_EOR }, + { "LEV", C_LEV }, + { "FL ", C_FLAG }, + { "AC ", C_ACTION }, + { "CMD", C_PROCESS }, + { "PID", C_PID }, + { "EXS", C_EXS }, + { "-RL", D_RUNLEVEL }, + { "-TL", D_THISLEVEL }, + { "-PL", D_PREVLEVEL }, + { "-SI", D_GOTSIGN }, + { "-WR", D_WROTE_WTMP_REBOOT}, + { "-WU", D_WROTE_UTMP_REBOOT}, + { "-ST", D_SLTIME }, + { "-DB", D_DIDBOOT }, + { "-LW", D_WROTE_WTMP_RLEVEL}, + { "-LU", D_WROTE_UTMP_RLEVEL}, + { "", 0 } +}; +struct { + char *name; + int mask; +} flags[]={ + {"RU",RUNNING}, + {"DE",DEMAND}, + {"XD",XECUTED}, + {"WT",WAITING}, + {NULL,0} +}; + +#define NR_EXTRA_ENV 16 +char *extra_env[NR_EXTRA_ENV]; + + +/* + * Sleep a number of seconds. + * + * 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; + + tv.tv_sec = sec; + tv.tv_usec = 0; + + while(select(0, NULL, NULL, NULL, &tv) < 0 && errno == EINTR) + ; +} + + +/* + * Non-failing allocation routines (init cannot fail). + */ +static +void *imalloc(size_t size) +{ + void *m; + + while ((m = malloc(size)) == NULL) { + initlog(L_VB, "out of memory"); + do_sleep(5); + } + memset(m, 0, size); + return m; +} + +static +char *istrdup(char *s) +{ + char *m; + int l; + + l = strlen(s) + 1; + m = imalloc(l); + memcpy(m, s, l); + return m; +} + + +/* + * 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; + CHILD *p; + int i,val; + + fp = fdopen(fd,"w"); + + fprintf(fp, "VER%s\n", Version); + fprintf(fp, "-RL%c\n", runlevel); + fprintf(fp, "-TL%c\n", thislevel); + fprintf(fp, "-PL%c\n", prevlevel); + fprintf(fp, "-SI%u\n", got_signals); + fprintf(fp, "-WR%d\n", wrote_wtmp_reboot); + fprintf(fp, "-WU%d\n", wrote_utmp_reboot); + fprintf(fp, "-ST%d\n", sltime); + fprintf(fp, "-DB%d\n", did_boot); + + for (p = family; p; p = p->next) { + fprintf(fp, "REC%s\n", p->id); + fprintf(fp, "LEV%s\n", p->rlevel); + for (i = 0, val = p->flags; flags[i].mask; i++) + if (val & flags[i].mask) { + val &= ~flags[i].mask; + fprintf(fp, "FL %s\n",flags[i].name); + } + fprintf(fp, "PID%d\n",p->pid); + fprintf(fp, "EXS%u\n",p->exstat); + for(i = 0; actions[i].act; i++) + if (actions[i].act == p->action) { + fprintf(fp, "AC %s\n", actions[i].name); + break; + } + fprintf(fp, "CMD%s\n", p->process); + fprintf(fp, "EOR\n"); + } + fprintf(fp, "END\n"); + fclose(fp); +} + +/* + * Read a string from a file descriptor. + * FIXME: why not use fgets() ? + */ +static int get_string(char *p, int size, FILE *f) +{ + int c; + + while ((c = getc(f)) != EOF && c != '\n') { + if (--size > 0) + *p++ = c; + } + *p = '\0'; + return (c != EOF) && (size > 0); +} + +/* + * Read trailing data from the state pipe until we see a newline. + */ +static int get_void(FILE *f) +{ + int c; + + while ((c = getc(f)) != EOF && c != '\n') + ; + + return (c != EOF); +} + +/* + * Read the next "command" from the state pipe. + */ +static int get_cmd(FILE *f) +{ + char cmd[4] = " "; + int i; + + if (fread(cmd, 1, sizeof(cmd) - 1, f) != sizeof(cmd) - 1) + return C_EOF; + + for(i = 0; cmds[i].cmd && strcmp(cmds[i].name, cmd) != 0; i++) + ; + return cmds[i].cmd; +} + +/* + * Read a CHILD * from the state pipe. + */ +static CHILD *get_record(FILE *f) +{ + int cmd; + char s[32]; + int i; + CHILD *p; + + do { + switch (cmd = get_cmd(f)) { + case C_END: + get_void(f); + return NULL; + case 0: + get_void(f); + break; + case C_REC: + break; + case D_RUNLEVEL: + fscanf(f, "%c\n", &runlevel); + break; + case D_THISLEVEL: + fscanf(f, "%c\n", &thislevel); + break; + case D_PREVLEVEL: + fscanf(f, "%c\n", &prevlevel); + break; + case D_GOTSIGN: + fscanf(f, "%u\n", &got_signals); + break; + case D_WROTE_WTMP_REBOOT: + fscanf(f, "%d\n", &wrote_wtmp_reboot); + break; + case D_WROTE_UTMP_REBOOT: + fscanf(f, "%d\n", &wrote_utmp_reboot); + break; + case D_SLTIME: + fscanf(f, "%d\n", &sltime); + break; + 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; + return NULL; + } + } + } while (cmd != C_REC); + + p = imalloc(sizeof(CHILD)); + get_string(p->id, sizeof(p->id), f); + + do switch(cmd = get_cmd(f)) { + case 0: + case C_EOR: + get_void(f); + break; + case C_PID: + fscanf(f, "%d\n", &(p->pid)); + break; + case C_EXS: + fscanf(f, "%u\n", &(p->exstat)); + break; + case C_LEV: + get_string(p->rlevel, sizeof(p->rlevel), f); + break; + case C_PROCESS: + get_string(p->process, sizeof(p->process), f); + break; + case C_FLAG: + get_string(s, sizeof(s), f); + for(i = 0; flags[i].name; i++) { + if (strcmp(flags[i].name,s) == 0) + break; + } + p->flags |= flags[i].mask; + break; + case C_ACTION: + get_string(s, sizeof(s), f); + for(i = 0; actions[i].name; i++) { + if (strcmp(actions[i].name, s) == 0) + break; + } + p->action = actions[i].act ? actions[i].act : OFF; + break; + default: + free(p); + oops_error = -1; + return NULL; + } while( cmd != C_EOR); + + return p; +} + +/* + * Read the complete state info from the state pipe. + * Returns 0 on success + */ +static +int receive_state(int fd) +{ + FILE *f; + char old_version[256]; + CHILD **pp; + + f = fdopen(fd, "r"); + + if (get_cmd(f) != C_VER) + return -1; + get_string(old_version, sizeof(old_version), f); + oops_error = 0; + for (pp = &family; (*pp = get_record(f)) != NULL; pp = &((*pp)->next)) + ; + fclose(f); + return oops_error; +} + +/* + * Set the process title. + */ +#ifdef __GNUC__ +__attribute__ ((format (printf, 1, 2))) +#endif +static int setproctitle(char *fmt, ...) +{ + va_list ap; + int len; + char buf[256]; + + buf[0] = 0; + + va_start(ap, fmt); + len = vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + + if (maxproclen > 1) { + memset(argv0, 0, maxproclen); + strncpy(argv0, buf, maxproclen - 1); + } + + return len; +} + +/* + * Set console_dev to a working console. + */ +static +void console_init(void) +{ + int fd; + int tried_devcons = 0; + int tried_vtmaster = 0; + char *s; + + if ((s = getenv("CONSOLE")) != NULL) + console_dev = s; + else { + console_dev = CONSOLE; + tried_devcons++; + } + + while ((fd = open(console_dev, O_RDONLY|O_NONBLOCK)) < 0) { + if (!tried_devcons) { + tried_devcons++; + console_dev = CONSOLE; + continue; + } + if (!tried_vtmaster) { + tried_vtmaster++; + console_dev = VT_MASTER; + continue; + } + break; + } + if (fd < 0) + console_dev = "/dev/null"; + else + close(fd); +} + + +/* + * Open the console with retries. + */ +static +int console_open(int mode) +{ + int f, fd = -1; + int m; + + /* + * Open device in nonblocking mode. + */ + m = mode | O_NONBLOCK; + + /* + * Retry the open five times. + */ + for(f = 0; f < 5; f++) { + if ((fd = open(console_dev, m)) >= 0) break; + usleep(10000); + } + + if (fd < 0) return fd; + + /* + * Set original flags. + */ + if (m != mode) + fcntl(fd, F_SETFL, mode); + return fd; +} + +/* + * We got a signal (HUP PWR WINCH ALRM INT) + */ +static +void signal_handler(int sig) +{ + ADDSET(got_signals, sig); +} + +/* + * SIGCHLD: one of our children has died. + */ +static +# ifdef __GNUC__ +void chld_handler(int sig __attribute__((unused))) +# else +void chld_handler(int sig) +# endif +{ + CHILD *ch; + int pid, st; + int saved_errno = errno; + + /* + * Find out which process(es) this was (were) + */ + while((pid = waitpid(-1, &st, WNOHANG)) != 0) { + if (errno == ECHILD) break; + for( ch = family; ch; ch = ch->next ) + if ( ch->pid == pid && (ch->flags & RUNNING) ) { + INITDBG(L_VB, + "chld_handler: marked %d as zombie", + ch->pid); + ADDSET(got_signals, SIGCHLD); + ch->exstat = st; + ch->flags |= ZOMBIE; + if (ch->new) { + ch->new->exstat = st; + ch->new->flags |= ZOMBIE; + } + break; + } + if (ch == NULL) { + INITDBG(L_VB, "chld_handler: unknown child %d exited.", + pid); + } + } + errno = saved_errno; +} + +/* + * Linux ignores all signals sent to init when the + * SIG_DFL handler is installed. Therefore we must catch SIGTSTP + * and SIGCONT, or else they won't work.... + * + * The SIGCONT handler + */ +static +# ifdef __GNUC__ +void cont_handler(int sig __attribute__((unused))) +# else +void cont_handler(int sig) +# endif +{ + got_cont = 1; +} + +/* + * Fork and dump core in /. + */ +static +void coredump(void) +{ + static int dumped = 0; + struct rlimit rlim; + sigset_t mask; + + if (dumped) return; + dumped = 1; + + if (fork() != 0) return; + + sigfillset(&mask); + sigprocmask(SIG_SETMASK, &mask, NULL); + + rlim.rlim_cur = RLIM_INFINITY; + rlim.rlim_max = RLIM_INFINITY; + setrlimit(RLIMIT_CORE, &rlim); + chdir("/"); + + signal(SIGSEGV, SIG_DFL); + raise(SIGSEGV); + sigdelset(&mask, SIGSEGV); + sigprocmask(SIG_SETMASK, &mask, NULL); + + do_sleep(5); + exit(0); +} + +/* + * OOPS: segmentation violation! + * 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; + + if ((void *)ctx.eip >= (void *)do_sleep && + (void *)ctx.eip < (void *)main) + p = " (code)"; + initlog(L_VB, "PANIC: segmentation violation at %p%s! " + "sleeping for 30 seconds.", (void *)ctx.eip, p); + coredump(); + do_sleep(30); + errno = saved_errno; +} +#else +# ifdef __GNUC__ +void segv_handler(int sig __attribute__((unused))) +# else +void segv_handler(int sig) +# endif +{ + int saved_errno = errno; + + initlog(L_VB, + "PANIC: segmentation violation! sleeping for 30 seconds."); + coredump(); + do_sleep(30); + errno = saved_errno; +} +#endif + +/* + * The SIGSTOP & SIGTSTP handler + */ +static +# ifdef __GNUC__ +void stop_handler(int sig __attribute__((unused))) +# else +void stop_handler(int sig) +# endif +{ + int saved_errno = errno; + + got_cont = 0; + while(!got_cont) pause(); + got_cont = 0; + errno = saved_errno; +} + +/* + * Set terminal settings to reasonable defaults + */ +static +void console_stty(void) +{ + struct termios tty; + int fd; + + if ((fd = console_open(O_RDWR|O_NOCTTY)) < 0) { + initlog(L_VB, "can't open %s", console_dev); + 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] = 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. + */ + (void) tcsetattr(fd, TCSANOW, &tty); + (void) tcflush(fd, TCIOFLUSH); + (void) close(fd); +} + +/* + * Print to the system console + */ +void print(char *s) +{ + int fd; + + if ((fd = console_open(O_WRONLY|O_NOCTTY|O_NDELAY)) >= 0) { + write(fd, s, strlen(s)); + close(fd); + } +} + +/* + * Log something to a logfile and the console. + */ +#ifdef __GNUC__ +__attribute__ ((format (printf, 2, 3))) +#endif +void initlog(int loglevel, char *s, ...) +{ + va_list va_alist; + char buf[256]; + sigset_t nmask, omask; + + va_start(va_alist, s); + vsnprintf(buf, sizeof(buf), s, va_alist); + va_end(va_alist); + + if (loglevel & L_SY) { + /* + * Re-establish connection with syslogd every time. + * Block signals while talking to syslog. + */ + sigfillset(&nmask); + sigprocmask(SIG_BLOCK, &nmask, &omask); + openlog("init", 0, LOG_DAEMON); + syslog(LOG_INFO, "%s", buf); + closelog(); + sigprocmask(SIG_SETMASK, &omask, NULL); + } + + /* + * And log to the console. + */ + if (loglevel & L_CO) { + print("\rINIT: "); + print(buf); + print("\r\n"); + } +} + + +/* + * Build a new environment for execve(). + */ +char **init_buildenv(int child) +{ + 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; + 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++) { + 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); + e[n++] = istrdup(E_VERSION); + } + + e[n++] = NULL; + + return e; +} + + +void init_freeenv(char **e) +{ + int n; + + for (n = 0; e[n]; n++) + free(e[n]); + free(e); +} + + +/* + * Fork and execute. + * + * This function is too long and indents too deep. + * + */ +static +pid_t spawn(CHILD *ch, int *res) +{ + char *args[16]; /* Argv array */ + char buf[136]; /* Line buffer */ + int f, st; /* Scratch variables */ + char *ptr; /* Ditto */ + time_t t; /* System time */ + int oldAlarm; /* Previous alarm value */ + char *proc = ch->process; /* Command line */ + pid_t pid, pgrp; /* child, console process group. */ + sigset_t nmask, omask; /* For blocking SIGCHLD */ + struct sigaction sa; + + *res = -1; + buf[sizeof(buf) - 1] = 0; + + /* Skip '+' if it's there */ + if (proc[0] == '+') proc++; + + ch->flags |= XECUTED; + + if (ch->action == RESPAWN || ch->action == ONDEMAND) { + /* Is the date stamp from less than 2 minutes ago? */ + time(&t); + if (ch->tm + TESTTIME > t) { + ch->count++; + } else { + ch->count = 0; + ch->tm = t; + } + + /* Do we try to respawn too fast? */ + if (ch->count >= MAXSPAWN) { + + initlog(L_VB, + "Id \"%s\" respawning too fast: disabled for %d minutes", + ch->id, SLEEPTIME / 60); + ch->flags &= ~RUNNING; + ch->flags |= FAILING; + + /* Remember the time we stopped */ + ch->tm = t; + + /* Try again in 5 minutes */ + oldAlarm = alarm(0); + if (oldAlarm > SLEEPTIME || oldAlarm <= 0) oldAlarm = SLEEPTIME; + alarm(oldAlarm); + return(-1); + } + } + + /* See if there is an "initscript" (except in single user mode). */ + if (access(INITSCRIPT, R_OK) == 0 && runlevel != 'S') { + /* Build command line using "initscript" */ + args[1] = SHELL; + args[2] = INITSCRIPT; + args[3] = ch->id; + args[4] = ch->rlevel; + args[5] = "unknown"; + for(f = 0; actions[f].name; f++) { + if (ch->action == actions[f].act) { + args[5] = actions[f].name; + break; + } + } + args[6] = proc; + args[7] = NULL; + } else if (strpbrk(proc, "~`!$^&*()=|\\{}[];\"'<>?")) { + /* See if we need to fire off a shell for this command */ + /* Give command line to shell */ + args[1] = SHELL; + args[2] = "-c"; + strcpy(buf, "exec "); + strncat(buf, proc, sizeof(buf) - strlen(buf) - 1); + args[3] = buf; + args[4] = NULL; + } else { + /* Split up command line arguments */ + buf[0] = 0; + strncat(buf, proc, sizeof(buf) - 1); + ptr = buf; + for(f = 1; f < 15; f++) { + /* Skip white space */ + while(*ptr == ' ' || *ptr == '\t') ptr++; + args[f] = ptr; + + /* May be trailing space.. */ + if (*ptr == 0) break; + + /* Skip this `word' */ + while(*ptr && *ptr != ' ' && *ptr != '\t' && *ptr != '#') + ptr++; + + /* If end-of-line, break */ + if (*ptr == '#' || *ptr == 0) { + f++; + *ptr = 0; + break; + } + /* End word with \0 and continue */ + *ptr++ = 0; + } + args[f] = NULL; + } + args[0] = args[1]; + while(1) { + /* + * Block sigchild while forking. + */ + sigemptyset(&nmask); + sigaddset(&nmask, SIGCHLD); + sigprocmask(SIG_BLOCK, &nmask, &omask); + + if ((pid = fork()) == 0) { + + close(0); + close(1); + close(2); + if (pipe_fd >= 0) close(pipe_fd); + + sigprocmask(SIG_SETMASK, &omask, NULL); + + /* + * In sysinit, boot, bootwait or single user mode: + * for any wait-type subprocess we _force_ the console + * to be its controlling tty. + */ + if (strchr("*#sS", runlevel) && ch->flags & WAITING) { + /* + * We fork once extra. This is so that we can + * wait and change the process group and session + * of the console after exit of the leader. + */ + setsid(); + if ((f = console_open(O_RDWR|O_NOCTTY)) >= 0) { + /* Take over controlling tty by force */ + (void)ioctl(f, TIOCSCTTY, 1); + 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", + strerror(errno)); + exit(1); + } + if (pid > 0) { + pid_t rc; + /* + * Ignore keyboard signals etc. + * Then wait for child to exit. + */ + SETSIG(sa, SIGINT, SIG_IGN, SA_RESTART); + SETSIG(sa, SIGTSTP, SIG_IGN, SA_RESTART); + SETSIG(sa, SIGQUIT, SIG_IGN, SA_RESTART); + + while ((rc = waitpid(pid, &st, 0)) != pid) + if (rc < 0 && errno == ECHILD) + break; + + /* + * Small optimization. See if stealing + * controlling tty back is needed. + */ + pgrp = tcgetpgrp(f); + if (pgrp != getpid()) + exit(0); + + /* + * Steal controlling tty away. We do + * this with a temporary process. + */ + if ((pid = fork()) < 0) { + initlog(L_VB, "cannot fork: %s", + strerror(errno)); + exit(1); + } + if (pid == 0) { + setsid(); + (void)ioctl(f, TIOCSCTTY, 1); + exit(0); + } + while((rc = waitpid(pid, &st, 0)) != pid) + if (rc < 0 && errno == ECHILD) + break; + exit(0); + } + + /* Set ioctl settings to default ones */ + console_stty(); + + } else { + setsid(); + if ((f = console_open(O_RDWR|O_NOCTTY)) < 0) { + initlog(L_VB, "open(%s): %s", console_dev, + strerror(errno)); + f = open("/dev/null", O_RDWR); + } + dup(f); + 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); + + /* + * Execute prog. In case of ENOEXEC try again + * as a shell script. + */ + execvp(args[1], args + 1); + if (errno == ENOEXEC) { + args[1] = SHELL; + args[2] = "-c"; + strcpy(buf, "exec "); + strncat(buf, proc, sizeof(buf) - strlen(buf) - 1); + args[3] = buf; + args[4] = NULL; + 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; + sigprocmask(SIG_SETMASK, &omask, NULL); + + INITDBG(L_VB, "Started id %s (pid %d)", ch->id, pid); + + if (pid == -1) { + initlog(L_VB, "cannot fork, retry.."); + do_sleep(5); + continue; + } + return(pid); + } +} + +/* + * Start a child running! + */ +static +void startup(CHILD *ch) +{ + /* + * See if it's disabled + */ + if (ch->flags & FAILING) return; + + switch(ch->action) { + + case SYSINIT: + case BOOTWAIT: + case WAIT: + case POWERWAIT: + case POWERFAILNOW: + case POWEROKWAIT: + case CTRLALTDEL: + if (!(ch->flags & XECUTED)) ch->flags |= WAITING; + case KBREQUEST: + case BOOT: + case POWERFAIL: + case ONCE: + if (ch->flags & XECUTED) break; + case ONDEMAND: + case RESPAWN: + ch->flags |= RUNNING; + (void)spawn(ch, &(ch->pid)); + break; + } +} + + +/* + * Read the inittab file. + */ +static +void read_inittab(void) +{ + FILE *fp; /* The INITTAB file */ + CHILD *ch, *old, *i; /* Pointers to CHILD structure */ + CHILD *head = NULL; /* Head of linked list */ +#ifdef INITLVL + struct stat st; /* To stat INITLVL */ +#endif + sigset_t nmask, omask; /* For blocking SIGCHLD. */ + char buf[256]; /* Line buffer */ + char err[64]; /* Error message. */ + char *id, *rlevel, + *action, *process; /* Fields of a line */ + char *p; + int lineNo = 0; /* Line number in INITTAB file */ + int actionNo; /* Decoded action field */ + int f; /* Counter */ + int round; /* round 0 for SIGTERM, 1 for SIGKILL */ + int foundOne = 0; /* No killing no sleep */ + int talk; /* Talk to the user */ + int done = 0; /* Ready yet? */ + +#if DEBUG + if (newFamily != NULL) { + INITDBG(L_VB, "PANIC newFamily != NULL"); + exit(1); + } + INITDBG(L_VB, "Reading inittab"); +#endif + + /* + * Open INITTAB and real line by line. + */ + if ((fp = fopen(INITTAB, "r")) == NULL) + initlog(L_VB, "No inittab file found"); + + while(!done) { + /* + * Add single user shell entry at the end. + */ + if (fp == NULL || fgets(buf, sizeof(buf), fp) == NULL) { + done = 1; + /* + * See if we have a single user entry. + */ + for(old = newFamily; old; old = old->next) + if (strpbrk(old->rlevel, "S")) break; + if (old == NULL) + snprintf(buf, sizeof(buf), "~~:S:wait:%s\n", SULOGIN); + else + continue; + } + lineNo++; + /* + * Skip comments and empty lines + */ + for(p = buf; *p == ' ' || *p == '\t'; p++) + ; + if (*p == '#' || *p == '\n') continue; + + /* + * Decode the fields + */ + id = strsep(&p, ":"); + rlevel = strsep(&p, ":"); + action = strsep(&p, ":"); + process = strsep(&p, "\n"); + + /* + * Check if syntax is OK. Be very verbose here, to + * avoid newbie postings on comp.os.linux.setup :) + */ + err[0] = 0; + if (!id || !*id) strcpy(err, "missing id field"); + if (!rlevel) strcpy(err, "missing runlevel field"); + if (!process) strcpy(err, "missing process field"); + if (!action || !*action) + strcpy(err, "missing action field"); + if (id && strlen(id) > sizeof(utproto.ut_id)) + sprintf(err, "id field too long (max %d characters)", + (int)sizeof(utproto.ut_id)); + if (rlevel && strlen(rlevel) > 11) + strcpy(err, "rlevel field too long (max 11 characters)"); + if (process && strlen(process) > 127) + strcpy(err, "process field too long"); + if (action && strlen(action) > 32) + strcpy(err, "action field too long"); + if (err[0] != 0) { + initlog(L_VB, "%s[%d]: %s", INITTAB, lineNo, err); + INITDBG(L_VB, "%s:%s:%s:%s", id, rlevel, action, process); + continue; + } + + /* + * Decode the "action" field + */ + actionNo = -1; + for(f = 0; actions[f].name; f++) + if (strcasecmp(action, actions[f].name) == 0) { + actionNo = actions[f].act; + break; + } + if (actionNo == -1) { + initlog(L_VB, "%s[%d]: %s: unknown action field", + INITTAB, lineNo, action); + continue; + } + + /* + * See if the id field is unique + */ + for(old = newFamily; old; old = old->next) { + if(strcmp(old->id, id) == 0 && strcmp(id, "~~")) { + initlog(L_VB, "%s[%d]: duplicate ID field \"%s\"", + INITTAB, lineNo, id); + break; + } + } + if (old) continue; + + /* + * Allocate a CHILD structure + */ + ch = imalloc(sizeof(CHILD)); + + /* + * And fill it in. + */ + ch->action = actionNo; + 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 < (int)sizeof(rlevel) - 1 && rlevel[f]; f++) { + ch->rlevel[f] = rlevel[f]; + if (ch->rlevel[f] == 's') ch->rlevel[f] = 'S'; + } + strncpy(ch->rlevel, rlevel, sizeof(ch->rlevel) - 1); + } else { + strcpy(ch->rlevel, "0123456789"); + if (ISPOWER(ch->action)) + strcpy(ch->rlevel, "S0123456789"); + } + /* + * We have the fake runlevel '#' for SYSINIT and + * '*' for BOOT and BOOTWAIT. + */ + if (ch->action == SYSINIT) strcpy(ch->rlevel, "#"); + if (ch->action == BOOT || ch->action == BOOTWAIT) + strcpy(ch->rlevel, "*"); + + /* + * Now add it to the linked list. Special for powerfail. + */ + if (ISPOWER(ch->action)) { + + /* + * Disable by default + */ + ch->flags |= XECUTED; + + /* + * Tricky: insert at the front of the list.. + */ + old = NULL; + for(i = newFamily; i; i = i->next) { + if (!ISPOWER(i->action)) break; + old = i; + } + /* + * Now add after entry "old" + */ + if (old) { + ch->next = i; + old->next = ch; + if (i == NULL) head = ch; + } else { + ch->next = newFamily; + newFamily = ch; + if (ch->next == NULL) head = ch; + } + } else { + /* + * Just add at end of the list + */ + if (ch->action == KBREQUEST) ch->flags |= XECUTED; + ch->next = NULL; + if (head) + head->next = ch; + else + newFamily = ch; + head = ch; + } + + /* + * Walk through the old list comparing id fields + */ + for(old = family; old; old = old->next) + if (strcmp(old->id, ch->id) == 0) { + old->new = ch; + break; + } + } + /* + * We're done. + */ + if (fp) fclose(fp); + + /* + * Loop through the list of children, and see if they need to + * be killed. + */ + + INITDBG(L_VB, "Checking for children to kill"); + for(round = 0; round < 2; round++) { + talk = 1; + for(ch = family; ch; ch = ch->next) { + ch->flags &= ~KILLME; + + /* + * Is this line deleted? + */ + if (ch->new == NULL) ch->flags |= KILLME; + + /* + * If the entry has changed, kill it anyway. Note that + * we do not check ch->process, only the "action" field. + * This way, you can turn an entry "off" immediately, but + * changes in the command line will only become effective + * after the running version has exited. + */ + if (ch->new && ch->action != ch->new->action) ch->flags |= KILLME; + + /* + * Only BOOT processes may live in all levels + */ + if (ch->action != BOOT && + strchr(ch->rlevel, runlevel) == NULL) { + /* + * Ondemand procedures live always, + * except in single user + */ + if (runlevel == 'S' || !(ch->flags & DEMAND)) + ch->flags |= KILLME; + } + + /* + * Now, if this process may live note so in the new list + */ + if ((ch->flags & KILLME) == 0) { + ch->new->flags = ch->flags; + ch->new->pid = ch->pid; + ch->new->exstat = ch->exstat; + continue; + } + + + /* + * Is this process still around? + */ + if ((ch->flags & RUNNING) == 0) { + ch->flags &= ~KILLME; + continue; + } + INITDBG(L_VB, "Killing \"%s\"", ch->process); + switch(round) { + case 0: /* Send TERM signal */ + if (talk) + initlog(L_CO, + "Sending processes the TERM signal"); + kill(-(ch->pid), SIGTERM); + foundOne = 1; + break; + case 1: /* Send KILL signal and collect status */ + if (talk) + initlog(L_CO, + "Sending processes the KILL signal"); + kill(-(ch->pid), SIGKILL); + break; + } + talk = 0; + + } + /* + * See if we have to wait 5 seconds + */ + if (foundOne && round == 0) { + /* + * Yup, but check every second if we still have children. + */ + for(f = 0; f < sltime; f++) { + for(ch = family; ch; ch = ch->next) { + if (!(ch->flags & KILLME)) continue; + if ((ch->flags & RUNNING) && !(ch->flags & ZOMBIE)) + break; + } + if (ch == NULL) { + /* + * No running children, skip SIGKILL + */ + round = 1; + foundOne = 0; /* Skip the sleep below. */ + break; + } + do_sleep(1); + } + } + } + + /* + * Now give all processes the chance to die and collect exit statuses. + */ + if (foundOne) do_sleep(1); + for(ch = family; ch; ch = ch->next) + if (ch->flags & KILLME) { + if (!(ch->flags & ZOMBIE)) + initlog(L_CO, "Pid %d [id %s] seems to hang", ch->pid, + ch->id); + else { + INITDBG(L_VB, "Updating utmp for pid %d [id %s]", + ch->pid, ch->id); + ch->flags &= ~RUNNING; + if (ch->process[0] != '+') + write_utmp_wtmp("", ch->id, ch->pid, DEAD_PROCESS, NULL); + } + } + + /* + * Both rounds done; clean up the list. + */ + sigemptyset(&nmask); + sigaddset(&nmask, SIGCHLD); + sigprocmask(SIG_BLOCK, &nmask, &omask); + for(ch = family; ch; ch = old) { + old = ch->next; + free(ch); + } + family = newFamily; + for(ch = family; ch; ch = ch->next) ch->new = NULL; + newFamily = NULL; + sigprocmask(SIG_SETMASK, &omask, NULL); + +#ifdef INITLVL + /* + * Dispose of INITLVL file. + */ + if (lstat(INITLVL, &st) >= 0 && S_ISLNK(st.st_mode)) { + /* + * INITLVL is a symbolic link, so just truncate the file. + */ + close(open(INITLVL, O_WRONLY|O_TRUNC)); + } else { + /* + * Delete INITLVL file. + */ + unlink(INITLVL); + } +#endif +#ifdef INITLVL2 + /* + * Dispose of INITLVL2 file. + */ + if (lstat(INITLVL2, &st) >= 0 && S_ISLNK(st.st_mode)) { + /* + * INITLVL2 is a symbolic link, so just truncate the file. + */ + close(open(INITLVL2, O_WRONLY|O_TRUNC)); + } else { + /* + * Delete INITLVL2 file. + */ + unlink(INITLVL2); + } +#endif +} + +/* + * Walk through the family list and start up children. + * 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 */ + int delete; /* Delete this entry from list? */ + + INITDBG(L_VB, "Checking for children to start"); + + for(ch = family; ch; ch = ch->next) { + +#if DEBUG + if (ch->rlevel[0] == 'C') { + INITDBG(L_VB, "%s: flags %d", ch->process, ch->flags); + } +#endif + + /* Are we waiting for this process? Then quit here. */ + if (ch->flags & WAITING) break; + + /* Already running? OK, don't touch it */ + if (ch->flags & RUNNING) continue; + + /* See if we have to start it up */ + delete = 1; + if (strchr(ch->rlevel, runlevel) || + ((ch->flags & DEMAND) && !strchr("#*Ss", runlevel))) { + startup(ch); + delete = 0; + } + + if (delete) { + /* FIXME: is this OK? */ + ch->flags &= ~(RUNNING|WAITING); + if (!ISPOWER(ch->action) && ch->action != KBREQUEST) + ch->flags &= ~XECUTED; + ch->pid = 0; + } else + /* Do we have to wait for this process? */ + if (ch->flags & WAITING) break; + } + /* Done. */ +} + +/* + * Ask the user on the console for a runlevel + */ +static +int ask_runlevel(void) +{ + const char prompt[] = "\nEnter runlevel: "; + char buf[8]; + int lvl = -1; + int fd; + + console_stty(); + fd = console_open(O_RDWR|O_NOCTTY); + + if (fd < 0) return('S'); + + while(!strchr("0123456789S", lvl)) { + write(fd, prompt, sizeof(prompt) - 1); + buf[0] = 0; + read(fd, buf, sizeof(buf)); + if (buf[0] != 0 && (buf[1] == '\r' || buf[1] == '\n')) + lvl = buf[0]; + if (islower(lvl)) lvl = toupper(lvl); + } + close(fd); + return lvl; +} + +/* + * 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; + int lvl = -1; + char *p; + + /* + * Look for initdefault. + */ + for(ch = family; ch; ch = ch->next) + if (ch->action == INITDEFAULT) { + p = ch->rlevel; + while(*p) { + if (*p > lvl) lvl = *p; + p++; + } + break; + } + /* + * See if level is valid + */ + if (lvl > 0) { + if (islower(lvl)) lvl = toupper(lvl); + if (strchr("0123456789S", lvl) == NULL) { + initlog(L_VB, + "Initdefault level '%c' is invalid", lvl); + lvl = 0; + } + } + /* + * Ask for runlevel on console if needed. + */ + if (lvl <= 0) lvl = ask_runlevel(); + + /* + * Log the fact that we have a runlevel now. + */ + return lvl; +} + + +/* + * We got signaled. + * + * Do actions for the new level. If we are compatible with + * 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 */ + unsigned char foo = 'X'; /* Contents of INITLVL */ + int ok = 1; +#ifdef INITLVL + FILE *fp; + struct stat stt; + int st; +#endif + + if (arg) foo = arg; + +#ifdef INITLVL + ok = 0; + + if (arg == 0) { + fp = NULL; + if (stat(INITLVL, &stt) != 0 || stt.st_size != 0L) + fp = fopen(INITLVL, "r"); +#ifdef INITLVL2 + if (fp == NULL && + (stat(INITLVL2, &stt) != 0 || stt.st_size != 0L)) + fp = fopen(INITLVL2, "r"); +#endif + if (fp == NULL) { + /* INITLVL file empty or not there - act as 'init q' */ + initlog(L_SY, "Re-reading inittab"); + return(runlevel); + } + ok = fscanf(fp, "%c %d", &foo, &st); + fclose(fp); + } else { + /* We go to the new runlevel passed as an argument. */ + foo = arg; + ok = 1; + } + if (ok == 2) sltime = st; + +#endif /* INITLVL */ + + if (islower(foo)) foo = toupper(foo); + if (ok < 1 || ok > 2 || strchr("QS0123456789ABCU", foo) == NULL) { + initlog(L_VB, "bad runlevel: %c", foo); + return runlevel; + } + + /* Log this action */ + switch(foo) { + case 'S': + initlog(L_VB, "Going single user"); + break; + case 'Q': + initlog(L_SY, "Re-reading inittab"); + break; + case 'A': + case 'B': + case 'C': + initlog(L_SY, + "Activating demand-procedures for '%c'", foo); + break; + case 'U': + initlog(L_SY, "Trying to re-exec init"); + return 'U'; + default: + initlog(L_VB, "Switching to runlevel: %c", foo); + } + + 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)) { + if (runlevel == 'S') return(runlevel); + + /* Read inittab again first! */ + read_inittab(); + + /* Mark those special tasks */ + for(ch = family; ch; ch = ch->next) + if (strchr(ch->rlevel, foo) != NULL || + strchr(ch->rlevel, tolower(foo)) != NULL) { + ch->flags |= DEMAND; + ch->flags &= ~XECUTED; + INITDBG(L_VB, + "Marking (%s) as ondemand, flags %d", + ch->id, ch->flags); + } + return runlevel; + } + + /* 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; + return foo; +} + + +/* + * This procedure is called after every signal (SIGHUP, SIGALRM..) + * + * Only clear the 'failing' flag if the process is sleeping + * longer than 5 minutes, or inittab was read again due + * to user interaction. + */ +static +void fail_check(void) +{ + CHILD *ch; /* Pointer to child structure */ + time_t t; /* System time */ + time_t next_alarm = 0; /* When to set next alarm */ + + time(&t); + + for(ch = family; ch; ch = ch->next) { + + if (ch->flags & FAILING) { + /* Can we free this sucker? */ + if (ch->tm + SLEEPTIME < t) { + ch->flags &= ~FAILING; + ch->count = 0; + ch->tm = 0; + } else { + /* No, we'll look again later */ + if (next_alarm == 0 || + ch->tm + SLEEPTIME > next_alarm) + next_alarm = ch->tm + SLEEPTIME; + } + } + } + if (next_alarm) { + next_alarm -= t; + if (next_alarm < 1) next_alarm = 1; + alarm(next_alarm); + } +} + +/* Set all 'Fail' timers to 0 */ +static +void fail_cancel(void) +{ + CHILD *ch; + + for(ch = family; ch; ch = ch->next) { + ch->count = 0; + ch->tm = 0; + ch->flags &= ~FAILING; + } +} + +/* + * Start up powerfail entries. + */ +static +void do_power_fail(int pwrstat) +{ + CHILD *ch; + + /* + * Tell powerwait & powerfail entries to start up + */ + for (ch = family; ch; ch = ch->next) { + if (pwrstat == 'O') { + /* + * The power is OK again. + */ + if (ch->action == POWEROKWAIT) + ch->flags &= ~XECUTED; + } else if (pwrstat == 'L') { + /* + * Low battery, shut down now. + */ + if (ch->action == POWERFAILNOW) + ch->flags &= ~XECUTED; + } else { + /* + * Power is failing, shutdown imminent + */ + if (ch->action == POWERFAIL || ch->action == POWERWAIT) + ch->flags &= ~XECUTED; + } + } +} + +/* + * Check for state-pipe presence + */ +static +int check_pipe(int fd) +{ + struct timeval t; + fd_set s; + char signature[8]; + + FD_ZERO(&s); + FD_SET(fd, &s); + t.tv_sec = t.tv_usec = 0; + + if (select(fd+1, &s, NULL, NULL, &t) != 1) + return 0; + if (read(fd, signature, 8) != 8) + return 0; + return strncmp(Signature, signature, 8) == 0; +} + +/* + * Make a state-pipe. + */ +static +int make_pipe(int fd) +{ + int fds[2]; + + pipe(fds); + dup2(fds[0], fd); + close(fds[0]); + fcntl(fds[1], F_SETFD, 1); + fcntl(fd, F_SETFD, 0); + write(fds[1], Signature, 8); + + return fds[1]; +} + +/* + * Attempt to re-exec. + */ +static +void re_exec(void) +{ + CHILD *ch; + sigset_t mask, oldset; + pid_t pid; + char **env; + int fd; + + if (strchr("S0123456",runlevel) == NULL) + return; + + /* + * Reset the alarm, and block all signals. + */ + alarm(0); + sigfillset(&mask); + sigprocmask(SIG_BLOCK, &mask, &oldset); + + /* + * construct a pipe fd --> STATE_PIPE and write a signature + */ + fd = make_pipe(STATE_PIPE); + + /* + * It's a backup day today, so I'm pissed off. Being a BOFH, however, + * does have it's advantages... + */ + fail_cancel(); + close(pipe_fd); + pipe_fd = -1; + DELSET(got_signals, SIGCHLD); + DELSET(got_signals, SIGHUP); + DELSET(got_signals, SIGUSR1); + + /* + * That should be cleaned. + */ + for(ch = family; ch; ch = ch->next) + if (ch->flags & ZOMBIE) { + INITDBG(L_VB, "Child died, PID= %d", ch->pid); + ch->flags &= ~(RUNNING|ZOMBIE|WAITING); + if (ch->process[0] != '+') + write_utmp_wtmp("", ch->id, ch->pid, DEAD_PROCESS, NULL); + } + + if ((pid = fork()) == 0) { + /* + * Child sends state information to the parent. + */ + send_state(fd); + exit(0); + } + + /* + * The existing init process execs a new init binary. + */ + env = init_buildenv(0); + execle(myname, myname, "--init", NULL, env); + + /* + * We shouldn't be here, something failed. + * Bitch, close the state pipe, unblock signals and return. + */ + close(fd); + close(STATE_PIPE); + sigprocmask(SIG_SETMASK, &oldset, NULL); + init_freeenv(env); + 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 + CHILD *ch; +#endif + int oldlevel; + + if (level == runlevel) return; + +#if CHANGE_WAIT + /* Are we waiting for a child? */ + for(ch = family; ch; ch = ch->next) + if (ch->flags & WAITING) break; + if (ch == NULL) +#endif + { + /* We need to go into a new runlevel */ + oldlevel = runlevel; + runlevel = read_level(level); + if (runlevel == 'U') { + runlevel = oldlevel; + re_exec(); + } else { + 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]", (int)runlevel); + } + } +} + + +/* + * Set/unset environment variables. The variables are + * 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; + int i, sz; + + e = data + size; + + while (*data && data < e) { + eq = NULL; + for (p = data; *p && p < e; p++) + if (*p == '=') eq = p; + if (*p) break; + env = data; + data = ++p; + + sz = eq ? (eq - env) : (p - env); + + /*initlog(L_SY, "init_setenv: %s, %s, %d", env, eq, sz);*/ + + /* + * We only allow INIT_* to be set. + */ + if (strncmp(env, "INIT_", 5) != 0) + continue; + + /* Free existing vars. */ + for (i = 0; i < NR_EXTRA_ENV; i++) { + if (extra_env[i] == NULL) continue; + if (!strncmp(extra_env[i], env, sz) && + extra_env[i][sz] == '=') { + free(extra_env[i]); + extra_env[i] = NULL; + } + } + + /* Set new vars if needed. */ + if (eq == NULL) continue; + for (i = 0; i < NR_EXTRA_ENV; i++) { + if (extra_env[i] == NULL) { + extra_env[i] = istrdup(env); + break; + } + } + } +} + + +/* + * Read from the init FIFO. Processes like telnetd and rlogind can + * ask us to create login processes on their behalf. + * + * FIXME: this needs to be finished. NOT that it is buggy, but we need + * to add the telnetd/rlogind stuff so people can start using it. + * Maybe move to using an AF_UNIX socket so we can use + * the 2.2 kernel credential stuff to see who we're talking to. + * + */ +static +void check_init_fifo(void) +{ + struct init_request request; + struct timeval tv; + struct stat st, st2; + fd_set fds; + int n; + int quit = 0; + + /* + * First, try to create /dev/initctl if not present. + */ + if (stat(INIT_FIFO, &st2) < 0 && errno == ENOENT) + (void)mkfifo(INIT_FIFO, 0600); + + /* + * If /dev/initctl is open, stat the file to see if it + * is still the _same_ inode. + */ + if (pipe_fd >= 0) { + fstat(pipe_fd, &st); + if (stat(INIT_FIFO, &st2) < 0 || + st.st_dev != st2.st_dev || + st.st_ino != st2.st_ino) { + close(pipe_fd); + pipe_fd = -1; + } + } + + /* + * Now finally try to open /dev/initctl + */ + if (pipe_fd < 0) { + if ((pipe_fd = open(INIT_FIFO, O_RDWR|O_NONBLOCK)) >= 0) { + fstat(pipe_fd, &st); + if (!S_ISFIFO(st.st_mode)) { + initlog(L_VB, "%s is not a fifo", INIT_FIFO); + close(pipe_fd); + pipe_fd = -1; + } + } + if (pipe_fd >= 0) { + /* + * Don't use fd's 0, 1 or 2. + */ + (void) dup2(pipe_fd, PIPE_FD); + close(pipe_fd); + pipe_fd = PIPE_FD; + + /* + * Return to caller - we'll be back later. + */ + } + } + + /* Wait for data to appear, _if_ the pipe was opened. */ + if (pipe_fd >= 0) while(!quit) { + + /* Do select, return on EINTR. */ + FD_ZERO(&fds); + FD_SET(pipe_fd, &fds); + tv.tv_sec = 5; + tv.tv_usec = 0; + n = select(pipe_fd + 1, &fds, NULL, NULL, &tv); + if (n <= 0) { + if (n == 0 || errno == EINTR) return; + continue; + } + + /* Read the data, return on EINTR. */ + n = read(pipe_fd, &request, sizeof(request)); + if (n == 0) { + /* + * End of file. This can't happen under Linux (because + * the pipe is opened O_RDWR - see select() in the + * kernel) but you never know... + */ + close(pipe_fd); + pipe_fd = -1; + return; + } + if (n <= 0) { + if (errno == EINTR) return; + initlog(L_VB, "error reading initrequest"); + continue; + } + + /* + * This is a convenient point to also try to + * find the console device or check if it changed. + */ + console_init(); + + /* + * Process request. + */ + if (request.magic != INIT_MAGIC || n != sizeof(request)) { + initlog(L_VB, "got bogus initrequest"); + continue; + } + switch(request.cmd) { + case INIT_CMD_RUNLVL: + sltime = request.sleeptime; + fifo_new_level(request.runlevel); + quit = 1; + break; + case INIT_CMD_POWERFAIL: + sltime = request.sleeptime; + do_power_fail('F'); + quit = 1; + break; + case INIT_CMD_POWERFAILNOW: + sltime = request.sleeptime; + do_power_fail('L'); + quit = 1; + break; + case INIT_CMD_POWEROK: + sltime = request.sleeptime; + do_power_fail('O'); + quit = 1; + break; + case INIT_CMD_SETENV: + initcmd_setenv(request.i.data, sizeof(request.i.data)); + break; + default: + initlog(L_VB, "got unimplemented initrequest."); + break; + } + } + + /* + * We come here if the pipe couldn't be opened. + */ + if (pipe_fd < 0) pause(); + +} + + +/* + * This function is used in the transition + * sysinit (-> single user) boot -> multi-user. + */ +static +void boot_transitions() +{ + CHILD *ch; + static int newlevel = 0; + static int warn = 1; + int loglevel; + int oldlevel; + + /* Check if there is something to wait for! */ + for( ch = family; ch; ch = ch->next ) + if ((ch->flags & RUNNING) && ch->action != BOOT) break; + + if (ch == NULL) { + /* No processes left in this level, proceed to next level. */ + loglevel = -1; + oldlevel = 'N'; + switch(runlevel) { + case '#': /* SYSINIT -> BOOT */ + INITDBG(L_VB, "SYSINIT -> BOOT"); + + /* Write a boot record. */ + wrote_utmp_reboot = 0; + wrote_wtmp_reboot = 0; + write_utmp_wtmp("reboot", "~~", 0, BOOT_TIME, "~"); + + /* Get our run level */ + newlevel = dfl_level ? dfl_level : get_init_default(); + if (newlevel == 'S') { + runlevel = newlevel; + /* Not really 'S' but show anyway. */ + setproctitle("init [S]"); + } else + runlevel = '*'; + break; + case '*': /* BOOT -> NORMAL */ + INITDBG(L_VB, "BOOT -> NORMAL"); + if (runlevel != newlevel) + loglevel = newlevel; + runlevel = newlevel; + did_boot = 1; + warn = 1; + break; + case 'S': /* Ended SU mode */ + case 's': + INITDBG(L_VB, "END SU MODE"); + newlevel = get_init_default(); + if (!did_boot && newlevel != 'S') + runlevel = '*'; + else { + if (runlevel != newlevel) + loglevel = newlevel; + runlevel = newlevel; + oldlevel = 'S'; + } + warn = 1; + for(ch = family; ch; ch = ch->next) + if (strcmp(ch->rlevel, "S") == 0) + ch->flags &= ~(FAILING|WAITING|XECUTED); + break; + default: + if (warn) + initlog(L_VB, + "no more processes left in this runlevel"); + warn = 0; + loglevel = -1; + if (got_signals == 0) + check_init_fifo(); + break; + } + 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]", (int)runlevel); + } + } +} + +/* + * Init got hit by a signal. See which signal it is, + * and act accordingly. + */ +static +void process_signals() +{ + CHILD *ch; + int pwrstat; + int oldlevel; + int fd; + char c; + + if (ISMEMBER(got_signals, SIGPWR)) { + INITDBG(L_VB, "got SIGPWR"); + /* See _what_ kind of SIGPWR this is. */ + pwrstat = 0; + if ((fd = open(PWRSTAT, O_RDONLY)) >= 0) { + c = 0; + read(fd, &c, 1); + 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) + if (ch->action == CTRLALTDEL) + ch->flags &= ~XECUTED; + DELSET(got_signals, SIGINT); + } + + if (ISMEMBER(got_signals, SIGWINCH)) { + INITDBG(L_VB, "got SIGWINCH"); + /* Tell kbrequest entry to start up */ + for(ch = family; ch; ch = ch->next) + if (ch->action == KBREQUEST) + ch->flags &= ~XECUTED; + DELSET(got_signals, SIGWINCH); + } + + if (ISMEMBER(got_signals, SIGALRM)) { + INITDBG(L_VB, "got SIGALRM"); + /* The timer went off: check it out */ + DELSET(got_signals, SIGALRM); + } + + if (ISMEMBER(got_signals, SIGCHLD)) { + INITDBG(L_VB, "got SIGCHLD"); + /* First set flag to 0 */ + DELSET(got_signals, SIGCHLD); + + /* See which child this was */ + for(ch = family; ch; ch = ch->next) + if (ch->flags & ZOMBIE) { + INITDBG(L_VB, "Child died, PID= %d", ch->pid); + ch->flags &= ~(RUNNING|ZOMBIE|WAITING); + if (ch->process[0] != '+') + write_utmp_wtmp("", ch->id, ch->pid, DEAD_PROCESS, NULL); + } + + } + + if (ISMEMBER(got_signals, SIGHUP)) { + INITDBG(L_VB, "got SIGHUP"); +#if CHANGE_WAIT + /* Are we waiting for a child? */ + for(ch = family; ch; ch = ch->next) + if (ch->flags & WAITING) break; + if (ch == NULL) +#endif + { + /* We need to go into a new runlevel */ + oldlevel = runlevel; +#ifdef INITLVL + runlevel = read_level(0); +#endif + if (runlevel == 'U') { + runlevel = oldlevel; + re_exec(); + } else { + if (oldlevel != 'S' && runlevel == 'S') console_stty(); + if (runlevel == '6' || runlevel == '0' || + runlevel == '1') console_stty(); + read_inittab(); + fail_cancel(); + setproctitle("init [%c]", (int)runlevel); + DELSET(got_signals, SIGHUP); + } + } + } + if (ISMEMBER(got_signals, SIGUSR1)) { + /* + * SIGUSR1 means close and reopen /dev/initctl + */ + INITDBG(L_VB, "got SIGUSR1"); + close(pipe_fd); + pipe_fd = -1; + DELSET(got_signals, SIGUSR1); + } +} + +/* + * The main loop + */ +static +void init_main(void) +{ + CHILD *ch; + struct sigaction sa; + sigset_t sgt; + int f, st; + + if (!reload) { + +#if INITDEBUG + /* + * Fork so we can debug the init process. + */ + if ((f = fork()) > 0) { + static const char killmsg[] = "PRNT: init killed.\r\n"; + pid_t rc; + + while((rc = wait(&st)) != f) + if (rc < 0 && errno == ECHILD) + break; + write(1, killmsg, sizeof(killmsg) - 1); + while(1) pause(); + } +#endif + +#ifdef __linux__ + /* + * Tell the kernel to send us SIGINT when CTRL-ALT-DEL + * is pressed, and that we want to handle keyboard signals. + */ + init_reboot(BMAGIC_SOFT); + if ((f = open(VT_MASTER, O_RDWR | O_NOCTTY)) >= 0) { + (void) ioctl(f, KDSIGACCEPT, SIGWINCH); + close(f); + } else + (void) ioctl(0, KDSIGACCEPT, SIGWINCH); +#endif + + /* + * Ignore all signals. + */ + for(f = 1; f <= NSIG; f++) + SETSIG(sa, f, SIG_IGN, SA_RESTART); + } + + SETSIG(sa, SIGALRM, signal_handler, 0); + SETSIG(sa, SIGHUP, signal_handler, 0); + SETSIG(sa, SIGINT, signal_handler, 0); + SETSIG(sa, SIGCHLD, chld_handler, SA_RESTART); + SETSIG(sa, SIGPWR, signal_handler, 0); + SETSIG(sa, SIGWINCH, signal_handler, 0); + SETSIG(sa, SIGUSR1, signal_handler, 0); + SETSIG(sa, SIGSTOP, stop_handler, SA_RESTART); + SETSIG(sa, SIGTSTP, stop_handler, SA_RESTART); + SETSIG(sa, SIGCONT, cont_handler, SA_RESTART); + SETSIG(sa, SIGSEGV, (void (*)(int))segv_handler, SA_RESTART); + + console_init(); + + if (!reload) { + int fd; + + /* Close whatever files are open, and reset the console. */ + close(0); + close(1); + close(2); + console_stty(); + setsid(); + + /* + * Set default PATH variable. + */ + setenv("PATH", PATH_DEFAULT, 1 /* Overwrite */); + + /* + * Initialize /var/run/utmp (only works if /var is on + * root and mounted rw) + */ + if ((fd = open(UTMP_FILE, O_WRONLY|O_CREAT|O_TRUNC, 0644)) >= 0) + close(fd); + + /* + * Say hello to the world + */ + initlog(L_CO, bootmsg, "booting"); + + /* + * 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) + if (rc < 0 && errno == ECHILD) + break; + } + SETSIG(sa, SIGCHLD, chld_handler, SA_RESTART); + } + + /* + * Start normal boot procedure. + */ + runlevel = '#'; + read_inittab(); + + } else { + /* + * Restart: unblock signals and let the show go on + */ + initlog(L_CO, bootmsg, "reloading"); + sigfillset(&sgt); + sigprocmask(SIG_UNBLOCK, &sgt, NULL); + + /* + * Set default PATH variable. + */ + setenv("PATH", PATH_DEFAULT, 0 /* Don't overwrite */); + } + start_if_needed(); + + while(1) { + + /* See if we need to make the boot transitions. */ + boot_transitions(); + INITDBG(L_VB, "init_main: waiting.."); + + /* Check if there are processes to be waited on. */ + for(ch = family; ch; ch = ch->next) + if ((ch->flags & RUNNING) && ch->action != BOOT) break; + +#if CHANGE_WAIT + /* Wait until we get hit by some signal. */ + while (ch != NULL && got_signals == 0) { + if (ISMEMBER(got_signals, SIGHUP)) { + /* See if there are processes to be waited on. */ + for(ch = family; ch; ch = ch->next) + if (ch->flags & WAITING) break; + } + if (ch != NULL) check_init_fifo(); + } +#else /* CHANGE_WAIT */ + if (ch != NULL && got_signals == 0) check_init_fifo(); +#endif /* CHANGE_WAIT */ + + /* Check the 'failing' flags */ + fail_check(); + + /* Process any signals. */ + process_signals(); + + /* See what we need to start up (again) */ + start_if_needed(); + } + /*NOTREACHED*/ +} + +/* + * 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 + FILE *fp; +#endif + struct init_request request; + struct sigaction sa; + int f, fd, l; + char *env = NULL; + + memset(&request, 0, sizeof(request)); + request.magic = INIT_MAGIC; + + while ((f = getopt(argc, argv, "t:e:")) != EOF) switch(f) { + case 't': + sltime = atoi(optarg); + break; + case 'e': + if (env == NULL) + env = request.i.data; + l = strlen(optarg); + if (env + l + 2 > request.i.data + sizeof(request.i.data)) { + fprintf(stderr, "%s: -e option data " + "too large\n", progname); + exit(1); + } + memcpy(env, optarg, l); + env += l; + *env++ = 0; + break; + default: + usage(progname); + break; + } + + if (env) *env++ = 0; + + if (env) { + if (argc != optind) + usage(progname); + request.cmd = INIT_CMD_SETENV; + } else { + if (argc - optind != 1 || strlen(argv[optind]) != 1) + usage(progname); + if (!strchr("0123456789SsQqAaBbCcUu", argv[optind][0])) + usage(progname); + request.cmd = INIT_CMD_RUNLVL; + request.runlevel = env ? 0 : argv[optind][0]; + 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) { + 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; + } + +#ifdef TELINIT_USES_INITLVL + if (request.cmd == INIT_CMD_RUNLVL) { + /* Fallthrough to the old method. */ + + /* Now write the new runlevel. */ + if ((fp = fopen(INITLVL, "w")) == NULL) { + fprintf(stderr, "%s: cannot create %s\n", + progname, INITLVL); + exit(1); + } + fprintf(fp, "%s %d", argv[optind], sltime); + fclose(fp); + + /* And tell init about the pending runlevel change. */ + if (kill(INITPID, SIGHUP) < 0) perror(progname); + + return 0; + } +#endif + + fprintf(stderr, "%s: ", progname); + if (ISMEMBER(got_signals, SIGALRM)) { + fprintf(stderr, "timeout opening/writing control channel %s\n", + INIT_FIFO); + } else { + perror(INIT_FIFO); + } + return 1; +} + +/* + * Main entry for init and telinit. + */ +int main(int argc, char **argv) +{ + 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 */ + if (geteuid() != 0) { + fprintf(stderr, "%s: must be superuser.\n", p); + exit(1); + } + + /* + * Is this telinit or init ? + */ + isinit = (getpid() == 1); + for (f = 1; f < argc; f++) { + if (!strcmp(argv[f], "-i") || !strcmp(argv[f], "--init")) { + isinit = 1; + break; + } + } + if (!isinit) exit(telinit(p, argc, argv)); + + /* + * Check for re-exec + */ + if (check_pipe(STATE_PIPE)) { + + receive_state(STATE_PIPE); + + myname = istrdup(argv[0]); + argv0 = argv[0]; + maxproclen = 0; + for (f = 0; f < argc; f++) + maxproclen += strlen(argv[f]) + 1; + reload = 1; + setproctitle("init [%c]", (int)runlevel); + + init_main(); + } + + /* Check command line arguments */ + maxproclen = strlen(argv[0]) + 1; + for(f = 1; f < argc; f++) { + if (!strcmp(argv[f], "single") || !strcmp(argv[f], "-s")) + dfl_level = 'S'; + else if (!strcmp(argv[f], "-a") || !strcmp(argv[f], "auto")) + putenv("AUTOBOOT=YES"); + else if (!strcmp(argv[f], "-b") || !strcmp(argv[f],"emergency")) + emerg_shell = 1; + else if (!strcmp(argv[f], "-z")) { + /* Ignore -z xxx */ + if (argv[f + 1]) f++; + } else if (strchr("0123456789sS", argv[f][0]) + && strlen(argv[f]) == 1) + dfl_level = argv[f][0]; + /* "init u" in the very beginning makes no sense */ + if (dfl_level == 's') dfl_level = 'S'; + maxproclen += strlen(argv[f]) + 1; + } + +#ifdef WITH_SELINUX + 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(); + + /*NOTREACHED*/ + return 0; +} diff --git a/src/init.h b/src/init.h new file mode 100644 index 00000000..9763140a --- /dev/null +++ b/src/init.h @@ -0,0 +1,148 @@ +/* + * init.h Several defines and declarations to be + * included by all modules of the init program. + * + * Version: @(#)init.h 2.85-5 02-Jul-2003 miquels@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 */ +#define CHANGE_WAIT 0 /* Change runlevel while + waiting for a process to exit? */ +/* Debug and test modes */ +#define DEBUG 0 /* Debug code off */ +#define INITDEBUG 0 /* Fork at startup to debug init. */ + +/* Some constants */ +#define INITPID 1 /* pid of first process */ +#define PIPE_FD 10 /* Fileno of initfifo. */ +#define STATE_PIPE 11 /* used to pass state through exec */ + +/* Failsafe configuration */ +#define MAXSPAWN 10 /* Max times respawned in.. */ +#define TESTTIME 120 /* this much seconds */ +#define SLEEPTIME 300 /* Disable time */ + +/* Default path inherited by every child. */ +#define PATH_DEFAULT "/sbin:/usr/sbin:/bin:/usr/bin" + + +/* Prototypes. */ +void write_utmp_wtmp(char *user, char *id, int pid, int type, char *line); +void write_wtmp(char *user, char *id, int pid, int type, char *line); +#ifdef __GNUC__ +__attribute__ ((format (printf, 2, 3))) +#endif +void initlog(int loglevel, char *fmt, ...); +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 +# define INITDBG(level, fmt, args...) +#endif + +/* Actions to be taken by init */ +#define RESPAWN 1 +#define WAIT 2 +#define ONCE 3 +#define BOOT 4 +#define BOOTWAIT 5 +#define POWERFAIL 6 +#define POWERWAIT 7 +#define POWEROKWAIT 8 +#define CTRLALTDEL 9 +#define OFF 10 +#define ONDEMAND 11 +#define INITDEFAULT 12 +#define SYSINIT 13 +#define POWERFAILNOW 14 +#define KBREQUEST 15 + +/* Information about a process in the in-core inittab */ +typedef struct _child_ { + int flags; /* Status of this entry */ + int exstat; /* Exit status of process */ + int pid; /* Pid of this process */ + time_t tm; /* When respawned last */ + int count; /* Times respawned in the last 2 minutes */ + char id[8]; /* Inittab id (must be unique) */ + char rlevel[12]; /* run levels */ + int action; /* what to do (see list below) */ + char process[128]; /* The command line */ + struct _child_ *new; /* New entry (after inittab re-read) */ + struct _child_ *next; /* For the linked list */ +} CHILD; + +/* Values for the 'flags' field */ +#define RUNNING 2 /* Process is still running */ +#define KILLME 4 /* Kill this process */ +#define DEMAND 8 /* "runlevels" a b c */ +#define FAILING 16 /* process respawns rapidly */ +#define WAITING 32 /* We're waiting for this process */ +#define ZOMBIE 64 /* This process is already dead */ +#define XECUTED 128 /* Set if spawned once or more times */ + +/* Log levels. */ +#define L_CO 1 /* Log on the console. */ +#define L_SY 2 /* Log with syslog() */ +#define L_VB (L_CO|L_SY) /* Log with both. */ + +#ifndef NO_PROCESS +# define NO_PROCESS 0 +#endif + +/* + * Global variables. + */ +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 +#define C_END 2 +#define C_REC 3 +#define C_EOR 4 +#define C_LEV 5 +#define C_FLAG 6 +#define C_ACTION 7 +#define C_PROCESS 8 +#define C_PID 9 +#define C_EXS 10 +#define C_EOF -1 +#define D_RUNLEVEL -2 +#define D_THISLEVEL -3 +#define D_PREVLEVEL -4 +#define D_GOTSIGN -5 +#define D_WROTE_WTMP_REBOOT -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 + diff --git a/src/initreq.h b/src/initreq.h new file mode 100644 index 00000000..757ffe0e --- /dev/null +++ b/src/initreq.h @@ -0,0 +1,84 @@ +/* + * initreq.h Interface to talk to init through /dev/initctl. + * + * Copyright (C) 1995-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 + * + * Version: @(#)initreq.h 1.28 31-Mar-2004 MvS + * + */ +#ifndef _INITREQ_H +#define _INITREQ_H + +#include + +#if defined(__FreeBSD_kernel__) +# define INIT_FIFO "/etc/.initctl" +#else +# define INIT_FIFO "/dev/initctl" +#endif + +#define INIT_MAGIC 0x03091969 +#define INIT_CMD_START 0 +#define INIT_CMD_RUNLVL 1 +#define INIT_CMD_POWERFAIL 2 +#define INIT_CMD_POWERFAILNOW 3 +#define INIT_CMD_POWEROK 4 +#define INIT_CMD_BSD 5 +#define INIT_CMD_SETENV 6 +#define INIT_CMD_UNSETENV 7 + +#ifdef MAXHOSTNAMELEN +# define INITRQ_HLEN MAXHOSTNAMELEN +#else +# define INITRQ_HLEN 64 +#endif + +/* + * This is what BSD 4.4 uses when talking to init. + * Linux doesn't use this right now. + */ +struct init_request_bsd { + char gen_id[8]; /* Beats me.. telnetd uses "fe" */ + char tty_id[16]; /* Tty name minus /dev/tty */ + char host[INITRQ_HLEN]; /* Hostname */ + char term_type[16]; /* Terminal type */ + int signal; /* Signal to send */ + int pid; /* Process to send to */ + char exec_name[128]; /* Program to execute */ + char reserved[128]; /* For future expansion. */ +}; + + +/* + * Because of legacy interfaces, "runlevel" and "sleeptime" + * aren't in a seperate struct in the union. + * + * The weird sizes are because init expects the whole + * struct to be 384 bytes. + */ +struct init_request { + int magic; /* Magic number */ + int cmd; /* What kind of request */ + int runlevel; /* Runlevel to change to */ + int sleeptime; /* Time between TERM and KILL */ + union { + struct init_request_bsd bsd; + char data[368]; + } i; +}; + +#endif diff --git a/src/initscript.sample b/src/initscript.sample new file mode 100755 index 00000000..64126d0f --- /dev/null +++ b/src/initscript.sample @@ -0,0 +1,25 @@ +# +# initscript If this script is intalled as /etc/initscript, +# it is executed by init(8) for every program it +# wants to spawn like this: +# +# /bin/sh /etc/initscript +# +# It can be used to set the default umask and ulimit +# of all processes. By default this script is installed +# as /etc/initscript.sample, so to enable it you must +# rename this script first to /etc/initscript. +# +# Version: @(#)initscript 1.10 10-Dec-1995 MvS. +# +# Author: Miquel van Smoorenburg, +# + + # Set umask to safe level, and enable core dumps. + umask 022 + ulimit -c 2097151 + PATH=/bin:/sbin:/usr/bin:/usr/sbin + export PATH + + # Execute the program. + eval exec "$4" diff --git a/src/killall5.c b/src/killall5.c new file mode 100644 index 00000000..5937d98e --- /dev/null +++ b/src/killall5.c @@ -0,0 +1,1104 @@ +/* + * kilall5.c Kill all processes except processes that have the + * same session id, so that the shell that called us + * won't be killed. Typically used in shutdown scripts. + * + * pidof.c Tries to get the pid of the process[es] named. + * + * Version: 2.86 30-Jul-2004 MvS + * + * Usage: killall5 [-][signal] + * pidof [-s] [-o omitpid [-o omitpid]] program [program..] + * + * Authors: Miquel van Smoorenburg, miquels@cistron.nl + * + * Riku Meskanen, + * - return all running pids of given program name + * - single shot '-s' option for backwards combatibility + * - omit pid '-o' option and %PPID (parent pid metavariable) + * - 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 (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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +char *Version = "@(#)killall5 2.86 31-Jul-2004 miquels@cistron.nl"; + +#define STATNAMELEN 15 +#define DO_NETFS 2 +#define DO_STAT 1 +#define NO_STAT 0 + +/* Info about a process. */ +typedef struct proc { + char *argv0; /* Name as found out from argv[0] */ + char *argv0base; /* `basename argv[1]` */ + char *argv1; /* Name as found out from argv[1] */ + char *argv1base; /* `basename argv[1]` */ + char *statname; /* the statname without braces */ + ino_t ino; /* Inode number */ + dev_t dev; /* Device it is on */ + pid_t pid; /* Process ID. */ + 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; + +/* pid queue */ + +typedef struct pidq { + PROC *proc; + struct pidq *next; +} PIDQ; + +typedef struct { + PIDQ *head; + PIDQ *tail; + 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; + +int scripts_too = 0; + +char *progname; /* the name of the running program */ +#ifdef __GNUC__ +__attribute__ ((format (printf, 2, 3))) +#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. + */ +#ifdef __GNUC__ +static void *xmalloc(size_t) __attribute__ ((__malloc__)); +#endif +static void *xmalloc(size_t bytes) +{ + void *p; + + if ((p = malloc(bytes)) == NULL) { + if (sent_sigstop) kill(-1, SIGCONT); + nsyslog(LOG_ERR, "out of memory"); + exit(1); + } + 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. + */ +int mount_proc(void) +{ + struct stat st; + char *args[] = { "mount", "-t", "proc", "proc", "/proc", 0 }; + pid_t pid, rc; + int wst; + int did_mount = 0; + + /* Stat /proc/version to see if /proc is mounted. */ + if (stat("/proc/version", &st) < 0 && errno == ENOENT) { + + /* It's not there, so mount it. */ + if ((pid = fork()) < 0) { + nsyslog(LOG_ERR, "cannot fork"); + exit(1); + } + if (pid == 0) { + /* Try a few mount binaries. */ + execv("/sbin/mount", args); + execv("/bin/mount", args); + + /* Okay, I give up. */ + nsyslog(LOG_ERR, "cannot execute mount"); + exit(1); + } + /* Wait for child. */ + while ((rc = wait(&wst)) != pid) + if (rc < 0 && errno == ECHILD) + break; + if (rc != pid || WEXITSTATUS(wst) != 0) + nsyslog(LOG_ERR, "mount returned non-zero exit status"); + + did_mount = 1; + } + + /* See if mount succeeded. */ + if (stat("/proc/version", &st) < 0) { + if (errno == ENOENT) + nsyslog(LOG_ERR, "/proc not mounted, failed to mount."); + else + nsyslog(LOG_ERR, "/proc unavailable."); + exit(1); + } + + 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; + + while (f < (sz-1) && (c = fgetc(fp)) != EOF && c) + buf[f++] = c; + buf[f] = 0; + + return (c == EOF && f == 0) ? c : f; +} + +/* + * Read the proc filesystem. + * CWD must be /proc to avoid problems if / is affected by the killing (ie depend on fuse). + */ +int readproc(int do_stat) +{ + DIR *dir; + FILE *fp; + PROC *p, *n; + struct dirent *d; + struct stat st; + char path[PATH_MAX+1]; + char buf[PATH_MAX+1]; + char *s, *q; + unsigned long startcode, endcode; + int pid, f; + + /* Open the /proc directory. */ + if (chdir("/proc") == -1) { + nsyslog(LOG_ERR, "chdir /proc failed"); + return -1; + } + if ((dir = opendir(".")) == NULL) { + nsyslog(LOG_ERR, "cannot opendir(/proc)"); + return -1; + } + + /* Free the already existing process list. */ + n = plist; + for (p = plist; n; p = n) { + 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; + + /* Walk through the directory. */ + while ((d = readdir(dir)) != NULL) { + + /* See if this is a process */ + if ((pid = atoi(d->d_name)) == 0) continue; + + /* Get a PROC struct . */ + p = (PROC *)xmalloc(sizeof(PROC)); + memset(p, 0, sizeof(PROC)); + + /* Open the status file. */ + snprintf(path, sizeof(path), "%s/stat", d->d_name); + + /* Read SID & statname from it. */ + if ((fp = fopen(path, "r")) != NULL) { + buf[0] = 0; + fgets(buf, sizeof(buf), fp); + + /* See if name starts with '(' */ + s = buf; + while (*s != ' ') s++; + s++; + if (*s == '(') { + /* Read program name. */ + q = strrchr(buf, ')'); + if (q == NULL) { + p->sid = 0; + 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; + } + s++; + } else { + q = s; + while (*q != ' ') q++; + } + *q++ = 0; + while (*q == ' ') q++; + p->statname = (char *)xmalloc(strlen(s)+1); + strcpy(p->statname, s); + + /* Get session, startcode, endcode. */ + startcode = endcode = 0; + if (sscanf(q, "%*c %*d %*d %d %*d %*d %*u %*u " + "%*u %*u %*u %*u %*u %*d %*d " + "%*d %*d %*d %*d %*u %*u %*d " + "%*u %lu %lu", + &p->sid, &startcode, &endcode) != 3) { + 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; + } + if (startcode == 0 && endcode == 0) + p->kernel = 1; + 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; + } + + snprintf(path, sizeof(path), "%s/cmdline", d->d_name); + if ((fp = fopen(path, "r")) != NULL) { + + /* Now read argv[0] */ + f = readarg(fp, buf, sizeof(buf)); + + if (buf[0]) { + /* Store the name into malloced memory. */ + p->argv0 = (char *)xmalloc(f + 1); + strcpy(p->argv0, buf); + + /* Get a pointer to the basename. */ + p->argv0base = strrchr(p->argv0, '/'); + if (p->argv0base != NULL) + p->argv0base++; + else + p->argv0base = p->argv0; + } + + /* And read argv[1] */ + while ((f = readarg(fp, buf, sizeof(buf))) != EOF) + if (buf[0] != '-') break; + + if (buf[0]) { + /* Store the name into malloced memory. */ + p->argv1 = (char *)xmalloc(f + 1); + strcpy(p->argv1, buf); + + /* Get a pointer to the basename. */ + p->argv1base = strrchr(p->argv1, '/'); + if (p->argv1base != NULL) + p->argv1base++; + else + p->argv1base = p->argv1; + } + + 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; + } + + /* Try to stat the executable. */ + snprintf(path, sizeof(path), "/proc/%s/exe", d->d_name); + + 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. */ + p->next = plist; + plist = p; + p->pid = pid; + } + closedir(dir); + + /* Done. */ + return 0; +} + +PIDQ_HEAD *init_pid_q(PIDQ_HEAD *q) +{ + q->head = q->next = q->tail = NULL; + return q; +} + +int empty_q(PIDQ_HEAD *q) +{ + return (q->head == NULL); +} + +int add_pid_to_q(PIDQ_HEAD *q, PROC *p) +{ + PIDQ *tmp; + + tmp = (PIDQ *)xmalloc(sizeof(PIDQ)); + + tmp->proc = p; + tmp->next = NULL; + + if (empty_q(q)) { + q->head = tmp; + q->tail = tmp; + } else { + q->tail->next = tmp; + q->tail = tmp; + } + return 0; +} + +PROC *get_next_from_pid_q(PIDQ_HEAD *q) +{ + PROC *p; + PIDQ *tmp = q->head; + + if (!empty_q(q)) { + p = q->head->proc; + q->head = tmp->next; + free(tmp); + return p; + } + + return NULL; +} + +/* Try to get the process ID of a given process. */ +PIDQ_HEAD *pidof(char *prog) +{ + PROC *p; + 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; + else + s++; + + if (! *s) + return NULL; + + q = (PIDQ_HEAD *)xmalloc(sizeof(PIDQ_HEAD)); + q = init_pid_q(q); + + /* First try to find a match based on dev/ino pair. */ + 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++; + } + } + } + + /* 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; + + /* matching nonmatching + * proc name prog name prog name + * --- ----------- ------------ + * b b, p/b, q/b + * p/b b, p/b q/b + * + * Algorithm: Match if: + * cmd = arg + * or cmd = base(arg) + * or base(cmd) = arg + * + * Specifically, do not match just because base(cmd) = base(arg) + * as was done in earlier versions of this program, since this + * allows /aaa/foo to match /bbb/foo . + */ + ok |= + (p->argv0 && strcmp(p->argv0, prog) == 0) + || (p->argv0 && s != prog && strcmp(p->argv0, s) == 0) + || (p->argv0base && strcmp(p->argv0base, prog) == 0); + + /* For scripts, compare argv[1] as well. */ + if ( + scripts_too && p->statname && p->argv1base + && !strncmp(p->statname, p->argv1base, STATNAMELEN) + ) { + ok |= + (p->argv1 && strcmp(p->argv1, prog) == 0) + || (p->argv1 && s != prog && strcmp(p->argv1, s) == 0) + || (p->argv1base && strcmp(p->argv1base, prog) == 0); + } + + /* + * if we have a space in argv0, process probably + * used setproctitle so try statname. + */ + if (strlen(s) <= STATNAMELEN && + (p->argv0 == NULL || + p->argv0[0] == 0 || + 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; +} + +/* Give usage message and exit. */ +void usage(void) +{ + nsyslog(LOG_ERR, "only one argument, a signal number, allowed"); + closelog(); + exit(1); +} + +/* write to syslog file if not open terminal */ +#ifdef __GNUC__ +__attribute__ ((format (printf, 2, 3))) +#endif +void nsyslog(int pri, char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + + if (ttyname(0) == NULL) { + vsyslog(pri, fmt, args); + } else { + fprintf(stderr, "%s: ",progname); + vfprintf(stderr, fmt, args); + fprintf(stderr, "\n"); + } + + va_end(args); +} + +#define PIDOF_SINGLE 0x01 +#define PIDOF_OMIT 0x02 +#define PIDOF_NETFS 0x04 + +/* + * Pidof functionality. + */ +int main_pidof(int argc, char **argv) +{ + PIDQ_HEAD *q; + PROC *p; + char *token, *here; + int f; + int first = 1; + int opt, flags = 0; + int chroot_check = 0; + struct stat st; + char tmp[512]; + + omit = (OMIT*)0; + nlist = (NFS*)0; + opterr = 0; + + 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(); + exit(1); + case 'c': + if (geteuid() == 0) chroot_check = 1; + break; + case 'o': + 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; + } + flags |= PIDOF_OMIT; + break; + case 's': + flags |= PIDOF_SINGLE; + break; + case 'x': + scripts_too++; + break; + case 'n': + flags |= PIDOF_NETFS; + break; + default: + /* Nothing */ + break; + } + argc -= optind; + argv += optind; + + /* Check if we are in a chroot */ + if (chroot_check) { + snprintf(tmp, 512, "/proc/%d/root", getpid()); + if (stat(tmp, &st) < 0) { + nsyslog(LOG_ERR, "stat failed for %s!\n", tmp); + closelog(); + exit(1); + } + } + + if (flags & PIDOF_NETFS) + init_nfs(); /* Which network based FS are online? */ + + /* Print out process-ID's one by one. */ + readproc((flags & PIDOF_NETFS) ? DO_NETFS : DO_STAT); + + for(f = 0; f < argc; f++) { + if ((q = pidof(argv[f])) != NULL) { + pid_t spid = 0; + while ((p = get_next_from_pid_q(q))) { + 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 (optr) + continue; + } + if (flags & PIDOF_SINGLE) { + if (spid) + continue; + else + spid = 1; + } + if (chroot_check) { + struct stat st2; + snprintf(tmp, 512, "/proc/%d/root", + p->pid); + if (stat(tmp, &st2) < 0 || + st.st_dev != st2.st_dev || + st.st_ino != st2.st_ino) { + continue; + } + } + if (!first) + printf(" "); + printf("%d", p->pid); + first = 0; + } + } + } + if (!first) + printf("\n"); + + clear_mnt(); + + closelog(); + return(first ? 1 : 0); +} + +/* Main for either killall or pidof. */ +int main(int argc, char **argv) +{ + PROC *p; + int pid, sid = -1; + int sig = SIGKILL; + int c; + + /* return non-zero if no process was killed */ + int retval = 2; + + /* Get program name. */ + if ((progname = strrchr(argv[0], '/')) == NULL) + progname = argv[0]; + else + progname++; + + /* Now connect to syslog. */ + openlog(progname, LOG_CONS|LOG_PID, LOG_DAEMON); + + /* Were we called as 'pidof' ? */ + if (strcmp(progname, "pidof") == 0) + return main_pidof(argc, argv); + + /* Right, so we are "killall". */ + omit = (OMIT*)0; + + if (argc > 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; + } + } + else if ((sig = atoi(argv[1])) <= 0 || sig > 31) + usage(); + } + } + + /* First get the /proc filesystem online. */ + mount_proc(); + + /* + * Ignoring SIGKILL and SIGSTOP do not make sense, but + * someday kill(-1, sig) might kill ourself if we don't + * do this. This certainly is a valid concern for SIGTERM- + * Linux 2.1 might send the calling process the signal too. + */ + signal(SIGTERM, SIG_IGN); + signal(SIGSTOP, SIG_IGN); + signal(SIGKILL, SIG_IGN); + + /* lock us into memory */ + mlockall(MCL_CURRENT | MCL_FUTURE); + + /* Now stop all processes. */ + kill(-1, SIGSTOP); + sent_sigstop = 1; + + /* Read /proc filesystem */ + if (readproc(NO_STAT) < 0) { + kill(-1, SIGCONT); + return(1); + } + + /* Now kill all processes except init (pid 1) and our session. */ + sid = (int)getsid(0); + pid = (int)getpid(); + for (p = plist; p; p = p->next) { + if (p->pid == 1 || p->pid == pid || p->sid == sid || p->kernel) + continue; + + if (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 (optr) + continue; + } + + kill(p->pid, sig); + retval = 0; + } + + /* And let them continue. */ + kill(-1, SIGCONT); + + /* Done. */ + closelog(); + + /* Force the kernel to run the scheduler */ + usleep(1); + + return retval; +} diff --git a/src/last.c b/src/last.c new file mode 100644 index 00000000..5003c7c9 --- /dev/null +++ b/src/last.c @@ -0,0 +1,928 @@ +/* + * last.c Re-implementation of the 'last' command, this time + * for Linux. Yes I know there is BSD last, but I + * just felt like writing this. No thanks :-). + * Also, this version gives lots more info (especially with -x) + * + * Author: Miquel van Smoorenburg, miquels@cistron.nl + * + * Version: @(#)last 2.85 30-Jul-2004 miquels@cistron.nl + * + * This file is part of the sysvinit suite, + * 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 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "oldutmp.h" + +#ifndef SHUTDOWN_TIME +# define SHUTDOWN_TIME 254 +#endif + +char *Version = "@(#) last 2.85 31-Apr-2004 miquels"; + +#define CHOP_DOMAIN 0 /* Define to chop off local domainname. */ +#define NEW_UTMP 1 /* Fancy & fast utmp read code. */ +#define UCHUNKSIZE 16384 /* How much we read at once. */ + +/* Double linked list of struct utmp's */ +struct utmplist { + struct utmp ut; + struct utmplist *next; + struct utmplist *prev; +}; +struct utmplist *utmplist = NULL; + +/* Types of listing */ +#define R_CRASH 1 /* No logout record, system boot in between */ +#define R_DOWN 2 /* System brought down in decent way */ +#define R_NORMAL 3 /* Normal */ +#define R_NOW 4 /* Still logged in */ +#define R_REBOOT 5 /* Reboot record. */ +#define R_PHANTOM 6 /* No logout record but session is stale. */ +#define R_TIMECHANGE 7 /* NEW_TIME or OLD_TIME */ + +/* Global variables */ +int maxrecs = 0; /* Maximum number of records to list. */ +int recsdone = 0; /* Number of records listed */ +int showhost = 1; /* Show hostname too? */ +int altlist = 0; /* Show hostname at the end. */ +int usedns = 0; /* Use DNS to lookup the hostname. */ +int useip = 0; /* Print IP address in number format */ +int fulltime = 0; /* Print full dates and times */ +int 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 */ +time_t lastdate; /* Last date we've seen */ +char *progname; /* Name of this program */ +#if CHOP_DOMAIN +char hostname[256]; /* For gethostbyname() */ +char *domainname; /* Our domainname. */ +#endif + +/* + * Convert old utmp format to new. + */ +void uconv(struct oldutmp *oldut, struct utmp *utn) +{ + memset(utn, 0, sizeof(struct utmp)); + utn->ut_type = oldut->ut_type; + utn->ut_pid = oldut->ut_pid; + utn->ut_time = oldut->ut_oldtime; + utn->ut_addr = oldut->ut_oldaddr; + strncpy(utn->ut_line, oldut->ut_line, OLD_LINESIZE); + strncpy(utn->ut_user, oldut->ut_user, OLD_NAMESIZE); + strncpy(utn->ut_host, oldut->ut_host, OLD_HOSTSIZE); +} + +#if NEW_UTMP +/* + * Read one utmp entry, return in new format. + * Automatically reposition file pointer. + */ +int uread(FILE *fp, struct utmp *u, int *quit) +{ + static int utsize; + static char buf[UCHUNKSIZE]; + char tmp[1024]; + static off_t fpos; + static int bpos; + struct oldutmp uto; + int r; + off_t o; + + if (quit == NULL && u != NULL) { + /* + * Normal read. + */ + if (oldfmt) { + r = fread(&uto, sizeof(uto), 1, fp); + uconv(&uto, u); + } else + r = fread(u, sizeof(struct utmp), 1, fp); + return r; + } + + if (u == NULL) { + /* + * Initialize and position. + */ + utsize = oldfmt ? sizeof(uto) : sizeof(struct utmp); + fseeko(fp, 0, SEEK_END); + fpos = ftello(fp); + if (fpos == 0) + return 0; + o = ((fpos - 1) / UCHUNKSIZE) * UCHUNKSIZE; + if (fseeko(fp, o, SEEK_SET) < 0) { + fprintf(stderr, "%s: seek failed!\n", progname); + return 0; + } + bpos = (int)(fpos - o); + if (fread(buf, bpos, 1, fp) != 1) { + fprintf(stderr, "%s: read failed!\n", progname); + return 0; + } + fpos = o; + return 1; + } + + /* + * Read one struct. From the buffer if possible. + */ + bpos -= utsize; + if (bpos >= 0) { + if (oldfmt) + uconv((struct oldutmp *)(buf + bpos), u); + else + memcpy(u, buf + bpos, sizeof(struct utmp)); + return 1; + } + + /* + * Oops we went "below" the buffer. We should be able to + * seek back UCHUNKSIZE bytes. + */ + fpos -= UCHUNKSIZE; + if (fpos < 0) + return 0; + + /* + * Copy whatever is left in the buffer. + */ + memcpy(tmp + (-bpos), buf, utsize + bpos); + if (fseeko(fp, fpos, SEEK_SET) < 0) { + perror("fseek"); + return 0; + } + + /* + * Read another UCHUNKSIZE bytes. + */ + if (fread(buf, UCHUNKSIZE, 1, fp) != 1) { + perror("fread"); + return 0; + } + + /* + * The end of the UCHUNKSIZE byte buffer should be the first + * few bytes of the current struct utmp. + */ + memcpy(tmp, buf + UCHUNKSIZE + bpos, -bpos); + bpos += UCHUNKSIZE; + + if (oldfmt) + uconv((struct oldutmp *)tmp, u); + else + memcpy(u, tmp, sizeof(struct utmp)); + + return 1; +} + +#else /* NEW_UTMP */ + +/* + * Read one utmp entry, return in new format. + * Automatically reposition file pointer. + */ +int uread(FILE *fp, struct utmp *u, int *quit) +{ + struct oldutmp uto; + off_t r; + + if (u == NULL) { + r = oldfmt ? sizeof(struct oldutmp) : sizeof(struct utmp); + fseek(fp, -1 * r, SEEK_END); + return 1; + } + + if (!oldfmt) { + r = fread(u, sizeof(struct utmp), 1, fp); + if (r == 1) { + if (fseeko(fp, -2 * sizeof(struct utmp), SEEK_CUR) < 0) + if (quit) *quit = 1; + } + return r; + } + r = fread(&uto, sizeof(struct oldutmp), 1, fp); + if (r == 1) { + if (fseeko(fp, -2 * sizeof(struct oldutmp), SEEK_CUR) < 0) + if (quit) *quit = 1; + uconv(&uto, u); + } + + return r; +} +#endif + +/* + * Try to be smart about the location of the BTMP file + */ +#ifndef BTMP_FILE +#define BTMP_FILE getbtmp() +char *getbtmp() +{ + static char btmp[128]; + char *p; + + strcpy(btmp, WTMP_FILE); + if ((p = strrchr(btmp, '/')) == NULL) + p = btmp; + else + p++; + *p = 0; + strcat(btmp, "btmp"); + return btmp; +} +#endif + +/* + * Print a short date. + */ +char *showdate() +{ + char *s = ctime(&lastdate); + s[16] = 0; + return s; +} + +/* + * SIGINT handler + */ +void int_handler() +{ + printf("Interrupted %s\n", showdate()); + exit(1); +} + +/* + * SIGQUIT handler + */ +void quit_handler() +{ + printf("Interrupted %s\n", showdate()); + signal(SIGQUIT, quit_handler); +} + +/* + * Get the basename of a filename + */ +char *mybasename(char *s) +{ + char *p; + + if ((p = strrchr(s, '/')) != NULL) + p++; + else + p = s; + return p; +} + +/* + * Lookup a host with DNS. + */ +int dns_lookup(char *result, int size, int useip, int32_t *a) +{ + struct sockaddr_in sin; + struct sockaddr_in6 sin6; + struct sockaddr *sa; + int salen, flags; + unsigned int topnibble; + unsigned int azero = 0, sitelocal = 0; + int mapped = 0; + + flags = useip ? NI_NUMERICHOST : 0; + + /* + * IPv4 or IPv6 ? We use 2 heuristics: + * 1. Current IPv6 range uses 2000-3fff or fec0-feff. + * Outside of that is illegal and must be IPv4. + * 2. If last 3 bytes are 0, must be IPv4 + * 3. If IPv6 in IPv4, handle as IPv4 + * + * Ugly. + */ + if (a[0] == 0 && a[1] == 0 && a[2] == (int32_t)htonl (0xffff)) + mapped = 1; + topnibble = ntohl((unsigned int)a[0]) >> 28; + + azero = ntohl((unsigned int)a[0]) >> 16; + sitelocal = (azero >= 0xfec0 && azero <= 0xfeff) ? 1 : 0; + + if (((topnibble < 2 || topnibble > 3) && (!sitelocal)) || mapped || + (a[1] == 0 && a[2] == 0 && a[3] == 0)) { + /* IPv4 */ + sin.sin_family = AF_INET; + sin.sin_port = 0; + sin.sin_addr.s_addr = mapped ? a[3] : a[0]; + sa = (struct sockaddr *)&sin; + salen = sizeof(sin); + } else { + /* IPv6 */ + memset(&sin6, 0, sizeof(sin6)); + sin6.sin6_family = AF_INET6; + sin6.sin6_port = 0; + memcpy(sin6.sin6_addr.s6_addr, a, 16); + sa = (struct sockaddr *)&sin6; + salen = sizeof(sin6); + } + + return getnameinfo(sa, salen, result, size, NULL, 0, flags); +} + +/* + * Show one line of information on screen + */ +int list(struct utmp *p, time_t t, int what) +{ + time_t secs, tmp; + char logintime[32]; + char logouttime[32]; + char length[32]; + char final[512]; + char utline[UT_LINESIZE+1]; + char domain[256]; + char *s, **walk; + int mins, hours, days; + int r, len; + + /* + * uucp and ftp have special-type entries + */ + utline[0] = 0; + strncat(utline, p->ut_line, UT_LINESIZE); + if (strncmp(utline, "ftp", 3) == 0 && isdigit(utline[3])) + utline[3] = 0; + if (strncmp(utline, "uucp", 4) == 0 && isdigit(utline[4])) + utline[4] = 0; + + /* + * Is this something we wanna show? + */ + if (show) { + for (walk = show; *walk; walk++) { + if (strncmp(p->ut_name, *walk, UT_NAMESIZE) == 0 || + strcmp(utline, *walk) == 0 || + (strncmp(utline, "tty", 3) == 0 && + strcmp(utline + 3, *walk) == 0)) break; + } + if (*walk == NULL) return 0; + } + + /* + * Calculate times + */ + tmp = (time_t)p->ut_time; + strcpy(logintime, ctime(&tmp)); + if (fulltime) + sprintf(logouttime, "- %s", ctime(&t)); + else { + logintime[16] = 0; + sprintf(logouttime, "- %s", ctime(&t) + 11); + logouttime[7] = 0; + } + secs = t - p->ut_time; + mins = (secs / 60) % 60; + hours = (secs / 3600) % 24; + days = secs / 86400; + if (days) + sprintf(length, "(%d+%02d:%02d)", days, hours, mins); + else + sprintf(length, " (%02d:%02d)", hours, mins); + + switch(what) { + case R_CRASH: + sprintf(logouttime, "- crash"); + break; + case R_DOWN: + sprintf(logouttime, "- down "); + break; + case R_NOW: + length[0] = 0; + if (fulltime) + sprintf(logouttime, " still logged in"); + else { + sprintf(logouttime, " still"); + sprintf(length, "logged in"); + } + break; + case R_PHANTOM: + length[0] = 0; + if (fulltime) + sprintf(logouttime, " gone - no logout"); + else { + sprintf(logouttime, " gone"); + sprintf(length, "- no logout"); + } + break; + case R_REBOOT: + break; + case R_TIMECHANGE: + logouttime[0] = 0; + length[0] = 0; + break; + case R_NORMAL: + break; + } + + /* + * Look up host with DNS if needed. + */ + r = -1; + if (usedns || useip) + r = dns_lookup(domain, sizeof(domain), useip, p->ut_addr_v6); + if (r < 0) { + len = UT_HOSTSIZE; + if (len >= (int)sizeof(domain)) len = sizeof(domain) - 1; + domain[0] = 0; + strncat(domain, p->ut_host, len); + } + + if (showhost) { +#if CHOP_DOMAIN + /* + * See if this is in our domain. + */ + if (!usedns && (s = strchr(p->ut_host, '.')) != NULL && + strcmp(s + 1, domainname) == 0) *s = 0; +#endif + if (!altlist) { + len = snprintf(final, sizeof(final), + fulltime ? + "%-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 { + len = snprintf(final, sizeof(final), + fulltime ? + "%-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 + len = snprintf(final, sizeof(final), + fulltime ? + "%-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. + */ + for (s = final; *s; s++) { + if (*s == '\n' || (*s >= 32 && (unsigned char)*s <= 126)) + putchar(*s); + else + putchar('*'); + } + + if (len < 0 || (size_t)len >= sizeof(final)) + putchar('\n'); + + recsdone++; + if (maxrecs && recsdone >= maxrecs) + return 1; + + return 0; +} + + +/* + * show usage + */ +void usage(char *s) +{ + fprintf(stderr, "Usage: %s [-num | -n num] [-f file] " + "[-t YYYYMMDDHHMMSS] " + "[-R] [-adioxFw] [username..] [tty..]\n", s); + exit(1); +} + +time_t parsetm(char *ts) +{ + struct tm u, origu; + time_t tm; + + memset(&tm, 0, sizeof(tm)); + + if (sscanf(ts, "%4d%2d%2d%2d%2d%2d", &u.tm_year, + &u.tm_mon, &u.tm_mday, &u.tm_hour, &u.tm_min, + &u.tm_sec) != 6) + return (time_t)-1; + + u.tm_year -= 1900; + u.tm_mon -= 1; + u.tm_isdst = -1; + + origu = u; + + if ((tm = mktime(&u)) == (time_t)-1) + return tm; + + /* + * Unfortunately mktime() is much more forgiving than + * it should be. For example, it'll gladly accept + * "30" as a valid month number. This behavior is by + * design, but we don't like it, so we want to detect + * it and complain. + */ + if (u.tm_year != origu.tm_year || + u.tm_mon != origu.tm_mon || + u.tm_mday != origu.tm_mday || + u.tm_hour != origu.tm_hour || + u.tm_min != origu.tm_min || + u.tm_sec != origu.tm_sec) + return (time_t)-1; + + return tm; +} + +int main(int argc, char **argv) +{ + FILE *fp; /* Filepointer of wtmp file */ + + struct utmp ut; /* Current utmp entry */ + struct utmp oldut; /* Old utmp entry to check for duplicates */ + struct utmplist *p; /* Pointer into utmplist */ + struct utmplist *next;/* Pointer into utmplist */ + + time_t lastboot = 0; /* Last boottime */ + time_t lastrch = 0; /* Last run level change */ + time_t lastdown; /* Last downtime */ + time_t begintime; /* When wtmp begins */ + int whydown = 0; /* Why we went down: crash or shutdown */ + + int c, x; /* Scratch */ + struct stat st; /* To stat the [uw]tmp file */ + int quit = 0; /* Flag */ + int down = 0; /* Down flag */ + int lastb = 0; /* Is this 'lastb' ? */ + int extended = 0; /* Lots of info. */ + char *altufile = NULL;/* Alternate wtmp */ + + time_t until = 0; /* at what time to stop parsing the file */ + + progname = mybasename(argv[0]); + + /* Process the arguments. */ + while((c = getopt(argc, argv, "f:n:RxadFiot:0123456789w")) != EOF) + switch(c) { + case 'R': + showhost = 0; + break; + case 'x': + extended = 1; + break; + case 'n': + maxrecs = atoi(optarg); + break; + case 'o': + oldfmt = 1; + break; + case 'f': + if((altufile = malloc(strlen(optarg)+1)) == NULL) { + fprintf(stderr, "%s: out of memory\n", + progname); + exit(1); + } + strcpy(altufile, optarg); + break; + case 'd': + usedns++; + break; + case 'i': + useip++; + break; + case 'a': + altlist++; + break; + case 'F': + fulltime++; + break; + case 't': + if ((until = parsetm(optarg)) == (time_t)-1) { + fprintf(stderr, "%s: Invalid time value \"%s\"\n", + progname, optarg); + 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'; + break; + default: + usage(progname); + break; + } + if (optind < argc) show = argv + optind; + + /* + * Which file do we want to read? + */ + if (strcmp(progname, "lastb") == 0) { + ufile = BTMP_FILE; + lastb = 1; + } else + ufile = WTMP_FILE; + if (altufile) + ufile = altufile; + time(&lastdown); + lastrch = lastdown; + + /* + * Fill in 'lastdate' + */ + lastdate = lastdown; + +#if CHOP_DOMAIN + /* + * Find out domainname. + * + * This doesn't work on modern systems, where only a DNS + * lookup of the result from hostname() will get you the domainname. + * Remember that domainname() is the NIS domainname, not DNS. + * So basically this whole piece of code is bullshit. + */ + hostname[0] = 0; + (void) gethostname(hostname, sizeof(hostname)); + if ((domainname = strchr(hostname, '.')) != NULL) domainname++; + if (domainname == NULL || domainname[0] == 0) { + hostname[0] = 0; + (void) getdomainname(hostname, sizeof(hostname)); + hostname[sizeof(hostname) - 1] = 0; + domainname = hostname; + if (strcmp(domainname, "(none)") == 0 || domainname[0] == 0) + domainname = NULL; + } +#endif + + /* + * Install signal handlers + */ + signal(SIGINT, int_handler); + signal(SIGQUIT, quit_handler); + + /* + * Open the utmp file + */ + if ((fp = fopen(ufile, "r")) == NULL) { + x = errno; + fprintf(stderr, "%s: %s: %s\n", progname, ufile, strerror(errno)); + if (altufile == NULL && x == ENOENT) + fprintf(stderr, "Perhaps this file was removed by the " + "operator to prevent logging %s info.\n", progname); + exit(1); + } + + /* + * Optimize the buffer size. + */ + setvbuf(fp, NULL, _IOFBF, UCHUNKSIZE); + + /* + * Read first structure to capture the time field + */ + if (uread(fp, &ut, NULL) == 1) + begintime = ut.ut_time; + else { + fstat(fileno(fp), &st); + begintime = st.st_ctime; + quit = 1; + } + + /* + * Go to end of file minus one structure + * and/or initialize utmp reading code. + */ + uread(fp, NULL, NULL); + + /* + * Read struct after struct backwards from the file. + */ + while(!quit) { + + if (uread(fp, &ut, &quit) != 1) + break; + + if (until && until < ut.ut_time) + continue; + + if (memcmp(&ut, &oldut, sizeof(struct utmp)) == 0) continue; + memcpy(&oldut, &ut, sizeof(struct utmp)); + lastdate = ut.ut_time; + + if (lastb) { + quit = list(&ut, ut.ut_time, R_NORMAL); + continue; + } + + /* + * Set ut_type to the correct type. + */ + if (strncmp(ut.ut_line, "~", 1) == 0) { + if (strncmp(ut.ut_user, "shutdown", 8) == 0) + ut.ut_type = SHUTDOWN_TIME; + else if (strncmp(ut.ut_user, "reboot", 6) == 0) + ut.ut_type = BOOT_TIME; + else if (strncmp(ut.ut_user, "runlevel", 8) == 0) + ut.ut_type = RUN_LVL; + } +#if 1 /*def COMPAT*/ + /* + * For stupid old applications that don't fill in + * ut_type correctly. + */ + else { + if (ut.ut_type != DEAD_PROCESS && + ut.ut_name[0] && ut.ut_line[0] && + strcmp(ut.ut_name, "LOGIN") != 0) + ut.ut_type = USER_PROCESS; + /* + * Even worse, applications that write ghost + * entries: ut_type set to USER_PROCESS but + * empty ut_name... + */ + if (ut.ut_name[0] == 0) + ut.ut_type = DEAD_PROCESS; + + /* + * Clock changes. + */ + if (strcmp(ut.ut_name, "date") == 0) { + if (ut.ut_line[0] == '|') ut.ut_type = OLD_TIME; + if (ut.ut_line[0] == '{') ut.ut_type = NEW_TIME; + } + } +#endif + + switch (ut.ut_type) { + case SHUTDOWN_TIME: + if (extended) { + strcpy(ut.ut_line, "system down"); + quit = list(&ut, lastboot, R_NORMAL); + } + lastdown = lastrch = ut.ut_time; + down = 1; + break; + case OLD_TIME: + case NEW_TIME: + if (extended) { + strcpy(ut.ut_line, + ut.ut_type == NEW_TIME ? "new time" : + "old time"); + quit = list(&ut, lastdown, R_TIMECHANGE); + } + break; + case BOOT_TIME: + strcpy(ut.ut_line, "system boot"); + quit = list(&ut, lastdown, R_REBOOT); + lastboot = ut.ut_time; + down = 1; + break; + case RUN_LVL: + x = ut.ut_pid & 255; + if (extended) { + sprintf(ut.ut_line, "(to lvl %c)", x); + quit = list(&ut, lastrch, R_NORMAL); + } + if (x == '0' || x == '6') { + lastdown = ut.ut_time; + down = 1; + ut.ut_type = SHUTDOWN_TIME; + } + lastrch = ut.ut_time; + break; + + case USER_PROCESS: + /* + * This was a login - show the first matching + * logout record and delete all records with + * the same ut_line. + */ + c = 0; + for (p = utmplist; p; p = next) { + next = p->next; + if (strncmp(p->ut.ut_line, ut.ut_line, + UT_LINESIZE) == 0) { + /* Show it */ + if (c == 0) { + quit = list(&ut, p->ut.ut_time, + R_NORMAL); + c = 1; + } + if (p->next) p->next->prev = p->prev; + if (p->prev) + p->prev->next = p->next; + else + utmplist = p->next; + free(p); + } + } + /* + * Not found? Then crashed, down, still + * logged in, or missing logout record. + */ + if (c == 0) { + if (lastboot == 0) { + c = R_NOW; + /* Is process still alive? */ + if (ut.ut_pid > 0 && + kill(ut.ut_pid, 0) != 0 && + errno == ESRCH) + c = R_PHANTOM; + } else + c = whydown; + quit = list(&ut, lastboot, c); + } + /* FALLTHRU */ + + case DEAD_PROCESS: + /* + * Just store the data if it is + * interesting enough. + */ + if (ut.ut_line[0] == 0) + break; + if ((p = malloc(sizeof(struct utmplist))) == NULL) { + fprintf(stderr, "%s: out of memory\n", + progname); + exit(1); + } + memcpy(&p->ut, &ut, sizeof(struct utmp)); + p->next = utmplist; + p->prev = NULL; + if (utmplist) utmplist->prev = p; + utmplist = p; + break; + + } + /* + * If we saw a shutdown/reboot record we can remove + * the entire current utmplist. + */ + if (down) { + lastboot = ut.ut_time; + whydown = (ut.ut_type == SHUTDOWN_TIME) ? R_DOWN : R_CRASH; + for (p = utmplist; p; p = next) { + next = p->next; + free(p); + } + utmplist = NULL; + down = 0; + } + } + printf("\n%s begins %s", mybasename(ufile), ctime(&begintime)); + + fclose(fp); + + /* + * Should we free memory here? Nah. This is not NT :) + */ + return 0; +} diff --git a/src/mesg.c b/src/mesg.c new file mode 100644 index 00000000..5bd6c0bf --- /dev/null +++ b/src/mesg.c @@ -0,0 +1,124 @@ +/* + * mesg.c The "mesg" utility. Gives / restrict access to + * your terminal by others. + * + * Usage: mesg [y|n]. + * Without arguments prints out the current settings. + * + * This file is part of the sysvinit suite, + * 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 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 +#include +#include +#include +#include +#include +#include +#include + +char *Version = "@(#) mesg 2.81 31-Jul-2001 miquels@cistron.nl"; + +#define TTYGRP "tty" + +/* + * See if the system has a special 'tty' group. + * If it does, and the tty device is in that group, + * we set the modes to -rw--w--- instead if -rw--w--w. + */ +int hasttygrp(void) +{ + struct group *grp; + + if ((grp = getgrnam(TTYGRP)) != NULL) + return 1; + return 0; +} + + +/* + * See if the tty devices group is indeed 'tty' + */ +int tty_in_ttygrp(struct stat *st) +{ + struct group *gr; + + if ((gr = getgrgid(st->st_gid)) == NULL) + return 0; + if (strcmp(gr->gr_name, TTYGRP) != 0) + return 0; + + return 1; +} + +int main(int argc, char **argv) +{ + struct stat st; + unsigned int ttymode, st_mode_old; + int ht; + int it; + int e; + + if (!isatty(0)) { + /* Or should we look in /var/run/utmp? */ + fprintf(stderr, "stdin: is not a tty\n"); + return(1); + } + + if (fstat(0, &st) < 0) { + perror("fstat"); + return(1); + } + + ht = hasttygrp(); + it = tty_in_ttygrp(&st); + + if (argc < 2) { + ttymode = (ht && it) ? 020 : 002; + printf("is %s\n", (st.st_mode & ttymode) ? "y" : "n"); + return 0; + } + if (argc > 2 || (argv[1][0] != 'y' && argv[1][0] != 'n')) { + fprintf(stderr, "Usage: mesg [y|n]\n"); + return 1; + } + + /* + * Security check: allow mesg n when group is + * weird, but don't allow mesg y. + */ + ttymode = ht ? 020 : 022; + if (ht && !it && argv[1][0] == 'y') { + fprintf(stderr, "mesg: error: tty device is not owned " + "by group `%s'\n", TTYGRP); + exit(1); + } + + st_mode_old = st.st_mode; + if (argv[1][0] == 'y') + st.st_mode |= ttymode; + else + st.st_mode &= ~(ttymode); + if (st_mode_old != st.st_mode && fchmod(0, st.st_mode) != 0) { + e = errno; + fprintf(stderr, "mesg: %s: %s\n", + ttyname(0), strerror(e)); + exit(1); + } + + return 0; +} diff --git a/src/mountpoint.c b/src/mountpoint.c new file mode 100644 index 00000000..aca6c04a --- /dev/null +++ b/src/mountpoint.c @@ -0,0 +1,128 @@ +/* + * mountpoint See if a directory is a mountpoint. + * + * Author: Miquel van Smoorenburg. + * + * Version: @(#)mountpoint 2.85-12 17-Mar-2004 miquels@cistron.nl + * + * This file is part of the sysvinit suite, + * 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 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 +#include +#include +#include +#include +#include +#include +#include + +int dostat(char *path, struct stat *st, int do_lstat, int quiet) +{ + int n; + + if (do_lstat) + n = lstat(path, st); + else + n = stat(path, st); + + if (n != 0) { + if (!quiet) + fprintf(stderr, "mountpoint: %s: %s\n", path, + strerror(errno)); + return -1; + } + return 0; +} + +void usage(void) { + fprintf(stderr, "Usage: mountpoint [-q] [-d] [-x] path\n"); + exit(1); +} + +int main(int argc, char **argv) +{ + struct stat st, st2; + char buf[256]; + char *path; + int quiet = 0; + int showdev = 0; + int xdev = 0; + int c, r; + + while ((c = getopt(argc, argv, "dqx")) != EOF) switch(c) { + case 'd': + showdev = 1; + break; + case 'q': + quiet = 1; + break; + case 'x': + xdev = 1; + break; + default: + usage(); + break; + } + if (optind != argc - 1) usage(); + path = argv[optind]; + + if (dostat(path, &st, !xdev, quiet) < 0) + return 1; + + if (xdev) { +#ifdef __linux__ + if (!S_ISBLK(st.st_mode)) +#else + if (!S_ISBLK(st.st_mode) && !S_ISCHR(st.st_mode)) +#endif + { + if (quiet) + printf("\n"); + else + fprintf(stderr, "mountpoint: %s: not a block device\n", + path); + return 1; + } + printf("%u:%u\n", major(st.st_rdev), minor(st.st_rdev)); + return 0; + } + + if (!S_ISDIR(st.st_mode)) { + if (!quiet) + fprintf(stderr, "mountpoint: %s: not a directory\n", + path); + return 1; + } + + memset(buf, 0, sizeof(buf)); + strncpy(buf, path, sizeof(buf) - 4); + strcat(buf, "/.."); + if (dostat(buf, &st2, 0, quiet) < 0) + return 1; + + r = (st.st_dev != st2.st_dev) || + (st.st_dev == st2.st_dev && st.st_ino == st2.st_ino); + + if (!quiet && !showdev) + printf("%s is %sa mountpoint\n", path, r ? "" : "not "); + if (showdev) + printf("%u:%u\n", major(st.st_dev), minor(st.st_dev)); + + return r ? 0 : 1; +} diff --git a/src/oldutmp.h b/src/oldutmp.h new file mode 100644 index 00000000..b94029c7 --- /dev/null +++ b/src/oldutmp.h @@ -0,0 +1,41 @@ +/* + * oldutmp.h Definition of the old libc5 utmp structure. + * + * Version: @(#)oldutmp.h 1.00 29-Mar-1998 miquels@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 + +#define OLD_LINESIZE 12 +#define OLD_NAMESIZE 8 +#define OLD_HOSTSIZE 16 + +struct oldutmp { + short ut_type; + int ut_pid; + char ut_line[OLD_LINESIZE]; + char ut_id[4]; + long ut_oldtime; + char ut_user[OLD_NAMESIZE]; + char ut_host[OLD_HOSTSIZE]; + long ut_oldaddr; +}; + +#endif diff --git a/src/paths.h b/src/paths.h new file mode 100644 index 00000000..232a9441 --- /dev/null +++ b/src/paths.h @@ -0,0 +1,50 @@ +/* + * paths.h Paths of files that init and related utilities need. + * + * Version: @(#) paths.h 2.85-8 05-Nov-2003 + * + * Author: Miquel van Smoorenburg, + * + * This file is part of the sysvinit suite, + * 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 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 */ +#define SECURETTY "/etc/securetty" /* List of root terminals */ +#define SDALLOW "/etc/shutdown.allow" /* Users allowed to shutdown */ +#define INITTAB "/etc/inittab" /* Location of inittab */ +#define INIT "/sbin/init" /* Location of init itself. */ +#define NOLOGIN "/etc/nologin" /* Stop user logging in. */ +#define FASTBOOT "/fastboot" /* Enable fast boot. */ +#define FORCEFSCK "/forcefsck" /* Force fsck on boot */ +#define SDPID "/var/run/shutdown.pid" /* PID of shutdown program */ +#define SHELL "/bin/sh" /* Default shell */ +#define SULOGIN "/sbin/sulogin" /* Sulogin */ +#define INITSCRIPT "/etc/initscript" /* Initscript. */ +#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 */ +#define INITLVL2 "/var/log/initrunlvl" /* COMPAT: New runlevel */ + /* Note: INITLVL2 definition needs INITLVL */ +#define HALTSCRIPT1 "/etc/init.d/halt" /* Called by "fast" shutdown */ +#define HALTSCRIPT2 "/etc/rc.d/rc.0" /* Called by "fast" shutdown */ +#define REBOOTSCRIPT1 "/etc/init.d/reboot" /* Ditto. */ +#define REBOOTSCRIPT2 "/etc/rc.d/rc.6" /* Ditto. */ +#endif + diff --git a/src/reboot.h b/src/reboot.h new file mode 100644 index 00000000..c7807ca7 --- /dev/null +++ b/src/reboot.h @@ -0,0 +1,51 @@ +/* + * reboot.h Headerfile that defines how to handle + * the reboot() system call. + * + * Version: @(#)reboot.h 2.85-17 04-Jun-2004 miquels@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 + +#ifdef RB_ENABLE_CAD +# define BMAGIC_HARD RB_ENABLE_CAD +#endif + +#ifdef RB_DISABLE_CAD +# define BMAGIC_SOFT RB_DISABLE_CAD +#endif + +#ifdef RB_HALT_SYSTEM +# define BMAGIC_HALT RB_HALT_SYSTEM +#else +# define BMAGIC_HALT RB_HALT +#endif + +#define BMAGIC_REBOOT RB_AUTOBOOT + +#ifdef RB_POWER_OFF +# define BMAGIC_POWEROFF RB_POWER_OFF +#elif defined(RB_POWEROFF) +# define BMAGIC_POWEROFF RB_POWEROFF +#else +# define BMAGIC_POWEROFF BMAGIC_HALT +#endif + +#define init_reboot(magic) reboot(magic) + diff --git a/src/runlevel.c b/src/runlevel.c new file mode 100644 index 00000000..65e4b31a --- /dev/null +++ b/src/runlevel.c @@ -0,0 +1,53 @@ +/* + * runlevel Prints out the previous and the current runlevel. + * + * Version: @(#)runlevel 1.20 16-Apr-1997 MvS + * + * This file is part of the sysvinit suite, + * 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 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 +#include +#include +#include + +int main(argc, argv) +int argc; +char **argv; +{ + struct utmp *ut; + char prev; + + if (argc > 1) utmpname(argv[1]); + + setutent(); + while ((ut = getutent()) != NULL) { + if (ut->ut_type == RUN_LVL) { + prev = ut->ut_pid / 256; + if (prev == 0) prev = 'N'; + printf("%c %c\n", prev, ut->ut_pid % 256); + endutent(); + exit(0); + } + } + + printf("unknown\n"); + endutent(); + return(1); +} + diff --git a/src/set.h b/src/set.h new file mode 100644 index 00000000..724c35fc --- /dev/null +++ b/src/set.h @@ -0,0 +1,28 @@ +/* + * 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))) +#define EMPTYSET(set) ((set) = 0) + diff --git a/src/shutdown.c b/src/shutdown.c new file mode 100644 index 00000000..7e997da8 --- /dev/null +++ b/src/shutdown.c @@ -0,0 +1,762 @@ +/* + * shutdown.c Shut the system down. + * + * Usage: shutdown [-krhfnc] time [warning message] + * -k: don't really shutdown, only warn. + * -r: reboot after shutdown. + * -h: halt after shutdown. + * -f: do a 'fast' reboot (skip fsck). + * -F: Force fsck on reboot. + * -n: do not go through init but do it ourselves. + * -c: cancel an already running shutdown. + * -t secs: delay between SIGTERM and SIGKILL for init. + * + * Author: Miquel van Smoorenburg, miquels@cistron.nl + * + * Version: @(#)shutdown 2.86-1 31-Jul-2004 miquels@cistron.nl + * + * This file is part of the sysvinit suite, + * 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 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "paths.h" +#include "reboot.h" +#include "initreq.h" +#include "init.h" + + +char *Version = "@(#) shutdown 2.86-1 31-Jul-2004 miquels@cistron.nl"; + +#define MESSAGELEN 256 + +int dontshut = 0; /* Don't shutdown, only warn */ +char down_level[2]; /* What runlevel to go to. */ +int dosync = 1; /* Sync before reboot or halt */ +int fastboot = 0; /* Do a 'fast' reboot */ +int forcefsck = 0; /* Force fsck on reboot */ +char message[MESSAGELEN]; /* Warning message */ +char *sltime = 0; /* Sleep time */ +char newstate[64]; /* What are we gonna do */ +int doself = 0; /* Don't use init */ +int got_alrm = 0; + +char *clean_env[] = { + "HOME=/", + "PATH=/bin:/usr/bin:/sbin:/usr/sbin", + "TERM=dumb", + "SHELL=/bin/sh", + NULL, +}; + +/* From "utmp.c" */ +extern void write_wtmp(char *user, char *id, int pid, int type, char *line); + +/* + * Sleep without being interrupted. + */ +void hardsleep(int secs) +{ + struct timespec ts, rem; + + ts.tv_sec = secs; + ts.tv_nsec = 0; + + while(nanosleep(&ts, &rem) < 0 && errno == EINTR) + ts = rem; +} + +/* + * Break off an already running shutdown. + */ +# ifdef __GNUC__ +void stopit(int sig __attribute__((unused))) +# else +void stopit(int sig) +# endif + +{ + unlink(NOLOGIN); + unlink(FASTBOOT); + unlink(FORCEFSCK); + unlink(SDPID); + printf("\r\nShutdown cancelled.\r\n"); + exit(0); +} + +/* + * Show usage message. + */ +void usage(void) +{ + fprintf(stderr, + "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" + "\t\t -h: halt after shutdown.\n" + "\t\t -P: halt action is to turn off power.\n" + "\t\t -H: halt action is to just halt.\n" + "\t\t -f: do a 'fast' reboot (skip fsck).\n" + "\t\t -F: Force fsck on reboot.\n" + "\t\t -n: do not go through \"init\" but go down real fast.\n" + "\t\t -c: cancel a running shutdown.\n" + "\t\t -t secs: delay between warning and kill signal.\n" + "\t\t ** the \"time\" argument is mandatory! (try \"now\") **\n"); + exit(1); +} + + +void alrm_handler(int sig) +{ + got_alrm = sig; +} + + +/* + * Set environment variables in the init process. + */ +int init_setenv(char *name, char *value) +{ + struct init_request request; + struct sigaction sa; + int fd; + int nl, vl; + + memset(&request, 0, sizeof(request)); + request.magic = INIT_MAGIC; + request.cmd = INIT_CMD_SETENV; + nl = strlen(name); + vl = value ? strlen(value) : 0; + + if (nl + vl + 3 >= (int)sizeof(request.i.data)) + return -1; + + memcpy(request.i.data, name, nl); + if (value) { + request.i.data[nl] = '='; + memcpy(request.i.data + nl + 1, value, vl); + } + + /* + * Open the fifo and write the command. + * Make sure we don't hang on opening /dev/initctl + */ + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = alrm_handler; + sigaction(SIGALRM, &sa, NULL); + got_alrm = 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; +} + + +/* + * Tell everyone the system is going down in 'mins' minutes. + */ +void warn(int mins) +{ + char buf[MESSAGELEN + sizeof(newstate)]; + int len; + + buf[0] = 0; + strncat(buf, message, sizeof(buf) - 1); + len = strlen(buf); + + if (mins == 0) + snprintf(buf + len, sizeof(buf) - len, + "\rThe system is going down %s NOW!\r\n", + newstate); + else + 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, 0); +} + +/* + * Create the /etc/nologin file. + */ +void donologin(int min) +{ + FILE *fp; + time_t t; + + time(&t); + t += 60 * min; + + if ((fp = fopen(NOLOGIN, "w")) != NULL) { + fprintf(fp, "\rThe system is going down on %s\r\n", ctime(&t)); + if (message[0]) fputs(message, fp); + fclose(fp); + } +} + +/* + * Spawn an external program. + */ +int spawn(int noerr, char *prog, ...) +{ + va_list ap; + pid_t pid, rc; + int i; + char *argv[8]; + + i = 0; + while ((pid = fork()) < 0 && i < 10) { + perror("fork"); + sleep(5); + i++; + } + + if (pid < 0) return -1; + + if (pid > 0) { + while((rc = wait(&i)) != pid) + if (rc < 0 && errno == ECHILD) + break; + return (rc == pid) ? WEXITSTATUS(i) : -1; + } + + if (noerr) fclose(stderr); + + argv[0] = prog; + va_start(ap, prog); + for (i = 1; i < 7 && (argv[i] = va_arg(ap, char *)) != NULL; i++) + ; + argv[i] = NULL; + va_end(ap); + + chdir("/"); + environ = clean_env; + + execvp(argv[0], argv); + perror(argv[0]); + exit(1); + + /*NOTREACHED*/ + return 0; +} + +/* + * Kill all processes, call /etc/init.d/halt (if present) + */ +void fastdown() +{ + int do_halt = (down_level[0] == '0'); + int i; +#if 0 + char cmd[128]; + char *script; + + /* + * Currently, the halt script is either init.d/halt OR rc.d/rc.0, + * likewise for the reboot script. Test for the presence + * of either. + */ + if (do_halt) { + if (access(HALTSCRIPT1, X_OK) == 0) + script = HALTSCRIPT1; + else + script = HALTSCRIPT2; + } else { + if (access(REBOOTSCRIPT1, X_OK) == 0) + script = REBOOTSCRIPT1; + else + script = REBOOTSCRIPT2; + } +#endif + + /* First close all files. */ + for(i = 0; i < 3; i++) + if (!isatty(i)) { + close(i); + open("/dev/null", O_RDWR); + } + for(i = 3; i < 20; i++) close(i); + close(255); + + /* First idle init. */ + if (kill(1, SIGTSTP) < 0) { + fprintf(stderr, "shutdown: can't idle init: %s.\r\n", strerror(errno)); + exit(1); + } + + /* Kill all processes. */ + fprintf(stderr, "shutdown: sending all processes the TERM signal...\r\n"); + kill(-1, SIGTERM); + sleep(sltime ? atoi(sltime) : 3); + fprintf(stderr, "shutdown: sending all processes the KILL signal.\r\n"); + (void) kill(-1, SIGKILL); + +#if 0 + /* See if we can run /etc/init.d/halt */ + if (access(script, X_OK) == 0) { + spawn(1, cmd, "fast", NULL); + fprintf(stderr, "shutdown: %s returned - falling back " + "on default routines\r\n", script); + } +#endif + + /* script failed or not present: do it ourself. */ + sleep(1); /* Give init the chance to collect zombies. */ + + /* Record the fact that we're going down */ + 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(); + fprintf(stderr, "shutdown: turning off swap\r\n"); + spawn(0, "swapoff", "-a", NULL); + fprintf(stderr, "shutdown: unmounting all file systems\r\n"); + spawn(0, "umount", "-a", NULL); + + /* We're done, halt or reboot now. */ + if (do_halt) { + fprintf(stderr, "The system is halted. Press CTRL-ALT-DEL " + "or turn off power\r\n"); + init_reboot(BMAGIC_HALT); + exit(0); + } + + fprintf(stderr, "Please stand by while rebooting the system.\r\n"); + init_reboot(BMAGIC_REBOOT); + exit(0); +} + +/* + * Go to runlevel 0, 1 or 6. + */ +void shutdown(char *halttype) +{ + char *args[8]; + int argp = 0; + int do_halt = (down_level[0] == '0'); + + /* Warn for the last time */ + warn(0); + if (dontshut) { + hardsleep(1); + stopit(0); + } + openlog("shutdown", LOG_PID, LOG_USER); + if (do_halt) + syslog(LOG_NOTICE, "shutting down for system halt"); + else + syslog(LOG_NOTICE, "shutting down for system reboot"); + closelog(); + + /* See if we have to do it ourself. */ + if (doself) fastdown(); + + /* Create the arguments for init. */ + args[argp++] = INIT; + if (sltime) { + args[argp++] = "-t"; + args[argp++] = sltime; + } + args[argp++] = down_level; + args[argp] = (char *)NULL; + + unlink(SDPID); + unlink(NOLOGIN); + + /* Now execute init to change runlevel. */ + sync(); + init_setenv("INIT_HALT", halttype); + execv(INIT, args); + + /* Oops - failed. */ + fprintf(stderr, "\rshutdown: cannot execute %s\r\n", INIT); + unlink(FASTBOOT); + unlink(FORCEFSCK); + init_setenv("INIT_HALT", NULL); + openlog("shutdown", LOG_PID, LOG_USER); + syslog(LOG_NOTICE, "shutdown failed"); + closelog(); + exit(1); +} + +/* + * returns if a warning is to be sent for wt + */ +static int needwarning(int wt) +{ + int ret; + + if (wt < 10) + ret = 1; + else if (wt < 60) + ret = (wt % 15 == 0); + else if (wt < 180) + ret = (wt % 30 == 0); + else + ret = (wt % 60 == 0); + + return ret; +} + +/* + * Main program. + * Process the options and do the final countdown. + */ +int main(int argc, char **argv) +{ + FILE *fp; + extern int getopt(); + extern int optind; + struct sigaction sa; + struct tm *lt; + struct stat st; + struct utmp *ut; + time_t t; + uid_t realuid; + char *halttype; + char *downusers[32]; + char buf[128]; + char term[UT_LINESIZE + 6]; + char *sp; + char *when = NULL; + int c, i, wt; + int hours, mins; + int didnolog = 0; + int cancel = 0; + int useacl = 0; + int pid = 0; + int user_ok = 0; + + /* We can be installed setuid root (executable for a special group) */ + realuid = getuid(); + setuid(geteuid()); + + if (getuid() != 0) { + fprintf(stderr, "shutdown: you must be root to do that!\n"); + usage(); + exit(1); + } + strcpy(down_level, "1"); + halttype = NULL; + + /* Process the options. */ + while((c = getopt(argc, argv, "HPacqkrhnfFyt:g:i:")) != EOF) { + switch(c) { + case 'H': + halttype = "HALT"; + break; + case 'P': + halttype = "POWERDOWN"; + break; + case 'a': /* Access control. */ + useacl = 1; + break; + case 'c': /* Cancel an already running shutdown. */ + cancel = 1; + break; + case 'k': /* Don't really shutdown, only warn.*/ + dontshut = 1; + break; + case 'r': /* Automatic reboot */ + down_level[0] = '6'; + break; + case 'h': /* Halt after shutdown */ + down_level[0] = '0'; + break; + case 'f': /* Don't perform fsck after next boot */ + fastboot = 1; + break; + case 'F': /* Force fsck after next boot */ + forcefsck = 1; + break; + case 'n': /* Don't switch runlevels. */ + doself = 1; + break; + case 't': /* Delay between TERM and KILL */ + sltime = optarg; + break; + case 'y': /* Ignored for sysV compatibility */ + break; + case 'g': /* sysv style to specify time. */ + when = optarg; + break; + case 'i': /* Level to go to. */ + if (!strchr("0156aAbBcCsS", optarg[0])) { + fprintf(stderr, + "shutdown: `%s': bad runlevel\n", + optarg); + exit(1); + } + down_level[0] = optarg[0]; + break; + default: + usage(); + break; + } + } + + if (NULL != halttype && down_level[0] != '0') { + fprintf(stderr, "shutdown: -H and -P flags can only be used along with -h flag.\n"); + usage(); + exit(1); + } + + /* Do we need to use the shutdown.allow file ? */ + if (useacl && (fp = fopen(SDALLOW, "r")) != NULL) { + + /* Read /etc/shutdown.allow. */ + i = 0; + while(fgets(buf, 128, fp)) { + if (buf[0] == '#' || buf[0] == '\n') continue; + if (i > 31) continue; + for(sp = buf; *sp; sp++) if (*sp == '\n') *sp = 0; + downusers[i++] = strdup(buf); + } + if (i < 32) downusers[i] = 0; + fclose(fp); + + /* Now walk through /var/run/utmp to find logged in users. */ + while(!user_ok && (ut = getutent()) != NULL) { + + /* See if this is a user process on a VC. */ + if (ut->ut_type != USER_PROCESS) continue; + sprintf(term, "/dev/%.*s", UT_LINESIZE, ut->ut_line); + if (stat(term, &st) < 0) continue; +#ifdef major /* glibc */ + if (major(st.st_rdev) != 4 || + minor(st.st_rdev) > 63) continue; +#else + if ((st.st_rdev & 0xFFC0) != 0x0400) continue; +#endif + /* Root is always OK. */ + if (strcmp(ut->ut_user, "root") == 0) { + user_ok++; + break; + } + + /* See if this is an allowed user. */ + for(i = 0; i < 32 && downusers[i]; i++) + if (!strncmp(downusers[i], ut->ut_user, + UT_NAMESIZE)) { + user_ok++; + break; + } + } + endutent(); + + /* See if user was allowed. */ + if (!user_ok) { + if ((fp = fopen(CONSOLE, "w")) != NULL) { + fprintf(fp, "\rshutdown: no authorized users " + "logged in.\r\n"); + fclose(fp); + } + exit(1); + } + } + + /* Read pid of running shutdown from a file */ + if ((fp = fopen(SDPID, "r")) != NULL) { + fscanf(fp, "%d", &pid); + fclose(fp); + } + + /* Read remaining words, skip time if needed. */ + message[0] = 0; + for(c = optind + (!cancel && !when); c < argc; c++) { + if (strlen(message) + strlen(argv[c]) + 4 > MESSAGELEN) + break; + strcat(message, argv[c]); + strcat(message, " "); + } + if (message[0]) strcat(message, "\r\n"); + + /* See if we want to run or cancel. */ + if (cancel) { + if (pid <= 0) { + fprintf(stderr, "shutdown: cannot find pid " + "of running shutdown.\n"); + exit(1); + } + init_setenv("INIT_HALT", NULL); + if (kill(pid, SIGINT) < 0) { + fprintf(stderr, "shutdown: not running.\n"); + exit(1); + } + if (message[0]) wall(message, 0); + exit(0); + } + + /* Check syntax. */ + if (when == NULL) { + if (optind == argc) usage(); + when = argv[optind++]; + } + + /* See if we are already running. */ + if (pid > 0 && kill(pid, 0) == 0) { + fprintf(stderr, "\rshutdown: already running.\r\n"); + exit(1); + } + + /* Extra check. */ + if (doself && down_level[0] != '0' && down_level[0] != '6') { + fprintf(stderr, + "shutdown: can use \"-n\" for halt or reboot only.\r\n"); + exit(1); + } + + /* Tell users what we're gonna do. */ + switch(down_level[0]) { + case '0': + strcpy(newstate, "for system halt"); + break; + case '6': + strcpy(newstate, "for reboot"); + break; + case '1': + strcpy(newstate, "to maintenance mode"); + break; + default: + sprintf(newstate, "to runlevel %s", down_level); + break; + } + + /* Create a new PID file. */ + unlink(SDPID); + umask(022); + if ((fp = fopen(SDPID, "w")) != NULL) { + fprintf(fp, "%d\n", getpid()); + fclose(fp); + } else if (errno != EROFS) + fprintf(stderr, "shutdown: warning: cannot open %s\n", SDPID); + + /* + * Catch some common signals. + */ + signal(SIGQUIT, SIG_IGN); + signal(SIGCHLD, SIG_IGN); + signal(SIGHUP, SIG_IGN); + signal(SIGTSTP, SIG_IGN); + signal(SIGTTIN, SIG_IGN); + signal(SIGTTOU, SIG_IGN); + + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = stopit; + sigaction(SIGINT, &sa, NULL); + + /* Go to the root directory */ + chdir("/"); + if (fastboot) close(open(FASTBOOT, O_CREAT | O_RDWR, 0644)); + if (forcefsck) close(open(FORCEFSCK, O_CREAT | O_RDWR, 0644)); + + /* Alias now and take care of old '+mins' notation. */ + if (!strcmp(when, "now")) strcpy(when, "0"); + if (when[0] == '+') when++; + + /* Decode shutdown time. */ + for (sp = when; *sp; sp++) { + if (*sp != ':' && (*sp < '0' || *sp > '9')) + usage(); + } + if (strchr(when, ':') == NULL) { + /* Time in minutes. */ + wt = atoi(when); + if (wt == 0 && when[0] != '0') usage(); + } else { + /* Time in hh:mm format. */ + if (sscanf(when, "%d:%2d", &hours, &mins) != 2) usage(); + if (hours > 23 || mins > 59) usage(); + time(&t); + lt = localtime(&t); + wt = (60*hours + mins) - (60*lt->tm_hour + lt->tm_min); + if (wt < 0) wt += 1440; + } + /* Shutdown NOW if time == 0 */ + if (wt == 0) shutdown(halttype); + + /* Give warnings on regular intervals and finally shutdown. */ + if (wt < 15 && !needwarning(wt)) warn(wt); + while(wt) { + if (wt <= 5 && !didnolog) { + donologin(wt); + didnolog++; + } + if (needwarning(wt)) warn(wt); + hardsleep(60); + wt--; + } + shutdown(halttype); + + return 0; /* Never happens */ +} diff --git a/src/sulogin.c b/src/sulogin.c new file mode 100644 index 00000000..75376547 --- /dev/null +++ b/src/sulogin.c @@ -0,0 +1,607 @@ +/* + * sulogin This program gives Linux machines a reasonable + * secure way to boot single user. It forces the + * user to supply the root password before a + * shell is started. + * + * If there is a shadow password file and the + * encrypted root password is "x" the shadow + * password will be used. + * + * Version: @(#)sulogin 2.85-3 23-Apr-2003 miquels@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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(__GLIBC__) +# include +#endif + +#ifdef WITH_SELINUX +# include +# include +#endif + +#define CHECK_DES 1 +#define CHECK_MD5 1 + +#define F_PASSWD "/etc/passwd" +#define F_SHADOW "/etc/shadow" +#define BINSH "/bin/sh" +#define STATICSH "/bin/sash" + +char *Version = "@(#)sulogin 2.85-3 23-Apr-2003 miquels@cistron.nl"; + +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 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); + + /* Use defaults of 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 |= (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); + + /* 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[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 + + +/* + * Called at timeout. + */ +static +# ifdef __GNUC__ +void alrm_handler(int sig __attribute__((unused))) +# else +void alrm_handler(int sig) +# endif +{ +} + +/* + * See if an encrypted password is valid. The encrypted + * password is checked for traditional-style DES and + * FreeBSD-style MD5 encryption. + */ +static +int valid(const char *pass) +{ + 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; + + /* + * 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 ((strcmp(id, "$1$") == 0) && (len < 22 || len > 24)) return 0; + + /* + * 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; + for (s = pass; *s; s++) { + if ((*s < '0' || *s > '9') && + (*s < 'a' || *s > 'z') && + (*s < 'A' || *s > 'Z') && + *s != '.' && *s != '/') return 0; + } +#endif + return 1; +} + +/* + * Set a variable if the value is not NULL. + */ +static +void set(char **var, char *val) +{ + if (val) *var = val; +} + +/* + * Get the root password entry. + */ +static +struct passwd *getrootpwent(int try_manually) +{ + static struct passwd pwd; + struct passwd *pw; + struct spwd *spw; + FILE *fp; + static char line[256]; + static char sline[256]; + char *p; + + /* + * First, we try to get the password the standard + * way using normal library calls. + */ + if ((pw = getpwnam("root")) && + !strcmp(pw->pw_passwd, "x") && + (spw = getspnam("root"))) + pw->pw_passwd = spw->sp_pwdp; + if (pw || !try_manually) return pw; + + /* + * If we come here, we could not retrieve the root + * password through library calls and we try to + * read the password and shadow files manually. + */ + pwd.pw_name = "root"; + pwd.pw_passwd = ""; + pwd.pw_gecos = "Super User"; + pwd.pw_dir = "/"; + pwd.pw_shell = ""; + pwd.pw_uid = 0; + pwd.pw_gid = 0; + + if ((fp = fopen(F_PASSWD, "r")) == NULL) { + perror(F_PASSWD); + return &pwd; + } + + /* + * Find root in the password file. + */ + while((p = fgets(line, 256, fp)) != NULL) { + if (strncmp(line, "root:", 5) != 0) + continue; + p += 5; + set(&pwd.pw_passwd, strsep(&p, ":")); + (void)strsep(&p, ":"); + (void)strsep(&p, ":"); + set(&pwd.pw_gecos, strsep(&p, ":")); + set(&pwd.pw_dir, strsep(&p, ":")); + set(&pwd.pw_shell, strsep(&p, "\n")); + p = line; + break; + } + fclose(fp); + + /* + * If the encrypted password is valid + * or not found, return. + */ + if (p == NULL) { + fprintf(stderr, "%s: no entry for root\n", F_PASSWD); + return &pwd; + } + if (valid(pwd.pw_passwd)) return &pwd; + + /* + * The password is invalid. If there is a + * shadow password, try it. + */ + strcpy(pwd.pw_passwd, ""); + if ((fp = fopen(F_SHADOW, "r")) == NULL) { + fprintf(stderr, "%s: root password garbled\n", F_PASSWD); + return &pwd; + } + while((p = fgets(sline, 256, fp)) != NULL) { + if (strncmp(sline, "root:", 5) != 0) + continue; + p += 5; + set(&pwd.pw_passwd, strsep(&p, ":")); + break; + } + fclose(fp); + + /* + * If the password is still invalid, + * NULL it, and return. + */ + if (p == NULL) { + fprintf(stderr, "%s: no entry for root\n", F_SHADOW); + strcpy(pwd.pw_passwd, ""); + } + if (!valid(pwd.pw_passwd)) { + fprintf(stderr, "%s: root password garbled\n", F_SHADOW); + strcpy(pwd.pw_passwd, ""); } + return &pwd; +} + +/* + * 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; + struct termios old, tty; + 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"); + printf("(or type Control-D to continue): "); +#endif + fflush(stdout); + + tcgetattr(0, &old); + tcgetattr(0, &tty); + tty.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY); + tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP); + tcsetattr(0, TCSANOW, &tty); + + pass[sizeof(pass) - 1] = 0; + + sa.sa_handler = alrm_handler; + sa.sa_flags = 0; + sigaction(SIGALRM, &sa, NULL); + if (timeout) alarm(timeout); + + if (read(0, pass, sizeof(pass) - 1) <= 0) + ret = NULL; + else { + for(i = 0; i < (int)sizeof(pass) && pass[i]; i++) + if (pass[i] == '\r' || pass[i] == '\n') { + pass[i] = 0; + break; + } + } + alarm(0); + tcsetattr(0, TCSANOW, &old); + printf("\n"); + + return ret; +} + +/* + * Password was OK, execute a shell. + */ +static +void sushell(struct passwd *pwd) +{ + char shell[128]; + char home[128]; + char *p; + char *sushell; + + /* + * Set directory and shell. + */ + (void)chdir(pwd->pw_dir); + if ((p = getenv("SUSHELL")) != NULL) + sushell = p; + else if ((p = getenv("sushell")) != NULL) + sushell = p; + else { + if (pwd->pw_shell[0]) + sushell = pwd->pw_shell; + else + sushell = BINSH; + } + if ((p = strrchr(sushell, '/')) == NULL) + p = sushell; + else + p++; + snprintf(shell, sizeof(shell), profile ? "-%s" : "%s", p); + + /* + * Set some important environment variables. + */ + getcwd(home, sizeof(home)); + setenv("HOME", home, 1); + setenv("LOGNAME", "root", 1); + setenv("USER", "root", 1); + if (!profile) + setenv("SHLVL","0",1); + + /* + * Try to execute a shell. + */ + setenv("SHELL", sushell, 1); + signal(SIGINT, saved_sigint); + signal(SIGTSTP, saved_sigtstp); + signal(SIGQUIT, saved_sigquit); +#ifdef WITH_SELINUX + if (is_selinux_enabled() > 0) { + security_context_t scon=NULL; + char *seuser=NULL; + char *level=NULL; + if (getseuserbyname("root", &seuser, &level) == 0) + if (get_default_context_with_level(seuser, level, 0, &scon) == 0) { + if (setexeccon(scon) != 0) + fprintf(stderr, "setexeccon faile\n"); + freecon(scon); + } + free(seuser); + free(level); + } +#endif + execl(sushell, shell, NULL); + perror(sushell); + + setenv("SHELL", BINSH, 1); + execl(BINSH, profile ? "-sh" : "sh", NULL); + perror(BINSH); + + /* Fall back to staticly linked shell if both the users shell + and /bin/sh failed to execute. */ + setenv("SHELL", STATICSH, 1); + execl(STATICSH, STATICSH, NULL); + perror(STATICSH); +} + +static +void usage(void) +{ + fprintf(stderr, "Usage: sulogin [-e] [-p] [-t timeout] [tty device]\n"); +} + +int main(int argc, char **argv) +{ + char *tty = NULL; + char *p; + struct passwd *pwd; + int c, fd = -1; + int opt_e = 0; + pid_t pid, pgrp, ppgrp, ttypgrp; + + /* + * See if we have a timeout flag. + */ + opterr = 0; + while((c = getopt(argc, argv, "ept:")) != EOF) switch(c) { + case 't': + timeout = atoi(optarg); + break; + case 'p': + profile = 1; + break; + case 'e': + opt_e = 1; + break; + default: + usage(); + /* Do not exit! */ + break; + } + + if (geteuid() != 0) { + fprintf(stderr, "sulogin: only root can run sulogin.\n"); + exit(1); + } + + /* + * See if we need to open an other tty device. + */ + 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 || (tty = getenv("CONSOLE"))) { + + if ((fd = open(tty, O_RDWR)) < 0) { + perror(tty); + fd = dup(0); + } + + if (!isatty(fd)) { + fprintf(stderr, "%s: not a tty\n", tty); + close(fd); + } else { + + /* + * Only go through this trouble if the new + * tty doesn't fall in this process group. + */ + pid = getpid(); + pgrp = getpgid(0); + ppgrp = getpgid(getppid()); + ttypgrp = tcgetpgrp(fd); + + if (pgrp != ttypgrp && ppgrp != ttypgrp) { + if (pid != getsid(0)) { + if (pid == getpgid(0)) + setpgid(0, getpgid(getppid())); + setsid(); + } + + signal(SIGHUP, SIG_IGN); + if (ttypgrp > 0) + ioctl(0, TIOCNOTTY, (char *)1); + signal(SIGHUP, SIG_DFL); + close(0); + close(1); + close(2); + 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 + if (fd > 2) + close(fd); + } + } else if (getpid() == 1) { + /* We are init. We hence need to set a session anyway */ + setsid(); + if (ioctl(0, TIOCSCTTY, (char *)1)) + perror("ioctl(TIOCSCTTY)"); + } + +#if defined(SANE_TIO) && (SANE_TIO == 1) + fixtty(); +#endif + + /* + * Get the root password. + */ + if ((pwd = getrootpwent(opt_e)) == NULL) { + fprintf(stderr, "sulogin: cannot open password database!\n"); + sleep(2); + } + + /* + * Ask for the password. + */ + while(pwd) { + if ((p = getpasswd(pwd->pw_passwd)) == NULL) break; + 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"); + } + + /* + * User pressed Control-D. + */ + return 0; +} diff --git a/src/utmp.c b/src/utmp.c new file mode 100644 index 00000000..c1ae0c9a --- /dev/null +++ b/src/utmp.c @@ -0,0 +1,264 @@ +/* + * utmp.c Routines to read/write the utmp and wtmp files. + * Basically just wrappers around the library routines. + * + * Version: @(#)utmp.c 2.77 09-Jun-1999 miquels@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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "init.h" +#include "initreq.h" +#include "paths.h" + + +#if defined(__GLIBC__) +# if (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0) && defined(__powerpc__) +# define HAVE_UPDWTMP 0 +# else +# define HAVE_UPDWTMP 1 +# endif +#else +# define HAVE_UPDWTMP 0 +#endif + + +/* + * Log an event in the wtmp file (reboot, runlevel) + */ +void write_wtmp( +char *user, /* name of user */ +char *id, /* inittab ID */ +int pid, /* PID of process */ +int type, /* TYPE of entry */ +char *line) /* Which line is this */ +{ + int fd; + struct utmp utmp; + struct utsname uname_buf; + 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. + */ + if ((fd = open(WTMP_FILE, O_WRONLY|O_APPEND)) < 0) return; + +#ifdef INIT_MAIN + /* + * Note if we are going to write a boot record. + */ + if (type == BOOT_TIME) wrote_wtmp_reboot++; + + /* + * 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. + */ + 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 + + /* + * Zero the fields and enter new fields. + */ + memset(&utmp, 0, sizeof(utmp)); +#if defined(__GLIBC__) + gettimeofday(&tv, NULL); + utmp.ut_tv.tv_sec = tv.tv_sec; + utmp.ut_tv.tv_usec = tv.tv_usec; +#else + time(&utmp.ut_time); +#endif + utmp.ut_pid = pid; + utmp.ut_type = type; + 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) + strncpy(utmp.ut_host, uname_buf.release, sizeof(utmp.ut_host)); + +#if HAVE_UPDWTMP + updwtmp(WTMP_FILE, &utmp); +#else + write(fd, (char *)&utmp, sizeof(utmp)); +#endif + close(fd); +} + +/* + * Write an entry to the UTMP file. For DEAD_PROCESS, put + * the previous ut_line into oldline if oldline != NULL. + */ +static void write_utmp( +char *user, /* name of user */ +char *id, /* inittab ID */ +int pid, /* PID of process */ +int type, /* TYPE of entry */ +char *line, /* LINE if used. */ +char *oldline) /* Line of old utmp entry. */ +{ + struct utmp utmp; + struct utmp tmp; + struct utmp *utmptr; + struct timeval tv; + + /* + * Can't do much if UTMP_FILE is not present or not writable. + */ + if (access(UTMP_FILE, W_OK) < 0) + return; + +#ifdef INIT_MAIN + /* + * Note if we are going to write a boot record. + */ + if (type == BOOT_TIME) wrote_utmp_reboot++; + + /* + * 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 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 + + /* + * Fill out an utmp struct. + */ + memset(&utmp, 0, sizeof(utmp)); + utmp.ut_type = type; + utmp.ut_pid = pid; + strncpy(utmp.ut_id, id, sizeof(utmp.ut_id)); +#if defined(__GLIBC__) + gettimeofday(&tv, NULL); + utmp.ut_tv.tv_sec = tv.tv_sec; + utmp.ut_tv.tv_usec = tv.tv_usec; +#else + time(&utmp.ut_time); +#endif + strncpy(utmp.ut_user, user, UT_NAMESIZE); + if (line) strncpy(utmp.ut_line, line, UT_LINESIZE); + + /* + * We might need to find the existing entry first, to + * find the tty of the process (for wtmp accounting). + */ + if (type == DEAD_PROCESS) { + /* + * Find existing entry for the tty line. + */ + setutent(); + tmp = utmp; + if ((utmptr = getutid(&tmp)) != NULL) { + strncpy(utmp.ut_line, utmptr->ut_line, UT_LINESIZE); + if (oldline) + strncpy(oldline, utmptr->ut_line, UT_LINESIZE); + } + } + + /* + * Update existing utmp file. + */ + setutent(); + pututline(&utmp); + endutent(); +} + +/* + * Write a record to both utmp and wtmp. + */ +void write_utmp_wtmp( +char *user, /* name of user */ +char *id, /* inittab ID */ +int pid, /* PID of process */ +int type, /* TYPE of entry */ +char *line) /* LINE if used. */ +{ + char oldline[UT_LINESIZE]; + + /* + * For backwards compatibility we just return + * if user == NULL (means : clean up utmp file). + */ + if (user == NULL) + return; + + oldline[0] = 0; + write_utmp(user, id, pid, type, line, oldline); + write_wtmp(user, id, pid, type, line && line[0] ? line : oldline); +} + diff --git a/src/utmpdump.c b/src/utmpdump.c new file mode 100644 index 00000000..97f98697 --- /dev/null +++ b/src/utmpdump.c @@ -0,0 +1,302 @@ +/* + * utmpdump Simple program to dump UTMP and WTMP files in + * raw format, so they can be examined. + * + * Author: Miquel van Smoorenburg, + * Danek Duvall + * + * Version: @(#)utmpdump 2.79 12-Sep-2000 + * + * This file is part of the sysvinit suite, + * 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 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include "oldutmp.h" + +struct utmp +oldtonew(struct oldutmp src) +{ + struct utmp dest; + + memset(&dest, 0, sizeof dest); + dest.ut_type = src.ut_type; + dest.ut_pid = src.ut_pid; + dest.ut_time = src.ut_oldtime; + dest.ut_addr = src.ut_oldaddr; + strncpy(dest.ut_id, src.ut_id, 4); + strncpy(dest.ut_line, src.ut_line, OLD_LINESIZE); + strncpy(dest.ut_user, src.ut_user, OLD_NAMESIZE); + strncpy(dest.ut_host, src.ut_host, OLD_HOSTSIZE); + + return dest; +} + +struct oldutmp +newtoold(struct utmp src) +{ + struct oldutmp dest; + + memset(&dest, 0, sizeof dest); + dest.ut_type = src.ut_type; + dest.ut_pid = src.ut_pid; + dest.ut_oldtime = src.ut_time; + dest.ut_oldaddr = src.ut_addr; + strncpy(dest.ut_id, src.ut_id, 4); + strncpy(dest.ut_line, src.ut_line, OLD_LINESIZE); + strncpy(dest.ut_user, src.ut_user, OLD_NAMESIZE); + strncpy(dest.ut_host, src.ut_host, OLD_HOSTSIZE); + + return dest; +} + +char * +timetostr(const time_t time) +{ + static char s[29]; /* [Sun Sep 01 00:00:00 1998 PST] */ + + if (time != 0) + strftime(s, 29, "%a %b %d %T %Y %Z", localtime(&time)); + else + s[0] = '\0'; + + return s; +} + +time_t +strtotime(const char *s_time) +{ + struct tm tm; + + memset(&tm, '\0', sizeof(struct tm)); + + if (s_time[0] == ' ' || s_time[0] == '\0') + return (time_t)0; + + strptime(s_time, "%a %b %d %T %Y", &tm); + + /* Cheesy way of checking for DST */ + if (s_time[26] == 'D') + tm.tm_isdst = 1; + + return mktime(&tm); +} + +#define cleanse(x) xcleanse(x, sizeof(x)) +void +xcleanse(char *s, int len) +{ + for ( ; *s && len-- > 0; s++) + if (!isprint(*s) || *s == '[' || *s == ']') + *s = '?'; +} + +void +unspace(char *s, int len) +{ + while (*s && *s != ' ' && len--) + ++s; + + if (len > 0) + *s = '\0'; +} + +void +print_utline(struct utmp ut) +{ + char *addr_string, *time_string; + struct in_addr in; + + in.s_addr = ut.ut_addr; + addr_string = inet_ntoa(in); + time_string = timetostr(ut.ut_time); + cleanse(ut.ut_id); + cleanse(ut.ut_user); + cleanse(ut.ut_line); + cleanse(ut.ut_host); + + /* pid id user line host addr time */ + printf("[%d] [%05d] [%-4.4s] [%-*.*s] [%-*.*s] [%-*.*s] [%-15.15s] [%-28.28s]\n", + ut.ut_type, ut.ut_pid, ut.ut_id, 8, UT_NAMESIZE, ut.ut_user, + 12, UT_LINESIZE, ut.ut_line, 20, UT_HOSTSIZE, ut.ut_host, + addr_string, time_string); +} + +void +dump(FILE *fp, int forever, int oldfmt) +{ + struct utmp ut; + struct oldutmp uto; + + if (forever) + fseek(fp, -10 * (oldfmt ? sizeof uto : sizeof ut), SEEK_END); + + do { + if (oldfmt) + while (fread(&uto, sizeof uto, 1, fp) == 1) + print_utline(oldtonew(uto)); + else + while (fread(&ut, sizeof ut, 1, fp) == 1) + print_utline(ut); + if (forever) sleep(1); + } while (forever); +} + +/* This function won't work properly if there's a ']' or a ' ' in the real + * token. Thankfully, this should never happen. */ +int +gettok(char *line, char *dest, int size, int eatspace) +{ + int bpos, epos, eaten; + char *t; + + bpos = strchr(line, '[') - line; + if (bpos < 0) { + fprintf(stderr, "Extraneous newline in file. Exiting."); + exit(1); + } + line += 1 + bpos; + + epos = strchr(line, ']') - line; + if (epos < 0) { + fprintf(stderr, "Extraneous newline in file. Exiting."); + exit(1); + } + line[epos] = '\0'; + + eaten = bpos + epos + 1; + + if (eatspace) + if ((t = strchr(line, ' '))) + *t = 0; + + strncpy(dest, line, size); + + return eaten + 1; +} + +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; + char s_addr[16], s_time[29], *linestart, *line; + int count = 0; + + line = linestart = malloc(1024 * sizeof *linestart); + s_addr[15] = 0; + s_time[28] = 0; + + while(fgets(linestart, 1023, fp)) + { + line = linestart; + memset(&ut, '\0', sizeof(ut)); + sscanf(line, "[%hd] [%d] [%4c] ", &ut.ut_type, &ut.ut_pid, ut.ut_id); + + line += 19; + line += gettok(line, ut.ut_user, sizeof(ut.ut_user), 1); + line += gettok(line, ut.ut_line, sizeof(ut.ut_line), 1); + line += gettok(line, ut.ut_host, sizeof(ut.ut_host), 1); + line += gettok(line, s_addr, sizeof(s_addr)-1, 1); + line += gettok(line, s_time, sizeof(s_time)-1, 0); + + ut.ut_addr = inet_addr(s_addr); + ut.ut_time = strtotime(s_time); + + if (oldfmt) { + uto = newtoold(ut); + fwrite(&uto, sizeof(uto), 1, stdout); + } else + fwrite(&ut, sizeof(ut), 1, stdout); + + ++count; + } + + free(linestart); +} + +void +usage(int result) +{ + printf("Usage: utmpdump [ -froh ] [ filename ]\n"); + exit(result); +} + +int main(int argc, char **argv) +{ + int c; + FILE *fp; + int reverse = 0, forever = 0, oldfmt = 0; + + while ((c = getopt(argc, argv, "froh")) != EOF) { + switch (c) { + case 'r': + reverse = 1; + break; + + case 'f': + forever = 1; + break; + + case 'o': + oldfmt = 1; + break; + + case 'h': + usage(0); + break; + + default: + usage(1); + } + } + + if (optind < argc) { + fprintf(stderr, "Utmp %sdump of %s\n", reverse ? "un" : "", argv[optind]); + if ((fp = fopen(argv[optind], "r")) == NULL) { + perror("Unable to open file"); + exit(1); + } + } + else { + fprintf(stderr, "Utmp %sdump of stdin\n", reverse ? "un" : ""); + fp = stdin; + } + + if (reverse) + undump(fp, forever, oldfmt); + else + dump(fp, forever, oldfmt); + + fclose(fp); + + return 0; +} diff --git a/src/wall.c b/src/wall.c new file mode 100644 index 00000000..92d9fb41 --- /dev/null +++ b/src/wall.c @@ -0,0 +1,122 @@ +/* + * wall.c Write to all users logged in. + * + * Usage: wall [text] + * + * Version: @(#)wall 2.79 12-Sep-2000 miquels@cistron.nl + * + * This file is part of the sysvinit suite, + * 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 + */ + +#include +#include +#include +#include +#include +#include +#include "init.h" + + +char *Version = "@(#) wall 2.79 12-Sep-2000 miquels@cistron.nl"; +#define MAXLEN 4096 +#define MAXLINES 20 + +int main(int argc, char **argv) +{ + char buf[MAXLEN]; + char line[83]; + int i, f, ch; + int len = 0; + int remote = 0; + char *p; + char *whoami; + struct passwd *pwd; + + buf[0] = 0; + if ((pwd = getpwuid(getuid())) == NULL) { + if (getuid() == 0) + whoami = "root"; + else { + fprintf(stderr, "You don't exist. Go away.\n"); + exit(1); + } + } else + whoami = pwd->pw_name; + + while((ch = getopt(argc, argv, "n")) != EOF) + switch(ch) { + case 'n': + /* + * Undocumented option for suppressing + * banner from rpc.rwalld. Only works if + * we are root or if we're NOT setgid. + */ + if (geteuid() != 0 && getgid() != getegid()) { + fprintf(stderr, "wall -n: not priviliged\n"); + exit(1); + } + remote = 1; + break; + default: + fprintf(stderr, "usage: wall [message]\n"); + return 1; + break; + } + + if ((argc - optind) > 0) { + for(f = optind; f < argc; f++) { + len += strlen(argv[f]) + 1; + if (len >= MAXLEN-2) break; + strcat(buf, argv[f]); + if (f < argc-1) strcat(buf, " "); + } + strcat(buf, "\r\n"); + } else { + while(fgets(line, 80, stdin)) { + /* + * Make sure that line ends in \r\n + */ + for(p = line; *p && *p != '\r' && *p != '\n'; p++) + ; + strcpy(p, "\r\n"); + len += strlen(line); + if (len >= MAXLEN) break; + strcat(buf, line); + } + } + + i = 0; + for (p = buf; *p; p++) { + if (*p == '\n' && i++ > MAXLINES) { + *++p = 0; + break; + } + } + + openlog("wall", LOG_PID, LOG_USER); + syslog(LOG_INFO, "wall: user %s broadcasted %d lines (%d chars)", + whoami, i, strlen(buf)); + closelog(); + + unsetenv("TZ"); + wall(buf, remote); + + /*NOTREACHED*/ + return 0; +} + -- cgit v1.2.3 From 8190b942e6d53b98bd5a1cb7de75c122680fe33d Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: Import sysvinit_2.88dsf-59.11.debian.tar.xz [dgit import tarball sysvinit 2.88dsf-59.11 sysvinit_2.88dsf-59.11.debian.tar.xz] --- NOTES | 115 + README.source | 7 + bootlogd.install | 2 + bootlogd.lintian-overrides | 4 + bootlogd.postinst | 33 + bootlogd.postrm | 31 + changelog | 4854 +++++++++++++++++++++ compat | 1 + control | 105 + copyright | 52 + deps-mount | 14 + fscklog.sh | 18 + gbp.conf | 3 + git-tag | 17 + init-d-script | 242 + init-d-script.5 | 85 + initscripts.NEWS | 48 + initscripts.conffiles | 29 + initscripts.copyright | 31 + initscripts.lintian-overrides | 26 + initscripts.maintscript | 3 + initscripts.postinst | 234 + initscripts.postrm | 75 + initscripts.preinst | 52 + patches/10_doc_manuals.dpatch | 78 + patches/11_inittab_limits.patch | 31 + patches/11_lfs_cflags.patch | 17 + patches/11_man_fstab_decode_typo | 17 + patches/11_man_halt8.patch | 32 + patches/11_run_nologin.patch | 43 + patches/20_init_freebsd_vswtc.patch | 17 + patches/30_killall5_hurd.patch | 30 + patches/31_killall5_hurd.patch | 37 + patches/40_multiarch_libcrypt.patch | 24 + patches/63_init_keep_utf8_ttyflag.patch | 21 + patches/64_init_selinux_enabled.patch | 40 + patches/92_kfreebsd_ifdown.patch | 128 + patches/93_run_initctl.patch | 158 + patches/94_kfreebsd_xterm.patch | 20 + patches/95_kfreebsd_bootlogd.patch | 43 + patches/96_allow_multiple_console_output.patch | 294 ++ patches/series | 17 + po/POTFILES.in | 1 + po/ca.po | 107 + po/cs.po | 101 + po/da.po | 66 + po/de.po | 67 + po/es.po | 127 + po/fi.po | 107 + po/fr.po | 69 + po/gl.po | 105 + po/it.po | 108 + po/ja.po | 99 + po/nb.po | 112 + po/nl.po | 66 + po/pl.po | 103 + po/pt.po | 107 + po/pt_BR.po | 106 + po/ru.po | 106 + po/sk.po | 107 + po/sv.po | 108 + po/templates.pot | 57 + po/vi.po | 108 + po/zh_CN.po | 63 + rules | 133 + share/inittab | 69 + share/inittab.gnu | 70 + share/inittab.kfreebsd-gnu | 69 + share/inittab.knetbsd-gnu | 67 + share/inittab.s390-linux-gnu | 63 + share/inittab.s390x-linux-gnu | 63 + share/update-rc.d | 27 + source/format | 1 + source/lintian-overrides | 1 + src/bootlogd/Makefile | 15 + src/bootlogd/etc/init.d/bootlogd | 101 + src/bootlogd/etc/init.d/stop-bootlogd | 34 + src/bootlogd/etc/init.d/stop-bootlogd-single | 52 + src/initscripts/Makefile | 43 + src/initscripts/doc/README.Debian | 52 + src/initscripts/etc/default/devpts | 5 + src/initscripts/etc/default/halt | 2 + src/initscripts/etc/default/rcS | 27 + src/initscripts/etc/default/tmpfs | 37 + src/initscripts/etc/hurd/runsystem.sysv | 122 + src/initscripts/etc/init.d/bootlogs | 60 + src/initscripts/etc/init.d/bootmisc.sh | 59 + src/initscripts/etc/init.d/checkfs.sh | 155 + src/initscripts/etc/init.d/checkroot-bootclean.sh | 43 + src/initscripts/etc/init.d/checkroot.sh | 371 ++ src/initscripts/etc/init.d/halt | 83 + src/initscripts/etc/init.d/hostname.sh | 68 + src/initscripts/etc/init.d/killprocs | 62 + src/initscripts/etc/init.d/motd | 53 + src/initscripts/etc/init.d/mountall-bootclean.sh | 35 + src/initscripts/etc/init.d/mountall.sh | 100 + src/initscripts/etc/init.d/mountdevsubfs.sh | 68 + src/initscripts/etc/init.d/mountkernfs.sh | 75 + src/initscripts/etc/init.d/mountnfs-bootclean.sh | 35 + src/initscripts/etc/init.d/mountnfs.sh | 106 + src/initscripts/etc/init.d/rc.local | 43 + src/initscripts/etc/init.d/reboot | 41 + src/initscripts/etc/init.d/rmnologin | 59 + src/initscripts/etc/init.d/sendsigs | 126 + src/initscripts/etc/init.d/single | 35 + src/initscripts/etc/init.d/skeleton | 27 + src/initscripts/etc/init.d/umountfs | 130 + src/initscripts/etc/init.d/umountnfs.sh | 100 + src/initscripts/etc/init.d/umountroot | 56 + src/initscripts/etc/init.d/urandom | 106 + src/initscripts/etc/network/if-up.d/mountnfs | 185 + src/initscripts/lib/init/bootclean.sh | 181 + src/initscripts/lib/init/mount-functions.sh | 708 +++ src/initscripts/lib/init/swap-functions.sh | 28 + src/initscripts/lib/init/tmpfs.sh | 133 + src/initscripts/man/fsck.nfs.8 | 16 + src/initscripts/man/halt.5 | 49 + src/initscripts/man/rcS.5 | 115 + src/initscripts/man/tmpfs.5 | 206 + src/initscripts/sbin/fsck.nfs | 21 + src/sysv-rc/Makefile | 32 + src/sysv-rc/doc/README.Debian | 46 + src/sysv-rc/doc/README.runlevels | 103 + src/sysv-rc/etc/init.d/README | 60 + src/sysv-rc/etc/init.d/rc | 263 ++ src/sysv-rc/etc/init.d/rcS | 8 + src/sysv-rc/etc/rc0.d/README | 11 + src/sysv-rc/etc/rc1.d/README | 11 + src/sysv-rc/etc/rc6.d/README | 11 + src/sysv-rc/etc/rcS.d/README | 12 + src/sysv-rc/rc2-5.d-README | 15 + src/sysv-rc/saveconfig | 94 + sysv-rc.NEWS | 24 + sysv-rc.copyright | 32 + sysv-rc.lintian-overrides | 41 + sysv-rc.postinst | 101 + sysv-rc.postrm | 24 + sysv-rc.preinst | 31 + sysv-rc.prerm | 20 + sysv-rc.templates | 28 + sysvinit-core.config | 44 + sysvinit-core.dirs | 1 + sysvinit-core.install | 14 + sysvinit-core.links | 3 + sysvinit-core.lintian-overrides | 1 + sysvinit-core.postinst | 139 + sysvinit-core.templates | 14 + sysvinit-utils.NEWS | 9 + sysvinit-utils.install | 7 + sysvinit-utils.links | 1 + sysvinit-utils.manpages | 1 + sysvinit-watch | 2 + vars.sh | 53 + watch | 3 + 154 files changed, 15178 insertions(+) create mode 100644 NOTES create mode 100644 README.source create mode 100644 bootlogd.install create mode 100644 bootlogd.lintian-overrides create mode 100644 bootlogd.postinst create mode 100644 bootlogd.postrm create mode 100644 changelog create mode 100644 compat create mode 100644 control create mode 100644 copyright create mode 100755 deps-mount create mode 100644 fscklog.sh create mode 100644 gbp.conf create mode 100755 git-tag create mode 100755 init-d-script create mode 100644 init-d-script.5 create mode 100644 initscripts.NEWS create mode 100644 initscripts.conffiles create mode 100644 initscripts.copyright create mode 100644 initscripts.lintian-overrides create mode 100644 initscripts.maintscript create mode 100755 initscripts.postinst create mode 100755 initscripts.postrm create mode 100755 initscripts.preinst create mode 100644 patches/10_doc_manuals.dpatch create mode 100644 patches/11_inittab_limits.patch create mode 100644 patches/11_lfs_cflags.patch create mode 100644 patches/11_man_fstab_decode_typo create mode 100644 patches/11_man_halt8.patch create mode 100644 patches/11_run_nologin.patch create mode 100644 patches/20_init_freebsd_vswtc.patch create mode 100644 patches/30_killall5_hurd.patch create mode 100644 patches/31_killall5_hurd.patch create mode 100644 patches/40_multiarch_libcrypt.patch create mode 100644 patches/63_init_keep_utf8_ttyflag.patch create mode 100644 patches/64_init_selinux_enabled.patch create mode 100644 patches/92_kfreebsd_ifdown.patch create mode 100644 patches/93_run_initctl.patch create mode 100644 patches/94_kfreebsd_xterm.patch create mode 100644 patches/95_kfreebsd_bootlogd.patch create mode 100644 patches/96_allow_multiple_console_output.patch create mode 100644 patches/series create mode 100644 po/POTFILES.in create mode 100644 po/ca.po create mode 100644 po/cs.po create mode 100644 po/da.po create mode 100644 po/de.po create mode 100644 po/es.po create mode 100644 po/fi.po create mode 100644 po/fr.po create mode 100644 po/gl.po create mode 100644 po/it.po create mode 100644 po/ja.po create mode 100644 po/nb.po create mode 100644 po/nl.po create mode 100644 po/pl.po create mode 100644 po/pt.po create mode 100644 po/pt_BR.po create mode 100644 po/ru.po create mode 100644 po/sk.po create mode 100644 po/sv.po create mode 100644 po/templates.pot create mode 100644 po/vi.po create mode 100644 po/zh_CN.po create mode 100755 rules create mode 100644 share/inittab create mode 100644 share/inittab.gnu create mode 100644 share/inittab.kfreebsd-gnu create mode 100644 share/inittab.knetbsd-gnu create mode 100644 share/inittab.s390-linux-gnu create mode 100644 share/inittab.s390x-linux-gnu create mode 100755 share/update-rc.d create mode 100644 source/format create mode 100644 source/lintian-overrides create mode 100644 src/bootlogd/Makefile create mode 100644 src/bootlogd/etc/init.d/bootlogd create mode 100644 src/bootlogd/etc/init.d/stop-bootlogd create mode 100644 src/bootlogd/etc/init.d/stop-bootlogd-single create mode 100644 src/initscripts/Makefile create mode 100644 src/initscripts/doc/README.Debian create mode 100644 src/initscripts/etc/default/devpts create mode 100644 src/initscripts/etc/default/halt create mode 100644 src/initscripts/etc/default/rcS create mode 100644 src/initscripts/etc/default/tmpfs create mode 100755 src/initscripts/etc/hurd/runsystem.sysv create mode 100644 src/initscripts/etc/init.d/bootlogs create mode 100755 src/initscripts/etc/init.d/bootmisc.sh create mode 100755 src/initscripts/etc/init.d/checkfs.sh create mode 100755 src/initscripts/etc/init.d/checkroot-bootclean.sh create mode 100755 src/initscripts/etc/init.d/checkroot.sh create mode 100755 src/initscripts/etc/init.d/halt create mode 100755 src/initscripts/etc/init.d/hostname.sh create mode 100755 src/initscripts/etc/init.d/killprocs create mode 100644 src/initscripts/etc/init.d/motd create mode 100755 src/initscripts/etc/init.d/mountall-bootclean.sh create mode 100755 src/initscripts/etc/init.d/mountall.sh create mode 100755 src/initscripts/etc/init.d/mountdevsubfs.sh create mode 100755 src/initscripts/etc/init.d/mountkernfs.sh create mode 100755 src/initscripts/etc/init.d/mountnfs-bootclean.sh create mode 100755 src/initscripts/etc/init.d/mountnfs.sh create mode 100644 src/initscripts/etc/init.d/rc.local create mode 100755 src/initscripts/etc/init.d/reboot create mode 100755 src/initscripts/etc/init.d/rmnologin create mode 100755 src/initscripts/etc/init.d/sendsigs create mode 100755 src/initscripts/etc/init.d/single create mode 100644 src/initscripts/etc/init.d/skeleton create mode 100755 src/initscripts/etc/init.d/umountfs create mode 100755 src/initscripts/etc/init.d/umountnfs.sh create mode 100755 src/initscripts/etc/init.d/umountroot create mode 100755 src/initscripts/etc/init.d/urandom create mode 100644 src/initscripts/etc/network/if-up.d/mountnfs create mode 100644 src/initscripts/lib/init/bootclean.sh create mode 100644 src/initscripts/lib/init/mount-functions.sh create mode 100644 src/initscripts/lib/init/swap-functions.sh create mode 100644 src/initscripts/lib/init/tmpfs.sh create mode 100644 src/initscripts/man/fsck.nfs.8 create mode 100644 src/initscripts/man/halt.5 create mode 100644 src/initscripts/man/rcS.5 create mode 100644 src/initscripts/man/tmpfs.5 create mode 100644 src/initscripts/sbin/fsck.nfs create mode 100644 src/sysv-rc/Makefile create mode 100644 src/sysv-rc/doc/README.Debian create mode 100644 src/sysv-rc/doc/README.runlevels create mode 100644 src/sysv-rc/etc/init.d/README create mode 100644 src/sysv-rc/etc/init.d/rc create mode 100644 src/sysv-rc/etc/init.d/rcS create mode 100644 src/sysv-rc/etc/rc0.d/README create mode 100644 src/sysv-rc/etc/rc1.d/README create mode 100644 src/sysv-rc/etc/rc6.d/README create mode 100644 src/sysv-rc/etc/rcS.d/README create mode 100644 src/sysv-rc/rc2-5.d-README create mode 100644 src/sysv-rc/saveconfig create mode 100644 sysv-rc.NEWS create mode 100644 sysv-rc.copyright create mode 100644 sysv-rc.lintian-overrides create mode 100644 sysv-rc.postinst create mode 100755 sysv-rc.postrm create mode 100644 sysv-rc.preinst create mode 100755 sysv-rc.prerm create mode 100644 sysv-rc.templates create mode 100755 sysvinit-core.config create mode 100644 sysvinit-core.dirs create mode 100644 sysvinit-core.install create mode 100644 sysvinit-core.links create mode 100644 sysvinit-core.lintian-overrides create mode 100755 sysvinit-core.postinst create mode 100644 sysvinit-core.templates create mode 100644 sysvinit-utils.NEWS create mode 100644 sysvinit-utils.install create mode 100644 sysvinit-utils.links create mode 100644 sysvinit-utils.manpages create mode 100644 sysvinit-watch create mode 100644 vars.sh create mode 100644 watch diff --git a/NOTES b/NOTES new file mode 100644 index 00000000..739b9584 --- /dev/null +++ b/NOTES @@ -0,0 +1,115 @@ + Maintainer notes for sysvinit + +News +---- +Last updated 16 May 2009 + +Stuff to implement +------------------ +* Do not allow system to continue booting if both fsck and sulogin fail (#337444)? +* Make sulogin try /bin/sh and /bin/sash too (#40144, #43317)? +* Port bootlogd to use posix_openpt(3), since BSD PTs are now deprecated and + /dev/pts _is_ now available at the time that bootlogd starts (...in Debian)? + +Stuff to do after etch +---------------------- +* mountnfs.sh: Don't start portmap + +Ubuntu changes to backport +-------------------------- +(none known ATM) + +Stuff to send upstream +---------------------- +debian/patches/fix-minor-warnings should be applied upstream. +So should a lot of the other patches. + +src/Makefile should not set CC. + +set -e +------ +Note that many scripts do not use "set -e". This is deliberate. +Instead, return statuses are checked. + +PATH +---- +* Current policy: + + Leave unset if absolutely no pathless commands are run; otherwise... + + set to "/sbin:/bin" in /etc/init.d/rc and in scripts that run prior + to mountnfs.sh; otherwise... + + set to "/usr/sbin:/usr/bin:/sbin:/bin". + + Add "/lib/init" to beginning of PATH if readlink command or domount + function used. This will disappear once coreutils 5.94 makes it + into testing, and we Depend on that. +* Question: Should we include /usr/local/sbin and /usr/local/bin too? + I don't see this question addressed in Policy. Ref: #227540 + +Rotating fsck logs? +------------------- +debian/fscklog.sh is a proposed script for rotating fsck logs. +Currently, we _overwrite_ the fsck log files on every boot so there +is no need to rotate them. I am not inclined to implement rotation +of fsck logs. + +Dependencies +------------ +To go away: +* sysvinit Pre-Depends on initscripts, sysv-rc | file-rc so that the + conffiles in the old monolithic sysvinit package are taken over by + the initscripts package. (Only a Pre-Depends is strong enough to + ensure that the conffiles are taken over without an orphanic hiatus.) + Strictly speaking we can drop this dependency now since everyone is + either installing anew or else has upgraded to sarge; and Debian does + not support skip upgrades. However, I don't see any harm in keeping + this dependency around until after etch releases. But then it should + go away. +* initscripts Depends on mount >= 2.11x-1 because that's when swapon's + "-e" option was added. Sarge satisfies this requirement so this + dependency could be dropped. We can drop it after etch releases; + then both stable and oldstable will satisfy the requirement. +* initscripts needs to Depend on debianutils >= 2.12.0 until etch has + been released so that which can be assumed to be in /bin (rather than + in /usr/bin, as it was before, including in 2.8.4 in sarge) +* initscripts Conflicts with and Replaces mdutils which was last seen in + potato. Can disappear after etch. +* initscripts Conflicts with sysvinit (<< 2.86.ds1-12) because earlier + versions of bootlogd didn't have the -c option which the bootlogd + initscripts now uses + +Questionable: +* initscripts Replaces various libc packages for reasons described here: + http://lists.debian.org/debian-hurd/2004/06/msg00048.html. + Anyone know how long this dependency needs to be carried? +* sysv-rc (current) Conflicts with and Replaces file-rc. file-rc (0.8.7) + Replaces: sysv-rc but does not Conflict with it. I am not sure that + sysv-rc needs to Replace: file-rc. Isn't Conflicting sufficient? + And why doesn't file-rc Conflict with sysv-rc? Strange. + +Possible future: +* If the mtab initscript is ever changed so that it updates the mtab file + without rerunning mountdevsubfs.sh then initscripts should be made to + Conflict with udev << 0.080-1. (The latter versions of udev put the + udev initscript at S04, _after_ S04mountdevsubfs.sh, and the script + unmounts /dev/pts and /dev/shm.) + + +Speed and compatibility +----------------------- +People running Debian on low-memory systems say: +* Use built-ins +* Avoid fork-and-exec, pipelines, $() +* Reduce the number of commands within pipelines +* Avoid unnecessary code +* Avoid commands that don't work the same way in BusyBox: + 'nice', 'find', 'mount', 'umount', 'init', 'halt', 'shutdown', + 'syslogd', 'klogd', 'hwclock', 'cron', 'anacron', 'crontab'. + +Regenerate /etc/default/rcS? +---------------------------- +The current /etc/default/rcS template just refers the admin to rcS(5). +This way we have only one set of docs to maintain, and we don't have +to worry about out-of-date comments in /etc/default/rcS. + +I wonder if we should strip comments out of existing /etc/default/rcS +files, leaving behind only the reference to rcS(5). + diff --git a/README.source b/README.source new file mode 100644 index 00000000..3ea4bc7e --- /dev/null +++ b/README.source @@ -0,0 +1,7 @@ +This package uses quilt to manage all modifications to the upstream +source. Changes are stored in the source package as diffs in +debian/patches and debian/insserv/patches and applied during the build. + +After installing the quilt package, plenty of documentation and tips +for using it with Debian packaging can be found in /usr/share/doc/quilt/ +and quilt(1). diff --git a/bootlogd.install b/bootlogd.install new file mode 100644 index 00000000..1f21bd92 --- /dev/null +++ b/bootlogd.install @@ -0,0 +1,2 @@ +sbin/bootlogd +usr/share/man/man8/bootlogd.8 diff --git a/bootlogd.lintian-overrides b/bootlogd.lintian-overrides new file mode 100644 index 00000000..2d4f0be3 --- /dev/null +++ b/bootlogd.lintian-overrides @@ -0,0 +1,4 @@ +bootlogd: script-calls-init-script-directly ./etc/init.d/stop-bootlogd:19 +bootlogd: script-calls-init-script-directly ./etc/init.d/stop-bootlogd-single:36 +bootlogd: init.d-script-call-internal-API etc/init.d/bootlogd +bootlogd: init.d-script-missing-dependency-on-remote_fs etc/init.d/bootlogd: required-start diff --git a/bootlogd.postinst b/bootlogd.postinst new file mode 100644 index 00000000..50ab21ad --- /dev/null +++ b/bootlogd.postinst @@ -0,0 +1,33 @@ +#!/bin/sh +set -e + +INITSCRIPTS="bootlogd stop-bootlogd-single stop-bootlogd" + +for F in $INITSCRIPTS; do + if [ -x /etc/init.d/$F ]; then + update-rc.d $F defaults >/dev/null || exit $? + fi +done + +mkdir -p /etc/systemd/system +for F in $INITSCRIPTS; do + SERVICE="$(basename $F .sh).service" + if [ -x /etc/init.d/$F ] && [ ! -e /etc/systemd/system/$SERVICE ]; then + ln -s /dev/null /etc/systemd/system/$SERVICE + fi +done + +# +# Create initial log files +# +for F in /var/log/boot +do + if [ ! -f "$F" ] && touch "$F" >/dev/null 2>&1 + then + echo "(Nothing has been logged yet. If you're still seeing this message your current init system might not write bootup messages to the system console at all.)" >| "$F" + chown root:adm "$F" + chmod 640 "$F" + fi +done + +#DEBHELPER# diff --git a/bootlogd.postrm b/bootlogd.postrm new file mode 100644 index 00000000..2705c154 --- /dev/null +++ b/bootlogd.postrm @@ -0,0 +1,31 @@ +#!/bin/sh +set -e + +INITSCRIPTS="bootlogd stop-bootlogd-single stop-bootlogd" + +case "$1" in + purge) + # + # Remove log files + # + rm -f /var/log/boot + + # Remove rc symlinks in the reverse dependency order they were + # inserted + for F in $INITSCRIPTS; do + REVERSE="$F $REVERSE" + done + for F in $REVERSE; do + update-rc.d $F remove >/dev/null || exit $? + done + + for F in $INITSCRIPTS; do + SERVICE="$(basename $F .sh).service" + if [ -L /etc/systemd/system/$SERVICE ]; then + rm /etc/systemd/system/$SERVICE + fi + done + ;; +esac + +#DEBHELPER# diff --git a/changelog b/changelog new file mode 100644 index 00000000..32ade0ea --- /dev/null +++ b/changelog @@ -0,0 +1,4854 @@ +sysvinit (2.88dsf-59.11) unstable; urgency=medium + + * Non-maintainer upload. + + [ Mert Dirik ] + * Make sure that services using init-d-script can be properly redirected to + systemctl. (Closes: #826214) + * Avoid naming collisions when storing the script name in init-d-script by + using a custom prefix. + + -- Michael Biebl Sun, 07 Oct 2018 16:04:09 +0200 + +sysvinit (2.88dsf-59.10) unstable; urgency=medium + + * Non-maintainer upload. + * The init scripts provided by the bootlogd and initscripts package are + specific to sysvinit/sysv-rc and should not be run when systemd is the + active init system. To ensure that, mask those services by creating a + symlink pointing at /dev/null which tells systemd to ignore those + services. (Closes: #874685) + + -- Michael Biebl Fri, 08 Sep 2017 21:18:37 +0200 + +sysvinit (2.88dsf-59.9) unstable; urgency=medium + + [ Martin Pitt ] + * Mark sysvinit-utils as Multi-Arch: foreign, like sysv-rc and initscripts. + + [ Michael Biebl ] + * Demote priority of sysv-rc and initscripts to optional. + + [ Petter Reinholdtsen ] + * Avoid remounting tmpfs, linprocfs and linsysfs on kFreeBSD + (Closes: #833687). These file systems are not remountable. The + change avoid a warning from mount. Based on Patch from Jon Boden. + + [ Ian Jackson ] + * Add myself to Uploaders, as part of adopting the package. + Closes:#811377 (RFA bug). + * Add Benda Xu to Uploaders, as requested in #811377. + + [ Ben Hutchings ] + * Keep /usr mounted read-only on shutdown (Closes: #757083) + + -- Ian Jackson Sun, 12 Feb 2017 21:55:39 +0000 + +sysvinit (2.88dsf-59.8) unstable; urgency=medium + + * Non-maintainer upload. + + [ Benda Xu ] + * Add openrc to the dependencies of initscripts and sysvinit-core. + openrc is going to drop Provides: sysv-rc. + + [ Michael Biebl ] + * Update Vcs-* fields to use the canonical alioth URLs and prefer https://. + * Drop obsolete Conflicts, Breaks and Replaces from pre-wheezy. + * Drop Suggests: sash from sysvinit-utils. It is obsolete now that we use + the sulogin implementation from util-linux. + * Move Suggests: bootlogd from sysvinit-utils to sysvinit-core. Under + systemd, bootlogd is non-functional. So only suggest its installation when + sysvinit-core is the active init system. (Closes: #754443) + * Document that /etc/default/{rcS,tmpfs} are ignored when systemd is the + active init system. (Closes: #776963) + * Drop transitional sysvinit package. It has served its purpose for the + wheezy → jessie transition and keeping it around for longer only leads to + confusion as it doesn't setup /etc/inittab which is necessary to boot with + SysV. This functionality has moved into sysvinit-core, which should be + used instead in such a case. (Closes: #781766) + + -- Michael Biebl Wed, 20 Jul 2016 15:28:28 +0200 + +sysvinit (2.88dsf-59.7) unstable; urgency=medium + + * Non-maintainer upload. + * Drop sysvinit-utils' versioned Breaks: on initscripts, as this causes apt + to fail upgrades because of Breaks/Depends loops on essential packages. + Only keep the Replaces: for moving vars.sh. (Closes: #827705) + + -- Martin Pitt Wed, 22 Jun 2016 12:33:26 +0200 + +sysvinit (2.88dsf-59.6) unstable; urgency=medium + + * Non-maintainer upload. + * Bump versioned initscripts dependency to sysvinit-utils to ensure that we + get the one with vars.sh. (Closes: #827212) + + -- Martin Pitt Mon, 13 Jun 2016 22:04:06 +0300 + +sysvinit (2.88dsf-59.5) unstable; urgency=medium + + * Non-maintainer upload. + + [ Andreas Henriksson ] + * bootlogd: mention it won't do anything under systemd (Closes: #791907) + + [ Martin Pitt ] + * Move /lib/init/vars.sh from initscripts to sysvinit-utils. It's not + specific to initscripts, but API for other init scripts similar to + /lib/init/init-d-script. This will allow initscripts to drop from the + default installation. (Closes: #826205) + * Drop startpar dependency from sysvinit-utils. It's only being used by + sysv-rc and remains a dependency of that. (Closes: #825937) + + -- Martin Pitt Wed, 08 Jun 2016 15:25:01 +0200 + +sysvinit (2.88dsf-59.4) unstable; urgency=medium + + * Non-maintainer upload. + + [ Petter Reinholdtsen ] + * Fix typo in init-d-script(5) reported by Eric S. Raymond. + + [ Andreas Henriksson ] + * sysvinit-utils: move util-linux back to Depends (instead of Breaks) + - that's where it belonged and can be put now that the cyclic-dep + (via initscripts pkg) workaround is no longer needed. + - also bump util-linux version to the one with the matching change. + Closes: #823569 + * Add a basic debian/gbp.conf with debian/upstream branch names + + -- Andreas Henriksson Fri, 06 May 2016 05:55:46 +0200 + +sysvinit (2.88dsf-59.3) unstable; urgency=medium + + * Non-maintainer upload. + + [ Samuel Thibault ] + * /etc/init.d/rc: Mount /proc on GNU/Hurd too (Closes: #798406) + + [ Ben Hutchings ] + * Add support for mount and fsck of root and /usr by an initramfs: + - checkroot.sh: Do nothing if /run/initramfs/fsck-root exists + - checkfs.sh: Pass -M option to fsck instead of -R (Closes: #697002) + - mountall.sh: Remount /usr if already mounted + * Remove current uploaders, all of which have retired + + [ Andreas Henriksson ] + * Move service control commands to init-system-helpers (Closes: #805487) + - sysv-rc: Drop invoke-rc.d + update-rc.d + - sysvinit-utils: Drop service + - sysv-rc/sysvinit-utils: (Pre-)Depends on init-system-helpers + - sysv-rc: drop now obsolete Conflicts/Replaces file-rc + + -- Ben Hutchings Mon, 18 Jan 2016 14:39:32 +0000 + +sysvinit (2.88dsf-59.2) unstable; urgency=medium + + * Non-maintainer upload. + + [ Martin Pitt ] + * Previous version introduced a circular dependency sysvinit-utils → + util-linux → initscripts → sysvinit-utils. Drop sysvinit-utils' versioned + Depends: on util-linux again and replace with versioned Breaks:. + This fixes debootstrap troubles like LP: #1456670. + * service, invoke-rc.d: Don't ignore systemd unit dependencies in "degraded" + mode. Followup fix for #777113, see LP: #1429734. + * Drop 91_sulogin_lockedpw.dpatch: Obsolete now that we ship sulogin from + util-linux. + + [ Andreas Henriksson ] + * Update dependency for /bin/mountpoint being moved to util-linux instead + of mount. Use breaks instead of depends to avoid circular dependency. + + -- Martin Pitt Thu, 21 May 2015 13:33:26 +0200 + +sysvinit (2.88dsf-59.1) unstable; urgency=medium + + * Non-maintainer upload. + + [ Martin Pitt ] + * service, invoke-rc.d: Avoid deadlocks during bootup and shutdown from + units/hooks which call "invoke-rc.d service reload" and similar, since the + synchronous wait plus systemd's normal behaviour of transactionally + processing all dependencies first easily causes dependency loops. Thus + during boot/shutdown operate only on the unit and not on its dependencies, + just like SysV behaves. (Closes: #777113) + * Make sysvinit-utils and sysv-rc break systemd << 215 to ensure we have the + "systemctl is-system-running" command. + + [ Andreas Henriksson ] + * Let mount (src:util-linux) provide mountpoint (Closes: #399608) + * Let util-linux provide sulogin, last, lastb, mesg (Closes: #784567) + + -- Andreas Henriksson Tue, 12 May 2015 11:21:13 +0200 + +sysvinit (2.88dsf-59) unstable; urgency=medium + + * Call 'systemctl daemon-reload' after any insserv call if systemd + is the system init to pick up changes (Closes: #766429, #774799) + + -- Adam Conrad Mon, 06 Apr 2015 10:44:47 -0600 + +sysvinit (2.88dsf-58) unstable; urgency=low + + * Fix typo in invoke-rc.d breaking upstart installations (Closes: + #768496). + + -- Petter Reinholdtsen Tue, 11 Nov 2014 20:34:18 +0100 + +sysvinit (2.88dsf-57) unstable; urgency=low + + * Upload to unstable. + + -- Petter Reinholdtsen Sun, 26 Oct 2014 18:36:37 +0100 + +sysvinit (2.88dsf-56) experimental; urgency=medium + + [ Dimitri John Ledkov ] + * service & invoke-rc.d: in upstart interfacing code, check that the job + is actually known to upstart. This is because during upgrades, pid 1 + might still be an older upstart which may not yet support syntax of + the newly unpacked jobs, thus sysv-init script should be continued to + be used instead. (Closes: #745503) + * service & invoke-rc.d: unset UPSTART_SESSION environment variable to + make sure all upstart initctl commands are executed against system + init and not the session one. (Closes: #745505) + * service: in upstart interfacing code, map "force-reload" to restart as + per Debian policy 9.3.2, since there is no way to know for-sure if a + reload is supported (Closes: #746795). + + [ Petter Reinholdtsen ] + * Adjust the sysvinit/hurd-fix-inittab debconf template to no longer + claim sysvinit have never been used on hurd. It is not true any + more. + + [ Steve Langasek ] + * Add necessary Conflicts/Replaces against systemd-sysv and upstart to + sysvinit-core. Closes: #751589. + * Confirm SRU fixing circular dependency of mountnfs ifupdown hook when + running with systemd. Closes: #746587. + + [ Petter Reinholdtsen ] + * Update Vcs links in control file to the correct paths. + * Correct code in update-rc.d looking for insserv to look in + /usr/lib/insserv/insserv every time insserv is used, not only + only one of the relevant code blocks. + + -- Petter Reinholdtsen Sat, 25 Oct 2014 23:33:38 +0200 + +sysvinit (2.88dsf-55.3) experimental; urgency=medium + + * Non-maintainer upload. + * Since the new "init" metapackage has taken over the role to ensure an init + system is installed at all times, drop the Essential: yes flag from + sysvinit and demote its priority to optional so this package is no longer + pulled in on new installations on Linux. Make sysvinit depend on "init" so + this new package is installed on upgrades. + * Provide a fallback SysV init binary in the sysvinit package which can be + used to boot the system via init=/lib/sysvinit/init even if systemd is the + default init system and /sbin/init is provided by systemd-sysv. + * Demote the priority of sysvinit-core to extra so it is no longer installed + by default on Linux. + + -- Michael Biebl Sun, 03 Aug 2014 21:06:44 +0200 + +sysvinit (2.88dsf-55.2) experimental; urgency=medium + + * Fix a formatting error in mountnfs which turned a tab character into + U+21A6. + + -- Michael Biebl Sun, 08 Jun 2014 01:22:37 +0200 + +sysvinit (2.88dsf-55.1) experimental; urgency=medium + + * Non-maintainer upload. + * Skip the mountnfs hook when being triggered by the networking SysV init + script and instead use the systemd built-in mechanisms to mount remote + file systems. + This avoids a deadlock caused by the rpcbind SysV init script depending + on $network and the $network LSB facility being provided by the networking + SysV init script. (Closes: #746587) + + -- Michael Biebl Fri, 06 Jun 2014 12:59:06 +0200 + +sysvinit (2.88dsf-55) experimental; urgency=medium + + [ Gabriele Giacone ] + * sysv-rc: + - On hurd, fix hurd-console addition to inittab if inittab is already + existent and fix getty pathnames in commented out lines as well + (Closes: #745260). + + [ Petter Reinholdtsen ] + * Drop sysv-rc-conf as suggests. It do not work with dependency based + boot ordering. + * Adjust initscripts.postinst to use --compare-versions checks that + cause relevant code to only run on upgrades, and not on first time + install, fixing debootstrap fakechroot failure (Closes: #720584). + Patch from Andreas Mohr. + * Add 'status' support to all init.d scripts (Closes: #641669). + Based on patch from Peter Eisentraut. + + -- Petter Reinholdtsen Mon, 21 Apr 2014 10:12:00 +0200 + +sysvinit (2.88dsf-54) experimental; urgency=medium + + [ Justus Winter ] + * hurd-i386 runsystem.sysv: honor init=something in the kernel command line + (Closes: #742615). + + [ Petter Reinholdtsen ] + * Look for insserv /usr/lib/insserv/insserv and /sbin/insserv, to + handle newer insserv packages where it no longer is in the default + PATH. + * Let the service script pass environment variables LANGUAGE, + LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, + LC_MESSAGES, LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, + LC_MEASUREMENT, LC_IDENTIFICATION and LC_ALL (in other word, all + locale related environment variables) in addition to LANG to the + init.d scripts, in accordance with the principle of least surprise + (Closes: #606875). + * Change checkfs/checkroot and avoid printing the kernel command line + during boot if forcefsck is set (Closes: #587954). + + -- Petter Reinholdtsen Thu, 17 Apr 2014 15:01:34 +0200 + +sysvinit (2.88dsf-53.4) unstable; urgency=medium + + * Added bootlogd patch to output on multiple consoles (Closes: #181756). + + -- Thomas Goirand Sun, 24 Aug 2014 20:22:42 +0000 + +sysvinit (2.88dsf-53.3) unstable; urgency=medium + + * Non-maintainer upload. + * Since the new "init" metapackage has taken over the role to ensure an init + system is installed at all times, drop the Essential: yes flag from + sysvinit and demote its priority to optional so this package is no longer + pulled in on new installations on Linux. Make sysvinit depend on "init" so + this new package is installed on upgrades. + * Provide a fallback SysV init binary in the sysvinit package which can be + used to boot the system via init=/lib/sysvinit/init even if systemd is the + default init system and /sbin/init is provided by systemd-sysv. + * Demote the priority of sysvinit-core to extra so it is no longer installed + by default on Linux. + + -- Michael Biebl Sun, 03 Aug 2014 19:29:38 +0200 + +sysvinit (2.88dsf-53.2) unstable; urgency=medium + + * Fix a formatting error in mountnfs which turned a tab character into + U+21A6. + + -- Michael Biebl Sun, 08 Jun 2014 01:13:48 +0200 + +sysvinit (2.88dsf-53.1) unstable; urgency=medium + + * Non-maintainer upload. + * Skip the mountnfs hook when being triggered by the networking SysV init + script and instead use the systemd built-in mechanisms to mount remote + file systems. + This avoids a deadlock caused by the rpcbind SysV init script depending + on $network and the $network LSB facility being provided by the networking + SysV init script. (Closes: #746587) + + -- Michael Biebl Fri, 06 Jun 2014 12:56:54 +0200 + +sysvinit (2.88dsf-53) unstable; urgency=medium + + [ Gabriele Giacone ] + * Make Vcs-Git field canonical. + + [ Petter Reinholdtsen ] + * Upload startpar split to unstable. + + -- Petter Reinholdtsen Mon, 07 Apr 2014 11:24:52 +0200 + +sysvinit (2.88dsf-52) experimental; urgency=low + + * Upload to experimental to test the startpar migration. + * Replace debian/watch with file available from + http://qa.debian.org/cgi-bin/watchfile.cgi?package=sysvinit . + * Make sure init-d-script exit at the end, to make sure init.d script + is only sourced once. + * kFreeBSD can not use a script as an interpreter. Rewrite + init.d/skeletop to source /lib/init/init-d-script instead + (Closes: #739604). + * Adjust /lib/init/init-d-script to specify --exec when starting and + stopping using start-stop-daemon, and add $START_ARGS and $STOP_ARGS + to allow init.d scripts to add arguments to the start-stop-daemon calls. + * Split startpar out from sysvinit-utils and into its own separate + package. + * Make sure sysvinit-utils depend on startpar, to make sure some startpar + implementation is available before sysvinit-utils is upgraded to a version + without it. + * Make sure sysv-rc depend on startpar. + + -- Petter Reinholdtsen Fri, 28 Mar 2014 14:19:58 +0100 + +sysvinit (2.88dsf-51) unstable; urgency=low + + * Corrected tmpfs(5) manual page to correctly state when /tmp is not + mounted as tmpfs (Closes: #703833). Patch from Charles Plessy. + * Add SEE ALSO fsck(8) to rcS(5) manual page (Closes: #686701). + Patch from Regid Ichira. + + -- Petter Reinholdtsen Thu, 13 Feb 2014 11:51:12 +0100 + +sysvinit (2.88dsf-50) experimental; urgency=low + + [ Thomas Goirand ] + * Added maintenance of /run/openrc/started symlinks in the "service" shell + tool. + + [ Petter Reinholdtsen ] + * Added code to install startpar-upstart-inject.8 manual page in + sysvinit-utils. + * Transform init.d/skeleton into an init.d script interpreter + /lib/init/init-d-script in sysvinit-utils that can be reused by other + init.d scripts to avoid duplicate code (Closes: #464854). See + init-d-script(5) for how to use it. + * Rewrite service to detect status support by running scripts with + 'status' as the argument, and look for usage description. + * Make sure initscripts depend on sysvinit-utils (>= 2.88dsf-50) to + have the new /lib/init/init-d-script interpreter available. + + -- Petter Reinholdtsen Mon, 10 Feb 2014 00:25:10 +0100 + +sysvinit (2.88dsf-49) unstable; urgency=low + + * Document the meaning of +, - and ? for service --status-all in + service(8) (Closes: #699529). + * Make the service command better at finding scripts with status + support (Closes: #619582). Patch from Hamish Downer. + * New patch 95_kfreebsd_bootlogd.patch improving bootlogd behaviour + on kFreeBSD (Closes: #576443). Patch from Mats Erik Andersson. + * Update debian/watch file to use the new upstream location linked to + from http://savannah.nongnu.org/projects/sysvinit . + * Update meta information about patches applied upstream. + * Adjust the sysvinit/hurd-fix-inittab debconf template text to + avoid asking a question in the extended description. Thanks + Lintian. + + -- Petter Reinholdtsen Sat, 08 Feb 2014 00:49:41 +0100 + +sysvinit (2.88dsf-48) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Tell init.d/umountfs to not umount /dev/vcs, as it break the console + on Hurd. Patch from Samuel Thibault. + + [ Samuel Thibault ] + * Add Hurd -s boot flag parsing. + * Make Hurd's boot runsystem use shell wait loop instead of sleep, which seems + to also suffer from the race. + + -- Petter Reinholdtsen Thu, 06 Feb 2014 18:34:50 +0100 + +sysvinit (2.88dsf-47) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Make fastboot detection more robust (Closes: #734901). + + -- Petter Reinholdtsen Tue, 04 Feb 2014 12:55:45 +0100 + +sysvinit (2.88dsf-46) experimental; urgency=medium + + [ Thomas Goirand ] + * Uploading to Experimental. + * Added myself as uploader (after Petter advised for it). + * Refreshed patches. + + [ James McCoy ] + * sysv-rc: + - Update invoke-rc.d and service to trim .sh from service names when + calling systemctl. (Closes: #726483) + + [ Roger Leigh ] + * sysv-rc: + - Remove obsolete/broken update-rc.d usage information from + update-rc.d(8) and update-rc.d itself (Closes: #736060). Thanks + to Julian Gilbey for finding these bugs. + * initscripts: + - mountkernfs mounts configfs on /sys/kernel/config when available. + + [ Justus Winter ] + * Fixes for Debian/Hurd (Closes: #737073, #721917). + - mount-functions.sh: Hurd has a tmpfs translator now, remove + workaround. + - mount-functions.sh: Add -ocompatible to procfs mounts on Hurd. + - mountall.sh: Use pidof -s /sbin/init for robustness. + - checkroot.sh: Only run rootcheck on Linux. Neither kFreeBSD nor + Hurd have /dev/root and the device ids used here are specific to + Linux. + - killall5.c: Use sysconf(_SC_SYMLOOP_MAX) instead of MAXSYMLINKS. + Fixes build on Hurd. + - sysvinit.postinst: Fix file name of gettys in /etc/inittab on + Hurd. + - Break hurd << 0.5.git20131101~. Older versions of the hurd + package lack the necessary functionality to boot Debian/Hurd + using sysvinit. + - Add runsystem.sysv that uses sysvinit to boot Debian/Hurd. + + [ Petter Reinholdtsen ] + * Updated Japanese debconf translations from Hideki Yamane + (Closes: #705132). + * Added getty on the Mach console in the Hurd inittab. Patch from + Samuel Thibault. + * Completed Norwegian Bokmål debconf translation. + + [ Gabriele Giacone ] + * Bump Standards-Version to 3.9.5 (no changes). + * sysv-rc: + - Remove leftover from .legacy-bootordering flagfile removal (#668312) + (Closes: #691210) + + -- Petter Reinholdtsen Fri, 31 Jan 2014 20:48:39 +0100 + +sysvinit (2.88dsf-45) unstable; urgency=medium + + * Add upstart support to update-rc.d enable/disable. Closes: #733289. + + -- Steve Langasek Sun, 29 Dec 2013 09:37:40 +0000 + +sysvinit (2.88dsf-44) unstable; urgency=low + + [ Roger Leigh ] + * initscripts: + - Mount pstore on /sys/fs/pstore (Closes: #722179). + + [ Andrew Shadura ] + * initscripts: + - Use ifquery --state instead of parsing ifstate manually. + - Update Breaks for ifupdown. + + [ Steve Langasek ] + * Move sysvinit functionality into a new binary package, sysvinit-core, + and have sysvinit depend on an ORed list of the available + implementations of /sbin/init. Since sysvinit is an Essential: yes + package, this is the only away to allow users to cleanly switch between + init systems without having to go through a multi-release-cycle + transition. Closes: #728566. + + -- Steve Langasek Thu, 26 Dec 2013 11:09:49 -0800 + +sysvinit (2.88dsf-43) unstable; urgency=low + + [ Roger Leigh ] + * sysv-rc: update-rc.d only depends upon modules from perl-base. + Closes: #716923. Thanks to Michael Stapelberg for this patch. + + -- Roger Leigh Sun, 14 Jul 2013 22:02:11 +0100 + +sysvinit (2.88dsf-42) unstable; urgency=low + + [ Roger Leigh ] + * Introduce jessie changes from 2.88dsf-41+jessie1 to unstable. + * Correct the Breaks on bootchart to ensure that all broken + versions are removed on upgrade (Closes: #694252). Break + bootchart << 0.10~svn407-4 to ensure that 0.10~svn407-3.3 + and earlier are removed. + * Clean up legacy migration logic in maintainer scripts and init + scripts for /run, /lib/init/rw, /etc/mtab, /etc/motd. + * Don't generate debian/copyright; include missing bits of + COPYRIGHT directly. + * Upgrade to Standards-Version 3.9.4 (no changes). + * Add lintian overrides for init script dependency warnings; + these don't apply to our scripts since they have special + dependency requirements. + * bootlogd: Ensure boot logs are flushed (Closes: #423528). Save + logs in /run/bootlog and copy to /var/log/boot at the end of the + boot sequence. + * sysv-rc: + - update-rc.d no longer supports non-dependency-based boot. + + Remove non-insserv codepaths. + + Warn if the start or stop actions are used. + + Skip runlevel mismatch warnings if default action is used + (no arguments to validate). + + Update manual page to remove start and stop actions, plus + manual setting of boot sequence ordering; note that start + and stop are no longer supported. Closes: #606505. + * initscripts: + - Remove static runlevels from update-rc.d calls in postinst. + - checkroot.sh skips fsck of btrfs filesystems. Thanks to Ben + Klein for this patch. Closes: #701956. Note that this is + intended to be a workaround until such time btrfs provides a + non-broken fsck.btrfs. + - Remove use of absolute program paths in postinst. + * bootlogd: + - Remove static runlevels from update-rc.d calls in postinst. + + [ Pino Toscano ] + * Update inittab.gnu to the new path of Hurd's getty. + * mount-functions.sh: do not add "nodev" to the mount options also on Hurd, + as this option does not exist there. + + [ Steve Langasek ] + * Kill pointless script-not-executable overrides for things that are not + scripts. + * /etc/default/rcS is a conffile; remove postinst code that attempts to + create it from a non-existent template. + * Relax the Breaks: on upstart for compatibility with Ubuntu. + * Don't duplicate the /etc/default/rcS conffile with a template in the + preinst; unmodified files should just be removed, and created + automatically by dpkg. + * Fix 'service $foo restart' implementation for upstart jobs. + * Update service(8) manpage to document the support for upstart jobs. + * debian/sysv-rc/sbin/invoke-rc.d: replace RUNLEVEL with RUNLEVELHELPER. + Using RUNLEVEL causes spurious failures when invoke-rc.d is invoked + with RUNLEVEL already defined in the environment (as it is e.g. during + bootup) since invoke-rc.d's RUNLEVEL will become an exported variable + at that point and cause /sbin/runlevel to return bad data. (LP: #619246) + Thanks to James Troup for the patch. + * Properly clean up bootlogd conffiles on upgrade using dpkg-maintscript, + instead of leaving them orphaned on the filesystem when the bootlogd + package is not installed. + * Drop maintainer script migration code for versions older than squeeze. + * Mark sysv-rc Multi-Arch: foreign, now that debhelper is generating + versioned dependencies on it, this is important for cross-installability + of packages providing services. Closes: #710304. + * Also mark initscripts Multi-Arch: foreign, for similar reasons. This is + probably less important, given that the number of packages affected is + small and the /run transition is already past, but it is still correct + in its own right so might as well be added. Closes: #677369. + + [ Michael Biebl ] + * Redirect error output from 'initctl version', suppressing warnings when + upstart is installed but not running. Closes: #685779. + + -- Roger Leigh Sat, 13 Jul 2013 21:24:31 +0100 + +sysvinit (2.88dsf-41+jessie1) experimental; urgency=low + + [ Roger Leigh ] + * initscripts: + - Move /etc/nologin and /var/lib/initscripts/nologin to + /run/nologin. This means that nologin is always created on + a writable, available filesystem. Closes: #660862. + - Remove code to generate /etc/mtab. /etc/mtab is now always a + symbolic link to /proc/mounts. Closes: #630723. + - Remove incorrect use of break in case blocks in vars.sh. Thanks + to Raphaël Hertzog for this patch. Closes: #701031. + - /etc/network/if-up.d/mountnfs: Skip lo if already configured. + Closes: #705052. Thanks to Timo Weingärtner. + * sysvinit: + - Document length limit of 127 in inittab process field. Thanks + to Johannes Truschnigg. Closes: #693960. + * sysv-rc: + - Fix typo in invoke-rc.d(8). Closes: #683804. Thanks to + Martin-Éric Racine. + + [ Michael Stapelberg ] + * systemd: update check to look for /run/systemd/system. + Closes: #703571 + * sysv-rc: + - Add systemd support to update-rc.d(8) and invoke-rc.d(8). + Closes: #683084. + - service(8): use systemctl on machines that run systemd. + Closes: #704923 + + -- Roger Leigh Sat, 28 Jul 2012 20:09:11 +0100 + +sysvinit (2.88dsf-41) unstable; urgency=low + + [ Roger Leigh ]: + * sysvinit postinst always creates /etc/inittab if absent during + configuration (Closes: #700051). + + -- Roger Leigh Thu, 07 Feb 2013 23:32:12 +0000 + +sysvinit (2.88dsf-40) unstable; urgency=low + + [ Roger Leigh ]: + * Don't restart init on GNU/Hurd (Closes: #663009). + * Handle PID detection more robustly, to work better with containers + (Closes: #699523). Always use PID1, which avoids the need for + fragile pidof usage. + * Handle ischroot more gracefully on failure (Closes: #699566). + + -- Roger Leigh Sun, 03 Feb 2013 14:52:05 +0000 + +sysvinit (2.88dsf-39) unstable; urgency=low + + [ Roger Leigh ]: + * initscripts postinst calls urandom, not urandom.sh (Closes: #698966). + * sysvinit postinst unconditionally creates a compatibility initctl + link to ensure the migration to /run won't fail (Closes: #663009). + + -- Roger Leigh Sat, 26 Jan 2013 12:09:29 +0000 + +sysvinit (2.88dsf-38) unstable; urgency=low + + [ Roger Leigh ]: + * If pidof fails in the sysvinit postinst or initscripts, default + to PID 1 (for /sbin/init) (Closes: #663009). + * Make fstab globbing in initscripts completely robust. + + -- Roger Leigh Wed, 23 Jan 2013 22:43:55 +0000 + +sysvinit (2.88dsf-37) unstable; urgency=low + + [ Roger Leigh ] + * initscripts: Remove all use of shell heredocs in shell libraries; + these require a writable /tmp which will not be guaranteed to be + present in early boot (Closes: #697994). + + -- Roger Leigh Mon, 14 Jan 2013 21:53:59 +0000 + +sysvinit (2.88dsf-36) unstable; urgency=low + + [ Roger Leigh ] + * initscripts: + - Handle globbing of /etc/fstab.d/* safely. + - Correct erroneous error that an entry for /dev/shm existed in + /etc/fstab when no entry was present (Closes: #697537). + + -- Roger Leigh Fri, 11 Jan 2013 23:36:28 +0000 + +sysvinit (2.88dsf-35) unstable; urgency=low + + [ David Prévot ] + * Fix German translation charset. + + [ Roger Leigh ] + * initscripts: + - To permit enabling of dependency-based boot, add Breaks on older + versions of bootchart. Thanks to Andreas Beckmann. + Closes: #694252. + - To work around a bug in the Oracle database, which has a faulty + check for /dev/shm, continue to mount a tmpfs on /dev/shm rather + than /run/shm if one is defined in /etc/fstab. Closes: #694379. + * sysvinit-utils: + - Add Breaks: upstart (<< 1.5-1) to avoid breaking the boot with + older versions of upstart. Closes: #694961. + + -- Roger Leigh Mon, 17 Dec 2012 22:50:49 +0000 + +sysvinit (2.88dsf-34) unstable; urgency=low + + [ Roger Leigh ] + * initscripts: Don't run mountall until checkroot-bootclean is finished. + + [ Steve Langasek ] + * initscripts.postinst: hide from lintian the fact that we're removing + /dev/shm, since otherwise a buggy lintian check prevents us from + uploading legitimate code to the archive. + + -- Steve Langasek Fri, 16 Nov 2012 14:51:06 -0600 + +sysvinit (2.88dsf-33) unstable; urgency=low + + [ David Prévot ] + * Updated debconf translations: + - es. Thanks to Javier Fernández-Sanguino. Closes: #686774, #682560. + - pt_BR. Thanks to Adriano Rafael Gomes. Closes: #686906. + + [ Roger Leigh ] + * All bootclean scripts run before bootmisc. Closes: #677097. + + [ Steve Langasek ] + * when running under upstart, emit an 'unmounted-remote-filesystems' event + when we're done unmounting in umountnfs.sh so that upstart can finish + shutting down. + * make the startpar bridge track stopped jobs, not just started ones; + required for us to have a smooth event-based shutdown with upstart. + + -- Steve Langasek Fri, 16 Nov 2012 04:30:29 -0800 + +sysvinit (2.88dsf-32) unstable; urgency=low + + [ Roger Leigh ] + * Apply patch to startpar to prevent the use of mlockall on + kFreeBSD, which was causing a kernel panic at boot. Thanks to + Petr Salinger for this patch. Closes: #672959. + * Correctly detect service availability with service(8). Thanks + to Alexander Golov for this patch. Closes: #685212. + + -- Roger Leigh Fri, 31 Aug 2012 23:03:14 +0100 + +sysvinit (2.88dsf-31) unstable; urgency=low + + [ Roger Leigh ] + * initscripts: + - Remove debugging echo statement from postinst. + + -- Roger Leigh Sat, 11 Aug 2012 18:27:50 +0100 + +sysvinit (2.88dsf-30) unstable; urgency=low + + [ Roger Leigh ] + * initscripts: + - Fix /dev/shm to /run/shm migration bug which occurred in chroots + when /dev/shm was a mountpoint but /dev was not. Check + specifially for /dev, /dev/shm, run or /run/shm being a mountpoint + before attempting to migrate. This copes with all combinations of + mountpoints, directories and symlinks. Closes: #683103. + + -- Roger Leigh Sat, 11 Aug 2012 16:44:22 +0100 + +sysvinit (2.88dsf-29) unstable; urgency=low + + [ Steve Langasek ] + * initscripts: + - Improve /dev/shm to /run/shm upgrade handling in the postinst + (improvement for #674178). + + [ Roger Leigh ] + * initscripts: + - Remove /lib/init/rw if possible. Closes: #679612. + - If /run is a symlink to /var/run, correct this on both upgrade + and on boot. On upgrade, the proper /run migration will occur + on reboot. On boot, the system will require rebooting to fully + migrate /run to a working configuration (but this will only + occur on systems which are already broken, it's not an upgrade + path). This correct problems with udev breakage due to /run + being mounted twice when /run is a symlink. + Closes: #677097, #679523. + - Start urandom on initial install, so that a random seed exists on + first boot. Closes: #679972. + - Restore creation of /var/log/dmesg (Closes: #681639). + * sysv-rc: + Remove unused debconf logic in postinst. + + -- Roger Leigh Sat, 30 Jun 2012 23:21:06 +0100 + +sysvinit (2.88dsf-28) unstable; urgency=low + + [ Steve Langasek ] + * debian/patches/upstart_support.patch: add missing + startpar-upstart-inject manpage. + + [ Roger Leigh ] + * Updated debconf translations: + - ca. Thanks to Innocent De Marchi. Closes: #677904. + - cs. Thanks to Miroslav Kure. Closes: #678680. + - da. Thanks to Joe Hansen. Closes: #676893. + - de. Thanks to Chris Leick. Closes: #677753. + - fr. Thanks to Steve Petruzzello. Closes: #677590. + - gl. Thanks to Jorge Barreiro. Closes: #678627. + - nl. Thanks to Jeroen Schot. Closes: #677333. + - pl. Thanks to Michał Kułach. Closes: #676773. + - pt. Thanks to Miguel Figueiredo. Closes: #676814. + - ru. Thanks to Yuri Kozlov. Closes: #677011. + - sk. Thanks to Slavko. Closes: #676721. + - sv. Thanks to Martin Bagge. Closes: #676791. + - zh_CN. Thanks to YunQiang Su. Closes: #676725. + * Add missing hardening CPPFLAGS. Thanks to Simon Ruderich. + Closes: #678878. + * Update clean run to cope with nonexistent startpar. + * initscripts: + - Only run update-rc.d in maintainer scripts when the init + script exists and is executable. Closes: #671124. + - Break initramfs-tools (<< 0.104), needed to prevent initrd + generation failure since older initramfs-tools can't cope with + /etc/mtab being a symlink. Closes: #668650. + - Don't mount with -o nodev on kFreeBSD. Closes: #669162. + - Set up /run correctly in a chroot when running debootstrap. + Thanks to Serge Hallyn. initscripts.postinst: if /dev is not a + separate partition and we're in a chroot, then create /run/shm + and make /dev/shm a symbolic link to it, as we would expect to + find in a upgraded and rebooted running system. LP: #974584. + Closes: #674178. + * sysvinit: + - rc and startpar distinguish between LSB not installed and + not configured failure conditions. Thanks to Nate Coraor. + Closes: #625463. + * sysv-rc: + - Dependency-based booting is activated unconditionally. Scripts + without LSB headers will generally be ordered after all other + scripts, but before scripts requiring $all to be started, such as + rc.local, but this is not guaranteed. Add an LSB header if you + need to guarantee the ordering of scripts. + Closes: #676463, #678231, #676473. + - update-rc.d uses absolute path to insserv, to give better error + messages to non-root users where /sbin is not in the PATH. + Thanks to Regid Ichira. Closes: #637390. + + [ Paul Menzel ] + * Fix usage message in /etc/init.d/motd. Closes: #676910. + + -- Roger Leigh Wed, 27 Jun 2012 23:00:45 +0100 + +sysvinit (2.88dsf-27) unstable; urgency=low + + [ Salvatore Bonaccorso ] + * Remove reference to /usr/share/initscripts/default.rcS. + With commit d0388ba464e69b1b7915a3d9071cfcba21d0102c /etc/default/rcS + was made a regular conffile. Remove reference to original location with + default values. + + [ Roger Leigh ] + * initscripts: + - Don't fail in the absence of /proc/meminfo. The ram_size and + swap_size functions in /lib/init/tmpfs.sh always return true. + Closes: #676669. + + -- Roger Leigh Fri, 08 Jun 2012 22:29:04 +0100 + +sysvinit (2.88dsf-26) unstable; urgency=low + + [ Roger Leigh ] + * initscripts: + - /run/shm is mounted noexec. Closes: #386368. + - The RAMSHM and RAMTMP settings in /etc/default/rcS are used if + present, though the replacement settings in /etc/default/tmpfs + will override these, if enabled. + - Revert RAMTMP setting to be disabled by default. + Closes: #630615, #665635, #666698, #674517. + - Don't prompt the user on upgrade if rcS was not modified by + the admin. Closes: #674460. + * sysvinit-utils: + - Fix typo in fstab-decode(8). Thanks to Bjarni Ingi Gislason. + Closes: #674208. + + -- Roger Leigh Mon, 28 May 2012 17:58:38 +0100 + +sysvinit (2.88dsf-25) experimental; urgency=low + + [ Roger Leigh ] + * Build with hardening flags enabled; CFLAGS and LDFLAGS are passed + to all build commands. + * initscripts: + - /etc/default/rcS is no longer managed by ucf, and is a regular + conffile. Drop the UTC setting, which has been migrated to + /etc/adjtime by util-linux. Break util-linux << 2.20.1-5 in order + to ensure correct migration of the UTC setting before the file is + upgraded. + - Use ifquery in /etc/network/if-up.d/mountnfs to replace complex + parsing. Also only run if inet or inet6 interfaces have been + configured, to avoid freezing when the interface hasn't yet + been configured (Closes: #674039). + - %VM tmpfs size calculation works when swap is disabled. + + -- Roger Leigh Tue, 22 May 2012 23:46:14 +0100 + +sysvinit (2.88dsf-24) experimental; urgency=low + + [ Roger Leigh ] + * initscripts: + - Don't generate or touch /etc/motd. Instead, the dynamic part of + /etc/motd is created as /run/motd.dynamic, leaving /etc/motd + entirely under the control of the system administrator. If + /etc/motd is a symlink to /run/motd, /etc/motd.tail is moved + back to /etc/motd. Closes: #353229, #624391, #668307. /etc/motd + is not removed if initscripts is purged, since it's not owned by + initscripts. + - By default, /run/motd is just the output of uname, preserving the + existing behaviour. However, should the administrator wish to + include dynamic information in the motd, they may write scripts + to update /run/motd.dynamic as they please. Closes: #437176. + - motd generation is split from bootlogs into a separate motd + init script. + - bootlogs init script has been removed; current logging daemons + handle this themselves, making this script redundant. + - tmpfs mounts are never cleaned by bootclean.sh. Cleaning /run + can lead to nonfunctional input when Xorg starts. Closes: #669949. + * sysvinit-utils: + - Suggest rather than Recommend bootlogd. + + [ Kel Modderman ] + * sysv-rc: + - Run check_divert in postinst to make sure /usr/sbin/update-rc.d + not symlinked to /usr/sbin/update-rc.d-insserv. Closes: #670085. + + [ Steve Langasek ] + * Install the startpar bridge now that dh_installinit in Debian handles + this. Closes: #660824. + * Give startpar a listening backlog on its socket for upstart connections, + since there's no protocol-level queuing for unix sockets and these + connections tend to come in fast and furious at boot. + * Add upstart support to invoke-rc.d, per the policy discussion in bug + #591791. Closes: #671284. + + -- Roger Leigh Sun, 29 Apr 2012 23:52:14 +0100 + +sysvinit (2.88dsf-23) experimental; urgency=low + + [ Roger Leigh ] + * Acknowledge NMU for translation updates. Thanks to Christian + Perrier. + * debian/control: + - Upgrade to Standards-Version 3.9.3. + - Build-Depend on debhelper v9. + - Correct Vcs-Git URL. + * debian/rules: + - Use DEB_HOST_ARCH_OS = hurd rather than + DEB_HOST_ARCH = hurd-i386. Thanks to Pino Toscano. + * debian/patches: + - 11_lfs_cflags.patch: Add patch for enabling large file support, + needed on GNU/Hurd, but useful for all platforms. + - 73_lfs_cflags.patch: Add patch for enabling large file support + in startpar. + * initscripts: + - Moved RAM* settings from /etc/default/rcS to /etc/default/tmpfs. + This ensures that the settings are equivalent for upgrades and + new installations, but will require manual configuration of the + settings for upgrades (no migration from /etc/default/rcS to + /etc/default/tmpfs will take place, due to tmpfs being a + conffile). tmpf(5) manual page added to document all aspects + of tmpfs configuration, including the existing documentation in + rcS(5). + - Drop the use of .ramfs dotfiles in /run and /run/lock. These + were a legacy of /lib/init/rw and were not actually used by + anything. Closes: #403863. + - Drop /etc/init.d/mountoverflowtmp. This has been merged into + the general tmpfs on /tmp handling functions. This means the + generic RAMTMP configuration is used for the overflowtmp. + Closes: #567539. + - It is now possible to configure a tmpfs mount size limit as a + percentage of the total VM size (%VM) as well as a percentage + of the RAM size (%). This is computed by tmpfs.sh and the + tmpfs mounts are remounted with the updated size limit after + swap becomes available. + - An fstab entry for /tmp overrides RAMTMP. Document tmpfs + override and tmpfs defaults in tmpfs(5), also undeprecating the + tmpfs settings. Closes: #585540, #665995. + - An fstab entry for /run/lock or /run/shm overrides RAMLOCK and + RAMSHM. + - bootclean cleans /tmp, /run and /run/lock before any filesystems + are mounted as well as after local and network mounts. This + permits cleaning of directories which would otherwise be hidden + by mountpoints later in the boot process. + Closes: #55707, #558000, #666871. Additionally clean up + /lib/init/rw in case any files were hidden by the (now removed) + tmpfs mount at this location. Closes: #652625. + - Removed last trace of the long-removed EDITMOTD from the + postinst. Closes: #438895. + - Removed documentation of #346342 in rcS(5). This is no longer + an issue now tzdata keeps a copy of the data on the rootfs. + Closes: #385172. + - Correct description of TMPTIME in rcS(5). Thanks to Alan J. + Greenberger. Closes: #562500. + - urandom: Applied a series of patches from John Denker to + improve the integrity of random number generation. Many thanks. + Closes: #596479, #596480, #596481, #596482, #596483. + * sysv-rc: + - Remove old upgrade logic from maintainer scripts not required + for wheezy. + - Migrate users of obsolete static boot ordering to dynamic boot + ordering. + - Remove use of /etc/init.d/.legacy-bootordering. Closes: #668312. + - Improve help text of debconf message when it is not possible to + automatically enable dynamic boot ordering. Provide explicit + instructions for how to purge obsolete init scripts. + Closes: #550425. + - etc/init.d/rc: Ensure linprocfs is mounted on kFreeBSD. Thanks + to Robert Millan. Closes: #659480. + - Drop undocumented CONCURRENCY setting from /etc/init.d/rc. + Closes: #518249, #540448, #539261. Note that this still contains + internal fallbacks to support non-insserv booting, which may be + removed at a later date. + - invoke-rc.d: + + Minor manual page corrections. Thanks to Anthony Fiumara. + Closes: #664816. + + Remove mention of the "dpkg Programmers' Manual" and replace + with references to Debian Policy. Closes: #543793. + - update-rc.d: + + Correctly warn about non-LSB standard runlevels. Thanks to + Chris Hiestand for this patch. Closes: #614895. + + Remove obsolete documentation of + /var/lib/sysv-rc/legacy-bootsequence. Thanks to Thomas Hood. + Closes: #623051. + * sysvinit: + - Minor corrections for halt(8) manual page. Thanks to + Christoph Anton Mitterer. Closes: #587923. + - Installation with debootstrap --variant=fakechroot now works, due + to only migrating the old control channel when it is still + present. Thanks to Michael Gilbert. Closes: #596284. + * sysvinit-utils: + - Recommend bootlogd. Closes: #659490. This means that booklogd + will be installed by default, but will be removable. + Closes: #232569. + - Correct documentation of the startpar -i option. Closes: #545438. + - Correct startpar(8) SEE ALSO section. Closes: #634146. + - Correct wording in service(8). Thanks to Joey Hess and Regid + Ichira. Closes: #545401, #667745. + + [ Steve Langasek ] + * debian/service/service: fix upstart compatibility to not try to use the + upstart commands when init isn't upstart. Closes: #636054. + * debian/rules: pass CFLAGS when building startpar. + * Fix startpar to not run init scripts that have matching upstart jobs, + instead waiting for a signal from upstart. Closes: #660824. + * sysvinit: + - Don't restart or perform initctl migration if systemd is + running. + + -- Roger Leigh Sat, 21 Apr 2012 12:11:45 +0100 + +sysvinit (2.88dsf-22.1) unstable; urgency=low + + * Non-maintainer upload. + * Fix pending l10n issues. Debconf translations: + - Dutch; (Jeroen Schot). Closes: #626270 + - Polish (Michał Kułach). Closes: #658156 + + -- Christian Perrier Tue, 13 Mar 2012 07:03:06 +0100 + +sysvinit (2.88dsf-22) unstable; urgency=low + + [ Roger Leigh ] + * mountall.sh uses mknod rather than mkfifo (Closes: #658045). + + -- Roger Leigh Mon, 30 Jan 2012 23:44:21 +0000 + +sysvinit (2.88dsf-21) unstable; urgency=low + + [ Roger Leigh ] + * debian/patches/72_path_max.patch: New patch for startpar. Don't + use PATH_MAX, to fix compilation on GNU/Hurd. + + -- Roger Leigh Sat, 28 Jan 2012 11:14:53 +0000 + +sysvinit (2.88dsf-20) unstable; urgency=low + + [ Roger Leigh ] + * debian/patches/71_signalfd.patch: New patch for startpar. Don't + include , which is not used and breaks + compilation on architectures not having this Linux-specific + header. (Closes: #657676) + * sysvinit: + - Don't restart init when a chroot is detected, to avoid lengthy + timeouts. Use ischroot from debianutils to determine whether + the postinst is being run in a chroot environment, as already + done by initscripts. + + -- Roger Leigh Sat, 28 Jan 2012 00:07:39 +0000 + +sysvinit (2.88dsf-19) unstable; urgency=low + + [ Roger Leigh ] + * debian/control: + - initscripts adds versioned Breaks on autofs (<< 5) since + autofs 4.x does not cope with /etc/mtab symlinked to + /proc/mounts. Users should upgrade to autofs5, which works + correctly. (Closes: #653126) + - initscripts Breaks aide << 0.15.1-5 and sysklogd << 1.5-6.2 now + they support /run. + - sysvinit Pre-Depends on initscripts >= 2.88dsf-13.3 in order + to transition initctl to /run. + * sysvinit: + - /sbin/init control channel FIFO is /run/initctl rather than + /dev/initctl (Linux) or /etc/.initctl (FreeBSD). The postinst + migrates the running init to use the new control channel by + replacing the old channel with a symlink prior to issuing a + SIGUSR1 to cause init to reopen its control channel and then + exec of the new version of init using the new path. Thanks + to Robert Millan. (Closes: #638019) + - Add Catalan (ca) translation. Thanks to Innocent De Marchi. + (Closes: #622785) + * sysvinit-utils: + - Upgrade to startpar 0.58. Thanks to Dr. Werner Fink at SuSE for + this updated release. This release incorporates all of the + existing Debian patchset; debian/patches/7[1-9]* have now been + dropped. + * initscripts: + - mountall.sh recreates /run/initctl and sends SIGUSR1 to init + if needed. + - /etc/init.d/rc.local uses only $all in Required-Start; + $remote_fs and $syslog being redundant. Thanks to Regid Ichira. + (Closes: #635025) + - rcS.5 documents that RAMTMP defaults to yes for new + installations, and no for upgrades (since RAMTMP is not present + in /etc/default/rcS). (Closes: #652337) + - /etc/default/rcS is updated using ucf. (Closes: #648433) + - umountfs uses more sophisticated sed expression to compute + PROTECTED_MOUNTS, to support unionfs and more complex cases. + Thanks to Michele Mazzucchi for this patch. (Closes: #655582) + + -- Roger Leigh Sun, 22 Jan 2012 17:07:46 +0000 + +sysvinit (2.88dsf-18) unstable; urgency=low + + [ Roger Leigh ] + debian/rules: Fix FTBFS on Hurd by moving file renaming to a later + point in the build. + + -- Roger Leigh Thu, 22 Dec 2011 22:59:47 +0000 + +sysvinit (2.88dsf-17) unstable; urgency=low + + [ Roger Leigh ] + * debian/control: + - initscripts adds versioned Breaks on readahead-fedora + (<< 2:1.5.6-3), which removed splash support. Thanks to Sven + Joachim. + - Update initscripts Breaks for fixed version of libpam-mount. + * initscripts: + - Document /lib/init/rw removal and cleanup in NEWS. + (Closes: #652512). + - /etc/network/if-up.d/mountnfs handles whitespace correctly + (Closes: #612378). grep on /etc/network/run/ifstate is corrected + (inverted the logic). Thanks to Jamie Heilman and Corey Hickey. + * sysvinit: Install reboot and halt commands with a -sysv suffix + on GNU/Hurd. (Closes: #652830) + + [ Josh Triplett ] + * Split bootlogd into a separate package. (Closes: #545181) + + -- Roger Leigh Thu, 22 Dec 2011 20:58:36 +0000 + +sysvinit (2.88dsf-16) unstable; urgency=low + + [ Roger Leigh ] + * debian/control: + - initscripts versioned Breaks use correct epochs and binary + package names. + - initscripts Breaks libpam-mount <= 2.11-1, which does not + support a read-only mtab. This is supported in new upstream + versions. + + -- Roger Leigh Sat, 17 Dec 2011 15:57:24 +0000 + +sysvinit (2.88dsf-15) experimental; urgency=low + + [ Roger Leigh ] + * /etc/init.d/skeleton: Small whitespace cleanup. Thanks to + Peter Eisentraut. (Closes: #651862) + * Move all patches in debian/startpar/patches to debian/patches + and make debian/startpar/ content a separate patch applied to + startpar/. Build and install startpar in debian/rules. + (Closes: #652097). + + -- Roger Leigh Thu, 15 Dec 2011 00:24:22 +0000 + +sysvinit (2.88dsf-14) experimental; urgency=low + + [ Kel Modderman ] + * Add support for s390x, thanks to Aurelien Jarno . + (Closes: #641107) + + [ Roger Leigh ] + * debian/rules: + - Add build-arch and -indep rules. (Closes: #648472) + - Remove dpatch usage. + - Use dh and debhelper compat level 9. + * debian/control: + - Add git version control information. + - Upgrade to Standards-Version 3.9.2. + - Add myself to Uploaders. + * Use dpkg 3.0 (quilt) source format. Rediffed + debian/patches/40_multiarch_libcrypt.patch which was not well + formed and failed to apply. + * initscripts: + - Make /etc/mtab a symlink to /proc/mounts. (Closes: #494001) + Note that this is only done when the root filesystem is writable + and /proc/mount is readable. + - Support the ceph network filesystem. (Closes: #580579). Thanks + to Sage Weil. + - Restore boot-time cleaning of /var/run and /var/lock, used by + systems which currently do not use a tmpfs for /run. + - Remove /lib/init/rw: Add Breaks for all packages which used + /lib/init/rw, and which now use /run. Unmount and remove + following upgrade. + - Don't create /run/.run-transition on upgrade, only on actually + setting up a transitional bind mount. + - Add Breaks on all packages previously using /lib/init/rw, in + order to permit removal of /lib/init/rw. It is not possible to + remove prior to rebooting due to initscripts being required to + be configured by the packages transitioning to /run. Remove in + wheezy+1. + - Remove trailing period from the initscripts init script log + message. (Closes: #648881). Thanks to Clint Byrum. + - /etc/network/if-up.d/mountnfs: grep: character class syntax is + [[:space:]], not [:space:]. (Closes: #631077, #645655). Thanks to + Milan Kocian and Jan-Benedict Glaw. Also simplify function logic + using a for loop rather than a while loop. Thanks to Corey Hickey. + * sysv-rc: + - Remove splash support and use of removed /dev/.initramfs. + (Closes: #643558). Thanks to Michael Biebl. + + -- Roger Leigh Tue, 13 Dec 2011 20:11:48 +0000 + +sysvinit (2.88dsf-13.13) unstable; urgency=low + + * Non-maintainer upload. + * Replace "cons25" with "xterm" on GNU/kFreeBSD. + + -- Robert Millan Wed, 02 Nov 2011 23:42:14 +0000 + +sysvinit (2.88dsf-13.12) unstable; urgency=low + + * Non-maintainer upload. + * 92_kfreebsd_ifdown.patch: Shut down network interfaces correctly on + GNU/kFreeBSD. Thanks Guillem. (Closes: #606565) + * Replace `ttyd' with `cuau' in inittab for GNU/kFreeBSD. Thanks Tuco. + (Closes: #587162) + * Use linux-any in debian/control to avoid hardcoded lists of non-Linux + arches. (Closes: #634514) + + -- Robert Millan Fri, 14 Oct 2011 23:27:34 +0200 + +sysvinit (2.88dsf-13.11) unstable; urgency=low + + * Non-maintainer upload. + * initscripts provides /run/sendsigs.omit.d as soon as /run is + available. + * initscripts bootlogs: Remove support for /dev/.udev.log, + which is no longer needed now udev uses /run. + * initscripts umountroot: Remove ubuntu-specific patch which + created directories on the root filesystem prior to umounting it. + This was never applicable to Debian, and is now no longer required + following the introduction of /run (Closes: #633541). + + -- Roger Leigh Wed, 13 Jul 2011 19:47:10 +0100 + +sysvinit (2.88dsf-13.10) unstable; urgency=low + + * Non-maintainer upload. + * Correct selinux-policy-default Breaks versioning (use <= rather + than <<). + + -- Roger Leigh Thu, 09 Jun 2011 20:31:00 +0100 + +sysvinit (2.88dsf-13.9) unstable; urgency=low + + * Non-maintainer upload. + * Try both old and multiarch paths to cope with buildds which don't + yet have a multiarch libc installed. + + -- Roger Leigh Thu, 09 Jun 2011 14:50:53 +0100 + +sysvinit (2.88dsf-13.8) unstable; urgency=low + + * Non-maintainer upload. + * initscripts Breaks all selinux-policy-default versions up to and + including 2:0.2.20100524-9, which do not support /run. + * Add restorecon support for selinux to /run in mountkernfs. + (Closes: #628107). Thanks to Martin Orr for this patch. + * Search for libcrypt using multiarch path (Closes: #629677). + + -- Roger Leigh Thu, 09 Jun 2011 13:35:56 +0100 + +sysvinit (2.88dsf-13.7) unstable; urgency=low + + [ Roger Leigh ] + * Non-maintainer upload. + * Correct version check used for reboot notification in initscripts + postinst. + * Don't use "rm -rf" when creating compatibility links in chroots; + use plain rmdir and abort with an error if it fails. This is in + order to avoid removing host data if e.g. /run from the host is + already bind mounted on the chroot /run, which would remove the + contents of the host /run if upgrading initscripts in the chroot. + * Restore rpcbind/portmap changes from 2.88dsf-13.5. + * Add restorecon support for selinux using new paths. (Closes: #626725) + Thanks to Martin Orr for this patch. + * Use new debianutils "ischroot" program to detect if in a chroot in + the initscripts postinst more reliably. Depend on initscripts + version 4 or greater to ensure ischroot is available. + (Closes: #626846) + + -- Roger Leigh Wed, 18 May 2011 23:12:30 +0100 + +sysvinit (2.88dsf-13.6) unstable; urgency=low + + [ Roger Leigh ] + * Non-maintainer upload. + * Don't remount filesystems mounted in the initramfs until mtab + exists. Use the existing reload functionality of mountkernfs + an mountdevsubfs to allow mtab.sh to trigger the remounts. + (Closes: #623174) + * Revert to using absolute paths in compatibility symlinks in order + to comply with Policy §10.5 symlink rules. (Closes: #626263) + * The permissions of /tmp are only set when root is writable. + (Closes: #623934) + + -- Roger Leigh Sat, 14 May 2011 00:30:52 +0100 + +sysvinit (2.88dsf-13.5) experimental; urgency=low + + [ Roger Leigh ] + * Non-maintainer upload. + * Unify mount logic shared between mountkernfs.sh, mountdevsubfs.sh + and mtab.sh + - all functions use domount() from /lib/init/mount-functions. This + merges in the functionality of domtab() in mtab.sh, which was + almost entirely identical. domount is now capable of mounting and + remounting (with and without mtab updates) as well as updating + /etc/mtab. + - mtab.sh calls mountkernfs.sh and mountdevsubfs with an "mtab" + argument to do the mtab generation for early mounts. This means + that the mount logic is not needlessly duplicated, and does not + require two copies to be kept exactly in sync. This reduces the + risk of problems as a consequence of subtle differences between + the two scripts. + - mount options may be specified in either /etc/default/tmpfs or + in /etc/fstab, and will supersede hard coded defaults. The + the values in fstab (if any) will supersede those in + /etc/default/tmpfs should an entry be present. These values are + also used for remounting, which means that filesystems mounted in + an initramfs and moved onto the root filesystem prior to init + starting will be remounted with the correct user-specified + options. + - Improve robustness of stat checks when comparing directories. + - mountkernfs.sh and mountdevsubfs.sh are idempotent, so allow for + repeated invocation. This is needed to allow the same code to + be used for mounting, remounting and mtab generation. + - Enabling RAMLOCK, RAMSHM and RAMTMP in /etc/default/rcS is no longer + required if the filesystems are present in /etc/fstab + * /etc/default/tmpfs is deprecated + - If changing the default size limits, adding an entry to /etc/fstab + is preferred compared with editing /etc/default/tmpfs. This also + permits modifying the default mount options, and setting additional + mount options. + - If /etc/default/tmpfs has been modified from the defaults, any + needed entries will be created in /etc/fstab on upgrade, to + preserve the settings from /etc/default/tmpfs. The entries in + /etc/fstab will subsequently override the settings in + /etc/default/tmpfs. + * The mount options for /run are made stricter when possible. For + example, if /run/shm is a separate filesystem, it may be safely + mounted with "noexec". + * Compatibility symbolic links are relative, not absolute. e.g. + /var/lock is ../run/lock rather than /run/lock. This means that if + you're using a chroot from the host system, you'll always be using + locations in the chroot, rather than the host, when following the + links. + * Updated documentation in initscripts README.Debian and rcS(5). + + [ Kel Modderman ] + * Consider rpcbind as alternative to portmap in mountnfs ifupdown + script. Thanks to Jamie Heilman and Arthur de Jong. + (Closes: #620788) + + -- Roger Leigh Fri, 22 Apr 2011 15:25:25 +0100 + +sysvinit (2.88dsf-13.4) experimental; urgency=low + + [ Roger Leigh ] + * Non-maintainer upload. + + [ Kel Modderman ] + * Remove code from /etc/init.d/bootmisc.sh which is not needed with modern + kernel which do not support BSD ptys. The udev check is not reliable + anymore due to /run/. Thanks Marco d'Itri (Closes: #620784) + * Handle user interupt of fsck in etc/init.d/checkfs.sh and + init.d/checkroot.sh. Trap SIGINT and handle fsck exit status of 32. + (Closes: #608534) + + -- Roger Leigh Sat, 16 Apr 2011 16:50:51 +0100 + +sysvinit (2.88dsf-13.3) experimental; urgency=low + + [ Roger Leigh ] + * Non-maintainer upload. + * Support for new top-level directory /run to replace /var/run, + /var/lock, /dev/shm and /lib/init/rw as a place to store transient + writable data which should not be preserved across a system + reboot (Closes: #186892, #616571, #620191). /run fixes existing + issues with RAMRUN and RAMLOCK options using tmpfs on /var/run and + /var/lock (Closes: #423405, #481546, #564635, #607136, #620735). + Additionally, /run/shm replaces /dev/shm and may share the same + tmpfs as /run if RAMSHM is set to "no" in /etc/default/rcS. /tmp + may also be configured to be a tmpfs if RAMTMP is set to "yes" in + /etc/default/rcS. /tmp may also be configured to use /run directly if + it is symlinked to /run/tmp, for example. + Summary: + /var/run → /run + /var/lock → /run/lock + /dev/shm → /run/shm + /lib/init/rw → /run (not transitioned automatically) + /dev/.* → /run (not transitioned automatically) + These changes do not take effect until the system is rebooted as + is currently done for /lib/init/rw setup. Prior to a reboot, the + paths are made available via bind/nullfs/firmlink mounts, depending on + the platform. Following a reboot, the old paths will be converted to + symlinks, or bind/nullfs/firmlink mounts where symlinking is not + possible, to allow access via either the old or new paths, to permit + programs using the old paths to transition to use the new paths for + wheezy. + - debian/initscripts.postinst: + Take chroot detection logic from udev postinst (existing logic was + broken). Add detection logic for vserver environments and Hurd. + Trigger reboot to complete transition. + If the system has not yet transitioned to a tmpfs-based /run, set up + bind mounts as follows: + /var/run → /run + /var/lock → /run/lock + /dev/shm → /run/shm + On reboot, the system will complete the migration to a tmpfs-based + /run; this creates the directory heierachy from the old paths to + enable the use of the new /run paths prior to a restart. This means + packages may transition to using /run with a versioned dependency + upon initscripts. + Remove special handling for RAMRUN and RAMLOCK, which is now taken + care of by /run. + If in a chroot environment, just create symlinks from the new names + to the existing locations, since otherwise the changes would be + lost, and since rcS scripts aren't run the transition won't + complete. + - debian/src/initscripts/Makefile: + Provide top-level /run. + - debian/src/initscripts/doc/README.Debian: + Document new use of RUN_SIZE and LOCK_SIZE. + Document use of /run rather than /lib/init/rw. + Document use of SHM_SIZE and TMP_SIZE. + - debian/src/initscripts/etc/init.d/checkroot.sh: + Use /run in place of /lib/init/rw. + - debian/src/initscripts/etc/default/tmpfs: + Document TMPFS_SIZE, RUN_SIZE and LOCK_SIZE (Closes: #483643). + Document TMP_SIZE and SHM_SIZE. + - debian/src/initscripts/etc/init.d/mountkernfs.sh: + Create /run, /run/sendsigs.omit.d and /run/lock. + Mount /run/lock as a separate tmpfs if RAMLOCK=yes. + /run/lock has 01777 permissions to match /var/lock. + Mount /tmp as a separate tmpfs if RAMTMP=yes or / is being mounted + read-only (Closes: #503805, #585543). + Drop mounting of /var/run and /var/lock. + - debian/src/initscripts/etc/init.d/mountdevsubfs.sh: + Create /run/shm. Mount /run/shm as a separate tmpfs if RAMSHM=yes. + - debian/src/initscripts/etc/init.d/mtab.sh: + domtab mirrors behaviour of domount in mount-functions exactly, to + prevent duplicate mounts (required for bind mount support). + Bind mount /run/init and drop mounting of /var/run. Mount /run/lock + in place of /var/lock. + Mount /tmp if RAMTMP=yes. + Mount /run/shm if RAMSHM=yes. + - debian/src/initscripts/etc/init.d/sendsigs: + Use new paths: + files: /run/sendsigs.omit /lib/init/rw/sendsigs.omit + dirs: /run/sendsigs.omit.d/ /lib/init/rw/sendsigs.omit.d/ + - debian/src/initscripts/etc/init.d/umountfs: + Ignore /run. Continue to ignore /lib/init/rw in order to handle + clean shutdown. No longer ignore /var/run and /var/lock. + - debian/src/initscripts/etc/init.d/umountnfs.sh: + Check for presence of .ramfs than configuration variable when + skipping /var/run and /var/lock. + Ignore /run. Continue to ignore /lib/init/rw in order to handle + clean shutdown. No longer ignore /var/run and /var/lock. + - debian/src/initscripts/lib/init/bootclean.sh + Don't clean /var/run and /var/lock (Closes: #378776). Because + these directories are now a tmpfs, cleaning no longer makes sense. + - debian/src/initscripts/lib/init/tmpfs.sh: + Read /etc/default/tmpfs and provide defaults if unset. + - debian/src/initscripts/lib/init/mount-functions.sh: + Support bind mounts in domount() (Closes: #353943). + Drop support for mounting /var/run and /var/lock as separate + tmpfs filesystems. Symlink /var/run to /run and /var/lock to + /run/lock if possible. If /var/run and /var/lock are directories, + attempt to remove and symlink if successful, or else bind mount. + - debian/src/initscripts/lib/init/vars.sh: + Read /etc/default/rcS and provide defaults if unset. + - debian/src/initscripts/man/rcS.5: + Drop documentation of RAMRUN. + Update documentation for RAMLOCK (Closes: #406685). + Document RAMTMP and RAMSHM. + - debian/src/initscripts/share/default.rcS: + Remove RAMRUN. + Add RAMSHM and RAMTMP. + RAMLOCK, RAMSHM and RAMTMP default to enabled for new installs. + + [ Michael Biebl ] + * Remove dead usplash support code (Closes: #599241, #599734, #612594). + + [ Martin F. Krafft ] + * Add comments to /etc/default/rcS (Closes: #530582). + + [ Samuel Thibault ] + * Hurd portability for initscripts postinst and init scripts. + Hurd does not currently support tmpfs mounts, but will do in the + future. Use firmlinks in place of bind mounts. + + -- Roger Leigh Sat, 16 Apr 2011 01:17:29 +0100 + +sysvinit (2.88dsf-13.2) unstable; urgency=low + + * Non-maintainer upload. + * Fix pending l10n issues. Debconf translations: + - Danish (Joe Hansen). Closes: #599430 + - Brazilian Portuguese (Adriano Rafael Gomes). Closes: #605851 + - Slovak (Slavko). Closes: #614193 + + -- Christian Perrier Tue, 05 Apr 2011 07:24:09 +0200 + +sysvinit (2.88dsf-13.1) unstable; urgency=low + + * Non-maintainer upload. + * Disable SIGINT for non-interactive init scripts (Closes: #582442) + + -- Ben Hutchings Sat, 01 Jan 2011 03:45:28 +0000 + +sysvinit (2.88dsf-13) unstable; urgency=low + + [ Kel Modderman ] + * Remove runlevel duration printing code from init.d/rc script + as it was scheduled for removal before squeeze and imperfect. + (Closes: #584862) + * Prevent init.d/rc script from executing stop scripts twice + in runlevels 0 and 6 when conccurrent boot is enabled. + (Closes: #594253) + * Modify debian/startpar/patches/06_stdin_notty.patch so it applies + without fuzziness. + * Add debian/startpar/patches/08_kfreebsd_proc_error_debug.patch to + prevent frequent messages on Debian GNU/kFreeBSD from littering boot + messages. Thanks Petr Salinger for the patch. (Closes: #590560) + * Avoid umounting virtual filesystems (eg, cgroup) mounted under + /sys/* as there is no good reason to do so. Thanks Michael Biebl + for the patch. (Closes: #597338) + + [ Petter Reinholdtsen ] + * Update Standards-Version from 3.8.4 to 3.9.1. No changes needed. + + -- Petter Reinholdtsen Sun, 14 Nov 2010 23:08:45 +0100 + +sysvinit (2.88dsf-12) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Fix typo introduced when fixing #526398 and make sure the root + file system is only checked if it is specified in /etc/fstab that + it should be checked, to avoid breaking boot when root is on NFS + (Closes: #592427). + + -- Petter Reinholdtsen Sun, 15 Aug 2010 20:05:30 +0200 + +sysvinit (2.88dsf-11) unstable; urgency=low + + * Avoid /usr/bin/find in init.d/urandom to be able to run it before + /usr/ is mounted (Closes: #587665). + + -- Petter Reinholdtsen Sat, 03 Jul 2010 09:54:01 +0200 + +sysvinit (2.88dsf-10) unstable; urgency=low + + * Change init.d/urandom depend from $remote_fs to $local_fs. As far + as I can see, it do not use anything in /usr/. + * Change warning message from invoke-rc.d when called during shutdown + to also include the requested action name. + + -- Petter Reinholdtsen Wed, 30 Jun 2010 14:06:17 +0200 + +sysvinit (2.88dsf-9) unstable; urgency=low + + * Drop soft dependency from init.d/bootlogs to gdm3 until gdm3 stop + depending on bootlogs, to avoid init.d script loop (Closes: #577146). + * Rewrite rm command in initscripts.postrm to avoid bogus lintian + error. + * Extend startpar patch 05_pri_kdm_gdm.patch to also give priority + to gdm3. + + -- Petter Reinholdtsen Fri, 11 Jun 2010 08:47:28 +0200 + +sysvinit (2.88dsf-8) unstable; urgency=low + + * New startpar patch 06_stdin_notty.patch to make sure startpar run + programs also when stdin is a pipe, to get it working on OpenVZ + (Closes: #584102) + * New startpar patch 07_nocrash_missing_arg.patch to make sure + missing argument (-a) do not cause startpar to segfault. + * Change startpar patch 05_pri_kdm_gdm.patch to also give priority + to udev to get kernel module loading started as early as possible + during boot. Based on idea from live-net-startpar. + * Make init.d/bootlogs soft depend on gdm3 while we wait for gdm3 to + provide $x-display-manager. + * Make sure to create /dev/pts/ and /dev/shm/ in mountdevsub.sh + before mounting them to allow udev to stop creating them at boot + (Closes: #584742). Thanks to Marco d'Itri for the patch. + * Drop support for the now obsolete devfs file system in the init.d + scripts bootmisc.sh, checkroot.sh, mountdevsubfs.sh, umountfs and + umountnfs.sh. + * Loosen up the migration check to dependency based boot sequencing, + to only report removed but not purged packages if insserv detected + problems with the init.d script dependencies. + * Add Norwegian Bokmål (nb) debconf translation. + + -- Petter Reinholdtsen Thu, 10 Jun 2010 15:41:18 +0200 + +sysvinit (2.88dsf-7) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Protect new code calling initctl in sendsigs to only run when + /sbin/initctl is available. + + -- Petter Reinholdtsen Sun, 30 May 2010 14:57:17 +0200 + +sysvinit (2.88dsf-6) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Update comment in init.d/rc explaining the CONCURRENCY value to + reflect that 'startpar' is no longer a useful value and that + dependency based boot sequencing with parallel boot is the + default. + * Additional upstart jobs may be /started/ on shutdown after + init.d/sendsigs has first been invoked; so don't assume the list + of known jobs is constant, instead requery initctl before each + killall5 -CONT to properly exclude any new jobs upstart knows + about so that we aren't waiting an extra 10 seconds for no reason. + Patch from Steve Langasek and Ubuntu. + * Print to the console how many seconds were spent running boot + scripts, to get more focus on boot speed while we prepare Squeeze. + * Add workaround in sysv-rc.postinst for systems migrating from + file-rc to make sure their use of legacy boot ordering is detected + and handled (Closes: #575080). + + -- Petter Reinholdtsen Sat, 29 May 2010 21:08:23 +0200 + +sysvinit (2.88dsf-5) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Make sure now obsolete startpar and shell concurrency setting + work as aliases for makefile style concurrency (Closes: #581704). + + -- Petter Reinholdtsen Sat, 15 May 2010 20:31:19 +0200 + +sysvinit (2.88dsf-4) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Fix typo in code detecting legacy boot ordering when concurrent + startup is enabled. + * Call splash_stop early during boot when using concurrent booting, + to stop usplash from confusing X. + + -- Petter Reinholdtsen Fri, 14 May 2010 21:39:27 +0200 + +sysvinit (2.88dsf-3) experimental; urgency=low + + * New 30_killall5_hurd.patch to fix build problem on Hurd. Patch + from Werner Fink. + * Fix typo in invoke-rc.d (Closes: #580298). + * Switch to concurrent booting by default, when dependency based + boot sqeuencing is enabled. Make shell and startpar concurrency + aliases for makefile style concurrency, as both are obsolete now. + * Add 64_init_selinux_enabled.patch to try to fix the logic used to + enable SELinux (Closes: #580272). + * Mention the LSB style header now required for init.d scripts in + /etc/init.d/README (Closes: #576788). + + -- Petter Reinholdtsen Wed, 12 May 2010 21:36:01 +0200 + +sysvinit (2.88dsf-2) experimental; urgency=low + + [ Petter Reinholdtsen ] + * Change start dependencies for bootlogs to use new virtual facility + $x-display-manager and also mention wdm and nodm. The individual + display managers should be dropped as stop dependencies when all + of them provide the virtual facility. + * Report script name requested if invoke-rc.d is used during + shutdown. + * Update 63_init_keep_utf8_ttyflag.patch to actually work on kfreebsd. + * New 20_init_freebsd_vswtc.patch to add workaround for missing VSWTC + on kfreebsd (Closes: 579293). + + -- Petter Reinholdtsen Tue, 27 Apr 2010 18:46:02 +0200 + +sysvinit (2.88dsf-1) experimental; urgency=low + + * Upload to experimental for build testing and wider review. + + * New upstream release. + - Drop 11_doc_shutdown-c.dpatch, now included upstream. + - Drop 14_doc_fsf_addr.dpatch, now included upstream. + - Drop 15_doc_upstream_email.dpatch, now included upstream. + - Drop 21_ifdown_kfreebsd.patch, now included upstream. + - Drop 46_pidof_symlinkman.patch, now included upstream. + - Drop 50_bootlogd_devsubdir.dpatch, now included upstream. + - Drop 54_bootlogd_findptyfail.dpatch, now included upstream. + - Drop 55_bootlogd_flush.patch, now included upstream. + - Drop 60_init_selinux_ifdef.dpatch, now included upstream. + - Drop 62_init_freebsdterm.dpatch, now included upstream. + - Drop 70_compiler_warnings.dpatch, now included upstream. + - Drop 94_fstab-decode.dpatch, now included upstream. + - Drop 96_shutdown_acctoff.dpatch, now included upstream. + - Drop 97_init_starttest.dpatch, now included upstream. + - Drop 98_installtarget.dpatch, now included upstream. + - Update 63_init_keep_utf8_ttyflag.patch. + - New upstream do not strip binaries, allowing the nostrip + build option to work (Closes: #438085). + * Update Standards-Version from 3.8.3 to 3.8.4. No change needed. + * Update homepage in control file to the new home + http://savannah.nongnu.org/projects/sysvinit . + * Quiet down init.d/bootlogd when VERBOSE=no. + * Document in init.d/skeleton that lsb-base (>= 3.2-14) is + needed for status_of_proc(). + + -- Petter Reinholdtsen Sun, 25 Apr 2010 19:56:47 +0200 + +sysvinit (2.87dsf-10) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Avoid killing processes managed by upstart in init.d/sendsigs, and + print list of misbehaving processes. Partly based on patch from + Martin Pitt, Scott James Remnant and Ubuntu. + * Change service to use upstart for service management if an upstart + configuration exist. Patch from Dustin Kirkland and Ubuntu. + * Always print message from invoke-rc.d when policy-rc.d denied + execution (Closes: #566783). Patch from Per Wawra. + * Correct use of .IB and .IR macros in update-rc.d manual page + (Closes: 556080). Patch from Matt Kraai. + * Only create /dev/initctl and send SIGUSR to init in + init.d/mountall.sh when sysvinit is installed (Closes: #569032). + * Change lsb-base depend for sysv-rc and initscripts from (>= 3.0-6) + to (>= 3.2-14) for the status_of_proc() function. Patch from + Dustin Kirkland and Ubuntu. + * Adjust init.d/umountfs to avoid using -f when umounting devices + mounted before /, and avoid umounting file systems listed before / + in /proc/mounts to avoid hangs during shutdown. Patch from Colin + Watson and Ubuntu. + * Implement status reporting in init.d/stop-bootlogd and + init.d/stop-bootlogd-single. + + [ Kel Modderman ] + * Exit with value rather than echo the value for the status action in + rmnologin and hostname.sh initscripts. (Closes: #567074, #567069) + + -- Petter Reinholdtsen Mon, 22 Mar 2010 20:21:01 +0100 + +sysvinit (2.87dsf-9) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Correct typo preventing sysv-rc error messages to be sent to stderr. + * Only override VERBOSE in /lib/init/vars.sh based on kernel + argument when called from /etc/init.d/rc (Closes: #505468). + * Only use /proc/cmdline to override VERBOSE setting during boot if + it is readable (Closes: #540008). + * Only send SIGUSR to init from init.d/mountall.sh when /dev/initctl + was created, to reduce the chance of confusing upstart (Related to + #569032). + * Make kernel argument parsing in /lib/init/vars.sh more robust to + avoid incorrect matches (Closes: #557648). + * Enable swap earlier in the boot, to avoid running out of memory + during fsck (Closes: #552029). + * Update upstream email address in the README to the current one. + + -- Petter Reinholdtsen Sun, 21 Mar 2010 08:19:38 +0100 + +sysvinit (2.87dsf-8.1) unstable; urgency=low + + * Non-maintainer upload. + * Fix pending l10n issues. Debconf translations: + - Russian (Yuri Kozlov). Closes: #552415 + - Japanese (Hideki Yamane (Debian-JP)). Closes: #553185 + - Italian (Vincenzo Campanella). Closes: #556075 + - German (Chris Leick). Closes: #550829 + - Galician (Marce Villarino). Closes: #554226 + + -- Christian Perrier Fri, 12 Feb 2010 05:57:33 +0100 + +sysvinit (2.87dsf-8) unstable; urgency=low + + * Update patch 63_init_keep_utf8_ttyflag.patch to try to get it + working on freebsd and hurd too. + * Debconf templates and debian/control changed based on review + by the debian-l10n- english team as part of the Smith review + project (Closes: #549539). Thanks to Christian Perrier for + the patch. + * Added section in README.Debian for sysv-rc, explaining the + migration in more detail. Thanks to Justin B Rye for the text. + * Debconf translations: + - Added Vietnamese from Clytie Siddall (Closes: #550220). + - Added Swedish from Martin Ågren (Closes: #550495). + - Added Czech from Miroslav Kure (Closes: #551325). + - Added Spanish from Francisco Javier Cuadrado (Closes: #551594). + - Added Portuguese from António Moreira (Closes: #551675). + - Added French from Steve Petruzzello (Closes: #551722). + - Added Finnish from Esko Arajärvi (Closes: #551916). + - Added Italian from Luca Monducci (Closes: #551922). + + -- Petter Reinholdtsen Sun, 25 Oct 2009 21:49:44 +0100 + +sysvinit (2.87dsf-7) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Change if-up.d/mountnfs to not claim to wait for the last network + interface when there are no network file systems listed in + /etc/fstab (Closes: #512237, 481028). Patch from Adrian Bridgett. + * Add startpar patch 05_pri_kdm_gdm.patch to try to get gdm and kdm + to start earlier when concurrent booting is enabled. + * Quiet down sysv-rc postinst to not give error when no file exist + in /var/lib/update-rc.d. Discovered from piuparts. + * Report error from update-rc.d when insserv reject a script, to + make it more clear what program call failed in a postinst. + * Drop optional dependency from checkfs to cryptdisks, the + cryptdisks script have a reverse dependency on checkfs, and that + is a better way to do it. + * Rewrite init.d/mtab.sh and init.d/checkroot.sh to not use + /usr/bin/which, as it is running before /usr/ is guaranteed to be + available. + * Rewrite /lib/init/usplash-fsck-functions.sh to use blkid instead of + the now obsolete vol_id. Patch from Martin Pitt and Ubuntu. + * Update 91_sulogin_lockedpw.dpatch to include documentation, + without the Ubuntu references. Based on patch from Scott James + Remnant and Ubuntu. + * Add patch 55_bootlogd_flush.patch to make sure lines are flushed + to the kernel even when not asking the kernel to flush to disk + (Closes: 542515). Patch from Scott Gifford. + * Add patch 63_init_keep_utf8_ttyflag.patch to make sure the utf-8 + tty flag is not cleared (Closes: 547073). Patch from Samuel + Thibault. + * Include url to wiki page with information on how to fix the + problems when unable to migrate to dependency based boot + sequencing. + * Make mountnfs-bootclean.sh also depend on $local_fs, to avoid + surprises on systems where the admin removed mountnfs.sh from + rcS.d/. It is not a good idea to remove it, but there is no need + for the script to fail when someone is crazy enough to remove a + essential init.d script + + [ Henrique de Moraes Holschuh ] + * invoke-rc.d: return exit status 4 when action "status" is denied, + to allow simpleminded policy-rc.d scripts to work well with the + status action (closes: #381497) + + [ Kel Modderman ] + * Fix bootlogs init.d script to output correct name and supported + actions in usage statement. (Closes: #551263) + + -- Petter Reinholdtsen Sun, 25 Oct 2009 11:07:22 +0100 + +sysvinit (2.87dsf-6) unstable; urgency=low + + * Correct code in sysv-rc postinst to avoid failing to install when no + init.d scripts have been removed (Closes: #546405). + * Start bootlogd before lvm2 too, to push it even further forward + in the boot sequence. + + -- Petter Reinholdtsen Tue, 15 Sep 2009 01:28:19 +0200 + +sysvinit (2.87dsf-5) experimental; urgency=low + + * Uploading to experimental, to test the new build rules. + + * Make sysv-rc postinst report detected problems to stderr too when + failing to migrate. + * Fix typo in error message from postinst (Closes: #545409). + * Make initscripts depend on sysvinit-utils (>= 2.86.ds1-64), to + make sure the fstab-decode program is available (Closes: #545356). + * Make sure the calls to 'update-rc.d X remove' in initscripts + postinst do not ignore errors (Closes: #406361). + * Make sysvinit depend on sysvinit-utils (>= 2.86.ds1-66) to avoid + that bootlogd disappear during partial upgrades (Closes: #545368). + * Restructure source package to make it possible to use debhelper in + the common way to build the source, by moving debian/initscripts/ + and debian/sysv-rc/ into debian/src/. Restructure build rules to + use debhelper more, and migrate to debhelper 7. + * New patch 98_installtarget.patch to improve the sysvinit install + target. + * Remove /etc/init.d/.depend.* in prerm, not postrm, to avoid + surprises. + * Remove /var/lib/update-rc.d/* when the package is purged. + * Change cut-off point for the trimmed changelog entries in + sysvinit-utils, initscripts and sysv-rc from version 2.84-3 to + version 2.86.ds1-47, to reduce the package sizes. + * Drop hurd specific dependency on libc0.3 (>= 2.3.2.ds1-12). It is + no longer needed according to Michael Bunk. Patch from Michael + Biebl. + * Remove information about scripts in /var/lib/update-rc.d/ when + their runlevel symlinks are removed (Closes: #545949). Remove + such files left behind earlier during upgrade. + * Bootlogd now starts as late as possible (Closes: #265801) + * Drop the binary /lib/init/readlink from initscripts and depend on + coreutils (>= 5.93) instead. Adjust scripts to use the program + from coreutils from now on (Closes: #239342). + * Make sure insserv exit values propagate through update-rc.d to make + sure packages with errors fail to install. + + -- Petter Reinholdtsen Sun, 13 Sep 2009 00:13:49 +0200 + +sysvinit (2.87dsf-4) unstable; urgency=low + + * Send all output from the sysv-rc postinst to stderr, to make sure + we do not confuse debconf. + * Fix sysv-rc postinst to not fail when insserv report more than one + error (Closes: #545205) + + -- Petter Reinholdtsen Sat, 05 Sep 2009 22:23:38 +0200 + +sysvinit (2.87dsf-3) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Drop execution of files in /etc/rc.boot from sysv-rc. This feature + have been obsolete since before 1999. Remove the rc.boot(5) manual + page from the source as well. + * Make init.d/rc.local depend on $all to get it to start later in + the boot sequence (Closes: #539084). + * Rewrite message from update-rc.d to make it more obvious that both + start and stop symlinks are taken into account (Closes: #519553). + * Rewrite /etc/rcS.d/README and /etc/rc[2-5].d/README to explain how + to disable a service at a given runlevel with the dependency based + boot sequencing. Remove the list of well known sequence numbers + in rcS.d/ that is no longer valid with dependency based boot + sequencing. + * Make sysv-rc Breaks: initscripts (<< 2.86.ds1-63) to make sure + scripts working with makefile style concurrent booting is + installed. Not using dependency to avoid circular dependency + between initscripts and sysv-rc. + * Move the code to migrate to dependency based boot sequencing + during upgrades from the insserv package to the sysv-rc package. + Depend on insserv (>> 1.12.0-10) for this. Let initscripts depend + on sysv-rc | file-rc to make sure they are installed first. + Migration is a one-way process, enabled after a critical debconf + question during upgrades when it is safe to do so (Closes: + #540546, #541041, 541604). Checks previously done by + update-bootsystem-insserv are now only done once in sysv-rc + postinst (Closes: #538934). Dependency based boot sequencing is + now the default. This change make it possible to remove both + sysv-rc and insserv (Closes: #538959) if other packages want to + take over the boot sequencing resposibility. + * Rewrite initscripts postinst to always use the update-rc.d script + instead of the legacy updatercd() function which was used as a + speed optimization no longer relevant when dependency based boot + sequencing is the default. + + [ Kel Modderman ] + * Migrate from dpatch to quilt for patch management: + - build-depend on quilt (>= 0.40) + - provide patch and unpatch targets in debian/rules. use custom + patch targets to allow for separate debian/patches and + debian/startpar/patches patch series + - keep .dpatch file extenstion to make checking changes easier + - add debian/README.source to describe patch system we use + * Purge debian/patches/12_doc_lastb.dpatch and + debian/patches/68_init_quiet.dpatch, they were never applied and wrong. + * Update patch header for all remaining patches. + * Call dpkg-shlibdeps debian/startpar/startpar for sysvinit-utils package + and not sysvinit, startpar moved in revision 2.86.ds1-62. + * Remove checkdir, checkroot and buildfromsvn targets from + debian/rules. The latter is unused by current maintainers and the + former can be replaced with dh_testdir and dh_testroot instead. + * Fix reject hunk of debian/patches/70_compiler_warnings.dpatch to + fix another compile warning. + * Make sure update-rc.d compares command line parameters for start/stop + runlevel configuration with the Default-Start and Default-Stop values in + LSB info comment of script and warns if there are differences. + * Update sysv-rc debconf templates with text which help explain + dependency based boot to end users, and provide sound advice for + people who encounter problems which prevent the migration. + * Update inittab.kfreebsd-gnu: On GNU/kFreeBSD the serial devices have + change from /dev/cuuaX to /dev/ttydX in kernel 6.0 which is minumum + kernel currently supported in Debian. (Closes: #544555) + * Make sure sysv-rc/etc/init.d/rc checks insserv has reordered boot + system by checking for /etc/init.d/.depend.* when CONCURRENCY=shell + too. (Closes: #544565) + + [ Petter Reinholdtsen ] + * Adjust init.d/bootlogd dependencies to start before hostname, + procps, pcmcia, hwclock, hwclockfirst, hibernate-clean and hdparm, + to get the bootlogger started earlier in the boot (Closes: #538936). + * Extend the update-rc.d(8) manual page to document the new behaviour. + Do not install translated update-rc.d manual pages until they + are updated to reflect this. + * Use versioned conflict on chkconfig (<< 11.0-79.1-2), now that it + dropped the service command (Closes: #541727). + * Drop unneeded dependency rmnologin from init.d/stop-bootlogd, and + correct $remote_fs dependency to $local_fs, as /usr/ is not aused. + * Drop unneeded dependency on udev for init.d/bootlogs, and add ldm + and sdm to list of display managers to start after to get the + complete list. + * Extend boot order migration check to reject migration if init.d + scripts from removed but not purged packages are present. + * Add $syslog as a dependency for init.d/skeleton, as it should + be used in the normal case. + * Change init.d/urandom dependency from $local_fs to $remote_fs, as + it uses /usr/bin/find to handle locally increased pool size + (Closes: #543294). + * Drop initscripts conflict on insserv (<< 1.09.0-12), now that + sysv-rc depend on insserv (>> 1.12.0-10). + * Drop initscripts conflict on udev (<< 0.080-1), which was + before the current oldstable was released. + * Drop initscripts conflict on usplash (<< 0.5.8-2), which was + before the current stable was released. + * Remove code in init.d/killprocs to restart /sbin/update, as it is + only useful for kernels up to linux 2.2, which is no longer + supported (Closes: #544249). Thanks to Marco d'Itri for the tip. + * Update Standards-Version from 3.8.2 to 3.8.3. No changes needed. + * Add code in initscripts.postrm to remove rc settings for init.d + scripts on removal to follow policy and keep lintian happy, even + though removing initscripts will leave the system unbootable. + Update lintian overrides to reflect this. + * Implement status argument to init.d/bootlogs, init.d/checkroot.sh, + init.d/hostname.sh, init.d/rmnologin and init.d/urandom. + + -- Petter Reinholdtsen Sat, 05 Sep 2009 11:52:51 +0200 + +sysvinit (2.87dsf-2) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Start generating MD5 sum files using dh_md5sum, build-depend + on debhelper for this. Use compat level 1 to get it to process + debian/tmp/. + * Drop the stop calls for K11mountoverflowtmp in runlevels 0 and 6. + The umountfs script will take care of that task (Closes: 526733). + * Remove setting of unused makefile variable LIBC6 from rules. + * Move copyright, preinst, postinst and postrm files for initscripts + and sysv-rc to debian/ to make the build system closer to other + source packages. + * Add the sysv-rc saveconfig script to /usr/share/doc/sysv-rc/ + to provide an example. + * Let sysv-rc depend on insserv (>= 1.12.0-10) to activate + dependency based boot sequencing by default (Closes: #472587). + + [ Kel Modderman ] + * Allow forcefsck on kernel cmdline to have same effect as touching + /forcefsck in checkfs.sh and checkroot.sh. (Closes: #529498) + * Also allow fastboot on kernel cmdline to have same effect as touching + /fastboot in checkfs.sh and checkroot.sh. + * Do not use brace expansion in debian/rules and remove need for + setting SHELL to /bin/bash. + + -- Petter Reinholdtsen Mon, 27 Jul 2009 21:12:27 +0200 + +sysvinit (2.87dsf-1) unstable; urgency=low + + * New upstream release. + - Update patch 10_doc_manuals to drop the parts now included upstream. + - Drop patch 11_doc_mountpoint now included upstream. + - Drop patch 13_doc_telinit now included upstream. + - Update patch 14_doc_fsf_addr to drop the parts now included upstream. + - Drop patch 15_doc_pidof now included upstream. + - Drop patch 16_doc_runlevel now included upstream. + - Drop patch 17_doc_halt now included upstream. + - Drop patch 25_last_sanify now included upstream. + - Drop patch 26_last_ipv6 now included upstream. + - Drop patch 27_last_usageopts now included upstream. + - Drop patch 28_last_full-time now included upstream. + - Drop patch 30_strip now included upstream. + - Drop patch 31_build_warnings now included upstream. + - Drop patch 40_selinux now included upstream. + - Drop patch 41_utmp_64bit now included upstream. + - Drop patch 42_utmpdump_retval now included upstream. + - Drop patch 45_pidof_symlink now included upstream. + - Drop patch 47_pidof_chroot now included upstream. + - Drop patch 50_bootlogd_exitcode now included upstream. + - Drop patch 51_bootlogd_syncalot now included upstream. + - Drop patch 52_bootlogd_createlogfile now included upstream. + - Drop patch 53_bootlogd_ttyB now included upstream. + - Drop patch 60_init_race now included upstream. + - Drop patch 61_init_msg now included upstream. + - Drop patch 63_init_longer_procname now included upstream. + - Drop patch 64_init_reexec_env now included upstream. + - Drop patch 64_init_set_PATH now included upstream. + - Drop patch 65_init_u_in_06 now included upstream. + - Drop patch 66_init_emerg_tty now included upstream. + - Drop patch 67_init_hddown now included upstream. + - Drop patch 69_init_waiting now included upstream. + - Drop patch 70_init_consoleopen now included upstream. + - Drop patch 70_wall_ttyname now included upstream. + - Drop patch 71_wall_hostname now included upstream. + - Drop patch 80_killall_pidof now included upstream. + - Drop patch 80_killall_sched now included upstream. + - Drop patch 81_killall_avoid_init now included upstream. + - Drop patch 82_killall_exclude_pids now included upstream. + - Drop patch 82_killall_retval now included upstream. + - Drop patch 83_killall_manref now included upstream. + - Drop patch 84_killall_fuse now included upstream. + - Drop patch 85_killall_safecwd now included upstream. + - Drop patch 90_shutdown_H now included upstream. + - Drop patch 92_sata-hddown now included upstream. + - Drop patch 93_sulogin_fallback now included upstream. + - Drop patch 95_halt-name now included upstream. + * Modify shutdown(8) manual page to make it more clear when -c + work (Closes: #374038). Based on text proposal from Dan Jacobson. + * New patch 50_bootlogd_devsubdir to change bootlogd to recursively + search /dev/ for the correct terminal device (Closes: #376406). + * New patches 60_init_selinux_ifdef and 70_compiler_warnings to get + rid of compiler warnings. + * Rewrite rules to unpatch after the 'make clean' to get rid of binaries + depending on debian patches. + + -- Petter Reinholdtsen Sat, 25 Jul 2009 16:44:55 +0200 + +sysvinit (2.86.ds1-66) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Replace Ó with \['O] and Á with \['A] in spanish + update-rc.d(8) after looking up the correct string in + groff_man(7), to avoid lintian warning. + * Move bootlogd to the sysvinit-utils package, as it is useful also + without the sysvinit init program. Make sysvinit-utils replace + sysvinit (<= 2.86.ds1-65) to handle this. + * Clean up control file, dropping replaces and conflicts on sysvinit + and file-rc packages before oldstable: sysvinit (<< 2.85-1), + sysv-rc (<< 2.86.ds1-1.2), sysvinit (<< 2.86.ds1-12) and file-rc + (>> 0.7.0) (Closes: #509449). + * New patch 54_bootlogd_findptyfail making sure bootlogd findpty() + returns an error value when it fails to find a usable pty + (Closes: #492796). Patch from Rob Leslie. + * New patch 96_shutdown_acctoff making sure to call accton with the + argument off during shutdown to stop accounting (Closes: #536574). + * Modify LSB header of init.d/bootlogd to depend on $all when + starting, to get it to start later in the boot sequence + (Closes: #531198. Patch from Vincent Crevot. + * Modify LSB header of init.d/bootlogd to start earlier when + dependency based boot sequencing is enabled, by stating that + it should start before keymap and keyboard-setup. + * Make sure more verbose temp cleaning always calls log_end_msg + after log_begin_msg (might solve #534713). + * New patch 97_init_starttest solving problem reported to + 2003-03-10. + * Change init.d/bootmisc.sh to not set pseudo-terminal access + permissions when udev is active. Leave that to udev, the same way + it is left to devfs. + * Correct boot dependency, move hostname dependency from bootmisc.sh to + bootlogs. + + [ Kel Modderman ] + * Remove debian/startpar/README, it contains outdated information about + the origin of startpar upstream. + * Update startpar to version 0.53.1 upstream. Add Debian quilt patch series + to ./debian/startpar/patches, while they wait for inclusion upstream. + * Patch startpar makeboot.c to allow a much higher amount of loops when + calculating dependecies from make files. + * Modify all copyright blurbs which refer to the version-less symlink + /usr/share/common-licenses/GPL to point to the versioned GPL-2 license. + + -- Petter Reinholdtsen Fri, 24 Jul 2009 10:51:50 +0200 + +sysvinit (2.86.ds1-65) unstable; urgency=low + + [ Kel Modderman ] + * Patch debian/startpar/startpar.c to enable workaround for missing + /dev/pts in early runlevel S when using CONCURRENCY=startpar. + * Modify debian/patches/85_killall_safecwd.dpatch to make sure /proc + is CWD when killall5 is called as pidof as well. (Closes: #536543) + + -- Petter Reinholdtsen Sat, 11 Jul 2009 19:58:29 +0200 + +sysvinit (2.86.ds1-64) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Make sure only noswap kernel option disable swap (Closes: #523346). + Patch from Michael Tokarev. + * Do not rotate /var/log/dmesg if the file is not present (Closes: + #533047). Patch from Aaro Koskinen. + * Split init.d/bootmisc.sh in two, one part that need to run very early, + and another (bootlogs) which can be executed later, to make it possible + to postpone some work until after gdm/kdm/xdm is started. Based on + patch from Scott James Remnant and Ubuntu. + * Add improved progress bar during fsck when usplash is used, based + on patch from Martin Pitt and Ubuntu. Modified Ubuntu patch to + keep the generic splash support when usplash is not used. + * Avoid bashism in service(8) (Closes: #535883). + * New patch 85_killall_safecwd to chdir to /proc before stopping and + killing processes, to avoid deadlock if / is a fuse file system. + Patch from Goswin von Brederlow, fixing part of 476698. The rest + of the issues reported in #476698 should be handled using omitpids + (Closes: #476698). + * New patch 42_utmpdump_retval fixing unchecked return value from + malloc(). Patch from Christian 'Dr. Disk' Hechelmann and Fedora. + * New patch 46_pidof_symlinkman to improve pidof manual page regarding + its handling of symlinks. Patch from Bill Nottingham and Fedora. + * New patch 94_fstab-decode adding helper program fstab-decode to + sysvinit-utils. Source from the initscripts package in Fedora. + * Rewrite umountfs and umountnfs.sh to use fstab-decode, to handle + mount points with space in their names (Closes: #415482). + * Reduce initscripts dependency on e2fsprogs to recomments and drop + the versioned relation, as the version needed + (1.32+1.33-WIP-2003.04.14-1) was included in a version before + oldstable (Closes: #379340). + * Document in rcS(5) how RAMRUN and RAMLOCK affect packages creating + directories in /var/run and /var/lock (Closes: #422257). + * Drop Miquel van Smoorenburg as uploader. He have not been active + since 2004. + * New patch 17_doc_halt changing halt(8) to make it clear that sync + might happen even when -n is used. Patch from Bill Nottingham and + Fedora. + * New patch 47_pidof_chroot adding -c option to pidof, for only + checking processes with the same file system root. Patch by + Thomas Woerner and Fedora. + * New patch 70_init_consoleopen to give missing console some time to + show up. Patch from Bill Nottingham and Fedora. + * New patch 95_halt-name fixing halt/reboot to work properly when used + as login shells. Dale R. Worley and Fedora. + * Modify 40_selinux patch to avoid aborting if a SE policy is already + loaded in the initrd. Patch from Bill Nottingham and Fedora. + * Use set -e in initscripts.preinst to exit on errors and get rid + of a lintian error. + * Change symlink from /bin/pidof to /sbin/killall5 from relative to + absolute, to get rid of lintian message. + * New patch 28_last_full-time to add a new -F option to last. Patch + from Olaf Dabrunz and SuSe. + * Fix typos in rcS(5) (Closes: #495925). Patch from Michael Biebl. + * Make sourcing of /etc/default/rcS conditional in init.d/rc, to + get rid of lintian error. + * Change LSB header of init.d/rc.local, to depend on $syslog too, + to avoid starting local applications too early. + * Impove initscripts package description (Closes: #535557). Based + on patch from Justin B Rye. + * Add some lintian overrides to hide issues that are intentional. + + -- Petter Reinholdtsen Fri, 10 Jul 2009 09:16:04 +0200 + +sysvinit (2.86.ds1-63) unstable; urgency=low + + [ Kel Modderman ] + * Patch startpar to add compat define for posix_fadvise() when on + platform such as kfreebsd which does not support that. Thanks to + Petr Salinger for the patch. (Closes: #534337) + * Patch startpar to add compat define for O_DIRECT to fix ftbfs on + hurd. Thanks Samuel Thibault for the patch. (Closes: #534471) + + [ Petter Reinholdtsen ] + * Make temp cleaning more verbose (Closes: #534609). + * Use X-Interactive flag in LSB headers of those scripts that should + run on their own, based on the current content of insserv.conf. + Dropped interactive flag from hostname.sh, mountkernfs.sh and + mountdevsubfs.sh, based on testing confirming that the fix in + #457896 made them obsolete. + * Make sure kfreebsd also get /sys in the initscripts + package (Closes: #525787). + * Add new co-maintainer Kel Modderman as uploader. + * Solve charset encoding issues with the french update-rc.d + manual page (Closes: #499863). + * Add 'status' argument to init.d/bootlogd based on patch from + Scott James Remnant and Ubuntu. + * Fix computing of runlevel in init.d/rc by allowing A-Z in init + scripts names (like NetworkManager). Patch from Loic Minier + and Ubuntu. + * Add status argument support to init.d/skeleton. + * Update Standards-Version from 3.8.1 to 3.8.2. No changes needed. + + -- Petter Reinholdtsen Mon, 29 Jun 2009 22:11:17 +0200 + +sysvinit (2.86.ds1-62) unstable; urgency=low + + [ Kel Modderman ] + * Add missing semi-colon in LSB header of init.d/urandom (Closes: + #501724). + * Force C locale for df command used in init.d/mountoverflowtmp. + (Closes: #510912) + * Update startpar source to upstream 0.52 (from 0.50) and apply debian + compatibility patch (sent upstream). Also workaround /dev/pts not + being mounted early in runlevel S by having startpar use an own + version of getpt(2) system call. (Closes: #457896, #484883) + * Enable CONCURRENCY=makefile mode in debian/sysv-rc/etc/init.d/rc. + This mode uses startpar and the /etc/init.d/.depend.* makefile-like + information created by insserv to calculate boot script execution + order. The splash API is not supported in this mode of boot. This + mode of boot is considered very experimental at this time. + * Allow startpar using concurrency modes to operate in runlevel S, now + that startpar can manage to work properly in absence of /dev/pts. + * Use uscan dversionmangle option to remove .ds\d+ string from modifed + orig.tar.gz. This fixes the debian-watch-file-should-mangle-version + lintian warning. Patch taken from diff on LP: #312764. + * Add comment to debian/sysv-rc/etc/init.d/rc about debug=echo, it + should never be left uncommented for a real boot process and should + only be used for interactive debugging. (Closes: #510455) + * Do not mount usbfs any more, it was deprecated long ago. + Applications should all use /dev/bus/usb, which can be managed more + flexibly (assign permissions with udev, and the like). Thanks Martin + Pitt. (Closes: #483392, #422940, #360165, #471101) + * Add Homepage field to debian/control. + * Add interface for disabling system init script start links with + update-rc.d, and enabling them again. (Closes: #67095) + * When update-rc.d in "start|stop"-mode is invoked without the final + dot, script warnings are displayed just before the "usage" message + is shown. Check that last argument to start|stop command is a period + earlier. Thanks to Patrick . (Closes: #512003) + * Use -delete option of find(1) instead of piping through xargs in + debian/initscripts/lib/init/bootclean.sh. (Closes: #316468, #461103) + * Make init.d/rc simpler by dropping support for sourcing .sh files + after the policy finally changed in 3.8.1. Update to Standards + version 3.8.1. (Closes: #339955, #519520) + * Allow initscripts postinst maintainer script to not fail when + attempting to mkdir /dev/pts and /dev/shm when running in a + fakechroot environment. This is done by checking for FAKECHROOT env + variable before bailing out. Patch thanks to Daniel Kahn Gillmor. + (Closes: #504877) + * Update debian/NOTES to reflect current affairs. + + [ Petter Reinholdtsen ] + * Move the startpar binary to a more proper location, from sysvinit + to sysvinit-utils. + * Comment out the code disabling fsck when running on battery. It + need changes in fsck to work properly (Closes: #526398). This + Reopens #326647. + * Add a /usr/sbin/service command (Closes: #534300). Modified the + manual page based on ideas from the sysvconfig package. Thanks to + Steve Langasek and Ubuntu. Add conflict with sysvconfig and + chkconfig providing the same program. + * Improve init.d/umountfs umount ordering code to avoid being + confused while still solving #391673 (Closes: #529805). Patch + from Tim Phipps. + * Make sysv-rc depend on a version of sysvinit-utils with a properly + working startpar, in case concurrent booting is enabled. + * Drop shell style concurrent booting, and make CONCURRENCY=shell + behave like CONCURRENTY=startpar, as startpar concurrency now work + properly. + + -- Petter Reinholdtsen Tue, 23 Jun 2009 18:18:53 +0200 + +sysvinit (2.86.ds1-61) unstable; urgency=low + + * Fix typo in rcS(5), proberly->properly (Closes: #484233). Thanks to + Julien Danjou for noticing. + * Fix typo in rcS(5), maually->manually (Closes: #493680). Thanks to + Xr for noticing. + * Modify runlevel detection code in invoke-rc.d to notice the + difference between runlevels 0 and 6, and the boot runlevel, to + make it possible to use invoke-rc.d during boot (Closes: 384509). + * Make sure to call restorecon after mounting tmpfs file systems, to + set SELinux permissions (Closes: #493679). Patch from Russell + Coker. + * Move responsibility of stopping the splash screen process from + individual init.d scripts to init.d/rc. This make sure the + progress calculation reflect reality, and that the splash screen + is taken down in runlevel 1 (Closes: #431560) and that it stop + before gdm and kdm (Closes: #422922, #489734). + * Skip error message from checkfs.sh when / is read-only. Patch + from Mirek Slugen (Closes: #492214). + + -- Petter Reinholdtsen Tue, 12 Aug 2008 16:07:50 +0200 + +sysvinit (2.86.ds1-60) unstable; urgency=low + + * Make bootmisc.sh depend on $remote_fs instead of $local_fs, to + make sure it is executed after mountnfs-bootclean.sh to avoid + cleaning up /var/run/ twice (Closes: #491059). + * Drop support for experimental flag file /etc/update-rc.d-lsbparse. + People should use insserv if they want the boot system sequencing + to use the LSB headers. Patch from Kel Modderman. This fixes + typo in update-rc.d, making sure it ignore the LSB Default-Start + header. + * Updated Standards-Version from 3.7.3 to 3.8.0. No changes needed. + * Remove obsolete linda overrides. Linda is removed from Debian. + + -- Petter Reinholdtsen Fri, 18 Jul 2008 20:57:59 +0200 + +sysvinit (2.86.ds1-59) unstable; urgency=low + + * Fix uninitialised previous_stop caused by typo in fix for + bug #483172 (Closes: #484607). + * Set $LANG from /etc/default/locale in mountall.sh, so that ntfs-3g and + friends can get correct file name encodings. (Closes: #483396) + + -- Petter Reinholdtsen Fri, 6 Jun 2008 10:02:32 +0200 + +sysvinit (2.86.ds1-58) unstable; urgency=low + + * Optimize start symlinks as if they are stop symlinks for runlevels 0 and + 6, to avoid problems with portmap during shutdown (Closes: #483172). + * Repair eliminate_conffile() in initscripts preinst, making sure + unchanged conffiles are properly handled (Closes: #483391). + Patch from Martin Pitt and Ubuntu. + * Make sure a few essential directories (/proc, /sys, /var/{run,lock}) is + created in init.d/umountroot if missing, right before mounting root r/o. + It is a convenient (and one of the very few possible) place to ensure that + the next boot will succeed (Closes: #483393). Patch from Martin Pitt + and Ubuntu. + + -- Petter Reinholdtsen Thu, 29 May 2008 20:10:17 +0200 + +sysvinit (2.86.ds1-57) unstable; urgency=low + + * Remove another bashism in init.d/rc blocking startpar concurrency + (Closes: #481770). + * Fix wake on lan issue introduced with freebsd patch in version + 2.86.ds1-4 (Closes: #405870). Patch from Lucas Nussbaum. + * Convert files debian/patches/12_doc_lastb.dpatch, + debian/sysv-rc/man8/es/update-rc.d.8, + debian/sysv-rc/man8/fr/update-rc.d.8, + debian/sysv-rc/man8/ja/update-rc.d.8 and + debian/sysv-rc/etc/init.d/rc to UTF-8 (Closes: #478657). + Patch from Ben Finney. + * New patch 84_killall_fuse.dpatch to avoid shutdown problems with + user space file systems, by not stat()-ing files when killing + processes during shutdown (Closes: #476695). Patch from Goswin + von Brederlow. + * Remove special case handling of splash screens in sendsigs. + The usplash and splashy packages are expected to use the + omitpid feature from now on. + + -- Petter Reinholdtsen Tue, 20 May 2008 09:23:13 +0200 + +sysvinit (2.86.ds1-56) unstable; urgency=low + + * Avoid bashism in init.d/rc (Closes: #473694). + + -- Petter Reinholdtsen Sat, 12 Apr 2008 09:32:18 +0200 + +sysvinit (2.86.ds1-55) unstable; urgency=low + + * Use $(MAKE) instead of make in debian/rules, to make it easier to + use make -j. + * Adjust debian/rules to support cross building (Closes: #466148). + * Change init.d/rc to disable startpar concurrency if insserv isn't + enabled and if startpar fail to run. + * Adjust init.d script dependencies for bootmisc.sh, as it can run + before $remote_fs and need to run after both udev and hostname. + * Change update-rc.d to warn about scripts missing LSB style + dependency information. + * Updated all patches to make sure they apply without offset and + fuzzying to the current source. + + -- Petter Reinholdtsen Wed, 26 Mar 2008 10:03:05 +0100 + +sysvinit (2.86.ds1-54) unstable; urgency=low + + * Fix shell quoting typo in conffile removal code (Closes: #464869). + * Make sure to only check for conffile removal on upgrades. + * Improve displayed text when removing unused obsolete conffiles. + * Update version trigger for the /etc/init.d/bootclean to this + version, to make sure those left with the file because of bug + #464869 get it removed on this upgrade. + * Patch startpar to use the correct path to the rcX.d/ directories + in "make mode". + * Update LSB dependency for mountnfs.sh to make sure it is started + after portmap. + * Make sure init.d/sendsigs work even when /proc/cmdline is missing + as it is on vserver clients (Closes: #468473). + + -- Petter Reinholdtsen Sun, 02 Mar 2008 00:32:55 +0100 + +sysvinit (2.86.ds1-53) unstable; urgency=low + + * Correct file name in output when removing conffiles, to + use the correct file ending .dpkg-old, not .dpkg-bak. + * Fix typo in omitpid handling in init.d/sendsigs (Closes: #462354) + * Change progress bar calculations to not divide by zero when there + are no progress steps to be taken (Closes: #463504). + * Fix quoting typo in initscripts.preinst (Closes: #463551) + + -- Petter Reinholdtsen Fri, 01 Feb 2008 19:37:42 +0100 + +sysvinit (2.86.ds1-52) unstable; urgency=low + + * Rewrite conffile removal code in initscripts.preinst to use the + original *.dpkg-old and not the *.dpkg-bak introduced by mistake + when changing to use dpkg-query. + * New patch 83_killall_manref to add references between killall5 and + pidof, and mention pidof in killall5(8) (Closes: #461160). + * Improve documentation for the CONCURRENCY option in /etc/init.d/rc + (Closes: #408491). + * New patch 93_sulogin_fallback to let sulogin fall back to the + staticly linked /bin/sash if both roots shell and /bin/sh fail to + execute. Add suggests for sysvinit-utils to sah, for those that + want this extra level of redundancy (Closes: #43317). + + -- Petter Reinholdtsen Sun, 20 Jan 2008 15:27:16 +0100 + +sysvinit (2.86.ds1-51) unstable; urgency=low + + * Remove debug code left by mistake in if-up.d/mountnfs when fixing + bugs #460463 and 461011 (Closes: #461406). + + -- Petter Reinholdtsen Fri, 18 Jan 2008 12:10:56 +0100 + +sysvinit (2.86.ds1-50) unstable; urgency=low + + * Rewrite conffile removal code in initscripts.preinst to use dpkg- + query instead of reading /var/lib/dpkg/status directly. + * Do not allow "make -C debian/startpar clean" to fail, it should + work every time. + * Handle both trailing space after interface names and multiple + interfaces on one auto line in /etc/network/interfaces when + checking if the last interface has been enabled for NFS mounting + (Closes: #460463, 461011). + + -- Petter Reinholdtsen Thu, 17 Jan 2008 22:36:41 +0100 + +sysvinit (2.86.ds1-49) unstable; urgency=low + + * Handle trailing space after interface names in + /etc/network/interfaces when checking if the last interface has + been enabled for NFS mounting (Closes: #460463). + * New patch 27_last_usageopts to document options -adi in last usage + output (Closes: #415525). + + -- Petter Reinholdtsen Sun, 13 Jan 2008 10:19:22 +0100 + +sysvinit (2.86.ds1-48) unstable; urgency=low + + * Removed unused mountvirtfs as a dependecy provides for + init.d/mountdevsubfs.sh, to avoid duplicate provides. + * Removed hostname as a dependency for init.d/bootmisc.sh, as it is + now a dependency of checkroot.sh and thus still will have a known + order in the boot. + * Removed stop dependencies in the LSB header of bootmisc.sh. Its + stop operation is a no-op, and it is not run in any level to stop. + * Document in stop-bootlogd-single why bootlogd has to be stopped in + rcS.d/ for single user boots. + * Specify that one is to read the init.d/bootlogd script in the + stop-bootlogd* scripts. (Closes: #372676) + * Drop libdevmapper as a dependency for init.d/checkfs.sh, as the + init.d script was removed in devmapper version 2:1.02.24-1. + Conflict initscripts with libdevmapper1.02.1 versions before that. + * Drop modutils as a dependency for init.d/checkfs.sh, as the + modutils package was removed 2007-07-04. + * Drop $syslog as a dependency for init.d/rmnologin, as it seem to + be redundant. + * Extend waiting time of init.d/sendsigs from 0-5 seconds to 0-10 + seconds, to give slow processes more time to shut down properly. + * Extend init.d/sendsigs to sync before killing processes, and to + detect and report as a failure if it had to use SIGKILL to + terminate processes. Based on ideas from Gabor Gombas. + * Drop lvm as optional depend for checkfs, mountall and umountfs, + and conflict with insserv versions before 1.09.0-12 to make sure a + version with the override file providing the same dependencies as + reverse dependencies is used. + * Extend sendsigs code to omit some pids during shutdown to also + load pids from /lib/init/rw/sendsigs.omit and + /lib/init/rw/sendsigs.omit.d/packagename, to make it easier for + systems starting very early in the boot, or systems that need to + modify the pid list at run time, to update their pid list (Closes: + #459146). Based on patch from Kel Modderman. + * Change init.d/bootlogd to not report failure when trying to stop + an already stopped bootlogd. + * Change init.d/killprocs to use the same optimization as sendsigs, + to avoid having to wait 5 seconds if there is no more processes. + * Document the way to list /sys/ in /etc/fstab in initscripts + README.Debian (Closes: #401424). + * Reduce stop dependency for mountoverflowtmp from $local_fs to + umountfs, to allow it to stop later during shutdown, and to make + it possible to make it part of the $local_fs dependencies. + * Remove initscripts conflict on mdutils. mdutils was removed in + woody. + * Move optional start dependency on udev-mtab from checkfs to + mountnfs, to better reflect the current ordering of these scripts. + * Improve content of initscripts README.Debian, and document the new + sendsigs omitpid interface there (Closes: #459425). Based on + patch from Kel Modderman. + * Updated the startpar source to version 0.50 from + . + * Optimized the startpar case of init.d/rc to only call the progress + bar API once for each startpar invocation. + * Drop redundant optional dependency on kdm, gdm and xdm for + rmnologin, as it already depend on $all. + + -- Petter Reinholdtsen Sat, 12 Jan 2008 13:10:12 +0100 + +sysvinit (2.86.ds1-47) unstable; urgency=low + + * Added hostname as dependency and hdparm and bootlogd as optional + dependencies for checkroot, to make sure the script are run before + the root file system is checked when present. + * Added libdevmapper, mtab and udev-mtab as optional dependencies + for checkfs to make sure the script are run after the root is + writable and before the other file system is checked. + * Added lvm as optional stop dependency for umountfs, to make sure + LVM is available when all non-root file systems are umounted. + + -- Petter Reinholdtsen Mon, 31 Dec 2007 12:18:42 +0100 + +sysvinit (2.86.ds1-46) unstable; urgency=low + + * Move from experimental to unstable. + * Remove debug code from init.d/mountoverflowtmp that was included + by mistake. + * Reduce output from init.d/mountoverflowtmp when VERBOSE!=yes. + * Add $all as a dependency for init.d/single, to make sure it is + started last in runlevel 1. + * Change runlevel setting in LSB header for init.d/rmnologin and + init.d/stop-bootlogd to not start in runlevel 1 (single user). + This reflect the current and correct setting specified in the + postinst. + * Remove redundant $local_fs dependency from init.d/bootmisc.sh, + init.d/rc.local, init.d/rmnologin and init.d/skeleton + * Move /lib/init/bootclean to /lib/init/bootclean.sh and source it + instead of running it. + + -- Petter Reinholdtsen Sun, 30 Dec 2007 10:32:52 +0100 + +sysvinit (2.86.ds1-45) experimental; urgency=low + + * Replace log_daemon_msg() in init.d/rc with log_action_msg() to + improve visual layout when parallel booting is enabled. + * Avoid using startpar for rcS.d/. It does not work properly before + ptys are available. Related to bug #457896. + * Correct init.d/rc progress bar calculations for the startpar + option, counting each script that is started in parallel too. + * Patch startpar to not print exit codes for each subprocess, to + reduce the noise during boot. + * Remove usplash progress bar support from initscripts and use the + API hook file provided by usplash version 0.5.8-2 instead. Add + conflict on earlier versions of usplash. + + -- Petter Reinholdtsen Fri, 28 Dec 2007 10:32:16 +0100 + +sysvinit (2.86.ds1-44) experimental; urgency=low + + * Add debian/watch file pointing to ftp.cistron.nl. + * Change init.d/mountnfs.sh dependencies to list nfs-common in + should-start (Closes: #433359). + * Change init.d/umountnfs.sh dependencies to list nfs-common in + should-start too. + * Mount a 1 MiB tmpfs on /tmp if /tmp is otherwise less than + 1 MiB to make sure one can still log in when /tmp/ is too + full (Closes: #430814). Based on patch from Ian Jackson and Ubuntu. + * Rewrote ifup.d/mountnfs to wait for all 'auto' interfaces to be + initialized before trying to mount network file systems (Closes: + #386959, #390404, #418596, #419195, #426071, #428823, #432511, + #432511, #432750, #433119, #434177). Based on patch from Phil + Snowdon. + + -- Petter Reinholdtsen Thu, 27 Dec 2007 13:19:14 +0100 + +sysvinit (2.86.ds1-43) experimental; urgency=low + + * Fix typo in /etc/network/if-up.d/mountnfs fstab option parsing used to + detect kerberos v5. (Closes: #416223) + * Update sysv-rc documentation based on text and suggestions + from Alessandro Vesely (Closes: #382410). + * Modify rules to install /lib/init/bootclean with the execute flag + set (Closes: 457847). + + -- Petter Reinholdtsen Wed, 26 Dec 2007 19:36:43 +0100 + +sysvinit (2.86.ds1-42) experimental; urgency=low + + * Change XS-Vcs-Svn to Vcs-Svn as the control flags are official now. + * Add Vcs-Browser flag in debian/control, documenting the browsable source. + * Change how init.d/rc call scripts, to make sure sourced scripts + get the correct argument. + * Reduce redundant code in init.d/rc, to make it easier to enable + sourcing of *.sh scripts. It is still not possible to source + scripts, as some of them use exit and terminate the boot. This is + related to bug #339955. + + -- Petter Reinholdtsen Tue, 25 Dec 2007 20:56:44 +0100 + +sysvinit (2.86.ds1-41) experimental; urgency=low + + * Update standards-version from 3.7.2 to 3.7.3. No change needed. + * Remove empty /lib/ directory from the sysvinit and sysvinit-utils + packages. + * Remove the empty /usr/share/man/man5/ from the sysv-rc package. + * Remove the registration of init.d/modutils from + initscripts/postinst, as the package is removed from Debian. + + -- Petter Reinholdtsen Mon, 24 Dec 2007 13:49:17 +0100 + +sysvinit (2.86.ds1-40) experimental; urgency=low + + [ Petter Reinholdtsen ] + * Rewrite libata shutdown handling to use patch from + Werner Fink at SuSe to handle each disk individually and + automatically instead of guessing in the init.d script how + to handle them collectively (Closes: #426224). This removes + the HDDOWN variable from /etc/default/halt. + * Improve usage information in update-rc.d by using the same + notation as the one used in the manual page (Closes: #268713) + * Implement noswap kernel boot option to stop automatic + swap activation at boot time (Closes: #388525). Based on patch + from Michael Prokop. + * Rewrite init.d/rc to use shell features instead of calling sed + (Closes: #406393). Patch from Ivan Baldo. + * Fix typo in update-rc.d example code (Closes: #433378). + * Fix minor typo in rc*.d/README files (Closes: #452384). + * Make sure init.d/rc do not complain because the new progress bar + API is unavailable (Closes: #457544). + * New patch 26_last_ipv6 from Fedora to recognize more IPv6 + addresses. + * Extend the 68_init_quiet patch based on patch from Fedora to also + suppress the "Switching to runlevel" message. This patch is + currently disabled because the 'quiet' flag is removed by the + kernel when init is called. + * New patch 69_init_waiting from Fedora to make sure the init + waiting status is preserved across re-exec. + * New patch 41_utmp_64bit from Fedora to avoid writing past the + utmp.ut_tv struct on 64 bit architectures. (Closes: #450543) + * New patch 64_init_init_reexec_env from Fedora to fix typo. Now + passes environment on to the new process when re-exec is used. + + -- Petter Reinholdtsen Sun, 23 Dec 2007 19:44:13 +0100 + +sysvinit (2.86.ds1-39) experimental; urgency=low + + [ Petter Reinholdtsen ] + * Upload to experimental to get more feedback from testers. + * Change checkfs.sh dependency info, make modutils an optional + dependency as it is no longer installed by default. + * Move /etc/init.d/bootclean to /lib/init/bootclean, as it is not an + init.d script but a library. + * Acknowledge NMU. (Closes: #433386) + * Make /lib/init/vars.sh usable when 'set -e' is in effect. Patch + from Ubuntu. + * Rename 20_pidof.dpatch to 80_killall_pidof.dpatch, to group the + killall5 patches together. + * New patch 82_killall_exclude_pids.dpatch adding new option -o + to killall5, to omit killing the pid given on the command line. + Based on patch from Ubuntu. (Closes: #453042) + * Use new killall5 -o option in init.d/sendsigs, reading pids to + omit from /var/run/sendsigs.omit. This make it possible to list + pids there if the process is required to umount the file systems + during shutdown. Make initscripts depend on sysvinit-utils + (>= 2.86.ds1-39) to make sure killall5 support the -o option. + Based on patch from Ubuntu. + * Stop progress bar on ltsp-client-core too. The script was renamed + in recent ltsp versions. Based on patch from Ubuntu. + * Add linux-gnulp to debian/deps-mount, to get the correct behaviour + with regard to initscripts dependencies on lpia. Patch from Adam + Conrad in Ubuntu. + * Add splash screen / progress bar API to initscripts in + /lib/init/splash-functions-base, overridable by the splash + implementations in /lib/init/splash-functions. Based on patch + from David Härdeman. (Closes: #423095) Make initscripts conflict + with usplash (<< 0.5) to make sure a version with PULSATE support + is used. + * Rewrite init.d/rc progress bar support to use new API. Move + usplash calls to separate file splash-functions-usplash. This + file should be moved to the usplash package. Based on patch from + David Härdeman. + * Do not mount gfs2 as a local file system. It is a network file system. + Patch from Guido Guenther (Closes: #454468). + * Modify update-rc.d to refuse to install init.d scripts with illegal + characters in the names. Only accept [a-zA-Z0-9+.-] to match the + limits on package names. Correct handling of init.d scripts with + + in their name (Closes: #431224). + + [ Henrique de Moraes Holschuh ] + * libata shutdown handling fixes: + Check http://linux-ata.org/shutdown.html for information + * init.d/halt: do not issue -h to halt(8) when the kernel supports + auto-shutdown + * init.d/halt, default/halt: add HDDOWN option to override initscript + halt -h logic + * Add halt(5) manpage, updated for HDDOWN. Thanks to Casper Gielen for + the manpage. (Closes: #407211) + + -- Petter Reinholdtsen Sat, 22 Dec 2007 17:49:42 +0100 + +sysvinit (2.86.ds1-38.1) unstable; urgency=low + + * Non-maintainer upload. + * Rework starting of portmap and nfs-common to better fit the new and + stricter mount.nfs; in particular, statd must be started for almost all + mounts, so start nfs-common even for non-NFSv4 and non-Kerberos mounts. + (Closes: #433386) + + -- Steinar H. Gunderson Tue, 24 Jul 2007 19:31:27 +0200 + +sysvinit (2.86.ds1-38) unstable; urgency=medium + + * Medium urgency as it solve an RC bug in etch. + * New upload, this time with only the files included in svn, and without + the cruft included by mistake last time. No idea why svn-buildpackage + didn't behave as I expected it to. + + -- Petter Reinholdtsen Tue, 30 Jan 2007 23:14:04 +0100 + +sysvinit (2.86.ds1-37) unstable; urgency=medium + + * Medium urgency as it solve an RC bug in etch. + * Replace 66_init_emerg_tty patch with one only creating a new + session group when sulogin is called directly from init, and not + as part of the runlevel start scripts, to avoid leaving the single + user shell behind when switching runlevel. Updated patch from Samuel + Thibault. (Closes:406587) + * Speed up shutdown 1 second by dropping sleep 1 in init.d/halt + introduced 2.86.ds1-12. + + -- Petter Reinholdtsen Sat, 13 Jan 2007 20:04:35 +0100 + +sysvinit (2.86.ds1-36) unstable; urgency=medium + + * Medium urgency as it solve some RC bugs in etch. + * Don't reset step to 0 between running Kill and Start scripts + (this is why the progress bar jumps during splash down). Patch from + Scott James Remnant and Ubuntu. + * Also consider ltsp-client as end-point for the usplash + progress bar. Patch from Scott James Remnant and Ubuntu. + + -- Petter Reinholdtsen Tue, 28 Nov 2006 19:56:20 +0100 + +sysvinit (2.86.ds1-35) unstable; urgency=medium + + * Medium urgency as it solve some RC bugs in etch. + * Make sure init.d/umountfs umount tmpfs file systems in order of + decreasing length, to avoid problems on systems with chroots. + Patch from Peter Rabbitson. (Closes: #391673) + * Add boot option ASYNCMOUNTNFS=no to get the old init.d/mountnfs.sh + behaviour until ifup work properly with / on NFS. The default is + 'yes' as it has the highest chance of success for non-diskless machines. + It is also useful for machines with multiple network cards. + (Closes: #388761, #393532) + * Fix syslogging code in if-up.d/mountnfs to find logger if it exist. + Patch from John Morrissey. (Closes: #398644) + * Avoid file descriptor leak to mount in init.d/mtab.sh. Based + on patch from David Härdeman. (Closes: #397525). + * Fix typo in message added in 91_sulogin_lockedpw.dpatch. + Thanks to Robert Bihlmeyer. (Closes: #399715) + * Undo use of fuser to kill processes in umountnfs before unmounting + partitions, as it will kill init and /etc/init.d/rc during + shutdown if root is on NFS or tmpfs file systems are bind-mounted + into chroots. Use sendsigs and move it before umountnfs, and thus + reopen bugs #258420, #367944. (Closes: #392861, #391375) + + -- Petter Reinholdtsen Sun, 26 Nov 2006 20:06:00 +0100 + +sysvinit (2.86.ds1-34) unstable; urgency=medium + + * Medium urgency as it solve some RC bugs. + * Remove the postinst code in initscripts for mounting /lib/init/rw/. + Just require a reboot for it to take effect, instead of trying to + make sure it is mounted when the package is installed. Flag this + need using /usr/share/update-notifier/notify-reboot-required if it + exist. (Closes: #393465, #391605, #390126) + * Remove debian/sysv-rc/postinst as well as it is unused now. + * Replace SElinux patches 40_selinux and 41_selinux_console with updated + 40_selinux from Manoj Srivastava. (Closes: #394304) + * Print message when refusing to mount nfs directories because the + lockdir exist. + * Add exit handler in if-up.d/mountnfs to make sure the lock directory + is removed when the script is interrupted. + * Remove NEWS entries explaining how to recover from the version of + sysv-rc present 6th to 8th of September in unstable. Remove + update-rc.d-recover as it should no longer be needed. (Closes: + #394332) + * Add XS-Vcs-Svn entry in the control file, to make the subversion + repository easier to find. + + -- Petter Reinholdtsen Sun, 29 Oct 2006 18:33:33 +0100 + +sysvinit (2.86.ds1-33) unstable; urgency=low + + * Do not insert /dev/.static/dev in /etc/mtab, and do not try to + umount it either. Avoids confusing users. (Closes: #391122) + * Let initscripts conflict with udev << 0.080-1, and stop calling + mountdevsub.sh from mtab.sh. (Closes: #391312) + * Do not fail to install initscripts even if /lib/init/rw/ can + not be mounted. (Closes: #391115) + * Adjust how fuser is called by umountnfs, using the exit code from + fuser instead of looking at its output. Based on patch from Markus + Schoder. (Closes: 390936) + + -- Petter Reinholdtsen Fri, 6 Oct 2006 19:51:05 +0200 + +sysvinit (2.86.ds1-32) unstable; urgency=low + + * Set SE context on /dev/pts and /dev/ptm if they are created by + mountdevsubfs.sh to work better with SELinux. Patch from Erich + Schubert. (Closes: 390897) + + -- Petter Reinholdtsen Wed, 4 Oct 2006 20:39:56 +0200 + +sysvinit (2.86.ds1-31) unstable; urgency=low + + * Fix calls to fuser in umountnfs.sh. Thanks to Frank Mehnert for the tip. + * Correct code detecting single-user in stop-bootlog-single to only + trigger on '1' as single word and not as option argument. (Closes: + #390572, #387340) + + -- Petter Reinholdtsen Mon, 2 Oct 2006 19:55:11 +0200 + +sysvinit (2.86.ds1-30) unstable; urgency=low + + * Avoid mounting /lib/init/rw/ during installation and upgrades if + the kernel do not support tmpfs. (Closes: #390339) + + -- Petter Reinholdtsen Sun, 1 Oct 2006 20:03:33 +0200 + +sysvinit (2.86.ds1-29) unstable; urgency=low + + * Ignore problems with creating /var/run and /var/lock during + installation and upgrades. This should avoid installation problem + in vserver environments. + * Only try to create /var/run and /var/lock on the root file system + in non-chroot environments? + * Use 'mkdir -p' when creating /.root, to avoid failing if it + already exist. (Closes: #390327) + * Do not try to create /var/run and /var/lock during installation or + upgrades if /var is a relative symlink. It is not going to + work. (Closes: #390328) + * List the options found in /etc/fstab after the default options + used when mounting virtual file systems, to allow options in fstab + to override the defaults. (Closes: #390181) + + -- Petter Reinholdtsen Sat, 30 Sep 2006 18:42:44 +0200 + +sysvinit (2.86.ds1-28) unstable; urgency=low + + * Avoid mounting /lib/init/rw/ when being installed in a chroot + environment. (Closes: #390126) + * Update init.d/mtab.sh to make sure it store the correct options + used to mount /dev/shm in /etc/mtab. + * Drop the 'noexec' flag from the /dev/shm/ mount point until etch + is released, to avoid breaking dosemu and user-mode-linux. It will + be reintroduced after etch is released. This is related to + bugs #386945 and #386368. + + -- Petter Reinholdtsen Fri, 29 Sep 2006 18:36:13 +0200 + +sysvinit (2.86.ds1-27) unstable; urgency=low + + * Make sure to mount /lib/init/rw/ during upgrades if it isn't mounted + already, to make it sure available for its users when the new initscripts + package is installed + + -- Petter Reinholdtsen Thu, 28 Sep 2006 20:40:12 +0200 + +sysvinit (2.86.ds1-26) unstable; urgency=low + + * Change umountnfs to use /etc/mtab instead of /proc/mounts, to make + sure it see the _netdev option. umountfs still uses /proc/mounts + to make every non-root file system is unmounted before halt or + reboot. (Closes: #383124) + * Correct exit code handling in init.d/rc.local. (Closes: #389435) + + -- Petter Reinholdtsen Thu, 28 Sep 2006 19:26:54 +0200 + +sysvinit (2.86.ds1-25) experimental; urgency=low + + * Improve manual entry for RAMRUN and RAMLOCK run rcS(5). + * Correct mtab.sh to make sure the mtab content matches the options used + when mounting /var/run/. + * New defaults/tmpfs options RUN_SIZE and LOCK_SIZE, controlling the + tmpfs size. Modified the mount code to also use TMPFS_SIZE if + set as a fallback value. + + -- Petter Reinholdtsen Tue, 26 Sep 2006 15:09:30 +0200 + +sysvinit (2.86.ds1-24) experimental; urgency=low + + * Make sure we do not umount /lib/init/rw/ during shutdown. + * Make it easier to debug the splash progress bar in init.d/rc. + * Correct mtab entry for /sys, to make sure its 'device' is sysfs. + * Include vars.sh in mtab.sh, to make sure the RAMRUN and RAMLOCK + options are available when used. + * Add defaults/tmpfs option RW_SIZE to control the size of + /lib/init/rw/, and change mountkernfs.sh to use TMPFS_SIZE too if + it is set. + * Rewrite post_mountall() function to avoid mounting /var/run/ and + /var/lock/ on top of themselves when RAMRUN or RAMLOCK is enabled. + + -- Petter Reinholdtsen Sat, 23 Sep 2006 19:01:38 +0200 + +sysvinit (2.86.ds1-23) experimental; urgency=low + + * Make the tmpfs on /var/run/ and /var/lock/ optional, and provide + RAMRUN and RAMLOCK options in /etc/default/rcS to control this. + Remove code to convert to this feature when the package is + upgraded or installed. It will take effect after a reboot if + /etc/default/rcS is modified. Keep them disabled for now. + Create .ramfs files in the directories if tmpfs is used to make it + easier for other scripts to know if they are safe to use early in + the boot. + * Create /lib/init/rw/, and mount a tmpfs there to garantee some + writable area very early in the boot. Use this in checkroot.sh if + a device node need to be created. Create .ramfs indicator when + it is mounted. + * Move sulogin to the sysvinit-utils package as well. (Closes: #388417) + * Add new halt option NETDOWN to make it easier to enable + wake-on-lan. (Closes: #388244) + * Add a stop dependency for umountroot on kexec, to document the + correct location for a kexec script. Related to bug #387599. + * Make sure update-rd.d-recover is not compressed to make it easier to run. + + -- Petter Reinholdtsen Fri, 22 Sep 2006 21:34:37 +0200 + +sysvinit (2.86.ds1-22) experimental; urgency=low + + * Let mountdevsubfs provide mountvirtfs to work with init.d scripts + with obsolete dependency information. + * Change mounting of virtual file systems to specify the device name + explicitly, to make sure /proc/mounts and /etc/mtab end up with + the same device name. + * Split killall5, last, lastb, mesg and pidof out of the sysvinit + package into a new sysvinit-utils package to make it easier to + replace sysvinit. (Closes: #385722) + * Mount /var/run/ as tmpfs in mountkernfs.sh, to have some place to + write state information very early in the boot, and thus avoid a + lot of cludges in scripts running before partitions are checked + and mounted. Mount /var/lock/ as tmpfs to avoid having to clean + it during boot, and to have some place to store locks for the + things running before partitions are checked and mounted. + Packages need to create the directories they expect to find in + these directories from now on. Patch from Scott James Remnant and + Ubuntu. + * Adjust checkroot.sh to create the root device node in /var/run/ + when needed, instead of mounting its own tmpfs. Modified + /var/run/ to allow devices and executables. + + -- Petter Reinholdtsen Sat, 16 Sep 2006 12:14:36 +0200 + +sysvinit (2.86.ds1-21) experimental; urgency=low + + * Correct status report handling in umountnfs.sh. Based on patch + from Markus Schoder. (Closes: #386893) + * Change mountnfs.sh, rc.local and skeleton to use /lib/init/vars.sh + instead of sourcing /etc/default/rcS, to activate the INIT_VERBOSE + variable for these scripts. + * Add support in the init.d scripts for the 'quiet' kernel option. + Keep support for the experiemental INIT_VERBOSE, to make it + possible to override VERBOSE=no on the kernel command line. + * New draft patch 68_init_quiet to make init less verbose when the + 'quiet' kernel option is used. If it worked, it would solve bug + #326677. + * Add a few lintian overrides for things that are correct though strange. + * Rewrite sendsigs to sleep up to 5 seconds (instead of always + sleeping 5 seconds) during shutdown if there are no processes left + to wait for. Modify killall5 to make it report if it found any + processes to kill to make this possible. + * Modify mtab.sh to include /dev/.static/dev in /etc/mtab, to avoid + message from umountfs during shutdown about it being missing in mtab. + * Now that mtab is properly updated by mtab.sh before mountall.sh, + there is no need to have special handling of proc file systems. + Remove the code from mountall.sh. (Closes: #359651) + * Only kill processes using remote file systems before trying to + umount them, if fuser from the psmisc package is available, and + move sendsigs to a point between where remote and local file systems + are umounted. Recommend psmisc for package initscripts. + (Closes: #258420, #367944) + * Add conditional dependency on glibc for hostname.sh and + mountkernfs.sh, to allow the glibc warnings to show up without + anything running in parallel. + * Change default PATH in initscripts and init to prefer sbin/ over + bin/, to avoid picking user visible replacement for system + binaries. This avoids shutdown problems on some + machines. (Closes: #354163) + * Fix typo in init.d/README. (Closes: #387236) + * Add /usr/bin/ to the checkroot and checkfs PATH, to make sure + on_ac_power is used if it is available. (Closes: #387308) + * Modify mtab.sh to insert the device name used when mounting + /dev/shm/ in /etc/mtab. (Closes: #387216) + + -- Petter Reinholdtsen Thu, 14 Sep 2006 15:09:33 +0200 + +sysvinit (2.86.ds1-20) unstable; urgency=low + + * Change initscripts postinst to use update-rc.d program instead of + its shell script function when insserv is installed. + * Change updatercd call order in initscripts postinst to make sure + they are called in dependency order, to work better with insserv. + * Improve update-rc.d-recover script to look in /var/log/dpkg.log + for version 2.86.ds1-17 as well as 2.86.ds1-16. Patch from Stefan + Bellon. + * LSB header updates: + - sendsigs should stop before umountnfs, and umountnfs should stop + before umountfs, until we have a solution for bug #258420 and + #367944. + - mountnfs.sh should list $network as an optional dependency like + for umountnfs, to work on machines without network. + + -- Petter Reinholdtsen Sun, 10 Sep 2006 17:45:19 +0200 + +sysvinit (2.86.ds1-19) unstable; urgency=low + + * Add new NEWS entry with a better shell fragment for recovering + from the update-rc.d problem. Add script + /usr/share/doc/sysv-rc/update-rc.d-recover to make it easier for + people to recover from problems introduced in versions 2.86.ds1-16 + and 2.86.ds1-17.(Closes: #386649) + * Rewrite checkroot.sh to not use lazy umount and a private tmpfs, + and keep the tmpfs mounted on /tmp/ as long as checkroot.sh need + it. It seem that fsck did not like relative device paths. + (Closes: #386347, #386699) + * LSB header updates: + - umountfs should execute before umountroot, not before halt or + reboot. + - umountroot should stop in runlevel 0 and 6, and execute before + halt or reboot. + + -- Petter Reinholdtsen Sat, 9 Sep 2006 20:12:47 +0200 + +sysvinit (2.86.ds1-18) unstable; urgency=low + + * Make sure running update-rc.d several times do not remove the + rc*.d/ symlinks, fixing bug introduced in 2.86.ds1-16. Patch from + Arjan Oosting. (Closes: #386500) Added entry in NEWS file to give + clues on how to fix the breakage in upgraded packages introduced + by this. Print a warning when upgrading from the broken versions. + * Change checkroot.sh to use a private tmpfs file system for its + device file if it is missing from /dev/. (Closes: #386347) + * Also create possibly non-existant parent directory of lock directory + /var/run/network/mountnfs in ifup script. Patch from Arjan + Oosting. (Closes: #386449). + * Mark /etc/init.d/rc.local as a conffile, to make sure we do not + replace an exisitng rc.local file without warning the system + admin. (Closes: #386418) + * Mount /dev/pts/ with noexec,nosuid, as it is only used for device files. + * Change sysv-rc to print a message when enabling concurrent boot, + specifying the concurrency style. Recommend lsb-base and use it + if available. + * Teach init.d/stop-bootlogd-single to accept the kernel arguments + 'S' and '1' as well as 'single' as single-user mode triggers. + (Closes: #367465, #372669) + * Only report umounting of remote file systems when there are remote + file systems to umount. + * Remove 'S' from default-stop in skeleton. It never make sense to add + stop links in rcS.d/. + * Remove execute bit from /etc/init.d/skeleton. (Closes: #372666) + * LSB header updates: + - stop-bootlogd should run after rmnologin. + - mountdevsub.sh should start after udev, if it exist. + - rc.local should not depend on $all to allow it to start earler + in the boot. + - stop-bootlogd-single should depend on $all, to get it last in + the rcS.d/ sequence. + - umountnfs.sh should stop in runlevel 0 and 6, and execute before + umountnfs, sendsigs, portman and $network. + - sendsigs should stop in runlevel 0 and 6, and execute before + umountfs. + - umountfs should stop in runlevel 0 and 6, and execute before halt + or reboot, if it exist. + - halt should stop in runlevel 0, and not run before any other script. + - reboot should stop in runlevel 6, and not run before any other script. + + -- Petter Reinholdtsen Fri, 8 Sep 2006 19:07:43 +0200 + +sysvinit (2.86.ds1-17) unstable; urgency=low + + * Make some log messages more usplash friendly in the VERBOSE=yes case. + * Undo fix for #309813, it was correct before. + + -- Petter Reinholdtsen Wed, 6 Sep 2006 20:20:06 +0200 + +sysvinit (2.86.ds1-16) unstable; urgency=low + + * Fix emergency mode's tty, making sure ^C and ^Z work when booting + with 'emergency' kernel option. Patch from Samuel + Thibault. (Closes: #374543) + * Rewrite usplash reactivation code in init.d/sendsigs to match the + code in Ubuntu. It need to behave the same way as the usplash + startup code, and should not match the code deciding if + usplash_write should be used. + * Change handling of CONCURRENCY in init.d/rc, to make sure an + unrecognized value is treated as 'none'. (Closes: #380602) + * Make sure SATA disks are powered down as well as IDE disks. Patch + from Sebastian Reichelt. (Closes: #348172) + * Mount /dev/shm, /sys, /proc and /proc/bus/usb using + noexec,nodev,nosuid to make it harder to misuse. + (Closes: #378182, #378280) + * Move NFS mounting to an if-up.d script, to make sure we try to + mount NFS file systems after the network is available. Based on + patch from Ubuntu. Modified to rewrite mountnfs.sh instead of + renaming it to waitnfs.sh. (Closes: #360123) + * Add rc.local support to be more compatible with non-Debian + distributions. Patch from Fabio M. Di Nitto via Ubuntu. Modified to + not print messages when VERBOSE=no. + * Drop and remove /etc/init.d/mountvirtfs. It is obsolete. + * Do not try to mount netdev file systems in mountall.sh. + (Closes: #383073, #386063) + * Mount netdev file systems when the network is up. (Closes: #383123) + * Umount netdev file systems in umountnfs.sh. (Closes: #383124) + * Remove obsolete code in init.d/rc to execute /sbin/unconfigured.sh + and /sbin/setup.sh. It was only to be used during installation, + and the installer no longer need it. Add a init.d script if you + need the functionallity. + * Change LSB dependency info for mtab.sh. It need a writable root + file system to update /etc/mtab, and should thus depend on + checkroot, not mountall. + * Move mtab to rcS.d/S12mtab.sh, to make sure it is the first script + to run after checkroot.sh. + * Change init.d/mtab.sh to be more self-contained, and update + /etc/mtab with info on all file systems mounted before /etc/mtab + was writable by processing /proc/mounts. Based on patch from + Scott James Remnant and Ubuntu. + * Add empty functions pre_mountall and post_mountall to reduce the + difference between the Ubuntu version + * Modify update-rc.d to run properly with perl error checking enabled. + * Add support for parsing LSB headers in update-rc.d, and use the + runlevel information in the default-start and default-stop headers + if they are present. Document this in update-rc.d(8). This can + be used instead of the 'multiuser' extention in Ubuntu, by setting + the 'default-stop' value to '1' in the init.d script. + Only enable this feature when /etc/update-rc.d-lsbparse exist + while we verify that LSB headers are correct. + * Change the default VERBOSE value from yes to no. + * Move init.d/hostname.sh to the very top of the boot sequence, + as it only require a readable /etc/hostname and a working kernel. + * Use the stop scripts from the runlevel we are leaving, not the one + we are entering, when switching between runlevels. (Closes: #309813) + + -- Petter Reinholdtsen Wed, 6 Sep 2006 15:29:01 +0200 + +sysvinit (2.86.ds1-15) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Modify LSB header for init.d/rmnologin, to make sure it is + executed with the 'stop' argument for runlevel 0 and 6, and make + it depend on '$all' to put it last in the startup sequence. + * Update the LSB descripton header for init.d/hostname.sh. + * Make sure hostname.sh return error code when it fail. (Closes: #365062) + * Fix 'startpar' concurrency option to only run start and stop + scripts only once. Patch from Sören Köpping. (Closes: #378092) + * Fix init.d/rc to make it possible to specify the CONCURRENCY + setting in /etc/default/rcS. + * Fix typo in update-rc.d.8 manual page. Patch from Justin + Pryzby. (Closes: #374476) + * Improve text in init.d/README to make it more obvious that the .sh + scripts should be working also when executed individually. Patch + from Bart Martens. (Closes: #362888) + * Modify the comment before the conditional calls to on_ac_power, to + document that checkfs.sh and checkroot.sh are written to work just + fine also when /usr/bin/on_ac_power is unavailable. (Closes: #367867) + * Integrate the patches from Ubuntu where I understand why they are + useful: + - Change runlevel manpage to be less misleading. + - Make messages in init.d/sendsigs less technical. Based on patch + from Ubuntu. + - Update progress bar changes in init.d/sendsigs and init.d/rc. + Based on patch from Ubuntu. Changed patch to check only once in + init.d/rc if the progress bar is enabled, and to use the same + way in sendsigs and rc to decide if it is enabled or not. It + will be enabled if /sbin/usplash_write is executable. + - If /dev/.udev.log exists, move it to /var/log/udev.log. Patch + from Scott James Remnant. + - Do not umount /dev/shm in umountnfs.sh. It is a tmpfs and can be + safely left behind when shutting down the system. + * Update standards version from 3.6.2.1 to 3.7.2. No changes required. + * Acknowledge NMU. Thanks, Steinar H. Gunderson . (Closes: #359176) + + [ Thomas Hood ] + * Remove myself from uploaders list. + + -- Petter Reinholdtsen Tue, 25 Jul 2006 19:42:27 +0200 + +sysvinit (2.86.ds1-14.1) unstable; urgency=low + + * Non-maintainer upload. + * mountnfs.sh: If needed, call nfs-common's init.d script to start + rpc.gssd or rpc.idmapd as needed. This is needed for Kerberized + NFS mounts and NFSv4 mounts. (Closes: #359176) + + -- Steinar H. Gunderson Sat, 6 May 2006 21:12:39 +0200 + +sysvinit (2.86.ds1-14) unstable; urgency=low + + [ Thomas Hood ] + * umountfs: Unmount in order of decreasing mount point length + without making use of the sort program (Closes: #356226) + Thanks to Jiri Polach for assistance + * Don't Build-Depend on selinux stuff on kfreebsd-amd64 + (Closes: #357245) + * Make initscripts Conflict with sysvinit (<< 2.86.ds1-12) because + bootlogd initscript uses an option that was introduced in + 2.86.ds1-12 (Closes: #357667) + * bootlogd: Mention -p and -c options in usage message + (Closes: #357667 too) + + -- Thomas Hood Thu, 16 Mar 2006 19:45:04 +0100 + +sysvinit (2.86.ds1-13) unstable; urgency=low + + [ Thomas Hood ] + * umountfs: Unmount even if sort not available (Addresses #356226) + * last: Fix strncmp bug (Closes: #353585) + * umountroot: Tweak handling of error messages from mount + (Closes: #352398) + * /etc/init.d/skeleton: Source init-functions (Closes: #353212) + * initscripts.postrm: Don't remove /etc/init.d/mountdevsubfs + * mount{all,nfs}.sh: Don't set TMPTIME cuz it's not used here + * pidof.8: Don't imply that pidof is in /sbin (Closes: #352741) + * sysv-rc: /etc/init.d/README: Refer user to /usr/share/doc/sysv-rc/ + (Closes: #353083) + * Add NEWS.Debian with entry for 2.86.ds1-10 which reports the + replacement of the bootclean.sh function library by the + bootclean initscript. (Closes: #355746) + + [ Petter Reinholdtsen ] + * Silence init.d/hostname.sh when VERBOSE=no. + * /etc/init.d/skeleton: Show how to use the VERBOSE variable. + + -- Thomas Hood Mon, 13 Feb 2006 08:42:44 +0100 + +sysvinit (2.86.ds1-12) unstable; urgency=low + + [ Thomas Hood ] + * Aim for testing: Closes: #341075 + * Fix dependency on mount for GNU/kFreeBSD (Closes: #349984) + This involved updating deps-mount and deps-glibc (Closes: #335297) + * bootlogd: 51_bootlogd_syncalot: Don't sync after each line unless + the (new) -s option is given + (Closes: #205724) + * bootlogd: 52_bootlogd_createlogfile.dpatch: Don't write to logfile + if it doesn't exist unless the (new) -c option is given + (Closes: #341167) + * bootlogd: 53_bootlogd_ttyB.dpatch: Also try ttyB0 + (Closes: #348506) + * last: 25_last_sanify: In "last -x" output: + + On "reboot" line print endpoint of uptime too + + On "shutdown" line print downtime rather that time between downs + (Closes: #58119) + * init: 41_selinux_console.dpatch: print to same console as others do + (Closes: #349149) + * bootclean: Don't fail to clean all directories in /tmp + (Closes: #350218) + * mountall.sh: Suppress error message about /proc already being mounted + (Closes: #349275) + * checkroot.sh: Don't try to enable swap if a swap device is + /dev/mapper/* or a swapfile (Closes: #346329, #348534) + * checkroot.sh: Remove some code specific to pre-2.4-Linux + * umountfs + - Don't try to unmount tmpfs on /dev (Closes: #350998) + - Improve comment explaining use of sort (Closes: #351497) + * several scripts: messages: Tweak; better condition them on $VERBOSE + * initscripts postinst: Don't run mount{kern,devsub}fs.sh + * initscripts postinst: Actually remove some things on purge + * rcS(5): Improve; mention that if UTC=no then admin must ensure + that zoneinfo is available + * shutdown(8): Fix typo (Closes: #350830) + * Add README.Debian for sysv-rc + * debian/rules: + + Handle older dpkg-architecture + + Tweak Build-Depends on libselinux1-dev (Closes: #340285, #351906) + + [ Robert Millan / TH ] + * inittab on GNU/kFreeBSD: (Closes: #351615) + - Pass "cons25" as parameter to getty (leaving it unspecified + required hacks in the getty side). + - "translate" all device names into kfreebsd ones, including those + in comments. + + [ A Costa / TH ] + * man pages: 10_doc_manuals.dpatch: Fix a shipload o' typos + (Closes: #349768, #349769, #349770, #349771, #349772, #349773) + + [ Ruben Porras / TH ] + * Fix typos in Spanish update-rc.d(8) (Closes: #349805) + + [ Henrique de Moraes Holschuh ] + * [S390] inittab: rename inittab.s390-linux to inittab.s390-linux-gnu + (Closes: #351871) + + -- Henrique de Moraes Holschuh Thu, 9 Feb 2006 09:27:51 -0200 + +sysvinit (2.86.ds1-11) unstable; urgency=low + + [ Thomas Hood ] + * rcS(5): Improve + * sulogin(8): Improve; mention -t option (Closes: #186880) + * bootlogd(8): Improve; mention need for PTY support + * initscripts postinst: Update to reflect script name changes + * initscripts: Harmonize PATH settings + * checkroot.sh: Don't check for need to start /sbin/update. + We don't support pre-2.4 kernels any more. + * checkroot.sh, mountall.sh: Run swapon with -v if VERBOSE!=no + * Remove obsolete lintian overrides + * Previous release also + closes: #258290 "bootlogd: Bad file descriptor" + closes: #327865 "bootlogd stopped working" + closes: #328764 "bootlogd fails to start" + + [ Petter Reinholdtsen ] + * Time to upload all these changes into unstable (Closes: #341075) + * Revert default VERBOSE value to "yes" to reduce the amount of + user visible changes in this upload. + + -- Petter Reinholdtsen Sun, 22 Jan 2006 22:17:38 +0100 + +sysvinit (2.86.ds1-10) experimental; urgency=low + + [ Thomas Hood ] + * bootclean: Adapt from old bootclean.sh; handle return status more + carefully; print diagnostic messages on failures; eliminate use of + subshells; add comments; improve deletion code + * bootclean: Always rm /tmp/.X*-lock + * mountall.sh: Eliminate unnecessary check for pre-2.4 Linux kernel + * mountnfs.sh, mountall.sh: Choose different names for intnl. functions + * mountnfs.sh: Only sleep 1 second after starting portmap; note that + the code to start portmap will disappear someday + * various scripts: Make more messages depend on VERBOSE being != "no" + * various scripts: Handle return status more carefully + * various scripts: Eliminate unnecessary uses of subshell + * mountvirtfs -> mountkernfs.sh; mountdevsubfs -> mountdevsubfs.sh; + mountvirtfs now calls the above two (for backward compatibility); + mtab.sh now runs mountkernfs.sh and mountdevsubfs.sh to update + the mtab file after mountall.sh. + * /etc/init.d/rc: Restore PATH after sourcing an initscript + * debian/rules: + + Use ':', not the deprecated '.' between owner and group names + in chown commands + + Use '-o root' with install + * /etc/init.d/README: Note that /etc/init.d/*.sh must have '#!/bin/sh' + and must follow policy 10.4. + * Override lintian and linda warnings + + [ Ubuntu backports by T.H. ] + * During shutdown and reboot take the progress bar from 100 to 0 + * Reduce diff with 2.86.ds1-6ubuntu1 + + Thanks to Mark Hatle and Marco d'Itri for help with this release. + + -- Petter Reinholdtsen Sun, 15 Jan 2006 13:38:42 +0100 + +sysvinit (2.86.ds1-9) experimental; urgency=low + + [ Thomas Hood ] + * Split mountdevsubfs out of mountvirtfs and run it at S04 and S37. + [Note added in 2.86.ds1-10: these scripts were renamed] + This should not behave any differently, but the split will allow + packages that futz with /dev to do this at S03. + * umountfs: Only run umount if there is something to unmount + (Closes: #345272) + * urandom: Set PATH so that find can be found (Closes: #345273) + * init: 64_init_set_PATH.dpatch: Set PATH if it's unset on re-exec + (Closes: #345370) + * init: 65_init_u_in_06.dpatch: Allow 'telinit u' in runlevels 0, 6 + (Closes: #345719) People running Debian from unusual media (such + as filesystems embedded in NTFS files) are wanting to unmount + /sbin at the last moment and need to re-exec init to do so. + * umountroot: Remount ro with -f on GNU/kFreeBSD (Closes: #344547) + * checkroot.sh, checkfs.sh: Pause for five seconds if sulogin fails + so that the user can see the error message (Addresses #337444) + * Include /var/log/fsck/ in initscripts package (Closes: #346139) + * Replace /lib/init/functions.sh with /lib/init/mount-functions.sh + for use by mountvirtfs and mountdevsubfs + * various initscripts: Clean up code that reads fstab + * various scripts: Redirect which program's stderr to /dev/null + since the GNU version prints an error message when the command is + not found (Closes: #345321) + * /etc/default/rcS: Make VERBOSE and DELAYLOGIN default to "no" + * /etc/default/rcS: Remove descriptions of variables; leave behind + a reference to rcS(5). This eliminates the problem of comments + becoming outdated without our being able to update them. + * Remove obsolete docs + * Make initscripts Depend on mount >= 2.11x-1 (Closes: #345968) + * Remove obsolete dependencies on bsdutils, coreutils, dpkg, kbd and + util-linux: the versions in question are older than oldstable, so + any newly installed system and any system that has upgraded to + sarge (or even woody) satisfies the constraints. + * Remove obsolete dependency on the last package: last was forced off + systems when they upgraded to buzz + * Add Replaces to Conflicts: mdutils which no longer exists even in + oldstable + * initscripts postinst: Remove obsolete GMT-to-UTC code: this + conversion was performed when systems were upgraded to potato + * sysvinit: Depend on libc6 rather than Pre-Depending on it; we don't + do anything special in the preinsts any more + * Correct documentation of init's -e and -t options + * Tweak descriptions + * Add READMEs for remaining runlevel dirs (Closes: #242957) + * Previous release also + closes: #227540 "skeleton: Don't include /usr/local/* in PATH" + closes: #346415 "mountnfs.sh doesn't work with the "bg" mount option" + + [ Petter Reinholdtsen ] + * sysv-rc: Fix some typos in the startpar handling. (Closes: #345269) + * Add code to detect and report bad 'exit' calls in init.d scripts, + if they kill /etc/init.d/rc. + * Make sure sourcing work with dash /bin/sh, by using 'set $action' + to pass arguments to the script. (Closes: #345267) + + Thanks to Mark Hatle for help with this release. + + -- Petter Reinholdtsen Sun, 8 Jan 2006 18:08:51 +0100 + +sysvinit (2.86.ds1-8) experimental; urgency=low + + [ Thomas Hood ] + * Omit /run until we are sure it's needed (Closes: #344001) + * Previous release also + closes: #338736 "mountvirtfs: Succeeds in various cases it should fail" + closes: #342160 "checkroot.sh ignores fsck result" + closes: #342744 "checkroot.sh sources mountvirtfs, yet supplies arguments" + * Use /proc/mounts instead of /etc/mtab when unmounting (Closes: #338801) + * Check for files under mountpoints more thoroughly + * initscripts.postinst: + + Don't fail to install on file-rc systems (Closes: #343993) + + Don't fail to install in chroots (Closes: #344089) + * No longer keep the dynamic nologin flag file on the root filesystem; + instead, keep it at /var/lib/initscripts/nologin. Note to admins: + initscripts's postinst symlinks /etc/nologin to the latter location. + To switch login delaying on or off permanently, set DELAYLOGIN=no in + /etc/default/rcS and either create or delete (respectively) + /var/lib/initscripts/nologin. + * mountvirtfs: Mount /dev/shm earlier; move long comment to README.Debian + * Add 45_pidof_symlink.dpatch: Make pidof an absolute symlink + (Closes: #343862) + * debian/rules, 30_strip.dpatch: Strip .comment section from executables + (Closes: #343863) + * In umountfs, run umount with -f (Closes: #344547) + + [ Petter Reinholdtsen ] + * Enable the startpar option as it should work now that .sh scripts + are serialized. The clock should no longer jump while startpar + is used. + + -- Petter Reinholdtsen Tue, 27 Dec 2005 14:18:19 +0100 + +sysvinit (2.86.ds1-7) experimental; urgency=low + + [ Petter Reinholdtsen ] + * Add commented-out code to /etc/init.d/rc for sourcing + *.sh scripts for runlevel 'S'. This is preparation for fixing + #339955. Actually fixing it has to wait until other packages + remove "exit" from their .sh scripts. + * Implement progress bar support for splash screen. Enabled when + usplash_write is in PATH. Patch from Scott James Remnant and Ubuntu. + + [ Thomas Hood ] + * *.sh: Make sure that these do their thing when they aren't given any + command line arguments (as is the case when they are sourced) + * initscripts: Improve use of log_* functions + (Closes: #55143, #116366, #323749) + * bootclean.sh: Do not delete symlinks-to-directories from /var/run/ + (Closes: #272066) + * checkroot.sh: Fix double printing of 'Done checking root file system'; + mountall.sh: Fix chopped-up printing of mount information + (Closes: #339979, #331397, #341097 and presumably closes: #332309) + * checkroot.sh, checkfs.sh: Save fsck logs (Closes: #189356) + Thanks to Theodore Y. Ts'o. + * checkroot.sh, mountvirtfs: Eliminate use of dir_writable in order to + try to please selinux (Closes: #333836) + * checkroot.sh: Only run findfs for mount on / (Closes: #275680) + Thanks to Cameron Hutchison for the patch. + * mountall.sh, mountnfs.sh: Split call to bootclean out into separate + script called at the next sequence number (Closes: #286479) + * bootmisc.sh: Shorten motd header (Closes: #340017) + * bootmisc.sh: Store dynamic motd in /var/run/ and make /etc/motd a + symbolic link. The EDITMOTD variable no longer has any effect; to + disable updating of the motd just point the /etc/motd symlink to a + static file such as /etc/motd.static. + * bootmisc.sh: Rotate dmesg log with savelog (Closes: #237074) + and chgrp adm. + * umountroot: Change mount command in order to exclude bind mounts of + the root directory (Closes: #339023) + * Replace /etc/rc1.d/20single by /etc/rc1.d/S30killprocs and + /etc/rc1.d/S99single so that packages can insert scripts to do + things between the "killall5" in the former and the "exec init -t1 S" + in the latter. This may help to address #145280. + * umountfs: Unmount tmpfs before swapoff and other fs's afterwards + (Closes: #328582, hopefully without reopening #84782) + * Make stop-bootlogd a distinct script rather than a symlink to bootlogd. + Give it its own LSB header. + * Add stop-bootlogd-single initscript to stop bootlogd in "single" mode + (Closes: #213028, #220025) + * checkfs.sh: Implement FSCKTYPES (Closes: #89481) Set, e.g., + FSCKTYPES="ext2,msdos" to fsck only file system types ext2 and msdos + See fsck(8) for syntax. FSCKTYPES="none" disables fsck of file + systems (other than the root filesystem) altogether. + * all initscripts: Set variables using common script + * all initscripts: Fix usage messages + * all initscripts: Allow VERBOSE to be set via the INIT_VERBOSE=yes + kernel argument (Closes: #286082) Experimental. The name of the + kernel argument may change in the future if we decide to implement + this more generally. + * Improve skeleton initscript + * all scripts: Clean up; standardize indentation + * all scripts: Use the "which" program to test for executability + * initscripts: Experimentally include /run; include /sys in Linux + builds + * mountvirtfs: Mount a tmpfs on /run + * mountvirtfs: Warn if mount point has stuff under it (Closes: #95390) + * initscripts postinst: Mount virtual filesystems + * initscripts preinst: Remove ancient /etc/init.d/boot conversion code + (Closes: #343596) + * default config files: Clean up comments + * Make initscripts Depend on debianutils >= 2.13.1 in order to prevent + #295850. Note that debianutils also has to be >= 2.12.0 so that the + "which" program is available in /bin. + * Remove currently unneeded sysvinit Dependency on coreutils + (Closes: #316423) + * pidof: If the program is specified with a path, don't match processes + of programs run from different paths (Closes: #160329) + * init: 40_selinux.dpatch: Remove superfluous printf argument + * init: Add 63_init_longer_procname.dpatch (Closes: #336172) + * init.8: Mention that entering runlevel 1 kills all processes + (Closes: #238861) + * update-rc.d.8: Mention that update-rc.d will not create multiple start + or multiple stop symlinks for a service in a single runlevel directory. + (Closes: #330155) + * Update FSF address + + -- Petter Reinholdtsen Sat, 17 Dec 2005 21:26:03 +0100 + +sysvinit (2.86.ds1-6) unstable; urgency=low + + [ Petter Reinholdtsen ] + * Updated versioned dependency of sysvinit from sysv-rc version + 2.85-2 to version 2.86.ds1-1.2, to make sure init.d/rcS calls all + init.d scripts with 'start' argument. Let initscripts conflict + with sysv-rc (<< 2.86.ds1-1.2) as well, to document that it need a + newer sysv-rc to work properly. (Closes: #338966) + * Added 91_sulogin_lockedpw.dpatch to make sure file systems can be + fixed on machines with locked root accounts too, by presenting a + shell in these cases. Patch from Ubuntu and Thom May. + (Closes: #326678) + * Make sure checkroot.sh calls mountvirtfs with argument 'start', to + avoid usage message and making sure it is executed as it + should. (Closes: #338966, #339351) + * Print message when hostname is set. Use default 'localhost' if no + hostname is set in /etc/hostname, and no current hostname is set. + * In mountall.sh, add '-e' to swapon call, to ignore missing devices + when enabling swap. Because of this, show error messages from + swapon. + * Add link to alioth project page in the Debian README. + * Created new file /lib/init/functions.sh for functions common to + scripts in initscripts. Moved dir_writable() into it. + * Add new function selinux_enabled(). Use it before running + /sbin/restorecon. + + [ Thomas Hood ] + * Improve update-rc.d man page text. + * Use log_action_* functions from recent (>= 3.0-6) lsb-base, to + improve output formatting. (Closes: #338967) + * Clean up initscript messages a bit, making them easier to + understand for non-technical users. + + -- Petter Reinholdtsen Sat, 19 Nov 2005 15:07:33 +0100 + +sysvinit (2.86.ds1-5) unstable; urgency=low + + [Petter Reinholdtsen] + * Make sure init.d/bootmisc.sh depend on hostname, as it uses the + host name when generating motd. + * Improve update-rc.d(8) manual page, documenting how to remove + services and how to make sure services are not started. Patch + from Peter Valdemar Mørch. + * Add sysv-rc-conf(8) to the SEE ALSO section of update-rc.d(8). + * Add suggest to bum for sysv-rc. Also added bum(8) to the SEE ALSO + section of update-rc.d(8). (Closes: #332823) + * Get update-rc.d to understand symlinks to /etc/init.d/ as well as + symlinks to ../init.d/. (Closes: #338666) + * Adjust and clean up init.d dependecy information. + * Added 90_shutdown_H.dpatch to make sure shutdown flags -P and -H + require the -h flag, and document this in the manual page. + (Closes: #331041) + * Added 71_wall_hostname.dpatch to include hostname in wall message + from halt. (Closes: #325772) + * Add comment in freshly installed /etc/default/rcS mentioning its + origin. (Closes: #336873) + * Revert fix for bug #295335, as the manual page patch is reported + to be incorrect. Commented out 10_doc_lastb.dpatch from patches/00list. + * Improve argument handling for init.d scripts. Based on patch from + Enrico Zini. + * On FreeBSD, set TERM=cons25 in init as the kernel isn't setting + TERM. Patch from Robert Millan. (Closes: #335023) + + -- Petter Reinholdtsen Sun, 13 Nov 2005 12:55:47 +0100 + +sysvinit (2.86.ds1-4) unstable; urgency=low + + [Petter Reinholdtsen] + * Add '#! /bin/sh' to the init.d scripts missing those. + * Improve boot message for init.d/bootlogd. + * Make sure init.d/checkroot.sh only print status of swap mounting + when VERBOSE!=no. Improve boot message for this case. + * Improve usage message of update-rc.d. Uncredited patch from Ubuntu. + * Set pkg-sysvinit-devel@lists.alioth.debian.org as the package + maintainer, and move Miquel van Smoorenburg into the uploaders list. + * Get bootlogd working, by fixing the exit code patch. (Closes: #327865) + * Get ifdown working on kFreeBSD. (Closes: #327031) + * Quiet down update-rc.d by removing unnecessary warning. Patch + by Thomas Hood. (Closes: #164471) + * Improve update-rc.d(8) manual page. (Closes: #243154) + * Fix typo in pidof(8) manual page. + * Update FSF address in copyright files. + + -- Petter Reinholdtsen Sun, 2 Oct 2005 11:44:07 +0200 + +sysvinit (2.86.ds1-3) unstable; urgency=low + + * Fixed typo in last(1) manual page. (Closes: #326408) + * Documented -e and -t option in telinit. (Closes: #272657) + * Rewrote init.d/rc to avoid error from ls when no start or stop + script is present in one rcX.d directory. + * Updated the startpar source to version 0.49 from + . Still hanging the + boot on my test machine, so it is not included in the binary + package. Added 01_enable_startpar.dpatch to document how to + enable it. + * Changed section of packages from base to admin, to match override + file. + * New lsb-base package avoid error during shutdown. (Closes: #327570) + + -- Petter Reinholdtsen Sun, 25 Sep 2005 10:40:03 +0200 + +sysvinit (2.86.ds1-2) unstable; urgency=low + + * This package is now maintained on Alioth as the pkg-sysvinit project. + * Add myself as uploader. + * Add support for linprocfs on kFreeBSD. Patch from Robert + Millan. (Closes: #300963) + * Rewrote /etc/mtab handling in mountvirtfs to work with SELinux. + Based on patch from Luke Kenneth Casson Leighton. + (Closes: #270919) + * Add SELinux support to sysvinit on linux. Add build-depend on + libselinux1-dev and libsepol1-dev for all linux archs. Patch from + Manoj Srivastava, based on patch from Fedora. (Closes: #242900, + #249515,#315611) + * Drop redundant build-depend on essensial package bash. + * Add version 0.47 of startpar(8) program from SuSe. Part of + experimental parallel booting system. Not included by default + yet, as it tend to hang during boot. + * Add support for starting init.d scripts on the same level in + parallel, to speed up the boot process a bit. Currently, only a + simple system is implemented (and enabled by adding + CONCURRENCY=shell in /etc/default/rcS). This simple system messes + up the script output during boot. Disabled by default. (Closes: + #316290) + * Add 'kdm xdm gdm $syslog' as conditional dependencies of + rmnologin, to move it further back in the boot process. + * Make sure bootlogd return non-error exit code after forking off + the child. (Closes: #326640) + * Add more warning flags to list of compiler flags, to get more + info about problematic code. + * Avoid race-condition while fork()ing. Patch from SuSe. + (Closes: #327612) + * Improve error message when fork() fail in init. Patch from SuSe. + * Avoid hardcoding tty name length in wall, use UT_LINESIZE instead. + Patch from SuSe. + * Force kernel to reschedule after killing processes. Patch from SuSe. + * Make sure killall never tries to kill init (pid 1). Patch from SuSe. + * Acknowledge NMUs. (Closes: #30659, #85221, #204857, #225476, + #247102, #248739 #252059, #267935, #269774, #269894, #272588, + #272916, #273496, #277204, #281782, #284426, #286081, #287243, + #288098, #289562, #295094, #295335, #296489, #300645, #311741, + #314351, #316431, #317385, #317704, #318453, #318857, #323749, + #325933, #326460, #326495, #326647) + + -- Petter Reinholdtsen Sat, 11 Sep 2005 17:46:54 +0200 + +sysvinit (2.86.ds1-1.2) unstable; urgency=low + + * Non-maintainer upload to fix bugs. + * Moved all changes to upstream source to debian/patches/, and use + dpatch to apply them. + * Modified pidof to not print empty line if no pid was found. + (Closes: #225476) + * Merged rcS into rc. (Closes: #326460) + * Convert french version of update-rc.d(8) from UTF-8 to + ISO-8859-1. (Closes: #273496) + * Make sure binaries are stripped when installed, to avoid lintian + warning. + * Fix typo in debian/README (seperate->separate). + * Modify debian/rules to install Debian changelog for sysv-rc and + initscripts as changelog.Debian to keep lintian happy. + * Corrected section of mountpoint(1) manual page. + * Improve lastb(1) manual page. (Closes: #295335) + * Changed init.d/rc to short-circit stop scripts when switching + runlevels. Based on patches from Lukas Eppler and Steven + Barker. (Closes: #30659) + * Optimize boot speed by enabling the short-circit of start-scripts + when switcing from rcS.d to the real runlevel. + * Splitted umountfs in umountfs and umountroot. (Closes: #252059) + * Avoid umounting /dev/ in umountfs. (Closes: #287243) + * Made sure all init.d scripts handle start or stop + argument. (Closes: #326495) + * Added GFS file system to list of networked file systems. + (Closes: #295094) + * Added ocfs2 file system in to list of networked file systems. Patch + from Fabio M. Di Nitto and Ubuntu. + * Added trailing newline to the rebooting message, to make sure + kernel messages end up on lines of their own during + reboot. (Closes: #323749) + * Added init.d script dependency info in LSB format. (Closes: #325933) + * Do not fsck when running on battery. Patch from Thom May and + Ubuntu. (Closes: #326647) + * Updated initscripts to depend on lsb-base, and use the LSB + functions in all init.d scripts. Patch from Ubuntu. (Closes: #269774) + * Added some support for VERBOSE in checkfs.sh. + * Make sure urandom pool size is restored on boot. (Closes: #267935) + * Make it easier to override /etc/defaults/rcS parameters. (Closes: #286081) + * Accept 96 (32/mount failure + 64/some mount succeeded) as a valid + exit code from mount in mountall.sh. It seem to be returned when + some mount points already was mounted. + * Updated Standards-Version to 3.6.2.1 (no changes needed). + + -- Petter Reinholdtsen Sat, 10 Sep 2005 12:50:10 +0200 + +sysvinit (2.86.ds1-1.1) unstable; urgency=low + + * Non-maintainer upload (bug cleanup) + * Fix stupid find warning by ordering the arguments correctly in + /etc/init.d/bootclean.sh (closes: #284426, #316431) + * Have cleantmp() in bootclean set TMPTIME to 0 if undefined to prevent + from breaking if the variable is not defined properly. (Closes: #314351) + * Introduce a better warning message in checkroot.sh when it fails + to fsck the root filesystem (Closes: #272916) + * Added a comment in /etc/init.d/skeleton regarding the use of 'sleep 1' + and describing possible changes maintainers might need to introduce + (Closes: #277204) + * Remove .clean files if not owned by root in bootclean.sh to prevent users + from tricking us to _not_ clean up some directories (Closes: #289562) + * Do not remove nologin twice (i.e. in checkroot.sh and in rmnologin) + (Closes: #317704) + * Check if there is a portmapper running before starting it up in + mountnfs.sh, also, use the portmap init.d script instead of running it + through start-stop-daemon if it is available (Closes: #85221) + * Do not install manpages with the execute permission bit (Closes: #281782) + * Clarify semantics of TMPFS_SIZE in /etc/default/tmpfs (Closes: #317385) + * Add feedback to user based on start-stop-daemon exit code + in the skeleton init script (Closes: #296489) + * Document the fact that shutdown touches /etc/nologin only 5 minutes + before shutting down the system (Closes: #204857) + * Add '-f' option to last manpage (Closes: #247102) + * Fix man page and help screen of update-rc.d (Closes: #268713, #288098) + * Changed 'editted' to 'regenerated' in /etc/default/rcS (Closes: #269894) + * Fix formatting issue in mesg(1) (Closes: #272588) + * Fix typo in bootlogd(8) manpage (Closes: #300645) + * Document exit status of pidof(1) (Closes: #311741) + * Point to proper chapter in init.d/README (Closes: #318453) + * Describe the proper behaviour in rcS's README (Closes: #318857) + * Added watch file provided by Stefano Fabri (Closes: #248739) + + -- Javier Fernandez-Sanguino Pen~a Wed, 10 Aug 2005 18:58:47 +0200 + +sysvinit (2.86.ds1-1) unstable; urgency=low + + * New upload with a clean .orig.tar.gz archive without the .o files. + No other changes from 2.86-5. Used the .ds naming convention + that is suggested for packages which need to have their + docs removed (thanks, Marc Haber) + + -- Miquel van Smoorenburg Fri, 10 Dec 2004 00:04:18 +0100 + +sysvinit (2.86-5) unstable; urgency=high + + * Remove leftover debugging "echo" that prevented + /etc/init.d/mountnfs.sh from actually doing anything (closes: #270894) + + -- Miquel van Smoorenburg Fri, 10 Sep 2004 16:57:34 +0200 + +sysvinit (2.86-4) unstable; urgency=high + + * Same upload, this time built without -sa so that original source + isn't included (archive rejects it). + + -- Miquel van Smoorenburg Wed, 8 Sep 2004 11:59:08 +0200 + +sysvinit (2.86-3) unstable; urgency=high + + * Upload of -3 to unstable so that -2 can go into testing-proposed-updates + + -- Miquel van Smoorenburg Mon, 6 Sep 2004 20:07:38 +0200 + +sysvinit (2.86-2) testing-proposed-updates; urgency=high + + * Remove .clean file before touching it; prevents symlink attack + which in rare circumstances could result in random file creation + (closes: #264234) + * Do the above in a noclobber environment (Martin Pitt). + * Don't mount network filesystems multiple times (closes: #264894) + * Include .orig.tar.gz source in -2 again ("dpkg-buildpackage -sa") - + the one that comes with -1 erronously includes .o files and + binaries (oops!). + + -- Miquel van Smoorenburg Mon, 6 Sep 2004 19:02:19 +0200 + +sysvinit (2.86-1) unstable; urgency=medium + + * Better algorithm for pidof (closes: #248210) + * Include fsck.nfs.8 (closes: #250089) + * Include new skeleton script (closes: #244908) + * Better error message on failure to find path to mtab (closes: #255820) + * Add support for fstype ncp (alias for ncpfs) (closes: #259971) + * Touch /tmp/.clean earlier (closes: #255303) + * Don't include halt and reboot for hurd-i386 (closes: #255880) + * Remove XSIisms in mountvirtfs and invoke-rc.d (closes: #256726) + * Add "-t $roottype" to mount -f for / (closes: #255849) + * Always initialize PATH (to /bin:/usr/bin:/sbin:/usr/sbin) (closes: #258065) + * Try harder to remount ro and rw (closes: #259979) + * Add support for LABEL=/UUID= in checkroot.sh (closes: #261342) + + -- Miquel van Smoorenburg Fri, 30 Jul 2004 14:17:05 +0200 + +sysvinit (2.85-22) unstable; urgency=medium + + * Fix typo in /etc/init.d/halt (closes: #255133) + + -- Miquel van Smoorenburg Sat, 19 Jun 2004 12:40:12 +0200 + +sysvinit (2.85-21) unstable; urgency=medium + + * Create dependencies on glibc (>= 2.3.2.ds1-12) not through the + shlibs.local hack anymore. That might clash with a future system + shlibs file. Use the same method as we use to generate the + mount dependency - with a script (closes: #253314). + * In checkroot.sh always use the two-argument version of mount + so that mount doesn't confuse device and directory (closes: #254724) + * Change [ cond1 -a cond2 ] to [ cond1 ] && [ cond2 ] everywhere. + * Fix mountvirtfs, it broke for virtual filesystems mentioned in + fstab without any options (closes: #254271) + + -- Miquel van Smoorenburg Fri, 18 Jun 2004 13:43:55 +0200 + +sysvinit (2.85-20) unstable; urgency=low + + * Create /dev/pts in mountvirtfs for Linux + devfs (closes: #252625) + + -- Miquel van Smoorenburg Mon, 7 Jun 2004 13:45:12 +0200 + +sysvinit (2.85-19) unstable; urgency=low + + * Create /dev/{pts,shm} and /sys in postinst (closes: #252820, #252925) + + -- Miquel van Smoorenburg Mon, 7 Jun 2004 13:30:31 +0200 + +sysvinit (2.85-18) unstable; urgency=medium + + * Fix typo in /etc/init.d/single (closes: #252611) + + -- Miquel van Smoorenburg Fri, 4 Jun 2004 14:38:55 +0200 + +sysvinit (2.85-17) unstable; urgency=low + + * On Debian/k*BSD, dmesg is in /sbin (closes: #252518) + * On Debian/k*BSD, RB_HALT_SYSTEM is called RB_HALT + * RB_POWEROFF can be RB_POWER_OFF (closes: #252547, #252598) + * Add /sys, /dev/pts and /dev/shm to sysvinit. Remove the + mkdir's for those directories from mountvirtfs. + + -- Miquel van Smoorenburg Fri, 4 Jun 2004 11:51:46 +0200 + +sysvinit (2.85-16) unstable; urgency=high + + * Remove /etc/init.d/{mountkernfs,devpts.sh) that glibc installed + since mountvirtfs now provides these. (closes: #230857) + * Remove -e from mountvirtfs (closes: #232122) + * Add some more comments/documentation to mountvirtfs + * Initscripts depends on libc6 anyway right now, so we let it + depend on libc6 (>= 2.3.2.ds1-12) via shlibs.local + * Suggest sysv-rc-conf (closes: #244643) + * Updated french manpage for update-rc.d (closes: #245007) + * Use larger dmesg buffer (-s option) (closes: #242923) + * Fix up comments in /etc/default/tmpfs (closes: #245681) + * Added GNU/Hurd and kFreeBSD fixes (closes: #246743) + * Run mountvirtfs again at S36 so that it mounts /proc/bus/usb in + case usb was loaded as a module (closes: #249031) + * Don't mkdir /dev/pts if it's not there - and don't mount devpts + filesystem on it either in that case. Should help udev. + * mountvirtfs now uses the options from /etc/fstab (closes: #251016) + * add filesystem type "cifs" as network fs (closes: #248919) + + -- Miquel van Smoorenburg Thu, 3 Jun 2004 20:03:33 +0200 + +sysvinit (2.85-15) unstable; urgency=high + + * Drop bogus dependency on fileutils (closes: #241570) + + -- Miquel van Smoorenburg Mon, 5 Apr 2004 17:07:24 +0200 + +sysvinit (2.85-14) unstable; urgency=high + + * When remounting "/", just use "mount -n -o remount,rw /" and don't + bother with the device or other arguments - "mount" will look up the + root device in /etc/fstab, but the device argument to the mount + system call is ignored by the kernel for remount anyway. So this + doesn't hurt even if the device is incorrect, and it fixes a + platform dependant case where "mount -n -o remount,rw /" + fails with "mount: you must specify the filesystem type". That + is a bug in mount(8): if you don't specify the type, it passes + garbage to the kernel, and some archs choke on that. + (closes: #239735) + * change checkroot.sh so that it never checks the root filesystem + if root is on NFS even if fs_passno is set (closes: #240470) + * Reckognize type "nfs4" as network filesystem + * Better check for file-rc in postinst of initscripts (closes: #240066) + * Use /proc/sys/kernel/random/poolsize in urandom script (closes: #240057) + * Applied Debian/KFreeBSD patches. Moved initctl to /etc/.initctl + for the FreeBSD kernels. (closes: #226939) + + -- Miquel van Smoorenburg Wed, 31 Mar 2004 13:10:48 +0200 + +sysvinit (2.85-13) unstable; urgency=low + + * Add /etc/default/halt (closes: #196983) + * Set default variables used in every /etc/init.d script explicitly + and only source /etc/default/rcS if it is present (closes: #239439) + * Fix MOTD typo in bootmisc.sh (closes: #239279) + * Include lastb (closes: #239586) + * Remove /lib/init/realpath (closes: #239343) + + -- Miquel van Smoorenburg Tue, 23 Mar 2004 16:55:38 +0100 + +sysvinit (2.85-12) unstable; urgency=low + + * Support for root on devices with a dynamic major, such as + LVM and partitionable RAID. If the root device in /etc/fstab doesn't + match up with the actual root device, we try to create a temporary + device node in /dev/shm/root so fsck and remount rw can be done. + * Use lstat() instead of stat() in the mountpoint(8) utility. + * Fix checkroot devfs behaviour. + * Hmm, /usr/bin/test -w works to check if a filesystem is readonly, + but bash's built-in doesn't. Work-around with touch -a. + * /lib/init/readlink was completely broken, argh. Fixed borkenness. + Also changed behaviour so that readlink -ff is equivalent to realpath, + and -f doesn't insist on the path being a symlink. (closes: #238611) + * Removed one more init_setenv debug message from init.c + * Move mountpoint and readlink to initscripts, so that initscripts + doesn't have to depend on a specific version of sysvinit anymore + (closes: #239059) + * Make initscripts non-essential (needed for Hurd) (closes: #219969). + * Remove period from short description (closes: #239098) + * Improved handling of /etc/nologin symlink (closes: #184402) + * Make sure 'skeleton restart' restart the service even if it is not + running in accordance to policy 3.5.9.0 (closes: #184342) + * Change -name x into -path ./x in bootclean.sh (closes: #193627) + * Remove /usr/local from bootlogd path, move /sbin:/bin to the + front of the PATH. /usr/bin:/usr/sbin is kept around because the + stop action needs it for savelog. (closes: #230763) + * Remove x bit from bootclean.sh (closes: #230762) + * Consolidate variables in skeleton (closes: #122486) + * Move set -e up in skeleton (closes: #148847) + * Include spanish manpage for update-rc.d (closes: #209199) + * In /etc/init.d/README change http: URL to file: URL (closes: #151761) + + -- Miquel van Smoorenburg Sun, 21 Mar 2004 13:10:09 +0100 + +sysvinit (2.85-11) unstable; urgency=high + + * Move runlevel back to /sbin (closes: #238261) + * Move killall5 back to /sbin (closes: #238416) + * More finetuning of the included readlink program. It now has a much + more correct version of realpath() than glibc (famous last words). + + -- Miquel van Smoorenburg Wed, 17 Mar 2004 00:29:53 +0100 + +sysvinit (2.85-10) unstable; urgency=low + + * Provide mountvirtfs. It mounts /proc,/sys, etc at early boot. + Libc6 does this too with a script called mountkernfs which is called + later, but that shouldn't matter. Libc6 must remove it later on. + Perhaps we should remove the symlink - I'm not sure. + * Add /etc/default/{devpts,tmpfs} to initscripts. Add Replaces: libc6, + libc6.1 to control for initscripts. + * Add /lib/init/readlink which we can use until the standard + readlink has the features we need. + * Fix maxproclen issue (closes: #236138) + * Remove INIT_HALT debug message (closes: #230743) + * When cleaning /tmp, don't look at directory atime for aging info + (closes: #236709,#205486,#221622) + * bootclean.sh: only run if find and xargs are available (closes: #232635) + * Depend on mount (>= 2.11l-1) for the -l option (closes: #217702) + * Mount non-/ proc filesystems in mountall.sh. This will not work + if you want to mount /foo/bar/proc if /foo/bar is an NFS filesystem, + but this will do for now (closes: #234152) + * Add coda to list of networked filesystems in mountall.sh/mountnfs.sh + + -- Miquel van Smoorenburg Tue, 16 Mar 2004 01:04:06 +0100 + +sysvinit (2.85-9) unstable; urgency=low + + * Fix typo in /etc/init.d/halt (closes: #224626) + * Fix /etc/mtab-is-a-symlink corner cases (closes: #204619) + * Fix /etc/init.d/mountall.sh to only mount local fses (closes: #224720) + * Replace reference to dpkg programmer's manual in update-rc.d.8 + with reference to Debian Policy (closes: #223658) + + -- Miquel van Smoorenburg Tue, 23 Dec 2003 12:16:14 +0100 + +sysvinit (2.85-8) unstable; urgency=low + + * Clean /tmp, /var/run and /var/lock directly after mounting all + local filesystems and once more after mounting network filesystems, + but not more than once per directory (closes: #208226,#223495) + * Do not run bootlogd by default - it's a bit to experimental for + the "stable" release. Can be turned on manually (closes: #217582) + * Fix /etc/init.d/bootlogd (closes: #208578) + * Rework umountnfs.sh/umountfs (closes: #204425, #206111, #20863, #203050) + * Depend on mount >= 2.11l (closes: #217702) + * Don't use umount -l on 2.4 kernels < 2.4.11 (closes: #217701) + * /var/log/boot mode 640, group adm (closes: #204400) + * Deal correctly with /etc/mtab being a symlink (closes: #204619) + * Set TMPTIME to "infinite" to not clean /tmp (closes: #205894) + * Mount all proc filesystems (closes: #206979) + * Fix typo in invoke-rc.d manpage (closes: #196135) + * Set correct permissions on /etc/{rcS.d,init.d}/README (closes: #201467) + * Update /etc/init.d/README (refer to correct paragraph) (closes: #206411) + * bootlogd: handle comma's in console= (closes: #213749) + * Remove trailing space from 'echo -n "something ... "' (closes: #219202) + * Include documentation on invoke-rc.d and policy-rc.d (closes: #219245) + * Remove empty /usr/include from sysv-rc (closes: #222538) + * Let sysvinit Pre-Depend on file-rc | sysv-rc (closes: #221808) + + -- Miquel van Smoorenburg Thu, 18 Dec 2003 23:11:20 +0100 + +sysvinit (2.85-7) unstable; urgency=low + + * Fix devfs mtab fixup in checkroot.sh (closes: #202421) + * pidof symlink should be in /bin (closes: #202611) + + -- Miquel van Smoorenburg Wed, 23 Jul 2003 19:11:59 +0200 + +sysvinit (2.85-6) unstable; urgency=high + + * When bootlogd gets an error writing to the real console, try + to re-open. If that fails, roll over and die (closes: #202382) + + -- Miquel van Smoorenburg Tue, 22 Jul 2003 12:43:07 +0200 + +sysvinit (2.85-5) unstable; urgency=low + + * Allow "init u" to fail in postinst without bailing out with an error + (closes: #197991, #198216, #198309, #198937) + * Revert changes to bootmisc wrt /etc/nologin, leave out the + /etc/nologin.boot stuff (which never worked anyway), /etc/nologin + is now always cleaned out on boot. + (closes: #198444, #184402, #199943, #199401) + * Block signals in syslog(), since syslog() is not re-entrant + (James Olin Oden , redhat bug #97534) + * Remove rc.boot manpage completely instead of installing it first + and then removing it in sysv-rc's postinst + * When unmounting all filesystems, do not unmount /proc, /dev and /sys + (closes: #198970, #184594, #173878, #200147, #198793) + * Umount network filesystems lazily (-l) (closes: #164503) + * Clarify initscript manpage (closes: #174058) + * Use /proc as reference to see if files in /var/lock and /var/run + are stale (closes: #198792). I should look at #120545 to + actually fix this right, I guess. + * Include bootlogd (closes: #151880, #15447, #132662) + * Move update-rc.d for initscripts to the initscrips packages' postinst + instead of doing it in the postinst of sysv-rc + + -- Miquel van Smoorenburg Mon, 21 Jul 2003 12:48:11 +0200 + +sysvinit (2.85-4) unstable; urgency=medium + + * Move default.rcS to /usr/share/initscripts, fix postinst (closes: #190921) + * Only clean /tmp if it is mode 777 (really in -3) (closes: #139870) + * Move initscripts and sysv-rc to binary-indep target (closes: #190801) + * Save fsck exit code in variable (closes: #189917,#194827,#197483) + * If /etc/motd is a symlink, follow it when + editting /etc/motd (closes: #150355) + * If /etc/nologin is a symlink, remove the destination file after + bootup instead of the link itself (closes: 191041) + * Don't remove /etc/mtab~ if /etc/mtab is a symbolic link + * Only start 'update' when running kernels < 2.4 + * Mount /proc before mounting other filesystems, umount all proc + filesystems at shutdown except /proc (closes: #140591,#197317) + * Add 'set -e' to postinst (closes: #148465) + * Don't umount devfs at shutdown time (closes: #156490) + * When cleaning /tmp, first remove old files then remove old + empty directories (closes: #193623) + * Don't remove /tmp/...security* (closes: #195760) + + -- Miquel van Smoorenburg Wed, 18 Jun 2003 16:08:09 +0200 + +sysvinit (2.85-3) unstable; urgency=high + + * Move sample inittab files to /usr/share/sysvinit (closes: #189761) + * Make sysv-rc point update-rc.d and invoke-rc.d to the dummy + /usr/share/sysvinit/update-rc.d script in the postrm script, so + that dpkg remains happy when installing file-rc or another package + to replace sysv-rc. + * Minor adjustements so that sysvinit compiles on the Hurd (closes: #43575) + * For now set Architecture: all on sysv-rc and initscripts + (closes: #190179, #190182) + * Add upstream source to copyright file (closes: #15183) + * Remove /etc/rc.boot from sysv-rc (closes: #113821) + + -- Miquel van Smoorenburg Wed, 23 Apr 2003 15:26:21 +0200 + +sysvinit (2.85-2) unstable; urgency=high + + * sysv-rc must not Depend: on sysvinit, otherwise sysvinit/sysv-rc + is not installable. + + -- Miquel van Smoorenburg Tue, 22 Apr 2003 12:40:54 +0200 + +sysvinit (2.85-1) unstable; urgency=low + + * Support for IPv6 in 'last'. + * Fix -i/-d options in last (closes: #171134) + * /dev/.devfsd: check only for existance, not for type (closes: #170852) + * Don't remove pump.sock from /var/run/utmp (closes: 167572) + * Get rid of /etc/ioctl.save, it's a legacy thing from Unices with + a serial console and no way to set reset the linespeed at boot. + With Linux we have console=tty0,speed as bootparameter anyway. + * Remove support for file-based runlevel signalling. All systems + use /dev/initctl by now (I hope, but we'll see). + * When cleaning /tmp, check atime and mtime as well (closes: #179006) + and do not remove aquota.user and aquota.group (closes: #175874) + * Only clean up /tmp at boot if it is world-writable. + * If fsck of the rootfs returns 2 or 3, reboot (closes: #170442,#167300) + * Sulogin: even if the root password is empty, ask for a password- + otherwise there is no way to set a timeout (closes: #180246) + * Split up sysvinit into sysvinit, sysv-rc and initscripts. + + -- Miquel van Smoorenburg Fri, 18 Apr 2003 21:26:53 +0200 + +sysvinit (2.84-3) unstable; urgency=low + + * Upload into unstable of 2.84-3 so 2.84-2woody1 can go into + woody-proposed-updates tomorrow or so. + + -- Miquel van Smoorenburg Tue, 28 May 2002 11:44:26 +0200 + +sysvinit (2.84-2woody1) woody-proposed-updates; urgency=high + + * On some systems, /proc didn't get mounted because there is junk + under the /proc mountpoint, makeing the system unuseable. Fixed + by an extra check. Also warns the user. (closes: #134316) + * Fix typos in README.runlevels (closes: #94745) + * Update /etc/init.d/skeleton to comply with policy (closes: #96711,#121947) + * On some systems "init" might show up as "ini" in "ps" output + due to a off-by-one error in maxproclen calculation (closes: #132870) + * Fix typo (SBM - SMB) in /etc/init.d/mountnfs.sh (closes: #139251) + * Fix typo in debian/rules that installed prerm as preinst, and + preinst not at all (closes: #148174) + * Up severity to "high" since any program with write access to + /var/run/utmp (group utmp) could trick the "shutdown" command into + corrupting random files (note that currently there are no known + exploits for setgroup-id-utmp programs). + + -- Miquel van Smoorenburg Mon, 27 May 2002 22:37:23 +0200 + +sysvinit (2.84-2) unstable; urgency=low + + * modernized inittab manpage. + * Don't shut down IDE drives on halt if RAID is active (closes: #127635) + * Add /etc/init.d/umountnfs.sh to conffiles (closes: #122190) + * Only mount /proc in checkroot.sh if it's not mounted yet. This + gives earlier scripts the possibility to mount /proc and just + leave it mounted. + * Set maxproclen correctly on re-exec. Make sure setproctitle() leaves + at least two zeroes at the end of the argv array. + * Don't put IDE drives into standby mode at halt time if RAID is still + active, since the RAID halt/reboot/poweroff codepath in the kernel + still needs to flush the RAID metadata to disk. (closes: #127635) + * Use 'dmesg -s 65536' when writing /var/log/dmesg (closes: #128568) + * Mount /proc only if not mounted yet, don't unmount (closes: #118977) + * Commented out kb line in sample inittab (closes: #130126) + * Update /etc/rcS.d/README (closes: #130225) + * Don't duplicate options when remounting rootfs (closes: #119381) + + -- Miquel van Smoorenburg Fri, 25 Jan 2002 14:02:17 +0100 + +sysvinit (2.84-1) unstable; urgency=high + + * Don't use /etc/initlvl interface for telinit; only use /dev/initctl, + and give a clear error when that fails (closes: #116829) + * Add -i/--init command line flag to init - this tells init + 'behave as system init even if you're not PID#1'. Useful for + testing in chroot/jail type environments. + * Use --print-installation-architecture in postinst instead of + --print-architecture. + + -- Miquel van Smoorenburg Tue, 27 Nov 2001 13:08:45 +0100 + +sysvinit (2.83-3) unstable; urgency=low + + * Don't disable write caching on IDE disks before unmounting file + systems, since that flag is kept over reboot. Instead the + halt program now has an extra -h switch that makes it send all + IDE drives a "standby" command that as a side effect flushes + the write-cache. That flag is used in /etc/init.d/halt + + -- Miquel van Smoorenburg Wed, 7 Nov 2001 16:11:28 +0100 + +sysvinit (2.83-2) unstable; urgency=high + + * Only disable write caching on disks, not on all IDE devices + such as CDROMs (closes: #115354,#115822,#117390) + * Mount verbose, except for proc (closes: #115362,#111481) + * Add comments about not using tty7 to default inittab (closes: #117618) + * Install inittab.$(arch) as default inittab in the installation + process, if it exists. Add inittab.s390 (closes: #113495) + * Appears that the 'shutdown to fast' bug is closed by + turning off the IDE write cache at shutdown (closes: #110804). + Only thing is that this should probably get in the kernel + somehow, as it's really a kernel bug. + + -- Miquel van Smoorenburg Thu, 1 Nov 2001 13:21:58 +0100 + +sysvinit (2.83-1) unstable; urgency=high + + * Upstream fix: race condiction in wait() [Andrea Arcangeli] + * shutdown.allow processing broke due to typo (closes: #111199) + * Call closelog() after openlog()/syslog() since recent libc's + keep the logging fd open and that is fd#0 aka stdin (closes: #111901) + * Typo in shutdown manpage fixed (closes: #112815) + * Don't remove .journal file during tmp cleanup (closes: #113564) + * Don't use '-v' flag to mount in mountall.sh (closes: 111481) + * Fix policy reference in README (closes: #97925) + * Treat 'ncpfs' as remote filesystem (closes: #94510) + * Don't do fsck -C if $TERM is unset or set to dumb|network|unknown. + Also don't do fsck -C if `uname -m` = s390 + * Turn off write-caching on all IDE disks prior to unmounting + filesystems. On some systems that poweroff on halt the system + powers off before the IDE disk write cache is flushed. You do + need to have hdparm installed to get this to work. + + -- Miquel van Smoorenburg Fri, 5 Oct 2001 14:37:42 +0200 + +sysvinit (2.82-1) unstable; urgency=low + + * New upstream version. + * Now prints out correct version at startup (closes: #109558,#108377) + * Versioned replaces (dpkg << 1.9.17) (closes: #109557) + * Mount all proc filesystems in fstab (closes: #108109) + * Fix spelling of initttab in init(8) (closes: #100659) + * Clarify "usage" message of update-rc.d (closes: #108391) + + -- Miquel van Smoorenburg Thu, 23 Aug 2001 17:50:03 +0200 + +sysvinit (2.81-1) unstable; urgency=low + + * New upstream version. + * 'pidof' now finds processes that do weird stuff with their + name in 'ps' listings (i.e. use setproctitle()) (closes: #67021) + + -- Miquel van Smoorenburg Tue, 31 Jul 2001 18:25:11 +0200 + +sysvinit (2.80-3) unstable; urgency=high + + * The diff that dpkg-source builds doesn't include empty directories + so we now create them in the debian/rules file. + * Make /etc/init.d/* executable (closes: #107018) + + -- Miquel van Smoorenburg Mon, 30 Jul 2001 16:15:29 +0200 + +sysvinit (2.80-2) unstable; urgency=high + + * Use install -m 755 instead of copy for the pre/post install/remove + scripts (closes: #106730) + + -- Miquel van Smoorenburg Thu, 26 Jul 2001 22:46:52 +0200 + +sysvinit (2.80-1) unstable; urgency=medium + + * New upstream version + * Don't prevent raid-rebuild from activating swap on 2.4 and up + (closes: #80446, #83118). + * Document IO redirection in wall manpage (closes: #79491) + * Use -x in skeleton file (closes: #67143) + * Update README (closes: #85650) + * Unmount tmpfs before turining off swap (closes: #84782) + * Fix check for passno in checkroot.sh (closes: #84035) + * Make sure scripts exit with code 0 if succesful (closes: #83410) + * Don't try to set hostname if /etc/hostname is not present (closes: #81711) + * Mount /proc early and keep it mounted (closes: #75936, #71433, #88352) + * Fix init.8 manpage (closes: #75268) + * Small fix to rc script (closes: #72859) + * Optimize /tmp cleaning (closes: #71176) + * Check for update before executing it in "single" script + (closes: #68983, #103144) + * Build package with SHELL=/bin/bash (closes: #68623) + * Fix typo in halt(8) manpage (closes: #67875) + * Check time argument of shutdown(8) for correctness (closes: #67825) + * Don't chown ptys on devfs system (closes: #88300) + * Check for stale sessions in last(1) (Chris Wolf ) + * Include invoke-rc.d (closes: #94140). Conflicts: file-rc (<= 0.5.7) + * Move random-seed to /var/lib/urandom (closes: #102216) + * Moved update-rc.d from dpkg to sysvinit + * Didn't include the UPS changes yet, that will come in a later + 2.80-xyz version -- needed to get 2.80 out of the door first. + + -- Miquel van Smoorenburg Thu, 26 Jul 2001 14:07:03 +0200 + +sysvinit (2.78-4) frozen unstable; urgency=high + + * In /etc/init.d/checkroot.sh, change 10>&0 into 9>&0, since + ash doesn't handle file descriptors > 9 + + -- Miquel van Smoorenburg Sun, 25 Jun 2000 14:03:04 +0200 + +sysvinit (2.78-3) frozen unstable; urgency=medium + + * Fix critical bug #61227: Kernel panic/filesystem corruption if + swapping started while software RAID resyncing. As this doesn't + matter on 99% of the installs out there it's up to the release + manager to decide whether to put this in potato or not (closes: #61227). + * Fix up /etc/init.d/README paths (closes: #58935,#58595) + * Don't check root filesystem if "pass" in /etc/fstab is 0 (closes: #65125) + * Unmount remote filesystems before network is shut down + (closes: #60898,#61907). This also was a release-critical bug. + * Changed "file systems" to "filesystems". + + -- Miquel van Smoorenburg Tue, 6 Jun 2000 11:08:24 +0200 + +sysvinit (2.78-2) frozen unstable; urgency=high + + * Change "booting" to "reloading" message at reload + * Don't create /etc/init.d/network if missing (closes: #56373) + * Treat SMB filesystems like NFS ones in mountall.sh and + mountnfs.sh (fixes: #55414) + * bootmisc.sh: do not remove files in /var/run that are newer + than /etc/mtab. This should preserve pid files created before + this script ran (closes: #49816) + * Add "-z xxx" dummy command line argument (closes: #54717) + + -- Miquel van Smoorenburg Fri, 11 Feb 2000 12:17:54 +0100 + +sysvinit (2.78-1) unstable; urgency=low + + * 2.78 will be the new upstream version, I'm skipping 2.77 + * Update /etc/init.d/rc (closes: #48764) + * Add -C argument to fck (closes: #47914, #53335) + * don't remove files in /var/run and /var/lock that are newer + than /etc/mtab (may fix the dhcpcd problems) + * Save kernel messages in /var/log/dmesg like RedHat does (closes: #47574) + * Shutdown now calls sync before switching the runlevel to 0 or 6, + or before unmounting filesystems if -n was used (closes: #46461) + * Call umount with -f option to force NFS umounts (closes: #45715) + * Fix TMPTIME documentation in rcS(5) (closes: #42570, #53224) + * Some cosmetic changes to init.c (closes: #32079) + * Move to /usr/share to comply with latest policy + + -- Miquel van Smoorenburg Thu, 30 Dec 1999 20:40:23 +0100 + +sysvinit (2.77-3) unstable; urgency=low + + * Remove hwclock.sh initialization and script itself (closes: #45164) + + -- Miquel van Smoorenburg Tue, 5 Oct 1999 21:52:02 +0200 + +sysvinit (2.77-2) unstable; urgency=low + + * Recompile against glibc 2.1 instead of 2.0 + * Fix compilation problems with glibc 2.1 + * Fix last -i option + + -- Miquel van Smoorenburg Tue, 5 Oct 1999 21:51:50 +0200 + +sysvinit (2.77-1) unstable; urgency=low + + * Write reboot record into utmp file as well to make rms happy + * Change GMT to UTC in /etc/default/rcS + * Change /var/run/utmp to mode 664 group utmp if utmp group exists + * Fork and dump core in / if SIGSEGV is received for debugging purposes + * Patch by Craig Sanders for "last" -i option + * Fixes: + #35429: sysvinit: bad comments in /etc/defaults/rcS + #37807: mountnfs.sh should start rpc.statd if available + #38384: sysvinit: Slight gramitical error in /etc/init.d/README + #41660: [Patch] bootmisc.sh: Change /var/run/utmp ownership to [...] + #41458: mountnfs.sh: should ignore noauto + #40923: sysvinit: /etc/ioctl.save a state file? + #42183: util-linux: hwclock.sh depends on UTC which is not defined + + -- Miquel van Smoorenburg Wed, 4 Aug 1999 11:16:23 +0200 + +sysvinit (2.76-4) unstable; urgency=low + + * Change dowall.c to handle Unix98 ptys correctly + * Add comment in rcS about usage of setup.sh and unconfigured.sh + * Shutdown now removes nologin file just before calling telinit + * SEGV handler now tries to continue after sleep of 30 seconds. + On a 386-class processor it also prints out the value of EIP. + * Fix for racecondition in check_init_fifo() by Richard Gooch + * Fixes: + #32698: sysvinit: checkroot.sh: should add devfs entry to mtab + #35689: wall/shutdown cannot handle Unix98 PTYs + #30392: sysvinit scripts are not executable + #32699: bootmisc.sh: should check for existence of /dev/tty[p-za-e][0-9a-f] + #34062: mountnfs.sh: ignore comments in fstab [patch] + #34780: sysvinit: ignores most options for rootfs + #35017: sysvinit: nologin after sungle user mode [sic] + #36209: init: segmentation violation (possibly kernel) + #36294: sysvinit: sulogin does not appear to recognize shadow passwords + #36705: README in init.d has section number off by 0.1 + #36849: sysvinit: shutdown doesn't send shutdown message to unix98 ptys + #36856: sysvinit: /etc/init.d/rc calls bash for no reason + #37265: sysvinit: devpts incompatibility? + #32698: sysvinit: checkroot.sh: should add devfs entry to mtab + #33954: sysvinit: [wishlist] bootmisc.sh: touch /var/run/utmpx + + -- Miquel van Smoorenburg Sat, 8 May 1999 17:22:57 +0200 + +sysvinit (2.76-3) frozen unstable; urgency=high + + * Small bugfix to last.c courtesy of Danek Duvall + * Recompile with latest libs, so dependency on libc6 (>= 2.0.7u) is gone. + * Fixes bugs: + #31601: sysvinit: Doesn't wipe new files from /tmp + #28132: checkroot.sh parsing of /etc/fstab is incorrect. + #29729: sysvinit: references wrong policy homepage + #27949: last: should use down instead of crash + + -- Miquel van Smoorenburg Tue, 12 Jan 1999 12:12:44 +0100 + +sysvinit (2.76-2) frozen unstable; urgency=high + + * Minor fix in debian/rules for dependency problem on the Alpha. + + -- Miquel van Smoorenburg Thu, 5 Nov 1998 10:54:28 +0100 + +sysvinit (2.76-1) frozen unstable; urgency=high + + * Fix bug in check_pipe() which crashes init on the Alpha. + * Re-upload since this should go into frozen too, ofcourse. + * Changed the version number to 2.76, even though it's a minor + upgrade. I want to release this version outside Debian too. + + -- Miquel van Smoorenburg Tue, 3 Nov 1998 11:09:13 +0100 + +sysvinit (2.75-4) unstable; urgency=low + + * Change sulogin password buffer to 128 characters. + * Don't print control characters in dowall.c + * Try to open getenv ("CONSOLE"), /dev/console and /dev/tty0 in order. + For backwards compatibility when you try to boot a 2.0.x kernel + with a linux > 2.1.70 /dev/console device. + * Change src/Makefile for non-debian systems (mainly, RedHat) + * Try to create /dev/initctl if not present; check every time to see + if the dev/ino of /dev/initctl has changed and re-open it. This should + help devfs a bit. + * Send SIGUSR1 to init at bootup to let it re-open /dev/initctl; + again in support of devfs. + * Rewrite of mountnfs.sh by Chris Ulrich + * Moved pidof to /bin (it's only a link to killall5 anyway) + * Fixes bugs: + #11895: pidof exists, is unreliable, and is not deprecated + #23943: `"$FSCKFIX" = yes' needed in "checkroot.sh", too + #24190: sysvinit: postinst and telinit u + #25531: sysvinit: README refers to the fatman website + #26115: sysvinit: There is no support for a read only root + #26179: sysvinit: pidof in /sbin ? why ? + #26281: sysvinit: Obsolete location for Policy Manual in /etc/init.d/README + #15739: libc6: strange interferention between sleep() and fork() + + -- Miquel van Smoorenburg Mon, 5 Oct 1998 14:03:14 +0200 + +sysvinit (2.75-3) frozen unstable; urgency=high + + * Source /etc/default/rcS in all scripts, otherwise file-rc is broken. + * Do not call update-rc.d for isapnp + * Fixes: + #23556: sysvinit tries to install isapnp + #23270: sysvinit: /etc/default/rcS: comment should indicate time units + #23191: /etc/default/rcS + #23651: sysvinit: sysvinit fails to clean stale X locks in /tmp + + -- Miquel van Smoorenburg Mon, 22 Jun 1998 14:48:53 +0200 + +sysvinit (2.75-2) frozen unstable; urgency=medium + + * Fix last.c again. + * Add check to see if /dev/initctl is really a FIFO + * In ifdown.c first down all shaper devices then the real devices + * Fixes bugs: + #22840: sysvinit (2.75-1): patch request for sparc + #22965: rcS is not sh independent + #22945: Problems with last ( bug in sysvinit package)? + #23005: sysvinit: [patch] install initreq.h for `genpowerd' patch. + + -- Miquel van Smoorenburg Tue, 2 Jun 1998 22:43:01 +0200 + +sysvinit (2.75-1) frozen unstable; urgency=low + + * Rewrote last.c to be much more memory friendly and correct, + thanks to Nick Andrew and + David Parrish + * Fixes bugs: + #21616: sysvinit: sulogin thinks md5 root password is bad + #21765: sysvinit: Typo in `killall5.c' + #21775: sysvinit: sysvinit does not support MD5 hashed passwords + #21990: /usr/bin/last: unnecessary memset and off-by-one bug + #22023: sysvinit: nfs isn't mounted + #22084: sysvinit 2.74-4: SIGPWR missing on sparc + #21900: init, powerfail events, and shutdown.allow + #21702: init 0 does not work as expected... + #21728: sysvinit: Typo in `init.c' + #22363: sysvinit: discrepance btw. manpage and /sbin/init + #22579: power-off on halt + + -- Miquel van Smoorenburg Tue, 19 May 1998 11:02:29 +0200 + +sysvinit (2.74-4) frozen unstable; urgency=medium + + * Add -o option to last to process libc5 utmp files. + * Buffer overflow fixed in init.c (not very serious; only exploitable + by root). Thanks to Chris Evans + * Fixes: + #20147: filesystems not unmounted on reboot + #20702: sysvinit: example inittab is broken + #20957: errors mounting remote filesystems + #20063: fsck is _always_ called with -y option + + -- Miquel van Smoorenburg Wed, 15 Apr 1998 17:04:33 +0200 + +sysvinit (2.74-3) frozen unstable; urgency=high + + * Install hwclock.sh (was missing!) + + -- Miquel van Smoorenburg Thu, 19 Mar 1998 20:15:06 +0100 + +sysvinit (2.74-2) frozen unstable; urgency=high + + * Fix problem with removing kbd startup file + * Fixes bugs; + #19711: sysvinit: postinst uses /tmp/*.$$ + #14785: sysvinit: non executable scripts from examples + #17004: suggestion for raidtools + + -- Miquel van Smoorenburg Mon, 16 Mar 1998 12:56:10 +0100 + +sysvinit (2.74-1) unstable; urgency=low + + * Should compile with glibc 1.99 :) + * Now confirms to policy manual 2.4.0.0 + * Change behaviour of reboot(1) and halt(1) so that the default when + the runlevel can't be determined is to call shutdown. + * Updated README and skeleton + * Depends on new dpkg for the new update-rc.d + * Added re-exec patch from Al Viro (21 Feb 1998): + 'U' flag added to telinit. It forces init to re-exec itself + (passing its state through exec, certainly). + May be useful for smoother (heh) upgrades. + 24 Feb 1998, AV: + did_boot made global and added to state - thanks, Miquel. + Yet another file descriptors leak - close state pipe if + re_exec fails. + * Now no longer contains mdutils.sh and conflicts with older mdutils + * /etc/rc.S/*.sh scripts that use set -e or exit no longer stop + the whole boot process. + * Fixes: + #16082: sysvinit: filesystems do not get unmounted properly on shutdown + #16977: sysvinit: libc6 twice into Pre-Depends + #17012: sysvinit: minor typo in install + #17084: /etc/rcS does not use a start arg + #17276: sysvinit: SIGUSR1 causes init to eat CPU + #18541: sysvinit: ^C aborts entire rcS script + + -- Miquel van Smoorenburg Thu, 12 Mar 1998 17:42:46 +0100 + +sysvinit (2.73-2) unstable; urgency=low + + * Change _NSIG to NSIG for 2.1.x kernel includes. + * Hopefully fixes bug 16082, but we'll see.. + * Fixes bugs: + #16622 sysvinit: should not depend on kbd + #16807: /etc/init.d/mdutils.sh is started at bootup _and_ halt/reboot. + + -- Miquel van Smoorenburg Thu, 8 Jan 1998 16:01:02 +0100 + +sysvinit (2.73-1) unstable; urgency=low + + * Use siginterrupt, now that system calls are restarted by default. + Main symptom was that the sulogin timeout didn't work but there + might have been more hidden problems. + * Kill process immidiately if turned off in inittab + * Fixed sulogin check on tty arg. + * Use strerror() instead of sys_errlist + * Chop up the reboot and halt scripts into seperate scripts. I had to + take some liberties so they are called with the argument "stop" even + though the scripts are Sxx scripts .. (start scripts in runlevel 0&6 + seem non-intuitive anyway) + * wall now supports a '-n' option to suppress [most of] the banner. + Debian doesn't use sysvinit's wall, but apparently Redhat does. + * Add '-F' (forcefsck) option to shutdown + * Depends on kbd_0.95-2 (or higher) package for /etc/rcS.d stuff. + * Close and reopen /dev/initctl on SIGUSR1 (mainly for a /dev in ram) + * Add FSCKFIX option to /etc/default/rcS + * Wrote rcS.5 manpage describing /etc/default/rcS + * Fixes bugs: + #13435: Could shutdown provide a way to force fsck? + #14108: sysvinit: sulogin's timeout does not work anymore + #14179: sysvinit: /etc/init.d/(halt|reboot) need to call mdstop + #14357: sysvinit: typo errors into script shells + #15010: shutdown is too fast + #15405: sysvinit: changelog uncompressed + #15751: "sulogin -t " does not time out + #15758: Outdated reference in README + + -- Miquel van Smoorenburg Sat, 3 Jan 1998 16:32:39 +0100 + +sysvinit (2.72-3) unstable; urgency=low + + * Remove perl check from preinst + * Add extra fork() in dowall.c to avoid hanging in rare cases + * Conflict with file-rc (<= 0.4.1) + * The 2.72 series fix the following bugs: + #9819: sysvinit: Typo in `pidof` manual + #9820: sysvinit: Incorrect filenames in `shutdown` manual + #9821: sysvinit: `init` manual gives incorrect information + #9822: sysvinit: `inittab` manual + #10045: sysvinit: error message "no more processes..." + #10276: sysvinit has uncompressed manpages. + #11728: libc6 + #11879: sysvinit: file in /tmp security hole + #12172: Sysvinit: Contains powerd manpage but not powerd + #12465: Trivial typos in killall5 man page + #12631: sysvinit: unchecked prompting in postinst + #13290: clock is now hwclock + #13300: patch to init.d/boot for compressed keymaps + #13344: sysvinit: command 'clock' not found + #13789: sysvinit: /etc/init.d/boot calls "clock", should call "hwclock" + #13830: sysvinit: Upgrading to new sysvinit left system unusable + #13838: sysvinit: gratuitous use of perl + + -- Miquel van Smoorenburg Wed, 22 Oct 1997 14:44:00 +0200 + +sysvinit (2.72-2) unstable; urgency=high + + * Don't use perl in postinst. Use more flexible regexp to match the + sysinit line. + * Remove /etc/default/boot from package + * Fix settime.sh for hwclock + + -- Miquel van Smoorenburg Tue, 14 Oct 1997 12:40:23 +0200 + +sysvinit (2.72) unstable; urgency=low + + * Applied manual page patches by Bill Hawes . Thanks Bill! + * Applied patches to the sample Slackware scripts by + "Jonathan I. Kamens" + * Fix halt and reboot runlevels 0 & 6 check. + * Only say "no more processes left in runlevel x" once + * Fix race condition with SIGCHLD in spawn() + (thanks to Alon Ziv ) + * Compress all manpages (missed 2) + * Compiled for libc6 + * Split up /etc/init.d/boot into seperate files in /etc/rcS.d + * Remove powerd.8 from debian package + * Fix /etc/init.d/settime.sh to look for hwclock first + * Added poweroff patch by Roderich Schupp + + -- Miquel van Smoorenburg Sun, 12 Oct 1997 17:20:17 +0200 + +sysvinit (2.71-2) frozen unstable; urgency=low + + * Print 2.71 instead of 2.70 on startup :) + * Fix /etc/init.d/skeleton for new console messages standard. + + -- Miquel van Smoorenburg Mon, 5 May 1997 12:45:25 +0200 + +sysvinit (2.71-1) frozen unstable; urgency=high + + * Added code for updwtmp() in utmp.c for glibc (2.0.3) + * Fixed all programs to use functions from utmp.c and getutent() + * Do not try to clean up utmp in init itself (Bug#9022) + * Removed sync() from main loop. + * Fix bug #8739 (/fastboot) + * Hopefully fixes bug #8657 (shutdown signal handling) + * Mount /proc before modules are loaded + * Check on both /etc/init.d/modules and modutils (Bug#9058, #8398) + * Fix PATH order (Bug#8087) + * Fix console messages (Bug#8899) + + -- Miquel van Smoorenburg Sat, 26 Apr 1997 19:57:27 +0200 + +sysvinit (2.70-1) unstable; urgency=low + + * small fix for postinst (Bug#5866) + * Respawn fix + * Removed StUdLy CaPs from source code + * Moved files in source archive around + * Moved mdadd in "boot" script to get called after module loading + * Fixes for glibc (utmp handling, signal handling). + * Fixed '-d' option to last (now also works without '-a'). + * Added extra checking in last.c to prevent showing dead entries + + -- Miquel van Smoorenburg Fri, 7 Feb 1997 15:31:30 +0100 + +sysvinit (2.69-1) frozen unstable; urgency=medium + + * Fixed bug that can throw X in a loop (or any other app that reads from + /dev/tty0) + * Moved inittab to /usr/doc/sysvinit/examples so that it is no longer + a config file. + + -- Miquel van Smoorenburg Sun, 1 Dec 1996 15:32:24 +0100 + +sysvinit (2.68-1) frozen unstable; urgency=high + + * Added dummy fsck.nfs [temporary] (Bug#5492) + * Changing /etc/motd optional (Bug#5493) + * Typo in /etc/init.d/urandom fixed (Bug#5556) + + -- Miquel van Smoorenburg Wed, 27 Nov 1996 17:30:36 +0100 + +sysvinit (2.67-1) frozen unstable; urgency=high + + * Fixes problem with /dev/console being controlling terminal of some + daemons + * Some fixes in debian bootup script "boot" + * Puts copyright file in the right place + * Move random-seed stuff to its own file + * Fix skeleton file (add set -e) + * Change preinst/postinst scripts to save all variables from "boot" file + * moved /etc/init.d/network to /usr/doc/examples/sysvinit + * Changed "rc" script slightly (potential recipy for disaster..) + * Various other fixes to close all outstanding bug reports. + + -- Miquel van Smoorenburg Fri, 15 Nov 1996 12:23:33 +0100 + +sysvinit (2.66-1) unstable; urgency=medium + + * Skipped 2.65. A development 2.65 got out by accident and is apparently + being used.. + * New source format + * Also compiles and runs with GNU libc (and on the Alpha) + * Fixed dowall.c not to exit when getpwuid() fails and uid == 0. + * Fixed init panic'ing on empty lines in /etc/inittab + * Changed default PATH to include /usr/local/sbin + * Set /dev/console as controlling terminal for sysinit,bootwait,wait,powerwait + This allows using ^C to interrupt some parts of eg the boot process. + * Remove old symlink in /var/log/initlvl; let init check both + /var/log and /etc itself. + + -- Miquel van Smoorenburg Tue, 29 Oct 1996 13:46:54 +0100 diff --git a/compat b/compat new file mode 100644 index 00000000..ec635144 --- /dev/null +++ b/compat @@ -0,0 +1 @@ +9 diff --git a/control b/control new file mode 100644 index 00000000..6c1023eb --- /dev/null +++ b/control @@ -0,0 +1,105 @@ +Source: sysvinit +Section: admin +Priority: optional +Maintainer: Debian sysvinit maintainers +Uploaders: Ian Jackson , + Benda Xu +Build-Depends: + debhelper (>= 9.20120410), + po-debconf, + quilt (>= 0.40), + libselinux1-dev (>= 1.14) [linux-any], + libsepol1-dev [linux-any] +Standards-Version: 3.9.5 +Homepage: http://savannah.nongnu.org/projects/sysvinit +Vcs-Git: https://anonscm.debian.org/git/collab-maint/sysvinit.git +Vcs-Browser: https://anonscm.debian.org/cgit/collab-maint/sysvinit.git + +Package: sysvinit-core +Priority: extra +Architecture: any +Depends: initscripts (>= 2.88dsf-13.3), + sysv-rc | file-rc | openrc, + sysvinit-utils (>= 2.86.ds1-66), + ${shlibs:Depends}, + ${misc:Depends}, +# For ischroot + debianutils (>= 4), +# Required for TERM=xterm switch (see #605777) + kbdcontrol (>= 8.2+ds2-6) [kfreebsd-any] +Conflicts: systemd-sysv, upstart +Replaces: sysvinit (<< 2.88dsf-44~), systemd-sysv, upstart +Suggests: bootlogd +Description: System-V-like init utilities + This package contains programs required for booting + a Debian system and doing basic process management. + . + The most important program in the package is /sbin/init. + It is the first process started on boot and continues + to run as process number 1 until the system halts. All + other processes are descended from it. + +Package: sysvinit-utils +Priority: required +Essential: yes +Architecture: any +Multi-Arch: foreign +Replaces: initscripts (<< 2.88dsf-59.5) +Depends: ${shlibs:Depends}, ${misc:Depends}, init-system-helpers (>= 1.25~) +# sulogin, last, lastb and mesg was moved to the util-linux package + , util-linux (>> 2.28-2~) +Breaks: systemd (<< 215) +Description: System-V-like utilities + This package contains the important System-V-like utilities. + . + Specifically, this package includes: + killall5, pidof + +Package: sysv-rc +Architecture: all +Multi-Arch: foreign +Recommends: lsb-base (>= 3.2-14) +Suggests: bum +Pre-Depends: init-system-helpers (>= 1.25~) +Depends: + ${misc:Depends}, + sysvinit-utils (>= 2.86.ds1-62), + insserv (>> 1.12.0-10) + , startpar +Breaks: systemd (<< 215) +Description: System-V-like runlevel change mechanism + This package provides support for the System-V like system + for booting, changing runlevels, and shutting down, + configured through symbolic links in /etc/rc?.d/. + +Package: initscripts +Architecture: any +Multi-Arch: foreign +Depends: + ${shlibs:Depends}, ${misc:Depends}, ${mount:Depends}, + debianutils (>= 4), + lsb-base (>= 3.2-14), + sysvinit-utils (>= 2.88dsf-59.5), sysv-rc | file-rc | openrc, + coreutils (>= 5.93), +Recommends: psmisc, e2fsprogs +Breaks: +# Needed for ifquery + ifupdown (<< 0.7.46), +# /bin/mountpoint was moved to util-linux + util-linux (<< 2.26.2-4~), +# Older versions of hurd do not implement the neccessary functionality + hurd (<< 0.5.git20131101~) +Description: scripts for initializing and shutting down the system + The scripts in this package initialize a standard Debian + system at boot time and shut it down at halt or reboot time. + +Package: bootlogd +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, lsb-base (>= 3.2-14) +Description: daemon to log boot messages + bootlogd logs all messages printed to the system console during system boot, + and records those messages to a logfile. + . + Note that not all init systems print messages to the system console, + so that the logfile may remain empty; this is the case with systemd + (the default init system). Try "journalctl -b" instead. diff --git a/copyright b/copyright new file mode 100644 index 00000000..fc180692 --- /dev/null +++ b/copyright @@ -0,0 +1,52 @@ +This is the Debian GNU/Linux prepackaged version of System V Init. + +Init was written by Miquel van Smoorenburg . + +This package was first put together by Bruce Perens +from pre-distribution sources. Ian Murdock +integrated it into the base system maintained it until the end of 1995. +Miquel van Smoorenburg implemented Debian support. +In version 2.85 the package was split into three (sysvinit, sysv-rc, +and initscripts) in order to make room for alternative rc mechanisms. + +The upstream source is available at: + +Primary-Site: ftp.cistron.nl /pub/people/miquels/software + 92K sysvinit-2.86.tar.gz +Alternate-Site: sunsite.unc.edu /pub/Linux/system/daemons/init + 92K sysvinit-2.86.tar.gz + +Send patches to sysvinit-devel@nongnu.org. + +The sysvinit package in Debian is maintained as an alioth project. +The project page is http://alioth.debian.org/projects/pkg-sysvinit/. + +Copyright 1997-2005 Miquel van Smoorenburg and +the members pkg-sysvinit project. + + 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 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-2'. + +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 , + * public domain. + diff --git a/deps-mount b/deps-mount new file mode 100755 index 00000000..7e96088a --- /dev/null +++ b/deps-mount @@ -0,0 +1,14 @@ +# +# deps-mount +# +# Figure out which package we need to depend on in order to have +# the right mount program +# + +DEB_BUILD_GNU_TYPE="$(dpkg-architecture -qDEB_BUILD_GNU_TYPE)" + +case "$DEB_BUILD_GNU_TYPE" in + *-linux|*-linux-gnu|*-linux-gnulp) + echo 'mount:Depends=mount (>= 2.11x-1)' + ;; +esac diff --git a/fscklog.sh b/fscklog.sh new file mode 100644 index 00000000..ebb931eb --- /dev/null +++ b/fscklog.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# fscklog.sh See if we need to rotate the fsck logs +# + +MAXSIZE=51200 +NUMFILES=5 +export BOOTLOGFILE=/var/log/fsck/boot.log +export ROOTLOGFILE=/var/log/fsck/root.log + +if [ -f "$BOOTLOGFILE" ] && [ "$(stat -c %s $BOOTLOGFILE)" -gt "$MAXSIZE" ] +then + savelog -g adm -m 640 -u root -c $NUMFILES $BOOTLOGFILE +fi + +if [ -f "$ROOTLOGFILE" ] && [ "$(stat -c %s $ROOTLOGFILE)" -gt "$MAXSIZE" ] +then + savelog -g adm -m 640 -u root -c $NUMFILES $ROOTLOGFILE +fi diff --git a/gbp.conf b/gbp.conf new file mode 100644 index 00000000..60ce09bc --- /dev/null +++ b/gbp.conf @@ -0,0 +1,3 @@ +[DEFAULT] +debian-branch = master +upstream-branch = upstream/2.88dsf diff --git a/git-tag b/git-tag new file mode 100755 index 00000000..366dc56b --- /dev/null +++ b/git-tag @@ -0,0 +1,17 @@ +#!/bin/sh + +DEBSOURCE="$(dpkg-parsechangelog | sed -ne '/^Source:/{s/Source:[[:space:]][[:space:]]*//p;q}')" +DEBVERSION="$(dpkg-parsechangelog | sed -ne '/^Version:/{s/Version:[[:space:]][[:space:]]*//p;q}')" +DEBDIST="$(dpkg-parsechangelog | sed -ne '/^Distribution:/{s/Distribution:[[:space:]][[:space:]]*//p;q}')" +DEBURGENCY="$(dpkg-parsechangelog | sed -ne '/^Urgency:/{s/Urgency:[[:space:]][[:space:]]*//p;q}')" + +if [ -z "$DEBSOURCE" ] || [ -z "$DEBVERSION" ] || \ + [ -z "$DEBDIST" ] || [ -z "$DEBURGENCY" ]; then + echo "Error parsing source, version, distribution and urgency from debian/changelog" + exit 1 +fi + +echo "Tagging ${DEBSOURCE}-${DEBVERSION} (dist=${DEBDIST}, urgency=${DEBURGENCY}) as 'debian/${DEBSOURCE}-${DEBVERSION}'" + +git tag -s "debian/${DEBSOURCE}-${DEBVERSION}" -m "${DEBSOURCE}-${DEBVERSION} (dist=${DEBDIST}, urgency=${DEBURGENCY})" + diff --git a/init-d-script b/init-d-script new file mode 100755 index 00000000..5d9a5a17 --- /dev/null +++ b/init-d-script @@ -0,0 +1,242 @@ +#!/bin/sh +# See init-d-script(5) for instructions on how to use this library. +#============================================================================= + +# Shift arguments early to fix #826214 +__init_d_script_name="$1" +shift + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.2-14) to ensure that this file is present +# and status_of_proc is working. +. /lib/lsb/init-functions + +# PATH should only include /usr/* if it runs after the mountnfs.sh +# script. Scripts running before mountnfs.sh should remove the /usr/* +# entries. +PATH=/sbin:/usr/sbin:/bin:/usr/bin +export PATH + +is_call_implemented() { + command -V $1 > /dev/null 2>&1 +} + +do_usage() { + if is_call_implemented do_reload ; then + echo "Usage: $SCRIPTNAME {start|stop|status|reload|restart|try-restart|force-reload}" >&2 + else + echo "Usage: $SCRIPTNAME {start|stop|status|restart|try-restart|force-reload}" >&2 + fi +} + +call() { + cmd="$1" + shift + if is_call_implemented ${cmd}_override ; then + ${cmd}_override "$@" + else + ${cmd} "$@" + fi +} + +# +# Function that starts the daemon/service +# + +# Return +# 0 if daemon has been started +# 1 if daemon was already running +# 2 if daemon could not be started +do_start_cmd() { + start-stop-daemon --start --quiet ${PIDFILE:+--pidfile ${PIDFILE}} \ + $START_ARGS \ + --startas $DAEMON --name $NAME --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet ${PIDFILE:+--pidfile ${PIDFILE}} \ + $START_ARGS \ + --startas $DAEMON --name $NAME --exec $DAEMON -- $DAEMON_ARGS \ + || return 2 + # Add code here, if necessary, that waits for the process to be ready + # to handle requests from services started subsequently which depend + # on this one. As a last resort, sleep for some time. +} + +do_start() +{ + if is_call_implemented do_start_prepare ; then + call do_start_prepare + fi + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + call do_start_cmd + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + if is_call_implemented do_start_cleanup ; then + call do_start_cleanup + fi +} + +# +# Function that stops the daemon/service +# + +# Return +# 0 if daemon has been stopped +# 1 if daemon was already stopped +# 2 if daemon could not be stopped +# other if a failure occurred +do_stop_cmd() { + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 \ + $STOP_ARGS \ + ${PIDFILE:+--pidfile ${PIDFILE}} --name $NAME --exec $DAEMON + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + # Wait for children to finish too if this is a daemon that forks + # and if the daemon is only ever run from this initscript. + # If the above conditions are not satisfied then add some other code + # that waits for the process to drop all resources that could be + # needed by services started subsequently. A last resort is to + # sleep for some time. + start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 \ + $STOP_ARGS \ + --exec $DAEMON + [ "$?" = 2 ] && return 2 + # Many daemons don't delete their pidfiles when they exit. + rm -f $PIDFILE + return $RETVAL +} + +do_stop() +{ + if is_call_implemented do_stop_prepare ; then + call do_stop_prepare + fi + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + call do_stop_cmd + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + if is_call_implemented do_stop_cleanup ; then + call do_stop_cleanup + fi +} + +do_restart() { + [ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME" + call do_stop_cmd + call do_start_cmd + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac +} + +do_force_reload() { + if is_call_implemented do_reload ; then + call do_reload + else + call do_restart + fi +} + +# Enable this using +# alias do_reload=do_reload_sigusr1 +do_reload_sigusr1() { + log_daemon_msg "Reloading $DESC configuration files" "$NAME" + start-stop-daemon --oknodo --stop --signal 1 --quiet \ + --pidfile "$PIDFILE" --exec "$DAEMON" + log_end_msg $? +} + +do_status() { + status_of_proc "$DAEMON" "$NAME" && return 0 || return $? +} + +if [ "$DEBUG" = "true" ] ; then + set -x +fi + +SCRIPTNAME="$__init_d_script_name" +scriptbasename="$(basename "$__init_d_script_name")" +if [ "$scriptbasename" != "init-d-script" ] ; then + . "$__init_d_script_name" +else + exit 0 +fi + +NAME=${NAME:=$(basename $DAEMON)} +DESC=${DESC:=$NAME} + +# Do not use pid file if $PIDFILE is 'none'. Otherwise, generate from +# $NAME or use the value provided by the init.d script. +if [ none = "$PIDFILE" ] ; then + PIDFILE= +elif [ -z "$PIDFILE" ] ; then + PIDFILE=/var/run/$NAME.pid +fi + +# Exit if the package is not installed +if [ none != "$DAEMON" ] && [ ! -x "$DAEMON" ] ; then + exit 0 +fi + +# Read configuration variable file if it is present +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh +if [ -t 0 ] ; then # Be verbose when called from a terminal + VERBOSE=yes +fi + +case "$1" in + start) + call do_start + ;; + stop) + call do_stop + ;; + status) + call do_status + ;; + reload) + if is_call_implemented do_reload ; then + do_reload + else + call do_usage + exit 3 + fi + ;; + force-reload) + call do_force_reload + ;; + restart) + call do_restart + ;; + try-restart) + log_daemon_msg "Trying to restart $DESC" "$NAME" + if call do_status > /dev/null 2>&1 ; then + call do_restart + log_end_msg $? + else + log_progress_msg "is not running." + log_end_msg 1 + fi + ;; + '') + call do_usage + exit 3 + ;; + *) + if is_call_implemented do_unknown ; then + call do_unknown "$1" + exit 3 + else + call do_usage + exit 3 + fi + ;; +esac +exit 0 diff --git a/init-d-script.5 b/init-d-script.5 new file mode 100644 index 00000000..812fba1d --- /dev/null +++ b/init-d-script.5 @@ -0,0 +1,85 @@ +.\" -*- nroff -*- +.\" macros +.de EX \" Begin Example +. IP +. ft CW +. nf +. ne \\$1 +.. +.de EE \" End Example +. ft P +. fi +. PP +.. +.de URL \" URL formatting +\\$2 \(la\\$1\(ra\\$3 +.. +.TH INIT-D-SCRIPT 5 "2014-02-09" "init-d-script" "File formats" +.SH NAME +init-d-script \- interpreter for short and simple init.d scripts. +.SH DESCRIPTION +Generic init.d script framework to reduce the redundant code in +/etc/init.d/. The goal is to create an init.d script that is Debian +and LSB compliant. When the Debian policy conflict with the LSB, the +Debian policy take preference. See +.URL http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html "The LSB specification" +for information about init.d scripts in the LSB. +.P +This is a simple example on how init-d-script can be used to start and +stop a daemon with PID file support: +.P +.EX +#!/lib/init/init-d-script +### BEGIN INIT INFO +# Provides: atd +# Required-Start: $syslog $time $remote_fs +# Required-Stop: $syslog $time $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: run at jobs +# Description: Debian init script to start the daemon +# running at jobs. +### END INIT INFO +DAEMON=/usr/sbin/atd +.EE +.P +In addition to the DAEMON setting, one can specify DESC, NAME, +PIDFILE (none means no PID file), or implement override functions +do_force_reload_override, do_reload_override, do_restart_override, +do_start_override, do_start_cmd_override, do_start_prepare, +do_start_cleanup do_status_override, do_stop_override, +do_stop_prepare, do_stop_cleanup and do_stop_cmd_override. +.P +If the daemon support reloading, implement the do_reload function to +make the init.d script recognize the reload operation as well as use +it for the force-reload operation. +.P +If DAEMON is 'none', the check to see if the daemon is installed is +disabled, and replacement functions do_start_cmd_override, +do_stop_cmd_override and do_status_override functions must be +implemented. +.P +Services supporting reload should define the do_reload function. If +the service handle reload using a SIGUSR1 signal, the following alias +can be used instead of implementing ones own do_reload function: +.P +.EX +alias do_reload=do_reload_sigusr1 +.EE +.RE +.SH FILES +.TP +.I /lib/init/init-d-script +Bourne shell interpreter with implementation of init.d actions +.TP +.I /etc/init.d/ +Location of init.d scripts. +.RE +.SH KNOWN BUGS/LIMITATIONS +Not yet documented +.SH AUTHOR +This manpage was written by Petter Reinholdtsen . +.SH "SEE ALSO" +.BR inittab (8), +.BR service (8), +.BR update-rc.d (8). diff --git a/initscripts.NEWS b/initscripts.NEWS new file mode 100644 index 00000000..77942046 --- /dev/null +++ b/initscripts.NEWS @@ -0,0 +1,48 @@ +sysvinit (2.88dsf-26) unstable; urgency=low + + Changes to the configuration and defaults of tmpfs filesystems: + + In version 2.88dsf-26 of the initscripts package, the RAMTMP + setting from /etc/default/tmpfs defaults to "no". This means that + a tmpfs will no longer be mounted on /tmp for upgrades or new + installs. Set RAMTMP to "yes" to continue to use a tmpfs on /tmp. + See tmpfs(5) for further details. + + -- Roger Leigh Wed, 06 Jun 2012 20:55:45 +0100 + +sysvinit (2.88dsf-23) unstable; urgency=low + + Changes to the configuration and defaults of tmpfs filesystems: + + In version 2.88dsf-23 of the initscripts package, the RAMLOCK, + RAMSHM and RAMTMP settings from the /etc/default/rcS file have been + moved to /etc/default/tmpfs. These settings can not be + automatically migrated. Please move these settings to + /etc/default/tmpfs if changed from the defaults. + + In order to improve the default size limits of tmpfs filesystems, + it is now possible to configure the size as a percentage of the + total virtual memory. The default for /tmp and /run/shm is now + 20%VM rather than 20% (RAM). A tmpfs will only be mounted on + /tmp on systems with more than 64MiB RAM. + + -- Roger Leigh Wed, 18 Apr 2012 23:30:37 +0100 + +sysvinit (2.88dsf-17) unstable; urgency=low + + In version 2.88dsf-17 of the initscripts package, the /etc/mtab + file used to record which filesystems are mounted has been replaced + with a symbolic link to /proc/mounts. + + The tmpfs filesystem mounted on /lib/init/rw has also been removed, + with all packages using /lib/init/rw having switched to using /run. + The migration process means that it will not be possible to + automatically remove the /lib/init/rw directory until after the + release of wheezy. However, it is safe to manually remove the + directory, which is no longer owned by the initscripts package. + Note that old init scripts in deleted (but not purged) packages may + continue to use /lib/init/rw; it is recommended that these packages + be fully purged. + + -- Roger Leigh Mon, 19 Dec 2011 12:24:04 +0000 + diff --git a/initscripts.conffiles b/initscripts.conffiles new file mode 100644 index 00000000..db7db271 --- /dev/null +++ b/initscripts.conffiles @@ -0,0 +1,29 @@ +/etc/init.d/bootlogs +/etc/init.d/bootmisc.sh +/etc/init.d/checkfs.sh +/etc/init.d/checkroot.sh +/etc/init.d/checkroot-bootclean.sh +/etc/init.d/halt +/etc/init.d/hostname.sh +/etc/init.d/killprocs +/etc/init.d/motd +/etc/init.d/mountall.sh +/etc/init.d/mountall-bootclean.sh +/etc/init.d/mountnfs.sh +/etc/init.d/mountnfs-bootclean.sh +/etc/init.d/mountdevsubfs.sh +/etc/init.d/mountkernfs.sh +/etc/init.d/rc.local +/etc/init.d/reboot +/etc/init.d/rmnologin +/etc/init.d/sendsigs +/etc/init.d/single +/etc/init.d/umountfs +/etc/init.d/umountnfs.sh +/etc/init.d/umountroot +/etc/init.d/urandom +/etc/default/devpts +/etc/default/halt +/etc/default/rcS +/etc/default/tmpfs +/etc/network/if-up.d/mountnfs diff --git a/initscripts.copyright b/initscripts.copyright new file mode 100644 index 00000000..a94ac07e --- /dev/null +++ b/initscripts.copyright @@ -0,0 +1,31 @@ +This package contains the scripts that are executed at start and +shutdown of Debian systems. + +This package is built from the `sysvinit' source package. Please +consult the copyright file of the sysvinit package for the location of +the upstream sources of the sysvinit package. Debian-specific files +for sysvinit, such as these initscripts, are maintained by the members +of the pkg-sysvinit project at alioth.debian.org. + + http://alioth.debian.org/projects/pkg-sysvinit + +Copyright 1997-2005 Miquel van Smoorenburg and +the members pkg-sysvinit project. + + 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 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-2'. diff --git a/initscripts.lintian-overrides b/initscripts.lintian-overrides new file mode 100644 index 00000000..6b27b21c --- /dev/null +++ b/initscripts.lintian-overrides @@ -0,0 +1,26 @@ +initscripts: file-in-etc-not-marked-as-conffile /etc/init.d/skeleton +initscripts: non-standard-toplevel-dir sys/ +initscripts: package-contains-empty-directory sys/ +initscripts: script-not-executable ./etc/init.d/skeleton +initscripts: maintainer-script-calls-init-script-directly postrm:14 +initscripts: script-calls-init-script-directly ./etc/network/if-up.d/mountnfs:102 +initscripts: depends-on-essential-package-without-using-version recommends: e2fsprogs +initscripts: no-upstream-changelog +initscripts: init.d-script-missing-dependency-on-remote_fs etc/init.d/bootlogs: required-start +initscripts: init.d-script-missing-dependency-on-remote_fs etc/init.d/killprocs: required-start +initscripts: init.d-script-possible-missing-stop etc/init.d/urandom 1 +initscripts: init.d-script-missing-dependency-on-remote_fs etc/init.d/checkfs.sh: required-start +initscripts: init.d-script-missing-dependency-on-remote_fs etc/init.d/motd: required-start +initscripts: init.d-script-possible-missing-stop etc/init.d/umountnfs.sh 1 +initscripts: init.d-script-missing-dependency-on-remote_fs etc/init.d/umountnfs.sh: required-stop +initscripts: init.d-script-missing-dependency-on-remote_fs etc/init.d/reboot: required-stop +initscripts: init.d-script-missing-dependency-on-remote_fs etc/init.d/mountall.sh: required-start +initscripts: init.d-script-should-depend-on-virtual-facility etc/init.d/mountnfs-bootclean.sh mountnfs -> $remote_fs +initscripts: init.d-script-missing-dependency-on-remote_fs etc/init.d/checkroot.sh: required-start +initscripts: init.d-script-possible-missing-stop etc/init.d/umountfs 1 +initscripts: init.d-script-missing-dependency-on-remote_fs etc/init.d/umountfs: required-stop +initscripts: init.d-script-should-depend-on-virtual-facility etc/init.d/mountall-bootclean.sh mountall -> $local_fs +initscripts: init.d-script-missing-dependency-on-remote_fs etc/init.d/mountnfs.sh: required-start +initscripts: init.d-script-missing-dependency-on-remote_fs etc/init.d/halt: required-stop +initscripts: init.d-script-possible-missing-stop etc/init.d/umountroot 1 +initscripts: unusual-interpreter etc/init.d/skeleton #!/lib/init/init-d-script diff --git a/initscripts.maintscript b/initscripts.maintscript new file mode 100644 index 00000000..54b8c359 --- /dev/null +++ b/initscripts.maintscript @@ -0,0 +1,3 @@ +rm_conffile /etc/init.d/bootlogd 2.88dsf-42 initscripts +rm_conffile /etc/init.d/stop-bootlogd-single 2.88dsf-42 initscripts +rm_conffile /etc/init.d/stop-bootlogd 2.88dsf-42 initscripts diff --git a/initscripts.postinst b/initscripts.postinst new file mode 100755 index 00000000..94c3dbc5 --- /dev/null +++ b/initscripts.postinst @@ -0,0 +1,234 @@ +#! /bin/sh +# +# initscripts postinst +# + +set -e + +. /lib/init/vars.sh +. /lib/init/tmpfs.sh +. /lib/init/mount-functions.sh + +# Set this as a variable to hide from lintian the fact that we're removing +# it; otherwise, a wrong lintian check + ftp fatal autoreject prevents us +# from uploading this legitimate code, even though the previous upload was +# accepted without incident. +devshm=/dev/shm + +case "$1" in + configure) + PREV_VER=$2 + ;; + abort-upgrade|abort-remove|abort-deconfigure) + exit 0 + ;; +esac + +umask 022 + +compat_link () { + SRC=$1 + DEST=$2 + + ssrc="$(stat -L --format="%d %i" "$SRC" 2>/dev/null || :)" + sdest="$(stat -L --format="%d %i" "$DEST" 2>/dev/null || :)" + + if [ -n "$ssrc" ] && [ "$ssrc" != "$sdest" ]; then + echo "guest environment detected: Linking $DEST to $SRC" + ( + if [ -e $DEST ]; then + if [ -L $DEST ]; then + echo "$DEST is already a symlink; not replacing with link to $SRC" + exit 0 + elif [ -d $DEST ]; then + rmdir $DEST || exit 1 + else + echo "$DEST isn't a directory or a symlink" + exit 1 + fi + fi + ln -fs $SRC $DEST + ) || { + echo "Can't symlink $DEST to $SRC; please fix manually." + return 1 + } + if which restorecon >/dev/null 2>&1; then + restorecon "$DEST" + fi + fi + + return 0 +} + +# In 2.88dsf-23 the "mountoverflowtmp" script was dropped entirely. +if dpkg --compare-versions "$PREV_VER" lt-nl "2.88dsf-23" ; then + update-rc.d -f mountoverflowtmp remove >/dev/null +fi +# In 2.88dsf-41+jessie1 the "mtab.sh" script was dropped entirely. +if dpkg --compare-versions "$PREV_VER" lt-nl "2.88dsf-41+jessie1" ; then + update-rc.d -f mtab.sh remove >/dev/null +fi + +# Comment out obsolete options in rcS. +if dpkg --compare-versions "$PREV_VER" lt-nl "2.88dsf-23" ; then + if [ -f /etc/default/rcS ]; then + sed -i \ +-e 's:^\(RAMRUN=.*\)$:#\1 # OBSOLETE; see /etc/default/tmpfs and tmpfs(5).:' \ +-e 's:^\(RAMLOCK=.*\)$:#\1 # OBSOLETE; see /etc/default/tmpfs and tmpfs(5).:' \ +-e ':^RAMSHM=:i# OBSOLETE; see /etc/default/tmpfs and tmpfs(5).' \ +-e ':^RAMTMP=:i# OBSOLETE; see /etc/default/tmpfs and tmpfs(5).' \ +-e 's:^\(EDITMOTD=.*\)$:#\1 # OBSOLETE.:' /etc/default/rcS + fi +fi + +INITSCRIPTS="mountkernfs.sh hostname.sh mountdevsubfs.sh checkroot.sh \ + checkroot-bootclean.sh checkfs.sh mountall.sh mountall-bootclean.sh \ + mountnfs.sh mountnfs-bootclean.sh bootmisc.sh urandom halt reboot \ + umountroot umountfs umountnfs.sh sendsigs killprocs single motd \ + bootlogs rc.local rmnologin" + +for F in $INITSCRIPTS; do + if [ -x /etc/init.d/$F ]; then + update-rc.d $F defaults >/dev/null || exit $? + fi +done + +mkdir -p /etc/systemd/system +for F in $INITSCRIPTS; do + SERVICE="$(basename $F .sh).service" + if [ -x /etc/init.d/$F ] && [ ! -e /etc/systemd/system/$SERVICE ]; then + ln -s /dev/null /etc/systemd/system/$SERVICE + fi +done + +# +# Remove scripts that were left behind by older glibc (<< 2.3.2.ds1-12) +# versions. We have the same functionality in mount{kern,devsub}fs.sh +# +# +# In 2.86.ds1-10 the "mountvirtfs" script was replaced by +# mountkernfs.sh and mountdevsubfs.sh. It was removed completely in +# 2.86.ds1-16. +# +for F in mountkernfs devpts.sh mountvirtfs +do + rm -f /etc/init.d/$F + update-rc.d $F remove >/dev/null +done + +# +# When installing for the first time or upgrading from a version +# before or equal to 2.88dsf-14, a reboot is needed to make the /run +# tmpfs available. Flag this using notify-reboot-required. /run is +# available in some form before the reboot, so the need for a reboot +# isn't particularly urgent. +# +if dpkg --compare-versions "$PREV_VER" le "2.88dsf-13.3" \ + && [ -x /usr/share/update-notifier/notify-reboot-required ]; then + /usr/share/update-notifier/notify-reboot-required +fi + +# +# Create initial log files +# +[ "$PREV_VER" ] || chmod 755 /var/log/fsck || : +for F in /var/log/dmesg /var/log/fsck/checkroot /var/log/fsck/checkfs +do + if [ ! -f "$F" ] && touch "$F" >/dev/null 2>&1 + then + echo "(Nothing has been logged yet.)" >| "$F" + chown root:adm "$F" + chmod 640 "$F" + fi +done + +# +# Create /dev/pts, /dev/shm directories +# +if [ "$(uname -s)" = Linux ] +then + # + # Only create /dev/{pts,shm} if /dev is on the + # root file system. If some package has mounted a + # seperate /dev (ramfs from udev, devfs) it is + # responsible for the presence of those subdirs. + # (it is OK for these to fail under fakechroot) + # + if ! mountpoint -q /dev + then + [ -d /dev/pts ] || { mkdir --mode=755 /dev/pts ; chown root:root /dev/pts || [ "$FAKECHROOT" = true ]; } + [ -d /dev/shm ] || { mkdir --mode=755 /dev/shm ; chown root:root /dev/shm || [ "$FAKECHROOT" = true ]; } + fi +fi + +# +# Install runsystem.sysv on Hurd. +# +if [ "$(uname -s)" = GNU ] +then + get_runsystem() { + update-alternatives --query runsystem \ + | sed -n -e '/^Value:/s|.*\.||p' + } + + current="$(get_runsystem)" + update-alternatives --quiet \ + --install /etc/hurd/runsystem runsystem \ + /etc/hurd/runsystem.sysv 10 \ + --slave /sbin/halt halt /sbin/halt-sysv \ + --slave /sbin/reboot reboot /sbin/reboot-sysv + new="$(get_runsystem)" + + if [ "$current" != "$new" ]; then + echo "Switching from runsystem.$current to runsystem.$new." + echo + fi + + echo "You can use update-alternatives --config runsystem to select" + echo "the runsystem to use." + echo + echo "You must use halt-hurd or reboot-hurd to halt or reboot the" + echo "system whenever you change the runsystem." +fi + +# Ensure we have a random seed on first boot. +if [ "$PREV_VER" = "" ]; then + if which invoke-rc.d >/dev/null 2>&1 + then + invoke-rc.d urandom start || true + else + /etc/init.d/urandom start || true + fi +fi + +# +# Create /etc/rc.local on first time install and when upgrading from +# versions before "2.86.ds1-16" +# +if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-16" +then + if [ ! -e /etc/rc.local ]; then + cat << EOF > /etc/rc.local +#!/bin/sh -e +# +# rc.local +# +# This script is executed at the end of each multiuser runlevel. +# Make sure that the script will "exit 0" on success or any other +# value on error. +# +# In order to enable or disable this script just change the execution +# bits. +# +# By default this script does nothing. + +exit 0 +EOF + # make sure it's enabled by default. + chmod 755 /etc/rc.local + fi +fi + +#DEBHELPER# + +: diff --git a/initscripts.postrm b/initscripts.postrm new file mode 100755 index 00000000..99e62c04 --- /dev/null +++ b/initscripts.postrm @@ -0,0 +1,75 @@ +#! /bin/sh +# +# initscripts postrm +# + +set -e + +INITSCRIPTS="mountkernfs.sh hostname.sh mountdevsubfs.sh checkroot.sh \ + checkroot-bootclean.sh checkfs.sh mountall.sh mountall-bootclean.sh \ + mountnfs.sh mountnfs-bootclean.sh bootmisc.sh urandom halt reboot \ + umountroot umountfs umountnfs.sh sendsigs killprocs single motd \ + bootlogs rc.local rmnologin" + +case "$1" in + purge) + # + # Remove abandoned conffiles + # + rm -f /etc/init.d/bootclean + rm -f /etc/init.d/bootclean.dpkg-old + rm -f /etc/init.d/bootclean.sh + rm -f /etc/init.d/bootclean.sh.dpkg-old + rm -f /etc/default/bootlogd + rm -f /etc/default/bootlogd.dpkg-old + + # + # Remove configuration files + # + rm -f \ + /etc/default/rcS \ + /etc/motd.tail \ + /etc/motd.static + + # + # Remove state files + # + rm -f /var/lib/initscripts/nologin + + # + # Remove run time state files + # + rm -f /var/run/motd + + # + # Remove log files + # + rm -f \ + /var/log/dmesg \ + /var/log/boot \ + /var/log/fsck/checkroot \ + /var/log/fsck/checkfs + + # Remove rc symlinks in the reverse dependency order they were + # inserted + for F in $INITSCRIPTS; do + REVERSE="$F $REVERSE" + done + for F in $REVERSE; do + update-rc.d $F remove >/dev/null || exit $? + done + + for F in $INITSCRIPTS; do + SERVICE="$(basename $F .sh).service" + if [ -L /etc/systemd/system/$SERVICE ]; then + rm /etc/systemd/system/$SERVICE + fi + done + + # Remove /dev/pts and /dev/shm ? + ;; +esac + +#DEBHELPER# + +: diff --git a/initscripts.preinst b/initscripts.preinst new file mode 100755 index 00000000..6c11ca13 --- /dev/null +++ b/initscripts.preinst @@ -0,0 +1,52 @@ +#! /bin/sh +# +# initscripts preinst +# + +set -e + +# Remove a no-longer used conffile +# +# $1: conffile +# +# If the argument was not listed as a conffile, silently do nothing. +# Adapted from code obtained from http://wiki.debian.org/DpkgConffileHandling +eliminate_conffile() { + PKGNAME="initscripts" + CONFFILE="$1" + + if [ -e "$CONFFILE" ]; then + CURRENT_MD5SUM="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`" + FACTORY_MD5SUM="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE'{s/ obsolete$//;s/.* //p}\"`" + if [ "$CURRENT_MD5SUM" != "$FACTORY_MD5SUM" ]; then + echo "Obsolete conffile $CONFFILE has been modified by you." + echo "Saving as $CONFFILE.dpkg-old ..." + mv -f "$CONFFILE" "$CONFFILE".dpkg-old + else + echo "Removing unmodified and obsolete conffile $CONFFILE ..." + rm -f "$CONFFILE" + fi + fi +} + +case "$1" in + install|upgrade) + # mtab was removed in 2.88dsf-41+jessie1; the remaining two lines + # were merged into checkroot, which provides mtab for compatibility + if [ "$2" ] && dpkg --compare-versions "$2" lt "2.88dsf-41+jessie1" ; then + eliminate_conffile "/etc/init.d/mtab.sh" + fi + + # + # Move conflicting log _file_ if present + # + [ -f /var/log/fsck ] && mv -f /var/log/fsck /var/log/fsck.dpkg-old + ;; + abort-upgrade) + exit 0 + ;; +esac + +#DEBHELPER# + +: diff --git a/patches/10_doc_manuals.dpatch b/patches/10_doc_manuals.dpatch new file mode 100644 index 00000000..44f4fd07 --- /dev/null +++ b/patches/10_doc_manuals.dpatch @@ -0,0 +1,78 @@ +Purpose: Misc patches to manual pages +Authour: the Debian ALSA psychos +Fixes: - +Status: unknown + +--- a/man/init.8 ++++ b/man/init.8 +@@ -56,21 +56,34 @@ A \fIrunlevel\fP is a software configura + only a selected group of processes to exist. The processes spawned by + \fBinit\fP for each of these runlevels are defined in the + \fB/etc/inittab\fP file. \fBInit\fP can be in one of eight runlevels: +-\fB0\(en6\fP and \fBS\fP or \fBs\fP. The runlevel is ++\fB0\(en6\fP and \fBS\fP (a.k.a. \fBs\fP). The runlevel is + changed by having a privileged user run \fBtelinit\fP, which sends + appropriate signals to \fBinit\fP, telling it which runlevel to change + to. + .PP +-Runlevels \fB0\fP, \fB1\fP, and \fB6\fP are reserved. Runlevel 0 is used to +-halt the system, runlevel 6 is used to reboot the system, and runlevel +-1 is used to get the system down into single user mode. Runlevel \fBS\fP +-is not really meant to be used directly, but more for the scripts that are +-executed when entering runlevel 1. For more information on this, ++Runlevels \fBS\fP, \fB0\fP, \fB1\fP, and \fB6\fP are reserved. ++Runlevel S is used to initialize the system on boot. ++When starting runlevel S (on boot) ++or runlevel 1 (switching from a multi-user runlevel) ++the system is entering ``single-user mode'', after which the ++current runlevel is S. ++Runlevel 0 is used to halt the system; ++runlevel 6 is used to reboot the system. ++.PP ++After booting through S the system automatically enters one of ++the multi-user runlevels 2 through 5, unless there was some ++problem that needs to be fixed by the administrator in ++single-user mode. ++Normally after entering single-user mode ++the administrator performs maintenance and then reboots the system. ++.PP ++For more information, + see the manpages for \fBshutdown\fP(8) and \fBinittab\fP(5). + .PP + Runlevels 7-9 are also valid, though not really documented. This is + because "traditional" Unix variants don't use them. +-In case you're curious, runlevels \fIS\fP and \fIs\fP are in fact the same. ++.PP ++Runlevels \fIS\fP and \fIs\fP are the same. + Internally they are aliases for the same runlevel. + .\"}}} + .PP +@@ -82,9 +95,10 @@ determines the initial runlevel of the s + entry (or no \fB/etc/inittab\fP at all), a runlevel must be + entered at the system console. + .PP +-Runlevel \fBS\fP or \fBs\fP bring the system to single user mode +-and do not require an \fB/etc/inittab\fP file. In single user mode, +-\fB/sbin/sulogin\fP is invoked on \fB/dev/console\fP. ++Runlevel \fBS\fP or \fBs\fP initialize the system ++and do not require an \fB/etc/inittab\fP file. ++.PP ++In single user mode, \fB/sbin/sulogin\fP is invoked on \fB/dev/console\fP. + .PP + When entering single user mode, \fBinit\fP initializes the consoles + \fBstty\fP settings to sane values. Clocal mode is set. Hardware +@@ -283,6 +297,14 @@ remain in the same process group which w + for them. If the processes change their group, \fBinit\fP can't + kill them and you may end up with two processes reading from one + terminal line. ++.PP ++On a Debian system, entering runlevel 1 causes all processes ++to be killed except for kernel threads and the script that does ++the killing and other processes in its session. ++As a consequence of this, it isn't safe to return from runlevel 1 ++to a multi-user runlevel: daemons that were started in runlevel S ++and are needed for normal operation are no longer running. ++The system should be rebooted. + .\"}}} + .\"{{{ Diagnostics + .SH DIAGNOSTICS diff --git a/patches/11_inittab_limits.patch b/patches/11_inittab_limits.patch new file mode 100644 index 00000000..64793300 --- /dev/null +++ b/patches/11_inittab_limits.patch @@ -0,0 +1,31 @@ +Description: Document process field limit in error message and manual page +Author: Johannes Truschnigg +Last-Update: 2012-11-23 +Status: applied upstream + +diff --git a/man/inittab.5 b/man/inittab.5 +index e1d739d..80aa084 100644 +--- a/man/inittab.5 ++++ b/man/inittab.5 +@@ -66,7 +66,7 @@ a `+' character, + .B init + will not do utmp and wtmp accounting for that process. This is needed for + gettys that insist on doing their own utmp/wtmp housekeeping. This is also +-a historic bug. ++a historic bug. The length of this field is limited to 127 characters. + .\"}}} + .PP + The \fIrunlevels\fP field may contain multiple characters for different +diff --git a/src/init.c b/src/init.c +index 27532ad..f8bf891 100644 +--- a/src/init.c ++++ b/src/init.c +@@ -1314,7 +1314,7 @@ void read_inittab(void) + if (rlevel && strlen(rlevel) > 11) + strcpy(err, "rlevel field too long (max 11 characters)"); + if (process && strlen(process) > 127) +- strcpy(err, "process field too long"); ++ strcpy(err, "process field too long (max 127 characters)"); + if (action && strlen(action) > 32) + strcpy(err, "action field too long"); + if (err[0] != 0) { diff --git a/patches/11_lfs_cflags.patch b/patches/11_lfs_cflags.patch new file mode 100644 index 00000000..20222b6e --- /dev/null +++ b/patches/11_lfs_cflags.patch @@ -0,0 +1,17 @@ +Purpose: Enable large file support +Author: Roger Leigh +Fixes: Needed on GNU/Hurd +Status: Not submitted upstream + +diff --git a/src/Makefile b/src/Makefile +index e2b8028..ccc5ab4 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -11,6 +11,7 @@ + CPPFLAGS = + CFLAGS ?= -ansi -O2 -fomit-frame-pointer + override CFLAGS += -W -Wall -D_GNU_SOURCE ++override CFLAGS += $(shell getconf LFS_CFLAGS) + STATIC = + + # For some known distributions we do not build all programs, otherwise we do. diff --git a/patches/11_man_fstab_decode_typo b/patches/11_man_fstab_decode_typo new file mode 100644 index 00000000..79c0db42 --- /dev/null +++ b/patches/11_man_fstab_decode_typo @@ -0,0 +1,17 @@ +Purpose: Fix typo in fstab-decode(8) font escape +Author: Bjarni Ingi Gislason +Fixes: - +Status: applied upstream + +--- +--- a/man/fstab-decode.8 ++++ b/man/fstab-decode.8 +@@ -26,7 +26,7 @@ fstab-decode \- run a command with fstab-encoded arguments + + .SH DESCRIPTION + .B fstab-decode +-decodes escapes in the specified \FIARGUMENT\fRs ++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, diff --git a/patches/11_man_halt8.patch b/patches/11_man_halt8.patch new file mode 100644 index 00000000..28e9161d --- /dev/null +++ b/patches/11_man_halt8.patch @@ -0,0 +1,32 @@ +Description: Fixes for halt(8) manual page. +Author: Christoph Anton Mitterer +Bug-Debian: http://bugs.debian.org/587923 + +diff --git a/man/halt.8 b/man/halt.8 +index 8ae3c63..9f326f6 100644 +--- a/man/halt.8 ++++ b/man/halt.8 +@@ -51,7 +51,7 @@ halt, reboot, poweroff \- stop the system. + .\"}}} + .\"{{{ Description + .SH DESCRIPTION +-\fBHalt\fP notes that the system is being brought down in the file ++\fBhalt\fP notes that the system is being brought down in the file + \fI/var/log/wtmp\fP, and then either tells the kernel to halt, reboot or + power-off the system. + .PP +@@ -68,12 +68,12 @@ and 6, that is when the systems shutdown scripts are being run. + .SH OPTIONS + .IP \fB\-n\fP + Don't sync before reboot or halt. Note that the kernel and storage +-drivers may still sync. ++drivers may still sync. This implies \fB\-d\fP. + .IP \fB\-w\fP + Don't actually reboot or halt but only write the wtmp record + (in the \fI/var/log/wtmp\fP file). + .IP \fB\-d\fP +-Don't write the wtmp record. The \fB\-n\fP flag implies \fB\-d\fP. ++Don't write the wtmp record. + .IP \fB\-f\fP + Force halt or reboot, don't call \fBshutdown\fP(8). + .IP \fB\-i\fP diff --git a/patches/11_run_nologin.patch b/patches/11_run_nologin.patch new file mode 100644 index 00000000..fd22070b --- /dev/null +++ b/patches/11_run_nologin.patch @@ -0,0 +1,43 @@ +Description: Use /run/nologin instead of /etc/nologin +Author: Roger Leigh +Bug-Debian: http://bugs.debian.org/660862 + +diff --git a/man/shutdown.8 b/man/shutdown.8 +index 919a77e..9ce56e4 100644 +--- a/man/shutdown.8 ++++ b/man/shutdown.8 +@@ -119,7 +119,7 @@ Second, it can be in the format \fB+\fP\fIm\fP, in which \fIm\fP is the + number of minutes to wait. The word \fBnow\fP is an alias for \fB+0\fP. + .PP + If shutdown is called with a delay, it will create the advisory file +-.I /etc/nologin ++.I /run/nologin + which causes programs such as \fIlogin(1)\fP to not allow new user + logins. This file is created five minutes before the shutdown sequence + starts. Shutdown removes this file if it is stopped before it +diff --git a/src/paths.h b/src/paths.h +index 232a944..74c867e 100644 +--- a/src/paths.h ++++ b/src/paths.h +@@ -28,7 +28,7 @@ + #define SDALLOW "/etc/shutdown.allow" /* Users allowed to shutdown */ + #define INITTAB "/etc/inittab" /* Location of inittab */ + #define INIT "/sbin/init" /* Location of init itself. */ +-#define NOLOGIN "/etc/nologin" /* Stop user logging in. */ ++#define NOLOGIN "/run/nologin" /* Stop user logging in. */ + #define FASTBOOT "/fastboot" /* Enable fast boot. */ + #define FORCEFSCK "/forcefsck" /* Force fsck on boot */ + #define SDPID "/var/run/shutdown.pid" /* PID of shutdown program */ +diff --git a/src/shutdown.c b/src/shutdown.c +index 7e997da..8c3345a 100644 +--- a/src/shutdown.c ++++ b/src/shutdown.c +@@ -234,7 +234,7 @@ void warn(int mins) + } + + /* +- * Create the /etc/nologin file. ++ * Create the /run/nologin file. + */ + void donologin(int min) + { diff --git a/patches/20_init_freebsd_vswtc.patch b/patches/20_init_freebsd_vswtc.patch new file mode 100644 index 00000000..d5baf6fd --- /dev/null +++ b/patches/20_init_freebsd_vswtc.patch @@ -0,0 +1,17 @@ +Purpose: kFreeBSD is missing VSWTC, provide workaround. +Authour: Petter Reinholdtsen +Fixes: #579293 +Status: applied upstream + +--- sysvinit.old/src/init.c (revision 1869) ++++ sysvinit/src/init.c (working copy) +@@ -770,7 +770,9 @@ + tty.c_cc[VEOF] = CEOF; + tty.c_cc[VTIME] = 0; + tty.c_cc[VMIN] = 1; ++#ifdef VSWTC /* not defined on FreeBSD */ + tty.c_cc[VSWTC] = _POSIX_VDISABLE; ++#endif /* VSWTC */ + tty.c_cc[VSTART] = CSTART; + tty.c_cc[VSTOP] = CSTOP; + tty.c_cc[VSUSP] = CSUSP; diff --git a/patches/30_killall5_hurd.patch b/patches/30_killall5_hurd.patch new file mode 100644 index 00000000..40920aac --- /dev/null +++ b/patches/30_killall5_hurd.patch @@ -0,0 +1,30 @@ +Purpose: Hurd is missing PATH_MAX, provide workaround. +Authour: Werner Fink +Fixes: ? +Status: applied upstream + +--- sysvinit.orig/src/killall5.c (revision 1869) ++++ sysvinit/src/killall5.c (working copy) +@@ -43,6 +43,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -59,6 +60,14 @@ + + char *Version = "@(#)killall5 2.86 31-Jul-2004 miquels@cistron.nl"; + ++#ifndef PATH_MAX ++# ifdef MAXPATHLEN ++# define PATH_MAX MAXPATHLEN ++# else ++# define PATH_MAX 2048 ++# endif ++#endif ++ + #define STATNAMELEN 15 + #define DO_NETFS 2 + #define DO_STAT 1 diff --git a/patches/31_killall5_hurd.patch b/patches/31_killall5_hurd.patch new file mode 100644 index 00000000..d43876bb --- /dev/null +++ b/patches/31_killall5_hurd.patch @@ -0,0 +1,37 @@ +Author: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Mon Jul 8 15:56:46 2013 +0200 +Description: killall5.c: Use sysconf(_SC_SYMLOOP_MAX) instead of MAXSYMLINKS. + If sysconf returns an error, fall back to MAXSYMLINKS on platforms that + define it. Fixes build on Hurd. +Status: applied upstream + +--- a/src/killall5.c ++++ b/src/killall5.c +@@ -376,13 +376,26 @@ out: + } + + /* ++ * Get the maximal number of symlinks to follow. ++ */ ++static int maxsymlinks(void) ++{ ++ int v = sysconf(_SC_SYMLOOP_MAX); ++#ifdef MAXSYMLINKS ++ if (v == -1) ++ return MAXSYMLINKS; ++#endif ++ return v; ++} ++ ++/* + * 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; ++ int deep = maxsymlinks(); + + if (!nlist) return 0; + diff --git a/patches/40_multiarch_libcrypt.patch b/patches/40_multiarch_libcrypt.patch new file mode 100644 index 00000000..c09e4317 --- /dev/null +++ b/patches/40_multiarch_libcrypt.patch @@ -0,0 +1,24 @@ +Purpose: Use multiarch library search path to find and link with libcrypt +Author: Roger Leigh +Fixes: #629677 +Status: Not sent upstream. + + +--- a/src/Makefile ++++ b/src/Makefile +@@ -78,10 +78,15 @@ else + SULOGINLIBS = + endif + ++LIBDIR=/usr/lib + # Additional libs for GNU libc. + ifneq ($(wildcard /usr/lib*/libcrypt.a),) ++ SULOGINLIBS += -lcrypt ++else ++ifneq ($(wildcard $(LIBDIR)*/libcrypt.a),) + SULOGINLIBS += -lcrypt + endif ++endif + + all: $(BIN) $(SBIN) $(USRBIN) + diff --git a/patches/63_init_keep_utf8_ttyflag.patch b/patches/63_init_keep_utf8_ttyflag.patch new file mode 100644 index 00000000..e16831f4 --- /dev/null +++ b/patches/63_init_keep_utf8_ttyflag.patch @@ -0,0 +1,21 @@ +Purpose: Make sure the utf-8 flag is not cleared from the tty. +Authour: Samuel Thibault +Fixes: #547073 +Status: applied upstream + +--- a/src/init.c ++++ b/src/init.c +@@ -786,10 +786,11 @@ void console_stty(void) + /* + * Set pre and post processing + */ +- tty.c_iflag = IGNPAR|ICRNL|IXON|IXANY; ++ tty.c_iflag = IGNPAR|ICRNL|IXON|IXANY + #ifdef IUTF8 /* Not defined on FreeBSD */ +- tty.c_iflag |= IUTF8; ++ | (tty.c_iflag & IUTF8) + #endif /* IUTF8 */ ++ ; + tty.c_oflag = OPOST|ONLCR; + tty.c_lflag = ISIG|ICANON|ECHO|ECHOCTL|ECHOPRT|ECHOKE; + diff --git a/patches/64_init_selinux_enabled.patch b/patches/64_init_selinux_enabled.patch new file mode 100644 index 00000000..47584dfc --- /dev/null +++ b/patches/64_init_selinux_enabled.patch @@ -0,0 +1,40 @@ +Purpose: Try to fix the logic used to enable SELinux +Authour: Petter Reinholdtsen +Fixes: #580272 +Status: applied upstream + +--- a/src/init.c ++++ b/src/init.c +@@ -54,10 +54,6 @@ + + #ifdef WITH_SELINUX + # include +-# include +-# ifndef MNT_DETACH /* present in glibc 2.10, missing in 2.7 */ +-# define MNT_DETACH 2 +-# endif + #endif + + #ifdef __i386__ +@@ -2872,11 +2868,9 @@ int main(int argc, char **argv) + + #ifdef WITH_SELINUX + 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 (is_selinux_enabled() != 1) { + if (selinux_init_load_policy(&enforce) == 0) { ++ putenv("SELINUX_INIT=YES"); + execv(myname, argv); + } else { + if (enforce > 0) { +@@ -2887,7 +2881,6 @@ int main(int argc, char **argv) + } + } + } +- if (rc == 0) umount2("/proc", MNT_DETACH); + } + #endif + /* Start booting. */ diff --git a/patches/92_kfreebsd_ifdown.patch b/patches/92_kfreebsd_ifdown.patch new file mode 100644 index 00000000..da85fe99 --- /dev/null +++ b/patches/92_kfreebsd_ifdown.patch @@ -0,0 +1,128 @@ +Purpose: Port ifdown.c to FreeBSD. +Authour: Guillem Jover +Fixes: #606565 +Status: applied upstream + +--- a/src/ifdown.c ++++ b/src/ifdown.c +@@ -37,6 +37,23 @@ + + #define MAX_IFS 64 + ++/* XXX: Ideally this would get detected at configure time... */ ++#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ ++ defined(__NetBSD__) || defined(__OpenBSD__) ++#define HAVE_SOCKADDR_SA_LEN 1 ++#endif ++ ++#ifndef _SIZEOF_ADDR_IFREQ ++#ifdef HAVE_SOCKADDR_SA_LEN ++#define _SIZEOF_ADDR_IFREQ(ifr) \ ++ ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \ ++ (sizeof((ifr).ifr_name) + (ifr).ifr_addr.sa_len) : \ ++ sizeof(struct ifreq)) ++#else ++#define _SIZEOF_ADDR_IFREQ(ifr) sizeof(struct ifreq) ++#endif ++#endif ++ + /* + * First, we find all shaper devices and down them. Then we + * down all real interfaces. This is because the comment in the +@@ -45,10 +62,10 @@ + */ + int ifdown(void) + { +- struct ifreq ifr[MAX_IFS]; ++ char ifr_buf[sizeof(struct ifreq) * MAX_IFS]; ++ char *ifr_end; + struct ifconf ifc; +- int i, fd; +- int numif; ++ int fd; + int shaper; + + if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { +@@ -56,8 +73,8 @@ + perror("socket"); + return -1; + } +- ifc.ifc_len = sizeof(ifr); +- ifc.ifc_req = ifr; ++ ifc.ifc_len = sizeof(ifr_buf); ++ ifc.ifc_buf = ifr_buf; + + if (ioctl(fd, SIOCGIFCONF, &ifc) < 0) { + fprintf(stderr, "ifdown: "); +@@ -65,42 +82,55 @@ + close(fd); + return -1; + } +- numif = ifc.ifc_len / sizeof(struct ifreq); ++ ifr_end = ifr_buf + ifc.ifc_len; + + for (shaper = 1; shaper >= 0; shaper--) { +- for (i = 0; i < numif; i++) { ++ char *ifr_next = ifr_buf; ++ ++ while (ifr_next < ifr_end) { ++ struct ifreq *ifr; ++ int flags; + +- if ((strncmp(ifr[i].ifr_name, "shaper", 6) == 0) ++ ifr = (struct ifreq *)ifr_next; ++ ifr_next += _SIZEOF_ADDR_IFREQ(*ifr); ++ ++ if ((strncmp(ifr->ifr_name, "shaper", 6) == 0) + != shaper) continue; + +- if (strcmp(ifr[i].ifr_name, "lo") == 0) ++ if (strncmp(ifr->ifr_name, "lo", 2) == 0) + continue; +- if (strchr(ifr[i].ifr_name, ':') != NULL) ++ if (strchr(ifr->ifr_name, ':') != NULL) + continue; + + /* Read interface flags */ +- if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) < 0) { ++ if (ioctl(fd, SIOCGIFFLAGS, ifr) < 0) { + fprintf(stderr, "ifdown: shutdown "); +- perror(ifr[i].ifr_name); ++ perror(ifr->ifr_name); + continue; + } + /* + * Expected in according to + * "UNIX Network Programming". + */ +-#ifdef ifr_flags +-# define IRFFLAGS ifr_flags +-#else /* Present on kFreeBSD */ +-# define IRFFLAGS ifr_flagshigh ++#ifdef ifr_flagshigh ++ flags = (ifr->ifr_flags & 0xffff) | ++ (ifr->ifr_flagshigh << 16); ++#else ++ flags = ifr->ifr_flags; ++#endif ++ if (flags & IFF_UP) { ++ flags &= ~(IFF_UP); ++#ifdef ifr_flagshigh ++ ifr->ifr_flags = flags & 0xffff; ++ ifr->ifr_flagshigh = flags >> 16; ++#else ++ ifr->ifr_flags = flags; + #endif +- if (ifr[i].IRFFLAGS & IFF_UP) { +- ifr[i].IRFFLAGS &= ~(IFF_UP); +- if (ioctl(fd, SIOCSIFFLAGS, &ifr[i]) < 0) { ++ if (ioctl(fd, SIOCSIFFLAGS, ifr) < 0) { + fprintf(stderr, "ifdown: shutdown "); +- perror(ifr[i].ifr_name); ++ perror(ifr->ifr_name); + } + } +-#undef IRFFLAGS + } + } + close(fd); diff --git a/patches/93_run_initctl.patch b/patches/93_run_initctl.patch new file mode 100644 index 00000000..43c24f0a --- /dev/null +++ b/patches/93_run_initctl.patch @@ -0,0 +1,158 @@ +Description: Change /dev/initctl to /run/initctl to work on kFreeBSD + Named pipes can not exist in /dev/ on kFreeBSD. Move it elsewhere. +Author: Robert Millan +Last-Update: 2012-01-08 +Fixes: #638019 +Status: not yet sent upstream + +--- a/doc/Install ++++ b/doc/Install +@@ -48,7 +48,7 @@ You might want to create a file called " + manual page on shutdown to find out more about this. + + Running from a read-only file system (CDROM?): +-o All communication to init goes through the FIFO /dev/initctl. ++o All communication to init goes through the FIFO /run/initctl. + There should be no problem using a read-only root file system + IF you use a Linux kernel > 1.3.66. Older kernels don't allow + writing to a FIFO on a read-only file system. +--- a/man/init.8 ++++ b/man/init.8 +@@ -144,7 +144,7 @@ letters \fBF\fP, \fBO\fP or \fBL\fP, ini + the letter \fBF\fP. + .PP + Usage of \fBSIGPWR\fP and \fB/etc/powerstatus\fP is discouraged. Someone +-wanting to interact with \fBinit\fP should use the \fB/dev/initctl\fP ++wanting to interact with \fBinit\fP should use the \fB/run/initctl\fP + control channel - see the source code of the \fBsysvinit\fP package + for more documentation about this. + .PP +@@ -248,7 +248,7 @@ can then manipulate the command line so + the current runlevel. + .PP + .SH INTERFACE +-Init listens on a \fIfifo\fP in /dev, \fI/dev/initctl\fP, for messages. ++Init listens on a \fIfifo\fP in /run, \fI/run/initctl\fP, for messages. + \fBTelinit\fP uses this to communicate with init. The interface is not + very well documented or finished. Those interested should study the + \fIinitreq.h\fP file in the \fIsrc/\fP subdirectory of the \fBinit\fP +@@ -262,7 +262,7 @@ Has the same effect as \fBtelinit q\fP. + .TP 0.5i + .B SIGUSR1 + On receipt of this signals, init closes and re-opens its control fifo, +-\fB/dev/initctl\fP. Useful for bootscripts when /dev is remounted. ++\fB/run/initctl\fP. + .TP 0.5i + .B SIGINT + Normally the kernel sends this signal to init when CTRL-ALT-DEL is +@@ -287,7 +287,7 @@ file in the directory \fI/etc/init.d\fP + /dev/console + /var/run/utmp + /var/log/wtmp +-/dev/initctl ++/run/initctl + .fi + .\"}}} + .\"{{{ Warnings +--- a/src/Makefile ++++ b/src/Makefile +@@ -182,8 +182,8 @@ ifeq ($(ROOT),) + # + # This part is skipped on Debian systems, the + # debian.preinst script takes care of it. +- @if [ ! -p /dev/initctl ]; then \ +- echo "Creating /dev/initctl"; \ +- rm -f /dev/initctl; \ +- mknod -m 600 /dev/initctl p; fi ++ @if [ ! -p /run/initctl ]; then \ ++ echo "Creating /run/initctl"; \ ++ rm -f /run/initctl; \ ++ mknod -m 600 /run/initctl p; fi + endif +--- a/src/init.c ++++ b/src/init.c +@@ -129,7 +129,7 @@ char *argv0; /* First arguments; show + int maxproclen; /* Maximal length of argv[0] with \0 */ + struct utmp utproto; /* Only used for sizeof(utproto.ut_id) */ + char *console_dev; /* Console device. */ +-int pipe_fd = -1; /* /dev/initctl */ ++int pipe_fd = -1; /* /run/initctl */ + int did_boot = 0; /* Did we already do BOOT* stuff? */ + int main(int, char **); + +@@ -2174,13 +2174,13 @@ void check_init_fifo(void) + int quit = 0; + + /* +- * First, try to create /dev/initctl if not present. ++ * First, try to create /run/initctl if not present. + */ + if (stat(INIT_FIFO, &st2) < 0 && errno == ENOENT) + (void)mkfifo(INIT_FIFO, 0600); + + /* +- * If /dev/initctl is open, stat the file to see if it ++ * If /run/initctl is open, stat the file to see if it + * is still the _same_ inode. + */ + if (pipe_fd >= 0) { +@@ -2194,7 +2194,7 @@ void check_init_fifo(void) + } + + /* +- * Now finally try to open /dev/initctl ++ * Now finally try to open /run/initctl + */ + if (pipe_fd < 0) { + if ((pipe_fd = open(INIT_FIFO, O_RDWR|O_NONBLOCK)) >= 0) { +@@ -2500,7 +2500,7 @@ void process_signals() + } + if (ISMEMBER(got_signals, SIGUSR1)) { + /* +- * SIGUSR1 means close and reopen /dev/initctl ++ * SIGUSR1 means close and reopen /run/initctl + */ + INITDBG(L_VB, "got SIGUSR1"); + close(pipe_fd); +@@ -2736,7 +2736,7 @@ int telinit(char *progname, int argc, ch + chdir("/"); + + /* Open the fifo and write a command. */ +- /* Make sure we don't hang on opening /dev/initctl */ ++ /* Make sure we don't hang on opening /run/initctl */ + SETSIG(sa, SIGALRM, signal_handler, 0); + alarm(3); + if ((fd = open(INIT_FIFO, O_WRONLY)) >= 0) { +--- a/src/initreq.h ++++ b/src/initreq.h +@@ -1,5 +1,5 @@ + /* +- * initreq.h Interface to talk to init through /dev/initctl. ++ * initreq.h Interface to talk to init through /run/initctl. + * + * Copyright (C) 1995-2004 Miquel van Smoorenburg + * +@@ -25,11 +25,7 @@ + + #include + +-#if defined(__FreeBSD_kernel__) +-# define INIT_FIFO "/etc/.initctl" +-#else +-# define INIT_FIFO "/dev/initctl" +-#endif ++#define INIT_FIFO "/run/initctl" + + #define INIT_MAGIC 0x03091969 + #define INIT_CMD_START 0 +--- a/src/shutdown.c ++++ b/src/shutdown.c +@@ -173,7 +173,7 @@ int init_setenv(char *name, char *value) + + /* + * Open the fifo and write the command. +- * Make sure we don't hang on opening /dev/initctl ++ * Make sure we don't hang on opening /run/initctl + */ + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = alrm_handler; diff --git a/patches/94_kfreebsd_xterm.patch b/patches/94_kfreebsd_xterm.patch new file mode 100644 index 00000000..c44705a9 --- /dev/null +++ b/patches/94_kfreebsd_xterm.patch @@ -0,0 +1,20 @@ +Description: Replace "cons25" with "xterm" on GNU/kFreeBSD. +Author: Robert Millan +Origin: http://anonscm.debian.org/gitweb/?p=collab-maint/sysvinit;a=commitdiff;h=3e8e00d23f57957645285937fbdcaea30adc7149 + +--- a/src/init.c ++++ b/src/init.c +@@ -747,11 +747,11 @@ + #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 ++ * "xterm". 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"); ++ putenv ("TERM=xterm"); + #endif + + (void) tcgetattr(fd, &tty); diff --git a/patches/95_kfreebsd_bootlogd.patch b/patches/95_kfreebsd_bootlogd.patch new file mode 100644 index 00000000..4ce4852f --- /dev/null +++ b/patches/95_kfreebsd_bootlogd.patch @@ -0,0 +1,43 @@ +Description: Adapt TIOCCONS call to kfreebsd. + Isolate Linux-only forms of ioctl call with TIOCCONS. The BSD form of + this needs a pointer to an integer, and its fails with a NULL pointer. +Author: Mats Erik Andersson +Last-Update: 2012-04-03 +Fixes: #576443 +Status: applied upstream + +--- sysvinit-2.88dsf.debian/src/bootlogd.c ++++ sysvinit-2.88dsf/src/bootlogd.c +@@ -482,6 +482,9 @@ + int realfd; + int n, m, i; + int todo; ++#ifndef __linux__ /* BSD-style ioctl needs an argument. */ ++ int on = 1; ++#endif + + fp = NULL; + logfile = LOGFILE; +@@ -554,15 +557,20 @@ + return 1; + } + ++#ifdef __linux__ + (void)ioctl(0, TIOCCONS, NULL); +-#if 1 + /* Work around bug in 2.1/2.2 kernels. Fixed in 2.2.13 and 2.3.18 */ + if ((n = open("/dev/tty0", O_RDWR)) >= 0) { + (void)ioctl(n, TIOCCONS, NULL); + close(n); + } + #endif +- if (ioctl(pts, TIOCCONS, NULL) < 0) { ++#ifdef __linux__ ++ if (ioctl(pts, TIOCCONS, NULL) < 0) ++#else /* BSD usage of ioctl TIOCCONS. */ ++ if (ioctl(pts, TIOCCONS, &on) < 0) ++#endif ++ { + fprintf(stderr, "bootlogd: ioctl(%s, TIOCCONS): %s\n", + buf, strerror(errno)); + return 1; diff --git a/patches/96_allow_multiple_console_output.patch b/patches/96_allow_multiple_console_output.patch new file mode 100644 index 00000000..028e7326 --- /dev/null +++ b/patches/96_allow_multiple_console_output.patch @@ -0,0 +1,294 @@ +Description: Allow multiple console output + When booting a kernel with multiple serial console support, or multuiple + console arguments ala "console=tty1 console=ttyS0,9600" the kernel will output + messages to all consoles, init however will not. It will only send output to, + and accept input from, the last of the consoles. + . + This patch fixes it. +Author: Martin Buck +Origin: other, https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=181756 +Bug-Debian: https://bugs.debian.org/181756 +Forwarded: no +Last-Update: 2014-07-20 + +Index: sysvinit-2.88dsf/src/bootlogd.c +=================================================================== +--- sysvinit-2.88dsf.orig/src/bootlogd.c 2010-03-23 15:37:01.000000000 +0100 ++++ sysvinit-2.88dsf/src/bootlogd.c 2013-07-15 09:56:55.953975300 +0200 +@@ -57,6 +57,7 @@ + char *Version = "@(#) bootlogd 2.86 03-Jun-2004 miquels@cistron.nl"; + + #define LOGFILE "/var/log/boot" ++#define MAX_CONSOLES 16 + + char ringbuf[32768]; + char *endptr = ringbuf + sizeof(ringbuf); +@@ -73,6 +74,11 @@ + int pos; + } line; + ++struct real_cons { ++ char name[1024]; ++ int fd; ++}; ++ + /* + * Console devices as listed on the kernel command line and + * the mapping to actual devices in /dev +@@ -235,10 +241,10 @@ + } + + /* +- * Find out the _real_ console. Assume that stdin is connected to ++ * Find out the _real_ console(s). Assume that stdin is connected to + * the console device (/dev/console). + */ +-int consolename(char *res, int rlen) ++int consolenames(struct real_cons *cons, int max_consoles) + { + #ifdef TIOCGDEV + unsigned int kdev; +@@ -247,34 +253,9 @@ + char buf[256]; + char *p; + int didmount = 0; +- int n, r; ++ int n; + int fd; +- +- fstat(0, &st); +- if (major(st.st_rdev) != 5 || minor(st.st_rdev) != 1) { +- /* +- * Old kernel, can find real device easily. +- */ +- 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 +-# 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 ++ int considx, num_consoles = 0; + + #ifdef __linux__ + /* +@@ -283,7 +264,7 @@ + stat("/", &st); + if (stat("/proc", &st2) < 0) { + perror("bootlogd: /proc"); +- return -1; ++ return 0; + } + if (st.st_dev == st2.st_dev) { + if (mount("proc", "/proc", "proc", 0, NULL) < 0) { +@@ -293,21 +274,21 @@ + didmount = 1; + } + +- n = 0; +- r = -1; ++ n = -1; + if ((fd = open("/proc/cmdline", O_RDONLY)) < 0) { + perror("bootlogd: /proc/cmdline"); + } else { + buf[0] = 0; +- if ((n = read(fd, buf, sizeof(buf) - 1)) >= 0) +- r = 0; +- else ++ if ((n = read(fd, buf, sizeof(buf) - 1)) < 0) + perror("bootlogd: /proc/cmdline"); + close(fd); + } + if (didmount) umount("/proc"); ++ ++ ++ if (n < 0) return 0; ++ + +- if (r < 0) return r; + + /* + * OK, so find console= in /proc/cmdline. +@@ -315,21 +296,32 @@ + */ + p = buf + n; + *p-- = 0; +- r = -1; + while (p >= buf) { + if (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n') { + *p-- = 0; + continue; + } + if (strncmp(p, "console=", 8) == 0 && +- isconsole(p + 8, res, rlen)) { +- r = 0; +- break; ++ isconsole(p + 8, cons[num_consoles].name, sizeof(cons[num_consoles].name))) { ++ /* ++ * Suppress duplicates ++ */ ++ for (considx = 0; considx < num_consoles; considx++) { ++ if (!strcmp(cons[num_consoles].name, cons[considx].name)) { ++ goto dontuse; ++ } ++ } ++ ++ num_consoles++; ++ if (num_consoles >= max_consoles) { ++ break; ++ } + } ++dontuse: + p--; + } + +- if (r == 0) return r; ++ if (num_consoles > 0) return num_consoles; + #endif + + /* +@@ -337,12 +329,12 @@ + * guess the default console. + */ + for (n = 0; defcons[n]; n++) +- if (isconsole(defcons[n], res, rlen)) +- return 0; ++ if (isconsole(defcons[n], cons[0].name, sizeof(cons[0].name))) ++ return 1; + + fprintf(stderr, "bootlogd: cannot deduce real console device\n"); + +- return -1; ++ return 0; + } + + +@@ -472,7 +464,6 @@ + struct timeval tv; + fd_set fds; + char buf[1024]; +- char realcons[1024]; + char *p; + char *logfile; + char *pidfile; +@@ -485,6 +476,9 @@ + #ifndef __linux__ /* BSD-style ioctl needs an argument. */ + int on = 1; + #endif ++ int considx; ++ struct real_cons cons[MAX_CONSOLES]; ++ int num_consoles, consoles_left; + + fp = NULL; + logfile = LOGFILE; +@@ -531,18 +525,22 @@ + /* + * Open console device directly. + */ +- if (consolename(realcons, sizeof(realcons)) < 0) +- return 1; +- +- if (strcmp(realcons, "/dev/tty0") == 0) +- strcpy(realcons, "/dev/tty1"); +- if (strcmp(realcons, "/dev/vc/0") == 0) +- strcpy(realcons, "/dev/vc/1"); +- +- if ((realfd = open_nb(realcons)) < 0) { +- fprintf(stderr, "bootlogd: %s: %s\n", buf, strerror(errno)); ++ if ((num_consoles = consolenames(cons, MAX_CONSOLES)) <= 0) + return 1; ++ consoles_left = num_consoles; ++ for (considx = 0; considx < num_consoles; considx++) { ++ if (strcmp(cons[considx].name, "/dev/tty0") == 0) ++ strcpy(cons[considx].name, "/dev/tty1"); ++ if (strcmp(cons[considx].name, "/dev/vc/0") == 0) ++ strcpy(cons[considx].name, "/dev/vc/1"); ++ ++ if ((cons[considx].fd = open_nb(cons[considx].name)) < 0) { ++ fprintf(stderr, "bootlogd: %s: %s\n", cons[considx].name, strerror(errno)); ++ consoles_left--; ++ } + } ++ if (!consoles_left) ++ return 1; + + /* + * Grab a pty, and redirect console messages to it. +@@ -626,26 +624,34 @@ + if ((n = read(ptm, inptr, endptr - inptr)) >= 0) { + /* + * Write data (in chunks if needed) +- * to the real output device. ++ * to the real output devices. + */ +- m = n; +- p = inptr; +- while (m > 0) { +- i = write(realfd, p, m); +- if (i >= 0) { +- m -= i; +- p += i; +- continue; +- } +- /* +- * Handle EIO (somebody hung +- * up our filedescriptor) +- */ +- realfd = write_err(pts, realfd, +- realcons, errno); +- if (realfd >= 0) continue; +- got_signal = 1; /* Not really */ +- break; ++ for (considx = 0; considx < num_consoles; considx++) { ++ if (cons[considx].fd < 0) continue; ++ m = n; ++ p = inptr; ++ while (m > 0) { ++ i = write(cons[considx].fd, p, m); ++ if (i >= 0) { ++ m -= i; ++ p += i; ++ continue; ++ } ++ /* ++ * Handle EIO (somebody hung ++ * up our filedescriptor) ++ */ ++ cons[considx].fd = write_err(pts, ++ cons[considx].fd, ++ cons[considx].name, errno); ++ if (cons[considx].fd >= 0) continue; ++ /* ++ * If this was the last console, ++ * generate a fake signal ++ */ ++ if (--consoles_left <= 0) got_signal = 1; ++ break; ++ } + } + + /* +@@ -691,7 +697,9 @@ + + close(pts); + close(ptm); +- close(realfd); ++ for (considx = 0; considx < num_consoles; considx++) { ++ close(cons[considx].fd); ++ } + + return 0; + } diff --git a/patches/series b/patches/series new file mode 100644 index 00000000..a95e1c8c --- /dev/null +++ b/patches/series @@ -0,0 +1,17 @@ +10_doc_manuals.dpatch +11_inittab_limits.patch +11_lfs_cflags.patch +11_man_halt8.patch +11_man_fstab_decode_typo +11_run_nologin.patch +20_init_freebsd_vswtc.patch +30_killall5_hurd.patch +31_killall5_hurd.patch +40_multiarch_libcrypt.patch +63_init_keep_utf8_ttyflag.patch +64_init_selinux_enabled.patch +92_kfreebsd_ifdown.patch +93_run_initctl.patch +94_kfreebsd_xterm.patch +95_kfreebsd_bootlogd.patch +96_allow_multiple_console_output.patch diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 00000000..b87b2686 --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1 @@ +[type: gettext/rfc822deb] sysv-rc.templates diff --git a/po/ca.po b/po/ca.po new file mode 100644 index 00000000..eb881fe0 --- /dev/null +++ b/po/ca.po @@ -0,0 +1,107 @@ +# sysvinit (debconf) translation to Catalan. +# Copyright (C) 1997-2005 +# This file is distributed under the same license as the sysvinit package. +# +# Innocent De Marchi , 2011-2012. +# +msgid "" +msgstr "" +"Project-Id-Version: sysvinit 2.88dsf-13.1\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-29 13:56-0400\n" +"PO-Revision-Date: 2012-06-12 18:14+0100\n" +"Last-Translator: Innocent De Marchi \n" +"Language-Team: Catalan \n" +"Language: ca\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Catalan\n" +"X-Poedit-Country: SPAIN\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "" +"No ha estat possible migrar al sistema d'arrencada basat en dependències" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Existeixen els següents problemes en el sistema d'arrencada, que impedeixen " +"la migració a la seqüència d'engegada basada en dependències:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Si el problema comunicat és una modificació local, cal solucionar-ho " +"manualment. Aquests problemes solen ser a causa de fitxers de configuració " +"obsolets que no s'han eliminat després de la eliminació d'un paquet, sense " +"haver-ho purgat. Es suggereix que s'eliminin executant:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"La instal·lació del paquet no pot continuar fins que no es solucionin els " +"problemes llistats. Per tornar a intentar el proces de migració, una vegada " +"solucionats els problemes, executeu «dpkg --configure sysv-rc»." + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "" +#~ "¿Voleu migrar l'antiga seqüència d'arrencada a la seqüència d'engegada " +#~ "basada en dependències?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "El sistema d'arrencada està preparat per migrar a la seqüència d'engegada " +#~ "basada en dependències. Aquest canvi és irreversible, però es recomana " +#~ "fer-ho: permet optimitzar el procés d'engegada en velocitat i eficiència, " +#~ "i proporciona un entorn robust de desenvolupament." + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "Al fitxer «/usr/share/doc/sysv-rc/README.Debian» hi ha l'explicació " +#~ "completa. Si decidiu no migrar ara, podreu fer-ho en el futur executant " +#~ "«dpkg-reconfigure sysv-rc»." + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "Si el problema és una modificació local, cal endreçar-ho manualment. Si " +#~ "és un error del paquet, caldrà informar-ne mitjançant el BTS, perquè " +#~ "s'endreci al paquet. Per obtenir més informació sobre com resoldre els " +#~ "problemes que impedeixen la migració, llegiu «http://wiki.debian.org/" +#~ "LSBInitScripts/DependencyBasedBoot»." diff --git a/po/cs.po b/po/cs.po new file mode 100644 index 00000000..18c2867d --- /dev/null +++ b/po/cs.po @@ -0,0 +1,101 @@ +# Czech translation of sysvinit debconf messages. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the sysvinit package. +# Miroslav Kure , 2009-2012. +# +msgid "" +msgstr "" +"Project-Id-Version: sysvinit\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-06-09 08:51+0200\n" +"PO-Revision-Date: 2012-06-23 19:28+0200\n" +"Last-Translator: Miroslav Kure \n" +"Language-Team: Czech \n" +"Language: cs\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "Nelze přejít na systém zavádění založený na závislostech" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Problémy v zaváděcím systému, které brání v přechodu na systém zavádění " +"založený na závislostech:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Pokud je nahlášený problém lokální úpravou, je nutno jej opravit ručně. " +"Typicky to bývají staré konfigurační soubory, které v systému zůstaly po " +"odstranění balíku (ne vyčištění). Můžete je zkusit odstranit příkazem:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"Instalace balíku nemůže pokračovat, dokud nebudou zmíněné problémy vyřešeny. " +"Po vyřešení problémů se můžete pokusit o nový přechod příkazem „dpkg " +"--configure sysv-rc“." + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "" +#~ "Přejít od starého systému zavádění k zavádění založenému na závislostech?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "Proces zavádění systému je připraven na přechod k systému zavádění " +#~ "založenému na závislostech. Tento krok je nevratný, nicméně doporučený, " +#~ "protože umožňuje optimalizovat rychlost a efektivitu zaváděcího procesu a " +#~ "navíc poskytuje pružnější rámec pro vývoj." + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "Podrobnější odůvodnění můžete nalézt v souboru /usr/share/doc/sysv-rc/" +#~ "README.Debian. Rozhodnete-li se přejít na tento systém někdy později, " +#~ "můžete tak učinit příkazem „dpkg-reconfigure sysv-rc“." + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "Pokud je zjištěný problém způsoben místními úpravami, budete ho muset " +#~ "opravit ručně. Jestliže se jedná o chybu v balíku, měli byste ji nahlásit " +#~ "do BTS a správce balíku by ji měl opravit. Více informací o nápravě " +#~ "problémů bránících v přechodu naleznete na http://wiki.debian.org/" +#~ "LSBInitScripts/DependencyBasedBoot." diff --git a/po/da.po b/po/da.po new file mode 100644 index 00000000..c3c8ed6b --- /dev/null +++ b/po/da.po @@ -0,0 +1,66 @@ +# Danish translation sysvinit. +# Copyright (C) 2012 sysvinit & Joe Hansen. +# This file is distributed under the same license as the sysvinit package. +# Joe Hansen , 2010, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: sysvinit\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-06-09 08:51+0200\n" +"PO-Revision-Date: 2012-06-10 17:30+01:00\n" +"Last-Translator: Joe Hansen \n" +"Language-Team: Danish \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "Kunne ikke migrere til afhængighedsbaseret opstartssystem" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Der findes problemer i opstartssystemet som forhindrer migrering til " +"afhængighedsbaserede opstartssekvenser:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Hvis de rapporterede problemer er lokale ændringer, skal de rettes " +"manuelt. Problemet skyldes typisk forældede konfigurationsfiler efterladt " +"efter at en pakke er blevet fjernet, men ikke afinstalleret. Det foreslås " +"at disse fjernes ved at køre:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"Pakkeinstallation kan ikke fortsætte, før at de ovenstående problemer " +"er blevet rettet. For at prøve migreringsprocessen igen efter at " +"problemerne er blevet rettet, kør »dpkg-reconfigure sysv-rc«." + diff --git a/po/de.po b/po/de.po new file mode 100644 index 00000000..38f64f83 --- /dev/null +++ b/po/de.po @@ -0,0 +1,67 @@ +# Translation of sysvinit to German +# Copyright (C) 1997-2005 Miquel van Smoorenburg . +# This file is distributed under the same license as the sysvinit package. +# Chris Leick , 2009, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: sysvinit 2.88dsf-27\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-06-09 08:51+0200\n" +"PO-Revision-Date: 2012-06-09 23:29+0200\n" +"Last-Translator: Chris Leick \n" +"Language-Team: German \n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "" +"Es konnte nicht auf abhängigkeitsbasierte Systemstartreihenfolge umgestellt " +"werden." + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Im Startsystem gibt es Probleme, die eine Umstellung auf " +"abhängigkeitsbasierte Systemstartreihenfolge verhindern:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Falls das gemeldete Problem von einer lokalen Änderung rührt, muss es manuell " +"behoben werden. Dies sind normalerweise veraltete Conffiles, die " +"zurückgeblieben sind, als ein Paket gelöscht, aber nicht vollständig entfernt " +"wurde. Es wird empfohlen, diese zu entfernen, indem Folgendes ausgeführt wird:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"Die Paketinstallation kann nicht fortgesetzt werden, bis obige Probleme " +"behoben wurde. Um den Umstellungsprozess nach dem Lösen dieser Probleme " +"erneut zu versuchen, führen Sie »dpkg --configure sysv-rc« aus." diff --git a/po/es.po b/po/es.po new file mode 100644 index 00000000..fcc09689 --- /dev/null +++ b/po/es.po @@ -0,0 +1,127 @@ +# sysvinit po-debconf translation to Spanish +# Copyright (C) 2009 Software in the Public Interest +# This file is distributed under the same license as the sysvinit package. +# +# Changes: +# - Initial translation +# Francisco Javier Cuadrado , 2009 +# - Translation update +# Javier Fernández-Sanguino , 2012 +# +# Traductores, si no conocen el formato PO, merece la pena leer la +# documentación de gettext, especialmente las secciones dedicadas a este +# formato, por ejemplo ejecutando: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# +# Equipo de traducción al español, por favor lean antes de traducir +# los siguientes documentos: +# +# - El proyecto de traducción de Debian al español +# http://www.debian.org/intl/spanish/ +# especialmente las notas y normas de traducción en +# http://www.debian.org/intl/spanish/notas +# +# - La guía de traducción de po's de debconf: +# /usr/share/doc/po-debconf/README-trans +# o http://www.debian.org/intl/l10n/po-debconf/README-trans +# +msgid "" +msgstr "" +"Project-Id-Version: sysvinit 2.87dsf-5\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-05 06:59+0200\n" +"PO-Revision-Date: 2012-09-05 16:29+0200\n" +"Last-Translator: Javier Fernández-Sanguino \n" +"Language-Team: Debian l10n Spanish \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-POFile-SpellExtra: sysv dpkg SUGGESTION rc\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "No se ha podido migrar al sistema de arranque basado en dependencias" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Existen los siguientes problemas en el sistema de arranque que impiden la " +"migración a la secuencia de arranque basada en dependencias:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Debe solucionar manualmente el problema reportado si se trata de una " +"modificación local. Habitualmente estos problemas se deben a ficheros de " +"configuración obsoletos que se mantienen tras haber borrado, pero no " +"purgado, un paquete. Se sugiere eliminar éstos ejecutando:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"El paquete de instalación no puede continuar hasta que los problemas se " +"hayan arreglado. Para reintentar el proceso de migración una vez estos " +"problemas se hayan solucionado, ejecute «dpkg --configure sysv-rc»." + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "" +#~ "¿Desea migrar la antigua secuencia de arranque a la secuencia de arranque " +#~ "basada en dependencias?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "El sistema de arranque está listo para migrar a la secuencia de arranque " +#~ "basada en dependencias. Este paso es irreversible, pero es recomendable: " +#~ "permite optimizar el proceso de arranque en velocidad y eficiencia, y " +#~ "proporciona un mejor entorno de desarrollo." + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "En el archivo «/usr/share/doc/sysv-rc/README.Debian» se detalla la " +#~ "explicación completa. Si escoge no migrar ahora, podrá hacerlo más " +#~ "adelante ejecutando «dpkg-reconfigure sysv-rc»." + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "Si el problema es una modificación local, se debe arreglar manualmente. " +#~ "Si es un error del paquete, se debería informar mediante el BTS y se " +#~ "arreglará en el paquete. Para más información sobre cómo resolver los " +#~ "problemas que impiden la migración, vea «http://wiki.debian.org/" +#~ "LSBInitScripts/DependencyBasedBoot»." diff --git a/po/fi.po b/po/fi.po new file mode 100644 index 00000000..0d9f45a0 --- /dev/null +++ b/po/fi.po @@ -0,0 +1,107 @@ +# Copyright (C) 2009 +# This file is distributed under the same license as the sysvinit package. +# +# Esko Arajärvi , 2009. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-29 13:56-0400\n" +"PO-Revision-Date: 2009-10-21 21:50+0300\n" +"Last-Translator: Esko Arajärvi \n" +"Language-Team: Finnish \n" +"Language: fi\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.0\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "Riippuvuusperusteiseen käynnistysjärjestelmään siirtyminen ei onnistu" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +#, fuzzy +#| msgid "" +#| "Tests have determined that problems in the boot system exist which " +#| "prevent migration to dependency-based boot sequencing:" +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Testien mukaan käynnistysjärjestelmässä on ongelmia, jotka estävät " +"riippuvuusperusteiseen käynnistysjärjestelmään siirtymisen." + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +#, fuzzy +#| msgid "" +#| "To reattempt the migration process after the problems have been fixed, " +#| "run \"dpkg-reconfigure sysv-rc\"." +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"Voit yrittää siirtymistä uudelleen vikojen korjauksen jälkeen ajamalla " +"komennon ”dpkg-reconfigure sysv-rc”." + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "" +#~ "Siirrytäänkö vanhasta käynnistysjärjestelmästä riippuvuusperusteiseen " +#~ "järjestelmään?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "Käynnistysjärjestelmässä voidaan siirtyä riippuvuusperusteiseen " +#~ "järjestelmään. Tätä muutosta ei voi perua, mutta sitä suositellaan. Se " +#~ "sallii käynnistysprosessin optimoinnin nopeuden ja tehokkuuden suhteen ja " +#~ "tarjoaa joustavamman kehyksen kehitystyölle." + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "Tarkempi kuvaus löytyy tiedostosta /usr/share/doc/sysv-rc/README.Debian. " +#~ "Jos päätät olla siirtymättä nyt, voit tehdä sen myöhemmin ajamalla " +#~ "komennon ”dpkg-reconfigure sysv-rc”." + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "Jos raportoitu ongelma on paikallinen muutos, se täytyy korjata käsin. " +#~ "Jos se on vika jossain paketissa, se tulisi raportoida " +#~ "virheidenhallintajärjestelmään ja korjata paketissa. Verkkosivulta http://" +#~ "wiki.debian.org/LSBInitScripts/DependencyBasedBoot löytyy lisätietoja " +#~ "siirtymisen estävien vikojen korjaamisesta." diff --git a/po/fr.po b/po/fr.po new file mode 100644 index 00000000..8658a152 --- /dev/null +++ b/po/fr.po @@ -0,0 +1,69 @@ +# Translation of sysvinit debconf template to French +# Copyright (C) 2012 Debian French l10n Team +# This file is distributed under the same license as the sysvinit package. +# Steve Petruzzello , 2009, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: sysvinit_2.88dsf-22.1\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-29 13:56-0400\n" +"PO-Revision-Date: 2012-06-14 14:14+0200\n" +"Last-Translator: Steve Petruzzello \n" +"Language-Team: French \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "" +"Impossible de migrer vers le nouveau système de démarrage basé sur les " +"dépendances" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"En raison de problèmes dans le système de démarrage, la migration vers la " +"nouvelle séquence de démarrage basée sur les dépendances n'est pas " +"possible." + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Si le problème indiqué est une modification locale, il est nécessaire de " +"le corriger vous-même. Ces problèmes sont typiquement dûs à des fichiers " +"de configuration obsolètes laissés après qu'un paquet ait été supprimé " +"ou purgé. Il est suggéré de les supprimer en exécutant :" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"L'installation du paquet ne peut pas continuer tant que les problèmes ci-" +"dessus n'ont pas été réparés. Pour retenter le processus de migration, " +"une fois que les problèmes ont été corrigés, vous pouvez exécuter la " +"commande « dpkg-reconfigure sysv-rc »." diff --git a/po/gl.po b/po/gl.po new file mode 100644 index 00000000..ba13b915 --- /dev/null +++ b/po/gl.po @@ -0,0 +1,105 @@ +# Copyright (C) 2009 This file is part of Debian +# This file is distributed under the same license as the sysvinit package. +# +# Marce Villarino , 2009. +# Jorge Barreiro , 2012. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-06-09 08:51+0200\n" +"PO-Revision-Date: 2012-06-23 12:18+0200\n" +"Last-Translator: Jorge Barreiro \n" +"Language-Team: Galician \n" +"Language: gl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.0\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "Non foi posíbel migrar para o sistema baseado en dependencias" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Hai problemas no sistema de arranque que fan que " +"non se poida migrar para a secuencia baseada en dependencias:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Se o problema mencionado é unha modificación local, debe ser arranxado " +"manualmente. Estes problemas débense normalmente a ficheiros de " +"configuración obsoletos deixados despois de que un paquete se eliminara, " +"pero non se purgara. Suxíreselle que se borren estes ficheiros executando:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"A instalación do paquete non pode continuar ata que os problemas " +"mencionados sexan arranxados. Para tentar de novo o proceso de migración " +"tras arranxar os problemas execute «dpkg --configure sysv-rc»." + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "" +#~ "Desexa migrar a secuencia de arranque herdada para unha baseada en " +#~ "dependencias?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "O sistema de arrinque está preparado para migrar para un baseado en " +#~ "dependencias. Este é un paso irreversíbel, pero recoméndase dalo, xa que " +#~ "permite optimizar o proceso de arrinque mellorando a eficiencia e a " +#~ "velocidade, e fornece un framework máis elástico para os desenvolventes." + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "Hai unha argumentación completa en /usr/share/doc/sysv-rc/README.Debian." +#~ "gz. Se escolle non migrar agora, poderá facelo máis tarde executando " +#~ "«dpkg-reconfigure sysv-rc»." + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "Se o problema que se detectou é unha modificación local deberá ser " +#~ "corrixido manualmente. De ser un erro no paquete debe informarse no BTS " +#~ "para corrixilo no paquete. Consulte http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot para obter máis información acerca de como corrixir " +#~ "os problemas que fan que non se poda migrar." diff --git a/po/it.po b/po/it.po new file mode 100644 index 00000000..d0921f46 --- /dev/null +++ b/po/it.po @@ -0,0 +1,108 @@ +# ITALIAN TRANSLATION OF SYSVINIT'S PO-DEBCONF FILE. +# COPYRIGHT (C) 2009 THE SYSVINIT'S COPYRIGHT HOLDER +# This file is distributed under the same license as the sysvinit package. +# +# Vincenzo Campanella , 2009. +msgid "" +msgstr "" +"Project-Id-Version: sysvinit 2.87dsf-5\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-29 13:56-0400\n" +"PO-Revision-Date: 2009-11-13 12:30+0100\n" +"Last-Translator: Vincenzo Campanella \n" +"Language-Team: Italian \n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "Impossibile migrare al sistema d'avvio basato sulle dipendenze" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +#, fuzzy +#| msgid "" +#| "Tests have determined that problems in the boot system exist which " +#| "prevent migration to dependency-based boot sequencing:" +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Le verifiche hanno trovato problemi esistenti nel sistema di avvio che " +"impediscono la migrazione alla sequenza di avvio basata sulle dipendenze:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +#, fuzzy +#| msgid "" +#| "To reattempt the migration process after the problems have been fixed, " +#| "run \"dpkg-reconfigure sysv-rc\"." +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"Per tentare nuovamente il processo di migrazione dopo che i problemi sono " +"stati risolti, eseguire «dpkg-reconfigure sysv-rc»." + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "" +#~ "Migrare la sequenza di avvio obsoleta alla sequenza basata sulle " +#~ "dipendenze?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "Il sistema di avvio è pronto a migrare alla sequenza basata sulle " +#~ "dipendenze. È un processo irreversibile, ma raccomandato, in quanto " +#~ "consente l'ottimizzaziione del processo di avvio in termini di velocità " +#~ "ed efficienza, e inoltre fornisce un'infrastruttura più elastica per lo " +#~ "sviluppo." + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "Le motivazioni complete sono esposte in «/usr/share/doc/sysvinit/README." +#~ "Debian.gz». Se si sceglie di non migrare adesso è possibile farlo in un " +#~ "secondo tempo, eseguendo «dpkg-reconfigure sysv-rc»." + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "Se il problema riportato è una modifica locale, esso deve essere risolto " +#~ "manualmente. Se si tratta di un bug del pacchetto, lo si dovrebbe " +#~ "riportare al BTS (Bug Tracking System) e dovrebbe essere risolto nel " +#~ "pacchetto. Per maggiori informazioni su come risolvere i problemi che " +#~ "impediscono la migrazione consultare http://wiki.debian.org/" +#~ "LSBInitScripts/DependencyBasedBoot." diff --git a/po/ja.po b/po/ja.po new file mode 100644 index 00000000..9f8ed117 --- /dev/null +++ b/po/ja.po @@ -0,0 +1,99 @@ +# Japanese translation of sysvinit debconf templates. +# Copyright (C) 2009 Hideki Yamane +# This file is distributed under the same license as the sysvinit package. +# +msgid "" +msgstr "" +"Project-Id-Version: sysvinit 2.88dsf-41\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-29 13:56-0400\n" +"PO-Revision-Date: 2013-02-08 23:44+0900\n" +"Last-Translator: Hideki Yamane (Debian-JP) \n" +"Language-Team: Debian JP Project \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "依存関係ベースのブートシステムへの移行ができません" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"起動システム中に問題があり、依存関係ベースのブートシーケンスへの移行作業を妨げ" +"ています:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"報告されている問題がローカルで変更したことによる場合は手作業で修正する必要があ" +"ります。こういった問題はパッケージを完全削除ではなく削除したことにより古い設定" +"ファイルが残っているときによく発生します。次のようにして古い設定ファイルを削除" +"することを提案します:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"上記の問題が修正されるまでパッケージのインストールを続けることはできません。" +"問題修正後に移行作業を再度試みるには「dpkg-reconfigure sysv-rc」を実行してく" +"ださい。" + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "" +#~ "レガシーな起動シーケンスから依存関係ベースのシーケンスへ移行しますか?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "起動システムは依存関係ベースのシーケンスへ移行する予定です。これは取り消し" +#~ "できない作業ですが、推奨される作業です: 起動プロセスのスピードと効率を最適" +#~ "化し、開発についてより柔軟なフレームワークを提供します:" + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "全ての関連情報は /usr/share/doc/sysv-rc/README.Debian に詳細にまとめられて" +#~ "います。今すぐ移行しないことを選んだ場合、後ほど「dpkg-reconfigure sysv-" +#~ "rc」を実行すれば移行可能です。" + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "報告された問題点がローカルで行った変更であれば、手動で修正する必要がありま" +#~ "す。それがパッケージのバグであれば BTS へ報告してパッケージを修正するべき" +#~ "です。移行を妨げる問題をどの様にして修正するか、詳細については http://" +#~ "wiki.debian.org/LSBInitScripts/DependencyBasedBoot を参照してください。" diff --git a/po/nb.po b/po/nb.po new file mode 100644 index 00000000..30b0d3a1 --- /dev/null +++ b/po/nb.po @@ -0,0 +1,112 @@ +# translation of nb.po to Norwegian Bokmål +# Copyright (C) 2009 +# This file is distributed under the same license as the sysvinit package. +# +# Petter Reinholdtsen , 2010, 2014. +msgid "" +msgstr "" +"Project-Id-Version: nb\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-29 13:56-0400\n" +"PO-Revision-Date: 2014-01-30 10:08+0100\n" +"Last-Translator: Petter Reinholdtsen \n" +"Language-Team: Norwegian Bokmål \n" +"Language: nb\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.4\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "Kan ikke gå over til avhengighetsbasert oppstartsystem" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +#| msgid "" +#| "Tests have determined that problems in the boot system exist which " +#| "prevent migration to dependency-based boot sequencing:" +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Det finnes problemer i oppstartsystemet som hindrer en overgang til " +"avhengighetsbasert oppstartrekkefølge:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Hvis det rapporterte problemet er en lokal endring, så trengs det " +"manuell reparasjon. Disse kommer typisk av utdaterte conffiler som er " +"etterlatt etter at en pakke har blitt fjernet men ikke renset ut. Det " +"foreslås at " +"disse blir fjernet ved å kjøre:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +#| msgid "" +#| "To reattempt the migration process after the problems have been fixed, " +#| "run \"dpkg-reconfigure sysv-rc\"." +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"Pakkeinstallasjon kan ikke fortsett før de overnevnte problemene har blitt " +"løst. For å gjøre et nytt forsøk med overgangsprosessen etter at disse " +"problemene er løst, kjør \"dpkg-reconfigure sysv-rc\"." + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "" +#~ "Gå over fra gammeldags oppstartrekkefølge til avhengighetsbasert " +#~ "rekkefølge?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "Oppstartsystemet er forberedt for overgang til avhengighetsbasert " +#~ "oppstartrekkefølge. Dette er et ugjenkallelig steg, men det er anbefalt: " +#~ "det tillater at oppstartprosessen optimeres for hastighet og " +#~ "effektivitet, og tilbyr et mer fleksibelt rammeverk for utvikling." + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "En fullstendig begrunnelse finnes i /usr/share/doc/sysv-rc/README.Debian. " +#~ "Hvis du velger å ikke migrere nå, så kan du gjøre det senere ved å kjøre " +#~ "\"dpkg-reconfigure sysv-rc\"." + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "Hvis det rapporterte problemet er en lokal endring så må det fikses " +#~ "manuelt. Hvis det er en feil i en pakke, så bør det rapporteres til " +#~ "feilhåndteringssystemet og rettes i pakken. Se http://wiki.debian.org/" +#~ "LSBInitScripts/DependencyBasedBoot for mer informasjon om hvordan fikse " +#~ "problemer som hindrer overgang." diff --git a/po/nl.po b/po/nl.po new file mode 100644 index 00000000..56544a76 --- /dev/null +++ b/po/nl.po @@ -0,0 +1,66 @@ +# Dutch translation of sysvinit debconf templates. +# Copyright (C) 2011, 2012 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the sysvinit package. +# Jeroen Schot , 2011, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: sysvinit 2.88dsf-27\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-06-09 08:51+0200\n" +"PO-Revision-Date: 2012-06-13 11:54+0200\n" +"Last-Translator: Jeroen Schot \n" +"Language-Team: Debian l10n Dutch \n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "Niet mogelijk om te migreren naar de nieuwe opstartvolgorde" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Er zijn problemen gevonden in het opstartsysteem die het migreren naar de " +"nieuwe opstartvolgorde verhinderen:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Als het gerapporteerde probleem een lokale wijziging is dient u dit " +"handmatig op te lossen. Deze worden meestal veroorzaakt door verouderde " +"conffiles die achter zijn gebleven nadat een pakket is verwijderd, maar niet " +"gewist ('purge'). U wordt aangeraden deze te verwijderen door het uitvoeren " +"van:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"De pakketinstallatie kan niet doorgaan totdat de bovenstaande problemen zijn " +"opgelost. Na het oplossen van de problemen kunt u het migratieproces " +"nogmaals proberen door \"dpkg-reconfigure sysv-rc\" uit te voeren." diff --git a/po/pl.po b/po/pl.po new file mode 100644 index 00000000..dfb1d982 --- /dev/null +++ b/po/pl.po @@ -0,0 +1,103 @@ +# Copyright (C) 2009 +# This file is distributed under the same license as the sysvinit package. +# +# Michał Kułach , 2012. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-29 13:56-0400\n" +"PO-Revision-Date: 2012-06-09 10:17+0200\n" +"Last-Translator: Michał Kułach \n" +"Language-Team: Polish \n" +"Language: pl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "Nie można zmienić systemu rozruchu na tryb oparty na zależnościach" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Problemy w istniejącym systemie rozruchu uniemożliwiły migrację do trybu " +"opartego na zależnościach:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Jeśli zgłoszony problem wynika z lokalnej modyfikacji, musi być naprawiony " +"ręcznie. Z reguły jest to skutek przestarzałych plików konfiguracyjnych, " +"które pozostały po pakiecie, który został usunięty, lecz nie wyczyszczony. " +"Zaleca się usunięcie ich, wykonując polecenie:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"Instalacja pakietu nie może być kontynuowana, dopóki powyższe problemy nie " +"zostaną naprawione. Aby spróbować przeprowadzić migrację ponownie, po " +"naprawieniu problemów, proszę wykonać polecenie \"dpkg --configure sysv-rc\"." + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "Zmienić tradycyjny tryb rozruchowy na tryb oparty na zależnościach?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "System rozruchowy jest przygotowany do migracji do trybu opartego na " +#~ "zależnościach. Jest to krok nieodwracalny, ale zalecany: pozwala na " +#~ "optymalizację procesu rozruchowego pod kątem szybkości i wydajności oraz " +#~ "zapewnia elastyczniejszą podstawę do rozwoju." + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "Pełne uzasadnienie można znaleźć w pliku /usr/share/doc/sysv-rc/README." +#~ "Debian. W przypadku niewybrania opcji migracji w tej chwili, można wrócić " +#~ "do niej później, przez wykonanie \"dpkg-reconfigure sysv-rc\"." + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "Jeśli wykazane problemy są lokalną modyfikacją, to muszą zostać " +#~ "naprawione ręcznie. Jeśli jest to błąd pakietu, powinno zostać wysłane " +#~ "zgłoszenie błędu. Proszę zapoznać się ze stroną http://wiki.debian.org/" +#~ "LSBInitScripts/DependencyBasedBoot, aby uzyskać więcej informacji na " +#~ "temat naprawiania problemów uniemożliwiających migrację." diff --git a/po/pt.po b/po/pt.po new file mode 100644 index 00000000..c0030153 --- /dev/null +++ b/po/pt.po @@ -0,0 +1,107 @@ +# Portuguese translation for the package sysvinit 2.87dsf +# Copyright (C) 2009 the sysvinit copyright holder +# This file is distributed under the same license as the sysvinit 2.87dsf package. +# António Moreira , 2009. +# Miguel Figueiredo , 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: sysvinit 2.87dsf\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-29 13:56-0400\n" +"PO-Revision-Date: 2012-06-09 15:26+0100\n" +"Last-Translator: Miguel Figueiredo \n" +"Language-Team: Portuguese \n" +"Language: pt\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Portuguese\n" +"X-Poedit-Country: PORTUGAL\n" +"X-Poedit-SourceCharset: utf-8\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "Incapaz de migrar para sistema de arranque baseado em dependências" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Problemas no sistema de arranque que impedem a migração para sequência de " +"arranque baseada em dependências de arranque:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Se o problema relatado for uma modificação local, tem de ser corrigido " +"manualmente. Tipicamente são devidos a ficheiros de configuração obsoletos " +"que ficaram quando um pacote foi removido mas não purgado. É sugerido que " +"estes sejam removidos ao correr:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"A instalação do pacote não pode continuar até os problemas acima terem sido " +"corrigidos. Para tentar novamente o processo de migração após a resolução " +"destes problemas, execute \"dpkg-reconfigure sysv-rc\"." + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "" +#~ "Migrar sequência de arranque legada para sequência baseada em " +#~ "dependências?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "O sistema de arranque está preparado para migrar para a sequência baseada " +#~ "em dependências. Este é um passo irreversível, mas um que é recomendado: " +#~ "permite que o processo de arranque seja optimizado para velocidade e " +#~ "eficiência, e fornece uma estrutura mais flexível para o desenvolvimento." + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "A lógica completa está detalhada em /usr/share/doc/sysv-rc/README.debian. " +#~ "Se optar por não migrar agora, você pode fazê-lo depois correndo \"dpkg-" +#~ "reconfigure sysv-rc\"." + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "Se o problema relatado é uma modificação local, tem de ser reparado " +#~ "manualmente. Se é um bug no pacote, deve ser comunicado ao BTS e reparado " +#~ "no pacote. Ver http://wiki.debian.org/LSBInitScripts/DependencyBasedBoot " +#~ "para mais informações de como corrigir os problemas que impedem a " +#~ "migração." diff --git a/po/pt_BR.po b/po/pt_BR.po new file mode 100644 index 00000000..8e7b71f9 --- /dev/null +++ b/po/pt_BR.po @@ -0,0 +1,106 @@ +# Debconf translations for sysvinit. +# Copyright (C) 2009 THE sysvinit'S COPYRIGHT HOLDER +# This file is distributed under the same license as the sysvinit package. +# Adriano Rafael Gomes , 2009, 2010, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: sysvinit 2.88dsf-32.1\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-29 13:56-0400\n" +"PO-Revision-Date: 2012-09-05 19:34-0300\n" +"Last-Translator: Adriano Rafael Gomes \n" +"Language-Team: Brazilian Portuguese \n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "" +"Incapaz de migrar para o sistema de inicialização baseado em dependência" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Existem problemas no sistema de inicialização que estão impedindo a migração " +"para a sequência de inicialização baseada em dependência:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Se o problema relatado é uma modificação local, ele deve ser corrigido " +"manualmente. Tipicamente, esses problemas são devidos a arquivos de " +"configuração obsoletos deixados depois de um pacote ter sido removido, mas " +"não expurgado. É sugerido que esses arquivos sejam removidos executando:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"A instalação do pacote não pode continuar até que os problemas acima tenham " +"sido corrigidos. Para tentar novamente o processo de migração depois desses " +"problemas terem sido corrigidos, execute \"dpkg --configure sysv-rc\"." + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "" +#~ "Migrar a sequência de inicialização legada para a sequência baseada em " +#~ "dependência?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "O sistema de inicialização está preparado para migrar para a sequência " +#~ "baseada em dependência. Este é um passo irreversível, mas recomendável: " +#~ "ele permite que o processo de inicialização seja otimizado para " +#~ "velocidade e eficiência, e fornece um framework mais flexível para o " +#~ "desenvolvimento." + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "Um embasamento completo está detalhado em /usr/share/doc/sysv-rc/README." +#~ "Debian. Se você escolher não migrar agora, você poderá fazê-lo mais tarde " +#~ "executando \"dpkg-reconfigure sysv-rc\"." + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "Se o problema reportado é uma modificação local, ele precisa ser " +#~ "corrigido manualmente. Se é um bug no pacote, ele deve ser reportado para " +#~ "o BTS e corrigido no pacote. Veja http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot para mais informações sobre como corrigir os " +#~ "problemas que impedem a migração." diff --git a/po/ru.po b/po/ru.po new file mode 100644 index 00000000..1c8b74cb --- /dev/null +++ b/po/ru.po @@ -0,0 +1,106 @@ +# translation of ru.po to Russian +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the sysvinit package. +# +# Yuri Kozlov , 2009, 2012. +msgid "" +msgstr "" +"Project-Id-Version: sysvinit 2.88dsf-27\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-29 13:56-0400\n" +"PO-Revision-Date: 2012-06-11 08:58+0400\n" +"Last-Translator: Yuri Kozlov \n" +"Language-Team: Russian \n" +"Language: ru\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.2\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "Невозможно перейти на систему загрузки на основе зависимостей" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"В системе загрузки имеются проблемы, которые не дают осуществить переход на " +"последовательность загрузки на основе зависимостей:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Если описанная проблема возникла из-за локальных изменений, то необходимо " +"ручное исправление. Обычно, это происходит из-за присутствия устаревших " +"conffiles от удалённого, но не вычищенного пакета. Предлагаем вам удалять их " +"с помощью команды:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"Установка пакета не будет продолжена, пока эти проблемы не будут решены. " +"Чтобы попытаться выполнить переход ещё раз после устранения проблем, " +"запустите «dpkg --configure sysv-rc»." + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "" +#~ "Перейти от старой последовательности загрузки к последовательности " +#~ "загрузки на основе зависимостей?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "Система загрузки готова к переходу на последовательность загрузки на " +#~ "основе зависимостей. Это необратимый шаг, но его рекомендуется выполнить: " +#~ "это позволит оптимизировать процесс загрузки по скорости и эффективности, " +#~ "и предоставляет более отказоустойчивую инфраструктуру для разработки." + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "Полное обоснование дано в /usr/share/doc/sysv-rc/README.Debian.gz. Если " +#~ "вы не хотите выполнять переход прямо сейчас, то можете сделать это позже " +#~ "с помощью команды \"dpkg-reconfigure sysv-rc\"." + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "Если указанные проблемы возникают из-за локальных изменений, то они " +#~ "должны быть устранены вручную. Если это ошибка в пакете, то об этом нужно " +#~ "сообщить в BTS, и это будет исправлено в пакете. Подробней о том, как " +#~ "исправлять проблемы, мешающие переходу, см. http://wiki.debian.org/" +#~ "LSBInitScripts/DependencyBasedBoot." diff --git a/po/sk.po b/po/sk.po new file mode 100644 index 00000000..041e8b1e --- /dev/null +++ b/po/sk.po @@ -0,0 +1,107 @@ +# Slovak translations for sysvinit package +# Slovenské preklady pre balík sysvinit. +# Copyright (C) 2011 THE sysvinit'S COPYRIGHT HOLDER +# This file is distributed under the same license as the sysvinit package. +# Automatically generated, 2011. +# Slavko , 2011, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: sysvinit 2.88dsf-13.1\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-29 13:56-0400\n" +"PO-Revision-Date: 2012-06-09 08:59+0200\n" +"Last-Translator: Slavko \n" +"Language-Team: slovenčina \n" +"Language: sk\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n" +"X-POFile-SpellExtra: purge dpkg-reconfigure sysv-rc SUGGESTION\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "Nemožno prejsť na zavádzanie založené na závislosti" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"V systéme zavádzania existujú problémy, ktoré bránia prechodu na systém " +"zavádzania založený na závislosti:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Ak je hlásený problém lokálnou úpravou, musí byť opravený manuálne. Tieto " +"prípady nastávajú najmä kvôli zastaraným konfiguračným súborom, ktoré ostali " +"po odinštalovaní balíka bez vyčistenia (purge). Odporúčame ich odstránenie " +"spustením:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"Inštalácia balíka nemôže pokračovať, kým tieto problémy nebudú odstránené. " +"Na opätovné spustenie prechodu, po odstránení problémov, spusťte „dpkg-" +"reconfigure sysv-rc”" + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "" +#~ "Prejsť zo starého systému zavádzania k zavádzaniu založenému na " +#~ "závislosti?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "Zavádzací systém je pripravený na prechod na zavádzanie založené na " +#~ "závislosti. Je to nevratný krok, ale je odporúčaný, pretože umožňuje " +#~ "optimalizáciu procesu zavedenia, čo sa týka rýchlosti i efektivity, as " +#~ "poskytuje oveľa pružnejšiu štruktúru vývoja." + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "Úplný popis dôvodov je k dispozícii v /usr/share/doc/sysv-rc/README." +#~ "Debian. Ak sa rozhodnete teraz neprechádzať, môžete to urobiť neskôr " +#~ "spustením „dpkg-reconfigure sysv-rc”." + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "Ak sú zistené problémy spôsobené lokálnymi úpravami, bude ich treba " +#~ "upraviť manuálne. Ak je to chyba balíka, mali by ste ju nahlásiť do BTS, " +#~ "aby ju mohol správca balíka opraviť. Ďalšie informácie o opravách chýb, " +#~ "ktoré bránia migrácii môžete nájsť na http://wiki.debian.org/" +#~ "LSBInitScripts/DependencyBasedBoot." diff --git a/po/sv.po b/po/sv.po new file mode 100644 index 00000000..68bbfb84 --- /dev/null +++ b/po/sv.po @@ -0,0 +1,108 @@ +# Translation of XX debconf template to Swedish +# Copyright (C) 2012 Martin Bagge +# This file is distributed under the same license as the XX package. +# +# Martin Ågren , 2009. +# Martin Bagge , 2012. +msgid "" +msgstr "" +"Project-Id-Version: sysvinit_sv\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-29 13:56-0400\n" +"PO-Revision-Date: 2012-06-09 13:14+0100\n" +"Last-Translator: Martin Bagge / brother \n" +"Language-Team: Swedish \n" +"Language: sv\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-Language: Swedish\n" +"X-Poedit-Country: Sweden\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "Kan inte gå över till beroendebaserat uppstartssystem" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Det finns problem i uppstartssystemet som hindrar en övergång till " +"beroendebaserat uppstartsordnande:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"Om det rapporterade problemet är en lokal förändring måste den justeras " +"manuellt. Vanligen beror detta på utdaterade inställningsfiler som lämnats " +"kvar efter att ett paket har tagits bort utan att rensa upp inställningar " +"efter sig. Rådet är att raderas dessa genom att exekvera:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"Paketinstallationen kan inte fortsätta innan ovanstående problem har " +"justerats. Om du vill göra ett nytt försök med övergången efter att " +"problemen har rättats, kör \"dpkg-reconfigure sysv-rc\"." + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "" +#~ "Gå över från gammaldags uppstartsordnande till beroendebaserat ordnande?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "Uppstartssystemet är förberett för övergång till beroendebaserat " +#~ "uppstartsordnande. Detta är ett oåterkalleligt steg, men det " +#~ "rekommenderas: det tillåter att uppstartsprocessen optimeras för " +#~ "hastighet och effektivitet och erbjuder ett mer flexibelt ramverk för " +#~ "utveckling." + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "En fullständig grund för beslut finns i /usr/share/doc/sysv-rc/README." +#~ "Debian. Om du väljer att inte gå över nu, kan du göra det senare genom " +#~ "att köra \"dpkg-reconfigure sysv-rc\"." + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "Om det rapporterade problemet är en lokal ändring, behöver det rättas " +#~ "manuellt. Om det är ett fel i paketet, bör det rapporteras till " +#~ "felhanteringssystemet och rättas i paketet. Se http://wiki.debian.org/" +#~ "LSBInitScripts/DependencyBasedBoot för mer information om att rätta " +#~ "problem som hindrar övergång." diff --git a/po/templates.pot b/po/templates.pot new file mode 100644 index 00000000..95de5441 --- /dev/null +++ b/po/templates.pot @@ -0,0 +1,57 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: sysvinit\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-29 13:56-0400\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" diff --git a/po/vi.po b/po/vi.po new file mode 100644 index 00000000..f7b05cb0 --- /dev/null +++ b/po/vi.po @@ -0,0 +1,108 @@ +# Vietnamese translation for SysVinit. +# Copyright © 2009 Free Software Foundation, Inc. +# Clytie Siddall , 2009. +# +msgid "" +msgstr "" +"Project-Id-Version: sysvinit 2.87dsf-5\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-09-29 13:56-0400\n" +"PO-Revision-Date: 2009-10-08 23:34+0930\n" +"Last-Translator: Clytie Siddall \n" +"Language-Team: Vietnamese \n" +"Language: vi\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: LocFactoryEditor 1.8\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "Không thể nâng cấp lên hệ thống khởi động dựa vào quan hệ phụ thuộc" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +#, fuzzy +#| msgid "" +#| "Tests have determined that problems in the boot system exist which " +#| "prevent migration to dependency-based boot sequencing:" +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "" +"Gặp vấn đề trong hệ thống khởi động mà ngăn cản nâng cấp lên thứ tự khởi " +"động dựa vào quan hệ phụ thuộc:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +#, fuzzy +#| msgid "" +#| "To reattempt the migration process after the problems have been fixed, " +#| "run \"dpkg-reconfigure sysv-rc\"." +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"Để thử lại tiến trình nâng cấp sau khi sửa chữa các vấn đề, hãy chạy « dpkg-" +"reconfigure sysv-rc »." + +#~ msgid "Migrate legacy boot sequencing to dependency-based sequencing?" +#~ msgstr "" +#~ "Nâng cấp thứ tự khởi động thừa tự lên thứ tự khởi động dựa vào quan hệ " +#~ "phụ thuộc ?" + +#~ msgid "" +#~ "The boot system is prepared to migrate to dependency-based sequencing. " +#~ "This is an irreversible step, but one that is recommended: it allows the " +#~ "boot process to be optimized for speed and efficiency, and provides a " +#~ "more resilient framework for development." +#~ msgstr "" +#~ "Hệ thống khởi động được chuẩn bị nâng cấp lên thứ tự khởi động dựa vào " +#~ "quan hệ phụ thuộc. Đây là một bước không thể hoàn lại mà vẫn còn khuyến " +#~ "khích vì nó cho phép tiến trình khởi động được tối ưu hoá theo tốc độ và " +#~ "hiệu suất, và cung cấp một khuôn khổ phát triển đàn hồi hơn." + +#~ msgid "" +#~ "A full rationale is detailed in /usr/share/doc/sysv-rc/README.Debian. If " +#~ "you choose not to migrate now, you can do so later by running \"dpkg-" +#~ "reconfigure sysv-rc\"." +#~ msgstr "" +#~ "Lý do hoàn toàn được diễn tả trong tài liệu Đọc Đi « /usr/share/doc/sysv-" +#~ "rc/README.Debian ». Không muốn nâng cấp ngay bây giờ thì bạn cũng có thể " +#~ "nâng cấp về sau bằng cách chạy câu lệnh cấu hình lại « dpkg-reconfigure " +#~ "sysv-rc »." + +#~ msgid "" +#~ "If the reported problem is a local modification, it needs to be fixed " +#~ "manually. If it's a bug in the package, it should be reported to the BTS " +#~ "and fixed in the package. See http://wiki.debian.org/LSBInitScripts/" +#~ "DependencyBasedBoot for more information about how to fix the problems " +#~ "preventing migration." +#~ msgstr "" +#~ "Nếu vấn đề đã thông báo là một sự sửa đổi chỉ cục bộ thì nó cần phải được " +#~ "sửa chữa bằng tay. Nếu nó là một lỗi trong gói phần mềm thì nó nên được " +#~ "thông báo cho hệ thống theo dõi lỗi (BTS) để sửa chữa trong gói đó. Xem " +#~ "trang wiki (http://wiki.debian.org/LSBInitScripts/DependencyBasedBoot) để " +#~ "tìm thêm thông tin về cách giải quyết vấn đề ngăn cản nâng cấp." diff --git a/po/zh_CN.po b/po/zh_CN.po new file mode 100644 index 00000000..19e4d9f7 --- /dev/null +++ b/po/zh_CN.po @@ -0,0 +1,63 @@ +# Chinese translations for sysvinit package +# sysvinit 软件包的简体中文翻译. +# Copyright (C) 2012 THE sysvinit'S COPYRIGHT HOLDER +# This file is distributed under the same license as the sysvinit package. +# 苏运强 , 2012. +# YunQiang Su , 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: sysvinit\n" +"Report-Msgid-Bugs-To: sysvinit@packages.debian.org\n" +"POT-Creation-Date: 2012-06-09 08:51+0200\n" +"PO-Revision-Date: 2012-06-09 15:52+0800\n" +"Last-Translator: YunQiang Su \n" +"Language-Team: Chinese (simplified) \n" +"Language: zh_CN\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bits\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "Unable to migrate to dependency-based boot system" +msgstr "无法迁移到基于依赖的引导系统" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Problems in the boot system exist which are preventing migration to " +"dependency-based boot sequencing:" +msgstr "引导系统中存在的阻止迁移到基于依赖的引导的问题有:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"If the reported problem is a local modification, it needs to be fixed " +"manually. These are typically due to obsolete conffiles being left after a " +"package has been removed, but not purged. It is suggested that these are " +"removed by running:" +msgstr "" +"如果报告的问题是本地修改引起的,需要手动修复。通常是因为包被移除而不是清除造" +"成的配置文件遗留。建议通过运行如下命令清除:" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "${SUGGESTION}" +msgstr "${SUGGESTION}" + +#. Type: note +#. Description +#: ../sysv-rc.templates:1001 +msgid "" +"Package installation can not continue until the above problems have been " +"fixed. To reattempt the migration process after these problems have been " +"fixed, run \"dpkg --configure sysv-rc\"." +msgstr "" +"包安装无法继续,除非修复上述问题。修复上述问题之后,通过运行 \"dpkg --" +"configure sysv-rc\" 重新尝试迁移。" diff --git a/rules b/rules new file mode 100755 index 00000000..6a9a9fb6 --- /dev/null +++ b/rules @@ -0,0 +1,133 @@ +#! /usr/bin/make -f + +tmp = $(CURDIR)/debian/tmp +sysvtmp = $(CURDIR)/debian/sysvinit-core +utiltmp = $(CURDIR)/debian/sysvinit-utils +rctmp = $(CURDIR)/debian/sysv-rc +inittmp = $(CURDIR)/debian/initscripts +bootlogdtmp = $(CURDIR)/debian/bootlogd +doc = /usr/share/doc + +LC_ALL = POSIX + +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_HOST_GNU_SYSTEM ?= $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM) +DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH) +DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS) +DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH) + +INSTALL_DATA = install -o root -g root -m 644 +INSTALL = install -o root -g root -m 755 + +# Handle cross builds +ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE)) +CROSS=CC=$(DEB_HOST_GNU_TYPE)-gcc +# CROSS is passed to make, CC is called directly. +CC=$(DEB_HOST_GNU_TYPE)-gcc +endif + +# Set arch specific build flags +ifeq ($(DEB_HOST_ARCH_OS),linux) +CONFFLAGS = WITH_SELINUX="yes" +endif + +DH_OPTIONS = + +# Use debhelper's dh +%: + dh $@ $(DH_OPTIONS) + +override_dh_auto_build: + $(MAKE) $(CROSS) $(CONFFLAGS) -C src DISTRO=Debian LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH) CFLAGS="$(CFLAGS) $(CPPFLAGS)" LDFLAGS="$(LDFLAGS)" + +override_dh_auto_install-arch: + $(MAKE) -C debian/src/bootlogd install DESTDIR=$(bootlogdtmp) + $(MAKE) -C debian/src/initscripts install DESTDIR=$(inittmp) + $(MAKE) -C src $(CROSS) ROOT=$(tmp) DISTRO=Debian install + +override_dh_auto_install-indep: + $(MAKE) -C debian/src/sysv-rc install DESTDIR=$(rctmp) + +override_dh_install-arch: + dh_install + + # sysvinit package + if test -e debian/share/inittab.$(DEB_HOST_GNU_TYPE) ; \ + then \ + $(INSTALL_DATA) \ + debian/share/inittab.$(DEB_HOST_GNU_TYPE) \ + $(sysvtmp)/usr/share/sysvinit/inittab ; \ + elif test -e debian/share/inittab.$(DEB_HOST_GNU_SYSTEM) ; \ + then \ + $(INSTALL_DATA) \ + debian/share/inittab.$(DEB_HOST_GNU_SYSTEM) \ + $(sysvtmp)/usr/share/sysvinit/inittab ; \ + else \ + $(INSTALL_DATA) debian/share/inittab \ + $(sysvtmp)/usr/share/sysvinit/inittab ; \ + fi + + # initscripts package may include /sys +ifneq (,$(findstring $(DEB_HOST_ARCH_OS),linux kfreebsd)) + $(INSTALL) -d $(inittmp)/sys +endif + +install-arch: build-arch + dh $@ $(DH_OPTIONS) + +override_dh_installchangelogs-arch: + dh_installchangelogs -psysvinit-core doc/Changelog + + dh_installchangelogs -psysvinit-utils doc/Changelog + sed -i -ne '/sysvinit (2.86.ds1-47)/q' -e p \ + $(utiltmp)$(doc)/sysvinit-utils/changelog.Debian + + dh_installchangelogs -pinitscripts + sed -i -ne '/sysvinit (2.86.ds1-47)/q' -e p \ + $(inittmp)$(doc)/initscripts/changelog.Debian + + dh_installchangelogs -pbootlogd + sed -i -ne '/sysvinit (2.86.ds1-47)/q' -e p \ + $(bootlogdtmp)$(doc)/bootlogd/changelog.Debian + +override_dh_installchangelogs-indep: + dh_installchangelogs + sed -i -ne '/sysvinit (2.86.ds1-47)/q' -e p \ + $(rctmp)$(doc)/sysv-rc/changelog.Debian + +override_dh_fixperms: + dh_fixperms -X/etc/init.d/skeleton -X/etc/init.d/README + +override_dh_installdeb-arch: + dh_installdeb + + # Override autogenerated conffiles + $(INSTALL_DATA) debian/initscripts.conffiles \ + $(inittmp)/DEBIAN/conffiles + sh debian/deps-mount >> debian/initscripts.substvars + +ifeq ($(DEB_HOST_ARCH_OS), hurd) + # The Hurd has its own halt and reboot commands. + mv $(sysvtmp)/usr/share/man/man8/halt.8.gz $(sysvtmp)/usr/share/man/man8/halt-sysv.8.gz + rm $(sysvtmp)/usr/share/man/man8/reboot.8.gz + ln -s halt-sysv.8.gz $(sysvtmp)/usr/share/man/man8/reboot-sysv.8.gz + mv $(sysvtmp)/sbin/halt $(sysvtmp)/sbin/halt-sysv + rm $(sysvtmp)/sbin/reboot + ln -s halt-sysv $(sysvtmp)/sbin/reboot-sysv + # Add runsystem to conffiles, suppress lintian error + echo /etc/hurd/runsystem.sysv >> $(inittmp)/DEBIAN/conffiles +else + rm -rf $(inittmp)/etc/hurd +endif + +override_dh_installdeb-indep: + dh_installdeb + + # Neither rc, rcS nor README are conffiles + $(RM) $(rctmp)/DEBIAN/conffiles + +override_dh_clean: + dh_clean + $(MAKE) -C src clobber + +.PHONY: override_dh_auto_build override_dh_auto_install-arch override_dh_auto_install-indep override_dh_installchangelogs-arch override_dh_installchangelogs-indep override_dh_fixperms override_dh_installdeb-arch override_dh_installdeb-indep override_dh_clean install-arch diff --git a/share/inittab b/share/inittab new file mode 100644 index 00000000..04eabd60 --- /dev/null +++ b/share/inittab @@ -0,0 +1,69 @@ +# /etc/inittab: init(8) configuration. +# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $ + +# The default runlevel. +id:2:initdefault: + +# Boot-time system configuration/initialization script. +# This is run first except when booting in emergency (-b) mode. +si::sysinit:/etc/init.d/rcS + +# What to do in single-user mode. +~~:S:wait:/sbin/sulogin + +# /etc/init.d executes the S and K scripts upon change +# of runlevel. +# +# Runlevel 0 is halt. +# Runlevel 1 is single-user. +# Runlevels 2-5 are multi-user. +# Runlevel 6 is reboot. + +l0:0:wait:/etc/init.d/rc 0 +l1:1:wait:/etc/init.d/rc 1 +l2:2:wait:/etc/init.d/rc 2 +l3:3:wait:/etc/init.d/rc 3 +l4:4:wait:/etc/init.d/rc 4 +l5:5:wait:/etc/init.d/rc 5 +l6:6:wait:/etc/init.d/rc 6 +# Normally not reached, but fallthrough in case of emergency. +z6:6:respawn:/sbin/sulogin + +# What to do when CTRL-ALT-DEL is pressed. +ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now + +# Action on special keypress (ALT-UpArrow). +#kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work." + +# What to do when the power fails/returns. +pf::powerwait:/etc/init.d/powerfail start +pn::powerfailnow:/etc/init.d/powerfail now +po::powerokwait:/etc/init.d/powerfail stop + +# /sbin/getty invocations for the runlevels. +# +# The "id" field MUST be the same as the last +# characters of the device (after "tty"). +# +# Format: +# ::: +# +# Note that on most Debian systems tty7 is used by the X Window System, +# so if you want to add more getty's go ahead but skip tty7 if you run X. +# +1:2345:respawn:/sbin/getty 38400 tty1 +2:23:respawn:/sbin/getty 38400 tty2 +3:23:respawn:/sbin/getty 38400 tty3 +4:23:respawn:/sbin/getty 38400 tty4 +5:23:respawn:/sbin/getty 38400 tty5 +6:23:respawn:/sbin/getty 38400 tty6 + +# Example how to put a getty on a serial line (for a terminal) +# +#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100 +#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100 + +# Example how to put a getty on a modem line. +# +#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3 + diff --git a/share/inittab.gnu b/share/inittab.gnu new file mode 100644 index 00000000..6433992f --- /dev/null +++ b/share/inittab.gnu @@ -0,0 +1,70 @@ +# /etc/inittab: init(8) configuration. +# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $ + +# The default runlevel. +id:2:initdefault: + +# Boot-time system configuration/initialization script. +# This is run first except when booting in emergency (-b) mode. +si::sysinit:/etc/init.d/rcS + +# What to do in single-user mode. +~~:S:wait:/sbin/sulogin + +# /etc/init.d executes the S and K scripts upon change +# of runlevel. +# +# Runlevel 0 is halt. +# Runlevel 1 is single-user. +# Runlevels 2-5 are multi-user. +# Runlevel 6 is reboot. + +l0:0:wait:/etc/init.d/rc 0 +l1:1:wait:/etc/init.d/rc 1 +l2:2:wait:/etc/init.d/rc 2 +l3:3:wait:/etc/init.d/rc 3 +l4:4:wait:/etc/init.d/rc 4 +l5:5:wait:/etc/init.d/rc 5 +l6:6:wait:/etc/init.d/rc 6 +# Normally not reached, but fallthrough in case of emergency. +z6:6:respawn:/sbin/sulogin + +# What to do when CTRL-ALT-DEL is pressed. +ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now + +# Action on special keypress (ALT-UpArrow). +#kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work." + +# What to do when the power fails/returns. +pf::powerwait:/etc/init.d/powerfail start +pn::powerfailnow:/etc/init.d/powerfail now +po::powerokwait:/etc/init.d/powerfail stop + +# /sbin/getty invocations for the runlevels. +# +# The "id" field MUST be the same as the last +# characters of the device (after "tty"). +# +# Format: +# ::: +# +# Note that on most Debian systems tty7 is used by the X Window System, +# so if you want to add more getty's go ahead but skip tty7 if you run X. +# +1:2345:respawn:/sbin/getty 38400 tty1 +2:23:respawn:/sbin/getty 38400 tty2 +3:23:respawn:/sbin/getty 38400 tty3 +4:23:respawn:/sbin/getty 38400 tty4 +5:23:respawn:/sbin/getty 38400 tty5 +6:23:respawn:/sbin/getty 38400 tty6 +c:23:respawn:/sbin/getty 38400 console + +# Example how to put a getty on a serial line (for a terminal) +# +#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100 +#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100 + +# Example how to put a getty on a modem line. +# +#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3 + diff --git a/share/inittab.kfreebsd-gnu b/share/inittab.kfreebsd-gnu new file mode 100644 index 00000000..ed7b5a18 --- /dev/null +++ b/share/inittab.kfreebsd-gnu @@ -0,0 +1,69 @@ +# /etc/inittab: init(8) configuration. +# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $ + +# The default runlevel. +id:2:initdefault: + +# Boot-time system configuration/initialization script. +# This is run first except when booting in emergency (-b) mode. +si::sysinit:/etc/init.d/rcS + +# What to do in single-user mode. +~~:S:wait:/sbin/sulogin + +# /etc/init.d executes the S and K scripts upon change +# of runlevel. +# +# Runlevel 0 is halt. +# Runlevel 1 is single-user. +# Runlevels 2-5 are multi-user. +# Runlevel 6 is reboot. + +l0:0:wait:/etc/init.d/rc 0 +l1:1:wait:/etc/init.d/rc 1 +l2:2:wait:/etc/init.d/rc 2 +l3:3:wait:/etc/init.d/rc 3 +l4:4:wait:/etc/init.d/rc 4 +l5:5:wait:/etc/init.d/rc 5 +l6:6:wait:/etc/init.d/rc 6 +# Normally not reached, but fallthrough in case of emergency. +z6:6:respawn:/sbin/sulogin + +# What to do when CTRL-ALT-DEL is pressed. +ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now + +# Action on special keypress (ALT-UpArrow). +#kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work." + +# What to do when the power fails/returns. +pf::powerwait:/etc/init.d/powerfail start +pn::powerfailnow:/etc/init.d/powerfail now +po::powerokwait:/etc/init.d/powerfail stop + +# /sbin/getty invocations for the runlevels. +# +# The "id" field MUST be the same as the last +# characters of the device (after "tty"). +# +# Format: +# ::: +# +# Note that on most Debian systems ttyv6 is used by the X Window System, +# so if you want to add more getty's go ahead but skip ttyv6 if you run X. +# +1:2345:respawn:/sbin/getty 38400 ttyv0 xterm +2:23:respawn:/sbin/getty 38400 ttyv1 xterm +3:23:respawn:/sbin/getty 38400 ttyv2 xterm +4:23:respawn:/sbin/getty 38400 ttyv3 xterm +5:23:respawn:/sbin/getty 38400 ttyv4 xterm +6:23:respawn:/sbin/getty 38400 ttyv5 xterm + +# Example how to put a getty on a serial line (for a terminal) +# +#T0:23:respawn:/sbin/getty -L cuau0 9600 vt100 +#T1:23:respawn:/sbin/getty -L cuau1 9600 vt100 + +# Example how to put a getty on a modem line. +# +#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyd3 + diff --git a/share/inittab.knetbsd-gnu b/share/inittab.knetbsd-gnu new file mode 100644 index 00000000..609a72cf --- /dev/null +++ b/share/inittab.knetbsd-gnu @@ -0,0 +1,67 @@ +# /etc/inittab: init(8) configuration. +# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $ + +# The default runlevel. +id:2:initdefault: + +# Boot-time system configuration/initialization script. +# This is run first except when booting in emergency (-b) mode. +si::sysinit:/etc/init.d/rcS + +# What to do in single-user mode. +~~:S:wait:/sbin/sulogin + +# /etc/init.d executes the S and K scripts upon change +# of runlevel. +# +# Runlevel 0 is halt. +# Runlevel 1 is single-user. +# Runlevels 2-5 are multi-user. +# Runlevel 6 is reboot. + +l0:0:wait:/etc/init.d/rc 0 +l1:1:wait:/etc/init.d/rc 1 +l2:2:wait:/etc/init.d/rc 2 +l3:3:wait:/etc/init.d/rc 3 +l4:4:wait:/etc/init.d/rc 4 +l5:5:wait:/etc/init.d/rc 5 +l6:6:wait:/etc/init.d/rc 6 +# Normally not reached, but fallthrough in case of emergency. +z6:6:respawn:/sbin/sulogin + +# What to do when CTRL-ALT-DEL is pressed. +ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now + +# Action on special keypress (ALT-UpArrow). +#kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work." + +# What to do when the power fails/returns. +pf::powerwait:/etc/init.d/powerfail start +pn::powerfailnow:/etc/init.d/powerfail now +po::powerokwait:/etc/init.d/powerfail stop + +# /sbin/getty invocations for the runlevels. +# +# The "id" field MUST be the same as the last +# characters of the device (after "tty"). +# +# Format: +# ::: +# +# Note that on most Debian systems tty7 is used by the X Window System, +# so if you want to add more getty's go ahead but skip tty7 if you run X. +# +1:2345:respawn:/sbin/getty 38400 ttyE0 +2:23:respawn:/sbin/getty 38400 ttyE1 +3:23:respawn:/sbin/getty 38400 ttyE2 +4:23:respawn:/sbin/getty 38400 ttyE3 + +# Example how to put a getty on a serial line (for a terminal) +# +#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100 +#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100 + +# Example how to put a getty on a modem line. +# +#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3 + diff --git a/share/inittab.s390-linux-gnu b/share/inittab.s390-linux-gnu new file mode 100644 index 00000000..fb571e16 --- /dev/null +++ b/share/inittab.s390-linux-gnu @@ -0,0 +1,63 @@ +# /etc/inittab: init(8) configuration. +# $Id: inittab.s390,v 1.9 2000/01/10 10:15:30 miquels Exp $ + +# The default runlevel. +id:2:initdefault: + +# Boot-time system configuration/initialization script. +# This is run first except when booting in emergency (-b) mode. +si::sysinit:/etc/init.d/rcS + +# What to do in single-user mode. +~~:S:wait:/sbin/sulogin + +# /etc/init.d executes the S and K scripts upon change +# of runlevel. +# +# Runlevel 0 is halt. +# Runlevel 1 is single-user. +# Runlevels 2-5 are multi-user. +# Runlevel 6 is reboot. + +l0:0:wait:/etc/init.d/rc 0 +l1:1:wait:/etc/init.d/rc 1 +l2:2:wait:/etc/init.d/rc 2 +l3:3:wait:/etc/init.d/rc 3 +l4:4:wait:/etc/init.d/rc 4 +l5:5:wait:/etc/init.d/rc 5 +l6:6:wait:/etc/init.d/rc 6 +# Normally not reached, but fallthrough in case of emergency. +z6:6:respawn:/sbin/sulogin + +# What to do when CTRL-ALT-DEL is pressed. +ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now + +# Action on special keypress (ALT-UpArrow). +kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work." + +# What to do when the power fails/returns. +pf::powerwait:/etc/init.d/powerfail start +pn::powerfailnow:/etc/init.d/powerfail now +po::powerokwait:/etc/init.d/powerfail stop + +# /sbin/getty invocations for the runlevels. +# +# The "id" field MUST be the same as the last +# characters of the device (after "tty"). +# +# Format: +# ::: +# +# The s390 only has a dumb terminal on /dev/console. +# +1:2345:respawn:/sbin/getty 38400 console dumb + +# Example how to put a getty on a serial line (for a terminal) +# +#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100 +#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100 + +# Example how to put a getty on a modem line. +# +#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3 + diff --git a/share/inittab.s390x-linux-gnu b/share/inittab.s390x-linux-gnu new file mode 100644 index 00000000..554a72c9 --- /dev/null +++ b/share/inittab.s390x-linux-gnu @@ -0,0 +1,63 @@ +# /etc/inittab: init(8) configuration. +# $Id: inittab.s390x,v 1.9 2000/01/10 10:15:30 miquels Exp $ + +# The default runlevel. +id:2:initdefault: + +# Boot-time system configuration/initialization script. +# This is run first except when booting in emergency (-b) mode. +si::sysinit:/etc/init.d/rcS + +# What to do in single-user mode. +~~:S:wait:/sbin/sulogin + +# /etc/init.d executes the S and K scripts upon change +# of runlevel. +# +# Runlevel 0 is halt. +# Runlevel 1 is single-user. +# Runlevels 2-5 are multi-user. +# Runlevel 6 is reboot. + +l0:0:wait:/etc/init.d/rc 0 +l1:1:wait:/etc/init.d/rc 1 +l2:2:wait:/etc/init.d/rc 2 +l3:3:wait:/etc/init.d/rc 3 +l4:4:wait:/etc/init.d/rc 4 +l5:5:wait:/etc/init.d/rc 5 +l6:6:wait:/etc/init.d/rc 6 +# Normally not reached, but fallthrough in case of emergency. +z6:6:respawn:/sbin/sulogin + +# What to do when CTRL-ALT-DEL is pressed. +ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now + +# Action on special keypress (ALT-UpArrow). +kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work." + +# What to do when the power fails/returns. +pf::powerwait:/etc/init.d/powerfail start +pn::powerfailnow:/etc/init.d/powerfail now +po::powerokwait:/etc/init.d/powerfail stop + +# /sbin/getty invocations for the runlevels. +# +# The "id" field MUST be the same as the last +# characters of the device (after "tty"). +# +# Format: +# ::: +# +# The s390x only has a dumb terminal on /dev/console. +# +1:2345:respawn:/sbin/getty 38400 console dumb + +# Example how to put a getty on a serial line (for a terminal) +# +#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100 +#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100 + +# Example how to put a getty on a modem line. +# +#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3 + diff --git a/share/update-rc.d b/share/update-rc.d new file mode 100755 index 00000000..daaa54cd --- /dev/null +++ b/share/update-rc.d @@ -0,0 +1,27 @@ +#! /bin/sh +# +# update-rc.d +# +# Dummy update-rc.d, installed when file-rc replaces +# sysv-rc or the other way around. The postrm of the +# package being replaced symlinks /usr/sbin/update-rc.d +# to this dummy file. +# +# All this script does is "scream and die". +# + +name=`basename $0` + +cat <&2 + +$name: not present yet. + +You are replacing sysv-rc with file-rc or another -rc package, or +the other way around. The replacement package must first be +unpacked before you can configure other packages. + +Exiting with error status 1. + +EOF + +exit 1 diff --git a/source/format b/source/format new file mode 100644 index 00000000..163aaf8d --- /dev/null +++ b/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/source/lintian-overrides b/source/lintian-overrides new file mode 100644 index 00000000..af2d30fe --- /dev/null +++ b/source/lintian-overrides @@ -0,0 +1 @@ +sysvinit source: debian-watch-file-should-mangle-version diff --git a/src/bootlogd/Makefile b/src/bootlogd/Makefile new file mode 100644 index 00000000..97415182 --- /dev/null +++ b/src/bootlogd/Makefile @@ -0,0 +1,15 @@ +DESTDIR = +sysconfdir = /etc + +INSTALL = install -m755 -o root -g root + +all: + +install: + $(INSTALL) -d $(DESTDIR)$(sysconfdir)/. + cp -afv etc/* $(DESTDIR)$(sysconfdir) + find $(DESTDIR)$(sysconfdir) -type d -name .svn -print0 |xargs -r0 rm -r + + chmod 755 $(DESTDIR)$(sysconfdir)/init.d/[a-z]* + chmod -R g-w $(DESTDIR) + chown -R root:root $(DESTDIR) diff --git a/src/bootlogd/etc/init.d/bootlogd b/src/bootlogd/etc/init.d/bootlogd new file mode 100644 index 00000000..3615eb23 --- /dev/null +++ b/src/bootlogd/etc/init.d/bootlogd @@ -0,0 +1,101 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: bootlogd +# Required-Start: mountdevsubfs +# X-Start-Before: hostname keymap keyboard-setup procps pcmcia hwclock hwclockfirst hdparm hibernate-cleanup lvm2 +# Required-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Start or stop bootlogd. +# Description: Starts or stops the bootlogd log program +# which logs boot messages. +### END INIT INFO + +PATH=/sbin:/bin # No remote fs at start +DAEMON=/sbin/bootlogd +TMPLOG=/run/bootlog +[ -x "$DAEMON" ] || exit 0 +NAME=bootlogd +DESC="boot logger" +BOOTLOGD_OPTS="-c -l $TMPLOG" +. /lib/init/vars.sh + +. /lib/lsb/init-functions + +# Previously this script was symlinked as "stop-bootlogd" which, when run +# with the "start" argument, should stop bootlogd. Now stop-bootlogd is +# a distinct script, but for backward compatibility this script continues +# to implement the old behavior. +SCRIPTNAME=${0##*/} +SCRIPTNAME=${SCRIPTNAME#[SK]??} +ACTION="$1" +case "$0" in + *stop-bootlog*) + [ "$ACTION" = start ] && ACTION=stop + ;; +esac + +if [ -d /run/system/system ]; then + if [ "$ACTION" = start ] && [ -f /var/log/boot ]; then + echo "(Booted up using systemd which doesn't write logs to system console. Please check 'journalctl -b' instead.)" > /var/log/boot + fi + log_daemon_msg "Skipping $NAME while running systemd" + exit 0 +fi + +case "$ACTION" in + start) + # PATH is set above + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + if [ -d /proc/1/. ] + then + umask 027 + start-stop-daemon --start --quiet --exec $DAEMON -- \ + $BOOTLOGD_OPTS + ES=$? + else + $DAEMON $BOOTLOGD_OPTS + ES=$? + fi + [ "$VERBOSE" != no ] && log_end_msg $ES + ;; + stop) + PATH=/bin:/sbin:/usr/bin:/usr/sbin + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + start-stop-daemon --oknodo --stop --quiet --exec $DAEMON + ES=$? + sleep 1 + [ "$VERBOSE" != no ] && log_end_msg $ES + if [ -r "$TMPLOG" ] + then + cat "$TMPLOG" >> /var/log/boot + rm -f "$TMPLOG" + fi + if [ -f /var/log/boot ] && [ -f /var/log/boot~ ] + then + [ "$VERBOSE" = no ] || log_action_begin_msg "Moving boot log file" + # bootlogd writes to boot, making backup at boot~ + cd /var/log && { + chgrp adm boot || : + savelog -q -p -c 5 boot \ + && mv boot.0 boot \ + && mv boot~ boot.0 + } + ES=$? + [ "$VERBOSE" = no ] || log_action_end_msg $ES + fi + ;; + restart|force-reload) + /etc/init.d/bootlogd stop + /etc/init.d/bootlogd start + ;; + status) + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2 + exit 3 + ;; +esac + +: diff --git a/src/bootlogd/etc/init.d/stop-bootlogd b/src/bootlogd/etc/init.d/stop-bootlogd new file mode 100644 index 00000000..7c173283 --- /dev/null +++ b/src/bootlogd/etc/init.d/stop-bootlogd @@ -0,0 +1,34 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: stop-bootlogd +# Required-Start: $local_fs $all +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: +# Short-Description: Stop bootlogd +# Description: See the init.d/bootlogd script +### END INIT INFO + +NAME=stop-bootlogd +DAEMON=/sbin/bootlogd + +[ -x "$DAEMON" ] || exit 0 +[ -d /run/systemd/system ] && exit 0 + +case "$1" in + start) + /etc/init.d/bootlogd stop + ;; + stop|restart|force-reload) + # No-op + ;; + status) + exec /etc/init.d/bootlogd status + ;; + *) + echo "Usage: $NAME {start|stop|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/src/bootlogd/etc/init.d/stop-bootlogd-single b/src/bootlogd/etc/init.d/stop-bootlogd-single new file mode 100644 index 00000000..a9261583 --- /dev/null +++ b/src/bootlogd/etc/init.d/stop-bootlogd-single @@ -0,0 +1,52 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: stop-bootlogd-single +# Required-Start: $local_fs $all +# Required-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Stop bootlogd in single user mode +# Description: See the init.d/bootlogd script +### END INIT INFO +# +# This has to run in the boot sequence (rcS.d), and not in the "single +# user" sequence (rc1.d), because rc1.d/ is not used when booting into +# single user. "grep :[S1]: /etc/inittab" show that single user is just +# a call to /sbin/sulogin, while runlevel 1 is a call to +# "/etc/init.d/rc 1" which in the end switches to runlevel S to run +# /sbin/sulogin. + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +NAME=stop-bootlogd-single +DAEMON=/sbin/bootlogd + +[ -x "$DAEMON" ] || exit 0 +[ -d /run/systemd/system ] && exit 0 + +case "$1" in + start) + single=false + for word in $(cat /proc/cmdline); do + case "$word" in + S|single|1) + single=true + ;; + esac + done + if [ true = "$single" ] ; then + /etc/init.d/bootlogd stop + fi + ;; + stop|restart|force-reload) + # No-op + ;; + status) + exec /etc/init.d/bootlogd status + ;; + *) + echo "Usage: $NAME {start|stop|restart|force-reload}" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/Makefile b/src/initscripts/Makefile new file mode 100644 index 00000000..7654e63a --- /dev/null +++ b/src/initscripts/Makefile @@ -0,0 +1,43 @@ +DESTDIR = +sysconfdir = /etc +prefix = /usr +docdir = $(prefix)/share/doc/initscripts +sbindir = /sbin + +INSTALL = install -m755 -o root -g root +INSTALL_DATA = install -m644 -o root -g root + +all: + +install: + $(INSTALL) -d $(DESTDIR)/lib/init/. + $(INSTALL) -d $(DESTDIR)/run/. + $(INSTALL) -d $(DESTDIR)/var/lib/initscripts/. + $(INSTALL) -d $(DESTDIR)/var/lib/urandom/. + $(INSTALL) -d $(DESTDIR)/var/log/fsck/. + $(INSTALL) -d $(DESTDIR)$(docdir)/. + $(INSTALL_DATA) doc/* $(DESTDIR)$(docdir) + + $(INSTALL) -d $(DESTDIR)$(sysconfdir)/. + $(INSTALL) -d $(DESTDIR)$(sysconfdir)/default + cp -afv etc/* $(DESTDIR)$(sysconfdir) + find $(DESTDIR)$(sysconfdir) -type d -name .svn -print0 |xargs -r0 rm -r + + cp -afv lib/init/* $(DESTDIR)/lib/init + find $(DESTDIR)/lib -type d -name .svn -print0 |xargs -r0 rm -r + chmod 755 $(DESTDIR)$(sysconfdir)/init.d/[a-z]* + chmod 755 $(DESTDIR)$(sysconfdir)/network/if-up.d/[a-z]* + chmod 644 $(DESTDIR)/lib/init/*.sh + chmod 644 $(DESTDIR)$(sysconfdir)/init.d/skeleton + chmod -R g-w $(DESTDIR) + chown -R root:root $(DESTDIR) + + $(INSTALL) -d $(DESTDIR)$(sbindir)/. + $(INSTALL) sbin/fsck.nfs $(DESTDIR)$(sbindir)/fsck.nfs + + $(INSTALL) -d $(DESTDIR)/usr/share/man/man8 + $(INSTALL_DATA) man/fsck.nfs.8 \ + $(DESTDIR)/usr/share/man/man8/fsck.nfs.8 + + $(INSTALL) -d $(DESTDIR)/usr/share/man/man5 + $(INSTALL_DATA) man/*.5 $(DESTDIR)/usr/share/man/man5/. diff --git a/src/initscripts/doc/README.Debian b/src/initscripts/doc/README.Debian new file mode 100644 index 00000000..ef14e634 --- /dev/null +++ b/src/initscripts/doc/README.Debian @@ -0,0 +1,52 @@ +tmpfs +----- + +Tmpfs can be used as virtual memory filesystem. glibc 2.2 and above +expects a tmpfs to be mounted at /run/shm (/dev/shm) for POSIX shared +memory; this is done automatically by /etc/init.d/mountdevsubfs.sh +early in the boot process. A tmpfs will also be mounted on /run as a +writable location available from early boot. Optionally, tmpfs +filesystems may be mounted on /run/lock and /tmp. The tmpfs +filesystems to be mounted are configured in /etc/default/rcS. Please +see rcS(5) for details. + +Size limits may be set of any of the ram file systems (tmpfs) mounted +on /run, /run/lock, /run/shm or /tmp. Please see rcS(5) for details. +Note that /tmp may be a symlink to e.g. /run/tmp, making it possible +to use a single tmpfs for all writable filesystems other than /var; +the directory pointed to by the symlink will be created if it does not +already exist. + + +sendsigs process omission interface +----------------------------------- + +Since initscripts package version 2.86.ds1-48, /etc/init.d/sendsigs is +able to omit processes from being killed by killall5(8). Process id's +listed in /run/sendsigs.omit, or any file in the /run/sendsigs.omit.d/ +directory will be omitted by sendsigs. + +The recommended practice for adding a process id for omission is to +create a file in /run/sendsigs.omit.d/ containing the +process id that is to be omitted by sendsigs. + +This feature is only to be used for processes that need to be running +when remote file systems are umounted, and that have current working +directory set to a directory in the root file system. + + +/sys in /etc/fstab +------------------ + +If the mount point /sys/ has an entry in /etc/fstab (which is not +required, it will be mounted in any case), the entry must be: + + sysfs /sys sysfs rw,nosuid,nodev,noexec 0 0 + +The reason is that the entry in fstab needs to match the entry +generated by the mountkernfs.sh script. If it does not, the system +will complain with this message during boot: + + Will now mount local filesystems:mount: /sys already mounted or /sys busy + mount: according to mtab, sysfs is already mounted on /sys + failed diff --git a/src/initscripts/etc/default/devpts b/src/initscripts/etc/default/devpts new file mode 100644 index 00000000..e10e3716 --- /dev/null +++ b/src/initscripts/etc/default/devpts @@ -0,0 +1,5 @@ +# GID of the `tty' group +TTYGRP=5 + +# Set to 600 to have `mesg n' be the default +TTYMODE=620 diff --git a/src/initscripts/etc/default/halt b/src/initscripts/etc/default/halt new file mode 100644 index 00000000..21bc1198 --- /dev/null +++ b/src/initscripts/etc/default/halt @@ -0,0 +1,2 @@ +# Default behaviour of shutdown -h / halt. Set to "halt" or "poweroff". +HALT=poweroff diff --git a/src/initscripts/etc/default/rcS b/src/initscripts/etc/default/rcS new file mode 100644 index 00000000..b60cf6b6 --- /dev/null +++ b/src/initscripts/etc/default/rcS @@ -0,0 +1,27 @@ +################################################################## +# NOTE: This file is ignored when systemd is used as init system # +################################################################## +# +# /etc/default/rcS +# +# Default settings for the scripts in /etc/rcS.d/ +# +# For information about these variables see the rcS(5) manual page. +# +# This file belongs to the "initscripts" package. + +# delete files in /tmp during boot older than x days. +# '0' means always, -1 or 'infinite' disables the feature +#TMPTIME=0 + +# spawn sulogin during boot, continue normal boot if not used in 30 seconds +#SULOGIN=no + +# do not allow users to log in until the boot has completed +#DELAYLOGIN=no + +# be more verbose during the boot process +#VERBOSE=no + +# automatically repair filesystems with inconsistencies during boot +#FSCKFIX=no diff --git a/src/initscripts/etc/default/tmpfs b/src/initscripts/etc/default/tmpfs new file mode 100644 index 00000000..80e60a6d --- /dev/null +++ b/src/initscripts/etc/default/tmpfs @@ -0,0 +1,37 @@ +################################################################## +# NOTE: This file is ignored when systemd is used as init system # +################################################################## +# +# Configuration for tmpfs filesystems mounted in early boot, before +# filesystems from /etc/fstab are mounted. For information about +# these variables see the tmpfs(5) manual page. + +# /run is always mounted as a tmpfs on systems which support tmpfs +# mounts. + +# mount /run/lock as a tmpfs (separately from /run). Defaults to yes; +# set to no to disable (/run/lock will then be part of the /run tmpfs, +# if available). +#RAMLOCK=yes + +# mount /run/shm as a tmpfs (separately from /run). Defaults to yes; +# set to no to disable (/run/shm will then be part of the /run tmpfs, +# if available). +#RAMSHM=yes + +# mount /tmp as a tmpfs. Defaults to no; set to yes to enable (/tmp +# will be part of the root filesystem if disabled). /tmp may also be +# configured to be a separate mount in /etc/fstab. +#RAMTMP=no + +# Size limits. Please see tmpfs(5) for details on how to configure +# tmpfs size limits. +#TMPFS_SIZE=20%VM +#RUN_SIZE=10% +#LOCK_SIZE=5242880 # 5MiB +#SHM_SIZE= +#TMP_SIZE= + +# Mount tmpfs on /tmp if there is less than the limit size (in kiB) on +# the root filesystem (overriding RAMTMP). +#TMP_OVERFLOW_LIMIT=1024 diff --git a/src/initscripts/etc/hurd/runsystem.sysv b/src/initscripts/etc/hurd/runsystem.sysv new file mode 100755 index 00000000..cb448d75 --- /dev/null +++ b/src/initscripts/etc/hurd/runsystem.sysv @@ -0,0 +1,122 @@ +#!/bin/sh +# +# This program is run by /hurd/init at boot time after the essential +# servers are up. It does some initialization of its own and then +# execs the SysV init to bring up the "userland" parts of a normal +# system. +# + +### +### Where to find programs, etc. +### + +PATH=/bin:/sbin:/usr/bin:/usr/sbin +export PATH + +# If we lose badly, try to exec each of these in turn. +fallback_shells='/bin/sh /bin/dash /bin/bash /bin/csh /bin/ash /bin/shd' + +# Shell used for normal single-user startup. +SHELL=/bin/sh + +# The init program to call. +# +# Can be overridden using init=something in the kernel command line. +init=/sbin/init + +### + +# If we get a SIGLOST, attempt to reopen the console in case +# our console ports were revoked. This lets us print messages. +reopen_console () +{ + exec 1>/dev/console 2>&1 || exit 3 +} +trap 'reopen_console' 32 # SIGLOST = server died on GNU + + +# Call this when we are losing badly enough that we want to punt normal +# startup entirely. We exec a single-user shell, so we will not come back +# here. The only way to get to multi-user from that shell will be +# explicitly exec this script or something like that. +singleuser() +{ + test $# -eq 0 || echo "$0: $*" + for try in ${fallback_shells}; do + SHELL=${try} + exec ${SHELL} + done + exit 127 +} + +# Print a newline. +echo + +# See whether pflocal is setup +# +# Normally this should be the case, but we better make sure since +# without the pflocal server, pipe(2) does not work. +if ! test -e /servers/socket/1 && which settrans >/dev/null ; then + # The root filesystem should be read-only at this point. + if fsysopts / --update --writable ; then + settrans -c /servers/socket/1 /hurd/pflocal + else + singleuser "Failed to create /servers/socket/1." + fi +fi + +# We expect to be started by console-run, which gives us no arguments and +# puts FALLBACK_CONSOLE=file-name in the environment if our console is +# other than a normal /dev/console. + +if [ "${FALLBACK_CONSOLE+set}" = set ]; then + singleuser "Running on fallback console ${FALLBACK_CONSOLE}" +fi + +### +### Normal startup procedures +### + +# Parse the multiboot command line. We only pay attention to -s and -f. +# The first argument is the kernel file name; skip that. +shift +flags= +single= +while [ $# -gt 0 ]; do + arg="$1" + shift + case "$arg" in + --*) ;; + init=*) + eval "${arg}" + ;; + *=*) ;; + -*) + flags="${flags}${arg#-}" + ;; + 'single') + single="-s" + ;; + 'fastboot'|'emergency') + ;; + esac +done + +# Check boot flags. +case "$flags" in +*s*) + single="-s" # force single-user + ;; +esac + +# Start the default pager. It will bail if there is already one running. +/hurd/mach-defpager + +# This is necessary to make stat / return the correct device ids. +# Work around a race condition (probably in the root translator). +for i in `seq 1 100000` ; do : ; done + +fsysopts / --update --readonly + +# Finally, start the actual SysV init. +exec ${init} ${single} -a diff --git a/src/initscripts/etc/init.d/bootlogs b/src/initscripts/etc/init.d/bootlogs new file mode 100644 index 00000000..3ad7d8b5 --- /dev/null +++ b/src/initscripts/etc/init.d/bootlogs @@ -0,0 +1,60 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: bootlogs +# Required-Start: hostname $local_fs +# Required-Stop: +# Should-Start: $x-display-manager gdm kdm xdm ldm sdm wdm nodm +# Default-Start: 1 2 3 4 5 +# Default-Stop: +# Short-Description: Log file handling to be done during bootup. +# Description: Various things that don't need to be done particularly +# early in the boot, just before getty is run. +### END INIT INFO + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +[ "$DELAYLOGIN" ] || DELAYLOGIN=yes +. /lib/init/vars.sh + +do_start () { + # Save kernel messages in /var/log/dmesg + if which dmesg >/dev/null 2>&1 + then + [ -f /var/log/dmesg ] && savelog -q -p -c 5 /var/log/dmesg + dmesg -s 524288 > /var/log/dmesg + chgrp adm /var/log/dmesg || : + elif [ -c /dev/klog ] + then + [ -f /var/log/dmesg ] && savelog -q -p -c 5 /var/log/dmesg + dd if=/dev/klog of=/var/log/dmesg & + sleep 1 + kill $! + [ -f /var/log/dmesg ] && { chgrp adm /var/log/dmesg || : ; } + fi +} + +do_status () { + return 0 +} + +case "$1" in + start|"") + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + # No-op + ;; + status) + do_status + exit $? + ;; + *) + echo "Usage: bootlogs [start|stop|status]" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/bootmisc.sh b/src/initscripts/etc/init.d/bootmisc.sh new file mode 100755 index 00000000..5c73683e --- /dev/null +++ b/src/initscripts/etc/init.d/bootmisc.sh @@ -0,0 +1,59 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: bootmisc +# Required-Start: $remote_fs +# Required-Stop: +# Should-Start: udev +# Default-Start: S +# Default-Stop: +# Short-Description: Miscellaneous things to be done during bootup. +# Description: Some cleanup. Note, it need to run after mountnfs-bootclean.sh. +### END INIT INFO + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +[ "$DELAYLOGIN" ] || DELAYLOGIN=yes +. /lib/init/vars.sh + +do_start () { + # + # If login delaying is enabled then create the flag file + # which prevents logins before startup is complete + # + case "$DELAYLOGIN" in + Y*|y*) + echo "System bootup in progress - please wait" > /var/lib/initscripts/nologin + ;; + esac + + # Create /var/run/utmp so we can login. + : > /var/run/utmp + if grep -q ^utmp: /etc/group + then + chmod 664 /var/run/utmp + chgrp utmp /var/run/utmp + fi + + # Remove bootclean's flag files. + # Don't run bootclean again after this! + rm -f /tmp/.clean /run/.clean /run/lock/.clean + rm -f /tmp/.tmpfs /run/.tmpfs /run/lock/.tmpfs +} + +case "$1" in + start|"") + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop|status) + # No-op + ;; + *) + echo "Usage: bootmisc.sh [start|stop]" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/checkfs.sh b/src/initscripts/etc/init.d/checkfs.sh new file mode 100755 index 00000000..3c556efe --- /dev/null +++ b/src/initscripts/etc/init.d/checkfs.sh @@ -0,0 +1,155 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: checkfs +# Required-Start: checkroot +# Required-Stop: +# Should-Start: +# Default-Start: S +# Default-Stop: +# X-Interactive: true +# Short-Description: Check all filesystems. +### END INIT INFO + +# Include /usr/bin in path to find on_ac_power if /usr/ is on the root +# partition. +PATH=/sbin:/bin:/usr/bin +FSCK_LOGFILE=/var/log/fsck/checkfs +[ "$FSCKFIX" ] || FSCKFIX=no +. /lib/init/vars.sh + +. /lib/lsb/init-functions +. /lib/init/mount-functions.sh +. /lib/init/swap-functions.sh + +do_start () { + # Trap SIGINT so that we can handle user interupt of fsck. + trap "" INT + + # See if we're on AC Power. If not, we're not gonna run our + # check. If on_ac_power (in /usr/) is unavailable, behave as + # before and check all file systems needing it. + +# Disabled AC power check until fsck can be told to only check the +# file system if it is corrupt when running on battery. (bug #526398) +# if which on_ac_power >/dev/null 2>&1 +# then +# on_ac_power >/dev/null 2>&1 +# if [ $? -eq 1 ] +# then +# [ "$VERBOSE" = no ] || log_success_msg "Running on battery power, so skipping file system check." +# BAT=yes +# fi +# fi + BAT="" + fscheck="yes" + + if is_fastboot_active + then + [ "$fscheck" = yes ] && log_warning_msg "Fast boot enabled, so skipping file system check." + fscheck=no + fi + + # + # Check the rest of the file systems. + # + if [ "$fscheck" = yes ] && [ ! "$BAT" ] && [ "$FSCKTYPES" != "none" ] + then + + # Execute swapon command again, in case there are lvm + # or md swap partitions. fsck can suck RAM. + swaponagain 'lvm and md' + + if [ -f /forcefsck ] || grep -q -s -w -i "forcefsck" /proc/cmdline + then + force="-f" + else + force="" + fi + if [ "$FSCKFIX" = yes ] + then + fix="-y" + else + fix="-a" + fi + spinner="-C" + case "$TERM" in + dumb|network|unknown|"") + spinner="" + ;; + esac + [ "$(uname -m)" = s390x ] && spinner="" # This should go away + FSCKTYPES_OPT="" + [ "$FSCKTYPES" ] && FSCKTYPES_OPT="-t $FSCKTYPES" + handle_failed_fsck() { + log_failure_msg "File system check failed. +A log is being saved in ${FSCK_LOGFILE} if that location is writable. +Please repair the file system manually." + log_warning_msg "A maintenance shell will now be started. +CONTROL-D will terminate this shell and resume system boot." + # Start a single user shell on the console + if ! sulogin $CONSOLE + then + log_failure_msg "Attempt to start maintenance shell failed. +Continuing with system boot in 5 seconds." + sleep 5 + fi + } + if [ "$VERBOSE" = no ] + then + log_action_begin_msg "Checking file systems" + logsave -s $FSCK_LOGFILE fsck $spinner -M -A $fix $force $FSCKTYPES_OPT + FSCKCODE=$? + + if [ "$FSCKCODE" -eq 32 ] + then + log_action_end_msg 1 "code $FSCKCODE" + log_warning_msg "File system check was interrupted by user" + elif [ "$FSCKCODE" -gt 1 ] + then + log_action_end_msg 1 "code $FSCKCODE" + handle_failed_fsck + else + log_action_end_msg 0 + fi + else + if [ "$FSCKTYPES" ] + then + log_action_msg "Will now check all file systems of types $FSCKTYPES" + else + log_action_msg "Will now check all file systems" + fi + logsave -s $FSCK_LOGFILE fsck $spinner -V -M -A $fix $force $FSCKTYPES_OPT + FSCKCODE=$? + if [ "$FSCKCODE" -eq 32 ] + then + log_warning_msg "File system check was interrupted by user" + elif [ "$FSCKCODE" -gt 1 ] + then + handle_failed_fsck + else + log_success_msg "Done checking file systems. +A log is being saved in ${FSCK_LOGFILE} if that location is writable." + fi + fi + fi + rm -f /fastboot /forcefsck 2>/dev/null +} + +case "$1" in + start|"") + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop|status) + # No-op + ;; + *) + echo "Usage: checkfs.sh [start|stop]" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/checkroot-bootclean.sh b/src/initscripts/etc/init.d/checkroot-bootclean.sh new file mode 100755 index 00000000..effe252b --- /dev/null +++ b/src/initscripts/etc/init.d/checkroot-bootclean.sh @@ -0,0 +1,43 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: checkroot-bootclean +# Required-Start: checkroot +# Required-Stop: +# Default-Start: S +# Default-Stop: +# X-Start-Before: bootmisc +# Short-Description: bootclean after checkroot. +# Description: Clean temporary filesystems after +# the root filesystem has been mounted. +# At this point, directories which may be +# masked by future mounts may be cleaned. +### END INIT INFO + +. /lib/init/bootclean.sh + +case "$1" in + start|"") + # Clean /tmp, /run and /run/lock. Remove the .clean files to + # force initial cleaning. This is intended to allow cleaning + # of directories masked by mounts while the system was + # previously running, which would otherwise prevent them being + # cleaned. + rm -f /tmp/.clean /run/.clean /run/lock/.clean + + clean_all + exit $? + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop|status) + # No-op + ;; + *) + echo "Usage: checkroot-bootclean.sh [start|stop]" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/checkroot.sh b/src/initscripts/etc/init.d/checkroot.sh new file mode 100755 index 00000000..9f70527a --- /dev/null +++ b/src/initscripts/etc/init.d/checkroot.sh @@ -0,0 +1,371 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: checkroot mtab +# Required-Start: mountdevsubfs hostname +# Required-Stop: +# Should-Start: keymap hwclockfirst hdparm bootlogd +# Should-stop: +# Default-Start: S +# Default-Stop: +# X-Interactive: true +# Short-Description: Check to root file system. +### END INIT INFO + +# Include /usr/bin in path to find on_ac_power if /usr/ is on the root +# partition. +PATH=/sbin:/bin:/usr/bin +FSCK_LOGFILE=/var/log/fsck/checkroot +[ "$FSCKFIX" ] || FSCKFIX=no +[ "$SULOGIN" ] || SULOGIN=no +. /lib/init/vars.sh + +. /lib/lsb/init-functions +. /lib/init/mount-functions.sh + +do_start () { + # Trap SIGINT so that we can handle user interrupt of fsck. + trap "" INT + + # + # Set SULOGIN in /etc/default/rcS to yes if you want a sulogin to + # be spawned from this script *before anything else* with a timeout, + # like sysv does. + # + [ "$SULOGIN" = yes ] && sulogin -t 30 $CONSOLE + + KERNEL="$(uname -s)" + MACHINE="$(uname -m)" + + read_fstab + + # + # Activate the swap device(s) in /etc/fstab. This needs to be done + # before fsck, since fsck can be quite memory-hungry. + # + ENABLE_SWAP=no + case "$KERNEL" in + Linux) + if [ "$NOSWAP" = yes ] + then + [ "$VERBOSE" = no ] || log_warning_msg "Not activating swap as requested via bootoption noswap." + ENABLE_SWAP=no + else + if [ "$swap_on_lv" = yes ] + then + [ "$VERBOSE" = no ] || log_warning_msg "Not activating swap on logical volume." + elif [ "$swap_on_file" = yes ] + then + [ "$VERBOSE" = no ] || log_warning_msg "Not activating swap on swapfile." + else + ENABLE_SWAP=yes + fi + fi + ;; + *) + ENABLE_SWAP=yes + ;; + esac + if [ "$ENABLE_SWAP" = yes ] + then + if [ "$VERBOSE" = no ] + then + log_action_begin_msg "Activating swap" + swapon -a -e >/dev/null 2>&1 + log_action_end_msg $? + else + log_daemon_msg "Activating swap" + swapon -a -v + log_end_msg $? + fi + fi + + # + # Does the root device in /etc/fstab match with the actual device ? + # If not we try to use the /dev/root alias device, and if that + # fails we create a temporary node in /run. + # + # Do this only on Linux. Neither kFreeBSD nor Hurd have + # /dev/root and the device ids used here are specific to + # Linux. + KERNEL="$(uname)" + if [ "$rootcheck" = yes ] && [ "$KERNEL" = Linux ] + then + ddev="$(mountpoint -qx $rootdev)" + rdev="$(mountpoint -d /)" + if [ "$ddev" != "$rdev" ] && [ "$ddev" != "4:0" ] + then + if [ "$(mountpoint -qx /dev/root)" = "4:0" ] + then + rootdev=/dev/root + else + if \ + rm -f /run/rootdev \ + && mknod -m 600 /run/rootdev b ${rdev%:*} ${rdev#*:} \ + && [ -e /run/rootdev ] + then + rootdev=/run/rootdev + else + rootfatal=yes + fi + fi + fi + fi + + # + # Bother, said Pooh. + # + if [ "$rootfatal" = yes ] + then + log_failure_msg "The device node $rootdev for the root filesystem is missing or incorrect +or there is no entry for the root filesystem listed in /etc/fstab. +The system is also unable to create a temporary node in /run. +This means you have to fix the problem manually." + log_warning_msg "A maintenance shell will now be started. +CONTROL-D will terminate this shell and restart the system." + # Start a single user shell on the console + if ! sulogin $CONSOLE + then + log_failure_msg "Attempt to start maintenance shell failed. +Will restart in 5 seconds." + sleep 5 + fi + [ "$VERBOSE" = no ] || log_action_msg "Will now restart" + reboot -f + fi + + # See if we're on AC Power. If not, we're not gonna run our + # check. If on_ac_power (in /usr/) is unavailable, behave as + # before and check all file systems needing it. +# Disabled AC power check until fsck can be told to only check the +# file system if it is corrupt when running on battery. (bug #526398) +# if which on_ac_power >/dev/null 2>&1 && [ "$rootcheck" = yes ] +# then +# on_ac_power >/dev/null 2>&1 +# if [ "$?" -eq 1 ] +# then +# log_warning_msg "On battery power, so skipping file system check." +# rootcheck=no +# fi +# fi + + # + # See if we want to check the root file system. + # + FSCKCODE=0 + + if [ -e /run/initramfs/fsck-root ] + then + rootcheck=no + fi + + if is_fastboot_active + then + [ "$rootcheck" = yes ] && log_warning_msg "Fast boot enabled, so skipping root file system check." + rootcheck=no + fi + + if which findmnt >/dev/null 2>&1 + then + if [ "$(findmnt -f -n -o FSTYPE /)" = "btrfs" ] + then + [ "$rootcheck" = yes ] && log_warning_msg "btrfs root detected, so skipping root file system check." + rootcheck=no + fi + fi + + if [ "$rootcheck" = yes ] + then + # + # Ensure that root is quiescent and read-only before fsck'ing. + # + # mount -n -o remount,ro / would be the correct syntax but + # mount can get confused when there is a "bind" mount defined + # in fstab that bind-mounts "/" somewhere else. + # + # So we use mount -n -o remount,ro $rootdev / but that can + # fail on older kernels on sparc64/alpha architectures due + # to a bug in sys_mount(). + # + # As a compromise we try both. + # + if \ + ! mount -n -o remount,ro $rootdev / \ + && ! mount -n -o remount,ro -t dummytype $rootdev / 2>/dev/null \ + && ! mount -n -o remount,ro / 2>/dev/null + then + log_failure_msg "Cannot check root file system because it is not mounted read-only." + rootcheck=no + fi + fi + + # + # The actual checking is done here. + # + if [ "$rootcheck" = yes ] + then + if [ -f /forcefsck ] || grep -q -s -w -i "forcefsck" /proc/cmdline + then + force="-f" + else + force="" + fi + + if [ "$FSCKFIX" = yes ] + then + fix="-y" + else + fix="-a" + fi + + spinner="-C" + case "$TERM" in + dumb|network|unknown|"") + spinner="" ;; + esac + # This Linux/s390x special case should go away. + if [ "${KERNEL}:${MACHINE}" = Linux:s390x ] + then + spinner="" + fi + + if [ "$VERBOSE" = no ] + then + log_action_begin_msg "Checking root file system" + logsave -s $FSCK_LOGFILE fsck $spinner $force $fix -t $roottype $rootdev + FSCKCODE=$? + if [ "$FSCKCODE" = 0 ] + then + log_action_end_msg 0 + else + log_action_end_msg 1 "code $FSCKCODE" + fi + else + log_daemon_msg "Will now check root file system" + logsave -s $FSCK_LOGFILE fsck $spinner $force $fix -V -t $roottype $rootdev + FSCKCODE=$? + log_end_msg $FSCKCODE + fi + fi + + # + # If there was a failure, drop into single-user mode. + # + # NOTE: "failure" is defined as exiting with a return code of + # 4 or larger. A return code of 1 indicates that file system + # errors were corrected but that the boot may proceed. A return + # code of 2 or 3 indicates that the system should immediately reboot. + # + if [ "$FSCKCODE" -eq 32 ] + then + log_warning_msg "File system check was interrupted by user" + elif [ "$FSCKCODE" -gt 3 ] + then + # Surprise! Re-directing from a HERE document (as in "cat << EOF") + # does not work because the root is currently read-only. + log_failure_msg "An automatic file system check (fsck) of the root filesystem failed. +A manual fsck must be performed, then the system restarted. +The fsck should be performed in maintenance mode with the +root filesystem mounted in read-only mode." + log_warning_msg "The root filesystem is currently mounted in read-only mode. +A maintenance shell will now be started. +After performing system maintenance, press CONTROL-D +to terminate the maintenance shell and restart the system." + # Start a single user shell on the console + if ! sulogin $CONSOLE + then + log_failure_msg "Attempt to start maintenance shell failed. +Will restart in 5 seconds." + sleep 5 + fi + [ "$VERBOSE" = no ] || log_action_msg "Will now restart" + reboot -f + elif [ "$FSCKCODE" -gt 1 ] + then + log_failure_msg "The file system check corrected errors on the root partition +but requested that the system be restarted." + log_warning_msg "The system will be restarted in 5 seconds." + sleep 5 + [ "$VERBOSE" = no ] || log_action_msg "Will now restart" + reboot -f + fi + + # + # Remount root to final mode (rw or ro). + # + # See the comments above at the previous "mount -o remount" + # for an explanation why we try this twice. + # + if ! mount -n -o remount,$rootopts,$rootmode $fstabroot / 2>/dev/null + then + mount -n -o remount,$rootopts,$rootmode / + fi + + # If possible, migrate /etc/mtab to be a symlink to + # /proc/mounts. Note that not all systems e.g. Hurd currently + # support this. + if [ "$rootmode" != "ro" ]; then + mtab_migrate + fi + + if selinux_enabled && [ -x /sbin/restorecon ] && [ -r /etc/mtab ] + then + restorecon /etc/mtab + fi + + # + # Remove /run/rootdev if we created it. + # + rm -f /run/rootdev + + # Update mount options for mounts created in early boot + # S01mountkernfs.sh + /etc/init.d/mountkernfs.sh reload + # S03mountdevsubfs.sh + /etc/init.d/mountdevsubfs.sh reload + +} + +do_status () { + # If / is read-write or swap is enabled, this script have done + # its job. + rootrw=false + swapon=false + if [ -f /etc/mtab ] ; then + if grep " / " /etc/mtab |grep -q rw ; then + rootrw=true + fi + fi + if [ -f /proc/swaps ] ; then + if [ "$(cat /proc/swaps |grep -v ^Filename)" ] ; then + swapon=true + fi + fi + if [ true = "$rootrw" ] || [ true = "$swapon" ] ; then + return 0 + else + return 4 + fi +} + +case "$1" in + start|"") + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + # No-op + ;; + status) + do_status + exit $? + ;; + *) + echo "Usage: checkroot.sh [start|stop]" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/halt b/src/initscripts/etc/init.d/halt new file mode 100755 index 00000000..c179a25a --- /dev/null +++ b/src/initscripts/etc/init.d/halt @@ -0,0 +1,83 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: halt +# Required-Start: +# Required-Stop: +# Default-Start: +# Default-Stop: 0 +# Short-Description: Execute the halt command. +# Description: +### END INIT INFO + +NETDOWN=yes + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +[ -f /etc/default/halt ] && . /etc/default/halt + +. /lib/lsb/init-functions + +do_stop () { + if [ "$INIT_HALT" = "" ] + then + case "$HALT" in + [Pp]*) + INIT_HALT=POWEROFF + ;; + [Hh]*) + INIT_HALT=HALT + ;; + *) + INIT_HALT=POWEROFF + ;; + esac + fi + + # See if we need to cut the power. + if [ "$INIT_HALT" = "POWEROFF" ] && [ -x /etc/init.d/ups-monitor ] + then + /etc/init.d/ups-monitor poweroff + fi + + # Don't shut down drives if we're using RAID. + hddown="-h" + if grep -qs '^md.*active' /proc/mdstat + then + hddown="" + fi + + # If INIT_HALT=HALT don't poweroff. + poweroff="-p" + if [ "$INIT_HALT" = "HALT" ] + then + poweroff="" + fi + + # Make it possible to not shut down network interfaces, + # needed to use wake-on-lan + netdown="-i" + if [ "$NETDOWN" = "no" ]; then + netdown="" + fi + + log_action_msg "Will now halt" + halt -d -f $netdown $poweroff $hddown +} + +case "$1" in + start|status) + # No-op + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + do_stop + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/hostname.sh b/src/initscripts/etc/init.d/hostname.sh new file mode 100755 index 00000000..61eb5ea6 --- /dev/null +++ b/src/initscripts/etc/init.d/hostname.sh @@ -0,0 +1,68 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: hostname +# Required-Start: +# Required-Stop: +# Should-Start: glibc +# Default-Start: S +# Default-Stop: +# Short-Description: Set hostname based on /etc/hostname +# Description: Read the machines hostname from /etc/hostname, and +# update the kernel value with this value. If +# /etc/hostname is empty, the current kernel value +# for hostname is used. If the kernel value is +# empty, the value 'localhost' is used. +### END INIT INFO + +PATH=/sbin:/bin + +. /lib/init/vars.sh +. /lib/lsb/init-functions + +do_start () { + [ -f /etc/hostname ] && HOSTNAME="$(cat /etc/hostname)" + + # Keep current name if /etc/hostname is missing. + [ -z "$HOSTNAME" ] && HOSTNAME="$(hostname)" + + # And set it to 'localhost' if no setting was found + [ -z "$HOSTNAME" ] && HOSTNAME=localhost + + [ "$VERBOSE" != no ] && log_action_begin_msg "Setting hostname to '$HOSTNAME'" + hostname "$HOSTNAME" + ES=$? + [ "$VERBOSE" != no ] && log_action_end_msg $ES + exit $ES +} + +do_status () { + HOSTNAME=$(hostname) + if [ "$HOSTNAME" ] ; then + return 0 + else + return 4 + fi +} + +case "$1" in + start|"") + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + # No-op + ;; + status) + do_status + exit $? + ;; + *) + echo "Usage: hostname.sh [start|stop]" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/killprocs b/src/initscripts/etc/init.d/killprocs new file mode 100755 index 00000000..d141de6b --- /dev/null +++ b/src/initscripts/etc/init.d/killprocs @@ -0,0 +1,62 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: killprocs +# Required-Start: $local_fs +# Required-Stop: +# Default-Start: 1 +# Default-Stop: +# Short-Description: executed by init(8) upon entering runlevel 1 (single). +### END INIT INFO + +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +. /lib/lsb/init-functions + +do_start () { + # Kill all processes. + log_action_begin_msg "Asking all remaining processes to terminate" + killall5 -15 # SIGTERM + log_action_end_msg 0 + alldead="" + for seq in 1 2 3 4 5 6 7 8 9 10; do + # use SIGCONT/signal 18 to check if there are + # processes left. No need to check the exit code + # value, because either killall5 work and it make + # sense to wait for processes to die, or it fail and + # there is nothing to wait for. + + if killall5 -18 ; then + : + else + alldead=1 + break + fi + + sleep 1 + done + if [ -z "$alldead" ] ; then + log_action_begin_msg "Killing all remaining processes" + killall5 -9 # SIGKILL + log_action_end_msg 1 + else + log_action_begin_msg "All processes ended within $seq seconds." + log_action_end_msg 0 + fi +} + +case "$1" in + start) + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop|status) + # No-op + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac diff --git a/src/initscripts/etc/init.d/motd b/src/initscripts/etc/init.d/motd new file mode 100644 index 00000000..e0d7706f --- /dev/null +++ b/src/initscripts/etc/init.d/motd @@ -0,0 +1,53 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: motd +# Required-Start: hostname $local_fs +# Required-Stop: +# Should-Start: +# Default-Start: 1 2 3 4 5 +# Default-Stop: +# Short-Description: Create dynamic part of /etc/motd +# Description: /etc/motd is user-editable and static. This script +# creates the initial dynamic part, by default the +# output of uname, and stores it in /var/run/motd.dynamic. +# Both parts are output by pam_motd. +### END INIT INFO + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +. /lib/init/vars.sh + +do_start () { + # Update motd + uname -snrvm > /var/run/motd.dynamic +} + +do_status () { + if [ -f /var/run/motd.dynamic ] ; then + return 0 + else + return 4 + fi +} + +case "$1" in + start|"") + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + # No-op + ;; + status) + do_status + exit $? + ;; + *) + echo "Usage: motd [start|stop|status]" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/mountall-bootclean.sh b/src/initscripts/etc/init.d/mountall-bootclean.sh new file mode 100755 index 00000000..546c5322 --- /dev/null +++ b/src/initscripts/etc/init.d/mountall-bootclean.sh @@ -0,0 +1,35 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: mountall-bootclean +# Required-Start: mountall +# Required-Stop: +# Default-Start: S +# Default-Stop: +# X-Start-Before: bootmisc +# Short-Description: bootclean after mountall. +# Description: Clean temporary filesystems after +# all local filesystems have been mounted. +### END INIT INFO + +. /lib/init/bootclean.sh + +case "$1" in + start|"") + # Clean /tmp, /var/lock, /var/run + clean_all + exit $? + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop|status) + # No-op + ;; + *) + echo "Usage: mountall-bootclean.sh [start|stop]" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/mountall.sh b/src/initscripts/etc/init.d/mountall.sh new file mode 100755 index 00000000..cf47e70a --- /dev/null +++ b/src/initscripts/etc/init.d/mountall.sh @@ -0,0 +1,100 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: mountall +# Required-Start: checkfs checkroot-bootclean +# Required-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Mount all filesystems. +# Description: +### END INIT INFO + +PATH=/sbin:/bin +. /lib/init/vars.sh +. /lib/init/tmpfs.sh + +. /lib/lsb/init-functions +. /lib/init/mount-functions.sh +. /lib/init/swap-functions.sh + +# for ntfs-3g to get correct file name encoding +if [ -r /etc/default/locale ]; then + . /etc/default/locale + export LANG +fi + +do_start() { + # + # Mount local file systems in /etc/fstab. + # + mount_all_local() { + if mountpoint -q /usr; then + # May have been mounted read-only by initramfs. + # Remount with unmodified options from /etc/fstab. + mount -o remount /usr + fi + mount -a -t nonfs,nfs4,smbfs,cifs,ncp,ncpfs,coda,ocfs2,gfs,gfs2,ceph \ + -O no_netdev + } + pre_mountall + if [ "$VERBOSE" = no ] + then + log_action_begin_msg "Mounting local filesystems" + mount_all_local + log_action_end_msg $? + else + log_daemon_msg "Will now mount local filesystems" + mount_all_local + log_end_msg $? + fi + post_mountall + + # We might have mounted something over /run; see if + # /run/initctl is present. Look for + # /usr/share/sysvinit/update-rc.d to verify that sysvinit (and + # not upstart) is installed). + INITCTL="/run/initctl" + if [ ! -p "$INITCTL" ] && [ -f "/usr/share/sysvinit/update-rc.d" ]; then + # Create new control channel + rm -f "$INITCTL" + mknod -m 600 "$INITCTL" p + + # Reopen control channel. + PID="$(pidof -s /sbin/init || echo 1)" + [ -n "$PID" ] && kill -s USR1 "$PID" + fi + + # Execute swapon command again, in case we want to swap to + # a file on a now mounted filesystem. + swaponagain 'swapfile' + + # Remount tmpfs filesystems; with increased VM after swapon, + # the size limits may be adjusted. + mount_run mount_noupdate + mount_lock mount_noupdate + mount_shm mount_noupdate + + # Now we have mounted everything, check whether we need to + # mount a tmpfs on /tmp. We can now also determine swap size + # to factor this into our size limit. + mount_tmp mount_noupdate +} + +case "$1" in + start|"") + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop|status) + # No-op + ;; + *) + echo "Usage: mountall.sh [start|stop]" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/mountdevsubfs.sh b/src/initscripts/etc/init.d/mountdevsubfs.sh new file mode 100755 index 00000000..bf1116b0 --- /dev/null +++ b/src/initscripts/etc/init.d/mountdevsubfs.sh @@ -0,0 +1,68 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: mountdevsubfs +# Required-Start: mountkernfs +# Required-Stop: +# Should-Start: udev +# Default-Start: S +# Default-Stop: +# Short-Description: Mount special file systems under /dev. +# Description: Mount the virtual filesystems the kernel provides +# that ordinarily live under the /dev filesystem. +### END INIT INFO +# +# This script gets called multiple times during boot +# + +PATH=/sbin:/bin +TTYGRP=5 +TTYMODE=620 +[ -f /etc/default/devpts ] && . /etc/default/devpts + +KERNEL="$(uname -s)" + +. /lib/init/vars.sh +. /lib/init/tmpfs.sh + +. /lib/lsb/init-functions +. /lib/init/mount-functions.sh + +# May be run several times, so must be idempotent. +# $1: Mount mode, to allow for remounting +mount_filesystems () { + MNTMODE="$1" + + # Mount a tmpfs on /run/shm + mount_shm "$MNTMODE" + + # Mount /dev/pts + if [ "$KERNEL" = Linux ] + then + if [ ! -d /dev/pts ] + then + mkdir --mode=755 /dev/pts + [ -x /sbin/restorecon ] && /sbin/restorecon /dev/pts + fi + domount "$MNTMODE" devpts "" /dev/pts devpts "-onoexec,nosuid,gid=$TTYGRP,mode=$TTYMODE" + fi +} + +case "$1" in + "") + echo "Warning: mountdevsubfs should be called with the 'start' argument." >&2 + mount_filesystems mount_noupdate + ;; + start) + mount_filesystems mount_noupdate + ;; + restart|reload|force-reload) + mount_filesystems remount + ;; + stop|status) + # No-op + ;; + *) + echo "Usage: mountdevsubfs [start|stop]" >&2 + exit 3 + ;; +esac diff --git a/src/initscripts/etc/init.d/mountkernfs.sh b/src/initscripts/etc/init.d/mountkernfs.sh new file mode 100755 index 00000000..e95cac3a --- /dev/null +++ b/src/initscripts/etc/init.d/mountkernfs.sh @@ -0,0 +1,75 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: mountkernfs +# Required-Start: +# Required-Stop: +# Should-Start: glibc +# Default-Start: S +# Default-Stop: +# Short-Description: Mount kernel virtual file systems. +# Description: Mount initial set of virtual filesystems the kernel +# provides and that are required by everything. +### END INIT INFO + +PATH=/sbin:/bin +. /lib/init/vars.sh +. /lib/init/tmpfs.sh + +. /lib/lsb/init-functions +. /lib/init/mount-functions.sh + +# May be run several times, so must be idempotent. +# $1: Mount mode, to allow for remounting +mount_filesystems () { + MNTMODE="$1" + + # + # Mount tmpfs on /run and/or /run/lock + # + mount_run "$MNTMODE" + mount_lock "$MNTMODE" + + # + # Mount proc filesystem on /proc + # + domount "$MNTMODE" proc "" /proc proc "-onodev,noexec,nosuid" + + # + # Mount sysfs on /sys + # + # Only mount sysfs if it is supported (kernel >= 2.6) + if grep -E -qs "sysfs\$" /proc/filesystems + then + domount "$MNTMODE" sysfs "" /sys sysfs "-onodev,noexec,nosuid" + fi + + if [ -d /sys/fs/pstore ] + then + domount "$MNTMODE" pstore "" /sys/fs/pstore pstore "" + fi + + if [ -d /sys/kernel/config ] + then + domount "$MNTMODE" configfs "" /sys/kernel/config configfs "" + fi +} + +case "$1" in + "") + echo "Warning: mountkernfs should be called with the 'start' argument." >&2 + mount_filesystems mount_noupdate + ;; + start) + mount_filesystems mount_noupdate + ;; + restart|reload|force-reload) + mount_filesystems remount + ;; + stop|status) + # No-op + ;; + *) + echo "Usage: mountkernfs [start|stop]" >&2 + exit 3 + ;; +esac diff --git a/src/initscripts/etc/init.d/mountnfs-bootclean.sh b/src/initscripts/etc/init.d/mountnfs-bootclean.sh new file mode 100755 index 00000000..d1a6d8bc --- /dev/null +++ b/src/initscripts/etc/init.d/mountnfs-bootclean.sh @@ -0,0 +1,35 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: mountnfs-bootclean +# Required-Start: $local_fs mountnfs +# Required-Stop: +# Default-Start: S +# Default-Stop: +# X-Start-Before: bootmisc +# Short-Description: bootclean after mountnfs. +# Description: Clean temporary filesystems after +# network filesystems have been mounted. +### END INIT INFO + +. /lib/init/bootclean.sh + +case "$1" in + start|"") + # Clean /tmp, /var/lock, /var/run + clean_all + exit $? + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop|status) + # No-op + ;; + *) + echo "Usage: mountnfs-bootclean.sh [start|stop]" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/mountnfs.sh b/src/initscripts/etc/init.d/mountnfs.sh new file mode 100755 index 00000000..6b1b09cc --- /dev/null +++ b/src/initscripts/etc/init.d/mountnfs.sh @@ -0,0 +1,106 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: mountnfs +# Required-Start: $local_fs +# Required-Stop: +# Should-Start: $network $portmap nfs-common udev-mtab +# Default-Start: S +# Default-Stop: +# Short-Description: Wait for network file systems to be mounted +# Description: Network file systems are mounted by +# /etc/network/if-up.d/mountnfs in the background +# when interfaces are brought up; this script waits +# for them to be mounted before carrying on. +### END INIT INFO + +. /lib/init/vars.sh +. /lib/init/mount-functions.sh +. /lib/lsb/init-functions + +do_wait_async_mount() { + # Read through fstab line by line. If it is NFS, set the flag + # for mounting NFS file systems. If any NFS partition is found + # then wait around for it. + + waitnfs= + for file in "$(eval ls $(fstab_files))"; do + if [ -f "$file" ]; then + while read DEV MTPT FSTYPE OPTS REST; do + case "$DEV" in + ""|\#*) + continue + ;; + esac + case "$OPTS" in + noauto|*,noauto|noauto,*|*,noauto,*) + continue + ;; + esac + case "$FSTYPE" in + nfs|nfs4|smbfs|cifs|coda|ncp|ncpfs|ocfs2|gfs|ceph) + ;; + *) + continue + ;; + esac + case "$MTPT" in + /usr/local|/usr/local/*) + ;; + /usr|/usr/*) + waitnfs="$waitnfs $MTPT" + ;; + /var|/var/*) + waitnfs="$waitnfs $MTPT" + ;; + esac + done < "$file" + fi + done + + # Wait for each path, the timeout is for all of them as that's + # really the maximum time we have to wait anyway + TIMEOUT=900 + for mountpt in $waitnfs; do + log_action_begin_msg "Waiting for $mountpt" + + while ! mountpoint -q $mountpt; do + sleep 0.1 + + TIMEOUT=$(( $TIMEOUT - 1 )) + if [ $TIMEOUT -le 0 ]; then + log_action_end_msg 1 + break + fi + done + + if [ $TIMEOUT -gt 0 ]; then + log_action_end_msg 0 + fi + done +} + +case "$1" in + start) + # Using 'no !=' instead of 'yes =' to make sure async nfs + # mounting is the default even without a value in + # /etc/default/rcS + if [ no != "$ASYNCMOUNTNFS" ] ; then + do_wait_async_mount + else + FROMINITD=yes /etc/network/if-up.d/mountnfs + fi + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop|status) + # No-op + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/rc.local b/src/initscripts/etc/init.d/rc.local new file mode 100644 index 00000000..43fcd3f5 --- /dev/null +++ b/src/initscripts/etc/init.d/rc.local @@ -0,0 +1,43 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: rc.local +# Required-Start: $all +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: +# Short-Description: Run /etc/rc.local if it exist +### END INIT INFO + + +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +. /lib/init/vars.sh +. /lib/lsb/init-functions + +do_start() { + if [ -x /etc/rc.local ]; then + [ "$VERBOSE" != no ] && log_begin_msg "Running local boot scripts (/etc/rc.local)" + /etc/rc.local + ES=$? + [ "$VERBOSE" != no ] && log_end_msg $ES + return $ES + fi +} + +case "$1" in + start) + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop|status) + # No-op + exit 0 + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac diff --git a/src/initscripts/etc/init.d/reboot b/src/initscripts/etc/init.d/reboot new file mode 100755 index 00000000..e1dcb1cc --- /dev/null +++ b/src/initscripts/etc/init.d/reboot @@ -0,0 +1,41 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: reboot +# Required-Start: +# Required-Stop: +# Default-Start: +# Default-Stop: 6 +# Short-Description: Execute the reboot command. +# Description: +### END INIT INFO + +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +. /lib/lsb/init-functions + +do_stop () { + # Message should end with a newline since kFreeBSD may + # print more stuff (see #323749) + log_action_msg "Will now restart" + reboot -d -f -i +} + +case "$1" in + start) + # No-op + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + do_stop + ;; + status) + exit 0 + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac diff --git a/src/initscripts/etc/init.d/rmnologin b/src/initscripts/etc/init.d/rmnologin new file mode 100755 index 00000000..a21589d7 --- /dev/null +++ b/src/initscripts/etc/init.d/rmnologin @@ -0,0 +1,59 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: rmnologin +# Required-Start: $remote_fs $all +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: +# Short-Description: Remove /run/nologin at boot +# Description: This script removes the /run/nologin file as the +# last step in the boot process, if DELAYLOGIN=yes. +# If DELAYLOGIN=no, /run/nologin was not created by +# bootmisc earlier in the boot process. +### END INIT INFO + +PATH=/sbin:/bin +[ "$DELAYLOGIN" ] || DELAYLOGIN=yes +. /lib/init/vars.sh + +do_start () { + # + # If login delaying is enabled then remove the flag file + # + case "$DELAYLOGIN" in + Y*|y*) + rm -f /run/nologin + ;; + esac +} + +do_status () { + if [ ! -f /run/nologin ] ; then + return 0 + else + return 4 + fi +} + +case "$1" in + start) + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + # No-op + ;; + status) + do_status + exit $? + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/sendsigs b/src/initscripts/etc/init.d/sendsigs new file mode 100755 index 00000000..dfb91e4e --- /dev/null +++ b/src/initscripts/etc/init.d/sendsigs @@ -0,0 +1,126 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: sendsigs +# Required-Start: +# Required-Stop: umountnfs +# Default-Start: +# Default-Stop: 0 6 +# Short-Description: Kill all remaining processes. +# Description: +### END INIT INFO + +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +. /lib/lsb/init-functions + +# Make it possible to see who the misbehaving processes are +report_unkillable() { + if [ -x /usr/bin/pstree ] ; then + echo "Currently running processes (pstree):" + pstree + elif [ -x /bin/ps ] ; then + echo "Currently running processes (ps):" + ps -ef + fi +} + +do_stop () { + OMITPIDS= + + for omitfile in /run/sendsigs.omit; do + if [ -e $omitfile ]; then + for pid in $(cat $omitfile); do + OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid" + done + fi + done + + # Load sendsigs.omit.d/packagename files too, to make it + # possible for scripts that need to modify the list of pids at + # run time without race conditions. + for omitdir in /run/sendsigs.omit.d; do + if [ -d "${omitdir}" ]; then + for pidfile in "${omitdir}/"*; do + [ -f "$pidfile" ] || continue + for pid in $(cat $pidfile); do + OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid" + done + done + fi + done + + # Upstart jobs have their own "stop on" clauses that sends + # SIGTERM/SIGKILL just like this, so if they're still running, + # they're supposed to be + if [ -x /sbin/initctl ]; then + for pid in $(initctl list | sed -n -e "/process [0-9]/s/.*process //p"); do + OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid" + done + fi + + # Flush the kernel I/O buffer before we start to kill + # processes, to make sure the IO of already stopped services to + # not slow down the remaining processes to a point where they + # are accidentily killed with SIGKILL because they did not + # manage to shut down in time. + sync + + # Kill all processes. + log_action_begin_msg "Asking all remaining processes to terminate" + killall5 -15 $OMITPIDS # SIGTERM + log_action_end_msg 0 + alldead="" + for seq in 1 2 3 4 5 6 7 8 9 10; do + # use SIGCONT/signal 18 to check if there are + # processes left. No need to check the exit code + # value, because either killall5 work and it make + # sense to wait for processes to die, or it fail and + # there is nothing to wait for. + + # did an upstart job start since we last polled initctl? check + # again on each loop and add any new jobs (e.g., plymouth) to + # the list. If we did miss one starting up, this beats waiting + # 10 seconds before shutting down. + if [ -x /sbin/initctl ]; then + for pid in $(initctl list | sed -n -e "/process [0-9]/s/.*process //p"); do + OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid" + done + fi + if killall5 -18 $OMITPIDS ; then + : + else + alldead=1 + break + fi + + sleep 1 + done + if [ -z "$alldead" ] ; then + report_unkillable + log_action_begin_msg "Killing all remaining processes" + killall5 -9 $OMITPIDS # SIGKILL + log_action_end_msg 1 + else + log_action_begin_msg "All processes ended within $seq seconds" + log_action_end_msg 0 + fi +} + +case "$1" in + start|status) + # No-op + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + do_stop + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/single b/src/initscripts/etc/init.d/single new file mode 100755 index 00000000..0402bbbf --- /dev/null +++ b/src/initscripts/etc/init.d/single @@ -0,0 +1,35 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: single +# Required-Start: $local_fs $all killprocs +# Required-Stop: +# Default-Start: 1 +# Default-Stop: +# Short-Description: executed by init(8) upon entering runlevel 1 (single). +### END INIT INFO + +PATH=/sbin:/bin + +. /lib/lsb/init-functions + +do_start () { + log_action_msg "Will now switch to single-user mode" + exec init -t1 S +} + +case "$1" in + start) + do_start + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop|status) + # No-op + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac diff --git a/src/initscripts/etc/init.d/skeleton b/src/initscripts/etc/init.d/skeleton new file mode 100644 index 00000000..1aeff11e --- /dev/null +++ b/src/initscripts/etc/init.d/skeleton @@ -0,0 +1,27 @@ +#!/bin/sh +# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing. +if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then + set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script +fi +### BEGIN INIT INFO +# Provides: skeleton +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Example initscript +# Description: This file should be used to construct scripts to be +# placed in /etc/init.d. This example start a +# single forking daemon capable of writing a pid +# file. To get other behavoirs, implemend +# do_start(), do_stop() or other functions to +# override the defaults in /lib/init/init-d-script. +### END INIT INFO + +# Author: Foo Bar +# +# Please remove the "Author" lines above and replace them +# with your own name if you copy and modify this script. + +DESC="Description of the service" +DAEMON=/usr/sbin/daemonexecutablename diff --git a/src/initscripts/etc/init.d/umountfs b/src/initscripts/etc/init.d/umountfs new file mode 100755 index 00000000..5f35b32b --- /dev/null +++ b/src/initscripts/etc/init.d/umountfs @@ -0,0 +1,130 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: umountfs +# Required-Start: +# Required-Stop: umountroot +# Default-Start: +# Default-Stop: 0 6 +# Short-Description: Turn off swap and unmount all local file systems. +# Description: +### END INIT INFO + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +. /lib/init/vars.sh + +. /lib/lsb/init-functions + +umask 022 + +do_stop () { + PROTECTED_MOUNTS="$(sed -n ':a;/^[^ ]* \(\/\|\/usr\) /!{H;n;ba};{H;s/.*//;x;s/\n//;p}' /proc/mounts)" + WEAK_MTPTS="" # be gentle, don't use force + REG_MTPTS="" + TMPFS_MTPTS="" + while read -r DEV MTPT FSTYPE REST + do + echo "$PROTECTED_MOUNTS" | grep -qs "^$DEV $MTPT " && continue + case "$MTPT" in + /|/proc|/dev|/.dev|/dev/pts|/dev/shm|/dev/.static/dev|/proc/*|/sys|/sys/*|/run|/run/*|/dev/vcs) + continue + ;; + esac + case "$FSTYPE" in + proc|procfs|linprocfs|sysfs|usbfs|usbdevfs|devpts) + continue + ;; + tmpfs) + TMPFS_MTPTS="$MTPT $TMPFS_MTPTS" + ;; + *) + if echo "$PROTECTED_MOUNTS" | grep -qs "^$DEV "; then + WEAK_MTPTS="$MTPT $WEAK_MTPTS" + else + REG_MTPTS="$MTPT $REG_MTPTS" + fi + ;; + esac + done < /proc/mounts + + # + # Make sure tmpfs file systems are umounted before turning off + # swap, to avoid running out of memory if the tmpfs filesystems + # use a lot of space. + # + if [ "$TMPFS_MTPTS" ] + then + if [ "$VERBOSE" = no ] + then + log_action_begin_msg "Unmounting temporary filesystems" + fstab-decode umount $TMPFS_MTPTS + log_action_end_msg $? + else + log_daemon_msg "Will now unmount temporary filesystems" + fstab-decode umount -v $TMPFS_MTPTS + log_end_msg $? + fi + fi + + # + # Deactivate swap + # + if [ "$VERBOSE" = no ] + then + log_action_begin_msg "Deactivating swap" + swapoff -a >/dev/null + log_action_end_msg $? + else + log_daemon_msg "Will now deactivate swap" + swapoff -a -v + log_end_msg $? + fi + + # + # Unmount local filesystems + # + if [ "$WEAK_MTPTS" ]; then + # Do not use -f umount option for WEAK_MTPTS + if [ "$VERBOSE" = no ] + then + log_action_begin_msg "Unmounting weak filesystems" + fstab-decode umount -r -d $WEAK_MTPTS + log_action_end_msg $? + else + log_daemon_msg "Will now unmount weak filesystems" + fstab-decode umount -v -r -d $WEAK_MTPTS + log_end_msg $? + fi + fi + if [ "$REG_MTPTS" ] + then + if [ "$VERBOSE" = no ] + then + log_action_begin_msg "Unmounting local filesystems" + fstab-decode umount -f -r -d $REG_MTPTS + log_action_end_msg $? + else + log_daemon_msg "Will now unmount local filesystems" + fstab-decode umount -f -v -r -d $REG_MTPTS + log_end_msg $? + fi + fi +} + +case "$1" in + start|status) + # No-op + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + do_stop + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/umountnfs.sh b/src/initscripts/etc/init.d/umountnfs.sh new file mode 100755 index 00000000..d33a3d5c --- /dev/null +++ b/src/initscripts/etc/init.d/umountnfs.sh @@ -0,0 +1,100 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: umountnfs +# Required-Start: +# Required-Stop: umountfs +# Should-Stop: $network $portmap nfs-common +# Default-Start: +# Default-Stop: 0 6 +# Short-Description: Unmount all network filesystems except the root fs. +# Description: Also unmounts all virtual filesystems (proc, +# devpts, usbfs, sysfs) that are not mounted at the +# top level. +### END INIT INFO + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +KERNEL="$(uname -s)" +RELEASE="$(uname -r)" +. /lib/init/vars.sh + +. /lib/lsb/init-functions + +case "${KERNEL}:${RELEASE}" in + Linux:[01].*|Linux:2.[01].*) + FLAGS="" + ;; + Linux:2.[23].*|Linux:2.4.?|Linux:2.4.?-*|Linux:2.4.10|Linux:2.4.10-*) + FLAGS="-f" + ;; + *) + FLAGS="-f -l" + ;; +esac + +do_stop () { + # Write a reboot record to /var/log/wtmp before unmounting + halt -w + + # Remove bootclean flag files (precaution against symlink attacks) + rm -f /tmp/.clean /run/.clean /run/lock/.clean + + # + # Make list of points to unmount in reverse order of their creation + # + + DIRS="" + while read -r DEV MTPT FSTYPE OPTS REST + do + case "$MTPT" in + /|/proc|/dev|/dev/pts|/dev/shm|/proc/*|/sys|/run|/run/*) + continue + ;; + esac + case "$FSTYPE" in + nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs|ceph) + DIRS="$MTPT $DIRS" + ;; + proc|procfs|linprocfs|devpts|usbfs|usbdevfs|sysfs) + DIRS="$MTPT $DIRS" + ;; + esac + case "$OPTS" in + _netdev|*,_netdev|_netdev,*|*,_netdev,*) + DIRS="$MTPT $DIRS" + ;; + esac + done < /etc/mtab + + if [ "$DIRS" ] + then + [ "$VERBOSE" = no ] || log_action_begin_msg "Unmounting remote and non-toplevel virtual filesystems" + fstab-decode umount $FLAGS $DIRS + ES=$? + [ "$VERBOSE" = no ] || log_action_end_msg $ES + fi + + # emit unmounted-remote-filesystems hook point so any upstart jobs + # that support remote filesystems can be stopped + if [ -x /sbin/initctl ]; then + initctl --quiet emit unmounted-remote-filesystems 2>/dev/null || true + fi +} + +case "$1" in + start|status) + # No-op + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop|"") + do_stop + ;; + *) + echo "Usage: umountnfs.sh [start|stop]" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/umountroot b/src/initscripts/etc/init.d/umountroot new file mode 100755 index 00000000..8b4c5bd1 --- /dev/null +++ b/src/initscripts/etc/init.d/umountroot @@ -0,0 +1,56 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: umountroot +# Required-Start: +# Required-Stop: +# Should-Stop: halt reboot kexec +# Default-Start: +# Default-Stop: 0 6 +# Short-Description: Mount the root and /usr filesystems read-only. +### END INIT INFO + +PATH=/sbin:/bin +. /lib/init/vars.sh + +. /lib/lsb/init-functions + +remount_ro () { + [ "$VERBOSE" = no ] || log_action_begin_msg "Mounting $1 filesystem read-only" + MOUNT_FORCE_OPT= + [ "$(uname -s)" = "GNU/kFreeBSD" ] && MOUNT_FORCE_OPT=-f + # This: + # mount -n -o remount,ro / + # will act on a bind mount of / if there is one. + # See #339023 and the comment in checkroot.sh + mount $MOUNT_FORCE_OPT -n -o remount,ro -t dummytype dummydev $2 2>/dev/null \ + || mount $MOUNT_FORCE_OPT -n -o remount,ro dummydev $2 2>/dev/null \ + || mount $MOUNT_FORCE_OPT -n -o remount,ro $2 + ES=$? + [ "$VERBOSE" = no ] || log_action_end_msg $ES +} + +do_stop () { + remount_ro root / + if mountpoint -q /usr; then + remount_ro /usr /usr + fi +} + +case "$1" in + start|status) + # No-op + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + stop) + do_stop + ;; + *) + echo "Usage: $0 start|stop" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/init.d/urandom b/src/initscripts/etc/init.d/urandom new file mode 100755 index 00000000..43f11861 --- /dev/null +++ b/src/initscripts/etc/init.d/urandom @@ -0,0 +1,106 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: urandom +# Required-Start: $local_fs $time +# Required-Stop: $local_fs +# Default-Start: S +# Default-Stop: 0 6 +# Short-Description: Save and restore random seed between restarts. +# Description: This script saves the random seed between restarts. +# It is called from the boot, halt and reboot scripts. +### END INIT INFO + +## Assumption 1: We assume $SAVEDFILE is a file (or a symlink +## to a file) that resides on a non-volatile medium that persists +## across reboots. +## Case 1a: Ideally, it is readable and writeable. Its is unshared, +## i.e. its contents are unique to this machine. It is protected so +## that its contents are not known to attackers. +## Case 1b: Less than ideally, it is read-only. Its contents are +## unique to this machine and not known to attackers. +SAVEDFILE=/var/lib/urandom/random-seed + +[ -c /dev/urandom ] || exit 0 + +PATH=/sbin:/bin +if ! POOLBYTES=$(( + ($(cat /proc/sys/kernel/random/poolsize 2>/dev/null) + 7) / 8 +)) ; then + POOLBYTES=512 +fi +. /lib/init/vars.sh + +. /lib/lsb/init-functions + +do_status () { + if [ -f $SAVEDFILE ] ; then + return 0 + else + return 4 + fi +} + +case "$1" in + start|"") + [ "$VERBOSE" = no ] || log_action_begin_msg "Initializing random number generator" + # Seed the RNG with date and time. + # This is helpful in the less-than-ideal case where $SAVEDFILE + # is read-only. + # The value of this is greatly reduced if $SAVEDFILE is missing, + # or its contents are shared machine-to-machine or known to + # attackers (since they might well know at what time this + # machine booted up). + ( + date +%s.%N + + # Load and then save $POOLBYTES bytes, + # which is the size of the entropy pool + if [ -f "$SAVEDFILE" ] + then + cat "$SAVEDFILE" + fi + # Redirect output of subshell (not individual commands) + # to cope with a misfeature in the FreeBSD (not Linux) + # /dev/random, where every superuser write/close causes + # an explicit reseed of the yarrow. + ) >/dev/urandom + + # Write a new seed into $SAVEDFILE because re-using a seed + # compromises security. Each time we re-seed, we want the + # seed to be as different as possible. + # Write it now, in case the machine crashes without doing + # an orderly shutdown. + # The write will fail if $SAVEDFILE is read-only, but it + # doesn't hurt to try. + umask 077 + dd if=/dev/urandom of=$SAVEDFILE bs=$POOLBYTES count=1 >/dev/null 2>&1 + ES=$? + umask 022 + [ "$VERBOSE" = no ] || log_action_end_msg $ES + ;; + stop) + # Carry a random seed from shut-down to start-up; + # Write it on shutdown, in case the one written at startup + # has been lost, snooped, or otherwise compromised. + # see documentation in linux/drivers/char/random.c + [ "$VERBOSE" = no ] || log_action_begin_msg "Saving random seed" + umask 077 + dd if=/dev/urandom of=$SAVEDFILE bs=$POOLBYTES count=1 >/dev/null 2>&1 + ES=$? + [ "$VERBOSE" = no ] || log_action_end_msg $ES + ;; + status) + do_status + exit $? + ;; + restart|reload|force-reload) + echo "Error: argument '$1' not supported" >&2 + exit 3 + ;; + *) + echo "Usage: urandom start|stop" >&2 + exit 3 + ;; +esac + +: diff --git a/src/initscripts/etc/network/if-up.d/mountnfs b/src/initscripts/etc/network/if-up.d/mountnfs new file mode 100644 index 00000000..78474a64 --- /dev/null +++ b/src/initscripts/etc/network/if-up.d/mountnfs @@ -0,0 +1,185 @@ +#! /bin/sh +# Description: Now that TCP/IP is configured, mount the NFS file +# systems in /etc/fstab if needed. If possible, +# start the portmapper before mounting (this is needed for +# Linux 2.1.x and up). +# +# Also mounts SMB filesystems now, so the name of +# this script is getting increasingly inaccurate. + +# Skip the mountnfs hook when being triggered by the networking SysV init +# script and instead use the systemd built-in mechanisms to mount remote +# file systems. +# This avoids a deadlock caused by the rpcbind SysV init script depending +# on $network and the $network LSB facility being provided by the networking +# SysV init script. +if [ -d /run/systemd/system ]; then + systemctl list-jobs | grep -q network.target && exit 0 +fi + +PATH=/sbin:/bin +. /lib/init/vars.sh + +. /lib/lsb/init-functions +. /lib/init/mount-functions.sh + +set_env() { + # Read through fstab line by line. If it is NFS, set the flag + # for mounting NFS file systems. If any NFS partition is found + # and it not mounted with the nolock option, we start the + # portmapper. + # + # If any sec={krb5,krb5i,krb5p} option is given, or any of the + # file systems are nfs4, we'll need to start rpc.gssd and/or + # rpc.idmapd too; we'll leave that to nfs-common. + + start_nfs=no + NETFS="" + NETDEV="" + for file in "$(eval ls $(fstab_files))"; do + if [ -f "$file" ]; then + while read DEV MTPT FSTYPE OPTS REST; do + case "$DEV" in + ""|\#*) + continue + ;; + esac + case "$OPTS" in + noauto|*,noauto|noauto,*|*,noauto,*) + continue + ;; + _netdev|*,_netdev|_netdev,*|*,_netdev,*) + NETDEV=yes + ;; + esac + case "$FSTYPE" in + nfs) + # NFS filsystems normally + # require statd and + # portmap. However, if nolock + # is set, portmap and statd + # are not required for this + # file system. + case "$OPTS" in + nolock|*,nolock|nolock,*|*,nolock,*) + # no action + ;; + *) + start_nfs=yes + ;; + esac + + # However, Kerberos requires + # gssd, so start nfs-common + # anyway. + case "$OPTS" in + sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*) + start_nfs=yes + ;; + esac + ;; + nfs4) + # NFSv4 requires idmapd, so + # start nfs-common no matter + # what the options are. + start_nfs=yes + ;; + smbfs|cifs|coda|ncp|ncpfs|ocfs2|gfs|ceph) + ;; + *) + FSTYPE= + ;; + esac + if [ "$FSTYPE" ]; then + case "$NETFS" in + $FSTYPE|*,$FSTYPE|$FSTYPE,*|*,$FSTYPE,*) + ;; + *) + NETFS="$NETFS${NETFS:+,}$FSTYPE" + ;; + esac + fi + done < "$file" + fi + done +} + +do_start() { + # + # Initialize nfs-common (which starts rpc.statd, rpc.gssd + # and/or rpc.idmapd, and loads the right kernel modules if + # applicable) if we use Kerberos and/or NFSv4 mounts. + # + if [ "$start_nfs" = yes ] && [ -x /etc/init.d/nfs-common ] + then + [ -x /etc/init.d/portmap ] && /etc/init.d/portmap start + [ -x /etc/init.d/rpcbind ] && /etc/init.d/rpcbind start + /etc/init.d/nfs-common start + fi + + pre_mountall + if [ "$NETFS" ] + then + mount -a -t$NETFS + fi + if [ "$NETDEV" ]; then + mount -a -O _netdev + fi + post_mountall +} + +exit_unless_last_interface() { + ifaces="$(ifquery --list)" + for i in $ifaces ; do + if [ "$i" = "lo" ]; then + continue + fi + if ! ifquery --state $i >/dev/null ; then + msg="if-up.d/mountnfs[$IFACE]: waiting for interface $i before doing NFS mounts" + log_warning_msg "$msg" + exit 0 + fi + done +} + +# Using 'no !=' instead of 'yes =' to make sure async nfs mounting is +# the default even without a value in /etc/default/rcS +set_env +# Exit imediately and do not claim to wait for the last interface if +# no network file systems are listed in /etc/fstab. +if [ "$start_nfs" = "no" ] && [ ! "$NETFS" ] && [ ! "$NETDEV" ]; then + exit 0 +fi + +if [ no != "$ASYNCMOUNTNFS" ]; then + # Not for loopback! + [ "$IFACE" != "lo" ] || exit 0 + + [ "$ADDRFAM" = "inet" ] || [ "$ADDRFAM" = "inet6" ] || exit 0 + + # Lock around this otherwise insanity may occur + mkdir /var/run/network 2>/dev/null || true + + # Wait until all auto interfaces are up before attemting to mount + # network file systems. + exit_unless_last_interface + + if mkdir /var/run/network/mountnfs 2>/dev/null ; then + : + else + msg="if-up.d/mountnfs[$IFACE]: lock /var/run/network/mountnfs exist, not mounting" + log_failure_msg "$msg" + # Log if /usr/ is mounted + [ -x /usr/bin/logger ] && /usr/bin/logger -t "if-up.d/mountnfs[$IFACE]" "$msg" + exit 0 + fi + + on_exit() { + # Clean up lock when script exits, even if it is interrupted + rmdir /var/run/network/mountnfs 2>/dev/null || exit 0 + } + trap on_exit EXIT # Enable emergency handler + do_start +elif [ yes = "$FROMINITD" ] ; then + do_start +fi diff --git a/src/initscripts/lib/init/bootclean.sh b/src/initscripts/lib/init/bootclean.sh new file mode 100644 index 00000000..196e5ee4 --- /dev/null +++ b/src/initscripts/lib/init/bootclean.sh @@ -0,0 +1,181 @@ +# bootclean +# +# Clean /tmp, /run and /var/lock if not mounted as tmpfs +# +# DO NOT RUN AFTER S:55bootmisc.sh and do not run this script directly +# in runlevel S. Instead write an initscript to call it. +# + +. /lib/init/vars.sh +. /lib/lsb/init-functions + +# Should be called outside verbose message block +mkflagfile() +{ + # Prevent symlink attack (See #264234.) + [ -L "$1" ] && log_warning_msg "bootclean: Deleting symbolic link '$1'." + rm -f "$1" || { log_failure_msg "bootclean: Failure deleting '$1'." ; return 1 ; } + # No user processes should be running, so no one should be + # able to introduce a symlink here. As an extra precaution, + # set noclobber. + set -o noclobber + :> "$1" || { log_failure_msg "bootclean: Failure creating '$1'." ; return 1 ; } + return 0 +} + +checkflagfile() +{ + if [ -f $1/.clean ] + then + which stat >/dev/null 2>&1 && cleanuid="$(stat -c %u $1/.clean)" + # Poor's man stat %u, since stat (and /usr) might not + # be available in some bootup stages + [ "$cleanuid" ] || cleanuid="$(find $1/.clean -printf %U)" + [ "$cleanuid" ] || { log_failure_msg "bootclean: Could not stat '$1/.clean'." ; return 1 ; } + if [ "$cleanuid" -ne 0 ] + then + rm -f $1/.clean || { log_failure_msg "bootclean: Could not delete '$1/.clean'." ; return 1 ; } + fi + fi + return 0 +} + + report_err() + { + dir="$1" + if [ "$VERBOSE" = no ] + then + log_failure_msg "bootclean: Failure cleaning ${dir}." + else + log_action_end_msg 1 "bootclean: Failure cleaning ${dir}" + fi + } + +clean_tmp() { + # Does not exist + [ -d /tmp ] || return 1 + # tmpfs does not require cleaning + [ -f /tmp/.tmpfs ] && return 0 + # Can clean? + checkflagfile /tmp || return 0 + # Already cleaned + [ -f /tmp/.clean ] && return 0 + # Can't clean yet? + which find >/dev/null 2>&1 || return 1 + + cd /tmp || { log_failure_msg "bootclean: Could not cd to /tmp." ; return 1 ; } + + # + # Only clean out /tmp if it is world-writable. This ensures + # it really is a/the temp directory we're cleaning. + # + [ "$(find . -maxdepth 0 -perm -002)" = "." ] || return 0 + + if [ ! "$TMPTIME" ] + then + log_warning_msg "Using default TMPTIME 0." + TMPTIME=0 + fi + + [ "$VERBOSE" = no ] || log_action_begin_msg "Cleaning /tmp" + + # + # Remove regardless of TMPTIME setting + # + rm -f .X*-lock + + # + # Don't clean remaining files if TMPTIME is negative or 'infinite' + # + case "$TMPTIME" in + -*|infinite|infinity) + [ "$VERBOSE" = no ] || log_action_end_msg 0 "skipped" + return 0 + ;; + esac + + # + # Wipe /tmp, excluding system files, but including lost+found + # + # If TMPTIME is set to 0, we do not use any ctime expression + # at all, so we can also delete files with timestamps + # in the future! + # + if [ "$TMPTIME" = 0 ] + then + TEXPR="" + DEXPR="" + else + TEXPR="-mtime +$TMPTIME -ctime +$TMPTIME -atime +$TMPTIME" + DEXPR="-mtime +$TMPTIME -ctime +$TMPTIME" + fi + + EXCEPT='! -name . + ! ( -path ./lost+found -uid 0 ) + ! ( -path ./quota.user -uid 0 ) + ! ( -path ./aquota.user -uid 0 ) + ! ( -path ./quota.group -uid 0 ) + ! ( -path ./aquota.group -uid 0 ) + ! ( -path ./.journal -uid 0 ) + ! ( -path ./.clean -uid 0 ) + ! ( -path './...security*' -uid 0 )' + + mkflagfile /tmp/.clean || return 1 + + # + # First remove all old files... + # + find . -depth -xdev $TEXPR $EXCEPT ! -type d -delete \ + || { report_err "/tmp"; return 1 ; } + + # + # ...and then all empty directories + # + find . -depth -xdev $DEXPR $EXCEPT -type d -empty -delete \ + || { report_err "/tmp"; return 1 ; } + + [ "$VERBOSE" = no ] || log_action_end_msg 0 + log_progress_msg "/tmp" + return 0 +} + +clean() { + dir="$1" + findopts="$2" + + # Does not exist + [ -d "$dir" ] || return 1 + # tmpfs does not require cleaning + [ -f "$dir/.tmpfs" ] && return 0 + # Can clean? + checkflagfile "$dir" || return 0 + # Already cleaned + [ -f "${dir}/.clean" ] && return 0 + # Can't clean yet? + which find >/dev/null 2>&1 || return 1 + + cd "$dir" || { log_action_end_msg 1 "bootclean: Could not cd to ${dir}." ; return 1 ; } + + [ "$VERBOSE" = no ] || log_action_begin_msg "Cleaning $dir" + + find . $findopts -delete \ + || { report_err "$dir"; return 1 ; } + [ "$VERBOSE" = no ] || log_action_end_msg 0 + mkflagfile "${dir}/.clean" || return 1 + log_progress_msg "$dir" + return 0 +} + +clean_all() +{ + which find >/dev/null 2>&1 || return 0 + log_begin_msg "Cleaning up temporary files..." + ES=0 + clean_tmp || ES=1 + clean /run "! -xtype d ! -name utmp ! -name innd.pid" || ES=1 + clean /run/lock "! -type d" || ES=1 + clean /run/shm "! -type d" || ES=1 + log_end_msg $ES + return $ES +} + diff --git a/src/initscripts/lib/init/mount-functions.sh b/src/initscripts/lib/init/mount-functions.sh new file mode 100644 index 00000000..6ddca0d6 --- /dev/null +++ b/src/initscripts/lib/init/mount-functions.sh @@ -0,0 +1,708 @@ +# +# Functions used by several mount* scripts in initscripts package +# +# Sourcer must source /lib/lsb/init-functions.sh + +# List available fstab files, including any files in /etc/fstab.d. +# This looks ugly, but we can't use find and it's safer than globbing. +fstab_files() +{ + echo /etc/fstab + if [ -d /etc/fstab.d ]; then + ls -1 /etc/fstab.d | grep '\.fstab$' | sed -e 's;^;/etc/fstab.d/;' + fi +} + +# $1: directory +is_empty_dir() { + for FILE in $1/* $1/.* + do + case "$FILE" in + "$1/.*") return 0 ;; + "$1/*"|"$1/."|"$1/..") continue ;; + *) return 1 ;; + esac + done + return 0 +} + + +selinux_enabled () { + which selinuxenabled >/dev/null 2>&1 && selinuxenabled +} + +# Read /etc/fstab, looking for: +# 1) The root filesystem, resolving LABEL=*|UUID=* entries to the +# device node, +# 2) Swap that is on a md device or a file that may be on a md +# device, +_read_fstab () { + echo "fstabroot=/dev/root" + echo "rootdev=none" + echo "roottype=none" + echo "rootopts=defaults" + echo "rootmode=rw" + echo "rootcheck=no" + echo "swap_on_lv=no" + echo "swap_on_file=no" + + fstab_files | while read file; do + if [ -f "$file" ]; then + while read DEV MTPT FSTYPE OPTS DUMP PASS JUNK; do + case "$DEV" in + ""|\#*) + continue; + ;; + /dev/mapper/*) + [ "$FSTYPE" = "swap" ] && echo swap_on_lv=yes + ;; + /dev/*) + ;; + LABEL=*|UUID=*) + if [ "$MTPT" = "/" ] && [ -x /sbin/findfs ] + then + DEV="$(findfs "$DEV")" + fi + ;; + /*) + [ "$FSTYPE" = "swap" ] && echo swap_on_file=yes + ;; + *) + ;; + esac + [ "$MTPT" != "/" ] && continue + echo rootdev=\"$DEV\" + echo fstabroot=\"$DEV\" + echo rootopts=\"$OPTS\" + echo roottype=\"$FSTYPE\" + ( [ "$PASS" != 0 ] && [ "$PASS" != "" ] ) && echo rootcheck=yes + ( [ "$FSTYPE" = "nfs" ] || [ "$FSTYPE" = "nfs4" ] ) && echo rootcheck=no + case "$OPTS" in + ro|ro,*|*,ro|*,ro,*) + echo rootmode=ro + ;; + esac + done < "$file" + fi + done +} + +# Read /etc/fstab, looking for: +# 1) The root filesystem, resolving LABEL=*|UUID=* entries to the +# device node, +# 2) Swap that is on a md device or a file that may be on a md +# device, + +read_fstab () { + eval "$(_read_fstab)" +} + +# Find a specific fstab entry +# $1=mountpoint +# $2=fstype (optional) +_read_fstab_entry () { + # Not found by default. + echo "MNT_FSNAME=" + echo "MNT_DIR=" + echo "MNT_TYPE=" + echo "MNT_OPTS=" + echo "MNT_FREQ=" + echo "MNT_PASS=" + + fstab_files | while read file; do + if [ -f "$file" ]; then + while read MNT_FSNAME MNT_DIR MNT_TYPE MNT_OPTS MNT_FREQ MNT_PASS MNT_JUNK; do + case "$MNT_FSNAME" in + ""|\#*) + continue; + ;; + esac + if [ "$MNT_DIR" = "$1" ]; then + if [ -n "$2" ]; then + [ "$MNT_TYPE" = "$2" ] || continue; + fi + echo "MNT_FSNAME=$MNT_FSNAME" + echo "MNT_DIR=$MNT_DIR" + echo "MNT_TYPE=$MNT_TYPE" + echo "MNT_OPTS=$MNT_OPTS" + echo "MNT_FREQ=$MNT_FREQ" + echo "MNT_PASS=$MNT_PASS" + break 2 + fi + MNT_DIR="" + done < "$file" + fi + done +} + +# Find a specific fstab entry +# $1=mountpoint +# $2=fstype (optional) +# returns 0 on success, 1 on failure (not found or no fstab) +read_fstab_entry () { + eval "$(_read_fstab_entry "$1" "$2")" + + # Not found by default. + found=1 + if [ "$1" = "$MNT_DIR" ]; then + found=0 + fi + + return $found +} + +# Mount kernel and device file systems. +# $1: mount mode (mount, remount) +# $2: file system type +# $3: alternative file system type (or empty string if none) +# $4: mount point +# $5: mount device name +# $6... : extra mount program options +domount () { + MOUNTMODE="$1" + PRIFSTYPE="$2" + ALTFSTYPE="$3" + MTPT="$4" + DEVNAME="$5" + CALLER_OPTS="$6" + + KERNEL="$(uname -s)" + # Figure out filesystem type from primary and alternative type + FSTYPE= + # Filesystem-specific mount options + FS_OPTS= + # Mount options from fstab + FSTAB_OPTS= + + if [ "$MOUNTMODE" = remount ] ; then + case "$KERNEL" in + *FreeBSD) + case "$PRIFSTYPE" in + proc|tmpfs|sysfs) + # can't be remounted + return 0 + ;; + esac + ;; + esac + fi + + if [ "$PRIFSTYPE" = proc ]; then + case "$KERNEL" in + Linux) FSTYPE=proc ;; + GNU) FSTYPE=proc; FS_OPTS="-ocompatible" ;; + *FreeBSD) FSTYPE=linprocfs ;; + *) FSTYPE=procfs ;; + esac + elif [ "$PRIFSTYPE" = bind ]; then + case "$KERNEL" in + Linux) FSTYPE="$DEVNAME"; FS_OPTS="-obind" ;; + *FreeBSD) FSTYPE=nullfs ;; + GNU) FSTYPE=firmlink ;; + *) FSTYPE=none ;; + esac + elif [ "$PRIFSTYPE" = tmpfs ]; then + # always accept tmpfs, to mount /run before /proc + case "$KERNEL" in + *) FSTYPE=$PRIFSTYPE ;; + esac + elif grep -E -qs "$PRIFSTYPE\$" /proc/filesystems; then + FSTYPE=$PRIFSTYPE + elif grep -E -qs "$ALTFSTYPE\$" /proc/filesystems; then + FSTYPE=$ALTFSTYPE + fi + + # Filesystem not supported by kernel + if [ ! "$FSTYPE" ]; then + if [ "$ALTFSTYPE" ]; then + log_warning_msg "Filesystem types '$PRIFSTYPE' and '$ALTFSTYPE' are not supported. Skipping mount." + else + log_warning_msg "Filesystem type '$PRIFSTYPE' is not supported. Skipping mount." + fi + return + fi + + # We give file system type as device name if not specified as + # an argument + if [ -z "$DEVNAME" ] ; then + DEVNAME=$FSTYPE + fi + + # Get the mount options from /etc/fstab + if read_fstab_entry "$MTPT" "$FSTYPE"; then + case "$MNT_OPTS" in + noauto|*,noauto|noauto,*|*,noauto,*) + return + ;; + ?*) + FSTAB_OPTS="-o$MNT_OPTS" + ;; + esac + fi + + if [ ! -d "$MTPT" ] + then + log_warning_msg "Mount point '$MTPT' does not exist. Skipping mount." + return + fi + + if [ "$MOUNTMODE" = "mount_noupdate" ]; then + MOUNTFLAGS="-n" + MOUNTMODE=mount + fi + if [ "$MOUNTMODE" = "remount_noupdate" ]; then + MOUNTFLAGS="-n" + MOUNTMODE=remount + fi + + case "$MOUNTMODE" in + mount) + if mountpoint -q "$MTPT"; then + # Already mounted, probably moved from the + # initramfs, so remount with the + # user-specified mount options later on. + : + else + if [ "$VERBOSE" != "no" ]; then + is_empty_dir "$MTPT" >/dev/null 2>&1 || log_warning_msg "Files under mount point '$MTPT' will be hidden." + fi + mount $MOUNTFLAGS -t $FSTYPE $CALLER_OPTS $FSTAB_OPTS $FS_OPTS $DEVNAME $MTPT + if [ "$FSTYPE" = "tmpfs" -a -x /sbin/restorecon ]; then + /sbin/restorecon $MTPT + fi + fi + ;; + remount) + if mountpoint -q "$MTPT"; then + # Remount with user-specified mount options + mount $MOUNTFLAGS -oremount $CALLER_OPTS $FSTAB_OPTS $MTPT + fi + ;; + esac +} + +# +# Preserve /var/run and /var/lock mountpoints +# +pre_mountall () +{ + : +} + +# If the device/inode are the same, a bind mount already exists or the +# transition is complete, so set up is not required. Otherwise bind +# mount $SRC on $DEST. +bind_mount () +{ + SRC=$1 + DEST=$2 + + FSTYPE="" + OPTS="" + + ssrc="$(/usr/bin/stat -L --format="%d %i" "$SRC" 2>/dev/null || :)" + sdest="$(/usr/bin/stat -L --format="%d %i" "$DEST" 2>/dev/null || :)" + + case "$(uname -s)" in + Linux) FSTYPE=$SRC; OPTS="-orw -obind" ;; + *FreeBSD) FSTYPE=nullfs; OPTS="-orw" ;; + GNU) FSTYPE=firmlink ;; + *) FSTYPE=none ;; + esac + + # Bind mount $SRC on $DEST + if [ -n "$ssrc" ] && [ "$ssrc" != "$sdest" ]; then + [ -d "$DEST" ] || mkdir "$DEST" + [ -x /sbin/restorecon ] && /sbin/restorecon "$DEST" + if mount -t $FSTYPE "$SRC" "$DEST" $OPTS ; then + echo "Please reboot to complete migration to tmpfs-based /run" > "${DEST}/.run-transition" + return 0 + fi + return 1 + fi + + return 0 +} + +# +# Migrate a directory to /run and create compatibility symlink or bind +# mount. +# +run_migrate () +{ + OLD=$1 + RUN=$2 + + KERNEL="$(uname -s)" + OPTS="" + case "$KERNEL" in + Linux) FSTYPE=none OPTS="-orw -obind";; + *FreeBSD) FSTYPE=nullfs OPTS="-orw" ;; + GNU) FSTYPE=firmlink ;; + *) FSTYPE=none ;; + esac + + # Create absolute symlink if not already present. This is to + # upgrade from older versions which created relative links, + # which are not permitted in policy between top-level + # directories. + if [ -L "$OLD" ] && [ "$(readlink "$OLD")" != "$RUN" ]; then + rm -f "$OLD" + ln -fs "$RUN" "$OLD" + [ -x /sbin/restorecon ] && /sbin/restorecon "$OLD" + fi + + # If both directories are the same, we don't need to do + # anything further. + sold="$(/usr/bin/stat -L --format="%d %i" "$OLD" 2>/dev/null || :)" + srun="$(/usr/bin/stat -L --format="%d %i" "$RUN" 2>/dev/null || :)" + if [ -n "$sold" ] && [ "$sold" = "$srun" ]; then + return 0 + fi + + # Try to remove if a directory. Note this is safe because the + # system is not yet fully up, and nothing is allowed to use + # them yet. If the user explicitly mounted a filesystem here, + # it will be cleaned out, but this would happen later on when + # bootclean runs in any case. + if [ ! -L "$OLD" ] && [ -d "$OLD" ] ; then + rm -fr "$OLD" 2>/dev/null || true + fi + + # If removal failed (directory still exists), set up bind mount. + if [ ! -L "$OLD" ] && [ -d "$OLD" ] ; then + if [ "$OLD" != "/tmp" ]; then + log_warning_msg "Filesystem mounted on $OLD; setting up compatibility bind mount." + log_warning_msg "Please remove this mount from /etc/fstab; it is no longer needed, and it is preventing completion of the transition to $RUN." + fi + mount -t $FSTYPE "$RUN" "$OLD" $OPTS + else + # Create symlink if not already present. + if [ -L "$OLD" ] && [ "$(readlink "$OLD")" != "$RUN" ]; then + : + else + rm -f "$OLD" + ln -fs "$RUN" "$OLD" + [ -x /sbin/restorecon ] && /sbin/restorecon "$OLD" + fi + fi + + return 0 +} + +# +# Migrate /etc/mtab to a compatibility symlink +# +mtab_migrate () +{ + # Don't symlink if /proc/mounts does not exist. + if [ ! -r "/proc/mounts" ]; then + return 1 + fi + + # Create symlink if not already present. + if [ -L "/etc/mtab" ] && [ "$(readlink "/etc/mtab")" = "/proc/mounts" ]; then + : + else + log_warning_msg "Creating compatibility symlink from /etc/mtab to /proc/mounts." + + rm -f "/etc/mtab" || return 1 + ln -fs "/proc/mounts" "/etc/mtab" || return 1 + [ -x /sbin/restorecon ] && /sbin/restorecon "/etc/mtab" + fi + + return 0 +} + +# +# For compatibility, create /var/run and /var/lock symlinks to /run +# and /run/lock, respectively. +# +post_mountall () +{ + # /var/run and /var/lock are now /run and /run/lock, + # respectively. Cope with filesystems being deliberately + # mounted on /var/run and /var/lock. We will create bind + # mounts from /run and /run/lock to /var/run and /var/lock if + # we can't remove the /var/run and /var/lock directories, or + # else simply create symlinks. For example, in the case that + # the user has explicitly mounted filesystems on /var/run or + # /var/lock, we bind mount over the top of them. Where no + # filesystems are mounted, we replace the directory with a + # symlink where possible. + + # Cater for systems which have a symlink from /run to /var/run + # for whatever reason. Remove the symlink and replace with a + # directory. The migration logic will then take care of the + # rest. Note that it will take a second boot to fully + # migrate; it should only ever be needed on broken systems. + RAMSHM_ON_DEV_SHM="no" + if read_fstab_entry "/dev/shm"; then + RAMSHM_ON_DEV_SHM="yes" + fi + if read_fstab_entry "/run/shm"; then + RAMSHM_ON_DEV_SHM="no" + fi + + if [ -L /run ]; then + if [ "$(readlink /run)" = "/var/run" ]; then + rm -f /run + mkdir /run + fi + if bind_mount /var/run /run; then + bind_mount /var/lock /run/lock + if [ yes = "$RAMSHM_ON_DEV_SHM" ]; then + run_migrate /run/shm /dev/shm + else + run_migrate /dev/shm /run/shm + fi + fi + else + run_migrate /var/run /run + run_migrate /var/lock /run/lock + if [ yes = "$RAMSHM_ON_DEV_SHM" ]; then + run_migrate /run/shm /dev/shm + else + run_migrate /dev/shm /run/shm + fi + fi +} + +# Mount /run +mount_run () +{ + MNTMODE="$1" + KERNEL="$(uname -s)" + + if [ "$MNTMODE" = remount ] ; then + case "$KERNEL" in + *FreeBSD) + # tmpfs can't be remounted + return 0 + ;; + esac + fi + + # Needed to determine if root is being mounted read-only. + read_fstab + + # + # Get some writable area available before the root is checked + # and remounted. Note that /run may be handed over from the + # initramfs. + # + + # If /run/shm is separately mounted, /run can be safely mounted noexec. + RUNEXEC= + if [ yes = "$RAMSHM" ] || read_fstab_entry /run/shm tmpfs; then + RUNEXEC=',noexec' + fi + # TODO: Add -onodev once checkroot no longer creates a device node. + domount "$MNTMODE" tmpfs shmfs /run tmpfs "-onosuid$RUNEXEC$RUN_OPT" + [ -x /sbin/restorecon ] && /sbin/restorecon -r /run + + # Make pidfile omit directory for sendsigs + [ -d /run/sendsigs.omit.d ] || mkdir --mode=755 /run/sendsigs.omit.d/ + + # Make sure we don't get cleaned + touch /run/.tmpfs +} + +# Mount /run/lock +mount_lock () +{ + MNTMODE="$1" + KERNEL="$(uname -s)" + + if [ "$MNTMODE" = remount ] ; then + case "$KERNEL" in + *FreeBSD) + # tmpfs can't be remounted + return 0 + ;; + esac + fi + + # Make lock directory as the replacement for /var/lock + [ -d /run/lock ] || mkdir --mode=755 /run/lock + [ -x /sbin/restorecon ] && /sbin/restorecon /run/lock + + # Now check if there's an entry in /etc/fstab. If there is, + # it overrides the existing RAMLOCK setting. + if read_fstab_entry /run/lock; then + if [ "$MNT_TYPE" = "tmpfs" ] ; then + RAMLOCK="yes" + else + RAMLOCK="no" + fi + fi + + NODEV="nodev," + case "$KERNEL" in + *FreeBSD|GNU) NODEV="" ;; + esac + + # Mount /run/lock as tmpfs if enabled. This prevents user DoS + # of /run by filling /run/lock at the expense of using an + # additional tmpfs. + if [ yes = "$RAMLOCK" ]; then + domount "$MNTMODE" tmpfs shmfs /run/lock tmpfs "-o${NODEV}noexec,nosuid$LOCK_OPT" + # Make sure we don't get cleaned + touch /run/lock/.tmpfs + else + chmod "$LOCK_MODE" /run/lock + fi +} + +# Mount /run/shm +mount_shm () +{ + MNTMODE="$1" + + RAMSHM_ON_DEV_SHM="no" + SHMDIR="/run/shm" + if read_fstab_entry "/dev/shm"; then + if [ "$MNTMODE" = "mount_noupdate" ]; then + log_warning_msg "Warning: fstab entry for /dev/shm; should probably be for /run/shm unless working around a bug in the Oracle database" + fi + SHMDIR="/dev/shm" + RAMSHM_ON_DEV_SHM="yes" + fi + if read_fstab_entry "/run/shm"; then + if [ "$MNTMODE" = "mount_noupdate" ] && [ "$RAMSHM_ON_DEV_SHM" = "yes" ]; then + log_warning_msg "Warning: fstab entries for both /dev/shm and /run/shm found; only /run/shm will be used" + fi + + SHMDIR="/run/shm" + RAMSHM_ON_DEV_SHM="no" + fi + + if [ ! -d "$SHMDIR" ] + then + mkdir --mode=755 "$SHMDIR" + [ -x /sbin/restorecon ] && /sbin/restorecon "$SHMDIR" + fi + + # Now check if there's an entry in /etc/fstab. If there is, + # it overrides the existing RAMSHM setting. + if read_fstab_entry "$SHMDIR"; then + if [ "$MNT_TYPE" = "tmpfs" ] ; then + RAMSHM="yes" + else + RAMSHM="no" + fi + fi + + KERNEL="$(uname -s)" + NODEV="nodev," + case "$KERNEL" in + *FreeBSD|GNU) NODEV="" ;; + esac + + if [ yes = "$RAMSHM" ]; then + domount "$MNTMODE" tmpfs shmfs "$SHMDIR" tmpfs "-onosuid,${NODEV}noexec$SHM_OPT" + # Make sure we don't get cleaned + touch "$SHMDIR"/.tmpfs + else + chmod "$SHM_MODE" "$SHMDIR" + fi + + # Migrate early, so /dev/shm is available from the start + if [ "$MNTMODE" = mount_noupdate ] || [ "$MNTMODE" = mount ]; then + if [ yes = "$RAMSHM_ON_DEV_SHM" ]; then + run_migrate /run/shm /dev/shm + else + run_migrate /dev/shm /run/shm + fi + fi +} + +# +# Mount /tmp +# +mount_tmp () +{ + MNTMODE="$1" + + # If /tmp is a symlink, make sure the linked-to directory exists. + if [ -L /tmp ] && [ ! -d /tmp ]; then + TMPPATH="$(readlink /tmp)" + mkdir -p --mode=755 "$TMPPATH" + [ -x /sbin/restorecon ] && /sbin/restorecon "$TMPPATH" + fi + + # Disable RAMTMP if there's 64MiB RAM or less. May be + # re-enabled by overflow or read only root, below. + RAM_SIZE="$(ram_size)" + if [ -n "$RAM_SIZE" ] && [ "$((RAM_SIZE <= 65536))" = "1" ]; then + RAMTMP=no + fi + + # If root is read only, default to mounting a tmpfs on /tmp, + # unless one is due to be mounted from fstab. + if [ "$RAMTMP" != "yes" ] && [ rw != "$rootmode" ]; then + # If there's an entry in fstab for /tmp (any + # filesystem type, not just tmpfs), then we don't need + # a tmpfs on /tmp by default. + if read_fstab_entry /tmp ; then + : + else + log_warning_msg "Root filesystem is read-only; mounting tmpfs on /tmp" + RAMTMP="yes" + fi + fi + + if [ "$RAMTMP" != "yes" ] && need_overflow_tmp; then + # If there's an entry in fstab for /tmp (any + # filesystem type, not just tmpfs), then we don't need + # a tmpfs on /tmp by default. + if read_fstab_entry /tmp ; then + : + else + log_warning_msg "Root filesystem has insufficient free space; mounting tmpfs on /tmp" + RAMTMP="yes" + fi + fi + + # Now check if there's an entry in /etc/fstab. If there is, + # it overrides all the above settings. + if read_fstab_entry /tmp; then + if [ "$MNT_TYPE" = "tmpfs" ] ; then + RAMTMP="yes" + else + RAMTMP="no" + fi + fi + + KERNEL="$(uname -s)" + NODEV="nodev," + case "$KERNEL" in + *FreeBSD|GNU) NODEV="" ;; + esac + + # Mount /tmp as tmpfs if enabled. + if [ yes = "$RAMTMP" ]; then + domount "$MNTMODE" tmpfs shmfs /tmp tmpfs "-o${NODEV}nosuid$TMP_OPT" + # Make sure we don't get cleaned + touch /tmp/.tmpfs + else + # When root is still read only, this will fail. + if [ mount_noupdate != "$MNTMODE" ] && [ rw = "$rootmode" ]; then + chmod "$TMP_MODE" /tmp + fi + fi +} + +is_fastboot_active() { + if [ -f /fastboot ] ; then + return 0 + fi + for cmd in $(cat /proc/cmdline) ; do + case "$cmd" in + fastboot) + return 0 + ;; + esac + done + return 1 +} diff --git a/src/initscripts/lib/init/swap-functions.sh b/src/initscripts/lib/init/swap-functions.sh new file mode 100644 index 00000000..48a2326e --- /dev/null +++ b/src/initscripts/lib/init/swap-functions.sh @@ -0,0 +1,28 @@ +# +# Functions that assist in turning on swap. +# + +# $1 is a string used to log the type of swap expected to be activated +swaponagain() { + # + # Execute swapon command again to pick up any swap partitions + # that have shown up since the last swapon. + # + # Ignore 255 status due to swap already being enabled + # + if [ "$NOSWAP" = yes ] + then + [ "$VERBOSE" = no ] || log_warning_msg "Not activating swap as requested via bootoption noswap." + else + if [ "$VERBOSE" = no ] + then + log_action_begin_msg "Activating $1 swap" + swapon -a -e 2>/dev/null || : # Stifle "Device or resource busy" + log_action_end_msg 0 + else + log_daemon_msg "Will now activate $1 swap" + swapon -a -e -v + log_action_end_msg $? + fi + fi +} diff --git a/src/initscripts/lib/init/tmpfs.sh b/src/initscripts/lib/init/tmpfs.sh new file mode 100644 index 00000000..117c342d --- /dev/null +++ b/src/initscripts/lib/init/tmpfs.sh @@ -0,0 +1,133 @@ +# +# Set tmpfs vars +# + + +# Get size of physical RAM in kiB +ram_size () +{ + [ -r /proc/meminfo ] && \ + grep MemTotal /proc/meminfo | \ + sed -e 's;.*[[:space:]]\([0-9][0-9]*\)[[:space:]]kB.*;\1;' || : +} + +# Get size of swap space in kiB +swap_size () +{ + [ -r /proc/meminfo ] && \ + grep SwapTotal /proc/meminfo | \ + sed -e 's;.*[[:space:]]\([0-9][0-9]*\)[[:space:]]kB.*;\1;' || : +} + +# +# Get total VM size in kiB. Prints nothing if no RAM and/or swap was +# detectable. +# +vm_size () +{ + RAM=$(ram_size) + SWAP=$(swap_size) + + RAM="${RAM:=0}" + SWAP="${SWAP:=0}" + + echo $((RAM + SWAP)) + return 0; +} + +# +# Get size of tmpfs. If the size is absolute or a percentage, return +# that unchanged. If suffixed with "%VM", return the absolute size as +# a percentage of RAM and swap combined. If no swap was available, +# return as a percentage (tmpfs will use a percentage of RAM only). +# +tmpfs_size_vm () +{ +# Handle the no-swap case here, i.e. core memory only. Also handle no +# memory either (no proc) by just returning the original value. + RET="$1" + VMTOTAL="$(vm_size)" + VMPCT="${RET%\%VM}" + if [ "$VMPCT" != "$RET" ]; then + if [ -n "$VMTOTAL" ]; then + RET=$(((VMTOTAL / 100) * VMPCT)) + RET="${RET}k" + else + RET="${VMPCT}%" + fi + fi + echo "$RET" +} + +# Free space on /tmp in kiB. +tmp_free_space () +{ + LC_ALL=C df -kP /tmp | grep -v Filesystem | sed -e 's;^[^[:space:]][^[:space:]]*[[:space:]][[:space:]]*[0-9][0-9]*[[:space:]][[:space:]]*[0-9][0-9]*[[:space:]][[:space:]]*\([0-9][0-9]*\)[[:space:]][[:space:]]*.*$;\1;' +} + +# Check if an emergency tmpfs is needed +need_overflow_tmp () +{ + [ "$VERBOSE" != no ] && log_action_begin_msg "Checking minimum space in /tmp" + + ROOT_FREE_SPACE=$(tmp_free_space) + [ "$VERBOSE" != no ] && log_action_end_msg 0 + if [ -n "$ROOT_FREE_SPACE" ] && [ -n "$TMP_OVERFLOW_LIMIT" ] \ + && [ $((ROOT_FREE_SPACE < TMP_OVERFLOW_LIMIT)) = "1" ]; then + return 0 + fi + return 1 +} + +# Set defaults for /etc/default/tmpfs, in case any options are +# commented out which are needed for booting. So that an empty or +# outdated file missing newer options works correctly, set the default +# values here. + +RAMLOCK=yes +# These might be overridden by /etc/default/rcS +if [ -z "$RAMSHM" ]; then RAMSHM=yes; fi +if [ -z "$RAMTMP" ]; then RAMTMP=no; fi + +TMPFS_SIZE=20%VM +TMPFS_MODE=755 + +RUN_SIZE=10% +RUN_MODE=755 + +LOCK_SIZE=5242880 # 5MiB +LOCK_MODE=1777 + +SHM_SIZE= +SHM_MODE=1777 + +TMP_SIZE= +TMP_MODE=1777 +TMP_OVERFLOW_LIMIT=1024 + +# Source conffile +if [ -f /etc/default/tmpfs ]; then + . /etc/default/tmpfs +fi + +TMPFS_SIZE="$(tmpfs_size_vm "$TMPFS_SIZE")" +RUN_SIZE="$(tmpfs_size_vm "$RUN_SIZE")" +LOCK_SIZE="$(tmpfs_size_vm "$LOCK_SIZE")" +SHM_SIZE="$(tmpfs_size_vm "$SHM_SIZE")" +TMP_SIZE="$(tmpfs_size_vm "$TMP_SIZE")" + +RUN_OPT= +[ "${RUN_SIZE:=$TMPFS_SIZE}" ] && RUN_OPT=",size=$RUN_SIZE" +[ "${RUN_MODE:=$TMPFS_MODE}" ] && RUN_OPT="$RUN_OPT,mode=$RUN_MODE" + +LOCK_OPT= +[ "${LOCK_SIZE:=$TMPFS_SIZE}" ] && LOCK_OPT=",size=$LOCK_SIZE" +[ "${LOCK_MODE:=$TMPFS_MODE}" ] && LOCK_OPT="$LOCK_OPT,mode=$LOCK_MODE" + +SHM_OPT= +[ "${SHM_SIZE:=$TMPFS_SIZE}" ] && SHM_OPT=",size=$SHM_SIZE" +[ "${SHM_MODE:=$TMPFS_MODE}" ] && SHM_OPT="$SHM_OPT,mode=$SHM_MODE" + +TMP_OPT= +[ "${TMP_SIZE:=$TMPFS_SIZE}" ] && TMP_OPT=",size=$TMP_SIZE" +[ "${TMP_MODE:=$TMPFS_MODE}" ] && TMP_OPT="$TMP_OPT,mode=$TMP_MODE" diff --git a/src/initscripts/man/fsck.nfs.8 b/src/initscripts/man/fsck.nfs.8 new file mode 100644 index 00000000..2fbcbb9e --- /dev/null +++ b/src/initscripts/man/fsck.nfs.8 @@ -0,0 +1,16 @@ +.TH FSCK.NFS 8 "May 2004" "Initscripts" +.SH NAME +fsck.nfs \- Dummy fsck.nfs script that always returns success. +.SH SYNOPSIS +.B fsck.nfs +.SH DESCRIPTION +Debian GNU/Linux need this for when the root file system is on NFS: there is +no way to find out if root is NFS mounted and we really want to do a +"fsck -a /". +.SH EXIT CODE +The exit code returned by +.B mount.nfs +is always zero, meaning successful completion. +.SH SEE ALSO +.BR fsck (8), +.BR fstab (5). diff --git a/src/initscripts/man/halt.5 b/src/initscripts/man/halt.5 new file mode 100644 index 00000000..96a83544 --- /dev/null +++ b/src/initscripts/man/halt.5 @@ -0,0 +1,49 @@ +.TH halt 5 "16 Jan 2007" "" "File Formats" +.SH NAME +halt \- variables that affect the behavior of the shutdown scripts +.SH DESCRIPTION +The +.I /etc/default/halt +file contains variable settings in POSIX format: +.IP "" .5i +VAR=VAL +.PP +Only one assignment is allowed per line. +Comments (starting with '#') are also allowed. + +.SH OPTIONS +The following variables can be set. + +.IP \fBHALT\fP +If set to +.B poweroff +the system will be powered down after it has been +brought down. This is the default. +.br +If set to +.B halt +the system will only be halted after it has been brought +down. What exactly this means depends on your hardware. + +.IP \fBNETDOWN\fB +Setting this to +.B no +prevents shutdown from shutting down the network intefaces. +This is necessary to use Wake-On-Lan. +Setting it to +.B yes +causes shutdown to also bring down the network interfaces (and +thus prevent the machine from being woken up remotely). + +.SH SEE ALSO +.BR halt "(8), " shutdown "(8)." + +.SH AUTHOR +\fBCasper Gielen\fR <\&casper@gielen.name\&> + +.SH "COPYRIGHT" +This manual page 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. +.PP +This manual page 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. +.PP +You should have received a copy of the GNU General Public License along with this manual page; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111\-1307 USA diff --git a/src/initscripts/man/rcS.5 b/src/initscripts/man/rcS.5 new file mode 100644 index 00000000..f49a0e45 --- /dev/null +++ b/src/initscripts/man/rcS.5 @@ -0,0 +1,115 @@ +.TH rcS 5 "21 May 2012" "" "Debian Administrator's Manual" +.SH NAME +rcS \- variables that affect the behavior of boot scripts +.SH DESCRIPTION +The +.I /etc/default/rcS +file contains variable settings in POSIX format: +.IP "" .5i +VAR=VAL +.PP +Only one assignment is allowed per line. +Comments (starting with '#') are also allowed. + +.PP +\fBNOTE: This file is ignored when systemd is used as init system.\fP + +.SH OPTIONS +The following variables can be set. + +.IP \fBTMPTIME\fP +On boot the files in /tmp will be deleted if their modification time, +file status time and access time are all at least TMPTIME days ago. +A value of 0 means that files are removed regardless of age. +If you don't want the system to clean /tmp +then set TMPTIME to a negative value (e.g., \-1) +or to the word \fIinfinite\fP. + +.IP \fBSULOGIN\fB +Setting this to +.B yes +causes init to spawn a +.B sulogin +on the console early in the boot process. +If the administrator does not login +then the sulogin session will time out +after 30 seconds and the boot process will continue. + +.IP \fBDELAYLOGIN\fB +Normally the system will not let non-root users log in +until the boot process is complete +and the system has finished switching +to the default runlevel (usually level 2). +However, in theory it is safe to log in a bit earlier, +namely, as soon as \fBinetd\fP has started. +Setting the variable to \fBno\fP allows earlier login; +setting the variable to \fByes\fP prevents it. + +Some details: +The \fBDELAYLOGIN\fP variable controls whether or not the +file \fI/run/nologin\fP is created during +the boot process and deleted at the end of it. +The \fBlogin\fP(1) program refuses to allow non-root logins so long +as \fI/run/nologin\fP exists. +If you set the variable to \fBno\fP then it is advisable to ensure +that \fI/run/nologin\fP does not exist. + +.IP \fBVERBOSE\fP +Setting this option to \fBno\fP (in lower case) will make the boot process +a bit less verbose. +Setting this option to \fByes\fP will make the boot process +a bit more verbose. + +.IP \fBFSCKFIX\fP +When the root and all other file systems are checked, +.B fsck +is invoked with the \fB\-a\fP option +which means "autorepair". +If there are major inconsistencies +then the fsck process will bail out. +The system will print a message +asking the administrator to repair the file system manually +and will present a root shell prompt +(actually a \fIsulogin\fP prompt) +on the console. +Setting this option to \fByes\fP causes the fsck commands +to be run with the \fB\-y\fP option instead of the \fB\-a\fP option. +This will tell fsck always to repair the file systems +without asking for permission. + +.IP \fBASYNCMOUNTNFS\fP +Set this to 'no' to disable asynchronous mounting of network drives +when the network interfaces are mounted, and instead do it only once +when the machine boots. The default is 'yes'. It is useful to +disable this on machines where the root file system is NFS, until ifup +from ifupdown works properly in such setup. + +.SH NOTE +The \fBEDITMOTD\fP, \fBRAMRUN\fP and \fBUTC\fP variables are no longer +used. The \fBRAMLOCK\fP, \fBRAMSHM\fP and \fBRAMTMP\fP variables have +been moved to /etc/default/tmpfs; RAMSHM and RAMTMP settings in rcS +are used (if set) for backward compatibility, but will be overridden +by settings enabled in /etc/default/tmpfs. See +.BR tmpfs (5) +for further details. The settings are not automatically migrated to +/etc/default/tmpfs. Please update /etc/default/tmpfs appropriately. +The UTC setting is replaced by the UTC or LOCAL setting in +/etc/adjtime, and should have been migrated automatically. See +.BR hwclock (5) +and +.BR hwclock (8) +for further details on configuring the system clock. + +.SH AUTHOR +Miquel van Smoorenburg +Roger Leigh + +.SH SEE ALSO +.BR fsck (8), +.BR hwclock (5), +.BR hwclock (8), +.BR inetd (8), +.BR init (8), +.BR inittab (5), +.BR login (1), +.BR tmpfs (5). diff --git a/src/initscripts/man/tmpfs.5 b/src/initscripts/man/tmpfs.5 new file mode 100644 index 00000000..99b877d6 --- /dev/null +++ b/src/initscripts/man/tmpfs.5 @@ -0,0 +1,206 @@ +.TH tmpfs 5 "18 Feb 2012" "" "Debian Administrator's Manual" +.SH NAME +tmpfs \- variables that configure tmpfs filesystems mounted during boot +.SH DESCRIPTION +The +.I /etc/default/tmpfs +file contains variable settings in POSIX format: +.IP "" .5i +VAR=VAL +.PP +Only one assignment is allowed per line. +Comments (starting with '#') are also allowed. +.PP +This file is for the configuration of tmpfs filesystems mounted in +early boot, before filesystems from /etc/fstab are mounted. This +currently includes the filesystems /run, /run/lock, /run/shm and /tmp. +/run is required to be a tmpfs on systems supporting tmpfs mounts. +/run/lock and /run/shm may be separate tmpfs mounts, useful for +enforcing separate size limits. /tmp is not required to be a tmpfs, +and is not mounted as a tmpfs by default. +.PP + +.IP /run +Previously configured using \fBRAMRUN\fP in /etc/default/rcS, /run is +now always mounted as a ram file system (tmpfs). The size of the +tmpfs can be controlled using TMPFS_SIZE and RUN_SIZE. If desired, +the defaults may also be overridden with an entry in in /etc/fstab, +for example: + +.EX +tmpfs /run tmpfs nodev,nosuid,size=10%,mode=755 0 0 +.EE + +.IP +The contents of /run will always be lost on system reboot, and it it +is no longer explicitly cleaned at boot. Packages can not expect +directories in /run to exist after boot. Packages expecting this are +buggy and need to be fixed. Note that /run was previously /var/run, +and a compatibility symlink or bind mount will be created to allow the +old path to continue to function. + +.IP /run/lock +Previously configured using \fBRAMLOCK\fP in /etc/default/rcS. +Configured using RAMLOCK, TMPFS_SIZE and LOCK_SIZE. If desired, +the defaults may also be overridden with an entry in in /etc/fstab, +for example: + +.EX +tmpfs /run/lock tmpfs nodev,noexec,nosuid,size=52428800,mode=1777 0 0 +.EE + +.IP +Note that irrespective of these settings, /run/lock will be located on +a tmpfs, either one mounted on /run/lock (if RAMLOCK=yes) or one +mounted on /run (if RAMLOCK=no), and as a result the contents of +/var/lock will always be lost on system reboot, and it it is no longer +explicitly cleaned at boot. Packages can not expect directories in +/var/lock to exist after boot. Packages expecting this are buggy and +need to be fixed. Note that /run/lock was previously /var/lock, and a +compatibility symlink or bind mount will be created to allow the old +path to continue to function. + +.IP /run/shm +Previously configured using \fBRAMSHM\fP in /etc/default/rcS. Note +that the setting in /etc/default/rcS, if present, will still be used, +but the setting in /etc/default/tmpfs will take precedence if enabled. +Configured using RAMSHM, TMPFS_SIZE and SHM_SIZE. If desired, the +defaults may also be overridden with an entry in in /etc/fstab, for +example: + +.EX +tmpfs /run/shm tmpfs nosuid,nodev,size=40%,mode=1777 0 0 +.EE + +.IP +Packages can not expect directories in /run/shm to exist after boot. +Note that /run/shm was previously /dev/shm, and a compatibility +symlink or bind mount will be created to allow the old path to +continue to function. If an fstab entry for /dev/shm exists instead +of /run/shm, then /dev/shm will continue to be used; note that this is +only needed for users of newer versions of the Oracle database, which +contain a buggy check for /dev/shm. + +.IP /tmp +Previously configured using \fBRAMTMP\fP in /etc/default/rcS. Note +that the setting in /etc/default/rcS, if present, will still be used, +but the setting in /etc/default/tmpfs will take precedence if enabled. +Configured using RAMTMP, TMPFS_SIZE and TMP_SIZE. If desired, the +defaults may also be overridden with an entry in in /etc/fstab, for +example: + +.EX +tmpfs /tmp tmpfs nodev,nosuid,size=20%,mode=1777 0 0 +.EE + +.IP +Packages can not expect directories in /tmp to exist after boot. + +.PP +\fBNOTE: This file is ignored when systemd is used as init system.\fP + +.SH OPTIONS +The following variables can be set. + +.SS Enabling or disabling tmpfs mounts + +.PP +The following options enable specific mounts (with the exception of +/run) to be enabled or disabled. Note that the addition of an entry +to /etc/fstab for any of the following will enable the mount +unconditionally, overriding the setting here. + +.IP \fBRAMLOCK\fP +Mount /run/lock as a tmpfs (separately from /run). Defaults to +\fByes\fP; set to \fBno\fP to disable (/run/lock will then be part of +the /run tmpfs, if available). + +.IP \fBRAMSHM\fP +Mount /run/shm as a tmpfs (separately from /run). Defaults to +\fByes\fP; set to \fBno\fP to disable (/run/shm will then be part of +the /run tmpfs, if available). + +.IP \fBRAMTMP\fP +Mount /tmp as a tmpfs. Defaults to \fBno\fP; set to \fByes\fP to +enable (/tmp will be part of the root filesystem if disabled). /tmp +may also be configured to be a separate mount in /etc/fstab, which +will override the RAMTMP setting. + +.SS Configuring size limits for tmpfs mounts + +.PP +The following options configure size limits for tmpfs mounts. Note +that the addition of an entry to /etc/fstab will override any of the +limits specified here. +.PP +The following _SIZE variables are the maximum size (in bytes) that +tmpfs filesystems can use. The size will be rounded down to a +multiple of the page size, 4096 bytes. If no size is set, TMPFS_SIZE +will be used as the default. +.PP +More complex mount options may be used by the creation of a +suitable entry in /etc/fstab. For example: + +.EX +tmpfs /run tmpfs size=10% 0 0 +.EE + +is equivalent to + +.EX +RUN_SIZE=10% +.EE + +and will override the RUN_SIZE setting. This will allow additional +options such as nr_blocks and nr_inodes to be used, and also +adjustment of the mode, nodev, nosuid, noexec options should any +change from the defaults be necessary. + +.IP "\fBTMPFS_SIZE\fP" +Maximum size for all tmpfs filesystems if no specific size is +provided. The default is \fB20%VM\fP (20% of virtual memory, +including swap space). If no value is provided here, the kernel +default (50% RAM) will be used. Note that the "%VM" suffix may be +used in this and all the _SIZE settings below, but may not be used in +/etc/fstab (the absolute size is calculated by the init scripts). + +.IP "\fBRUN_SIZE\fP" +Maximum size of /run (was previously /var/run). The default is 10% +core memory; the size required varies widely depending upon the +demands of the software being run; this heuristic scales /run usage on +system size. Samba in particular has been seen to use at least 50MiB +in a large heavily used server. Typical usage is hundreds of KiB, +maximum is tens of MiB. + +.IP "\fBLOCK_SIZE\fP" +Maximum size of /run/lock (was previously /var/lock). Defaults to +5242880 (5 MiB). Typical usage: tens of KiB; maximum hundreds of KiB. +The default of 5 MiB should ensure the limit is never reached. + +.IP "\fBSHM_SIZE\fP" +Maximum size of /run/shm (was previously /dev/shm). No default size; +the size required varies widely depending upon the demands of the +software being run. + +.IP "\fBTMP_SIZE\fP" +Maximum size of /tmp. No default size. + +.SS Emergency overflow /tmp + +.PP +If the amount of free space on the root filesystem falls below a +certain size, a tmpfs will be mounted on /tmp (irrespective of the +RAMTMP setting, which this overrides). This is to permit logins when +there would otherwise be too little free space for this to be possible. + +.IP "\fBTMP_OVERFLOW_LIMIT\fP" +Mount a tmpfs on /tmp if the amount of free space on the root +filesystem is below the specified limit at boot time (default 1024 +KiB). + +.SH AUTHOR +Roger Leigh + +.SH SEE ALSO +.BR mount (8), +.BR rcS (5). diff --git a/src/initscripts/sbin/fsck.nfs b/src/initscripts/sbin/fsck.nfs new file mode 100644 index 00000000..817da9b7 --- /dev/null +++ b/src/initscripts/sbin/fsck.nfs @@ -0,0 +1,21 @@ +#! /bin/sh +# +# fsck.nfs +# +# Dummy fsck.nfs file that always returns success. We +# need this for when the root file system is on NFS: +# there is no way to find out if root is NFS mounted +# and we really want to do a "fsck -a /". +# + +while : +do + case "$1" in + -*) shift ;; + *) break ;; + esac +done + +echo "$1: NFS file system." + +exit 0 diff --git a/src/sysv-rc/Makefile b/src/sysv-rc/Makefile new file mode 100644 index 00000000..4ce4cc64 --- /dev/null +++ b/src/sysv-rc/Makefile @@ -0,0 +1,32 @@ +DESTDIR = +sysconfdir = /etc +prefix = /usr +docdir = $(prefix)/share/doc/sysv-rc +bindir = $(prefix)/bin +sbindir = $(prefix)/sbin + +INSTALL = install -m755 -o root -g root +INSTALL_DATA = install -m644 -o root -g root + +all: + +install: + $(INSTALL) -d $(DESTDIR)$(docdir)/. + $(INSTALL) -d $(DESTDIR)/var/lib/insserv + $(INSTALL) -d $(DESTDIR)$(sysconfdir)/. + $(INSTALL_DATA) doc/* $(DESTDIR)$(docdir)/. + cp -af etc/* $(DESTDIR)$(sysconfdir) + find $(DESTDIR)$(sysconfdir) -type d -name .svn -print0 |xargs -r0 rm -r + + for N in 2 3 4 5 ; do \ + $(INSTALL) -d $(DESTDIR)$(sysconfdir)/rc$${N}.d ; \ + $(INSTALL_DATA) rc2-5.d-README \ + $(DESTDIR)$(sysconfdir)/rc$${N}.d/README ; \ + done + chmod 755 $(DESTDIR)$(sysconfdir)/init.d/[a-z]* + chmod 644 $(DESTDIR)$(sysconfdir)/init.d/README + chmod -R go=u-w $(DESTDIR)$(sysconfdir) + chown -R root:root $(DESTDIR)$(sysconfdir) + + $(INSTALL) -d $(DESTDIR)/usr/share/sysv-rc/. + $(INSTALL) saveconfig $(DESTDIR)/usr/share/sysv-rc/saveconfig diff --git a/src/sysv-rc/doc/README.Debian b/src/sysv-rc/doc/README.Debian new file mode 100644 index 00000000..75b0f938 --- /dev/null +++ b/src/sysv-rc/doc/README.Debian @@ -0,0 +1,46 @@ +README for sysv-rc +------------------ + +Policy requires that maintainer scripts use update-rc.d to register and +deregister initscripts. An unfortunate result of this policy, combined +with shortcomings in current update-rc.d implementations, is that there +is no way for maintainer scripts to change the sequence number of an +initscript that has already been registered if and only if its sequence +number has not been changed by the administrator. update-rc.d *never* +changes the sequence number of an already registered initscript, even +if its sequence number has not been changed by the administrator. +There are no plans to fix this problem. Therefore, if it is necessary +to change the sequence number of an initscript in order to fix a bug +then the maintainer script should go ahead and do: + + update-rc.d -f remove + +before the new update-rc.d call, even though this overrides out any +administrator changes. + +Migrating to dependency-based boot sequencing +--------------------------------------------- + +Migrating to the dependency-based system of boot sequencing (using LSB +headers) is non-reversible, and renders obsolete the legacy system of +static sequence numbers. Please note that any boot sequence changes +made locally will be lost in the migration, and must be reimplemented +in terms of dependencies. However, the new system is recommended for +several reasons. + + * initscripts can be made to run more efficiently via parallelized + execution strategies (see $POINTER_TO_ENTICING_BOOTCHARTS); + * boot and shutdown ordering is calculated on the basis of the + dependency information declared within each init.d script, ensuring + that the sequence is optimized for the set of packages installed; + * problems introduced by new or upgraded packages can be detected and + averted - the boot sequence is only modified if it is safe to do + so. + +It can also bring benefits for Debian package development, and for +admins maintaining local software, since it eliminates the difficulty +of fitting an initscript into the boot sequence between existing +services with adjacent sequence numbers. + +It is also a step in the direction of boot systems better suited to +the asynchronous nature of the Linux-2.6 kernel boot process. diff --git a/src/sysv-rc/doc/README.runlevels b/src/sysv-rc/doc/README.runlevels new file mode 100644 index 00000000..73c4b909 --- /dev/null +++ b/src/sysv-rc/doc/README.runlevels @@ -0,0 +1,103 @@ + + Order of scripts run in /etc/rc?.d + ================================== + +0. Overview. + + All scripts executed by the init system are located in /etc/init.d. + The directories /etc/rc?.d (? = S, 0 .. 6) contain relative links to + those scripts. These links are named S<2-digit-number> + or K<2-digit-number>. + + If a scripts has the ".sh" suffix it is a bourne shell script and + MAY be handled in an optimized manner. The behaviour of executing the + script in an optimized way will not differ in any way from it being + forked and executed in the regular way. + + The following runlevels are defined: + + N System bootup (NONE). + S Single user mode (not to be switched to directly) + 0 halt + 1 single user mode + 2 .. 5 multi user mode + 6 reboot + +1. Boot. + + When the systems boots, the /etc/init.d/rcS script is executed. It + in turn executes all the S* scripts in /etc/rcS.d in alphabetical + (and thus numerical) order. The first argument passed to the + executed scripts is "start". The runlevel at this point is "N" (none). + + Only things that need to be run once to get the system in a consistent + state are to be run. The rcS.d directory is NOT meant to replace rc.local. + One should not start daemons in this runlevel unless absolutely + necessary. Eg, NFS might need the portmapper, so it is OK to start it + early in the bootprocess. But this is not the time to start the + squid proxy server. + +2. Going multiuser. + + After the rcS.d scripts have been executed, init switches to the + default runlevel as specified in /etc/inittab, usually "2". + + Init then executes the /etc/init.d/rc script which takes care of + starting the services in /etc/rc2.d. + + Because the previous runlevel is "N" (none) the /etc/rc2.d/KXXxxxx + scripts will NOT be executed - there is nothing to stop yet, + the system is busy coming up. + + If for example there is a service that wants to run in runlevel 4 + and ONLY in that level, it will place a KXXxxxx script in + /etc/rc{2,3,5}.d to stop the service when switching out of runlevel 4. + We do not need to run that script at this point. + + The /etc.rc2.d/SXXxxxx scripts will be executed in alphabetical + order, with the first argument set to "start". + +3. Switching runlevels. + + When one switches from (for example) runlevel 2 to runlevel 3, + /etc/init.d/rc will first execute in alphabetical order all K + scripts for runlevel 3 (/etc/rc3.d/KXXxxxx) with as first argument + "stop" and then all S scripts for runlevel 3 (/etc/rc3.d/SXXxxxx) + with as first argument "start". + + As an optimization, a check is made for each "service" to see if + it was already running in the previous runlevel. If it was, and there + is no K (stop) script present for it in the new runlevel, there is + no need to start it a second time so that will not be done. + + On the other hand, if there was a K script present, it is assumed the + service was stopped on purpose first and so needs to be restarted. + + We MIGHT make the same optimization for stop scripts as well- + if no S script was present in the previous runlevel, we can assume + that service was not running and we don't need to stop it either. + In that case we can remove the "coming from level N" special case + mentioned above in 2). But right now that has not been implemented. + +4. Single user mode. + + Switching to single user mode is done by switching to runlevel 1. + That will cause all services to be stopped (assuming they all have + a K script in /etc/rc1.d). The runlevel 1 scripts will then switch + to runlevel "S" which has no scripts - all it does is spawn + a shell directly on /dev/console for maintenance. + +5. Halt/reboot + + Going to runlevel 0 or 6 will cause the system to be halted or rebooted, + respectively. For example, if we go to runlevel 6 (reboot) first + all /etc/rc6.d/KXXxxxx scripts will be executed alphabetically with + "stop" as the first argument. + + Then the /etc/rc6.d/SXXxxxx scripts will be executed alphabetically + with "stop" as the first argument as well. The reason is that there + is nothing to start anymore at this point - all scripts that are + run are meant to bring the system down. + + In the future, the /etc/rc6.d/SXXxxxx scripts MIGHT be moved to + /etc/rc6.d/K1XXxxxx for clarity. diff --git a/src/sysv-rc/etc/init.d/README b/src/sysv-rc/etc/init.d/README new file mode 100644 index 00000000..8477036a --- /dev/null +++ b/src/sysv-rc/etc/init.d/README @@ -0,0 +1,60 @@ + Configuration of System V init under Debian GNU/Linux + +Most Unix versions have a file here that describes how the scripts +in this directory work, and how the links in the /etc/rc?.d/ directories +influence system startup/shutdown. + +For Debian, this information is contained in the policy manual, chapter +"System run levels and init.d scripts". The Debian Policy Manual is +available at: + + http://www.debian.org/doc/debian-policy/#contents + +The Debian Policy Manual is also available in the Debian package +"debian-policy". When this package is installed, the policy manual can be +found in directory /usr/share/doc/debian-policy. If you have a browser +installed you can probably read it at + + file://localhost/usr/share/doc/debian-policy/ + +Some more detailed information can also be found in the files in the +/usr/share/doc/sysv-rc directory. + +Debian Policy dictates that /etc/init.d/*.sh scripts must work properly +when sourced. The following additional rules apply: + +* /etc/init.d/*.sh scripts must not rely for their correct functioning + on their being sourced rather than executed. That is, they must work + properly when executed too. They must include "#!/bin/sh" at the top. + This is useful when running scripts in parallel. + +* /etc/init.d/*.sh scripts must conform to the rules for sh scripts as + spelled out in the Debian policy section entitled "Scripts" (§10.4). + +Use the update-rc.d command to create symbolic links in the /etc/rc?.d +as appropriate. See that man page for more details. + +All init.d scripts are expected to have a LSB style header documenting +dependencies and default runlevel settings. The header look like this +(not all fields are required): + +### BEGIN INIT INFO +# Provides: skeleton +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Should-Start: $portmap +# Should-Stop: $portmap +# X-Start-Before: nis +# X-Stop-After: nis +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# X-Interactive: true +# Short-Description: Example initscript +# Description: This file should be used to construct scripts to be +# placed in /etc/init.d. +### END INIT INFO + +More information on the format is available from insserv(8). This +information is used to dynamicaly assign sequence numbers to the +boot scripts and to run the scripts in parallel during the boot. +See also /usr/share/doc/insserv/README.Debian. diff --git a/src/sysv-rc/etc/init.d/rc b/src/sysv-rc/etc/init.d/rc new file mode 100644 index 00000000..3f8841a3 --- /dev/null +++ b/src/sysv-rc/etc/init.d/rc @@ -0,0 +1,263 @@ +#! /bin/sh +# +# rc +# +# Starts/stops services on runlevel changes. +# +# Optimization: A start script is not run when the service was already +# configured to run in the previous runlevel. A stop script is not run +# when the the service was already configured not to run in the previous +# runlevel. +# +# Authors: +# Miquel van Smoorenburg +# Bruce Perens + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +export PATH + +# Un-comment the following for interactive debugging. Do not un-comment +# this for debugging a real boot process as no scripts will be executed. +# debug=echo + +# Make sure the name survive changing the argument list +scriptname="$0" + +umask 022 + +on_exit() { + echo "error: '$scriptname' exited outside the expected code flow." +} +trap on_exit EXIT # Enable emergency handler + +# Ignore CTRL-C only in this shell, so we can interrupt subprocesses. +trap ":" INT QUIT TSTP + +# Set onlcr to avoid staircase effect. +stty onlcr 0>&1 + +# Now find out what the current and what the previous runlevel are. + +runlevel=$RUNLEVEL +# Get first argument. Set new runlevel to this argument. +[ "$1" != "" ] && runlevel=$1 +if [ "$runlevel" = "" ] +then + echo "Usage: $scriptname " >&2 + exit 1 +fi +previous=$PREVLEVEL +[ "$previous" = "" ] && previous=N + +export runlevel previous + +if [ -f /etc/default/rcS ] ; then + . /etc/default/rcS +fi +export VERBOSE + +if [ -f /lib/lsb/init-functions ] ; then + . /lib/lsb/init-functions +else + log_action_msg() { echo $@; } + log_failure_msg() { echo $@; } + log_warning_msg() { echo $@; } +fi + +# +# Check if we are able to use make like booting. It require the +# insserv package to be enabled. Boot concurrency also requires +# startpar to be installed. +# +CONCURRENCY=makefile +test -s /etc/init.d/.depend.boot || CONCURRENCY="none" +test -s /etc/init.d/.depend.start || CONCURRENCY="none" +test -s /etc/init.d/.depend.stop || CONCURRENCY="none" +if test -e /etc/init.d/.legacy-bootordering ; then + CONCURRENCY="none" +fi +if ! test -e /proc/stat; then + # startpar requires /proc/stat + if [ "$(uname)" = "GNU/kFreeBSD" ] ; then + mount -t linprocfs linprocfs /proc + elif [ "$(uname)" = "GNU" ] ; then + mount -t proc none /proc + fi +fi +if [ -x /lib/startpar/startpar ] ; then + STARTPAR=/lib/startpar/startpar +else + STARTPAR=startpar +fi +$STARTPAR -v > /dev/null 2>&1 || CONCURRENCY="none" + +# +# Start script or program. +# +case "$CONCURRENCY" in + makefile|startpar|shell) # startpar and shell are obsolete + CONCURRENCY=makefile + log_action_msg "Using makefile-style concurrent boot in runlevel $runlevel" + startup() { + eval "$($STARTPAR -p 4 -t 20 -T 3 -M $1 -P $previous -R $runlevel)" + + if [ -n "$failed_service" ] + then + log_failure_msg "startpar: service(s) returned failure: $failed_service" + fi + + if [ -n "$skipped_service_not_installed" ] + then + log_warning_msg "startpar: service(s) skipped, program is not installed: $skipped_service_not_installed" + fi + + if [ -n "$skipped_service_not_configured" ] + then + log_warning_msg "startpar: service(s) skipped, program is not configured: $skipped_service_not_configured" + fi + + unset failed_service skipped_service_not_installed skipped_service_not_configured + } + ;; + none|*) + startup() { + action=$1 + shift + scripts="$@" + for script in $scripts ; do + $debug "$script" $action + done + } + ;; +esac + +# Is there an rc directory for this new runlevel? +if [ -d /etc/rc$runlevel.d ] +then + case "$runlevel" in + 0|6) + ACTION=stop + ;; + S) + ACTION=start + ;; + *) + ACTION=start + ;; + esac + + # First, run the KILL scripts. + if [ makefile = "$CONCURRENCY" ] + then + if [ "$ACTION" = "start" ] && [ "$previous" != N ] + then + startup stop + fi + elif [ "$previous" != N ] + then + # Run all scripts with the same level in parallel + CURLEVEL="" + for s in /etc/rc$runlevel.d/K* + do + # Extract order value from symlink + level=${s#/etc/rc$runlevel.d/K} + level=${level%%[a-zA-Z]*} + if [ "$level" = "$CURLEVEL" ] + then + continue + fi + CURLEVEL=$level + SCRIPTS="" + for i in /etc/rc$runlevel.d/K$level* + do + # Check if the script is there. + [ ! -f $i ] && continue + + # + # Find stop script in previous runlevel but + # no start script there. + # + suffix=${i#/etc/rc$runlevel.d/K[0-9][0-9]} + previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix + previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix + # + # If there is a stop script in the previous level + # and _no_ start script there, we don't + # have to re-stop the service. + # + [ -f $previous_stop ] && [ ! -f $previous_start ] && continue + + # Stop the service. + SCRIPTS="$SCRIPTS $i" + done + startup stop $SCRIPTS + done + fi + + if [ makefile = "$CONCURRENCY" ] + then + if [ S = "$runlevel" ] + then + startup boot + else + startup $ACTION + fi + else + # Now run the START scripts for this runlevel. + # Run all scripts with the same level in parallel + CURLEVEL="" + for s in /etc/rc$runlevel.d/S* + do + # Extract order value from symlink + level=${s#/etc/rc$runlevel.d/S} + level=${level%%[a-zA-Z]*} + if [ "$level" = "$CURLEVEL" ] + then + continue + fi + CURLEVEL=$level + SCRIPTS="" + for i in /etc/rc$runlevel.d/S$level* + do + [ ! -f $i ] && continue + + suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]} + if [ "$previous" != N ] + then + # + # Find start script in previous runlevel and + # stop script in this runlevel. + # + stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix + previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix + # + # If there is a start script in the previous level + # and _no_ stop script in this level, we don't + # have to re-start the service. + # + if [ start = "$ACTION" ] ; then + [ -f $previous_start ] && [ ! -f $stop ] && continue + else + # Workaround for the special + # handling of runlevels 0 and 6. + previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix + # + # If there is a stop script in the previous level + # and _no_ start script there, we don't + # have to re-stop the service. + # + [ -f $previous_stop ] && [ ! -f $previous_start ] && continue + fi + + fi + SCRIPTS="$SCRIPTS $i" + done + startup $ACTION $SCRIPTS + done + fi +fi + +trap - EXIT # Disable emergency handler + +exit 0 + diff --git a/src/sysv-rc/etc/init.d/rcS b/src/sysv-rc/etc/init.d/rcS new file mode 100644 index 00000000..546b7245 --- /dev/null +++ b/src/sysv-rc/etc/init.d/rcS @@ -0,0 +1,8 @@ +#! /bin/sh +# +# rcS +# +# Call all S??* scripts in /etc/rcS.d/ in numerical/alphabetical order +# + +exec /etc/init.d/rc S diff --git a/src/sysv-rc/etc/rc0.d/README b/src/sysv-rc/etc/rc0.d/README new file mode 100644 index 00000000..df13c03b --- /dev/null +++ b/src/sysv-rc/etc/rc0.d/README @@ -0,0 +1,11 @@ +The scripts in this directory are executed once when entering +runlevel 0. + +The scripts are all symbolic links whose targets are located in +/etc/init.d/ . + +Generally it is not necessary to alter the scripts in this directory. +Their purpose is to stop all services and to make the system ready +for shutdown. + +For more information see /etc/init.d/README. diff --git a/src/sysv-rc/etc/rc1.d/README b/src/sysv-rc/etc/rc1.d/README new file mode 100644 index 00000000..6be6c94b --- /dev/null +++ b/src/sysv-rc/etc/rc1.d/README @@ -0,0 +1,11 @@ +The scripts in this directory are executed each time the system enters +this runlevel. + +The scripts are all symbolic links whose targets are located in +/etc/init.d/ . + +Generally it is not necessary to alter the scripts in this directory. +Their purpose is to stop all services and thus to put the system in +single-user mode. + +For more information see /etc/init.d/README. diff --git a/src/sysv-rc/etc/rc6.d/README b/src/sysv-rc/etc/rc6.d/README new file mode 100644 index 00000000..baf54c95 --- /dev/null +++ b/src/sysv-rc/etc/rc6.d/README @@ -0,0 +1,11 @@ +The scripts in this directory are executed once when entering +runlevel 6. + +The scripts are all symbolic links whose targets are located in +/etc/init.d/ . + +Generally it is not necessary to alter the scripts in this directory. +Their purpose is to stop all services and to make the system ready +for reboot. + +For more information see /etc/init.d/README. diff --git a/src/sysv-rc/etc/rcS.d/README b/src/sysv-rc/etc/rcS.d/README new file mode 100644 index 00000000..fcf7c923 --- /dev/null +++ b/src/sysv-rc/etc/rcS.d/README @@ -0,0 +1,12 @@ +The scripts in this directory whose names begin with an 'S' are +executed once when booting the system, even when booting directly into +single user mode. + +The scripts are all symbolic links whose targets are located in +/etc/init.d/ . + +To disable a script in this directory, rename it so that it begins +with a 'K' and run 'update-rc.d script defaults' to update the order +using the script dependencies. + +For more information see /etc/init.d/README. diff --git a/src/sysv-rc/rc2-5.d-README b/src/sysv-rc/rc2-5.d-README new file mode 100644 index 00000000..6e0733f7 --- /dev/null +++ b/src/sysv-rc/rc2-5.d-README @@ -0,0 +1,15 @@ +The scripts in this directory are executed each time the system enters +this runlevel. + +The scripts are all symbolic links whose targets are located in +/etc/init.d/ . + +To disable a service in this runlevel, rename its script in this +directory so that the new name begins with a 'K' and a two-digit +number, and run 'update-rc.d script defaults' to reorder the scripts +according to dependencies. A warning about the current runlevels +being enabled not matching the LSB header in the init.d script will be +printed. To re-enable the service, rename the script back to its +original name beginning with 'S' and run update-rc.d again. + +For a more information see /etc/init.d/README. diff --git a/src/sysv-rc/saveconfig b/src/sysv-rc/saveconfig new file mode 100644 index 00000000..f9399350 --- /dev/null +++ b/src/sysv-rc/saveconfig @@ -0,0 +1,94 @@ +#! /usr/bin/perl +# +# saveconfig +# +# Print out the configuration of the current /etc/rc?.d +# symlink setup, in a format compatible to the +# "update-rc.d" command line. +# +# Author: Miquel van Smoorenburg +# Adjusted by Petter Reinholdtsen +# + +sub usage { + print STDERR "error: ", @_, "\n" if @_; + print STDERR <] + -s save each scripts setting in directory + -h show usage inforation +EOF +} + +my $archivedir = ""; + +while($#ARGV >= 0 && ($_ = $ARGV[0]) =~ /^-/) { + shift @ARGV; + if (/^-s$/) { $archivedir = shift; usage("Missing -s argument"), exit 1 unless $archivedir; next } + if (/^-h|--help$/) { &usage; } + &usage("unknown option"); +} + +chdir "/etc/init.d"; + +sub scan { + my $dir = shift; + local *DD; + my $f; + opendir DD, $dir; + foreach $f (readdir DD) { + next if ($f =~ m/^\./); + push @{$dir{$dir}}, $f; + } + closedir DD; +} + +foreach my $d (qw(S 0 1 2 3 4 5 6 7 8 9)) { + scan("/etc/rc$d.d"); +} +scan("/etc/init.d"); + +foreach my $s (@{$dir{"/etc/init.d"}}) { + my %start; + my %stop; + my $start = 0; + my $stop = 0; + foreach my $l (qw(S 0 1 2 3 4 5 6)) { + #print "L: $l\n"; + foreach my $f (@{$dir{"/etc/rc$l.d"}}) { + #print "F: $f\n"; + if ($f =~ m#^S(\d+)$s$#) { + $start{$1} .= "$l "; + $start = 1; + } + if ($f =~ m#^K(\d+)$s$#) { + $stop{$1} .= "$l "; + $stop = 1; + } + } + } + my $entry; + if ($start || $stop) { + $entry = "update-rc.d $s "; + if ($start > 0) { + foreach my $x (sort keys %start) { + $entry .= "start $x " . $start{$x} . ". "; + } + } + if ($stop > 0) { + foreach my $x (sort keys %stop) { + $entry .= "stop $x " . $stop{$x} . ". "; + } + } + $entry .= "\n"; + if ($archivedir) { + my $file = "$archivedir/$s"; + open(FILE, ">", "${file}.new") || + die "Unable to write to $file"; + print FILE $entry; + close(FILE); + rename "${file}.new", "$file"; + } else { + print $entry; + } + } +} diff --git a/sysv-rc.NEWS b/sysv-rc.NEWS new file mode 100644 index 00000000..1828b545 --- /dev/null +++ b/sysv-rc.NEWS @@ -0,0 +1,24 @@ +sysv-rc (2.88dsf-28) unstable; urgency=low + + Dependency based boot ordering is now required. + + Most systems will already be using dependency based boot ordering. + This includes all squeeze and later releases, unless you have taken + deliberate action to disable it. Installations upgraded from etch, + lenny or earlier releases will have enabled dependency based booting + when upgrading to squeeze and later releases. However, it was + previously possible to opt out of migrating to dependency based + booting and retain static boot ordering. This is no longer the case. + + If your system is still using static boot ordering, migrating to + dependency based boot ordering will be performed when sysv-rc is + configured. + + If you have custom init scripts, or old init scripts without LSB + headers, please ensure that these have the correct dependency + information in an LSB header so that they will be run at the correct + point in the boot sequence. By default, they tend to be ordered + last, but before scripts requiring $all such as rc.local, but the + ordering is not guaranteed. + + -- Roger Leigh Tue, 26 Jun 2012 23:13:28 +0100 diff --git a/sysv-rc.copyright b/sysv-rc.copyright new file mode 100644 index 00000000..24a7c772 --- /dev/null +++ b/sysv-rc.copyright @@ -0,0 +1,32 @@ +This package contains the mechanism for executing the right scripts +in the right order at bootup/shutdown time, and when changing runlevels. +It works through managing symlinks in /etc/rc?.d + +This package is built from the `sysvinit' source package. Please +consult the copyright file of the sysvinit package for the location of +the upstream sources of the sysvinit package. Debian-specific files +for sysvinit, such as these initscripts, are maintained by the members +of the pkg-sysvinit project at alioth.debian.org. + + http://alioth.debian.org/projects/pkg-sysvinit + +Copyright 1997-2005 Miquel van Smoorenburg and +the members pkg-sysvinit project. + + 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 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-2'. diff --git a/sysv-rc.lintian-overrides b/sysv-rc.lintian-overrides new file mode 100644 index 00000000..b84ce226 --- /dev/null +++ b/sysv-rc.lintian-overrides @@ -0,0 +1,41 @@ +sysv-rc: package-installs-into-etc-rc.d etc/rcS.d/README +sysv-rc: package-installs-into-etc-rc.d etc/rc0.d/README +sysv-rc: package-installs-into-etc-rc.d etc/rc1.d/README +sysv-rc: package-installs-into-etc-rc.d etc/rc2.d/README +sysv-rc: package-installs-into-etc-rc.d etc/rc3.d/README +sysv-rc: package-installs-into-etc-rc.d etc/rc4.d/README +sysv-rc: package-installs-into-etc-rc.d etc/rc5.d/README +sysv-rc: package-installs-into-etc-rc.d etc/rc6.d/README +sysv-rc: file-in-etc-not-marked-as-conffile /etc/rcS.d/README +sysv-rc: file-in-etc-not-marked-as-conffile /etc/rc0.d/README +sysv-rc: file-in-etc-not-marked-as-conffile /etc/rc1.d/README +sysv-rc: file-in-etc-not-marked-as-conffile /etc/rc2.d/README +sysv-rc: file-in-etc-not-marked-as-conffile /etc/rc3.d/README +sysv-rc: file-in-etc-not-marked-as-conffile /etc/rc4.d/README +sysv-rc: file-in-etc-not-marked-as-conffile /etc/rc5.d/README +sysv-rc: file-in-etc-not-marked-as-conffile /etc/rc6.d/README +sysv-rc: file-in-etc-not-marked-as-conffile /etc/init.d/README +sysv-rc: script-in-etc-init.d-not-registered-via-update-rc.d /etc/init.d/README +sysv-rc: script-in-etc-init.d-not-registered-via-update-rc.d /etc/init.d/rc +sysv-rc: script-in-etc-init.d-not-registered-via-update-rc.d /etc/init.d/rcS +sysv-rc: non-standard-file-permissions-for-etc-init.d-script etc/init.d/README 0644 != 0755 +sysv-rc: postrm-contains-additional-updaterc.d-calls /etc/init.d//usr/sbin/update-rc.d +sysv-rc: postrm-contains-additional-updaterc.d-calls /etc/init.d//usr/sbin/invoke-rc.d +sysv-rc: file-in-etc-not-marked-as-conffile /etc/init.d/rc +sysv-rc: init.d-script-missing-lsb-section /etc/init.d/rc +sysv-rc: init.d-script-does-not-implement-required-option /etc/init.d/rc start +sysv-rc: init.d-script-does-not-implement-required-option /etc/init.d/rc stop +sysv-rc: init.d-script-does-not-implement-required-option /etc/init.d/rc restart +sysv-rc: init.d-script-does-not-implement-required-option /etc/init.d/rc force-reload +sysv-rc: file-in-etc-not-marked-as-conffile /etc/init.d/rcS +sysv-rc: init.d-script-missing-lsb-section /etc/init.d/rcS +sysv-rc: init.d-script-does-not-implement-required-option /etc/init.d/rcS start +sysv-rc: init.d-script-does-not-implement-required-option /etc/init.d/rcS stop +sysv-rc: init.d-script-does-not-implement-required-option /etc/init.d/rcS restart +sysv-rc: init.d-script-does-not-implement-required-option /etc/init.d/rcS force-reload +sysv-rc: no-upstream-changelog +sysv-rc: no-debconf-config +sysv-rc: postinst-uses-db-input +sysv-rc: prerm-calls-updaterc.d information +sysv-rc: prerm-calls-updaterc.d call +sysv-rc: prerm-calls-updaterc.d call. diff --git a/sysv-rc.postinst b/sysv-rc.postinst new file mode 100644 index 00000000..367666cd --- /dev/null +++ b/sysv-rc.postinst @@ -0,0 +1,101 @@ +#!/bin/sh + +set -e + +now=`date +%Y%m%dT%H%M` +logdir=/var/lib/insserv +logfile="$logdir/run-$now.log" + +# Make sure insserv is in path +PATH=/sbin:$PATH + +# Based on code from dash postinst +check_divert() { + package=insserv + div=$(dpkg-divert --list $2) + distrib=${4:-$2.distrib} + case "$1" in + false) + if [ -n "$div" ] && [ -z "${div%%*by $package}" ]; then + mv $distrib $2 + dpkg-divert --package $package --remove $2 + fi + ;; + status) # Return true if the divert is in effect + if [ -n "$div" ] && [ -z "${div%%*by $package}" ]; then + : + else + false + fi + esac +} + +convert_rc_s_to_k() { + runlevel=$1 + for link in $(cd $target/etc/rc$runlevel.d; ls S* || true); do + set `echo $link|sed "s%S\(..\)\(.*\)%\1 \2%"` + seq=$1 + service=$2 + mv $target/etc/rc$runlevel.d/$link $target/etc/rc$runlevel.d/K$seq$service + done +} + +legacy_bootordering() { + for f in /etc/rc0.d/S* ; do + if [ -f $f ] ; then + return 0 + fi + done + + return 1 +} + +activate_insserv() { + echo "info: Reordering boot system, log to $logfile" 1>&2 + ( + echo "info: Converting rc0.d/S* and rc6.d/S* to K*." 1>&2 + convert_rc_s_to_k 0 + convert_rc_s_to_k 6 + echo "info: running insserv" 1>&2 + insserv -v + ) > $logfile 2>&1 || return 1 + + return 0 +} + +case "$1" in + configure) + if check_divert status /usr/sbin/update-rc.d \ + /usr/sbin/update-rc.d-insserv ; then + check_divert false /usr/sbin/update-rc.d \ + /usr/sbin/update-rc.d-insserv + fi + + if dpkg --compare-versions "$2" lt "2.88dsf-23"; then + rm -f /etc/init.d/.legacy-bootordering + fi + + if legacy_bootordering ; then + # Still using legacy ordering, try to convert + if activate_insserv ; then + echo "success: Enabled dependency based boot system." 1>&2 + else + echo "error: Something failed while migrating." 1>&2 + cat 1>&2 < `install' +# * `install' +# * `upgrade' +# * `abort-upgrade' + +case "$1" in + upgrade) + # Remove the recorded update-rc.d + rm -f /var/lib/update-rc.d/* + ;; + install) + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 0 + ;; +esac + +#DEBHELPER# + +exit 0 diff --git a/sysv-rc.prerm b/sysv-rc.prerm new file mode 100755 index 00000000..5b524a98 --- /dev/null +++ b/sysv-rc.prerm @@ -0,0 +1,20 @@ +#! /bin/sh +# +# sysv-rc prerm +# + +set -e + +case "$1" in + remove) + # Remove files generated by insserv to disable concurrent booting + rm -f /etc/init.d/.depend.boot + rm -f /etc/init.d/.depend.start + rm -f /etc/init.d/.depend.stop + ;; + *) : ;; +esac + +#DEBHELPER# + +exit 0 diff --git a/sysv-rc.templates b/sysv-rc.templates new file mode 100644 index 00000000..96737f5c --- /dev/null +++ b/sysv-rc.templates @@ -0,0 +1,28 @@ +# These templates have been reviewed by the debian-l10n-english +# team +# +# If modifications/additions/rewording are needed, please ask +# debian-l10n-english@lists.debian.org for advice. +# +# Even minor modifications require translation updates and such +# changes should be coordinated with translators and reviewers. +# +Template: sysv-rc/unable-to-convert +Type: note +#flag:translate!:3 +_Description: Unable to migrate to dependency-based boot system + Problems in the boot system exist which are preventing migration to + dependency-based boot sequencing: + . + ${PROBLEMATIC} + . + If the reported problem is a local modification, it needs to be fixed + manually. These are typically due to obsolete conffiles being left + after a package has been removed, but not purged. It is suggested + that these are removed by running: + . + ${SUGGESTION} + . + Package installation can not continue until the above problems have + been fixed. To reattempt the migration process after these problems + have been fixed, run "dpkg --configure sysv-rc". diff --git a/sysvinit-core.config b/sysvinit-core.config new file mode 100755 index 00000000..96dac79f --- /dev/null +++ b/sysvinit-core.config @@ -0,0 +1,44 @@ +#!/bin/sh +# config script for sysvinit +# +# see: dh_installdeb(1) + +set -e + +. /usr/share/debconf/confmodule + +# summary of how this script can be called: +# * 'configure' +# * 'reconfigure' +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + +case "$1" in + configure|reconfigure) + + if [ "$(uname)" = GNU ]; then + db_set sysvinit/hurd-fix-inittab "true" + if echo '3e3693078d18d4696c83a76531433cd4 /etc/inittab' \ + | md5sum --status --check -; then + # The file is unmodified, update it silently. + : + elif [ $(fgrep -c -e '/libexec/getty' /etc/inittab) -gt 0 ] || \ + [ $(grep -c '^c:' /etc/inittab) -eq 0 ]; then + db_input low sysvinit/hurd-fix-inittab || true + db_go + fi + fi + ;; + + *) + echo "config script called with unknown argument '$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/sysvinit-core.dirs b/sysvinit-core.dirs new file mode 100644 index 00000000..58f31975 --- /dev/null +++ b/sysvinit-core.dirs @@ -0,0 +1 @@ +usr/share/sysvinit diff --git a/sysvinit-core.install b/sysvinit-core.install new file mode 100644 index 00000000..35ee15f0 --- /dev/null +++ b/sysvinit-core.install @@ -0,0 +1,14 @@ +sbin/init +sbin/halt +sbin/runlevel +sbin/shutdown +usr/share/man/man8/halt.8 +usr/share/man/man8/poweroff.8 +usr/share/man/man8/runlevel.8 +usr/share/man/man8/reboot.8 +usr/share/man/man8/shutdown.8 +usr/share/man/man8/telinit.8 +usr/share/man/man8/init.8 +usr/share/man/man5/initscript.5 +usr/share/man/man5/inittab.5 +usr/include/initreq.h diff --git a/sysvinit-core.links b/sysvinit-core.links new file mode 100644 index 00000000..517461dd --- /dev/null +++ b/sysvinit-core.links @@ -0,0 +1,3 @@ +sbin/halt sbin/poweroff +sbin/halt sbin/reboot +sbin/init sbin/telinit diff --git a/sysvinit-core.lintian-overrides b/sysvinit-core.lintian-overrides new file mode 100644 index 00000000..0f27de2e --- /dev/null +++ b/sysvinit-core.lintian-overrides @@ -0,0 +1 @@ +sysvinit-core: depends-on-essential-package-without-using-version pre-depends: sysvinit-utils diff --git a/sysvinit-core.postinst b/sysvinit-core.postinst new file mode 100755 index 00000000..44b6fbad --- /dev/null +++ b/sysvinit-core.postinst @@ -0,0 +1,139 @@ +#! /bin/sh +# +# sysvinit postinst +# + +set -e + +# Source debconf library. +. /usr/share/debconf/confmodule + +# Restart init, and migrate to /run/initctl if needed. +do_restart() { + INITCTL=/run/initctl + case "$(uname -s)" in + *FreeBSD) + OLDINITCTL=/etc/.initctl + ;; + *) + OLDINITCTL=/dev/initctl + ;; + esac + + # PID of init; may not always be 1 but this code isn't run in + # these cases (Hurd). Use for sending signals and checking if + # init is running. + PID=1 + + # Create /run/initctl if not present, and also create compatibility + # symlinks + if [ ! -p "$INITCTL" ] + then + # Create new control channel + echo "sysvinit: creating $INITCTL" + rm -f $INITCTL + mkfifo -m 600 $INITCTL + fi + + # Replace old control channel with symlink + ln -s "$INITCTL" "$OLDINITCTL.new" + mv "$OLDINITCTL.new" "$OLDINITCTL" + + # Reopen control channel (uses new channel). + kill -s USR1 "$PID" + + # Tell init to re-exec itself. We loop on failure to reduce + # the chance of a race before the new control channel is + # opened. + echo -n "sysvinit: restarting..." + for delay in 0 1 2 3 4 5 6 fail; + do + if init u + then + echo " done." + break + else + if [ "$delay" = "fail" ] + then + echo " failed." + else + echo -n "." + sleep "$delay" + fi + fi + done + + # Remove old pipe if present. No longer in use after re-exec. + if [ -p "$OLDINITCTL" ] + then + rm -f "$OLDINITCTL" + fi +} + +case "$1" in + configure) + oldver=$2 + ;; + abort-upgrade|abort-remove|abort-deconfigure) + exit 0 + ;; +esac + +umask 022 + +rm -f /etc/ioctl.save + +if [ ! -f /etc/inittab ] +then + cp -p /usr/share/sysvinit/inittab /etc/inittab +elif [ "$(uname)" = GNU ]; then + ITAB=/etc/inittab + ITABNEW=${ITAB}.dpkg-new + cp $ITAB $ITABNEW + if fgrep -q '/libexec/getty' $ITABNEW; then + sed -e 's|/libexec/getty|/sbin/getty|' \ + -i $ITABNEW + fi + if ! grep -q '^c:' $ITABNEW; then + sed -e '/^6:/a c:23:respawn:/sbin/getty 38400 console' \ + -i $ITABNEW + fi + + if ! diff $ITAB $ITABNEW >/dev/null; then + db_get sysvinit/hurd-fix-inittab + if [ "${RET}" = "true" ]; then + mv -- $ITAB ${ITAB}.dpkg-old + mv -- $ITABNEW $ITAB + fi + else + rm -f -- $ITABNEW + fi +fi + +restart=yes + +chroot=0 +ischroot || chroot="$?" + +if [ "$chroot" != "1" ]; then + restart=no +fi + +# If systemd is running, don't restart init or doing any initctl +# migration. +if [ -d /run/systemd/system ]; then + restart=no +fi +if [ "$(uname -s)" = "GNU" ]; then + restart=no +fi + +if [ "$restart" = "yes" ]; then + do_restart +else + echo "Not restarting sysvinit" +fi + +#DEBHELPER# + +exit 0 diff --git a/sysvinit-core.templates b/sysvinit-core.templates new file mode 100644 index 00000000..be1ddc48 --- /dev/null +++ b/sysvinit-core.templates @@ -0,0 +1,14 @@ +Template: sysvinit/hurd-fix-inittab +Type: boolean +_Description: Update getty pathnames and add hurd-console? + Your /etc/inittab seems to use /libexec/getty as getty and/or to miss + hurd-console entry. The default inittab has been changed, however your + /etc/inittab has been modified. Note that sysvinit has not been used + to boot an Hurd system for long, so any errors in that file would not + have shown up earlier. + . + If you allow this change, a backup will be stored in /etc/inittab.dpkg-old. + . + If you don't allow this change, an updated inittab will be written to + /etc/inittab.dpkg-new. Please review the changes and update your + /etc/inittab accordingly. diff --git a/sysvinit-utils.NEWS b/sysvinit-utils.NEWS new file mode 100644 index 00000000..3fc12132 --- /dev/null +++ b/sysvinit-utils.NEWS @@ -0,0 +1,9 @@ +sysvinit-utils (2.88dsf-17) unstable; urgency=low + + bootlogd has moved from sysvinit-utils to a separate bootlogd package. If + you wish to continue using bootlogd, please install the bootlogd package. + Note that the configuration file /etc/default/bootlogd and its option + BOOTLOGD_ENABLE no longer exist; if you do not wish to run bootlogd, remove + the bootlogd package. + + -- Josh Triplett Mon, 19 Dec 2011 12:03:08 +0000 diff --git a/sysvinit-utils.install b/sysvinit-utils.install new file mode 100644 index 00000000..0b650913 --- /dev/null +++ b/sysvinit-utils.install @@ -0,0 +1,7 @@ +sbin/fstab-decode +sbin/killall5 +usr/share/man/man8/fstab-decode.8 +usr/share/man/man8/killall5.8 +usr/share/man/man8/pidof.8 +debian/init-d-script lib/init +debian/vars.sh lib/init diff --git a/sysvinit-utils.links b/sysvinit-utils.links new file mode 100644 index 00000000..f49b40eb --- /dev/null +++ b/sysvinit-utils.links @@ -0,0 +1 @@ +sbin/killall5 bin/pidof diff --git a/sysvinit-utils.manpages b/sysvinit-utils.manpages new file mode 100644 index 00000000..c4d68695 --- /dev/null +++ b/sysvinit-utils.manpages @@ -0,0 +1 @@ +debian/init-d-script.5 diff --git a/sysvinit-watch b/sysvinit-watch new file mode 100644 index 00000000..f449c64a --- /dev/null +++ b/sysvinit-watch @@ -0,0 +1,2 @@ +version=2 +ftp://ftp.cistron.nl/pub/people/miquels/sysvinit/sysvinit-([\d\.\d]+)\.tar\.gz diff --git a/vars.sh b/vars.sh new file mode 100644 index 00000000..f0280fed --- /dev/null +++ b/vars.sh @@ -0,0 +1,53 @@ +# +# Set rcS vars +# + +# Because /etc/default/rcS isn't a conffile, it's never updated +# automatically. So that an empty or outdated file missing newer +# options works correctly, set the default values here. +TMPTIME=0 +SULOGIN=no +DELAYLOGIN=no +UTC=yes +VERBOSE=no +FSCKFIX=no + +# Source conffile +if [ -f /etc/default/rcS ]; then + . /etc/default/rcS +fi + +# Unset old unused options +unset EDITMOTD +unset RAMRUN +unset RAMLOCK +# Don't unset RAMSHM and RAMTMP for now. + +# Parse kernel command line +if [ -r /proc/cmdline ]; then + for ARG in $(cat /proc/cmdline); do + case $ARG in + + # check for bootoption 'noswap' and do not activate swap + # partitions/files when it is set. + noswap) + NOSWAP=yes + ;; + + # Accept the same 'quiet' option as the kernel, but only + # during boot and shutdown. Only use this rule when the + # variables set by init.d/rc is present. + quiet) + if [ "$RUNLEVEL" ] && [ "$PREVLEVEL" ] ; then + VERBOSE="no" + fi + ;; + esac + done +fi + +# But allow both rcS and the kernel options 'quiet' to be overrided +# when INIT_VERBOSE=yes is used as well. +if [ "$INIT_VERBOSE" ] ; then + VERBOSE="$INIT_VERBOSE" +fi diff --git a/watch b/watch new file mode 100644 index 00000000..11db5e59 --- /dev/null +++ b/watch @@ -0,0 +1,3 @@ +version=3 +http://download.savannah.gnu.org/releases/sysvinit/ \ +(?:|.*/)sysvinit(?:[_\-]v?|)(\d[^\s/]*)\.(?:tar\.xz|txz|tar\.bz2|tbz2|tar\.gz|tgz) -- cgit v1.2.3 From 9679fabad8aa6b81e276016d1448c856db6376f3 Mon Sep 17 00:00:00 2001 From: Debian sysvinit maintainers Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: _doc_manuals.dpatch Purpose: Misc patches to manual pages Authour: the Debian ALSA psychos Fixes: - Status: unknown Gbp-Pq: Name 10_doc_manuals.dpatch --- man/init.8 | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/man/init.8 b/man/init.8 index d106a164..f2b82738 100644 --- a/man/init.8 +++ b/man/init.8 @@ -56,21 +56,34 @@ A \fIrunlevel\fP is a software configuration of the system which allows only a selected group of processes to exist. The processes spawned by \fBinit\fP for each of these runlevels are defined in the \fB/etc/inittab\fP file. \fBInit\fP can be in one of eight runlevels: -\fB0\(en6\fP and \fBS\fP or \fBs\fP. The runlevel is +\fB0\(en6\fP and \fBS\fP (a.k.a. \fBs\fP). The runlevel is changed by having a privileged user run \fBtelinit\fP, which sends appropriate signals to \fBinit\fP, telling it which runlevel to change to. .PP -Runlevels \fB0\fP, \fB1\fP, and \fB6\fP are reserved. Runlevel 0 is used to -halt the system, runlevel 6 is used to reboot the system, and runlevel -1 is used to get the system down into single user mode. Runlevel \fBS\fP -is not really meant to be used directly, but more for the scripts that are -executed when entering runlevel 1. For more information on this, +Runlevels \fBS\fP, \fB0\fP, \fB1\fP, and \fB6\fP are reserved. +Runlevel S is used to initialize the system on boot. +When starting runlevel S (on boot) +or runlevel 1 (switching from a multi-user runlevel) +the system is entering ``single-user mode'', after which the +current runlevel is S. +Runlevel 0 is used to halt the system; +runlevel 6 is used to reboot the system. +.PP +After booting through S the system automatically enters one of +the multi-user runlevels 2 through 5, unless there was some +problem that needs to be fixed by the administrator in +single-user mode. +Normally after entering single-user mode +the administrator performs maintenance and then reboots the system. +.PP +For more information, see the manpages for \fBshutdown\fP(8) and \fBinittab\fP(5). .PP Runlevels 7-9 are also valid, though not really documented. This is because "traditional" Unix variants don't use them. -In case you're curious, runlevels \fIS\fP and \fIs\fP are in fact the same. +.PP +Runlevels \fIS\fP and \fIs\fP are the same. Internally they are aliases for the same runlevel. .\"}}} .PP @@ -82,9 +95,10 @@ determines the initial runlevel of the system. If there is no such entry (or no \fB/etc/inittab\fP at all), a runlevel must be entered at the system console. .PP -Runlevel \fBS\fP or \fBs\fP bring the system to single user mode -and do not require an \fB/etc/inittab\fP file. In single user mode, -\fB/sbin/sulogin\fP is invoked on \fB/dev/console\fP. +Runlevel \fBS\fP or \fBs\fP initialize the system +and do not require an \fB/etc/inittab\fP file. +.PP +In single user mode, \fB/sbin/sulogin\fP is invoked on \fB/dev/console\fP. .PP When entering single user mode, \fBinit\fP initializes the consoles \fBstty\fP settings to sane values. Clocal mode is set. Hardware @@ -283,6 +297,14 @@ remain in the same process group which was originally created for them. If the processes change their group, \fBinit\fP can't kill them and you may end up with two processes reading from one terminal line. +.PP +On a Debian system, entering runlevel 1 causes all processes +to be killed except for kernel threads and the script that does +the killing and other processes in its session. +As a consequence of this, it isn't safe to return from runlevel 1 +to a multi-user runlevel: daemons that were started in runlevel S +and are needed for normal operation are no longer running. +The system should be rebooted. .\"}}} .\"{{{ Diagnostics .SH DIAGNOSTICS -- cgit v1.2.3 From f970ab467c209e307f59f93f75faf9ff90736bb1 Mon Sep 17 00:00:00 2001 From: Johannes Truschnigg Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: Document process field limit in error message and manual page Last-Update: 2012-11-23 Status: applied upstream Gbp-Pq: Name 11_inittab_limits.patch --- man/inittab.5 | 2 +- src/init.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/man/inittab.5 b/man/inittab.5 index e1d739d4..80aa084e 100644 --- a/man/inittab.5 +++ b/man/inittab.5 @@ -66,7 +66,7 @@ a `+' character, .B init will not do utmp and wtmp accounting for that process. This is needed for gettys that insist on doing their own utmp/wtmp housekeeping. This is also -a historic bug. +a historic bug. The length of this field is limited to 127 characters. .\"}}} .PP The \fIrunlevels\fP field may contain multiple characters for different diff --git a/src/init.c b/src/init.c index 27532ade..f8bf891e 100644 --- a/src/init.c +++ b/src/init.c @@ -1314,7 +1314,7 @@ void read_inittab(void) if (rlevel && strlen(rlevel) > 11) strcpy(err, "rlevel field too long (max 11 characters)"); if (process && strlen(process) > 127) - strcpy(err, "process field too long"); + strcpy(err, "process field too long (max 127 characters)"); if (action && strlen(action) > 32) strcpy(err, "action field too long"); if (err[0] != 0) { -- cgit v1.2.3 From 4a3a6b927090c2e0cc4385f768b5838da56c8c80 Mon Sep 17 00:00:00 2001 From: Debian sysvinit maintainers Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: _lfs_cflags Purpose: Enable large file support Fixes: Needed on GNU/Hurd Status: Not submitted upstream Gbp-Pq: Name 11_lfs_cflags.patch --- src/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile b/src/Makefile index e2b8028c..69ca13e1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -11,6 +11,7 @@ CPPFLAGS = CFLAGS ?= -ansi -O2 -fomit-frame-pointer override CFLAGS += -W -Wall -D_GNU_SOURCE +override CFLAGS += $(shell getconf LFS_CFLAGS) STATIC = # For some known distributions we do not build all programs, otherwise we do. -- cgit v1.2.3 From 5527ff0692a98c41587a945f8ec5ed870fb8bb12 Mon Sep 17 00:00:00 2001 From: Christoph Anton Mitterer Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: Fixes for halt(8) manual page. Bug-Debian: http://bugs.debian.org/587923 Gbp-Pq: Name 11_man_halt8.patch --- man/halt.8 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/man/halt.8 b/man/halt.8 index 8ae3c636..9f326f6c 100644 --- a/man/halt.8 +++ b/man/halt.8 @@ -51,7 +51,7 @@ halt, reboot, poweroff \- stop the system. .\"}}} .\"{{{ Description .SH DESCRIPTION -\fBHalt\fP notes that the system is being brought down in the file +\fBhalt\fP notes that the system is being brought down in the file \fI/var/log/wtmp\fP, and then either tells the kernel to halt, reboot or power-off the system. .PP @@ -68,12 +68,12 @@ and 6, that is when the systems shutdown scripts are being run. .SH OPTIONS .IP \fB\-n\fP Don't sync before reboot or halt. Note that the kernel and storage -drivers may still sync. +drivers may still sync. This implies \fB\-d\fP. .IP \fB\-w\fP Don't actually reboot or halt but only write the wtmp record (in the \fI/var/log/wtmp\fP file). .IP \fB\-d\fP -Don't write the wtmp record. The \fB\-n\fP flag implies \fB\-d\fP. +Don't write the wtmp record. .IP \fB\-f\fP Force halt or reboot, don't call \fBshutdown\fP(8). .IP \fB\-i\fP -- cgit v1.2.3 From e636400978f85aade95a57ba4cbaccafd6c6902f Mon Sep 17 00:00:00 2001 From: Bjarni Ingi Gislason Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: _man_fstab_decode_typo Purpose: Fix typo in fstab-decode(8) font escape Fixes: - Status: applied upstream Gbp-Pq: Name 11_man_fstab_decode_typo --- man/fstab-decode.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/fstab-decode.8 b/man/fstab-decode.8 index 6e800214..e04faa36 100644 --- a/man/fstab-decode.8 +++ b/man/fstab-decode.8 @@ -26,7 +26,7 @@ fstab-decode \- run a command with fstab-encoded arguments .SH DESCRIPTION .B fstab-decode -decodes escapes in the specified \FIARGUMENT\fRs +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, -- cgit v1.2.3 From 9f41b013472abfd68950915a7b736287701cb163 Mon Sep 17 00:00:00 2001 From: Roger Leigh Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: Use /run/nologin instead of /etc/nologin Bug-Debian: http://bugs.debian.org/660862 Gbp-Pq: Name 11_run_nologin.patch --- man/shutdown.8 | 2 +- src/paths.h | 2 +- src/shutdown.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/man/shutdown.8 b/man/shutdown.8 index 919a77e4..9ce56e4c 100644 --- a/man/shutdown.8 +++ b/man/shutdown.8 @@ -119,7 +119,7 @@ Second, it can be in the format \fB+\fP\fIm\fP, in which \fIm\fP is the number of minutes to wait. The word \fBnow\fP is an alias for \fB+0\fP. .PP If shutdown is called with a delay, it will create the advisory file -.I /etc/nologin +.I /run/nologin which causes programs such as \fIlogin(1)\fP to not allow new user logins. This file is created five minutes before the shutdown sequence starts. Shutdown removes this file if it is stopped before it diff --git a/src/paths.h b/src/paths.h index 232a9441..74c867e9 100644 --- a/src/paths.h +++ b/src/paths.h @@ -28,7 +28,7 @@ #define SDALLOW "/etc/shutdown.allow" /* Users allowed to shutdown */ #define INITTAB "/etc/inittab" /* Location of inittab */ #define INIT "/sbin/init" /* Location of init itself. */ -#define NOLOGIN "/etc/nologin" /* Stop user logging in. */ +#define NOLOGIN "/run/nologin" /* Stop user logging in. */ #define FASTBOOT "/fastboot" /* Enable fast boot. */ #define FORCEFSCK "/forcefsck" /* Force fsck on boot */ #define SDPID "/var/run/shutdown.pid" /* PID of shutdown program */ diff --git a/src/shutdown.c b/src/shutdown.c index 7e997da8..8c3345ae 100644 --- a/src/shutdown.c +++ b/src/shutdown.c @@ -234,7 +234,7 @@ void warn(int mins) } /* - * Create the /etc/nologin file. + * Create the /run/nologin file. */ void donologin(int min) { -- cgit v1.2.3 From ca9dd9adb102ab136cb22c664f48e45379ce6042 Mon Sep 17 00:00:00 2001 From: Debian sysvinit maintainers Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: _init_freebsd_vswtc Purpose: kFreeBSD is missing VSWTC, provide workaround. Authour: Petter Reinholdtsen Fixes: #579293 Status: applied upstream Gbp-Pq: Name 20_init_freebsd_vswtc.patch --- src/init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/init.c b/src/init.c index f8bf891e..3782a586 100644 --- a/src/init.c +++ b/src/init.c @@ -770,7 +770,9 @@ void console_stty(void) tty.c_cc[VEOF] = CEOF; tty.c_cc[VTIME] = 0; tty.c_cc[VMIN] = 1; +#ifdef VSWTC /* not defined on FreeBSD */ tty.c_cc[VSWTC] = _POSIX_VDISABLE; +#endif /* VSWTC */ tty.c_cc[VSTART] = CSTART; tty.c_cc[VSTOP] = CSTOP; tty.c_cc[VSUSP] = CSUSP; -- cgit v1.2.3 From efbd5df78d02cd0f672ba3a855141bca82f48775 Mon Sep 17 00:00:00 2001 From: Debian sysvinit maintainers Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: _killall5_hurd Purpose: Hurd is missing PATH_MAX, provide workaround. Authour: Werner Fink Fixes: ? Status: applied upstream Gbp-Pq: Name 30_killall5_hurd.patch --- src/killall5.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/killall5.c b/src/killall5.c index 5937d98e..d5856231 100644 --- a/src/killall5.c +++ b/src/killall5.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -59,6 +60,14 @@ char *Version = "@(#)killall5 2.86 31-Jul-2004 miquels@cistron.nl"; +#ifndef PATH_MAX +# ifdef MAXPATHLEN +# define PATH_MAX MAXPATHLEN +# else +# define PATH_MAX 2048 +# endif +#endif + #define STATNAMELEN 15 #define DO_NETFS 2 #define DO_STAT 1 -- cgit v1.2.3 From 707aa98883ccbc7468d01a3053ca4ec0939f05f8 Mon Sep 17 00:00:00 2001 From: Debian sysvinit maintainers Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: _killall5_hurd Gbp-Pq: Name 31_killall5_hurd.patch --- src/killall5.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/killall5.c b/src/killall5.c index d5856231..1e99d589 100644 --- a/src/killall5.c +++ b/src/killall5.c @@ -375,6 +375,19 @@ out: return 0; } +/* + * Get the maximal number of symlinks to follow. + */ +static int maxsymlinks(void) +{ + int v = sysconf(_SC_SYMLOOP_MAX); +#ifdef MAXSYMLINKS + if (v == -1) + return MAXSYMLINKS; +#endif + return v; +} + /* * Check path is located on a network based partition. */ @@ -382,7 +395,7 @@ int check4nfs(const char * path, char * real) { char buf[PATH_MAX+1]; const char *curr; - int deep = MAXSYMLINKS; + int deep = maxsymlinks(); if (!nlist) return 0; -- cgit v1.2.3 From d5452457c33e5a24cfe4025b2420198da30cfb97 Mon Sep 17 00:00:00 2001 From: Debian sysvinit maintainers Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: _multiarch_libcrypt Purpose: Use multiarch library search path to find and link with libcrypt Fixes: #629677 Status: Not sent upstream. Gbp-Pq: Name 40_multiarch_libcrypt.patch --- src/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Makefile b/src/Makefile index 69ca13e1..83a82e01 100644 --- a/src/Makefile +++ b/src/Makefile @@ -78,10 +78,15 @@ else SULOGINLIBS = endif +LIBDIR=/usr/lib # Additional libs for GNU libc. ifneq ($(wildcard /usr/lib*/libcrypt.a),) + SULOGINLIBS += -lcrypt +else +ifneq ($(wildcard $(LIBDIR)*/libcrypt.a),) SULOGINLIBS += -lcrypt endif +endif all: $(BIN) $(SBIN) $(USRBIN) -- cgit v1.2.3 From c00fedf75cac62d282a7b3b7c667f50be26a9c5b Mon Sep 17 00:00:00 2001 From: Debian sysvinit maintainers Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: _init_keep_utf8_ttyflag Purpose: Make sure the utf-8 flag is not cleared from the tty. Authour: Samuel Thibault Fixes: #547073 Status: applied upstream Gbp-Pq: Name 63_init_keep_utf8_ttyflag.patch --- src/init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/init.c b/src/init.c index 3782a586..399c1e24 100644 --- a/src/init.c +++ b/src/init.c @@ -786,10 +786,11 @@ void console_stty(void) /* * Set pre and post processing */ - tty.c_iflag = IGNPAR|ICRNL|IXON|IXANY; + tty.c_iflag = IGNPAR|ICRNL|IXON|IXANY #ifdef IUTF8 /* Not defined on FreeBSD */ - tty.c_iflag |= IUTF8; + | (tty.c_iflag & IUTF8) #endif /* IUTF8 */ + ; tty.c_oflag = OPOST|ONLCR; tty.c_lflag = ISIG|ICANON|ECHO|ECHOCTL|ECHOPRT|ECHOKE; -- cgit v1.2.3 From 118aceafa4f8d1c4b34cb959a364431f97eb8230 Mon Sep 17 00:00:00 2001 From: Debian sysvinit maintainers Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: _init_selinux_enabled Purpose: Try to fix the logic used to enable SELinux Authour: Petter Reinholdtsen Fixes: #580272 Status: applied upstream Gbp-Pq: Name 64_init_selinux_enabled.patch --- src/init.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/init.c b/src/init.c index 399c1e24..2c98d7f1 100644 --- a/src/init.c +++ b/src/init.c @@ -54,10 +54,6 @@ #ifdef WITH_SELINUX # include -# include -# ifndef MNT_DETACH /* present in glibc 2.10, missing in 2.7 */ -# define MNT_DETACH 2 -# endif #endif #ifdef __i386__ @@ -2872,11 +2868,9 @@ int main(int argc, char **argv) #ifdef WITH_SELINUX 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 (is_selinux_enabled() != 1) { if (selinux_init_load_policy(&enforce) == 0) { + putenv("SELINUX_INIT=YES"); execv(myname, argv); } else { if (enforce > 0) { @@ -2887,7 +2881,6 @@ int main(int argc, char **argv) } } } - if (rc == 0) umount2("/proc", MNT_DETACH); } #endif /* Start booting. */ -- cgit v1.2.3 From 720a228d33c99b8e9214e8d3e73a97e1fe644b1f Mon Sep 17 00:00:00 2001 From: Debian sysvinit maintainers Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: _kfreebsd_ifdown Purpose: Port ifdown.c to FreeBSD. Authour: Guillem Jover Fixes: #606565 Status: applied upstream Gbp-Pq: Name 92_kfreebsd_ifdown.patch --- src/ifdown.c | 72 ++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 21 deletions(-) diff --git a/src/ifdown.c b/src/ifdown.c index 3048a359..13cb3a52 100644 --- a/src/ifdown.c +++ b/src/ifdown.c @@ -37,6 +37,23 @@ char *v_ifdown = "@(#)ifdown.c 1.11 02-Jun-1998 miquels@cistron.nl"; #define MAX_IFS 64 +/* XXX: Ideally this would get detected at configure time... */ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ + defined(__NetBSD__) || defined(__OpenBSD__) +#define HAVE_SOCKADDR_SA_LEN 1 +#endif + +#ifndef _SIZEOF_ADDR_IFREQ +#ifdef HAVE_SOCKADDR_SA_LEN +#define _SIZEOF_ADDR_IFREQ(ifr) \ + ((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \ + (sizeof((ifr).ifr_name) + (ifr).ifr_addr.sa_len) : \ + sizeof(struct ifreq)) +#else +#define _SIZEOF_ADDR_IFREQ(ifr) sizeof(struct ifreq) +#endif +#endif + /* * First, we find all shaper devices and down them. Then we * down all real interfaces. This is because the comment in the @@ -45,10 +62,10 @@ char *v_ifdown = "@(#)ifdown.c 1.11 02-Jun-1998 miquels@cistron.nl"; */ int ifdown(void) { - struct ifreq ifr[MAX_IFS]; + char ifr_buf[sizeof(struct ifreq) * MAX_IFS]; + char *ifr_end; struct ifconf ifc; - int i, fd; - int numif; + int fd; int shaper; if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { @@ -56,8 +73,8 @@ int ifdown(void) perror("socket"); return -1; } - ifc.ifc_len = sizeof(ifr); - ifc.ifc_req = ifr; + ifc.ifc_len = sizeof(ifr_buf); + ifc.ifc_buf = ifr_buf; if (ioctl(fd, SIOCGIFCONF, &ifc) < 0) { fprintf(stderr, "ifdown: "); @@ -65,42 +82,55 @@ int ifdown(void) close(fd); return -1; } - numif = ifc.ifc_len / sizeof(struct ifreq); + ifr_end = ifr_buf + ifc.ifc_len; for (shaper = 1; shaper >= 0; shaper--) { - for (i = 0; i < numif; i++) { + char *ifr_next = ifr_buf; + + while (ifr_next < ifr_end) { + struct ifreq *ifr; + int flags; - if ((strncmp(ifr[i].ifr_name, "shaper", 6) == 0) + ifr = (struct ifreq *)ifr_next; + ifr_next += _SIZEOF_ADDR_IFREQ(*ifr); + + if ((strncmp(ifr->ifr_name, "shaper", 6) == 0) != shaper) continue; - if (strcmp(ifr[i].ifr_name, "lo") == 0) + if (strncmp(ifr->ifr_name, "lo", 2) == 0) continue; - if (strchr(ifr[i].ifr_name, ':') != NULL) + if (strchr(ifr->ifr_name, ':') != NULL) continue; /* Read interface flags */ - if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) < 0) { + if (ioctl(fd, SIOCGIFFLAGS, ifr) < 0) { fprintf(stderr, "ifdown: shutdown "); - perror(ifr[i].ifr_name); + perror(ifr->ifr_name); continue; } /* * Expected in according to * "UNIX Network Programming". */ -#ifdef ifr_flags -# define IRFFLAGS ifr_flags -#else /* Present on kFreeBSD */ -# define IRFFLAGS ifr_flagshigh +#ifdef ifr_flagshigh + flags = (ifr->ifr_flags & 0xffff) | + (ifr->ifr_flagshigh << 16); +#else + flags = ifr->ifr_flags; +#endif + if (flags & IFF_UP) { + flags &= ~(IFF_UP); +#ifdef ifr_flagshigh + ifr->ifr_flags = flags & 0xffff; + ifr->ifr_flagshigh = flags >> 16; +#else + ifr->ifr_flags = flags; #endif - if (ifr[i].IRFFLAGS & IFF_UP) { - ifr[i].IRFFLAGS &= ~(IFF_UP); - if (ioctl(fd, SIOCSIFFLAGS, &ifr[i]) < 0) { + if (ioctl(fd, SIOCSIFFLAGS, ifr) < 0) { fprintf(stderr, "ifdown: shutdown "); - perror(ifr[i].ifr_name); + perror(ifr->ifr_name); } } -#undef IRFFLAGS } } close(fd); -- cgit v1.2.3 From 43057b5650ffb530ecd7741255d42092615a3dcf Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: Change /dev/initctl to /run/initctl to work on kFreeBSD Named pipes can not exist in /dev/ on kFreeBSD. Move it elsewhere. Last-Update: 2012-01-08 Fixes: #638019 Status: not yet sent upstream Gbp-Pq: Name 93_run_initctl.patch --- doc/Install | 2 +- man/init.8 | 8 ++++---- src/Makefile | 8 ++++---- src/init.c | 12 ++++++------ src/initreq.h | 8 ++------ src/shutdown.c | 2 +- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/doc/Install b/doc/Install index 05f23a29..fdd25fc7 100644 --- a/doc/Install +++ b/doc/Install @@ -48,7 +48,7 @@ You might want to create a file called "/etc/shutdown.allow". Read the manual page on shutdown to find out more about this. Running from a read-only file system (CDROM?): -o All communication to init goes through the FIFO /dev/initctl. +o All communication to init goes through the FIFO /run/initctl. There should be no problem using a read-only root file system IF you use a Linux kernel > 1.3.66. Older kernels don't allow writing to a FIFO on a read-only file system. diff --git a/man/init.8 b/man/init.8 index f2b82738..eae722d1 100644 --- a/man/init.8 +++ b/man/init.8 @@ -144,7 +144,7 @@ letters \fBF\fP, \fBO\fP or \fBL\fP, init will behave as if it has read the letter \fBF\fP. .PP Usage of \fBSIGPWR\fP and \fB/etc/powerstatus\fP is discouraged. Someone -wanting to interact with \fBinit\fP should use the \fB/dev/initctl\fP +wanting to interact with \fBinit\fP should use the \fB/run/initctl\fP control channel - see the source code of the \fBsysvinit\fP package for more documentation about this. .PP @@ -248,7 +248,7 @@ can then manipulate the command line so that \fBps\fP(1) shows the current runlevel. .PP .SH INTERFACE -Init listens on a \fIfifo\fP in /dev, \fI/dev/initctl\fP, for messages. +Init listens on a \fIfifo\fP in /run, \fI/run/initctl\fP, for messages. \fBTelinit\fP uses this to communicate with init. The interface is not very well documented or finished. Those interested should study the \fIinitreq.h\fP file in the \fIsrc/\fP subdirectory of the \fBinit\fP @@ -262,7 +262,7 @@ Has the same effect as \fBtelinit q\fP. .TP 0.5i .B SIGUSR1 On receipt of this signals, init closes and re-opens its control fifo, -\fB/dev/initctl\fP. Useful for bootscripts when /dev is remounted. +\fB/run/initctl\fP. .TP 0.5i .B SIGINT Normally the kernel sends this signal to init when CTRL-ALT-DEL is @@ -287,7 +287,7 @@ file in the directory \fI/etc/init.d\fP explaining how these scripts work. /dev/console /var/run/utmp /var/log/wtmp -/dev/initctl +/run/initctl .fi .\"}}} .\"{{{ Warnings diff --git a/src/Makefile b/src/Makefile index 83a82e01..cc7a2969 100644 --- a/src/Makefile +++ b/src/Makefile @@ -182,8 +182,8 @@ ifeq ($(ROOT),) # # This part is skipped on Debian systems, the # debian.preinst script takes care of it. - @if [ ! -p /dev/initctl ]; then \ - echo "Creating /dev/initctl"; \ - rm -f /dev/initctl; \ - mknod -m 600 /dev/initctl p; fi + @if [ ! -p /run/initctl ]; then \ + echo "Creating /run/initctl"; \ + rm -f /run/initctl; \ + mknod -m 600 /run/initctl p; fi endif diff --git a/src/init.c b/src/init.c index 2c98d7f1..4d2becfe 100644 --- a/src/init.c +++ b/src/init.c @@ -129,7 +129,7 @@ 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 *console_dev; /* Console device. */ -int pipe_fd = -1; /* /dev/initctl */ +int pipe_fd = -1; /* /run/initctl */ int did_boot = 0; /* Did we already do BOOT* stuff? */ int main(int, char **); @@ -2174,13 +2174,13 @@ void check_init_fifo(void) int quit = 0; /* - * First, try to create /dev/initctl if not present. + * First, try to create /run/initctl if not present. */ if (stat(INIT_FIFO, &st2) < 0 && errno == ENOENT) (void)mkfifo(INIT_FIFO, 0600); /* - * If /dev/initctl is open, stat the file to see if it + * If /run/initctl is open, stat the file to see if it * is still the _same_ inode. */ if (pipe_fd >= 0) { @@ -2194,7 +2194,7 @@ void check_init_fifo(void) } /* - * Now finally try to open /dev/initctl + * Now finally try to open /run/initctl */ if (pipe_fd < 0) { if ((pipe_fd = open(INIT_FIFO, O_RDWR|O_NONBLOCK)) >= 0) { @@ -2500,7 +2500,7 @@ void process_signals() } if (ISMEMBER(got_signals, SIGUSR1)) { /* - * SIGUSR1 means close and reopen /dev/initctl + * SIGUSR1 means close and reopen /run/initctl */ INITDBG(L_VB, "got SIGUSR1"); close(pipe_fd); @@ -2736,7 +2736,7 @@ int telinit(char *progname, int argc, char **argv) chdir("/"); /* Open the fifo and write a command. */ - /* Make sure we don't hang on opening /dev/initctl */ + /* Make sure we don't hang on opening /run/initctl */ SETSIG(sa, SIGALRM, signal_handler, 0); alarm(3); if ((fd = open(INIT_FIFO, O_WRONLY)) >= 0) { diff --git a/src/initreq.h b/src/initreq.h index 757ffe0e..564a3630 100644 --- a/src/initreq.h +++ b/src/initreq.h @@ -1,5 +1,5 @@ /* - * initreq.h Interface to talk to init through /dev/initctl. + * initreq.h Interface to talk to init through /run/initctl. * * Copyright (C) 1995-2004 Miquel van Smoorenburg * @@ -25,11 +25,7 @@ #include -#if defined(__FreeBSD_kernel__) -# define INIT_FIFO "/etc/.initctl" -#else -# define INIT_FIFO "/dev/initctl" -#endif +#define INIT_FIFO "/run/initctl" #define INIT_MAGIC 0x03091969 #define INIT_CMD_START 0 diff --git a/src/shutdown.c b/src/shutdown.c index 8c3345ae..23c0774f 100644 --- a/src/shutdown.c +++ b/src/shutdown.c @@ -173,7 +173,7 @@ int init_setenv(char *name, char *value) /* * Open the fifo and write the command. - * Make sure we don't hang on opening /dev/initctl + * Make sure we don't hang on opening /run/initctl */ memset(&sa, 0, sizeof(sa)); sa.sa_handler = alrm_handler; -- cgit v1.2.3 From 9584cedb751d6261f3cac5a283916e4e2adacd46 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: Replace "cons25" with "xterm" on GNU/kFreeBSD. Origin: http://anonscm.debian.org/gitweb/?p=collab-maint/sysvinit;a=commitdiff;h=3e8e00d23f57957645285937fbdcaea30adc7149 Gbp-Pq: Name 94_kfreebsd_xterm.patch --- src/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/init.c b/src/init.c index 4d2becfe..496355bb 100644 --- a/src/init.c +++ b/src/init.c @@ -747,11 +747,11 @@ void console_stty(void) #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 + * "xterm". 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"); + putenv ("TERM=xterm"); #endif (void) tcgetattr(fd, &tty); -- cgit v1.2.3 From 58868e31cc1455df3aef03d04c70d463c7693688 Mon Sep 17 00:00:00 2001 From: Mats Erik Andersson Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: Adapt TIOCCONS call to kfreebsd. Isolate Linux-only forms of ioctl call with TIOCCONS. The BSD form of this needs a pointer to an integer, and its fails with a NULL pointer. Last-Update: 2012-04-03 Fixes: #576443 Status: applied upstream Gbp-Pq: Name 95_kfreebsd_bootlogd.patch --- src/bootlogd.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bootlogd.c b/src/bootlogd.c index 570d3822..55c470f2 100644 --- a/src/bootlogd.c +++ b/src/bootlogd.c @@ -482,6 +482,9 @@ int main(int argc, char **argv) int realfd; int n, m, i; int todo; +#ifndef __linux__ /* BSD-style ioctl needs an argument. */ + int on = 1; +#endif fp = NULL; logfile = LOGFILE; @@ -554,15 +557,20 @@ int main(int argc, char **argv) return 1; } +#ifdef __linux__ (void)ioctl(0, TIOCCONS, NULL); -#if 1 /* Work around bug in 2.1/2.2 kernels. Fixed in 2.2.13 and 2.3.18 */ if ((n = open("/dev/tty0", O_RDWR)) >= 0) { (void)ioctl(n, TIOCCONS, NULL); close(n); } #endif - if (ioctl(pts, TIOCCONS, NULL) < 0) { +#ifdef __linux__ + if (ioctl(pts, TIOCCONS, NULL) < 0) +#else /* BSD usage of ioctl TIOCCONS. */ + if (ioctl(pts, TIOCCONS, &on) < 0) +#endif + { fprintf(stderr, "bootlogd: ioctl(%s, TIOCCONS): %s\n", buf, strerror(errno)); return 1; -- cgit v1.2.3 From 48f10f55b758cc86c38ae9f7cbce57158b739842 Mon Sep 17 00:00:00 2001 From: Martin Buck Date: Sun, 7 Oct 2018 14:04:09 +0000 Subject: Allow multiple console output When booting a kernel with multiple serial console support, or multuiple console arguments ala "console=tty1 console=ttyS0,9600" the kernel will output messages to all consoles, init however will not. It will only send output to, and accept input from, the last of the consoles. This patch fixes it. Origin: other, https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=181756 Bug-Debian: https://bugs.debian.org/181756 Forwarded: no Last-Update: 2014-07-20 Gbp-Pq: Name 96_allow_multiple_console_output.patch --- src/bootlogd.c | 158 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 83 insertions(+), 75 deletions(-) diff --git a/src/bootlogd.c b/src/bootlogd.c index 55c470f2..bff403ab 100644 --- a/src/bootlogd.c +++ b/src/bootlogd.c @@ -57,6 +57,7 @@ char *Version = "@(#) bootlogd 2.86 03-Jun-2004 miquels@cistron.nl"; #define LOGFILE "/var/log/boot" +#define MAX_CONSOLES 16 char ringbuf[32768]; char *endptr = ringbuf + sizeof(ringbuf); @@ -73,6 +74,11 @@ struct line { int pos; } line; +struct real_cons { + char name[1024]; + int fd; +}; + /* * Console devices as listed on the kernel command line and * the mapping to actual devices in /dev @@ -235,10 +241,10 @@ int isconsole(char *s, char *res, int rlen) } /* - * Find out the _real_ console. Assume that stdin is connected to + * Find out the _real_ console(s). Assume that stdin is connected to * the console device (/dev/console). */ -int consolename(char *res, int rlen) +int consolenames(struct real_cons *cons, int max_consoles) { #ifdef TIOCGDEV unsigned int kdev; @@ -247,34 +253,9 @@ int consolename(char *res, int rlen) char buf[256]; char *p; int didmount = 0; - int n, r; + int n; int fd; - - fstat(0, &st); - if (major(st.st_rdev) != 5 || minor(st.st_rdev) != 1) { - /* - * Old kernel, can find real device easily. - */ - 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 -# 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 + int considx, num_consoles = 0; #ifdef __linux__ /* @@ -283,7 +264,7 @@ int consolename(char *res, int rlen) stat("/", &st); if (stat("/proc", &st2) < 0) { perror("bootlogd: /proc"); - return -1; + return 0; } if (st.st_dev == st2.st_dev) { if (mount("proc", "/proc", "proc", 0, NULL) < 0) { @@ -293,21 +274,21 @@ int consolename(char *res, int rlen) didmount = 1; } - n = 0; - r = -1; + n = -1; if ((fd = open("/proc/cmdline", O_RDONLY)) < 0) { perror("bootlogd: /proc/cmdline"); } else { buf[0] = 0; - if ((n = read(fd, buf, sizeof(buf) - 1)) >= 0) - r = 0; - else + if ((n = read(fd, buf, sizeof(buf) - 1)) < 0) perror("bootlogd: /proc/cmdline"); close(fd); } if (didmount) umount("/proc"); + + + if (n < 0) return 0; + - if (r < 0) return r; /* * OK, so find console= in /proc/cmdline. @@ -315,21 +296,32 @@ int consolename(char *res, int rlen) */ p = buf + n; *p-- = 0; - r = -1; while (p >= buf) { if (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\n') { *p-- = 0; continue; } if (strncmp(p, "console=", 8) == 0 && - isconsole(p + 8, res, rlen)) { - r = 0; - break; + isconsole(p + 8, cons[num_consoles].name, sizeof(cons[num_consoles].name))) { + /* + * Suppress duplicates + */ + for (considx = 0; considx < num_consoles; considx++) { + if (!strcmp(cons[num_consoles].name, cons[considx].name)) { + goto dontuse; + } + } + + num_consoles++; + if (num_consoles >= max_consoles) { + break; + } } +dontuse: p--; } - if (r == 0) return r; + if (num_consoles > 0) return num_consoles; #endif /* @@ -337,12 +329,12 @@ int consolename(char *res, int rlen) * guess the default console. */ for (n = 0; defcons[n]; n++) - if (isconsole(defcons[n], res, rlen)) - return 0; + if (isconsole(defcons[n], cons[0].name, sizeof(cons[0].name))) + return 1; fprintf(stderr, "bootlogd: cannot deduce real console device\n"); - return -1; + return 0; } @@ -472,7 +464,6 @@ int main(int argc, char **argv) struct timeval tv; fd_set fds; char buf[1024]; - char realcons[1024]; char *p; char *logfile; char *pidfile; @@ -485,6 +476,9 @@ int main(int argc, char **argv) #ifndef __linux__ /* BSD-style ioctl needs an argument. */ int on = 1; #endif + int considx; + struct real_cons cons[MAX_CONSOLES]; + int num_consoles, consoles_left; fp = NULL; logfile = LOGFILE; @@ -531,18 +525,22 @@ int main(int argc, char **argv) /* * Open console device directly. */ - if (consolename(realcons, sizeof(realcons)) < 0) - return 1; - - if (strcmp(realcons, "/dev/tty0") == 0) - strcpy(realcons, "/dev/tty1"); - if (strcmp(realcons, "/dev/vc/0") == 0) - strcpy(realcons, "/dev/vc/1"); - - if ((realfd = open_nb(realcons)) < 0) { - fprintf(stderr, "bootlogd: %s: %s\n", buf, strerror(errno)); + if ((num_consoles = consolenames(cons, MAX_CONSOLES)) <= 0) return 1; + consoles_left = num_consoles; + for (considx = 0; considx < num_consoles; considx++) { + if (strcmp(cons[considx].name, "/dev/tty0") == 0) + strcpy(cons[considx].name, "/dev/tty1"); + if (strcmp(cons[considx].name, "/dev/vc/0") == 0) + strcpy(cons[considx].name, "/dev/vc/1"); + + if ((cons[considx].fd = open_nb(cons[considx].name)) < 0) { + fprintf(stderr, "bootlogd: %s: %s\n", cons[considx].name, strerror(errno)); + consoles_left--; + } } + if (!consoles_left) + return 1; /* * Grab a pty, and redirect console messages to it. @@ -626,26 +624,34 @@ int main(int argc, char **argv) if ((n = read(ptm, inptr, endptr - inptr)) >= 0) { /* * Write data (in chunks if needed) - * to the real output device. + * to the real output devices. */ - m = n; - p = inptr; - while (m > 0) { - i = write(realfd, p, m); - if (i >= 0) { - m -= i; - p += i; - continue; - } - /* - * Handle EIO (somebody hung - * up our filedescriptor) - */ - realfd = write_err(pts, realfd, - realcons, errno); - if (realfd >= 0) continue; - got_signal = 1; /* Not really */ - break; + for (considx = 0; considx < num_consoles; considx++) { + if (cons[considx].fd < 0) continue; + m = n; + p = inptr; + while (m > 0) { + i = write(cons[considx].fd, p, m); + if (i >= 0) { + m -= i; + p += i; + continue; + } + /* + * Handle EIO (somebody hung + * up our filedescriptor) + */ + cons[considx].fd = write_err(pts, + cons[considx].fd, + cons[considx].name, errno); + if (cons[considx].fd >= 0) continue; + /* + * If this was the last console, + * generate a fake signal + */ + if (--consoles_left <= 0) got_signal = 1; + break; + } } /* @@ -691,7 +697,9 @@ int main(int argc, char **argv) close(pts); close(ptm); - close(realfd); + for (considx = 0; considx < num_consoles; considx++) { + close(cons[considx].fd); + } return 0; } -- cgit v1.2.3 From 4dc23679e1d872c8bcd792fb5c8048f193caba57 Mon Sep 17 00:00:00 2001 From: Roger Leigh Date: Thu, 22 Nov 2018 16:13:55 +0000 Subject: Use /run/nologin instead of /etc/nologin Bug-Debian: http://bugs.debian.org/660862 Gbp-Pq: Name 11_run_nologin.patch --- man/shutdown.8 | 2 +- src/paths.h | 2 +- src/shutdown.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/man/shutdown.8 b/man/shutdown.8 index f747dd91..595f1f2b 100644 --- a/man/shutdown.8 +++ b/man/shutdown.8 @@ -140,7 +140,7 @@ Second, it can be in the format \fB+\fP\fIm\fP, in which \fIm\fP is the number of minutes to wait. The word \fBnow\fP is an alias for \fB+0\fP. .PP If shutdown is called with a delay, it will create the advisory file -.I /etc/nologin +.I /run/nologin which causes programs such as \fIlogin(1)\fP to not allow new user logins. This file is created five minutes before the shutdown sequence starts. Shutdown removes this file if it is stopped before it diff --git a/src/paths.h b/src/paths.h index 05f9c1bf..c9b82c1a 100644 --- a/src/paths.h +++ b/src/paths.h @@ -28,7 +28,7 @@ #define SDALLOW "/etc/shutdown.allow" /* Users allowed to shutdown */ #define INITTAB "/etc/inittab" /* Location of inittab */ #define INIT "/sbin/init" /* Location of init itself. */ -#define NOLOGIN "/etc/nologin" /* Stop user logging in. */ +#define NOLOGIN "/run/nologin" /* Stop user logging in. */ #define FASTBOOT "/fastboot" /* Enable fast boot. */ #define FORCEFSCK "/forcefsck" /* Force fsck on boot */ #define SDPID "/var/run/shutdown.pid" /* PID of shutdown program */ diff --git a/src/shutdown.c b/src/shutdown.c index 91a40972..25cad6cf 100644 --- a/src/shutdown.c +++ b/src/shutdown.c @@ -244,7 +244,7 @@ void issue_warn(int mins) } /* - * Create the /etc/nologin file. + * Create the /run/nologin file. */ void donologin(int min) { -- cgit v1.2.3 From 2680748ecd572bb913e1d08bec94d18ebfd4b70a Mon Sep 17 00:00:00 2001 From: Debian sysvinit maintainers Date: Thu, 22 Nov 2018 16:13:55 +0000 Subject: _multiarch_libcrypt Purpose: Use multiarch library search path to find and link with libcrypt Fixes: #629677 Status: Not sent upstream. Gbp-Pq: Name 40_multiarch_libcrypt.patch --- src/Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Makefile b/src/Makefile index 3c93783b..b41d2e37 100644 --- a/src/Makefile +++ b/src/Makefile @@ -89,14 +89,14 @@ else SULOGINLIBS = endif +LIBDIR=/usr/lib # Additional libs for GNU libc. -ifneq ($(wildcard /usr/lib*/libcrypt.*),) +ifneq ($(wildcard /usr/lib*/libcrypt.a),) + SULOGINLIBS += -lcrypt +else +ifneq ($(wildcard $(LIBDIR)*/libcrypt.a),) SULOGINLIBS += -lcrypt endif - -# Additional libs for GNU libc / multiarch on Debian based systems. -ifneq ($(wildcard /usr/lib/*/libcrypt.*),) - SULOGINLIBS += -lcrypt endif all: $(BIN) $(SBIN) $(USRBIN) -- cgit v1.2.3