aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-git-receiver/shell.c
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2016-12-26 20:52:13 +0100
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2016-12-26 20:52:13 +0100
commit7bf68b0b617fb3ffa86f38fe06a49786883037f4 (patch)
tree797c86c0f24195555d4cd520a2a9c92c852be55b /src/blogc-git-receiver/shell.c
parent509af4c66c0b6287ba281a2d1f01d69450f6109c (diff)
downloadblogc-7bf68b0b617fb3ffa86f38fe06a49786883037f4.tar.gz
blogc-7bf68b0b617fb3ffa86f38fe06a49786883037f4.tar.bz2
blogc-7bf68b0b617fb3ffa86f38fe06a49786883037f4.zip
*: binaries should always return 3 on errors, for consistency.
We used to return 1 or 2 in case of errors, with no special meaning, other than "something is wrong", but these codes are reserved. Now we always return 3.
Diffstat (limited to 'src/blogc-git-receiver/shell.c')
-rw-r--r--src/blogc-git-receiver/shell.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/blogc-git-receiver/shell.c b/src/blogc-git-receiver/shell.c
index a21c5bd..d0799e4 100644
--- a/src/blogc-git-receiver/shell.c
+++ b/src/blogc-git-receiver/shell.c
@@ -30,7 +30,7 @@ bgr_shell(int argc, char *argv[])
char *self = getenv("SHELL");
if (self == NULL) {
fprintf(stderr, "error: failed to find blogc-git-receiver path\n");
- rv = 1;
+ rv = 3;
goto cleanup;
}
@@ -38,7 +38,7 @@ bgr_shell(int argc, char *argv[])
char *home = getenv("HOME");
if (home == NULL) {
fprintf(stderr, "error: failed to find user home path\n");
- rv = 1;
+ rv = 3;
goto cleanup;
}
@@ -46,7 +46,7 @@ bgr_shell(int argc, char *argv[])
char *tmp_repo = bgr_shell_command_parse(argv[2]);
if (tmp_repo == NULL) {
fprintf(stderr, "error: invalid git-shell command: %s\n", argv[2]);
- rv = 1;
+ rv = 3;
goto cleanup;
}
@@ -63,7 +63,7 @@ bgr_shell(int argc, char *argv[])
if (0 != system(git_init_cmd)) {
fprintf(stderr, "error: failed to create git repository: %s\n",
repo);
- rv = 1;
+ rv = 3;
free(git_init_cmd);
goto cleanup;
}
@@ -73,7 +73,7 @@ bgr_shell(int argc, char *argv[])
if (0 != chdir(repo)) {
fprintf(stderr, "error: failed to chdir (%s): %s\n", repo,
strerror(errno));
- rv = 1;
+ rv = 3;
goto cleanup;
}
@@ -83,7 +83,7 @@ bgr_shell(int argc, char *argv[])
if (0 != mkdir("hooks", 0777)) { // mkdir honors umask for us.
fprintf(stderr, "error: failed to create directory (%s/hooks): "
"%s\n", repo, strerror(errno));
- rv = 1;
+ rv = 3;
goto cleanup;
}
}
@@ -91,7 +91,7 @@ bgr_shell(int argc, char *argv[])
if (0 != chdir("hooks")) {
fprintf(stderr, "error: failed to chdir (%s/hooks): %s\n", repo,
strerror(errno));
- rv = 1;
+ rv = 3;
goto cleanup;
}
@@ -99,7 +99,7 @@ bgr_shell(int argc, char *argv[])
if (0 != unlink("pre-receive")) {
fprintf(stderr, "error: failed to remove old symlink "
"(%s/hooks/pre-receive): %s\n", repo, strerror(errno));
- rv = 1;
+ rv = 3;
goto cleanup;
}
}
@@ -107,7 +107,7 @@ bgr_shell(int argc, char *argv[])
if (0 != symlink(self, "pre-receive")) {
fprintf(stderr, "error: failed to create symlink "
"(%s/hooks/pre-receive): %s\n", repo, strerror(errno));
- rv = 1;
+ rv = 3;
goto cleanup;
}
@@ -115,7 +115,7 @@ bgr_shell(int argc, char *argv[])
if (0 != unlink("post-receive")) {
fprintf(stderr, "error: failed to remove old symlink "
"(%s/hooks/post-receive): %s\n", repo, strerror(errno));
- rv = 1;
+ rv = 3;
goto cleanup;
}
}
@@ -123,7 +123,7 @@ bgr_shell(int argc, char *argv[])
if (0 != symlink(self, "post-receive")) {
fprintf(stderr, "error: failed to create symlink "
"(%s/hooks/post-receive): %s\n", repo, strerror(errno));
- rv = 1;
+ rv = 3;
goto cleanup;
}
@@ -132,7 +132,7 @@ git_exec:
if (0 != chdir(home)) {
fprintf(stderr, "error: failed to chdir (%s): %s\n", home,
strerror(errno));
- rv = 1;
+ rv = 3;
goto cleanup;
}
@@ -146,13 +146,13 @@ git_exec:
if (sizeof(buffer) < (strlen(command) + strlen(quoted_repo) + 2)) {
fprintf(stderr, "error: git-shell command is too big\n");
- rv = 1;
+ rv = 3;
goto cleanup;
}
if (0 > snprintf(buffer, sizeof(buffer), "%s %s", command, quoted_repo)) {
fprintf(stderr, "error: failed to generate git-shell command\n");
- rv = 1;
+ rv = 3;
goto cleanup;
}
@@ -166,7 +166,7 @@ git_exec:
// execlp only returns on error, then something bad happened
fprintf(stderr, "error: failed to execute git-shell\n");
- return 1;
+ return 3;
}
printf("git-shell -c \"%s\"\n", buffer); // used by tests, ignore