diff --exclude Makefile --exclude Makefile.in --exclude .libs --exclude '*.lo' --exclude '*.o' --exclude '*.log' --exclude '*.status' --exclude configure --exclude xf86Build.h --exclude dix-config.h --exclude 'do-not-use-config.*' -Nrup xserver.old/xorg/configure.ac xserver/xorg/configure.ac --- xserver.old/xorg/configure.ac 2005-10-01 02:08:39.000000000 -0400 +++ xserver/xorg/configure.ac 2005-10-01 02:17:05.000000000 -0400 @@ -811,7 +811,7 @@ if test "x$XORG" = xyes; then AC_SUBST([LD_EXPORT_SYMBOLS_FLAG]) dnl these only go in xorg-config.h - CONFIGFILE="$sysconfdir/xorg.conf" + configdir="$sysconfdir" LOGPREFIX="$logdir/Xorg." AC_DEFINE(XORG_SERVER, 1, [Building Xorg server]) AC_DEFINE(XORGSERVER, 1, [Building Xorg server]) @@ -828,13 +828,14 @@ if test "x$XORG" = xyes; then AC_DEFINE(WITH_VGAHW, 1, [Building vgahw module]) AC_DEFINE(DRIVERS, {}, [Built-in output drivers (none)]) AC_DEFINE(IDRIVERS, {}, [Built-in input drivers (none)]) - AC_DEFINE_DIR(__XCONFIGFILE__, XF86CONFIGFILE, [Location of configuration file]) - AC_DEFINE_DIR(XF86CONFIGFILE, CONFIGFILE, [Path to Xorg configuration file]) + AC_DEFINE(XORG_CONFIGFILE, "xorg.conf", [Name of configuration file]) + AC_DEFINE_DIR(DEFAULT_CONFIGPATH, configdir, [Path to Xorg configuration file]) AC_DEFINE_DIR(DEFAULT_MODULE_PATH, moduledir, [Default module search path]) AC_DEFINE_DIR(DEFAULT_LOGPREFIX, LOGPREFIX, [Default log location]) AC_DEFINE_UNQUOTED(__VENDORDWEBSUPPORT__, ["$VENDOR_WEB"], [Vendor web address for support]) driverdir="$moduledir/drivers" + AC_SUBST([configdir]) AC_SUBST([moduledir]) AC_SUBST([driverdir]) sdkdir="$includedir/xorg" diff --exclude Makefile --exclude Makefile.in --exclude .libs --exclude '*.lo' --exclude '*.o' --exclude '*.log' --exclude '*.status' --exclude configure --exclude xf86Build.h --exclude dix-config.h --exclude 'do-not-use-config.*' -Nrup xserver.old/xorg/hw/xfree86/common/xf86Config.c xserver/xorg/hw/xfree86/common/xf86Config.c --- xserver.old/xorg/hw/xfree86/common/xf86Config.c 2005-08-26 01:00:07.000000000 -0400 +++ xserver/xorg/hw/xfree86/common/xf86Config.c 2005-10-01 02:17:53.000000000 -0400 @@ -88,31 +88,6 @@ extern DeviceAssocRec mouse_assoc; #define SUPPORT_PC98 #endif -/* - * These paths define the way the config file search is done. The escape - * sequences are documented in parser/scan.c. - */ -#ifndef ROOT_CONFIGPATH -#define ROOT_CONFIGPATH "%A," "%R," \ - "/etc/X11/%R," "%P/etc/X11/%R," \ - "%E," "%F," \ - "/etc/X11/%F," "%P/etc/X11/%F," \ - "%D/%X," \ - "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \ - "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \ - "%P/etc/X11/%X," \ - "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \ - "%P/lib/X11/%X" -#endif -#ifndef USER_CONFIGPATH -#define USER_CONFIGPATH "/etc/X11/%S," "%P/etc/X11/%S," \ - "/etc/X11/%G," "%P/etc/X11/%G," \ - "/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \ - "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \ - "%P/etc/X11/%X," \ - "%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \ - "%P/lib/X11/%X" -#endif #ifndef PROJECTROOT #define PROJECTROOT "/usr/X11R6" #endif @@ -2552,25 +2527,30 @@ addDefaultModes(MonPtr monitorp) ConfigStatus xf86HandleConfigFile(Bool autoconfig) { - const char *filename; - char *searchpath; + char *filename; MessageType from = X_DEFAULT; char *scanptr; + FILE *fptr = NULL; Bool singlecard = 0; if (!autoconfig) { - if (getuid() == 0) - searchpath = ROOT_CONFIGPATH; - else - searchpath = USER_CONFIGPATH; - if (xf86ConfigFile) + if (xf86ConfigFile) { from = X_CMDLINE; + filename = malloc(strlen(xf86ConfigFile) + 1); + strcpy(filename, xf86ConfigFile); + } else { + filename = malloc(strlen(DEFAULT_CONFIGPATH) + strlen(XORG_CONFIGFILE) + 1); + sprintf(filename, "%s/%s", DEFAULT_CONFIGPATH, XORG_CONFIGFILE); + } + + xf86openConfigFile(filename); + xf86ConfigFile = xnfstrdup(filename); + fptr = fopen(filename,"r"); - filename = xf86openConfigFile(searchpath, xf86ConfigFile, PROJECTROOT); - if (filename) { + if (fptr) { xf86MsgVerb(from, 0, "Using config file: \"%s\"\n", filename); - xf86ConfigFile = xnfstrdup(filename); + fclose(fptr); } else { xf86Msg(X_ERROR, "Unable to locate/open config file"); if (xf86ConfigFile) @@ -2579,11 +2559,13 @@ xf86HandleConfigFile(Bool autoconfig) return CONFIG_NOFILE; } } - + + if ((xf86configptr = xf86readConfigFile ()) == NULL) { xf86Msg(X_ERROR, "Problem parsing the config file\n"); return CONFIG_PARSE_ERROR; } + xf86closeConfigFile (); /* Initialise a few things. */ diff --exclude Makefile --exclude Makefile.in --exclude .libs --exclude '*.lo' --exclude '*.o' --exclude '*.log' --exclude '*.status' --exclude configure --exclude xf86Build.h --exclude dix-config.h --exclude 'do-not-use-config.*' -Nrup xserver.old/xorg/hw/xfree86/common/xf86Configure.c xserver/xorg/hw/xfree86/common/xf86Configure.c --- xserver.old/xorg/hw/xfree86/common/xf86Configure.c 2005-08-15 19:48:35.000000000 -0400 +++ xserver/xorg/hw/xfree86/common/xf86Configure.c 2005-10-01 02:17:53.000000000 -0400 @@ -888,7 +888,7 @@ DoConfigure() #if defined(SCO) || defined(SCO325) #define PATH_MAX 1024 #endif - const char* configfile = XF86CONFIGFILE".new"; + const char* configfile = XORG_CONFIGFILE".new"; char homebuf[PATH_MAX]; /* getenv might return R/O memory, as with OS/2 */ strncpy(homebuf,home,PATH_MAX-1); @@ -905,7 +905,6 @@ DoConfigure() #else sprintf(filename, "//%d%s/%s", getnid(),home,configfile); #endif - } xf86writeConfigFile(filename, xf86config); @@ -1035,7 +1034,7 @@ DoConfigure() " has configured a multihead system, please check your config.\n"); } - ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE ,filename); + ErrorF("\nYour %s file is %s\n\n", XORG_CONFIGFILE, filename); ErrorF("To test the server, run 'X -config %s'\n\n", filename); bail: diff --exclude Makefile --exclude Makefile.in --exclude .libs --exclude '*.lo' --exclude '*.o' --exclude '*.log' --exclude '*.status' --exclude configure --exclude xf86Build.h --exclude dix-config.h --exclude 'do-not-use-config.*' -Nrup xserver.old/xorg/hw/xfree86/common/xf86Init.c xserver/xorg/hw/xfree86/common/xf86Init.c --- xserver.old/xorg/hw/xfree86/common/xf86Init.c 2005-08-11 21:17:58.000000000 -0400 +++ xserver/xorg/hw/xfree86/common/xf86Init.c 2005-10-01 02:17:53.000000000 -0400 @@ -1397,7 +1397,7 @@ ddxProcessArgument(int argc, char **argv return 2; } } - if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config")) + if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config") || !strcmp(argv[i], "-xorgconfig")) { if (!argv[i + 1]) return 0; @@ -1405,7 +1405,7 @@ ddxProcessArgument(int argc, char **argv FatalError("\nInvalid argument for -config\n" "\tFor non-root users, the file specified with -config must be\n" "\ta relative path and must not contain any \"..\" elements.\n" - "\tUsing default "__XCONFIGFILE__" search path.\n\n"); + "\tUsing default "DEFAULT_CONFIGPATH" search path.\n\n"); } xf86ConfigFile = argv[i + 1]; return 2; @@ -1726,12 +1726,12 @@ ddxUseMsg() { ErrorF("-modulepath paths specify the module search path\n"); ErrorF("-logfile file specify a log file name\n"); - ErrorF("-configure probe for devices and write an "__XCONFIGFILE__"\n"); + ErrorF("-configure probe for devices and write an "XORG_CONFIGFILE"\n"); } else { ErrorF("-config file specify a configuration file, relative to the\n"); - ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n"); + ErrorF(" "XORG_CONFIGFILE" search path, only root can use absolute\n"); } ErrorF("-probeonly probe for devices, then exit\n"); ErrorF("-scanpci execute the scanpci module and exit\n"); diff --exclude Makefile --exclude Makefile.in --exclude .libs --exclude '*.lo' --exclude '*.o' --exclude '*.log' --exclude '*.status' --exclude configure --exclude xf86Build.h --exclude dix-config.h --exclude 'do-not-use-config.*' -Nrup xserver.old/xorg/hw/xfree86/parser/scan.c xserver/xorg/hw/xfree86/parser/scan.c --- xserver.old/xorg/hw/xfree86/parser/scan.c 2005-07-03 03:01:37.000000000 -0400 +++ xserver/xorg/hw/xfree86/parser/scan.c 2005-10-01 02:17:37.000000000 -0400 @@ -95,7 +95,7 @@ static int StringToToken (char *, xf86ConfigSymTabRec *); -static FILE *configFile = NULL; +FILE *configFile = NULL; static const char **builtinConfig = NULL; static int builtinIndex = 0; static int configPos = 0; /* current readers position */ @@ -181,9 +181,15 @@ xf86getToken (xf86ConfigSymTabRec * tab) * eol_seen is only set for the first token after a newline. */ eol_seen = 0; + + if (!configBuf) { + configBuf = xf86confmalloc (CONFIG_BUF_LEN); + configBuf[0] = '\0'; /* sanity ... */ + } + if (!configRBuf) + configRBuf = xf86confmalloc (CONFIG_BUF_LEN); c = configBuf[configPos]; - /* * Get start of next Token. EOF is handled, * whitespaces are skipped. @@ -193,7 +199,7 @@ again: if (!c) { char *ret; - if (configFile) + if (configFile) ret = fgets (configBuf, CONFIG_BUF_LEN - 1, configFile); else { if (builtinConfig[builtinIndex] == NULL) @@ -498,265 +504,18 @@ xf86pathIsSafe(const char *path) } \ } while (0) -static char * -DoSubstitution(const char *template, const char *cmdline, const char *projroot, - int *cmdlineUsed, int *envUsed, char *XConfigFile) -{ - char *result; - int i, l; - static const char *env = NULL, *home = NULL; - static char *hostname = NULL; - static char majorvers[3] = ""; -#ifdef __UNIXOS2__ - static char *x11root = NULL; -#endif - - if (!template) - return NULL; - - if (cmdlineUsed) - *cmdlineUsed = 0; - if (envUsed) - *envUsed = 0; - - result = xf86confmalloc(PATH_MAX + 1); - l = 0; - for (i = 0; template[i]; i++) { - if (template[i] != '%') { - result[l++] = template[i]; - CHECK_LENGTH; - } else { - switch (template[++i]) { - case 'A': - if (cmdline && xf86pathIsAbsolute(cmdline)) { - APPEND_STR(cmdline); - if (cmdlineUsed) - *cmdlineUsed = 1; - } else - BAIL_OUT; - break; - case 'R': - if (cmdline && !xf86pathIsAbsolute(cmdline)) { - APPEND_STR(cmdline); - if (cmdlineUsed) - *cmdlineUsed = 1; - } else - BAIL_OUT; - break; - case 'S': - if (cmdline && xf86pathIsSafe(cmdline)) { - APPEND_STR(cmdline); - if (cmdlineUsed) - *cmdlineUsed = 1; - } else - BAIL_OUT; - break; - case 'X': - APPEND_STR(XConfigFile); - break; - case 'H': - if (!hostname) { - if ((hostname = xf86confmalloc(MAXHOSTNAMELEN + 1))) { - if (gethostname(hostname, MAXHOSTNAMELEN) == 0) { - hostname[MAXHOSTNAMELEN] = '\0'; - } else { - xf86conffree(hostname); - hostname = NULL; - } - } - } - if (hostname) - APPEND_STR(hostname); - break; - case 'E': - if (!env) - env = getenv(XCONFENV); - if (env && xf86pathIsAbsolute(env)) { - APPEND_STR(env); - if (envUsed) - *envUsed = 1; - } else - BAIL_OUT; - break; - case 'F': - if (!env) - env = getenv(XCONFENV); - if (env && !xf86pathIsAbsolute(env)) { - APPEND_STR(env); - if (envUsed) - *envUsed = 1; - } else - BAIL_OUT; - break; - case 'G': - if (!env) - env = getenv(XCONFENV); - if (env && xf86pathIsSafe(env)) { - APPEND_STR(env); - if (envUsed) - *envUsed = 1; - } else - BAIL_OUT; - break; - case 'D': - if (!home) - home = getenv("HOME"); - if (home && xf86pathIsAbsolute(home)) - APPEND_STR(home); - else - BAIL_OUT; - break; - case 'P': - if (projroot && xf86pathIsAbsolute(projroot)) - APPEND_STR(projroot); - else - BAIL_OUT; - break; - case 'M': - if (!majorvers[0]) { - if (XF86_VERSION_MAJOR < 0 || XF86_VERSION_MAJOR > 99) { - fprintf(stderr, "XF86_VERSION_MAJOR is out of range\n"); - BAIL_OUT; - } else - sprintf(majorvers, "%d", XF86_VERSION_MAJOR); - } - APPEND_STR(majorvers); - break; - case '%': - result[l++] = '%'; - CHECK_LENGTH; - break; -#ifdef __UNIXOS2__ - case '&': - if (!x11root) - x11root = getenv("X11ROOT"); - if (x11root) - APPEND_STR(x11root); - else - BAIL_OUT; - break; -#endif - default: - fprintf(stderr, "invalid escape %%%c found in path template\n", - template[i]); - BAIL_OUT; - break; - } - } - } -#ifdef DEBUG - fprintf(stderr, "Converted `%s' to `%s'\n", template, result); -#endif - return result; -} - /* * xf86openConfigFile -- - * - * This function take a config file search path (optional), a command-line - * specified file name (optional) and the ProjectRoot path (optional) and - * locates and opens a config file based on that information. If a - * command-line file name is specified, then this function fails if none - * of the located files. - * - * The return value is a pointer to the actual name of the file that was - * opened. When no file is found, the return value is NULL. - * - * The escape sequences allowed in the search path are defined above. - * */ -#ifndef DEFAULT_CONF_PATH -#define DEFAULT_CONF_PATH "/etc/X11/%S," \ - "%P/etc/X11/%S," \ - "/etc/X11/%G," \ - "%P/etc/X11/%G," \ - "/etc/X11/%X-%M," \ - "/etc/X11/%X," \ - "/etc/%X," \ - "%P/etc/X11/%X.%H," \ - "%P/etc/X11/%X-%M," \ - "%P/etc/X11/%X," \ - "%P/lib/X11/%X.%H," \ - "%P/lib/X11/%X-%M," \ - "%P/lib/X11/%X" -#endif - -const char * -xf86openConfigFile(const char *path, const char *cmdline, const char *projroot) -{ - char *pathcopy; - const char *template; - int cmdlineUsed = 0; - - configFile = NULL; - configPos = 0; /* current readers position */ - configLineNo = 0; /* linenumber */ - pushToken = LOCK_TOKEN; - - if (!path || !path[0]) - path = DEFAULT_CONF_PATH; - pathcopy = xf86confmalloc(strlen(path) + 1); - strcpy(pathcopy, path); - if (!projroot || !projroot[0]) - projroot = PROJECTROOT; - - template = strtok(pathcopy, ","); - - /* First, search for a config file. */ - while (template && !configFile) { - if ((configPath = DoSubstitution(template, cmdline, projroot, - &cmdlineUsed, NULL, - XCONFIGFILE))) { - if ((configFile = fopen(configPath, "r")) != 0) { - if (cmdline && !cmdlineUsed) { - fclose(configFile); - configFile = NULL; - } - } - } - if (configPath && !configFile) { - xf86conffree(configPath); - configPath = NULL; - } - template = strtok(NULL, ","); - } - - /* Then search for fallback */ - if (!configFile) { - strcpy(pathcopy, path); - template = strtok(pathcopy, ","); - - while (template && !configFile) { - if ((configPath = DoSubstitution(template, cmdline, projroot, - &cmdlineUsed, NULL, - XFREE86CFGFILE))) { - if ((configFile = fopen(configPath, "r")) != 0) { - if (cmdline && !cmdlineUsed) { - fclose(configFile); - configFile = NULL; - } - } - } - if (configPath && !configFile) { - xf86conffree(configPath); - configPath = NULL; - } - template = strtok(NULL, ","); - } - } - - xf86conffree(pathcopy); - if (!configFile) { - - return NULL; - } +void +xf86openConfigFile(const char *conf) { + if (!configFile) + configFile = fopen(conf, "r"); configBuf = xf86confmalloc (CONFIG_BUF_LEN); configRBuf = xf86confmalloc (CONFIG_BUF_LEN); configBuf[0] = '\0'; /* sanity ... */ - - return configPath; } void diff --exclude Makefile --exclude Makefile.in --exclude .libs --exclude '*.lo' --exclude '*.o' --exclude '*.log' --exclude '*.status' --exclude configure --exclude xf86Build.h --exclude dix-config.h --exclude 'do-not-use-config.*' -Nrup xserver.old/xorg/hw/xfree86/parser/xf86Parser.h xserver/xorg/hw/xfree86/parser/xf86Parser.h --- xserver.old/xorg/hw/xfree86/parser/xf86Parser.h 2005-07-03 03:01:37.000000000 -0400 +++ xserver/xorg/hw/xfree86/parser/xf86Parser.h 2005-10-01 02:17:37.000000000 -0400 @@ -454,8 +454,8 @@ xf86ConfigSymTabRec, *xf86ConfigSymTabPt /* * prototypes for public functions */ -extern const char *xf86openConfigFile (const char *, const char *, - const char *); +extern FILE *configFile; +extern void xf86openConfigFile(const char *); extern void xf86setBuiltinConfig(const char *config[]); extern XF86ConfigPtr xf86readConfigFile (void); extern void xf86closeConfigFile (void); diff --exclude Makefile --exclude Makefile.in --exclude .libs --exclude '*.lo' --exclude '*.o' --exclude '*.log' --exclude '*.status' --exclude configure --exclude xf86Build.h --exclude dix-config.h --exclude 'do-not-use-config.*' -Nrup xserver.old/xorg/include/xorg-config.h.in xserver/xorg/include/xorg-config.h.in --- xserver.old/xorg/include/xorg-config.h.in 2005-10-01 02:09:28.000000000 -0400 +++ xserver/xorg/include/xorg-config.h.in 2005-10-01 02:17:19.000000000 -0400 @@ -48,11 +48,11 @@ /* Built-in input drivers. */ #undef IDRIVERS -/* Path to configuration file. */ -#undef XF86CONFIGFILE +/* Name of configuration file name. */ +#undef XORG_CONFIGFILE /* Path to configuration file. */ -#undef __XCONFIGFILE__ +#undef DEFAULT_CONFIGPATH /* Path to loadable modules. */ #undef DEFAULT_MODULE_PATH