471 free(binddn.ptr); |
471 free(binddn.ptr); |
472 free(basepw.ptr); |
472 free(basepw.ptr); |
473 free(name.ptr); |
473 free(name.ptr); |
474 */ |
474 */ |
475 |
475 |
|
476 } else if(!sstrcmp(type, sstr("keyfile"))) { |
|
477 // we only need the file parameter |
|
478 sstr_t file = cfg_directivelist_get_str( |
|
479 obj->directives, |
|
480 sstr("File")); |
|
481 if(file.length == 0) { |
|
482 log_ereport( |
|
483 LOG_MISCONFIG, |
|
484 "missing File parameter for keyfile authdb"); |
|
485 return 1; |
|
486 } |
|
487 |
|
488 // load keyfile |
|
489 ConfigFile *f = cfgmgr_get_file(file); |
|
490 if(f == NULL) { |
|
491 f = malloc(sizeof(ConfigFile)); |
|
492 f->data = NULL; |
|
493 f->file = sstrdup(file); |
|
494 f->reload = keyfile_reload; |
|
495 //f->reload(f, cfg); |
|
496 if(cfgmgr_reload_file(f, cfg, NULL)) { |
|
497 free(f->file.ptr); |
|
498 free(f); |
|
499 return -1; |
|
500 } |
|
501 cfgmgr_attach_file(f); |
|
502 } |
|
503 |
|
504 // add keyfile authdb |
|
505 Keyfile *keyfile = f->data; |
|
506 keyfile->authdb.name = sstrdup(name).ptr; |
|
507 printf("authdb: %d\n", keyfile); |
|
508 ucx_map_sstr_put(cfg->authdbs, name, keyfile); |
476 } |
509 } |
477 |
510 |
478 return 0; |
511 return 0; |
479 } |
512 } |
480 |
513 |
831 } |
864 } |
832 } |
865 } |
833 |
866 |
834 return &acllist->acl; |
867 return &acllist->acl; |
835 } |
868 } |
|
869 |
|
870 int keyfile_reload(ConfigFile *file, ServerConfiguration *cfg) { |
|
871 KeyfileConfig *conf = load_keyfile_config(file->file.ptr); |
|
872 if(!conf) { |
|
873 return 1; |
|
874 } |
|
875 |
|
876 Keyfile *keyfile = keyfile_new(); |
|
877 |
|
878 UCX_FOREACH(UcxList*, conf->users, elm) { |
|
879 KeyfileEntry *user = elm->data; |
|
880 keyfile_add_user( |
|
881 keyfile, |
|
882 user->name, |
|
883 user->hashtype, |
|
884 user->hashdata, |
|
885 user->groups, |
|
886 user->numgroups); |
|
887 } |
|
888 |
|
889 free_keyfile_config(conf); |
|
890 |
|
891 Keyfile *old_data = file->data; |
|
892 file->data = keyfile; |
|
893 if(old_data) { |
|
894 keyfile_unref(old_data); |
|
895 } |
|
896 |
|
897 return 0; |
|
898 } |