[ Pobierz całość w formacie PDF ]
.(If the value of initdefault is set to 2, the process willrun right after the boot.) init starts the process, waits for its termination and, when itdies, does not restart the process.initdefault.An entry with this action is only scanned when init is first started.init usesthis entry, if it exists, to determine which run level to enter first.It does this by takingthe highest run level specified in the run level field and using that as its initial level.Ifthe run level field is empty, it is interpreted as 0123456, which causes init to enter runlevel 6.If init does not find an initdefault entry in /etc/inittab, it will request an initialrun level from the user at reboot time.off.If the process associated with this entry is currently running, send the warningsignal (SIGTERM) and wait 20 seconds before forcibly terminating the process via thekill signal (SIGKILL).If the process is nonexistent, ignore the entry.once.When init enters a run level that matches the entry s run level, init is to start theprocess and not wait for its termination.When it dies, do not restart the process.If uponentering a new run level, when the process is still running from a previous run levelchange, the program will not be restarted.ondemand.This instruction is really a synonym for the respawn action.It is function-ally identical to respawn but is given a different keyword to separate it from run levels.This is used only with the a, b, or c values described in the run level field.powerfail.Execute the process associated with this entry only when init receives apower fail signal.powerwait.Execute the process associated with this entry only when init receives apower fail signal, but wait until it terminates before continuing any processing of inittab.respawn.If the process does not exist, then start the process; do not wait for itstermination (continue scanning the inittab file).When the process dies, restart theprocess.If the process currently exists, then do nothing and continue scanning theinittab file.sysinit.init executes these entries when the system first goes to single-user mode afterbeing rebooted.It does not execute these entries if the system is subsequently put insingle-user mode from any run-level 1 through 6.Entries with sysinit in their action fielddo not specify a run level in their run level field.wait.When init enters the run level that matches the entry s run level, start the processand wait for its termination.All subsequent reads of the inittab file while init is in thesame run level will cause init to ignore this entry. 74 Part I: Managing Internet SecurityThe init command will not report the run level it is operating in after it has switched runlevels.For example, when switiching from single-user to multiuser mode, init many report thisbay printing something likeinit: Run-Level 2before continuing.Currently, the only way to see what run level init is in is to use the com-mand who.In addition to showing you who is logged on the system, this command is capableof showing the run level the system is currently operating in.To view the run level, use theoption, -r.The output of this command is shown as follows:$ who -r.run-level 2 Aug 27 21:31 2 0 S$According to this output, the current run level is 2.The date refers to when the system enteredthat run level; the digits to the right show the current, oldest, and last run level.Program ListingsEach of the following code lists are programs discussed earlier in this chapter.Fortunately, youdo not have to type these lists by hand; they are included on the disc at the back of this book.Listing 2.1 The dfmon ProgramThis program and its output are discussed in the section on writing daemons in the Bourne/Korn shell.To use dfmon, install it /usr/local/bin, and add it to one of the system startupscripts.On the next reboot, dfmon will start up and commence monitoring your available diskspace.When installing dfmon.sh, do not execute it as root.Because none of the commands in thescript are restricted, it is not necessary for the script to run as root.In fact, allowing it to run asroot may contribute to lowering your security level.This is because the dfmon.sh script usesthe Bourne/Korn shell source command to load in the configuration file.This command simply  includes the contents of the named file into the shell, and could beused to circumvent the system.If you must run dfmon.sh as root, be sure to put the configu-ration file in a protected directory, and use the appropriate file permissions to prevent non-rootusers from accessing it.#!/bin/sh## This is a shell program to monitor the available disk space on a system# and report when it reaches a lower limit.# Understanding and Creating Daemons 75# The script is intended to run on both System V and BSD systems, and handle# the different forms of df that exist on both platforms.## Configuration# CONFIG=/dfmon.cfgCONFIG=./dfmon.cfg## Load hn the configuration file using the source (.) command.# NOTE# THE DFMON.SH PROGRAM SHOULD NOT BE EXECUTED AS ROOT.#.$CONFIG## With the configuration file loaded, we now start the daemon process.To do# this we run the balance of the command in a subshell, so the parent# process can exit.#echo  `date` Starting Disk Monitor Daemon.(## Ignore TRAPS, so we can t be killed with anything but a kill -9 [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • wpserwis.htw.pl