aboutsummaryrefslogtreecommitdiffstats
path: root/src/conf.c
diff options
context:
space:
mode:
authorJ. Alexander Treuman <jat@spatialrift.net>2007-06-13 15:27:09 +0000
committerJ. Alexander Treuman <jat@spatialrift.net>2007-06-13 15:27:09 +0000
commitc734c13b5c5c225c2119f6245963d20e207feef0 (patch)
treeb995c8d5ea6631ec289e10b4c8ac9020bd12d219 /src/conf.c
parentb496239e762cc354d9f5a9272893d35615e60144 (diff)
downloadmpd-c734c13b5c5c225c2119f6245963d20e207feef0.tar.gz
mpd-c734c13b5c5c225c2119f6245963d20e207feef0.tar.xz
mpd-c734c13b5c5c225c2119f6245963d20e207feef0.zip
Adding parsePath and making parseConfigFilePath use it.
git-svn-id: https://svn.musicpd.org/mpd/trunk@6622 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/conf.c53
1 files changed, 5 insertions, 48 deletions
diff --git a/src/conf.c b/src/conf.c
index 1addd7e82..d76d4ad9b 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -397,55 +397,12 @@ ConfigParam *parseConfigFilePath(char *name, int force)
if (!param)
return NULL;
- path = param->value;
+ path = parsePath(param->value);
+ if (!path)
+ FATAL("error parsing \"%s\" at line %i\n", name, param->line);
- if (path[0] != '/' && path[0] != '~') {
- FATAL("\"%s\" is not an absolute path at line %i\n",
- param->value, param->line);
- }
- /* Parse ~ in path */
- else if (path[0] == '~') {
- struct passwd *pwd = NULL;
- char *newPath;
- int pos = 1;
- if (path[1] == '/' || path[1] == '\0') {
- ConfigParam *userParam = getConfigParam(CONF_USER);
-
- if (userParam) {
- pwd = getpwnam(userParam->value);
- if (!pwd) {
- FATAL("no such user %s at line %i\n",
- userParam->value,
- userParam->line);
- }
- } else {
- uid_t uid = geteuid();
- if ((pwd = getpwuid(uid)) == NULL) {
- FATAL("problems getting passwd entry "
- "for current user\n");
- }
- }
- } else {
- int foundSlash = 0;
- char *ch = path + 1;
- for (; *ch != '\0' && *ch != '/'; ch++) ;
- if (*ch == '/')
- foundSlash = 1;
- *ch = '\0';
- pos += ch - path - 1;
- if ((pwd = getpwnam(path + 1)) == NULL) {
- FATAL("user \"%s\" not found at line %i\n",
- path + 1, param->line);
- }
- if (foundSlash)
- *ch = '/';
- }
- newPath = xmalloc(strlen(pwd->pw_dir) + strlen(path + pos) + 1);
- strcpy(newPath, pwd->pw_dir);
- strcat(newPath, path + pos);
- free(param->value);
- param->value = newPath;
- }
+ free(param->value);
+ param->value = path;
return param;
}