History log of /freebsd-11-stable/sbin/init/init.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 365534 09-Sep-2020 brooks

MFC r365279:

Remove risky compatability with old kernels

The badsys() handler for SIGSYS was added as a transtion aid for kernels
lacking sysctl() in 1993. It is unsafe and unsound so remove it rather
than running the risk of a privilege-dropping system call being silently
omitted.

This partially reverts SCCSID 6.12 (Berkeley) 03/03/93 "add code to
change the system security level".

Reviewed by: mckusick, imp, kevans
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D26289


# 346481 21-Apr-2019 kevans

MFC r337534-r337535

r337534:
Refactor common code into execute_script().

r337535:
Use NULLs instead of casted zeroes, for consistency.


# 346479 21-Apr-2019 kevans

MFC r337321, r337435, r337707, r337740, r337834, r337836, r337968

r337321:
Make it possible for init to execute any executable, not just sh(1)
scripts. This means one should be able to eg rewrite their /etc/rc
in Python.

r337435:
Move description of init_shell, init_script, and init_chroot kenv
tunables from loader(8) to init(8), since it's init that actually
uses them. Add .Xrs at their old place.

r337707:
Move around text in loader(8), in particular stuff related to ZFS,
to restore the usual section order.

r337740:
Add init_exec kenv(1) variable, to make init(8) execute a file
after opening the console, replacing init as PID 1.

From the user point of view, it makes it possible to run eg the
shell as PID 1, using 'set init_exec=/bin/sh' at the loader(8)
prompt.

r337834:
Add SECURITY section to loader(8).

r337836:
Improve formatting.

r337968:
Consistently use NULL to terminate the argv; no functional changes.

Relnotes: yes (init_exec kenv(1) variable)


# 333796 18-May-2018 gjb

MFC r315733, r315737, r315740, r330054:

r315733 (imp):
Impelemnt ttys onifexists in init.

Implement a new init(8) option in /etc/ttys. If this option is present
on the entry in /etc/ttys, the entry will be active if and only if it
exists. If the name starts with a '/', it will be considered an
absolute path. If not, it will be a path relative to /dev.

This allows one to turn off video console getty that aren't present
(while running a getty on them even when they aren't the system
console). Likewise with serial ports.

It differs from onifconsole in only requiring the device exist rather
than it be listed as one of the system consoles.

r315737 (ngie):
Unbreak world by adding sys/stat.h for stat(2)

r315740 (imp):
Simplify the code a little.

r330054 (trasz):
Improve missing tty handling in init(8). This removes a check that did
nothing - it was checking for ENXIO, which, with devfs, is no longer
returned - and was badly placed anyway, and replaces it with similar
one that works, and is done just before starting getty, instead of being
done when rereading ttys(5).

From the practical point of view, this makes init(8) handle disappearing
terminals (eg /dev/ttyU*) gracefully, without unneccessary getty restarts
and resulting error messages.

Reported by: Bart Ender, Andre Albsmeier
PR: 228315
Blocks: 11.2-BETA2
Approved by: re (marius)
Sponsored by: The FreeBSD Foundation


# 331722 29-Mar-2018 eadler

Revert r330897:

This was intended to be a non-functional change. It wasn't. The commit
message was thus wrong. In addition it broke arm, and merged crypto
related code.

Revert with prejudice.

This revert skips files touched in r316370 since that commit was since
MFCed. This revert also skips files that require $FreeBSD$ property
changes.

Thank you to those who helped me get out of this mess including but not
limited to gonzo, kevans, rgrimes.

Requested by: gjb (re)


# 330897 14-Mar-2018 eadler

Partial merge of the SPDX changes

These changes are incomplete but are making it difficult
to determine what other changes can/should be merged.

No objections from: pfg


# 321906 02-Aug-2017 delphij

MFC r320761:

- Use strlcat() instead of strncat().
- Use asprintf() and handle allocation errors.


# 308035 28-Oct-2016 kib

MFC r306808:
Add verbosity around failed reboot(2) call.


# 308034 28-Oct-2016 kib

MFC r306807:
When making a pause after detecting hard kill of the single-user
shell, ensure that we do sleep for at least the specified time, in
presence of signals.


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 299874 15-May-2016 araujo

For pointers use NULL instead of 0.

