aboutsummaryrefslogtreecommitdiffstats
path: root/src/permission.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-10-28 05:14:55 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-10-28 05:14:55 +0000
commit58dbe4bb5d974c34335d6906a9ce930f07cd1db4 (patch)
tree9a6aee08b21100cb74e809f0620d81466f6067df /src/permission.c
parent8f40569aeeafe4a36e3d719c1df97de42606ea76 (diff)
downloadmpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.tar.gz
mpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.tar.xz
mpd-58dbe4bb5d974c34335d6906a9ce930f07cd1db4.zip
merge shank-rewrite-config changes
git-svn-id: https://svn.musicpd.org/mpd/trunk@2375 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/permission.c')
-rw-r--r--src/permission.c57
1 files changed, 27 insertions, 30 deletions
diff --git a/src/permission.c b/src/permission.c
index e9e74ad7a..795fe577d 100644
--- a/src/permission.c
+++ b/src/permission.c
@@ -69,56 +69,53 @@ unsigned int parsePermissions(char * string) {
}
void initPermissions() {
- char * passwordSets;
- char * nextSet;
char * temp;
- char * cp1;
char * cp2;
char * password;
unsigned int * permission;
+ ConfigParam * param;
permission_passwords = makeList(free);
permission_default = PERMISSION_READ | PERMISSION_ADD |
PERMISSION_CONTROL | PERMISSION_ADMIN;
- if(getConf()[CONF_DEFAULT_PERMISSIONS]) {
- permission_default = parsePermissions(
- getConf()[CONF_DEFAULT_PERMISSIONS]);
- }
-
- if(!getConf()[CONF_PASSWORD]) return;
-
- if(!getConf()[CONF_DEFAULT_PERMISSIONS]) permission_default = 0;
+ param = getNextConfigParam(CONF_PASSWORD, NULL);
- passwordSets = strdup(getConf()[CONF_PASSWORD]);
+ if(param) {
+ permission_default = 0;
- nextSet = strtok_r(passwordSets,CONF_CAT_CHAR,&cp1);
- while(nextSet && strlen(nextSet)) {
- if(!strstr(nextSet,PERMISSION_PASSWORD_CHAR)) {
- ERROR("\"%s\" not found in password string \"%s\"\n",
+ do {
+ if(!strstr(param->value, PERMISSION_PASSWORD_CHAR)) {
+ ERROR("\"%s\" not found in password string "
+ "\"%s\", line %i\n",
PERMISSION_PASSWORD_CHAR,
- nextSet);
- exit(EXIT_FAILURE);
- }
+ param->value,
+ param->line);
+ exit(EXIT_FAILURE);
+ }
- if(!(temp = strtok_r(nextSet,PERMISSION_PASSWORD_CHAR,&cp2))) {
- ERROR("something weird just happend in permission.c\n");
- exit(EXIT_FAILURE);
- }
- password = temp;
+ if(!(temp = strtok_r(param->value,
+ PERMISSION_PASSWORD_CHAR,&cp2))) {
+ ERROR("something weird just happend in permission.c\n");
+ exit(EXIT_FAILURE);
+ }
- permission = malloc(sizeof(unsigned int));
- *permission = parsePermissions(strtok_r(NULL,"",&cp2));
+
+ password = temp;
- insertInList(permission_passwords,password,permission);
+ permission = malloc(sizeof(unsigned int));
+ *permission = parsePermissions(strtok_r(NULL,"",&cp2));
- nextSet = strtok_r(NULL,CONF_CAT_CHAR,&cp1);
+ insertInList(permission_passwords,password,permission);
+ } while((param = getNextConfigParam(CONF_PASSWORD, param)));
}
- sortList(permission_passwords);
+ param = getConfigParam(CONF_DEFAULT_PERMS);
- free(passwordSets);
+ if(param) permission_default = parsePermissions(param->value);
+
+ sortList(permission_passwords);
}
int getPermissionFromPassword(char * password, unsigned int * permission) {