--- spamd.orig 2022-05-05 17:57:02.000000000 +0200 +++ spamd 2022-05-11 11:14:52.307420717 +0200 @@ -366,6 +366,7 @@ 'create-prefs!' => \$opt{'create-prefs'}, 'daemonize!' => \$opt{'daemonize'}, 'debug|D:s' => \$opt{'debug'}, + 'default-user|U=s' => \$opt{'default-user'}, 'd' => \$opt{'daemonize'}, 'groupname|g=s' => \$opt{'groupname'}, 'helper-home-dir|H:s' => \$opt{'home_dir_for_helpers'}, @@ -449,6 +450,10 @@ exit($resphash{'EX_OK'}); } +unless ($opt{'default-user'}) { + $opt{'default-user'}="nobody"; +} + my $log_timestamp_fmt = $opt{'log-timestamp-fmt'}; if (defined $log_timestamp_fmt && lc($log_timestamp_fmt) eq 'default') { undef $log_timestamp_fmt; # undefined implies per-logger's default @@ -1805,15 +1810,15 @@ } if (!am_running_on_windows()) { warn("spamd: still running as root: user not specified with -u, " - . "not found, or set to root, falling back to nobody\n"); + . "not found, or set to root, falling back to $opt{'default-user'}\n"); my ($name, $pwd, $uid, $gid, $quota, $comment, $gcos, $dir, $etc) = - getpwnam('nobody'); + getpwnam($opt{'default-user'}); $) = (get_user_groups($uid)); # eGID $> = $uid; # eUID if (!defined($uid) || ($> != $uid and $> != ($uid - 2**32))) { - die("spamd: setuid to nobody failed"); + die("spamd: setuid to $opt{'default-user'} failed"); } $spamtest->signal_user_changed( @@ -3308,6 +3313,8 @@ -g groupname, --groupname=groupname Run as groupname -v, --vpopmail Enable vpopmail config -x, --nouser-config Disable user config files + -U username, --default-user=username Use username (default 'nobody') + if spamc user is not found -D, --debug[=areas] Print debugging messages (for areas) -L, --local Use local tests only (no DNS) -P, --paranoid Die upon user errors @@ -3639,6 +3646,12 @@ This option does not disable or otherwise influence the SQL, LDAP or Virtual Config Dir settings. +=item B<-U> I, B<--default-user>=I + +Use username if the username provided by spamc is not found. +This gives an advantage over the default I, which has no home +directory and thus no user settings, bayes database etc. + =item B<-A> I, B<--allowed-ips>=I Specify a comma-separated list of authorized hosts or networks which @@ -3704,7 +3717,7 @@ =item B<-P>, B<--paranoid> Die on user errors (for the user passed from spamc) instead of falling back to -user I and using the default configuration. +I and using the default configuration. =item B<-m> I , B<--max-children>=I