2 ** context_save.c -- write out the updated context file
4 ** This code is Copyright (c) 2002, by the authors of nmh. See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
10 * This function used to support setuid/setgid programs by writing
11 * the file as the user. But that code, m_chkids(), was removed
12 * because there no longer are setuid/setgid programs in nmh.
17 #include <h/signals.h>
22 register struct node *np;
26 /* No context in use -- silently ignore any changes! */
30 if (!(ctxflags & CTXMOD))
34 /* block a few signals */
36 sigaddset(&set, SIGHUP);
37 sigaddset(&set, SIGINT);
38 sigaddset(&set, SIGQUIT);
39 sigaddset(&set, SIGTERM);
40 sigprocmask(SIG_BLOCK, &set, &oset);
42 if (!(out = lkfopen(ctxpath, "w")))
43 adios(EX_IOERR, ctxpath, "unable to write");
44 for (np = m_defs; np; np = np->n_next)
46 fprintf(out, "%s: %s\n", np->n_name, np->n_field);
47 lkfclose(out, ctxpath);
49 sigprocmask(SIG_SETMASK, &oset, &set); /* reset the signal mask */