From ce6fb9175c104113396949f50364b0a49d69c9c6 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 14 Feb 2014 13:52:59 +0100 Subject: options: make --no-config block all auto-loaded configuration files Until now, the --no-config was explicitly checked in multiple places to suppress loading of config files. Add such a check to the config path code itself, and refuse to resolve _any_ configuration file locations if the option is set. osc.lua needs a small fixup, because it didn't handle the situation when no path was returned. There may some of such cases in the C code too, but I didn't find any on a quick look. --- DOCS/man/en/options.rst | 6 ++---- options/path.c | 11 +++++++++++ player/lua/osc.lua | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst index ce3b730387..da67544d3f 100644 --- a/DOCS/man/en/options.rst +++ b/DOCS/man/en/options.rst @@ -1412,10 +1412,8 @@ OPTIONS ``--no-config`` Do not load default configuration files. This prevents loading of ``~/.mpv/config`` and ``~/.mpv/input.conf``, as well as loading the - same files from system wide configuration directories. - - Loading of some configuration files is not affected by this option, such - as configuration files for DVB code and fontconfig. + same files from system wide configuration directories. Other configuration + files are blocked as well, such as resume playback files. .. note:: diff --git a/options/path.c b/options/path.c index 94b599803e..5fb20010cf 100644 --- a/options/path.c +++ b/options/path.c @@ -32,9 +32,12 @@ #include #include #include + #include "config.h" + #include "common/global.h" #include "common/msg.h" +#include "options/options.h" #include "options/path.h" #include "talloc.h" #include "osdep/io.h" @@ -53,6 +56,10 @@ static const lookup_fun config_lookup_functions[] = { char *mp_find_config_file(void *talloc_ctx, struct mpv_global *global, const char *filename) { + struct MPOpts *opts = global->opts; + if (!opts->load_config) + return NULL; + for (int i = 0; config_lookup_functions[i] != NULL; i++) { char *path = config_lookup_functions[i](talloc_ctx, global, filename); if (!path) continue; @@ -68,6 +75,10 @@ char *mp_find_config_file(void *talloc_ctx, struct mpv_global *global, char *mp_find_user_config_file(void *talloc_ctx, struct mpv_global *global, const char *filename) { + struct MPOpts *opts = global->opts; + if (!opts->load_config) + return NULL; + char *homedir = getenv("MPV_HOME"); char *configdir = NULL; char *result = NULL; diff --git a/player/lua/osc.lua b/player/lua/osc.lua index 5bf150274d..033f2c0d7e 100644 --- a/player/lua/osc.lua +++ b/player/lua/osc.lua @@ -121,7 +121,7 @@ function read_config(options, identifier) local conffilename = "plugin_" .. identifier .. ".conf" local conffile = mp.find_config_file(conffilename) - local f = io.open(conffile,"r") + local f = conffile and io.open(conffile,"r") if f == nil then -- config not found else -- cgit v1.2.3