1 --- xc/programs/xfs/difs/fonts.c.xfsredhat Sun Aug 22 15:29:55 1999
2 +++ xc/programs/xfs/difs/fonts.c Tue Mar 14 12:10:39 2000
8 + * Extract a single element from the font path string starting at
9 + * pnt. The font path element will be returned, and pnt will be
10 + * updated to point to the start of the next element, or set to
11 + * NULL if there are no more.
20 + *pnt = index(*pnt, ',');
29 + * xf86ValidateFontPath --
30 + * Validates the user-specified font path. Each element that
31 + * begins with a '/' is checked to make sure the directory exists.
32 + * If the directory exists, the existence of a file named 'fonts.dir'
33 + * is checked. If either check fails, an error is printed and the
34 + * element is removed from the font path.
36 +#define DIR_FILE "/fonts.dir"
37 +#define CHECK_TYPE(mode, type) ((S_IFMT & (mode)) == (type))
39 +xf86ValidateFontPath(path)
42 + char *tmp_path, *out_pnt, *path_elem, *next, *p1, *dir_elem;
43 + struct stat stat_buf;
47 + tmp_path = (char *)calloc(1,strlen(path)+1);
51 + while (next != NULL) {
52 + path_elem = xf86GetPathElem(&next);
54 + if (*path_elem == '/') {
55 + dir_elem = (char *)calloc(1, strlen(path_elem) + 1);
56 + if ((p1 = strchr(path_elem, ':')) != 0)
58 + /* OS/2 must prepend X11ROOT */
59 + if (*path_elem == '/') {
60 + path_elem = (char*)__XOS2RedirRoot(path_elem);
61 + dir_elem = (char*)calloc(1, strlen(path_elem) + 1);
62 + if (p1 = strchr(path_elem+2, ':'))
64 + dirlen = p1 - path_elem;
66 + dirlen = strlen(path_elem);
67 + strncpy(dir_elem, path_elem, dirlen);
68 + dir_elem[dirlen] = '\0';
69 + flag = stat(dir_elem, &stat_buf);
71 + if (!CHECK_TYPE(stat_buf.st_mode, S_IFDIR))
74 + printf("warning!\n");
75 + ErrorF("Warning: The directory \"%s\" does not exist.\n", dir_elem);
76 + ErrorF(" Entry deleted from font path.\n");
80 + p1 = (char *)malloc(strlen(dir_elem)+strlen(DIR_FILE)+1);
81 + strcpy(p1, dir_elem);
82 + strcat(p1, DIR_FILE);
83 + flag = stat(p1, &stat_buf);
85 + if (!CHECK_TYPE(stat_buf.st_mode, S_IFREG))
91 + ErrorF("Warning: 'fonts.dir' not found (or not valid) in \"%s\".\n",
93 + ErrorF(" Entry deleted from font path.\n");
94 + ErrorF(" (Run 'mkfontdir' on \"%s\").\n", dir_elem);
102 + * Either an OK directory, or a font server name. So add it to
105 + if (out_pnt != tmp_path)
107 + strcat(out_pnt, path_elem);
108 + out_pnt += strlen(path_elem);
114 * note that the font wakeup queue is not refcounted. this is because
115 * an fpe needs to be added when it's inited, and removed when it's finally
116 * freed, in order to handle any data that isn't requested, like FS events.
123 + fixedpath = xf86ValidateFontPath(str);
125 - len = strlen(str) + 1;
126 + len = strlen(fixedpath) + 1;
128 paths = p = (char *) ALLOCATE_LOCAL(len);
133 err = set_font_path_elements(npaths, paths, badpath);
136 DEALLOCATE_LOCAL(paths);
139 --- xc/programs/xfs/difs/main.c.xfsredhat Sun Mar 7 15:50:25 1999
140 +++ xc/programs/xfs/difs/main.c Tue Mar 14 12:10:39 2000
142 #include "dispatch.h"
143 #include "extentst.h"
147 +#include <sys/types.h>
149 char *ConnectionInfo;
154 +int droppriv; /* whether or not to drop root privileges at startup */
155 +int becomeDaemon; /* whether or not to become a daemon */
157 #ifndef DEFAULT_CONFIG_FILE
158 #define DEFAULT_CONFIG_FILE "/usr/lib/X11/fs/config"
161 main(int argc, char *argv[])
164 + struct passwd *pwent;
171 configfilename = DEFAULT_CONFIG_FILE;
174 ProcessCmdLine(argc, argv);
177 + /* become xfs user, if possible */
178 + if ((geteuid() == 0) && droppriv) {
179 + pwent = getpwnam("xfs");
181 + if (setgid(pwent->pw_gid)) {
182 + ErrorF("fatal: couldn't set groupid to xfs user's group\n");
186 + if (setgroups(0, 0)) {
187 + ErrorF("fatal: couldn't drop supplementary groups\n");
191 + if (setuid(pwent->pw_uid)) {
192 + ErrorF("fatal: couldn't set userid to xfs user\n");
196 + } else if (droppriv) {
197 + ErrorF("fatal: droppriv flag specified, but xfs not run as root\n");
202 * do this first thing, to get any options that only take effect at
203 * startup time. it is erad again each time the server resets
205 ErrorF("fatal: couldn't read config file\n");
209 + /* become a daemon if explicitly requested to do so. */
215 --- xc/programs/xfs/os/utils.c.xfsredhat Sun Mar 7 15:50:30 1999
216 +++ xc/programs/xfs/os/utils.c Tue Mar 14 12:10:39 2000
220 extern char *configfilename;
221 +extern int droppriv; /* whether or not to drop root privileges */
222 +extern int becomeDaemon; /* whether to become a daemon or not */
230 - fprintf(stderr, "usage: %s [-config config_file] [-port tcp_port]\n",
231 + fprintf(stderr, "usage: %s [-config config_file] [-port tcp_port] [-droppriv] [-daemon]\n",
236 ProcessLSoption (argv[++i]);
239 + } else if (!strcmp(argv[i], "-droppriv")) {
241 + } else if (!strcmp(argv[i], "-daemon")) {
243 } else if (!strcmp(argv[i], "-cf") || !strcmp(argv[i], "-config")) {
245 configfilename = argv[++i];
246 --- xc/programs/xfs/os/Imakefile.xfsredhat Sun Feb 13 08:54:42 2000
247 +++ xc/programs/xfs/os/Imakefile Tue Mar 14 12:10:39 2000
249 SOCK_DEFINES = -DBSD44SOCKETS
252 -/* ERROR_DEFINES = -DUSE_SYSLOG */
253 +ERROR_DEFINES = -DUSE_SYSLOG
255 OS_DEFINES = ServerOSDefines
257 --- xc/programs/xfs/os/error.c.xfsredhat Sun Oct 25 14:59:57 1998
258 +++ xc/programs/xfs/os/error.c Tue Mar 14 13:29:26 2000
262 char ErrorFile[PATH_MAX];
267 @@ -142,17 +143,21 @@
271 - syslog(LOG_NOTICE, f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
274 + syslog(LOG_NOTICE, f, args);
281 /* XXX should Notices just be ignored if not using syslog? */
284 fprintf(stderr, "%s notice: ", progname);
285 vfprintf(stderr, f, args);
291 @@ -164,15 +169,20 @@
295 - syslog(LOG_ERR, f, s0, s1, s2, s3, s4, s5, s6, s7, s8, s9);
298 + syslog(LOG_ERR, f, args);
306 fprintf(stderr, "%s error: ", progname);
307 vfprintf(stderr, f, args);