about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2015-01-23 16:07:31 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2015-01-23 16:07:31 +0000
commite62d3ae45e9bf3b97551b8879bf6c441ff961ec1 (patch)
tree239987a77426dac08b2877b8e0afab5d4aae6eff /src
parent2c922d2f9870ef174894a6b91399d5cd59318352 (diff)
downloads6-e62d3ae45e9bf3b97551b8879bf6c441ff961ec1.tar.gz
s6-e62d3ae45e9bf3b97551b8879bf6c441ff961ec1.tar.xz
s6-e62d3ae45e9bf3b97551b8879bf6c441ff961ec1.zip
- add s6_accessrules_params_free
 - some libfdholder debug
Diffstat (limited to 'src')
-rw-r--r--src/conn-tools/s6-sudo.c2
-rw-r--r--src/include/s6/accessrules.h2
-rw-r--r--src/include/s6/s6-fdholder.h12
-rw-r--r--src/libs6/deps-lib/s61
-rw-r--r--src/libs6/s6_accessrules_params_free.c10
-rw-r--r--src/libs6/s6_fdholder_delete.c3
-rw-r--r--src/libs6/s6_fdholder_getdump.c5
-rw-r--r--src/libs6/s6_fdholder_list.c3
-rw-r--r--src/libs6/s6_fdholder_list_cb.c2
-rw-r--r--src/libs6/s6_fdholder_retrieve.c3
-rw-r--r--src/libs6/s6_fdholder_setdump.c5
-rw-r--r--src/libs6/s6_fdholder_store.c3
12 files changed, 36 insertions, 15 deletions
diff --git a/src/conn-tools/s6-sudo.c b/src/conn-tools/s6-sudo.c
index 865b681..12880b2 100644
--- a/src/conn-tools/s6-sudo.c
+++ b/src/conn-tools/s6-sudo.c
@@ -1,4 +1,4 @@
-/* ISC license. */
+ /* ISC license. */
 
 #include <skalibs/uint.h>
 #include <skalibs/sgetopt.h>
diff --git a/src/include/s6/accessrules.h b/src/include/s6/accessrules.h
index 3edf8b6..e294817 100644
--- a/src/include/s6/accessrules.h
+++ b/src/include/s6/accessrules.h
@@ -15,6 +15,8 @@ struct s6_accessrules_params_s
 } ;
 #define S6_ACCESSRULES_PARAMS_ZERO { .env = STRALLOC_ZERO, .exec = STRALLOC_ZERO }
 
