3 * context_save.c -- write out the updated context file
14 static int m_chkids(void);
21 register struct node *np;
25 if (!(ctxflags & CTXMOD))
29 if ((action = m_chkids ()) > 0)
30 return; /* child did it for us */
32 /* block a few signals */
34 sigaddset (&set, SIGHUP);
35 sigaddset (&set, SIGINT);
36 sigaddset (&set, SIGQUIT);
37 sigaddset (&set, SIGTERM);
38 SIGPROCMASK (SIG_BLOCK, &set, &oset);
40 if (!(out = fopen (ctxpath, "w")))
41 adios (ctxpath, "unable to write");
42 for (np = m_defs; np; np = np->n_next)
44 fprintf (out, "%s: %s\n", np->n_name, np->n_field);
47 SIGPROCMASK (SIG_SETMASK, &oset, &set); /* reset the signal mask */
50 _exit (0); /* we are child, time to die */
54 * This hack brought to you so we can handle set[ug]id MH programs.
55 * If we return -1, then no fork is made, we update .mh_profile
56 * normally, and return to the caller normally. If we return 0,
57 * then the child is executing, .mh_profile is modified after
58 * we set our [ug]ids to the norm. If we return > 0, then the
59 * parent is executed and .mh_profile has already be modified.
60 * We can just return to the caller immediately.
69 if (getuid () == geteuid ())
72 for (i = 0; (pid = fork ()) == -1 && i < 5; i++)