From 2954208d00d422b34fa3a69631b0a091f17a349d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 2 Dec 2020 08:23:52 +0100 Subject: 5.44 --- driver/prefs.c | 55 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 25 deletions(-) (limited to 'driver/prefs.c') diff --git a/driver/prefs.c b/driver/prefs.c index 8fb029e..94e7a0c 100644 --- a/driver/prefs.c +++ b/driver/prefs.c @@ -1,5 +1,5 @@ /* dotfile.c --- management of the ~/.xscreensaver file. - * xscreensaver, Copyright (c) 1998-2018 Jamie Zawinski + * xscreensaver, Copyright (c) 1998-2020 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -136,33 +136,34 @@ init_file_name (void) if (!file) { uid_t uid = getuid (); - struct passwd *p = getpwuid (uid); + const char *home = getenv("HOME"); - if (i_am_a_nobody (uid)) - /* If we're running as nobody, then use root's .xscreensaver file - (since ~root/.xscreensaver and ~nobody/.xscreensaver are likely - to be different -- if we didn't do this, then xscreensaver-demo - would appear to have no effect when the luser is running as root.) - */ - uid = 0; - - p = getpwuid (uid); - - if (!p || !p->pw_name || !*p->pw_name) - { - fprintf (stderr, "%s: couldn't get user info of uid %d\n", - blurb(), getuid ()); - file = ""; - } - else if (!p->pw_dir || !*p->pw_dir) + if (i_am_a_nobody (uid) || !home || !*home) { - fprintf (stderr, "%s: couldn't get home directory of \"%s\"\n", - blurb(), (p->pw_name ? p->pw_name : "???")); - file = ""; + /* If we're running as nobody, then use root's .xscreensaver file + (since ~root/.xscreensaver and ~nobody/.xscreensaver are likely + to be different -- if we didn't do this, then xscreensaver-demo + would appear to have no effect when the luser is running as root.) + */ + struct passwd *p = getpwuid (uid); + uid = 0; + if (!p || !p->pw_name || !*p->pw_name) + { + fprintf (stderr, "%s: couldn't get user info of uid %d\n", + blurb(), getuid ()); + } + else if (!p->pw_dir || !*p->pw_dir) + { + fprintf (stderr, "%s: couldn't get home directory of \"%s\"\n", + blurb(), (p->pw_name ? p->pw_name : "???")); + } + else + { + home = p->pw_dir; + } } - else + if (home && *home) { - const char *home = p->pw_dir; const char *name = ".xscreensaver"; file = (char *) malloc(strlen(home) + strlen(name) + 2); strcpy(file, home); @@ -170,6 +171,10 @@ init_file_name (void) strcat(file, "/"); strcat(file, name); } + else + { + file = ""; + } } if (file && *file) @@ -1653,7 +1658,7 @@ stop_the_insanity (saver_preferences *p) if (p->watchdog_timeout > 57000) p->watchdog_timeout = 57000; /* 57 secs */ if (p->pointer_hysteresis < 0) p->pointer_hysteresis = 0; - if (p->pointer_hysteresis > 100) p->pointer_hysteresis = 100; +/* if (p->pointer_hysteresis > 100) p->pointer_hysteresis = 100; */ if (p->auth_warning_slack < 0) p->auth_warning_slack = 0; if (p->auth_warning_slack > 300) p->auth_warning_slack = 300; -- cgit v1.2.3-55-g7522