+extern void s6_accessrules_params_free (s6_accessrules_params_t *) ;
+
 typedef enum s6_accessrules_result_e s6_accessrules_result_t, *s6_accessrules_result_t_ref ;
 enum s6_accessrules_result_e
 {
diff --git a/src/include/s6/s6-fdholder.h b/src/include/s6/s6-fdholder.h
index 7907607..d15b869 100644
--- a/src/include/s6/s6-fdholder.h
+++ b/src/include/s6/s6-fdholder.h
@@ -17,9 +17,9 @@ struct s6_fdholder_s
 {
   unixconnection_t connection ;
 } ;
-#define S6_FDHOLDER_ZERO { .connection = UNIXMESSAGE_CONNECTION_ZERO } ;
+#define S6_FDHOLDER_ZERO { .connection = UNIXCONNECTION_ZERO } ;
 
-#define s6_fdholder_init(a, fdin, fdout) unixconnection_init(&(a)->connection, fdin, fdout)
+#define s6_fdholder_init(a, fd) unixconnection_init(&(a)->connection, fd, fd)
 #define s6_fdholder_free(a) unixconnection_free(&(a)->connection)
 
 
@@ -43,11 +43,11 @@ struct s6_fdholder_retrieve_result_s
 extern int s6_fdholder_retrieve_maybe_delete_async (s6_fdholder_t *, char const *, int) ;
 extern unixmessage_handler_func_t s6_fdholder_retrieve_cb ;
 extern int s6_fdholder_retrieve_maybe_delete (s6_fdholder_t *, char const *, int, tain_t const *, tain_t *) ;
-#define s6_fdholder_retrieve_maybe_delete_g (a, id, h, deadline) s6_fdholder_retrieve(a, id, h, (deadline), &STAMP)
+#define s6_fdholder_retrieve_maybe_delete_g(a, id, h, deadline) s6_fdholder_retrieve_maybe_delete(a, id, h, (deadline), &STAMP)
 #define s6_fdholder_retrieve(a, id, deadline, stamp) s6_fdholder_retrieve_maybe_delete(a, id, 0, deadline, stamp)
-#define s6_fdholder_retrieve_g (a, id, deadline) s6_fdholder_retrieve(a, id, (deadline), &STAMP)
+#define s6_fdholder_retrieve_g(a, id, deadline) s6_fdholder_retrieve(a, id, (deadline), &STAMP)
 #define s6_fdholder_retrieve_delete(a, id, deadline, stamp) s6_fdholder_retrieve_maybe_delete(a, id, 1, deadline, stamp)
-#define s6_fdholder_retrieve_delete_g (a, id, deadline) s6_fdholder_retrieve(a, id, (deadline), &STAMP)
+#define s6_fdholder_retrieve_delete_g(a, id, deadline) s6_fdholder_retrieve(a, id, (deadline), &STAMP)
 
 typedef struct s6_fdholder_list_result_s s6_fdholder_list_result_t, *s6_fdholder_list_result_t_ref ;
 struct s6_fdholder_list_result_s
@@ -74,7 +74,7 @@ struct s6_fdholder_fd_s
 } ;
 
 extern int s6_fdholder_getdump (s6_fdholder_t *, genalloc *, tain_t const *, tain_t *) ;
-#define s6_fdholder_getdump_g(a, g, deadline) s6_fdholder_getdump_g(a, g, (deadline), &STAMP)
+#define s6_fdholder_getdump_g(a, g, deadline) s6_fdholder_getdump(a, g, (deadline), &STAMP)
 extern int s6_fdholder_setdump (s6_fdholder_t *, s6_fdholder_fd_t const *, unsigned int, tain_t const *, tain_t *) ;
 #define s6_fdholder_setdump_g(a, list, n, deadline) s6_fdholder_setdump(a, list, n, (deadline), &STAMP)
 
diff --git a/src/libs6/deps-lib/s6 b/src/libs6/deps-lib/s6
index 35a3296..01b67c3 100644
--- a/src/libs6/deps-lib/s6
+++ b/src/libs6/deps-lib/s6
@@ -20,6 +20,7 @@ s6_accessrules_keycheck_ip4.o
 s6_accessrules_keycheck_ip6.o
 s6_accessrules_keycheck_reversedns.o
 s6_accessrules_keycheck_uidgid.o
+s6_accessrules_params_free.o
 s6_accessrules_uidgid_cdb.o
 s6_accessrules_uidgid_fs.o
 s6_supervise_lock.o
diff --git a/src/libs6/s6_accessrules_params_free.c b/src/libs6/s6_accessrules_params_free.c
new file mode 100644
index 0000000..5eabfde
--- /dev/null
+++ b/src/libs6/s6_accessrules_params_free.c
@@ -0,0 +1,10 @@
+/* ISC license. */
+
+#include <skalibs/stralloc.h>
+#include <s6/accessrules.h>
+
+void s6_accessrules_params_free (s6_accessrules_params_t *params)
+{
+  stralloc_free(&params->env) ;
+  stralloc_free(&params->exec) ;
+}
diff --git a/src/libs6/s6_fdholder_delete.c b/src/libs6/s6_fdholder_delete.c
index 0432421..fd7aa4e 100644
--- a/src/libs6/s6_fdholder_delete.c
+++ b/src/libs6/s6_fdholder_delete.c
@@ -1,6 +1,7 @@
  /* ISC license. */
 
 #include <errno.h>
