aboutsummaryrefslogtreecommitdiffstats
path: root/src/blogc-git-receiver/shell.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/blogc-git-receiver/shell.c')
-rw-r--r--src/blogc-git-receiver/shell.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/blogc-git-receiver/shell.c b/src/blogc-git-receiver/shell.c
index 8c45b54..d288654 100644
--- a/src/blogc-git-receiver/shell.c
+++ b/src/blogc-git-receiver/shell.c
@@ -19,6 +19,17 @@
#include "shell.h"
+static bool
+lexists(const char *pathname)
+{
+ struct stat b;
+ int tmp_errno = errno;
+ bool rv = lstat(pathname, &b) == 0;
+ errno = tmp_errno;
+ return rv;
+}
+
+
int
bgr_shell(int argc, char *argv[])
{
@@ -96,7 +107,7 @@ bgr_shell(int argc, char *argv[])
goto cleanup;
}
- if (0 == access("pre-receive", F_OK)) {
+ if (lexists("pre-receive")) {
if (0 != unlink("pre-receive")) {
fprintf(stderr, "error: failed to remove old symlink "
"(%s/hooks/pre-receive): %s\n", repo, strerror(errno));
@@ -112,7 +123,7 @@ bgr_shell(int argc, char *argv[])
goto cleanup;
}
- if (0 == access("post-receive", F_OK)) {
+ if (lexists("post-receive")) {
if (0 != unlink("post-receive")) {
fprintf(stderr, "error: failed to remove old symlink "
"(%s/hooks/post-receive): %s\n", repo, strerror(errno));