diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2018-05-30 23:53:26 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2018-05-30 23:53:26 +0200 |
commit | 316bd60579ea11daca4fa25e2720b7fa147cc7ba (patch) | |
tree | aa53a0daefe10e4d4f58f04af483db5094611a65 /src/blogc-git-receiver/shell.c | |
parent | 9acec235a6c47c3bede917187808a8acd1369050 (diff) | |
download | blogc-316bd60579ea11daca4fa25e2720b7fa147cc7ba.tar.gz blogc-316bd60579ea11daca4fa25e2720b7fa147cc7ba.tar.bz2 blogc-316bd60579ea11daca4fa25e2720b7fa147cc7ba.zip |
git-receiver: centralize settings to reuse later
Diffstat (limited to 'src/blogc-git-receiver/shell.c')
-rw-r--r-- | src/blogc-git-receiver/shell.c | 19 |
1 files changed, 8 insertions, 11 deletions
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 <errno.h> #include <sys/stat.h> #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; } |