DEALLOCATE_LOCAL(paths);
return err;
-diff -Nur XFree86-4.0.2.org/xc/programs/xfs/difs/main.c XFree86-4.0.2/xc/programs/xfs/difs/main.c
---- XFree86-4.0.2.org/xc/programs/xfs/difs/main.c Sat Dec 9 05:02:14 2000
-+++ XFree86-4.0.2/xc/programs/xfs/difs/main.c Thu Dec 21 09:40:53 2000
-@@ -56,12 +56,18 @@
- #include "dispatch.h"
- #include "extentst.h"
- #include "difs.h"
-+#include <unistd.h>
-+#include <pwd.h>
-+#include <sys/types.h>
-
- char *ConnectionInfo;
- int ConnInfoLen;
-
- Cache serverCache;
-
-+int droppriv; /* whether or not to drop root privileges at startup */
-+int becomeDaemon; /* whether or not to become a daemon */
-+
- #ifndef DEFAULT_CONFIG_FILE
- #define DEFAULT_CONFIG_FILE "/usr/lib/X11/fs/config"
- #endif
-@@ -84,13 +90,39 @@
-
- argcGlobal = argc;
- argvGlobal = argv;
--
-+ droppriv = 0;
-+ becomeDaemon =0;
-+
- configfilename = DEFAULT_CONFIG_FILE;
-
- /* init stuff */
- ProcessCmdLine(argc, argv);
- InitErrors();
-
-+ /* become xfs user, if possible */
-+ if ((geteuid() == 0) && droppriv) {
-+ pwent = getpwnam("xfs");
-+ if (pwent) {
-+ if (setgid(pwent->pw_gid)) {
-+ ErrorF("fatal: couldn't set groupid to xfs user's group\n");
-+ exit(1);
-+ }
-+
-+ if (setgroups(0, 0)) {
-+ ErrorF("fatal: couldn't drop supplementary groups\n");
-+ exit(1);
-+ }
-+
-+ if (setuid(pwent->pw_uid)) {
-+ ErrorF("fatal: couldn't set userid to xfs user\n");
-+ exit(1);
-+ }
-+ }
-+ } else if (droppriv) {
-+ ErrorF("fatal: droppriv flag specified, but xfs not run as root\n");
-+ exit(1);
-+ }
-+
- /*
- * do this first thing, to get any options that only take effect at
- * startup time. it is read again each time the server resets
-@@ -99,6 +131,10 @@
- ErrorF("fatal: couldn't read config file\n");
- exit(1);
- }
-+
-+ /* become a daemon if explicitly requested to do so. */
-+ if (becomeDaemon)
-+ daemon(0, 0);
-
- /* make sure at least world write access is disabled */
- if (((oldumask = umask(022)) & 002) == 002)
-diff -Nur XFree86-4.0.2.org/xc/programs/xfs/os/error.c XFree86-4.0.2/xc/programs/xfs/os/error.c
---- XFree86-4.0.2.org/xc/programs/xfs/os/error.c Tue Dec 5 01:59:41 2000
-+++ XFree86-4.0.2/xc/programs/xfs/os/error.c Thu Dec 21 09:26:42 2000
-@@ -81,6 +81,7 @@
- Bool log_open = FALSE;
- #endif
- char ErrorFile[PATH_MAX];
-+int log_open = 0;
-
- static void
- abort_server(void)
-diff -Nur XFree86-4.0.2.org/xc/programs/xfs/os/utils.c XFree86-4.0.2/xc/programs/xfs/os/utils.c
---- XFree86-4.0.2.org/xc/programs/xfs/os/utils.c Tue Dec 5 01:59:41 2000
-+++ XFree86-4.0.2/xc/programs/xfs/os/utils.c Thu Dec 21 09:26:42 2000
-@@ -317,6 +317,10 @@
- userId = argv[++i];
- else
- usage();
-+ } else if (!strcmp(argv[i], "-droppriv")) {
-+ droppriv = 1;
-+ } else if (!strcmp(argv[i], "-daemon")) {
-+ becomeDaemon = 1;
- } else if (!strcmp(argv[i], "-cf") || !strcmp(argv[i], "-config")) {
- if (argv[i + 1])
- configfilename = argv[++i];