summaryrefslogtreecommitdiffstats
path: root/sbin/init/init.c
Commit message (Collapse)AuthorAgeFilesLines
* Move utmpx handling out of init(8).ed2012-02-111-31/+0
| | | | | | | | | | | | | | | | | 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.
* Add missing static keywords for global variables to tools in sbin/.ed2011-11-041-4/+4
| | | | | | 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.
* init: Only run /etc/rc.shutdown if /etc/rc was run.jilles2011-01-231-10/+35
| | | | | | | | | | | | | | | | | 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@
* Remove stale inclusion of <ulog.h>.ed2010-01-271-1/+0
| | | | This tool doesn't require libulog anymore.
* Migrate init(8) towards utmpx.ed2010-01-131-3/+6
| | | | | | | | 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.
* Let init(8) and reboot(8) use utmpx to log wtmp entries.ed2009-12-051-5/+11
| | | | | | | | 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().
* Remove redundant code from runshutdown() now tcsetsid(3) works reliably.ed2009-06-151-18/+1
| | | | | | 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.
* Fix the staircase issue properly this time.ed2009-06-141-0/+8
| | | | | | | | | | | 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.
* Static-ify procedures in init(8).delphij2008-09-271-80/+80
|
* Addition style(9) change.obrien2007-11-201-3/+3
|
* style(9)obrien2007-11-201-95/+96
|
* Patches to allow one to allow one to specify a directory to chroot to.imp2007-02-041-63/+139
| | | | | | | | | | 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)
* Reparent the process that executes the window= command from the ttyskib2006-06-081-1/+13
| | | | | | | | | 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
* Fix system shutdown timeout handling by again supporting longer runningrse2005-09-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Make WARNS=6 happy with our init(8):delphij2005-01-111-24/+39
| | | | | | | | | - 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.
* Turns out that revision 1.52 was a bad idea. It broke the longimp2004-09-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Remove advertising clause from University of California Regent's license,markm2004-04-091-4/+0
| | | | | | per letter dated July 22, 1999. Approved by: core, imp
* Fixed misspellings of 0 as NULL.bde2004-03-111-2/+2
|
* Fix the case where one goes from zero to more than zero items enabledimp2003-12-051-3/+0
| | | | | | | | | | | 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
* Back out the previous commit, since there could be dire consequences ifgreen2002-12-171-4/+0
| | | | /etc/rc were accidentally executed (as requested by other committeers).
* /home/green/tmp/cvsSFosXggreen2002-12-171-0/+4
|
* Give up on a tty if opening it's special file returns ENOENT like we do forjhb2002-09-271-1/+1
| | | | | | ENXIO. Glanced at by: imp, gallatin
* I should have committed this ages ago...mux2002-08-031-3/+15
| | | | | | 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.
* o remove __Pimp2002-03-201-160/+64
| | | | | o Use ansi function definitions o unifdef -D__STDC__
* Remove 'register' keyword.obrien2002-03-201-18/+18
| | | | | | 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?)
* Allow reboot during runcom.des2001-10-151-0/+3
| | | | | | PR: bin/28116 Submitted by: Valentin Nechayev <netch@netch.kiev.ua> MFC in: 1 week
* Silence non-constant format string warnings by marking functionskris2001-08-191-9/+9
| | | | | | | as __printflike()/__printf0like(), adding const, or adding missing "%s" format strings, as appropriate. MFC after: 2 weeks
* Use STD{ERR,IN,OUT}_FILENO instead of their numeric values. Thesheldonh2001-07-261-1/+1
| | | | | | | definitions are more readable, and it's possible that they're more portable to pathalogical platforms. Submitted by: David Hill <david@phobia.ms>
* Fix typo which could lead to memory leak.mikeh2001-06-201-1/+1
| | | | | PR: misc/28283 MFC after: 2 weeks
* Fix typo present since 1997: single used mode -> single user mode.asmodai2001-03-031-1/+1
|
* Fix a cosmetic problem with some very defensive programming: The devfsphk2001-02-081-1/+17
| | | | mount would show up as "/dev/", loose that trailing slash.
* Add `_PATH_DEVZERO'.obrien2000-12-091-1/+2
| | | | Use _PATH_* where where possible.
* Mount DEVFS with no options.phk2000-08-261-1/+1
|
* Remove unused include.asmodai2000-05-011-1/+0
|
* Add include of errno.h where needed, remove extern int errno where not.imp2000-04-141-2/+0
| | | | These commits were inspired by a similar commit to netbsd.
* detect deleted tty lines in /etc/ttys.alfred2000-02-191-1/+25
|
* Finish up umntall support. init now passed an argument to thedillon1999-11-221-3/+8
| | | | | | | | | 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>
* FreeBSD kernel doesn't allow any process to decrease securelevel. So,kato1999-09-061-6/+0
| | | | | | | 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)
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Fix a non-critical memory leak.ru1999-07-231-4/+6
| | | | | PR: 12769 Submitted by: Peter Jeremy <peter.jeremy@alcatel.com.au>
* Bring in System V run-level patches (turned off by default).ru1999-06-181-4/+37
| | | | | | While I'm here, fix some typos in the manpage. Requested by: des
* Init(8) will halt the system if sent USR1 signal,ru1999-06-161-5/+12
| | | | | | | | | 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
* Memory management error in init.phk1998-07-221-2/+5
| | | | | | PR: 7320 Reviewed by: phk Submitted by: Anders Thulin <Anders.X.Thulin@telia.se>
* Correct .Nm use. Add rcsid. Use min for minutes instead of mn.charnier1998-07-061-4/+6
|
* Don't assume sigset_t and int are equivalent.jraynard1998-03-021-2/+2
|
* This has always bugged me. At single user, the implied example it givespeter1997-10-101-2/+2
| | | | | | 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.
* Test that rc.shutdown exists before attempting to run it - silentlydavidn1997-08-181-1/+13
| | | | return success if it doesn't to prevent any unwanted error msgs.
* runshutdown(): get rid of getdtablesize loop, it gains nothing nowache1997-08-061-4/+1
| | | | but can waste time if many descriptors are available
* rc.shutdown fixes:ache1997-08-061-12/+12
| | | | | | 1) revoke -> HUP 2) controlling terminal already present 3) add missing setprocresources call
* Add /etc/rc.shutdown capability to init.davidn1997-08-021-17/+158
| | | | | Add sample /etc/rc.shutdown (which is just a shell for now). Submitted by: Ollivier Robert <roberto@keltia.freenix.fr>
OpenPOWER on IntegriCloud