aboutsummaryrefslogtreecommitdiffstats
path: root/src/permission.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-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) {