From 316bd60579ea11daca4fa25e2720b7fa147cc7ba Mon Sep 17 00:00:00 2001 From: "Rafael G. Martins" Date: Wed, 30 May 2018 23:53:26 +0200 Subject: git-receiver: centralize settings to reuse later --- src/blogc-git-receiver/shell.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/blogc-git-receiver/shell.c') diff --git a/src/blogc-git-receiver/shell.c b/src/blogc-git-receiver/shell.c index eb859e8..f2eaf32 100644 --- a/src/blogc-git-receiver/shell.c +++ b/src/blogc-git-receiver/shell.c @@ -14,6 +14,7 @@ #include #include #include "../common/utils.h" +#include "settings.h" #include "shell-command-parser.h" #include "shell.h" @@ -34,13 +35,10 @@ bgr_shell(int argc, char *argv[]) goto cleanup; } - // get home path - char *home = getenv("BLOGC_GIT_RECEIVER_BASEDIR"); - if (home == NULL) { - home = getenv("HOME"); - } - if (home == NULL) { - fprintf(stderr, "error: failed to find user home path\n"); + // get base dir path + const char *bd = bgr_settings_get_basedir(); + if (bd == NULL) { + fprintf(stderr, "error: failed to find base directory path\n"); rv = 3; goto cleanup; } @@ -53,7 +51,7 @@ bgr_shell(int argc, char *argv[]) goto cleanup; } - repo = bc_strdup_printf("%s/repos/%s", home, tmp_repo); + repo = bc_strdup_printf("%s/repos/%s", bd, tmp_repo); quoted_repo = bc_shell_quote(repo); free(tmp_repo); @@ -132,9 +130,8 @@ bgr_shell(int argc, char *argv[]) git_exec: - if (0 != chdir(home)) { - fprintf(stderr, "error: failed to chdir (%s): %s\n", home, - strerror(errno)); + if (0 != chdir(bd)) { + fprintf(stderr, "error: failed to chdir (%s): %s\n", bd, strerror(errno)); rv = 3; goto cleanup; } -- cgit v1.2.3-18-g5258