MFC after: 2 weeks.


# 299419 11-May-2016 trasz

When rerooting, take the init(8) path from argv[0] instead of fetching
it via kern.proc.pathname sysctl(2). In some cases - booting from NFS
or rerooting after replacing the init binary with a new one - the sysctl
would fail. In other cases - after upgrading, which moves the old init
to /sbin/init.bak - it would return /sbin/init.bak, which is the actual
path of the running init, instead of /sbin/init.

Reported by: Melissa Jenkins <melissa-freebsd at littlebluecar.co.uk>, jilles@
MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# 299417 11-May-2016 trasz

When rerooting, ignore ESRCH returned from kill(2). I couldn't reproduce
this by myself, but apparently it sometimes happens when rerooting from
single user mode.

Reported by: jilles@
MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# 298236 18-Apr-2016 araujo

Use NULL instead of 0 for pointers.

dbopen(3) will returns a NULL on error.

MFC after: 2 weeks.


# 290689 11-Nov-2015 trasz

Fix resource leaks in error cases.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation


# 290548 08-Nov-2015 trasz

Userspace part of reroot support. This makes it possible to change
the root filesystem without full reboot, using "reboot -r". This can
be used to to eg. boot from a temporary md_image preloaded by loader(8),
setup an iSCSI session, and continue booting from rootfs mounted over
iSCSI.

Reviewed by: kib@, bapt@
MFC after: 1 month
Relnotes: yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D3693


# 288446 01-Oct-2015 cperciva

Disable suspend when we're shutting down. This solves the "tell FreeBSD
to shut down; close laptop lid" scenario which otherwise tended to end
with a laptop overheating or the battery dying.

The implementation uses a new sysctl, kern.suspend_blocked; init(8) sets
this while rc.suspend runs, and the ACPI sleep code ignores requests while
the sysctl is set.

Discussed on: freebsd-acpi (35 emails)
MFC after: 1 week


# 270111 17-Aug-2014 neel

Remove LOG_ODELAY because it does nothing.

Reviewed by: jilles
CR: https://reviews.freebsd.org/D611


# 261635 08-Feb-2014 jilles

init: Remove code to track line numbers in /etc/ttys.

The tracking generated warnings when the line number of an existing tty in
/etc/ttys changed, which would corrupt utmp (as it was indexed by the line
number). With utmpx, the line number no longer matters, so the tracking is
no longer needed.


# 254288 13-Aug-2013 jilles

init: Set kernel login class and CPU mask on new processes.

In particular, this makes the kernel login class on processes started from
/etc/rc "daemon" instead of "default".

Reviewed by: trasz


# 236020 25-May-2012 jilles

init: Remove unnecessary 2-second delay before calling reboot(2).


# 233945 06-Apr-2012 ed

Properly clear the O_NONBLOCK flag after opening the TTY.

Though we should open the TTY with O_NONBLOCK to prevent rc(8) execution
from potentially stalling, we must not forget to clear the flag later
on, to prevent read(2) calls from failing later on.

This prevented the shell pathname prompt from working properly.

Reported by: kib


# 232977 14-Mar-2012 ed

Make init(8) slightly more robust when /dev/console is missing.

If the environment doesn't offer a working /dev/console, the existing
version of init(8) will simply refuse running rc(8) scripts. This means
you'll only have a system running init(8) and nothing else.

Change the code to do the following:

- Open /dev/console like we used to do, but make it more robust to use
O_NONBLOCK to prevent blocking on a carrier.
- If this fails, use /dev/null as stdin and /var/log/init.log as stdout
and stderr.
- If even this fails, use /dev/null as stdin, stdout and stderr.

So why us this useful? Well, if you remove the `getpid() == 1' check in
main(), you can now use init(8) inside jails to properly execute rc(8).
It still requires some polishing, as existing tools assume init(8) has
PID 1.

Also it is now possible to use use init(8) on `headless' devices that
don't even have a serial boot console.


# 232841 11-Mar-2012 ed

Fix whitespace.

MFC after: 1 week


# 231994 22-Feb-2012 kevlo

Handle NULL return from crypt(3). Mostly from DragonFly


# 231534 11-Feb-2012 ed

Move utmpx handling out of init(8).

This has the following advantages:

