src/server/daemon/config.c

changeset 54
3a1d5a52adfc
parent 51
b28cf69f42e8
child 60
feb2f1e115c6
equal deleted inserted replaced
53:5ec9abba1027 54:3a1d5a52adfc
687 file->last_modified = s.st_mtim.tv_sec; 687 file->last_modified = s.st_mtim.tv_sec;
688 return 0; 688 return 0;
689 } 689 }
690 690
691 ACLList* acl_config_convert(ServerConfiguration *cfg, ACLConfig *acl) { 691 ACLList* acl_config_convert(ServerConfiguration *cfg, ACLConfig *acl) {
692 ACLList *acllist = malloc(sizeof(ACLList)); 692 WSAcl *acllist = malloc(sizeof(WSAcl));
693 acllist->authdb = NULL; 693 acllist->acl.check = (acl_check_f)wsacl_check;
694 acllist->authprompt = NULL; 694 acllist->acl.authdb = NULL;
695 acllist->acl.authprompt = NULL;
696 acllist->acl.isextern = 0;
695 acllist->ace = NULL; 697 acllist->ace = NULL;
696 acllist->ece = NULL; 698 acllist->ece = NULL;
697 699
698 size_t s = ucx_list_size(acl->entries); 700 size_t s = ucx_list_size(acl->entries);
699 ACLEntry **aces = calloc(s, sizeof(ACLEntry*)); 701 WSAce **aces = calloc(s, sizeof(WSAce*));
700 ACLEntry **eces = calloc(s, sizeof(ACLEntry*)); 702 WSAce **eces = calloc(s, sizeof(WSAce*));
701 int ai = 0; 703 int ai = 0;
702 int ei = 0; 704 int ei = 0;
703 705
704 // convert entries 706 // convert entries
705 UCX_FOREACH(UcxList*, acl->entries, elm) { 707 UCX_FOREACH(UcxList*, acl->entries, elm) {
706 ACEConfig *acecfg = elm->data; 708 ACEConfig *acecfg = elm->data;
707 709
708 // copy data 710 // copy data
709 ACLEntry *ace = malloc(sizeof(ACLEntry)); 711 WSAce *ace = malloc(sizeof(WSAce));
710 ace->access_mask = acecfg->access_mask; 712 ace->access_mask = acecfg->access_mask;
711 ace->flags = acecfg->flags; 713 ace->flags = acecfg->flags;
712 ace->type = acecfg->type; 714 ace->type = acecfg->type;
713 ace->who = sstrdup(acecfg->who).ptr; 715 ace->who = sstrdup(acecfg->who).ptr;
714 716
722 } 724 }
723 } 725 }
724 726
725 // create new entrie arrays with perfect fitting size 727 // create new entrie arrays with perfect fitting size
726 if(ai > 0) { 728 if(ai > 0) {
727 acllist->ace = calloc(ai, sizeof(ACLEntry*)); 729 acllist->ace = calloc(ai, sizeof(WSAce*));
728 } 730 }
729 if(ei > 0) { 731 if(ei > 0) {
730 acllist->ece = calloc(ei, sizeof(ACLEntry*)); 732 acllist->ece = calloc(ei, sizeof(WSAce*));
731 } 733 }
732 memcpy(acllist->ace, aces, ai*sizeof(ACLEntry*)); 734 memcpy(acllist->ace, aces, ai*sizeof(WSAce*));
733 memcpy(acllist->ece, eces, ei*sizeof(ACLEntry*)); 735 memcpy(acllist->ece, eces, ei*sizeof(WSAce*));
734 acllist->acenum = ai; 736 acllist->acenum = ai;
735 acllist->ecenum = ei; 737 acllist->ecenum = ei;
736 738
737 free(aces); 739 free(aces);
738 free(eces); 740 free(eces);
742 sstr_t authdb_str = cfg_param_get(acl->authparam, sstr("authdb")); 744 sstr_t authdb_str = cfg_param_get(acl->authparam, sstr("authdb"));
743 sstr_t prompt_str = cfg_param_get(acl->authparam, sstr("prompt")); 745 sstr_t prompt_str = cfg_param_get(acl->authparam, sstr("prompt"));
744 746
745 if(authdb_str.ptr) { 747 if(authdb_str.ptr) {
746 AuthDB *authdb = ucx_map_sstr_get(cfg->authdbs, authdb_str); 748 AuthDB *authdb = ucx_map_sstr_get(cfg->authdbs, authdb_str);
747 acllist->authdb = authdb; 749 acllist->acl.authdb = authdb;
748 if(authdb && prompt_str.ptr) { 750 if(authdb && prompt_str.ptr) {
749 acllist->authprompt = sstrdup(prompt_str).ptr; 751 acllist->acl.authprompt = sstrdup(prompt_str).ptr;
750 } 752 }
751 } 753 }
752 } 754 }
753 755
754 return acllist; 756 return &acllist->acl;
755 } 757 }

mercurial