Previous: , Up: Invocation   [Contents][Index]


8.2 Starting and Stopping

Right after startup, when mailfromd has done the operations that require root privileges, it switches to the privileges of the user it is configured to run as (see default user privileges) or the one given in its configuration file (see user). During this process it will drop all supplementary groups and switch to the principal group of that user.

Such limited privileges of the daemon can cause difficulties if your filter script needs to access some files (e.g. Sendmail databases) that are not accessible to that user and group. For example, the following fragment using dbmap function:

if dbmap("/etc/mail/aliases.db", $f, 1)
  …
fi

will normally fail, because /etc/mail/aliases.db is readable only to the root and members of the group ‘smmsp’.

In such situations you need to instruct mailfromd to retain the privileges of one or several supplementary groups when switching to the user privileges. This is done using group statement in the mailfromd configuration file (see group). In example above, you need to use the following settings:

group smmsp;

(The same effect can be achieved with --group command line option: mailfromd --group=smmsp).

To stop a running instance of mailfromd use one of the following signals: SIGQUIT, SIGTERM, SIGINT. All three signals have the same effect: the program cancels handling any pending requests, deinitializes the communication socket (if it is a UNIX socket, the program unlinks it) and exits.

To restart the running mailfromd instance, send it SIGHUP. For restart to be possible, two conditions must be met: mailfromd must be invoked with the full file name, and the configuration file name must be full as well. If either of them is not met, mailfromd displays a similar warning message:

warning: script file is given without full file name
warning: restart (SIGHUP) will not work

or:

warning: mailfromd started without full file name
warning: restart (SIGHUP) will not work

The reaction of mailfromd on SIGHUP in this case is the same as on the three signals described previously, i.e. cleanup and exit immediately.

The PID of the master instance of mailfromd is kept on the pidfile, which is named mailfromd.pid and is located in the program state directory. Assuming the default location of the latter, the following command will stop the running instance of the daemon:

kill -TERM `head -n1 /usr/local/var/mailfromd/mailfromd.pid`

The default pidfile location is shown in the output of mailfromd --show-defaults (see Examining Defaults), and can be changed at run time using pidfile statement (see pidfile).

To facilitate the use of mailfromd, it is shipped with a shell script that can be used to launch it on system startup and shut it down when the system goes down. The script, called rc.mailfromd, is located in the directory /etc of the distribution. It takes a single argument, specifying the action that should be taken:

start

Start the program.

stop

Shut down the program

reload

Reload the program, by sending it SIGHUP signal.

restart

Shut down the program and start it again.

status

Display program status. It displays the PID of the master process and its command line, for example:

$ /etc/rc.d/rc.mailfromd status
mailformd appears to be running at 26030
26030 /usr/local/sbin/mailfromd --group smmsp

If the second line is not displayed, this most probably mean that there is a ‘stale’ pidfile, i.e. the one left though the program is not running.

An empty rc.mailfromd status output means that mailfromd is not running.

configtest [file]

Check the script file syntax, report any errors found and exit. If file is given it is checked instead of the default one.

macros [-c] [file]

Parse the script file (or file, if it is given, extract the names of Sendmail macros it uses and generate corresponding export statements usable in the Sendmail configuration file. By default, mc statements are generated. If -c (--cf) is given, the statements for sendmail.cf are output. See the next chapter for the detailed description of this mode.

You can pass any additional arguments to mailfromd by editing ARGS variable near line 22.

The script is not installed by default. You will have to copy it to the directory where your system start-up scripts reside and ensure it is called during the system startup and shut down. The exact instructions on how to do so depend on the operating system you use and are beyond the scope of this manual.


Previous: , Up: Invocation   [Contents][Index]