- During boot, the BOOT_TIME record is now written right after the file
systems become writable, but before users are allowed to log in. This
means that they can't cause `hidden logins' by logging in right before
init(8) kicks in.

- The pututxline(3) function may potentially block on file locking,
though this is very rare to occur. By placing it in an rc script, the
user can still kill it with ^C if needed.

- Most importantly: jails don't use init(8). This means that a force
reboot of a system running jails will leave stale entries in the
accounting database of the jails individually.


# 227081 04-Nov-2011 ed

Add missing static keywords for global variables to tools in sbin/.

These tools declare global variables without using the static keyword,
even though their use is limited to a single C-file, or without placing
an extern declaration of them in the proper header file.


# 217750 23-Jan-2011 jilles

init: Only run /etc/rc.shutdown if /etc/rc was run.

It does not make sense to shut down daemons that were not started. In
particular, this fixes loss of mixer settings when shutting down using
shutdown(8), init(8) or ctrl+alt+del from single-user mode.

If /etc/rc reboots, /etc/rc.shutdown is not run.

Also fix segfaults and other erratic behaviour if init receives SIGHUP or
SIGTSTP while in single-user mode.

This commit does not attempt to fix any badness with signal handlers
(assumption that pointers can be read and written atomically, EINTR race
condition). I believe it does not make this badness any worse.

Silence on: -arch@


# 203096 27-Jan-2010 ed

Remove stale inclusion of <ulog.h>.

This tool doesn't require libulog anymore.


# 202194 13-Jan-2010 ed

Migrate init(8) towards utmpx.

According to a comment, we cannot safely remove utmpx entries here
anymore. This is because the libc routines may block on file locking. In
an ideal world login(1) should just remove the entries, which is why I'm
disabling this code for now. If it turns out we get lots of stale
entries here, we should figure out a way to deal with that.


# 200161 05-Dec-2009 ed

Let init(8) and reboot(8) use utmpx to log wtmp entries.

logwtmp() gets called with the raw strings that are written to disk. For
regular user entries, this isn't too bad, but when booting/shutting
down, the contents get rather cryptic.

Just call the standardized pututxline().


# 194257 15-Jun-2009 ed

Remove redundant code from runshutdown() now tcsetsid(3) works reliably.

We can now just call setctty() without any problems. This means the
shell running the shutdown script is now the session leader, just like
on startup.


# 194198 14-Jun-2009 ed

Fix the staircase issue properly this time.

Even though I thought this bug was somewhere in the TTY layer, it turns
out init(8) doesn't make sure /dev/console is opened initially properly.
I've added revoke() to two pieces of code:

- death(): Apart from killing the gettys on shutdown, this doesn't
guarantee the TTY to be closed immediately.
- runshutdown(): Just like setctty(), we should revoke /dev/console.
Applications like syslogd may have file descriptors to the console.


# 183391 26-Sep-2008 delphij

Static-ify procedures in init(8).


# 173787 20-Nov-2007 obrien

Addition style(9) change.


# 173785 20-Nov-2007 obrien

style(9)


# 166484 04-Feb-2007 imp

Patches to allow one to allow one to specify a directory to chroot to.
This includes support for running a script to setup that directory.
The kenv variables init_chroot and init_script control this behavior,
and are documented in loader(8) that's about to be committed (along
with the other variables like init_path...).

Submitted by: Oliver Fromme
Reviewed by: myself, jhb (earlier versions)


# 159402 08-Jun-2006 kib

Reparent the process that executes the window= command from the ttys
to the init. This prevents zombies from being accumulated.

PR: bin/64198
Tested by: Eugene Grosbein <eugen at www svzserv kemerovo su>
Approved by: kan (mentor)
MFC after: 1 month


# 150154 15-Sep-2005 rse

Fix system shutdown timeout handling by again supporting longer running
shutdown procedures (which have a duration of more than 120 seconds).

We have two user-space affecting shutdown timeouts: a "soft" one in
/etc/rc.shutdown and a "hard" one in init(8). The first one can be
configured via /etc/rc.conf variable "rcshutdown_timeout" and defaults
to 30 seconds. The second one was originally (in 1998) intended to be
configured via sysctl(8) variable "kern.shutdown_timeout" and defaults
to 120 seconds.