+#include <skalibs/allreadwrite.h>
 #include <skalibs/error.h>
 #include <skalibs/tai.h>
 #include <skalibs/unixmessage.h>
@@ -11,7 +12,7 @@ int s6_fdholder_delete (s6_fdholder_t *a, char const *id, tain_t const *deadline
   unixmessage_t m ;
   if (!s6_fdholder_delete_async(a, id)) return 0 ;
   if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return 0 ;
-  if (!unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) return 0 ;
+  if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return 0 ;
   if (m.len != 1 || m.nfds)
   {
     unixmessage_drop(&m) ;
diff --git a/src/libs6/s6_fdholder_getdump.c b/src/libs6/s6_fdholder_getdump.c
index 3fce3a7..f464546 100644
--- a/src/libs6/s6_fdholder_getdump.c
+++ b/src/libs6/s6_fdholder_getdump.c
@@ -2,6 +2,7 @@
 
 #include <errno.h>
 #include <skalibs/uint32.h>
+#include <skalibs/allreadwrite.h>
 #include <skalibs/error.h>
 #include <skalibs/bytestr.h>
 #include <skalibs/tai.h>
@@ -19,7 +20,7 @@ int s6_fdholder_getdump (s6_fdholder_t *a, genalloc *g, tain_t const *deadline,
   int ok ;
   if (!unixmessage_put(&a->connection.out, &m)) return 0 ;
   if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return 0 ;
-  if (!unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) return 0 ;
+  if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return 0 ;
   if (!m.len || m.nfds) return (errno = EPROTO, 0) ;
   if (m.s[0]) return (errno = m.s[0], 0) ;
   if (m.len != 9) return (errno = EPROTO, 0) ;
@@ -31,7 +32,7 @@ int s6_fdholder_getdump (s6_fdholder_t *a, genalloc *g, tain_t const *deadline,
   
   for (; i < n ; i++)
   {
-    if (!unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) goto err ;
+    if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) goto err ;
     if (genalloc_len(s6_fdholder_fd_t, g) + m.nfds > ntot) goto droperr ;
     if (ok)
     {
diff --git a/src/libs6/s6_fdholder_list.c b/src/libs6/s6_fdholder_list.c
index 4f804aa..868a3e6 100644
--- a/src/libs6/s6_fdholder_list.c
+++ b/src/libs6/s6_fdholder_list.c
@@ -1,6 +1,7 @@
  /* ISC license. */
 
 #include <errno.h>
+#include <skalibs/allreadwrite.h>
 #include <skalibs/error.h>
 #include <skalibs/tai.h>
 #include <skalibs/unixmessage.h>
@@ -12,7 +13,7 @@ int s6_fdholder_list (s6_fdholder_t *a, stralloc *sa, tain_t const *deadline, ta
   unixmessage_t m ;
   if (!s6_fdholder_list_async(a)) return -1 ;
   if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return -1 ;
-  if (!unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) return -1 ;
+  if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return -1 ;
   if (!s6_fdholder_list_cb(&m, &res)) return -1 ;
   if (res.err) return (errno = res.err, -1) ;
   return (int)res.n ;
diff --git a/src/libs6/s6_fdholder_list_cb.c b/src/libs6/s6_fdholder_list_cb.c
index bfdee50..d465004 100644
--- a/src/libs6/s6_fdholder_list_cb.c
+++ b/src/libs6/s6_fdholder_list_cb.c
@@ -2,6 +2,7 @@
 
 #include <errno.h>
 #include <skalibs/uint32.h>
+#include <skalibs/bytestr.h>
 #include <skalibs/error.h>
 #include <skalibs/stralloc.h>
 #include <skalibs/unixmessage.h>
@@ -19,6 +20,7 @@ int s6_fdholder_list_cb (unixmessage_t const *m, void *p)
     return 1 ;
   }
   uint32_unpack_big(m->s + 1, &n) ;
+  if (byte_count(m->s + 5, m->len - 5, 0) != n) goto err ;
   if (!stralloc_catb(res->sa, m->s + 5, m->len - 5)) return 0 ;
   res->n = n ;
   res->err = 0 ;
diff --git a/src/libs6/s6_fdholder_retrieve.c b/src/libs6/s6_fdholder_retrieve.c
index e2888a9..caf2426 100644
--- a/src/libs6/s6_fdholder_retrieve.c
+++ b/src/libs6/s6_fdholder_retrieve.c
@@ -1,6 +1,7 @@
  /* ISC license. */
 
 #include <errno.h>
+#include <skalibs/allreadwrite.h>
 #include <skalibs/tai.h>
 #include <skalibs/unixmessage.h>
 #include <s6/s6-fdholder.h>
@@ -11,7 +12,7 @@ int s6_fdholder_retrieve_maybe_delete (s6_fdholder_t *a, char const *id, int dod
   s6_fdholder_retrieve_result_t res ;
   if (!s6_fdholder_retrieve_maybe_delete_async(a, id, dodelete)) return -1 ;
   if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return -1 ;
-  if (!unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) return -1 ;
+  if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return -1 ;
   if (!s6_fdholder_retrieve_cb(&m, &res)) return -1 ;
   if (res.err) return (errno = res.err, -1) ;
   return res.fd ;
diff --git a/src/libs6/s6_fdholder_setdump.c b/src/libs6/s6_fdholder_setdump.c
index e5825dc..61c238c 100644
--- a/src/libs6/s6_fdholder_setdump.c
+++ b/src/libs6/s6_fdholder_setdump.c
@@ -2,6 +2,7 @@
 
 #include <errno.h>
 #include <skalibs/uint32.h>
+#include <skalibs/allreadwrite.h>
 #include <skalibs/bytestr.h>
 #include <skalibs/error.h>
 #include <skalibs/tai.h>
@@ -25,7 +26,7 @@ int s6_fdholder_setdump (s6_fdholder_t *a, s6_fdholder_fd_t const *list, unsigne
     uint32_pack_big(pack+1, ntot) ;
     if (!unixmessage_put(&a->connection.out, &m)) return 0 ;
     if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return 0 ;
-    if (!unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) return 0 ;
+    if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return 0 ;
     if (!m.len || m.nfds) { unixmessage_drop(&m) ; return (errno = EPROTO, 0) ; }
     if (m.s[0]) return (errno = m.s[0], 0) ;
     if (m.len != 5) return (errno = EPROTO, 0) ;
@@ -58,7 +59,7 @@ int s6_fdholder_setdump (s6_fdholder_t *a, s6_fdholder_fd_t const *list, unsigne
     if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return 0 ;
     {
       unixmessage_t m ;
-      if (!unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) return 0 ;
+      if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return 0 ;
       if (m.len != 1 || m.nfds)
       {
         unixmessage_drop(&m) ;
diff --git a/src/libs6/s6_fdholder_store.c b/src/libs6/s6_fdholder_store.c
index 4241d8d..7b8f6dc 100644
--- a/src/libs6/s6_fdholder_store.c
+++ b/src/libs6/s6_fdholder_store.c
@@ -1,6 +1,7 @@
  /* ISC license. */
 
 #include <errno.h>
+#include <skalibs/allreadwrite.h>
 #include <skalibs/error.h>
 #include <skalibs/tai.h>
 #include <skalibs/unixmessage.h>
@@ -11,7 +12,7 @@ int s6_fdholder_store (s6_fdholder_t *a, int fd, char const *id, tain_t const *l
   unixmessage_t m ;
   if (!s6_fdholder_store_async(a, fd, id, limit)) return 0 ;
   if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return 0 ;
-  if (!unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) return 0 ;
+  if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return 0 ;
   if (m.len != 1 || m.nfds)
   {
     unixmessage_drop(&m) ;