summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
8ab2aa9)
Exactly analogous to the existing `configfile' variable.
/** @brief Save current login details */
static void login_save_config(void) {
/** @brief Save current login details */
static void login_save_config(void) {
- char *path = config_userconf(), *tmp;
- byte_xasprintf(&tmp, "%s.tmp", path);
+ byte_xasprintf(&tmp, "%s.tmp", userconfigfile);
/* Make sure the directory exists; don't care if it already exists. */
mkdir(d_dirname(tmp), 02700);
/* Write out the file */
/* Make sure the directory exists; don't care if it already exists. */
mkdir(d_dirname(tmp), 02700);
/* Write out the file */
goto done;
}
/* Rename into place */
goto done;
}
/* Rename into place */
- if(rename(tmp, path) < 0) {
+ if(rename(tmp, userconfigfile) < 0) {
fpopup_msg(GTK_MESSAGE_ERROR, "error renaming %s: %s",
tmp, strerror(errno));
goto done;
fpopup_msg(GTK_MESSAGE_ERROR, "error renaming %s: %s",
tmp, strerror(errno));
goto done;
+/** @brief Path to user's config file
+ *
+ * set_configfile() sets the default if it is null.
+ */
+char *userconfigfile;
+
/** @brief Read user configuration
*
* If clear, the user-specific configuration is not read.
/** @brief Read user configuration
*
* If clear, the user-specific configuration is not read.
/** @brief Set the default configuration file */
static void set_configfile(void) {
/** @brief Set the default configuration file */
static void set_configfile(void) {
#if !_WIN32
if(!configfile) {
configfile = getenv("DISORDER_CONFIG");
#if !_WIN32
if(!configfile) {
configfile = getenv("DISORDER_CONFIG");
byte_xasprintf(&configfile, "%s/config", pkgconfdir);
}
#endif
byte_xasprintf(&configfile, "%s/config", pkgconfdir);
}
#endif
+ if(!userconfigfile && config_per_user) {
+ if((t = getenv("DISORDER_USERCONFIG"))) userconfigfile = xstrdup(t);
+ else if(!(userconfigfile = profile_filename("passwd")))
+ disorder_fatal(0, "failed to find user profile directory");
+ }
}
/** @brief Free a configuration object
}
/** @brief Free a configuration object
xfree(privconf);
#endif
/* if we have a password file, read it */
xfree(privconf);
#endif
/* if we have a password file, read it */
- if((privconf = config_userconf())
- && access(privconf, F_OK) == 0
- && config_include(c, privconf))
+ if(access(userconfigfile, F_OK) == 0
+ && config_include(c, userconfigfile))
}
/* install default namepart and transform settings */
config_postdefaults(c, server);
}
/* install default namepart and transform settings */
config_postdefaults(c, server);
+ if((s = getenv("DISORDER_PRIVCONFIG"))) return xstrdup(s);
set_configfile();
byte_xasprintf(&s, "%s.private", configfile);
return s;
#endif
}
set_configfile();
byte_xasprintf(&s, "%s.private", configfile);
return s;
#endif
}
-/** @brief Return the path to user's personal configuration file */
-char *config_userconf(void) {
- char *t;
- if((t = getenv("DISORDER_USERCONFIG"))) return xstrdup(t);
- return profile_filename("passwd");
-}
-
#if !_WIN32
/** @brief Return the path to user-specific system configuration */
char *config_usersysconf(const struct passwd *pw) {
#if !_WIN32
/** @brief Return the path to user-specific system configuration */
char *config_usersysconf(const struct passwd *pw) {
-char *config_userconf(void);
-/* get the user's own private conffile */
-
char *config_usersysconf(const struct passwd *pw );
/* get the user's conffile in /etc */
char *config_usersysconf(const struct passwd *pw );
/* get the user's conffile in /etc */
void config_free(struct config *c);
void config_free(struct config *c);
-extern char *configfile;
+extern char *configfile, *userconfigfile;
extern int config_per_user;
extern const struct uaudio *const *config_uaudio_apis;
extern int config_per_user;
extern const struct uaudio *const *config_uaudio_apis;