Unfortunately, the "kern.shutdown_timeout" was declared "unused" in 1999
(as it obviously is actually not used within the kernel itself) and
hence was intentionally but misleadingly removed in revision 1.107 from
init_main.c. Kernel sysctl(8) variables are certainly a wrong way to
control user-space processes in general, but in this particular case the
sysctl(8) variable should have remained as it supports init(8), which
isn't passed command line flags (which in turn could have been set via
/etc/rc.conf), etc.

As there is already a similar "kern.init_path" sysctl(8) variable which
directly affects init(8), resurrect the init(8) shutdown timeout under
sysctl(8) variable "kern.init_shutdown_timeout". But this time document
it as being intentionally unused within the kernel and used by init(8).
Also document it in the manpages init(8) and rc.conf(5).

Reviewed by: phk
MFC after: 2 weeks


# 140070 11-Jan-2005 delphij

Make WARNS=6 happy with our init(8):
- Use more ``const''s where suitable.
- Define strk() as a static function in global scope.
This avoids the "nested extern declaration" warnings.
- Use static initialization of strings, rather than
referring string constants through char *.
- Bump WARNS from 0 to 6.


# 135868 28-Sep-2004 imp

Turns out that revision 1.52 was a bad idea. It broke the long
standing ability to list a non-existant device in /etc/ttys to keep it
from dying. This is a documented feature of init(8):
The init utility can also be used to keep arbitrary daemons running,
automatically restarting them if they die. In this case, the first field
in the ttys(5) file must not reference the path to a configured device
node and will be passed to the daemon as the final argument on its com-
mand line. This is similar to the facility offered in the AT&T System V
UNIX /etc/inittab.

So rather than fix the man page to 'break' this feature, back out the change.

At the time this change was made, people felt that the spamage from
getty was annoying on headless consoles. Andrew Gallatin noted:
> Most of my machines are headless without video cards and use a serial
> console. With devfs this means that /dev/ttyv[1-N] do not exist and
> getty bitches like this:
>
> Sep 26 11:00:11 monet getty[543]: open /dev/ttyv1: No such file or directory

and we went off and applied this hack rather than fixing getty to
sleep forever when it gets an unknown device, as was Andrew's other
suggestion. Since it breaks things, I'm off to do that instead.


# 128073 09-Apr-2004 markm

Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core, imp


# 126836 11-Mar-2004 bde

Fixed misspellings of 0 as NULL.


# 123157 05-Dec-2003 imp

Fix the case where one goes from zero to more than zero items enabled
in /etc/ttys. Before this fix, once the count of active services
reaches 0, one could never restart any more without a reboot.

Steve Passe did the leg work on this patch. After he found the fix,
we discovered that an identical fix had been made to NetBSD.

Approved by: re@ <scottl>
Approval tool: peril sensitive sunglasses


# 108002 17-Dec-2002 green

Back out the previous commit, since there could be dire consequences if
/etc/rc were accidentally executed (as requested by other committeers).


# 107995 17-Dec-2002 green

Make /etc/rc and /etc/rc.shutdown executable, and execute them directly
instead of via /bin/sh. They already have the proper #! lines, and
there is no new failure case (if execution fails, it still attempts to
execute indirectly via /bin/sh). This is necessary for SEBSD to function
properly.


# 107994 17-Dec-2002 green

/home/green/tmp/cvsSFosXg


# 104034 27-Sep-2002 jhb

Give up on a tty if opening it's special file returns ENOENT like we do for
ENXIO.

Glanced at by: imp, gallatin


# 101271 03-Aug-2002 mux

I should have committed this ages ago...
Convert init(8) to use nmount() instead of mount() when
it has to mount devfs. This doesn't happen normally,
since the kernel is supposed to mount devfs itself.


# 92838 20-Mar-2002 imp

o remove __P
o Use ansi function definitions
o unifdef -D__STDC__


# 92806 20-Mar-2002 obrien

Remove 'register' keyword.
It does not help modern compilers, and some may take some hit from it.
(I also found several functions that listed *every* of its 10 local vars with
"register" -- just how many free registers do people think machines have?)


# 85010 15-Oct-2001 des

Allow reboot during runcom.

PR: bin/28116
Submitted by: Valentin Nechayev <netch@netch.kiev.ua>
MFC in: 1 week


