static void
privileged_initialization (saver_info *si, int *argc, char **argv)
{
+#ifndef NO_LOCKING
+ /* before hack_uid() for proper permissions */
+ lock_priv_init (*argc, argv, si->prefs.verbose_p);
+#endif /* NO_LOCKING */
+
+#ifndef NO_SETUID
+ hack_uid (si);
+#endif /* NO_SETUID */
+}
+
+
+/* Figure out what locking mechanisms are supported.
+ */
+static void
+lock_initialization (saver_info *si, int *argc, char **argv)
+{
#ifdef NO_LOCKING
si->locking_disabled_p = True;
si->nolock_reason = "not compiled with locking support";
#else /* !NO_LOCKING */
si->locking_disabled_p = False;
- /* before hack_uid() for proper permissions */
+
+ /* Finish initializing locking, now that we're out of privileged code. */
if (! lock_init (*argc, argv, si->prefs.verbose_p))
{
si->locking_disabled_p = True;
maybe_reload_init_file (si);
- blank_screen (si);
+ if (! blank_screen (si))
+ {
+ /* We were unable to grab either the keyboard or mouse.
+ This means we did not (and must not) blank the screen.
+ If we were to blank the screen while some other program
+ is holding both the mouse and keyboard grabbed, then
+ we would never be able to un-blank it! We would never
+ see any events, and the display would be wedged.
+
+ So, just go around the loop again and wait for the
+ next bout of idleness.
+ */
+
+ fprintf (stderr,
+ "%s: unable to grab keyboard or mouse! Blanking aborted.\n",
+ blurb());
+ continue;
+ }
+
kill_screenhack (si);
spawn_screenhack (si, True);
exit (1);
load_init_file (p);
+ lock_initialization (si, &argc, argv);
if (p->xsync_p) XSynchronize (si->dpy, True);
blurb_timestamp_p = p->timestamp_p; /* kludge */