X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=client_common.c;h=a7eee85d3cc0d5cf94073ca39c6223a7c4a639d4;hp=0d87a8d285315288a5e2238a7df69d1031a85576;hb=0c7c4d80673854527ce3c3786dd581169565b5e6;hpb=a4c2c4f9c7cd580252917729a65d482de3c14a97 diff --git a/client_common.c b/client_common.c index 0d87a8d2..a7eee85d 100644 --- a/client_common.c +++ b/client_common.c @@ -15,6 +15,7 @@ #include "para.h" #include "error.h" #include "list.h" +#include "lsu.h" #include "sched.h" #include "crypt.h" #include "net.h" @@ -40,7 +41,6 @@ void client_close(struct client_task *ct) if (!ct) return; free(ct->user); - free(ct->config_file); free(ct->key_file); lls_free_parse_result(ct->lpr, CLIENT_CMD_PTR); free(ct->challenge_hash); @@ -526,53 +526,25 @@ int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr, int *loglevel) { const struct lls_command *cmd = CLIENT_CMD_PTR; - void *map; - size_t sz; struct lls_parse_result *lpr; int ret, ll; struct client_task *ct; - char *cf = NULL, *kf = NULL, *user, *errctx, *home = para_homedir(); + char *kf = NULL, *user, *errctx, *home = para_homedir(); ret = lls(lls_parse(argc, argv, cmd, &lpr, &errctx)); if (ret < 0) goto out; - ll = CLIENT_OPT_UINT32_VAL(LOGLEVEL, lpr); version_handle_flag("client", CLIENT_OPT_GIVEN(VERSION, lpr)); handle_help_flag(lpr); - if (CLIENT_OPT_GIVEN(CONFIG_FILE, lpr)) - cf = para_strdup(CLIENT_OPT_STRING_VAL(CONFIG_FILE, lpr)); - else - cf = make_message("%s/.paraslash/client.conf", home); - ret = mmap_full_file(cf, O_RDONLY, &map, &sz, NULL); - if (ret < 0) { - if (ret != -E_EMPTY && ret != -ERRNO_TO_PARA_ERROR(ENOENT)) - goto out; - if (ret == -ERRNO_TO_PARA_ERROR(ENOENT) && - CLIENT_OPT_GIVEN(CONFIG_FILE, lpr)) - goto out; - } else { - int cf_argc; - char **cf_argv; - struct lls_parse_result *cf_lpr, *merged_lpr; - ret = lls(lls_convert_config(map, sz, NULL, &cf_argv, &errctx)); - para_munmap(map, sz); - if (ret < 0) - goto out; - cf_argc = ret; - ret = lls(lls_parse(cf_argc, cf_argv, cmd, &cf_lpr, &errctx)); - lls_free_argv(cf_argv); - if (ret < 0) - goto out; - ret = lls(lls_merge(lpr, cf_lpr, cmd, &merged_lpr, - &errctx)); - lls_free_parse_result(cf_lpr, cmd); - if (ret < 0) - goto out; - lls_free_parse_result(lpr, cmd); - lpr = merged_lpr; - } + ret = lsu_merge_config_file_options(CLIENT_OPT_STRING_VAL(CONFIG_FILE, lpr), + "client.conf", &lpr, cmd, client_suite, 0U /* default flags */); + if (ret < 0) + goto out; /* success */ + ll = CLIENT_OPT_UINT32_VAL(LOGLEVEL, lpr); + if (loglevel) + *loglevel = ll; user = CLIENT_OPT_GIVEN(USER, lpr)? para_strdup(CLIENT_OPT_STRING_VAL(USER, lpr)) : para_logname(); @@ -586,18 +558,14 @@ int client_parse_config(int argc, char *argv[], struct client_task **ct_ptr, } } PARA_INFO_LOG("user: %s\n", user); - PARA_INFO_LOG("config file: %s\n", cf); PARA_INFO_LOG("key file: %s\n", kf); PARA_INFO_LOG("loglevel: %d\n", ll); ct = para_calloc(sizeof(*ct)); ct->scc.fd = -1; ct->lpr = lpr; ct->key_file = kf; - ct->config_file = cf; ct->user = user; *ct_ptr = ct; - if (loglevel) - *loglevel = ll; ret = lls_num_inputs(lpr); out: free(home); @@ -605,9 +573,7 @@ out: if (errctx) PARA_ERROR_LOG("%s\n", errctx); free(errctx); - PARA_ERROR_LOG("%s\n", para_strerror(-ret)); lls_free_parse_result(lpr, cmd); - free(cf); free(kf); *ct_ptr = NULL; }