# 81911 19-Aug-2001 kris

Silence non-constant format string warnings by marking functions
as __printflike()/__printf0like(), adding const, or adding missing "%s"
format strings, as appropriate.

MFC after: 2 weeks


# 80381 26-Jul-2001 sheldonh

Use STD{ERR,IN,OUT}_FILENO instead of their numeric values. The
definitions are more readable, and it's possible that they're
more portable to pathalogical platforms.

Submitted by: David Hill <david@phobia.ms>


# 78484 19-Jun-2001 mikeh

Fix typo which could lead to memory leak.

PR: misc/28283
MFC after: 2 weeks


# 73373 03-Mar-2001 asmodai

Fix typo present since 1997: single used mode -> single user mode.


# 72188 08-Feb-2001 phk

Fix a cosmetic problem with some very defensive programming: The devfs
mount would show up as "/dev/", loose that trailing slash.


# 69793 09-Dec-2000 obrien

Add `_PATH_DEVZERO'.
Use _PATH_* where where possible.


# 65114 26-Aug-2000 phk

Mount DEVFS with no options.


# 59871 01-May-2000 asmodai

Remove unused include.


# 59216 14-Apr-2000 imp

Add include of errno.h where needed, remove extern int errno where not.

These commits were inspired by a similar commit to netbsd.


# 57344 19-Feb-2000 alfred

detect deleted tty lines in /etc/ttys.


# 53550 22-Nov-1999 dillon

Finish up umntall support. init now passed an argument to the
rundown script 'reboot' or 'single'. ISO support (which never
worked) has been removed from mount_nfs. mount_nfs and umount
now use mounttab, which allows umntall to work properly. The
rc scripts now call umntall as appropriate.

Submitted by: Martin Blapp <mb@imp.ch>


# 51008 06-Sep-1999 kato

FreeBSD kernel doesn't allow any process to decrease securelevel. So,
init(8) cannot decrease securelevel. The manual page explains this
and single_user() doesn't try to downgrade kernel to insecure mode.

Reviewed by: bde (manual page)


# 50476 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 49018 23-Jul-1999 ru

Fix a non-critical memory leak.

PR: 12769
Submitted by: Peter Jeremy <peter.jeremy@alcatel.com.au>


# 47998 18-Jun-1999 ru

Bring in System V run-level patches (turned off by default).
While I'm here, fix some typos in the manpage.

Requested by: des


# 47962 16-Jun-1999 ru

Init(8) will halt the system if sent USR1 signal,
or halt and turn the power off if sent SIGUSR2.

PR: 5451
Submitted by: Leif Neland <leifn@image.dk>
Reworked by: ru
Reviewed by: -hackers


# 37814 22-Jul-1998 phk

Memory management error in init.

PR: 7320
Reviewed by: phk
Submitted by: Anders Thulin <Anders.X.Thulin@telia.se>


# 37417 06-Jul-1998 charnier

Correct .Nm use. Add rcsid. Use min for minutes instead of mn.


# 34001 02-Mar-1998 jraynard

Don't assume sigset_t and int are equivalent.


# 30272 10-Oct-1997 peter

This has always bugged me. At single user, the implied example it gives
is not valid - it says that "sh" is the default, but you can't
actually type "sh" at this prompt - it has to be /bin/sh or some other
full pathname.


# 28344 17-Aug-1997 davidn

Test that rc.shutdown exists before attempting to run it - silently
return success if it doesn't to prevent any unwanted error msgs.


# 27942 06-Aug-1997 ache

runshutdown(): get rid of getdtablesize loop, it gains nothing now
but can waste time if many descriptors are available


# 27941 06-Aug-1997 ache

rc.shutdown fixes:
1) revoke -> HUP
2) controlling terminal already present
3) add missing setprocresources call


# 27837 01-Aug-1997 davidn

Add /etc/rc.shutdown capability to init.
Add sample /etc/rc.shutdown (which is just a shell for now).
Submitted by: Ollivier Robert <roberto@keltia.freenix.fr>


# 27275 08-Jul-1997 ache

Move logwtmp(shutdown) call before any real action in death().


# 27215 05-Jul-1997 ache

1. Replace malloc+bzero by calloc
2. Revoke internal active session list only now, not whole /etc/ttys


# 27197 04-Jul-1997 ache

death: revoke all lines listed in /etc/ttys instead of sending HUP
to all processes


# 27186 03-Jul-1997 ache

Include <libutil.h> instead of private declarations


# 27176 02-Jul-1997 ache

Remove unneded cast in login_getclassbyname which cause warning


# 27029 28-Jun-1997 pst

Attempt to open the device for reading before actually adding the device
to the session list. If the device comes back as unconfigured, just
ignore that line in /etc/ttys. If someone HUP's init, we'll try again.

This change stops getty's from hanging on vty and sio ports that don't
exist, either due to LKM drivers not being loaded, or probes failing.
Reviewed by: bde


# 26594 13-Jun-1997 charnier

Use err(3).


# 24408 30-Mar-1997 phk

Fix mount call for devfs.

Submitted by: bde


# 22922 19-Feb-1997 dg

Protect from stack overrun via /etc/ttys, which could possibly allow a
root user to change the securelevel. Pointed out by Thomas H. Ptacek
<tqbf@enteract.com>.


# 21941 22-Jan-1997 davidn

Style police.


# 21865 19-Jan-1997 davidn

Impose login_cap resource limits on processes started by init.
/etc/rc started with "daemon" settings.
"window=" started with "default" settings
gettys started with "default" settings.
This should open the way to junk kernel options MAX_{OPEN,CHILD}
and the corresponding sysctl vars.


# 19227 28-Oct-1996 phk

If passed the -d flag, mount devfs on /dev


# 12185 10-Nov-1995 dima

If root does not have a password, `init' should not ask to enter it.
otherwise it's not possible to get into single-user mode, if root
does not have password and console insecure.


