/* subprocs.c --- choosing, spawning, and killing screenhacks.
- * xscreensaver, Copyright (c) 1991, 1992, 1993, 1995, 1997
+ * xscreensaver, Copyright (c) 1991, 1992, 1993, 1995, 1997, 1998
* Jamie Zawinski <jwz@netscape.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
static struct screenhack_job *jobs = 0;
-#ifdef DEBUG
-static void
+/* for debugging -- nothing calls this, but it's useful to invoke from gdb. */
+void
show_job_list (void)
{
struct screenhack_job *job;
job->name);
fprintf (stderr, "\n");
}
-#endif
static void clean_job_list (void);
static void
block_sigchld (void)
{
-#ifdef USE_SIGACTION
+#ifdef HAVE_SIGACTION
sigset_t child_set;
sigemptyset (&child_set);
sigaddset (&child_set, SIGCHLD);
sigprocmask (SIG_BLOCK, &child_set, 0);
-#endif /* USE_SIGACTION */
+#endif /* HAVE_SIGACTION */
block_sigchld_handler++;
}
static void
unblock_sigchld (void)
{
-#ifdef USE_SIGACTION
+#ifdef HAVE_SIGACTION
sigset_t child_set;
sigemptyset(&child_set);
sigaddset(&child_set, SIGCHLD);
sigprocmask(SIG_UNBLOCK, &child_set, 0);
-#endif /* USE_SIGACTION */
+#endif /* HAVE_SIGACTION */
+
block_sigchld_handler--;
}
{
saver_info *si = global_si_kludge; /* I hate C so much... */
-#ifdef DEBUG
if (si->prefs.debug_p)
fprintf(stderr, "%s: got SIGCHLD%s\n", progname,
(block_sigchld_handler ? " (blocked)" : ""));
-#endif
if (block_sigchld_handler < 0)
abort();
init_sigchld();
}
-#endif
+#endif /* SIGCHLD */
#ifndef VMS
errno = 0;
kid = waitpid (-1, &wait_status, WNOHANG|WUNTRACED);
-#ifdef DEBUG
+
if (si->prefs.debug_p)
- if (kid < 0 && errno)
- fprintf (stderr, "%s: waitpid(-1) ==> %ld (%d)\n", progname,
- (long) kid, errno);
- else
- fprintf (stderr, "%s: waitpid(-1) ==> %ld\n", progname, (long) kid);
-#endif
+ {
+ if (kid < 0 && errno)
+ fprintf (stderr, "%s: waitpid(-1) ==> %ld (%d)\n", progname,
+ (long) kid, errno);
+ else
+ fprintf (stderr, "%s: waitpid(-1) ==> %ld\n", progname,
+ (long) kid);
+ }
/* 0 means no more children to reap.
-1 means error -- except "interrupted system call" isn't a "real"
{
#ifdef SIGCHLD
-# ifdef USE_SIGACTION /* Thanks to Tom Kelly <tom@ancilla.toronto.on.ca> */
+# ifdef HAVE_SIGACTION /* Thanks to Tom Kelly <tom@ancilla.toronto.on.ca> */
static Bool sigchld_initialized_p = 0;
if (!sigchld_initialized_p)
sigchld_initialized_p = True;
}
-# else /* !USE_SIGACTION */
+# else /* !HAVE_SIGACTION */
if (((long) signal (SIGCHLD, sigchld_handler)) == -1L)
{
sprintf (buf, "%s: couldn't catch SIGCHLD", progname);
perror (buf);
}
-# endif /* !USE_SIGACTION */
-#endif
+# endif /* !HAVE_SIGACTION */
+#endif /* SIGCHLD */
}
int i;
#ifdef SIGCHLD
signal (SIGCHLD, SIG_IGN);
-#endif
+#endif /* SIGCHLD */
for (i = 0; i < si->nscreens; i++)
{
si->locking_disabled_p = True;
si->nolock_reason = "running as root";
p = getpwnam ("nobody");
+ if (! p) p = getpwnam ("noaccess");
if (! p) p = getpwnam ("daemon");
if (! p) p = getpwnam ("bin");
if (! p) p = getpwnam ("sys");
}
}
}
-#ifndef NO_LOCKING
+# ifndef NO_LOCKING
else /* disable locking if already being run as "someone else" */
{
struct passwd *p = getpwuid (getuid ());
if (!p ||
!strcmp (p->pw_name, "root") ||
!strcmp (p->pw_name, "nobody") ||
+ !strcmp (p->pw_name, "noaccess") ||
!strcmp (p->pw_name, "daemon") ||
!strcmp (p->pw_name, "bin") ||
!strcmp (p->pw_name, "sys"))
sprintf (si->nolock_reason, "running as %s", p->pw_name);
}
}
-#endif /* NO_LOCKING */
+# endif /* !NO_LOCKING */
}
void