log more errors
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
diff --git a/git-auth.c b/git-auth.c
index fa6ffc8..f05d2e5 100644
--- a/git-auth.c
+++ b/git-auth.c
@@ -21,6 +21,7 @@
#include <stdarg.h>
#include <string.h>
#include <err.h>
+#include <errno.h>
#include <ctype.h>
#include <unistd.h>
#include <assert.h>
@@ -107,6 +108,10 @@ void rules_read (s_rules *rr, const char *path)
{
syslog(LOG_DEBUG, "READ %s", path);
FILE *fp = fopen(path, "r");
+ if (!fp) {
+ syslog(LOG_ERR, "rules_read: %s: %s", path, strerror(errno));
+ err(3, "rules_read: %s", path);
+ }
char line[2048];
while (fgets(line, sizeof(line) - 4, fp)) {
s_rule r;
@@ -121,8 +126,9 @@ void rules_read (s_rules *rr, const char *path)
syslog(LOG_WARNING, "invalid rule: %s", line);
}
if (ferror(fp)) {
+ syslog(LOG_ERR, "rules_read: %s: %s", path, strerror(errno));
fclose(fp);
- err(3, "%s", path);
+ err(3, "rules_read: %s", path);
}
fclose(fp);
}
@@ -199,7 +205,8 @@ void exec_cmd (const s_symtable *cmd)
log_cmd("EXEC", &xc);
cleanup();
execvp(xc.sym[0], (char **)xc.sym);
- err(2, "exec failed");
+ syslog(LOG_ERR, "execvp: %s", strerror(errno));
+ err(2, "execvp");
}
int main (int argc, char **argv)