# 11910 29-Oct-1995 phk

Define TRUE & FALSE rather than depending on bogus #includes.


# 10006 08-Aug-1995 mpp

Fix init to correctly detect processes that are exiting multiple
times per second.


# 9997 08-Aug-1995 ache

nspace count was incremented only in child, so warning never displayed
Pointed by: Mike Pritchard <mpp@mpp.minn.net>


# 8871 30-May-1995 rgrimes

Remove trailing whitespace.


# 5478 10-Jan-1995 ache

Add better argument handling
Submitted by: jmz


# 3594 14-Oct-1994 ache

revision 1.6
date: 1994/03/06 08:55:02; author: ache; state: Exp; lines: +4 -1
Stop count getty spacing problem, if we issue kill -1 1
----------------------------
revision 1.5
date: 1994/03/04 17:51:39; author: ache; state: Exp; lines: +9 -2
I got a lot of
"getty repeating too quickly on port %s, sleeping"
from init.bsdi, it means that getty start and exit in five seconds.
This is common situation for poor quality Russian phone lines:
modem got CONNECT message and after retries got NO CARRIER.
So I introduce spacing count, it means that this warning and
sleep occurse only after GETTY_NSPACE times of sequental attempts.
----------------------------
revision 1.4
date: 1994/02/28 21:53:52; author: ache; state: Exp; lines: +71 -10
I found (and fix) ugly bugs in init.bsdi (this bugs not present
in old init)

1) Init don't setup TERM environment variable for default terminal
type from /etc/ttys before calling getty/window.

2) When "kill -1 1" issued, init don't restart getty when
/etc/ttys parameters was changed (it only kill "off" end empty entries).

3) Small memory leak if "window" /etc/ttys parameter specified and
"kill -1 1" issued.

Obtained from: FreeBSD 1.x


# 2327 28-Aug-1994 jkh

What cretin named both a global and a function "reboot"? Global
changed to Reboot.
Submitted by: jkh


# 2323 27-Aug-1994 nate

Bring in my changes from the 1.1 init.bsdi which causes a reboot (was a
halt before) if init is sent an interrupt signal. This is necessary
for <CTL><ALT><DEL> to do the right thing if enabled.


# 2233 23-Aug-1994 dg

Nuked the 2 second DTR wait; this is handled correctly in the sio driver.


# 1559 26-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1558,
which included commits to RCS files with non-trunk default branches.


# 1558 26-May-1994 rgrimes

BSD 4.4 Lite sbin Sources

Note: XNSrouted and routed NOT imported here, they shall be imported with
usr.sbin.