about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-10-26 15:00:30 +0000
committerLaurent Bercot <ska@appnovation.com>2023-10-26 15:00:30 +0000
commitd05b3963381a4cd0329bced938d79a23bb392658 (patch)
tree0033b18d74eb24b497d7e258b85e7c7093541d2b
parent3dd236a9d8ff1fa0a754b359ceda12e85a123fff (diff)
downloadtipidee-d05b3963381a4cd0329bced938d79a23bb392658.tar.gz
tipidee-d05b3963381a4cd0329bced938d79a23bb392658.tar.xz
tipidee-d05b3963381a4cd0329bced938d79a23bb392658.zip
Some more fixes
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--src/include/tipidee/log.h2
-rw-r--r--src/libtipidee/tipidee_conf_get_redirection.c13
-rw-r--r--src/tipideed/cgi.c4
-rw-r--r--src/tipideed/responses.c3
4 files changed, 13 insertions, 9 deletions
diff --git a/src/include/tipidee/log.h b/src/include/tipidee/log.h
index bf3b812..0904ca4 100644
--- a/src/include/tipidee/log.h
+++ b/src/include/tipidee/log.h
@@ -22,7 +22,7 @@
 #define TIPIDEE_LOG_CLIENTIP 0x0080
 #define TIPIDEE_LOG_CLIENTHOST 0x0100
 #define TIPIDEE_LOG_HOSTASPREFIX 0x0200
-#define TIPIDEE_LOG_DEBUG 0x0400
+#define TIPIDEE_LOG_DEBUG 0x8000
 
 #define TIPIDEE_LOG_DEFAULT (TIPIDEE_LOG_REQUEST | TIPIDEE_LOG_ANSWER | TIPIDEE_LOG_SIZE)
 
diff --git a/src/libtipidee/tipidee_conf_get_redirection.c b/src/libtipidee/tipidee_conf_get_redirection.c
index 9d40de2..b117481 100644
--- a/src/libtipidee/tipidee_conf_get_redirection.c
+++ b/src/libtipidee/tipidee_conf_get_redirection.c
@@ -11,19 +11,20 @@
 
 static int get_redir (tipidee_conf const *conf, size_t minl, char *key, size_t l, char const *path, tipidee_redirection *r)
 {
-  char const *v ;
+  char const *v = 0 ;
   key[0] = 'R' ;
   key[l] = '/' ;
-  for (;;)
+  errno = ENOENT ;
+  while (!v)
   {
-    while (l > minl && key[l] != '/') l-- ;
-    if (l <= minl) return 0 ;
+    if (errno != ENOENT) return -1 ;
+    while (l >= minl && key[l] != '/') l-- ;
+    if (l < minl) break ;
     key[l--] = 0 ;
     v = tipidee_conf_get_string(conf, key) ;
-    if (v) break ;
-    if (errno != ENOENT) return -1 ;
     key[0] = 'r' ;
   }
+  if (!v) return 0 ;
   if (v[0] < '@' || v[0] > 'C') return (errno = EPROTO, -1) ;
   r->type = v[0] & ~'@' ;
   r->location = v+1 ;
diff --git a/src/tipideed/cgi.c b/src/tipideed/cgi.c
index 037076d..9751911 100644
--- a/src/tipideed/cgi.c
+++ b/src/tipideed/cgi.c
@@ -124,10 +124,10 @@ static inline int do_nph (tipidee_rql const *rql, char const *docroot, char cons
         PROG = progstr ;
         tain_add_g(&deadline, &g.cgitto) ;
         close(p[0]) ;
-        if (ndelay_on(p[1]) == -1) strerr_diefu1sys(111, "set fd nonblocking") ;
+        if (ndelay_on(p[1]) == -1) die500sys(rql, 111, docroot, "set fd nonblocking") ;
         if (buffer_timed_put_g(&b, body, bodylen, &deadline) < bodylen
          || !buffer_timed_flush_g(&b, &deadline))
-          strerr_diefu2sys(111, "write request body to nph ", argv[0]) ;
+          die500sys(rql, 111, docroot, "write request body to nph ", argv[0]) ;
         _exit(0) ;
       }
       default : break ;
diff --git a/src/tipideed/responses.c b/src/tipideed/responses.c
index 8155b55..f08f83c 100644
--- a/src/tipideed/responses.c
+++ b/src/tipideed/responses.c
@@ -2,6 +2,7 @@
 
 #include <skalibs/bsdsnowflake.h>
 
+#include <errno.h>
 #include <string.h>
 #include <unistd.h>
 
@@ -103,7 +104,9 @@ void response_error_and_exit (tipidee_rql const *rql, char const *docroot, unsig
 
 void response_error_and_die (tipidee_rql const *rql, int e, char const *docroot, unsigned int status, char const *const *v, unsigned int n, uint32_t options)
 {
+  int serr = errno ;
   response_error(rql, docroot, status, options | 1) ;
+  errno = serr ;
   if (options & 1) strerr_dievsys(e, v, n) ;
   else strerr_diev(e, v, n) ;
 }