<div dir="ltr">Hi Kristian,<div><br></div><div style>Here's another revision of the patch that attempts to implement your suggested simplification, as well as address the TOCTOU race in previous revisions of the patch.  The module entry point signature changed slightly because of the latter.  Note that I had to modify the strchrnul() loop slightly from what you suggested since the "next" string ended up beginning with a colon ':' after the first iteration.  I'm not exactly happy with my solution (p =( *next == ':' ? next + 1 : next)).  Please let me know what you think.</div>
<div style><br></div><div style>Thanks!</div><div style>-Ossama</div><div style><br></div><div style>---</div><div style><br></div><div style><div>From 528848247242cdf476e05569b5abef029d438f79 Mon Sep 17 00:00:00 2001</div>
<div>From: Ossama Othman <<a href="mailto:ossama.othman@intel.com">ossama.othman@intel.com</a>></div><div>Date: Mon, 13 May 2013 16:12:32 -0700</div><div>Subject: [PATCH] config-parser: Honor XDG_CONFIG_DIRS.</div><div>
<br></div><div>This set of changes adds support for searching for a given config file</div><div>in the directories listed in $XDG_CONFIG_DIRS if it wasn't found in</div><div>$XDG_CONFIG_HOME or ~/.config.  This allows packages to install custom</div>
<div>config files in /etc/xdg/weston, for example, thus allowing them to</div><div>avoid dealing with home directories.</div><div><br></div><div>To avoid a TOCTOU race the config file is actually open()ed during the</div>
<div>search.  Its file descriptor is returned and stored in the compositor</div><div>for later use when performing subsequent config file parses.</div><div><br></div><div>Signed-off-by: Ossama Othman <<a href="mailto:ossama.othman@intel.com">ossama.othman@intel.com</a>></div>
<div>---</div><div> clients/desktop-shell.c   |    8 ++--</div><div> clients/tablet-shell.c    |    8 ++--</div><div> clients/terminal.c        |    8 ++--</div><div> clients/window.c          |    8 ++--</div><div> man/weston.ini.man        |   12 +++++-</div>
<div> shared/config-parser.c    |   92 ++++++++++++++++++++++++++++++---------------</div><div> shared/config-parser.h    |    6 +--</div><div> src/cms-static.c          |    4 +-</div><div> src/compositor-drm.c      |   10 ++---</div>
<div> src/compositor-fbdev.c    |    8 ++--</div><div> src/compositor-headless.c |    8 ++--</div><div> src/compositor-rdp.c      |    4 +-</div><div> src/compositor-rpi.c      |    8 ++--</div><div> src/compositor-wayland.c  |    8 ++--</div>
<div> src/compositor-x11.c      |   10 ++---</div><div> src/compositor.c          |   31 +++++++--------</div><div> src/compositor.h          |    8 ++--</div><div> src/shell.c               |    8 ++--</div><div> src/tablet-shell.c        |    2 +-</div>
<div> src/text-backend.c        |    9 +++--</div><div> src/xwayland/launcher.c   |    2 +-</div><div> tests/weston-test.c       |    2 +-</div><div> 22 files changed, 154 insertions(+), 110 deletions(-)</div><div><br></div>
<div>diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c</div><div>index 38af6c6..3949975 100644</div><div>--- a/clients/desktop-shell.c</div><div>+++ b/clients/desktop-shell.c</div><div>@@ -1090,7 +1090,7 @@ add_default_launcher(struct desktop *desktop)</div>
<div> int main(int argc, char *argv[])</div><div> {</div><div> <span class="" style="white-space:pre">  </span>struct desktop desktop = { 0 };</div><div>-<span class="" style="white-space:pre">   </span>char *config_file;</div>
<div>+<span class="" style="white-space:pre">   </span>int config_fd;</div><div> <span class="" style="white-space:pre">    </span>struct output *output;</div><div> <span class="" style="white-space:pre">    </span>int ret;</div>
<div> </div><div>@@ -1122,11 +1122,11 @@ int main(int argc, char *argv[])</div><div> </div><div> <span class="" style="white-space:pre">    </span>grab_surface_create(&desktop);</div><div> </div><div>-<span class="" style="white-space:pre">        </span>config_file = config_file_path("weston.ini");</div>
<div>-<span class="" style="white-space:pre">   </span>ret = parse_config_file(config_file,</div><div>+<span class="" style="white-space:pre">      </span>config_fd = open_config_file("weston.ini");</div><div>+<span class="" style="white-space:pre">     </span>ret = parse_config_file(config_fd,</div>
<div> <span class="" style="white-space:pre">                           </span>config_sections, ARRAY_LENGTH(config_sections),</div><div> <span class="" style="white-space:pre">                           </span>&desktop);</div><div>-<span class="" style="white-space:pre">    </span>free(config_file);</div>
<div>+<span class="" style="white-space:pre">   </span>close(config_fd);</div><div> <span class="" style="white-space:pre"> </span>if (ret < 0)</div><div> <span class="" style="white-space:pre">           </span>add_default_launcher(&desktop);</div>
<div> </div><div>diff --git a/clients/tablet-shell.c b/clients/tablet-shell.c</div><div>index 99d66f2..3d5e79a 100644</div><div>--- a/clients/tablet-shell.c</div><div>+++ b/clients/tablet-shell.c</div><div>@@ -456,7 +456,7 @@ int main(int argc, char *argv[])</div>
<div> {</div><div> <span class="" style="white-space:pre">  </span>struct tablet tablet = { 0 };</div><div> <span class="" style="white-space:pre">     </span>struct display *display;</div><div>-<span class="" style="white-space:pre">  </span>char *config_file;</div>
<div>+<span class="" style="white-space:pre">   </span>int config_fd;</div><div> <span class="" style="white-space:pre">    </span>struct output *output;</div><div> </div><div> <span class="" style="white-space:pre">    </span>display = display_create(&argc, argv);</div>
<div>@@ -478,11 +478,11 @@ int main(int argc, char *argv[])</div><div> </div><div> <span class="" style="white-space:pre">      </span>wl_list_init(&tablet.homescreen->launcher_list);</div><div> </div><div>-<span class="" style="white-space:pre">   </span>config_file = config_file_path("weston.ini");</div>
<div>-<span class="" style="white-space:pre">   </span>parse_config_file(config_file,</div><div>+<span class="" style="white-space:pre">    </span>config_fd = open_config_file("weston.ini");</div><div>+<span class="" style="white-space:pre">     </span>parse_config_file(config_fd,</div>
<div> <span class="" style="white-space:pre">                   </span>  config_sections, ARRAY_LENGTH(config_sections),</div><div> <span class="" style="white-space:pre">                 </span>  &tablet);</div><div>-<span class="" style="white-space:pre">   </span>free(config_file);</div>
<div>+<span class="" style="white-space:pre">   </span>close(config_fd);</div><div> </div><div> <span class="" style="white-space:pre"> </span>signal(SIGCHLD, sigchild_handler);</div><div> </div><div>diff --git a/clients/terminal.c b/clients/terminal.c</div>
<div>index e80e0e5..f11a6cc 100644</div><div>--- a/clients/terminal.c</div><div>+++ b/clients/terminal.c</div><div>@@ -2671,17 +2671,17 @@ int main(int argc, char *argv[])</div><div> {</div><div> <span class="" style="white-space:pre"> </span>struct display *d;</div>
<div> <span class="" style="white-space:pre">   </span>struct terminal *terminal;</div><div>-<span class="" style="white-space:pre">        </span>char *config_file;</div><div>+<span class="" style="white-space:pre">        </span>int config_fd;</div>
<div> </div><div> <span class="" style="white-space:pre">   </span>option_shell = getenv("SHELL");</div><div> <span class="" style="white-space:pre"> </span>if (!option_shell)</div><div> <span class="" style="white-space:pre">                </span>option_shell = "/bin/bash";</div>
<div> </div><div>-<span class="" style="white-space:pre">   </span>config_file = config_file_path("weston.ini");</div><div>-<span class="" style="white-space:pre">   </span>parse_config_file(config_file,</div><div>+<span class="" style="white-space:pre">    </span>config_fd = open_config_file("weston.ini");</div>
<div>+<span class="" style="white-space:pre">   </span>parse_config_file(config_fd,</div><div> <span class="" style="white-space:pre">                      </span>  config_sections, ARRAY_LENGTH(config_sections),</div><div> <span class="" style="white-space:pre">                 </span>  NULL);</div>
<div>-<span class="" style="white-space:pre">   </span>free(config_file);</div><div>+<span class="" style="white-space:pre">        </span>close(config_fd);</div><div> </div><div> <span class="" style="white-space:pre"> </span>parse_options(terminal_options,</div>
<div> <span class="" style="white-space:pre">           </span>      ARRAY_LENGTH(terminal_options), &argc, argv);</div><div>diff --git a/clients/window.c b/clients/window.c</div><div>index 1562957..a742b2f 100644</div><div>--- a/clients/window.c</div>
<div>+++ b/clients/window.c</div><div>@@ -1188,7 +1188,7 @@ static const struct cursor_alternatives cursors[] = {</div><div> static void</div><div> create_cursors(struct display *display)</div><div> {</div><div>-<span class="" style="white-space:pre"> </span>char *config_file;</div>
<div>+<span class="" style="white-space:pre">   </span>int config_fd;</div><div> <span class="" style="white-space:pre">    </span>char *theme = NULL;</div><div> <span class="" style="white-space:pre">       </span>unsigned int size = 32;</div>
<div> <span class="" style="white-space:pre">   </span>unsigned int i, j;</div><div>@@ -1201,9 +1201,9 @@ create_cursors(struct display *display)</div><div> <span class="" style="white-space:pre">            </span>{ "shell", shell_keys, ARRAY_LENGTH(shell_keys), NULL },</div>
<div> <span class="" style="white-space:pre">   </span>};</div><div> </div><div>-<span class="" style="white-space:pre">        </span>config_file = config_file_path("weston.ini");</div><div>-<span class="" style="white-space:pre">   </span>parse_config_file(config_file, cs, ARRAY_LENGTH(cs), NULL);</div>
<div>-<span class="" style="white-space:pre">   </span>free(config_file);</div><div>+<span class="" style="white-space:pre">        </span>config_fd = open_config_file("weston.ini");</div><div>+<span class="" style="white-space:pre">     </span>parse_config_file(config_fd, cs, ARRAY_LENGTH(cs), NULL);</div>
<div>+<span class="" style="white-space:pre">   </span>close(config_fd);</div><div> </div><div> <span class="" style="white-space:pre"> </span>display->cursor_theme = wl_cursor_theme_load(theme, size, display->shm);</div>
<div> <span class="" style="white-space:pre">   </span>display->cursors =</div><div>diff --git a/man/weston.ini.man b/man/weston.ini.man</div><div>index 2287730..d37654a 100644</div><div>--- a/man/weston.ini.man</div><div>
+++ b/man/weston.ini.man</div><div>@@ -24,7 +24,10 @@ server is started:</div><div> .nf</div><div> .BR "$XDG_CONFIG_HOME/weston.ini   " "(if $XDG_CONFIG_HOME is set)"</div><div> .BR "$HOME/.config/weston.ini      " "(if $HOME is set)"</div>
<div>-.BR "<current dir>/weston.ini      " "(if both variables were not set)"</div><div>+.B  "weston/weston.ini in each"</div><div>+.BR "\ \ \ \ $XDG_CONFIG_DIR           " "(if $XDG_CONFIG_DIRS is set)"</div>
<div>+.BR "/etc/xdg/weston/weston.ini    " "(if $XDG_CONFIG_DIRS is not set)"</div><div>+.BR "<current dir>/weston.ini      " "(if no variables were set)"</div><div> .fi</div>
<div> .RE</div><div> .PP</div><div>@@ -32,7 +35,12 @@ where environment variable</div><div> .B $HOME</div><div> is the user's home directory, and</div><div> .B $XDG_CONFIG_HOME</div><div>-is the user specific configuration directory.</div>
<div>+is the user specific configuration directory, and</div><div>+.B $XDG_CONFIG_DIRS</div><div>+is a colon</div><div>+.B ':'</div><div>+delimited listed of configuration base directories, such as</div><div>+.BR /etc/xdg-foo:/etc/xdg .</div>
<div> .PP</div><div> The</div><div> .I weston.ini</div><div>diff --git a/shared/config-parser.c b/shared/config-parser.c</div><div>index 10ff86a..e988a89 100644</div><div>--- a/shared/config-parser.c</div><div>+++ b/shared/config-parser.c</div>
<div>@@ -20,11 +20,17 @@</div><div>  * OF THIS SOFTWARE.</div><div>  */</div><div> </div><div>+#define _GNU_SOURCE   /* for stchrnul() */</div><div> #include <string.h></div><div> #include <stdio.h></div><div>
 #include <stdlib.h></div><div> #include <assert.h></div><div> #include <ctype.h></div><div>+#include <limits.h></div><div>+#include <sys/types.h></div><div>+#include <sys/stat.h></div>
<div>+#include <fcntl.h></div><div>+#include <unistd.h></div><div> </div><div> #include "config-parser.h"</div><div> </div><div>@@ -86,7 +92,7 @@ handle_key(const struct config_key *key, const char *value)</div>
<div> }</div><div> </div><div> int</div><div>-parse_config_file(const char *path,</div><div>+parse_config_file(int fd,</div><div> <span class="" style="white-space:pre">           </span>  const struct config_section *sections, int num_sections,</div>
<div> <span class="" style="white-space:pre">           </span>  void *data)</div><div> {</div><div>@@ -95,12 +101,17 @@ parse_config_file(const char *path,</div><div> <span class="" style="white-space:pre">     </span>const struct config_section *current = NULL;</div>
<div> <span class="" style="white-space:pre">   </span>int i;</div><div> </div><div>-<span class="" style="white-space:pre">    </span>fp = fopen(path, "r");</div><div>+<span class="" style="white-space:pre">  </span>if (fd == -1)</div>
<div>+<span class="" style="white-space:pre">           </span>return -1;</div><div>+</div><div>+<span class="" style="white-space:pre">        </span>fp = fdopen(dup(fd), "r");</div><div> <span class="" style="white-space:pre">      </span>if (fp == NULL) {</div>
<div>-<span class="" style="white-space:pre">           </span>fprintf(stderr, "couldn't open %s\n", path);</div><div>+            perror("couldn't open config file");</div><div> <span class="" style="white-space:pre">          </span>return -1;</div>
<div> <span class="" style="white-space:pre">   </span>}</div><div> </div><div>+<span class="" style="white-space:pre"> </span>rewind(fp);</div><div>+</div><div> <span class="" style="white-space:pre">       </span>while (fgets(line, sizeof line, fp)) {</div>
<div> <span class="" style="white-space:pre">           </span>if (line[0] == '#' || line[0] == '\n') {</div><div> <span class="" style="white-space:pre">                  </span>continue;</div><div>@@ -151,37 +162,58 @@ parse_config_file(const char *path,</div>
<div> <span class="" style="white-space:pre">   </span>return 0;</div><div> }</div><div> </div><div>-char *</div><div>-config_file_path(const char *name)</div><div>+int</div><div>+open_config_file(const char *name)</div><div>
 {</div><div>-<span class="" style="white-space:pre">     </span>const char dotconf[] = "/.config/";</div><div>-<span class="" style="white-space:pre">     </span>const char *config_dir;</div><div>-<span class="" style="white-space:pre">   </span>const char *home_dir;</div>
<div>-<span class="" style="white-space:pre">   </span>char *path;</div><div>-<span class="" style="white-space:pre">       </span>size_t size;</div><div>-</div><div>-<span class="" style="white-space:pre">      </span>config_dir = getenv("XDG_CONFIG_HOME");</div>
<div>-<span class="" style="white-space:pre">   </span>if (!config_dir) {</div><div>-<span class="" style="white-space:pre">                </span>home_dir = getenv("HOME");</div><div>-<span class="" style="white-space:pre">              </span>if (!home_dir) {</div>
<div>-<span class="" style="white-space:pre">                   </span>fprintf(stderr, "HOME is not set, using cwd.\n");</div><div>-<span class="" style="white-space:pre">                       </span>return strdup(name);</div><div>-<span class="" style="white-space:pre">              </span>}</div>
<div>+<span class="" style="white-space:pre">   </span>const char *config_dir  = getenv("XDG_CONFIG_HOME");</div><div>+<span class="" style="white-space:pre">    </span>const char *home_dir<span class="" style="white-space:pre">      </span>= getenv("HOME");</div>
<div>+<span class="" style="white-space:pre">   </span>const char *config_dirs = getenv("XDG_CONFIG_DIRS");</div><div>+<span class="" style="white-space:pre">    </span>char path[PATH_MAX];</div><div>+<span class="" style="white-space:pre">      </span>const char *p, *next;</div>
<div>+<span class="" style="white-space:pre">   </span>int fd;</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>/* Precedence is given to config files in the home directory,</div><div>+<span class="" style="white-space:pre">     </span> * and then to directories listed in XDG_CONFIG_DIRS and</div>
<div>+<span class="" style="white-space:pre">   </span> * finally to the current working directory. */</div><div>+</div><div>+<span class="" style="white-space:pre">   </span>/* $XDG_CONFIG_HOME */</div><div>+<span class="" style="white-space:pre">    </span>if (config_dir) {</div>
<div>+<span class="" style="white-space:pre">           </span>snprintf(path, sizeof path, "%s/%s", config_dir, name);</div><div>+<span class="" style="white-space:pre">         </span>fd = open(path, O_RDONLY | O_CLOEXEC);</div>
<div>+<span class="" style="white-space:pre">           </span>if (fd >= 0)</div><div>+<span class="" style="white-space:pre">                   </span>return fd;</div><div>+<span class="" style="white-space:pre">        </span>}</div><div>+</div><div>
+<span class="" style="white-space:pre">      </span>/* $HOME/.config */</div><div>+<span class="" style="white-space:pre">       </span>if (home_dir) {</div><div>+<span class="" style="white-space:pre">           </span>snprintf(path, sizeof path, "%s/.config/%s", home_dir, name);</div>
<div>+<span class="" style="white-space:pre">           </span>fd = open(path, O_RDONLY | O_CLOEXEC);</div><div>+<span class="" style="white-space:pre">            </span>if (fd >= 0)</div><div>+<span class="" style="white-space:pre">                   </span>return fd;</div>
<div>+<span class="" style="white-space:pre">   </span>}</div><div> </div><div>-<span class="" style="white-space:pre">         </span>size = strlen(home_dir) + sizeof dotconf + strlen(name);</div><div>-<span class="" style="white-space:pre">          </span>path = malloc(size);</div>
<div>-<span class="" style="white-space:pre">           </span>if (!path)</div><div>-<span class="" style="white-space:pre">                        </span>return NULL;</div><div>+<span class="" style="white-space:pre">      </span>/* For each $XDG_CONFIG_DIRS: weston/<config_file> */</div>
<div>+<span class="" style="white-space:pre">   </span>if (!config_dirs)</div><div>+<span class="" style="white-space:pre">         </span>config_dirs = "/etc/xdg";  /* See XDG base dir spec. */</div><div> </div><div>-<span class="" style="white-space:pre">         </span>snprintf(path, size, "%s%s%s", home_dir, dotconf, name);</div>
<div>-<span class="" style="white-space:pre">           </span>return path;</div><div>+<span class="" style="white-space:pre">      </span>for (p = config_dirs; *p; p = (*next == ':' ? next + 1 : next)) {</div><div>+<span class="" style="white-space:pre">         </span>next = strchrnul(p, ':');</div>
<div>+<span class="" style="white-space:pre">           </span>snprintf(path, sizeof path, "%.*s/weston/%s", next - p, p, name);</div><div>+<span class="" style="white-space:pre">               </span>fd = open(path, O_RDONLY | O_CLOEXEC);</div>
<div>+<span class="" style="white-space:pre">           </span>if (fd >= 0)</div><div>+<span class="" style="white-space:pre">           </span>return fd;</div><div> <span class="" style="white-space:pre">        </span>}</div><div> </div><div>
-<span class="" style="white-space:pre">      </span>size = strlen(config_dir) + 1 + strlen(name) + 1;</div><div>-<span class="" style="white-space:pre"> </span>path = malloc(size);</div><div>-<span class="" style="white-space:pre">      </span>if (!path)</div>
<div>-<span class="" style="white-space:pre">           </span>return NULL;</div><div>+<span class="" style="white-space:pre">      </span>/* Current working directory. */</div><div>+<span class="" style="white-space:pre">  </span>snprintf(path, sizeof path, "./%s", name);</div>
<div>+<span class="" style="white-space:pre">   </span>fd = open(path, O_RDONLY | O_CLOEXEC);</div><div>+</div><div>+<span class="" style="white-space:pre">    </span>if (fd >= 0)</div><div>+<span class="" style="white-space:pre">           </span>fprintf(stderr,</div>
<div>+<span class="" style="white-space:pre">                   </span>"using config in current working directory: %s\n",</div><div>+<span class="" style="white-space:pre">                      </span>path);</div><div>+<span class="" style="white-space:pre">    </span>else</div>
<div>+<span class="" style="white-space:pre">           </span>fprintf(stderr, "config file \"%s\" not found.\n", name);</div><div> </div><div>-<span class="" style="white-space:pre">     </span>snprintf(path, size, "%s/%s", config_dir, name);</div>
<div>-<span class="" style="white-space:pre">   </span>return path;</div><div>+<span class="" style="white-space:pre">      </span>return fd;</div><div> }</div><div>diff --git a/shared/config-parser.h b/shared/config-parser.h</div>
<div>index 1d0ee3f..b4347d7 100644</div><div>--- a/shared/config-parser.h</div><div>+++ b/shared/config-parser.h</div><div>@@ -48,12 +48,12 @@ struct config_section {</div><div> };</div><div> </div><div> int</div><div>-parse_config_file(const char *path,</div>
<div>+parse_config_file(int config_fd,</div><div> <span class="" style="white-space:pre">           </span>  const struct config_section *sections, int num_sections,</div><div> <span class="" style="white-space:pre">                </span>  void *data);</div>
<div> </div><div>-char *</div><div>-config_file_path(const char *name);</div><div>+int</div><div>+open_config_file(const char *name);</div><div> </div><div> enum weston_option_type {</div><div> <span class="" style="white-space:pre">   </span>WESTON_OPTION_INTEGER,</div>
<div>diff --git a/src/cms-static.c b/src/cms-static.c</div><div>index be8e63e..94fea99 100644</div><div>--- a/src/cms-static.c</div><div>+++ b/src/cms-static.c</div><div>@@ -131,7 +131,7 @@ output_section_done(void *data)</div>
<div> </div><div> WL_EXPORT int</div><div> module_init(struct weston_compositor *ec,</div><div>-<span class="" style="white-space:pre">     </span>    int *argc, char *argv[], const char *config_file)</div><div>+<span class="" style="white-space:pre">     </span>    int *argc, char *argv[])</div>
<div> {</div><div> <span class="" style="white-space:pre">  </span>struct cms_static *cms;</div><div> <span class="" style="white-space:pre">   </span>struct weston_output *output;</div><div>@@ -157,7 +157,7 @@ module_init(struct weston_compositor *ec,</div>
<div> <span class="" style="white-space:pre">           </span>ARRAY_LENGTH(drm_config_keys), output_section_done },</div><div> <span class="" style="white-space:pre">     </span>};</div><div> </div><div>-<span class="" style="white-space:pre">        </span>parse_config_file(config_file, config_section,</div>
<div>+<span class="" style="white-space:pre">   </span>parse_config_file(ec->config_fd, config_section,</div><div> <span class="" style="white-space:pre">                       </span>  ARRAY_LENGTH(config_section), cms);</div><div> </div><div>
 <span class="" style="white-space:pre">      </span>cms->destroy_listener.notify = cms_notifier_destroy;</div><div>diff --git a/src/compositor-drm.c b/src/compositor-drm.c</div><div>index bb8ea46..b188a1a 100644</div><div>
--- a/src/compositor-drm.c</div><div>+++ b/src/compositor-drm.c</div><div>@@ -2340,7 +2340,7 @@ planes_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *data</div><div> static struct weston_compositor *</div>
<div> drm_compositor_create(struct wl_display *display,</div><div> <span class="" style="white-space:pre">          </span>      int connector, const char *seat, int tty, int pixman,</div><div>-<span class="" style="white-space:pre">               </span>      int *argc, char *argv[], const char *config_file)</div>
<div>+<span class="" style="white-space:pre">           </span>      int *argc, char *argv[], int config_fd)</div><div> {</div><div> <span class="" style="white-space:pre">    </span>struct drm_compositor *ec;</div><div> <span class="" style="white-space:pre">        </span>struct udev_device *drm_device;</div>
<div>@@ -2363,7 +2363,7 @@ drm_compositor_create(struct wl_display *display,</div><div> <span class="" style="white-space:pre">     </span>ec->use_pixman = pixman;</div><div> </div><div> <span class="" style="white-space:pre">       </span>if (weston_compositor_init(&ec->base, display, argc, argv,</div>
<div>-<span class="" style="white-space:pre">                           </span>   config_file) < 0) {</div><div>+<span class="" style="white-space:pre">                         </span>   config_fd) < 0) {</div><div> <span class="" style="white-space:pre">           </span>weston_log("%s failed\n", __func__);</div>
<div> <span class="" style="white-space:pre">           </span>goto err_base;</div><div> <span class="" style="white-space:pre">    </span>}</div><div>@@ -2644,7 +2644,7 @@ output_section_done(void *data)</div><div> </div><div> WL_EXPORT struct weston_compositor *</div>
<div> backend_init(struct wl_display *display, int *argc, char *argv[],</div><div>-<span class="" style="white-space:pre">  </span>     const char *config_file)</div><div>+<span class="" style="white-space:pre">     </span>     int config_fd)</div>
<div> {</div><div> <span class="" style="white-space:pre">  </span>int connector = 0, tty = 0, use_pixman = 0;</div><div> <span class="" style="white-space:pre">       </span>const char *seat = default_seat;</div><div>@@ -2672,9 +2672,9 @@ backend_init(struct wl_display *display, int *argc, char *argv[],</div>
<div> <span class="" style="white-space:pre">           </span>ARRAY_LENGTH(drm_config_keys), output_section_done },</div><div> <span class="" style="white-space:pre">     </span>};</div><div> </div><div>-<span class="" style="white-space:pre">        </span>parse_config_file(config_file, config_section,</div>
<div>+<span class="" style="white-space:pre">   </span>parse_config_file(config_fd, config_section,</div><div> <span class="" style="white-space:pre">                              </span>ARRAY_LENGTH(config_section), NULL);</div><div> </div><div> <span class="" style="white-space:pre">      </span>return drm_compositor_create(display, connector, seat, tty, use_pixman,</div>
<div>-<span class="" style="white-space:pre">                           </span>     argc, argv, config_file);</div><div>+<span class="" style="white-space:pre">                            </span>     argc, argv, config_fd);</div><div> }</div><div>diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c</div>
<div>index 0f45858..21028a5 100644</div><div>--- a/src/compositor-fbdev.c</div><div>+++ b/src/compositor-fbdev.c</div><div>@@ -835,7 +835,7 @@ switch_vt_binding(struct weston_seat *seat, uint32_t time, uint32_t key, void *d</div>
<div> </div><div> static struct weston_compositor *</div><div> fbdev_compositor_create(struct wl_display *display, int *argc, char *argv[],</div><div>-                        const char *config_file, struct fbdev_parameters *param)</div>
<div>+                        int config_fd, struct fbdev_parameters *param)</div><div> {</div><div> <span class="" style="white-space:pre">    </span>struct fbdev_compositor *compositor;</div><div> <span class="" style="white-space:pre">      </span>const char *seat = default_seat;</div>
<div>@@ -848,7 +848,7 @@ fbdev_compositor_create(struct wl_display *display, int *argc, char *argv[],</div><div> <span class="" style="white-space:pre">            </span>return NULL;</div><div> </div><div> <span class="" style="white-space:pre">      </span>if (weston_compositor_init(&compositor->base, display, argc, argv,</div>
<div>-<span class="" style="white-space:pre">   </span>                           config_file) < 0)</div><div>+<span class="" style="white-space:pre">   </span>                           config_fd) < 0)</div><div> <span class="" style="white-space:pre">             </span>goto out_free;</div>
<div> </div><div> <span class="" style="white-space:pre">   </span>compositor->udev = udev_new();</div><div>@@ -906,7 +906,7 @@ out_free:</div><div> </div><div> WL_EXPORT struct weston_compositor *</div><div> backend_init(struct wl_display *display, int *argc, char *argv[],</div>
<div>-<span class="" style="white-space:pre">   </span>     const char *config_file)</div><div>+<span class="" style="white-space:pre">     </span>     int config_fd)</div><div> {</div><div> <span class="" style="white-space:pre">      </span>/* TODO: Ideally, available frame buffers should be enumerated using</div>
<div> <span class="" style="white-space:pre">   </span> * udev, rather than passing a device node in as a parameter. */</div><div>@@ -922,6 +922,6 @@ backend_init(struct wl_display *display, int *argc, char *argv[],</div><div>
 </div><div> <span class="" style="white-space:pre">      </span>parse_options(fbdev_options, ARRAY_LENGTH(fbdev_options), argc, argv);</div><div> </div><div>-<span class="" style="white-space:pre">    </span>return fbdev_compositor_create(display, argc, argv, config_file,</div>
<div>+<span class="" style="white-space:pre">   </span>return fbdev_compositor_create(display, argc, argv, config_fd,</div><div> <span class="" style="white-space:pre">    </span>                               &param);</div>
<div> }</div><div>diff --git a/src/compositor-headless.c b/src/compositor-headless.c</div><div>index 4720329..0df0f7d 100644</div><div>--- a/src/compositor-headless.c</div><div>+++ b/src/compositor-headless.c</div><div>@@ -158,7 +158,7 @@ headless_destroy(struct weston_compositor *ec)</div>
<div> static struct weston_compositor *</div><div> headless_compositor_create(struct wl_display *display,</div><div> <span class="" style="white-space:pre">                    </span>  int width, int height, const char *display_name,</div>
<div>-<span class="" style="white-space:pre">                   </span>  int *argc, char *argv[], const char *config_file)</div><div>+<span class="" style="white-space:pre">                       </span>  int *argc, char *argv[], int config_fd)</div><div> {</div>
<div> <span class="" style="white-space:pre">   </span>struct headless_compositor *c;</div><div> </div><div>@@ -169,7 +169,7 @@ headless_compositor_create(struct wl_display *display,</div><div> <span class="" style="white-space:pre">   </span>memset(c, 0, sizeof *c);</div>
<div> </div><div> <span class="" style="white-space:pre">   </span>if (weston_compositor_init(&c->base, display, argc, argv,</div><div>-<span class="" style="white-space:pre">                          </span>   config_file) < 0)</div><div>
+<span class="" style="white-space:pre">                              </span>   config_fd) < 0)</div><div> <span class="" style="white-space:pre">             </span>goto err_free;</div><div> </div><div> <span class="" style="white-space:pre">    </span>weston_seat_init(&c->fake_seat, &c->base);</div>
<div>@@ -194,7 +194,7 @@ err_free:</div><div> </div><div> WL_EXPORT struct weston_compositor *</div><div> backend_init(struct wl_display *display, int *argc, char *argv[],</div><div>-<span class="" style="white-space:pre">  </span>     const char *config_file)</div>
<div>+<span class="" style="white-space:pre">   </span>     int config_fd)</div><div> {</div><div> <span class="" style="white-space:pre">      </span>int width = 1024, height = 640;</div><div> <span class="" style="white-space:pre">   </span>char *display_name = NULL;</div>
<div>@@ -208,5 +208,5 @@ backend_init(struct wl_display *display, int *argc, char *argv[],</div><div> <span class="" style="white-space:pre">               </span>      ARRAY_LENGTH(headless_options), argc, argv);</div><div> </div><div>
 <span class="" style="white-space:pre">      </span>return headless_compositor_create(display, width, height, display_name,</div><div>-<span class="" style="white-space:pre">                                   </span> argc, argv, config_file);</div><div>+<span class="" style="white-space:pre">                                        </span>  argc, argv, config_fd);</div>
<div> }</div><div>diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c</div><div>index 51ef475..0dae963 100644</div><div>--- a/src/compositor-rdp.c</div><div>+++ b/src/compositor-rdp.c</div><div>@@ -928,7 +928,7 @@ rdp_incoming_peer(freerdp_listener *instance, freerdp_peer *client)</div>
<div> static struct weston_compositor *</div><div> rdp_compositor_create(struct wl_display *display,</div><div> <span class="" style="white-space:pre">         </span>struct rdp_compositor_config *config,</div><div>-<span class="" style="white-space:pre">             </span>int *argc, char *argv[], const char *config_file)</div>
<div>+<span class="" style="white-space:pre">           </span>int *argc, char *argv[], int config_fd)</div><div> {</div><div> <span class="" style="white-space:pre">  </span>struct rdp_compositor *c;</div><div> <span class="" style="white-space:pre"> </span>char *fd_str;</div>
<div>@@ -941,7 +941,7 @@ rdp_compositor_create(struct wl_display *display,</div><div> <span class="" style="white-space:pre">       </span>memset(c, 0, sizeof *c);</div><div> </div><div> <span class="" style="white-space:pre">  </span>if (weston_compositor_init(&c->base, display, argc, argv,</div>
<div>-<span class="" style="white-space:pre">                           </span>   config_file) < 0)</div><div>+<span class="" style="white-space:pre">                           </span>   config_fd) < 0)</div><div> <span class="" style="white-space:pre">             </span>goto err_free;</div>
<div> </div><div> <span class="" style="white-space:pre">   </span>weston_seat_init(&c->main_seat, &c->base);</div><div>diff --git a/src/compositor-rpi.c b/src/compositor-rpi.c</div><div>index 8f3f2e9..3cb2b56 100644</div>
<div>--- a/src/compositor-rpi.c</div><div>+++ b/src/compositor-rpi.c</div><div>@@ -1441,7 +1441,7 @@ struct rpi_parameters {</div><div> </div><div> static struct weston_compositor *</div><div> rpi_compositor_create(struct wl_display *display, int *argc, char *argv[],</div>
<div>-<span class="" style="white-space:pre">           </span>      const char *config_file, struct rpi_parameters *param)</div><div>+<span class="" style="white-space:pre">              </span>      int config_fd, struct rpi_parameters *param)</div>
<div> {</div><div> <span class="" style="white-space:pre">  </span>struct rpi_compositor *compositor;</div><div> <span class="" style="white-space:pre">        </span>const char *seat = default_seat;</div><div>@@ -1464,7 +1464,7 @@ rpi_compositor_create(struct wl_display *display, int *argc, char *argv[],</div>
<div> <span class="" style="white-space:pre">           </span>return NULL;</div><div> </div><div> <span class="" style="white-space:pre">      </span>if (weston_compositor_init(&compositor->base, display, argc, argv,</div><div>
-<span class="" style="white-space:pre">                              </span>   config_file) < 0)</div><div>+<span class="" style="white-space:pre">                           </span>   config_fd) < 0)</div><div> <span class="" style="white-space:pre">             </span>goto out_free;</div>
<div> </div><div> <span class="" style="white-space:pre">   </span>compositor->udev = udev_new();</div><div>@@ -1554,7 +1554,7 @@ out_free:</div><div> </div><div> WL_EXPORT struct weston_compositor *</div><div> backend_init(struct wl_display *display, int *argc, char *argv[],</div>
<div>-<span class="" style="white-space:pre">   </span>     const char *config_file)</div><div>+<span class="" style="white-space:pre">     </span>     int config_fd)</div><div> {</div><div> <span class="" style="white-space:pre">      </span>struct rpi_parameters param = {</div>
<div> <span class="" style="white-space:pre">           </span>.tty = 0, /* default to current tty */</div><div>@@ -1571,5 +1571,5 @@ backend_init(struct wl_display *display, int *argc, char *argv[],</div><div> </div><div> <span class="" style="white-space:pre">      </span>parse_options(rpi_options, ARRAY_LENGTH(rpi_options), argc, argv);</div>
<div> </div><div>-<span class="" style="white-space:pre">   </span>return rpi_compositor_create(display, argc, argv, config_file, &param);</div><div>+<span class="" style="white-space:pre">       </span>return rpi_compositor_create(display, argc, argv, config_fd, &param);</div>
<div> }</div><div>diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c</div><div>index 44d234c..4112401 100644</div><div>--- a/src/compositor-wayland.c</div><div>+++ b/src/compositor-wayland.c</div><div>@@ -721,7 +721,7 @@ wayland_destroy(struct weston_compositor *ec)</div>
<div> static struct weston_compositor *</div><div> wayland_compositor_create(struct wl_display *display,</div><div> <span class="" style="white-space:pre">                     </span>  int width, int height, const char *display_name,</div>
<div>-<span class="" style="white-space:pre">                   </span>  int *argc, char *argv[], const char *config_file)</div><div>+<span class="" style="white-space:pre">                       </span>  int *argc, char *argv[], int config_fd)</div><div> {</div>
<div> <span class="" style="white-space:pre">   </span>struct wayland_compositor *c;</div><div> <span class="" style="white-space:pre">     </span>struct wl_event_loop *loop;</div><div>@@ -734,7 +734,7 @@ wayland_compositor_create(struct wl_display *display,</div>
<div> <span class="" style="white-space:pre">   </span>memset(c, 0, sizeof *c);</div><div> </div><div> <span class="" style="white-space:pre">  </span>if (weston_compositor_init(&c->base, display, argc, argv,</div><div>
-<span class="" style="white-space:pre">                              </span>   config_file) < 0)</div><div>+<span class="" style="white-space:pre">                           </span>   config_fd) < 0)</div><div> <span class="" style="white-space:pre">             </span>goto err_free;</div>
<div> </div><div> <span class="" style="white-space:pre">   </span>c->parent.wl_display = wl_display_connect(display_name);</div><div>@@ -797,7 +797,7 @@ err_free:</div><div> </div><div> WL_EXPORT struct weston_compositor *</div>
<div> backend_init(struct wl_display *display, int *argc, char *argv[],</div><div>-<span class="" style="white-space:pre">  </span>     const char *config_file)</div><div>+<span class="" style="white-space:pre">     </span>     int config_fd)</div>
<div> {</div><div> <span class="" style="white-space:pre">  </span>int width = 1024, height = 640;</div><div> <span class="" style="white-space:pre">   </span>char *display_name = NULL;</div><div>@@ -812,5 +812,5 @@ backend_init(struct wl_display *display, int *argc, char *argv[],</div>
<div> <span class="" style="white-space:pre">           </span>      ARRAY_LENGTH(wayland_options), argc, argv);</div><div> </div><div> <span class="" style="white-space:pre"> </span>return wayland_compositor_create(display, width, height, display_name,</div>
<div>-<span class="" style="white-space:pre">                                   </span> argc, argv, config_file);</div><div>+<span class="" style="white-space:pre">                                        </span> argc, argv, config_fd);</div><div> }</div><div>diff --git a/src/compositor-x11.c b/src/compositor-x11.c</div>
<div>index 21304a0..ea0d4b9 100644</div><div>--- a/src/compositor-x11.c</div><div>+++ b/src/compositor-x11.c</div><div>@@ -1383,7 +1383,7 @@ x11_compositor_create(struct wl_display *display,</div><div> <span class="" style="white-space:pre">               </span>      int fullscreen,</div>
<div> <span class="" style="white-space:pre">           </span>      int no_input,</div><div> <span class="" style="white-space:pre">               </span>      int use_pixman,</div><div>-<span class="" style="white-space:pre">             </span>      int *argc, char *argv[], const char *config_file)</div>
<div>+<span class="" style="white-space:pre">           </span>      int *argc, char *argv[], int config_fd)</div><div> {</div><div> <span class="" style="white-space:pre">    </span>struct x11_compositor *c;</div><div> <span class="" style="white-space:pre"> </span>struct x11_configured_output *o;</div>
<div>@@ -1401,7 +1401,7 @@ x11_compositor_create(struct wl_display *display,</div><div> <span class="" style="white-space:pre">     </span>memset(c, 0, sizeof *c);</div><div> </div><div> <span class="" style="white-space:pre">  </span>if (weston_compositor_init(&c->base, display, argc, argv,</div>
<div>-<span class="" style="white-space:pre">                           </span>   config_file) < 0)</div><div>+<span class="" style="white-space:pre">                           </span>   config_fd) < 0)</div><div> <span class="" style="white-space:pre">             </span>goto err_free;</div>
<div> </div><div> <span class="" style="white-space:pre">   </span>c->dpy = XOpenDisplay(NULL);</div><div>@@ -1574,7 +1574,7 @@ err_free:</div><div> </div><div> WL_EXPORT struct weston_compositor *</div><div> backend_init(struct wl_display *display, int *argc, char *argv[],</div>
<div>-<span class="" style="white-space:pre">   </span>     const char *config_file)</div><div>+<span class="" style="white-space:pre">     </span>     int config_fd)</div><div> {</div><div> <span class="" style="white-space:pre">      </span>int fullscreen = 0;</div>
<div> <span class="" style="white-space:pre">   </span>int no_input = 0;</div><div>@@ -1604,12 +1604,12 @@ backend_init(struct wl_display *display, int *argc, char *argv[],</div><div> <span class="" style="white-space:pre">         </span>ARRAY_LENGTH(x11_config_keys), output_section_done },</div>
<div> <span class="" style="white-space:pre">   </span>};</div><div> </div><div>-<span class="" style="white-space:pre">        </span>parse_config_file(config_file, config_section,</div><div>+<span class="" style="white-space:pre">    </span>parse_config_file(config_fd, config_section,</div>
<div> <span class="" style="white-space:pre">                           </span>ARRAY_LENGTH(config_section), NULL);</div><div> </div><div> <span class="" style="white-space:pre">      </span>return x11_compositor_create(display,</div><div> <span class="" style="white-space:pre">                             </span>     fullscreen,</div>
<div> <span class="" style="white-space:pre">                           </span>     no_input,</div><div> <span class="" style="white-space:pre">                            </span>     use_pixman,</div><div>-<span class="" style="white-space:pre">                          </span>     argc, argv, config_file);</div>
<div>+<span class="" style="white-space:pre">                           </span>     argc, argv, config_fd);</div><div> }</div><div>diff --git a/src/compositor.c b/src/compositor.c</div><div>index c1f90ca..fa5cb00 100644</div><div>--- a/src/compositor.c</div>
<div>+++ b/src/compositor.c</div><div>@@ -2685,7 +2685,7 @@ WL_EXPORT int</div><div> weston_compositor_init(struct weston_compositor *ec,</div><div> <span class="" style="white-space:pre">                </span>       struct wl_display *display,</div>
<div> <span class="" style="white-space:pre">           </span>       int *argc, char *argv[],</div><div>-<span class="" style="white-space:pre">           </span>       const char *config_file)</div><div>+<span class="" style="white-space:pre">           </span>       int config_fd)</div>
<div> {</div><div> <span class="" style="white-space:pre">  </span>struct wl_event_loop *loop;</div><div> <span class="" style="white-space:pre">       </span>struct xkb_rule_names xkb_names;</div><div>@@ -2702,7 +2702,9 @@ weston_compositor_init(struct weston_compositor *ec,</div>
<div> <span class="" style="white-space:pre">   </span>};</div><div> </div><div> <span class="" style="white-space:pre">        </span>memset(&xkb_names, 0, sizeof(xkb_names));</div><div>-<span class="" style="white-space:pre">     </span>parse_config_file(config_file, cs, ARRAY_LENGTH(cs), ec);</div>
<div>+</div><div>+<span class="" style="white-space:pre">   </span>ec->config_fd = config_fd;</div><div>+<span class="" style="white-space:pre">     </span>parse_config_file(config_fd, cs, ARRAY_LENGTH(cs), ec);</div><div> </div>
<div> <span class="" style="white-space:pre">   </span>ec->wl_display = display;</div><div> <span class="" style="white-space:pre">      </span>wl_signal_init(&ec->destroy_signal);</div><div>@@ -2788,6 +2790,8 @@ weston_compositor_shutdown(struct weston_compositor *ec)</div>
<div> <span class="" style="white-space:pre">   </span>weston_plane_release(&ec->primary_plane);</div><div> </div><div> <span class="" style="white-space:pre">  </span>wl_event_loop_destroy(ec->input_loop);</div><div>
+</div><div>+<span class="" style="white-space:pre">      </span>close(ec->config_fd);</div><div> }</div><div> </div><div> WL_EXPORT void</div><div>@@ -2944,12 +2948,12 @@ load_module(const char *name, const char *entrypoint)</div>
<div> </div><div> static int</div><div> load_modules(struct weston_compositor *ec, const char *modules,</div><div>-<span class="" style="white-space:pre">  </span>     int *argc, char *argv[], const char *config_file)</div>
<div>+<span class="" style="white-space:pre">   </span>     int *argc, char *argv[])</div><div> {</div><div> <span class="" style="white-space:pre">    </span>const char *p, *end;</div><div> <span class="" style="white-space:pre">      </span>char buffer[256];</div>
<div> <span class="" style="white-space:pre">   </span>int (*module_init)(struct weston_compositor *ec,</div><div>-<span class="" style="white-space:pre">                  </span>   int *argc, char *argv[], const char *config_file);</div>
<div>+<span class="" style="white-space:pre">                   </span>   int *argc, char *argv[]);</div><div> </div><div> <span class="" style="white-space:pre">      </span>if (modules == NULL)</div><div> <span class="" style="white-space:pre">              </span>return 0;</div>
<div>@@ -2960,7 +2964,7 @@ load_modules(struct weston_compositor *ec, const char *modules,</div><div> <span class="" style="white-space:pre">               </span>snprintf(buffer, sizeof buffer, "%.*s", (int) (end - p), p);</div>
<div> <span class="" style="white-space:pre">           </span>module_init = load_module(buffer, "module_init");</div><div> <span class="" style="white-space:pre">               </span>if (module_init)</div><div>-<span class="" style="white-space:pre">                  </span>module_init(ec, argc, argv, config_file);</div>
<div>+<span class="" style="white-space:pre">                   </span>module_init(ec, argc, argv);</div><div> <span class="" style="white-space:pre">              </span>p = end;</div><div> <span class="" style="white-space:pre">          </span>while (*p == ',')</div>
<div> <span class="" style="white-space:pre">                   </span>p++;</div><div>@@ -3086,8 +3090,8 @@ int main(int argc, char *argv[])</div><div> <span class="" style="white-space:pre"> </span>struct wl_event_loop *loop;</div><div>
 <span class="" style="white-space:pre">      </span>struct weston_compositor</div><div> <span class="" style="white-space:pre">          </span>*(*backend_init)(struct wl_display *display,</div><div>-<span class="" style="white-space:pre">                              </span> int *argc, char *argv[], const char *config_file);</div>
<div>-<span class="" style="white-space:pre">   </span>int i;</div><div>+<span class="" style="white-space:pre">                            </span> int *argc, char *argv[], int config_fd);</div><div>+<span class="" style="white-space:pre"> </span>int i, config_fd;</div>
<div> <span class="" style="white-space:pre">   </span>char *backend = NULL;</div><div> <span class="" style="white-space:pre">     </span>const char *modules = "desktop-shell.so", *option_modules = NULL;</div><div> <span class="" style="white-space:pre">       </span>char *log = NULL;</div>
<div>@@ -3095,7 +3099,6 @@ int main(int argc, char *argv[])</div><div> <span class="" style="white-space:pre">      </span>int32_t help = 0;</div><div> <span class="" style="white-space:pre"> </span>char *socket_name = "wayland-0";</div>
<div> <span class="" style="white-space:pre">   </span>int32_t version = 0;</div><div>-<span class="" style="white-space:pre">      </span>char *config_file;</div><div> </div><div> <span class="" style="white-space:pre">        </span>const struct config_key core_config_keys[] = {</div>
<div> <span class="" style="white-space:pre">           </span>{ "modules", CONFIG_KEY_STRING, &modules },</div><div>@@ -3161,14 +3164,14 @@ int main(int argc, char *argv[])</div><div> <span class="" style="white-space:pre">                  </span>backend = WESTON_NATIVE_BACKEND;</div>
<div> <span class="" style="white-space:pre">   </span>}</div><div> </div><div>-<span class="" style="white-space:pre"> </span>config_file = config_file_path("weston.ini");</div><div>-<span class="" style="white-space:pre">   </span>parse_config_file(config_file, cs, ARRAY_LENGTH(cs), NULL);</div>
<div>+<span class="" style="white-space:pre">   </span>config_fd = open_config_file("weston.ini");</div><div>+<span class="" style="white-space:pre">     </span>parse_config_file(config_fd, cs, ARRAY_LENGTH(cs), NULL);</div>
<div> </div><div> <span class="" style="white-space:pre">   </span>backend_init = load_module(backend, "backend_init");</div><div> <span class="" style="white-space:pre">    </span>if (!backend_init)</div><div> <span class="" style="white-space:pre">                </span>exit(EXIT_FAILURE);</div>
<div> </div><div>-<span class="" style="white-space:pre">   </span>ec = backend_init(display, &argc, argv, config_file);</div><div>+<span class="" style="white-space:pre"> </span>ec = backend_init(display, &argc, argv, config_fd);</div>
<div> <span class="" style="white-space:pre">   </span>if (ec == NULL) {</div><div> <span class="" style="white-space:pre">         </span>weston_log("fatal: failed to create compositor\n");</div><div> <span class="" style="white-space:pre">             </span>exit(EXIT_FAILURE);</div>
<div>@@ -3181,13 +3184,11 @@ int main(int argc, char *argv[])</div><div> </div><div> <span class="" style="white-space:pre">    </span>setenv("WAYLAND_DISPLAY", socket_name, 1);</div><div> </div><div>-<span class="" style="white-space:pre">      </span>if (load_modules(ec, modules, &argc, argv, config_file) < 0)</div>
<div>+<span class="" style="white-space:pre">   </span>if (load_modules(ec, modules, &argc, argv) < 0)</div><div> <span class="" style="white-space:pre">            </span>goto out;</div><div>-<span class="" style="white-space:pre"> </span>if (load_modules(ec, option_modules, &argc, argv, config_file) < 0)</div>
<div>+<span class="" style="white-space:pre">   </span>if (load_modules(ec, option_modules, &argc, argv) < 0)</div><div> <span class="" style="white-space:pre">             </span>goto out;</div><div> </div><div>-<span class="" style="white-space:pre"> </span>free(config_file);</div>
<div>-</div><div> <span class="" style="white-space:pre">   </span>for (i = 1; i < argc; i++)</div><div> <span class="" style="white-space:pre">             </span>weston_log("fatal: unhandled option: %s\n", argv[i]);</div>
<div> <span class="" style="white-space:pre">   </span>if (argc > 1) {</div><div>diff --git a/src/compositor.h b/src/compositor.h</div><div>index d7aa005..44d217e 100644</div><div>--- a/src/compositor.h</div><div>+++ b/src/compositor.h</div>
<div>@@ -546,6 +546,8 @@ struct weston_compositor {</div><div> <span class="" style="white-space:pre">      </span>struct xkb_rule_names xkb_names;</div><div> <span class="" style="white-space:pre">  </span>struct xkb_context *xkb_context;</div>
<div> <span class="" style="white-space:pre">   </span>struct weston_xkb_info xkb_info;</div><div>+</div><div>+<span class="" style="white-space:pre">  </span>int config_fd;</div><div> };</div><div> </div><div> struct weston_buffer_reference {</div>
<div>@@ -988,7 +990,7 @@ weston_compositor_get_time(void);</div><div> </div><div> int</div><div> weston_compositor_init(struct weston_compositor *ec, struct wl_display *display,</div><div>-<span class="" style="white-space:pre">            </span>       int *argc, char *argv[], const char *config_file);</div>
<div>+<span class="" style="white-space:pre">           </span>       int *argc, char *argv[], int config_fd);</div><div> void</div><div> weston_compositor_shutdown(struct weston_compositor *ec);</div><div> void</div><div>@@ -1126,11 +1128,11 @@ noop_renderer_init(struct weston_compositor *ec);</div>
<div> </div><div> struct weston_compositor *</div><div> backend_init(struct wl_display *display, int *argc, char *argv[],</div><div>-<span class="" style="white-space:pre">        </span>     const char *config_file);</div><div>
+<span class="" style="white-space:pre">      </span>     int config_fd);</div><div> </div><div> int</div><div> module_init(struct weston_compositor *compositor,</div><div>-<span class="" style="white-space:pre">  </span>    int *argc, char *argv[], const char *config_file);</div>
<div>+<span class="" style="white-space:pre">   </span>    int *argc, char *argv[]);</div><div> </div><div> void</div><div> weston_transformed_coord(int width, int height,</div><div>diff --git a/src/shell.c b/src/shell.c</div>
<div>index 5da649d..d5b5fcf 100644</div><div>--- a/src/shell.c</div><div>+++ b/src/shell.c</div><div>@@ -375,7 +375,7 @@ get_animation_type(char *animation)</div><div> }</div><div> </div><div> static void</div><div>-shell_configuration(struct desktop_shell *shell, const char *config_file)</div>
<div>+shell_configuration(struct desktop_shell *shell, int config_fd)</div><div> {</div><div> <span class="" style="white-space:pre">   </span>char *path = NULL;</div><div> <span class="" style="white-space:pre">        </span>int duration = 60;</div>
<div>@@ -400,7 +400,7 @@ shell_configuration(struct desktop_shell *shell, const char *config_file)</div><div> <span class="" style="white-space:pre">               </span>{ "screensaver", saver_keys, ARRAY_LENGTH(saver_keys), NULL },</div>
<div> <span class="" style="white-space:pre">   </span>};</div><div> </div><div>-<span class="" style="white-space:pre">        </span>parse_config_file(config_file, cs, ARRAY_LENGTH(cs), shell);</div><div>+<span class="" style="white-space:pre">      </span>parse_config_file(config_fd, cs, ARRAY_LENGTH(cs), shell);</div>
<div> </div><div> <span class="" style="white-space:pre">   </span>shell->screensaver.path = path;</div><div> <span class="" style="white-space:pre">        </span>shell->screensaver.duration = duration * 1000;</div><div>@@ -4286,7 +4286,7 @@ shell_add_bindings(struct weston_compositor *ec, struct desktop_shell *shell)</div>
<div> </div><div> WL_EXPORT int</div><div> module_init(struct weston_compositor *ec,</div><div>-<span class="" style="white-space:pre">     </span>    int *argc, char *argv[], const char *config_file)</div><div>+<span class="" style="white-space:pre">     </span>    int *argc, char *argv[])</div>
<div> {</div><div> <span class="" style="white-space:pre">  </span>struct weston_seat *seat;</div><div> <span class="" style="white-space:pre"> </span>struct desktop_shell *shell;</div><div>@@ -4333,7 +4333,7 @@ module_init(struct weston_compositor *ec,</div>
<div> <span class="" style="white-space:pre">   </span>wl_array_init(&shell->workspaces.array);</div><div> <span class="" style="white-space:pre">   </span>wl_list_init(&shell->workspaces.client_list);</div><div>
 </div><div>-<span class="" style="white-space:pre">      </span>shell_configuration(shell, config_file);</div><div>+<span class="" style="white-space:pre">  </span>shell_configuration(shell, ec->config_fd);</div><div> </div>
<div> <span class="" style="white-space:pre">   </span>for (i = 0; i < shell->workspaces.num; i++) {</div><div> <span class="" style="white-space:pre">               </span>pws = wl_array_add(&shell->workspaces.array, sizeof *pws);</div>
<div>diff --git a/src/tablet-shell.c b/src/tablet-shell.c</div><div>index 7c75c1b..cae8acf 100644</div><div>--- a/src/tablet-shell.c</div><div>+++ b/src/tablet-shell.c</div><div>@@ -527,7 +527,7 @@ tablet_shell_destroy(struct wl_listener *listener, void *data)</div>
<div> </div><div> WL_EXPORT int</div><div> module_init(struct weston_compositor *compositor,</div><div>-<span class="" style="white-space:pre">     </span>    int *argc, char *argv[], const char *config_file)</div><div>+<span class="" style="white-space:pre">     </span>    int *argc, char *argv[])</div>
<div> {</div><div> <span class="" style="white-space:pre">  </span>struct tablet_shell *shell;</div><div> <span class="" style="white-space:pre">       </span>struct wl_event_loop *loop;</div><div>diff --git a/src/text-backend.c b/src/text-backend.c</div>
<div>index 92efd9f..da62fd7 100644</div><div>--- a/src/text-backend.c</div><div>+++ b/src/text-backend.c</div><div>@@ -23,6 +23,7 @@</div><div> </div><div> #include <stdlib.h></div><div> #include <string.h></div>
<div>+#include <unistd.h></div><div> </div><div> #include "compositor.h"</div><div> #include "text-server-protocol.h"</div><div>@@ -885,7 +886,7 @@ handle_seat_created(struct wl_listener *listener,</div>
<div> static void</div><div> text_backend_configuration(struct text_backend *text_backend)</div><div> {</div><div>-<span class="" style="white-space:pre">  </span>char *config_file;</div><div>+<span class="" style="white-space:pre">        </span>int config_fd;</div>
<div> <span class="" style="white-space:pre">   </span>char *path = NULL;</div><div> </div><div> <span class="" style="white-space:pre">        </span>struct config_key input_method_keys[] = {</div><div>@@ -896,9 +897,9 @@ text_backend_configuration(struct text_backend *text_backend)</div>
<div> <span class="" style="white-space:pre">           </span>{ "input-method", input_method_keys, ARRAY_LENGTH(input_method_keys), NULL }</div><div> <span class="" style="white-space:pre">    </span>};</div><div> </div><div>
-<span class="" style="white-space:pre">      </span>config_file = config_file_path("weston.ini");</div><div>-<span class="" style="white-space:pre">   </span>parse_config_file(config_file, cs, ARRAY_LENGTH(cs), text_backend);</div>
<div>-<span class="" style="white-space:pre">   </span>free(config_file);</div><div>+<span class="" style="white-space:pre">        </span>config_fd = open_config_file("weston.ini");</div><div>+<span class="" style="white-space:pre">     </span>parse_config_file(config_fd, cs, ARRAY_LENGTH(cs), text_backend);</div>
<div>+        close(config_fd);</div><div> </div><div> <span class="" style="white-space:pre">  </span>if (path)</div><div> <span class="" style="white-space:pre">         </span>text_backend->input_method.path = path;</div><div>
diff --git a/src/xwayland/launcher.c b/src/xwayland/launcher.c</div><div>index e50177e..664cf6c 100644</div><div>--- a/src/xwayland/launcher.c</div><div>+++ b/src/xwayland/launcher.c</div><div>@@ -316,7 +316,7 @@ weston_xserver_destroy(struct wl_listener *l, void *data)</div>
<div> </div><div> WL_EXPORT int</div><div> module_init(struct weston_compositor *compositor,</div><div>-<span class="" style="white-space:pre">     </span>    int *argc, char *argv[], const char *config_file)</div><div>+<span class="" style="white-space:pre">     </span>    int *argc, char *argv[])</div>
<div> </div><div> {</div><div> <span class="" style="white-space:pre">  </span>struct wl_display *display = compositor->wl_display;</div><div>diff --git a/tests/weston-test.c b/tests/weston-test.c</div><div>index 612841b..b629c86 100644</div>
<div>--- a/tests/weston-test.c</div><div>+++ b/tests/weston-test.c</div><div>@@ -225,7 +225,7 @@ idle_launch_client(void *data)</div><div> </div><div> WL_EXPORT int</div><div> module_init(struct weston_compositor *ec,</div>
<div>-<span class="" style="white-space:pre">   </span>    int *argc, char *argv[], const char *config_file)</div><div>+<span class="" style="white-space:pre">     </span>    int *argc, char *argv[])</div><div> {</div><div> <span class="" style="white-space:pre">     </span>struct weston_test *test;</div>
<div> <span class="" style="white-space:pre">   </span>struct wl_event_loop *loop;</div><div>-- </div><div>1.7.10.4</div><div><br></div></div><div style><br></div></div>