diff -Nru s6-2.10.0.2/AUTHORS s6-2.11.0.0/AUTHORS --- s6-2.10.0.2/AUTHORS 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/AUTHORS 2021-09-26 14:04:15.000000000 +0000 @@ -12,6 +12,7 @@ Eric Le Bihan Shengjing Zhu Alexis + Mira Ressel Thanks to: Dan J. Bernstein @@ -33,7 +34,9 @@ Hardware Earl Chew Jonathan de Boyne Pollard - Mira Ressel Eric Vidal Jens Rehsack Xavier Stonestreet + Johannes Nixdorf + Oliver Schad + Alex Kiernan diff -Nru s6-2.10.0.2/configure s6-2.11.0.0/configure --- s6-2.10.0.2/configure 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/configure 2021-09-26 14:04:15.000000000 +0000 @@ -95,7 +95,7 @@ tryflag () { echo "Checking whether compiler accepts $2 ..." echo "typedef int x;" > "$tmpc" - if $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST "$2" -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then + if $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST "$2" -c -o "$tmpo" "$tmpc" >/dev/null 2>&1 ; then echo " ... yes" eval "$1=\"\${$1} \$2\"" eval "$1=\${$1# }" @@ -109,7 +109,7 @@ tryldflag () { echo "Checking whether linker accepts $2 ..." echo "typedef int x;" > "$tmpc" - if $CC_AUTO $CFLAGS_AUTO $CFLAGS $CFLAGS_POST $LDFLAGS_AUTO $LDFLAGS $LDFLAGS_POST -nostdlib "$2" -o /dev/null "$tmpc" >/dev/null 2>&1 ; then + if $CC_AUTO $CFLAGS_AUTO $CFLAGS $CFLAGS_POST $LDFLAGS_AUTO $LDFLAGS $LDFLAGS_POST -nostdlib "$2" -o "$tmpe" "$tmpc" >/dev/null 2>&1 ; then echo " ... yes" eval "$1=\"\${$1} \$2\"" eval "$1=\${$1# }" @@ -232,13 +232,15 @@ while : ; do i=$(($i+1)) tmpc="./tmp-configure-$$-$PPID-$i.c" + tmpo="./tmp-configure-$$-$PPID-$i.o" tmpe="./tmp-configure-$$-$PPID-$i.tmp" 2>|/dev/null > "$tmpc" && break + 2>|/dev/null > "$tmpo" && break 2>|/dev/null > "$tmpe" && break test "$i" -gt 50 && fail "$0: cannot create temporary files" done set +C -trap 'rm -f "$tmpc" "$tmpe"' EXIT ABRT INT QUIT TERM HUP +trap 'rm -f "$tmpc" "$tmpo" "$tmpe"' EXIT ABRT INT QUIT TERM HUP # Set slashpackage values if $slashpackage ; then @@ -301,7 +303,7 @@ echo " ... $CC_AUTO" echo "Checking whether C compiler works... " echo "typedef int x;" > "$tmpc" -if $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST -c -o /dev/null "$tmpc" 2>"$tmpe" ; then +if $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST -c -o "$tmpo" "$tmpc" 2>"$tmpe" ; then echo " ... yes" else echo " ... no. Compiler output follows:" @@ -341,7 +343,6 @@ tryflag CFLAGS_AUTO -fno-exceptions tryflag CFLAGS_AUTO -fno-unwind-tables tryflag CFLAGS_AUTO -fno-asynchronous-unwind-tables -tryflag CFLAGS_AUTO -Wa,--noexecstack tryflag CPPFLAGS_AUTO -Werror=implicit-function-declaration tryflag CPPFLAGS_AUTO -Werror=implicit-int tryflag CPPFLAGS_AUTO -Werror=pointer-sign diff -Nru s6-2.10.0.2/CONTRIBUTING s6-2.11.0.0/CONTRIBUTING --- s6-2.10.0.2/CONTRIBUTING 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/CONTRIBUTING 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,5 @@ + Please add a Signed-Off-By: line at the end of your commit, +which certifies that you have the right and authority to pass +it on as an open-source patch, as explicited in the Developer's +Certificate of Origin available in this project's DCO file, +or at https://developercertificate.org/ diff -Nru s6-2.10.0.2/DCO s6-2.11.0.0/DCO --- s6-2.10.0.2/DCO 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/DCO 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,37 @@ +Developer Certificate of Origin +Version 1.1 + +Copyright (C) 2004, 2006 The Linux Foundation and its contributors. +1 Letterman Drive +Suite D4700 +San Francisco, CA, 94129 + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. + + +Developer's Certificate of Origin 1.1 + +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I + have the right to submit it under the open source license + indicated in the file; or + +(b) The contribution is based upon previous work that, to the best + of my knowledge, is covered under an appropriate open source + license and I have the right under that license to submit that + work with modifications, whether created in whole or in part + by me, under the same open source license (unless I am + permitted to submit under a different license), as indicated + in the file; or + +(c) The contribution was provided directly to me by some other + person who certified (a), (b) or (c) and I have not modified + it. + +(d) I understand and agree that this project and the contribution + are public and that a record of the contribution (including all + personal information I submit with it, including my sign-off) is + maintained indefinitely and may be redistributed consistent with + this project or the open source license(s) involved. diff -Nru s6-2.10.0.2/debian/changelog s6-2.11.0.0/debian/changelog --- s6-2.10.0.2/debian/changelog 2021-02-16 14:50:14.000000000 +0000 +++ s6-2.11.0.0/debian/changelog 2021-10-08 14:56:06.000000000 +0000 @@ -1,3 +1,24 @@ +s6 (2.11.0.0-2) unstable; urgency=medium + + * Upload to unstable + + -- Shengjing Zhu Fri, 08 Oct 2021 22:56:06 +0800 + +s6 (2.11.0.0-1) experimental; urgency=medium + + * New upstream release v2.11.0.0 + * Bump SO version to 2.11 + + -- Shengjing Zhu Mon, 27 Sep 2021 03:59:20 +0800 + +s6 (2.10.0.3-1) unstable; urgency=medium + + * New upstream release v2.10.0.3 + * Update Standards-Version to 4.6.0 (no changes) + * Bump libexecline-dev to 2.8.0.1 + + -- Shengjing Zhu Mon, 23 Aug 2021 23:27:31 +0800 + s6 (2.10.0.2-1) unstable; urgency=medium * New upstream release v2.10.0.2 diff -Nru s6-2.10.0.2/debian/control s6-2.11.0.0/debian/control --- s6-2.10.0.2/debian/control 2021-02-16 14:50:14.000000000 +0000 +++ s6-2.11.0.0/debian/control 2021-10-08 14:56:06.000000000 +0000 @@ -6,14 +6,14 @@ Build-Depends: debhelper-compat (= 13), Build-Depends-Arch: - libexecline-dev (>= 2.7.0.1), - skalibs-dev (>= 2.10.0.2), -Standards-Version: 4.5.1 + libexecline-dev (>= 2.8.0.1), + skalibs-dev (>= 2.11.0.0), +Standards-Version: 4.6.0 Homepage: https://skarnet.org/software/s6/ Vcs-Git: https://salsa.debian.org/zhsj/s6.git Vcs-Browser: https://salsa.debian.org/zhsj/s6 -Package: libs6-2.10 +Package: libs6-2.11 Architecture: any Section: libs Multi-Arch: same @@ -38,7 +38,7 @@ Section: libdevel Multi-Arch: same Depends: - libs6-2.10 (= ${binary:Version}), + libs6-2.11 (= ${binary:Version}), ${misc:Depends}, Description: small and secure supervision software suite (development files) s6 is a small suite of programs for UNIX, designed to allow process diff -Nru s6-2.10.0.2/debian/libs6-2.10.install s6-2.11.0.0/debian/libs6-2.10.install --- s6-2.10.0.2/debian/libs6-2.10.install 2021-02-16 14:50:14.000000000 +0000 +++ s6-2.11.0.0/debian/libs6-2.10.install 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -usr/lib/*/*.so.* diff -Nru s6-2.10.0.2/debian/libs6-2.10.symbols s6-2.11.0.0/debian/libs6-2.10.symbols --- s6-2.10.0.2/debian/libs6-2.10.symbols 2021-02-16 14:50:14.000000000 +0000 +++ s6-2.11.0.0/debian/libs6-2.10.symbols 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -libs6.so.2.10 libs6-2.10 #MINVER# -* Build-Depends-Package: libs6-dev - ftrigr1_zero@Base 2.7.2.0 - ftrigr_ack@Base 2.7.2.0 - ftrigr_check@Base 2.7.2.0 - ftrigr_checksa@Base 2.7.2.0 - ftrigr_end@Base 2.7.2.0 - ftrigr_start@Base 2.7.2.0 - ftrigr_startf@Base 2.7.2.0 - ftrigr_subscribe@Base 2.7.2.0 - ftrigr_unsubscribe@Base 2.7.2.0 - ftrigr_update@Base 2.7.2.0 - ftrigr_updateb@Base 2.7.2.0 - ftrigr_wait_and@Base 2.7.2.0 - ftrigr_wait_or@Base 2.7.2.0 - ftrigr_zero@Base 2.7.2.0 - ftrigw_clean@Base 2.7.2.0 - ftrigw_fifodir_make@Base 2.7.2.0 - ftrigw_notify@Base 2.7.2.0 - ftrigw_notifyb@Base 2.7.2.0 - ftrigw_notifyb_nosig@Base 2.7.2.0 - s6_accessrules_backend_cdb@Base 2.7.2.0 - s6_accessrules_backend_fs@Base 2.7.2.0 - s6_accessrules_keycheck_ip4@Base 2.7.2.0 - s6_accessrules_keycheck_ip6@Base 2.7.2.0 - s6_accessrules_keycheck_reversedns@Base 2.7.2.0 - s6_accessrules_keycheck_uidgid@Base 2.7.2.0 - s6_accessrules_params_free@Base 2.7.2.0 - s6_accessrules_uidgid_cdb@Base 2.7.2.0 - s6_accessrules_uidgid_fs@Base 2.7.2.0 - s6_dtally_pack@Base 2.7.2.0 - s6_dtally_read@Base 2.7.2.0 - s6_dtally_unpack@Base 2.7.2.0 - s6_dtally_write@Base 2.7.2.0 - s6_fdholder_delete@Base 2.7.2.0 - s6_fdholder_delete_async@Base 2.7.2.0 - s6_fdholder_end@Base 2.7.2.0 - s6_fdholder_getdump@Base 2.7.2.0 - s6_fdholder_list@Base 2.7.2.0 - s6_fdholder_list_async@Base 2.7.2.0 - s6_fdholder_list_cb@Base 2.7.2.0 - s6_fdholder_retrieve_cb@Base 2.7.2.0 - s6_fdholder_retrieve_maybe_delete@Base 2.7.2.0 - s6_fdholder_retrieve_maybe_delete_async@Base 2.7.2.0 - s6_fdholder_setdump@Base 2.7.2.0 - s6_fdholder_start@Base 2.7.2.0 - s6_fdholder_store@Base 2.7.2.0 - s6_fdholder_store_async@Base 2.7.2.0 - s6_supervise_link@Base 2.10.0.0 - s6_supervise_unlink@Base 2.10.0.0 - s6_svc_ok@Base 2.7.2.0 - s6_svc_write@Base 2.7.2.0 - s6_svc_writectl@Base 2.7.2.0 - s6_svstatus_pack@Base 2.7.2.0 - s6_svstatus_read@Base 2.7.2.0 - s6_svstatus_unpack@Base 2.7.2.0 - s6_svstatus_write@Base 2.7.2.0 - s6lock_acquire@Base 2.7.2.0 - s6lock_check@Base 2.7.2.0 - s6lock_end@Base 2.7.2.0 - s6lock_release@Base 2.7.2.0 - s6lock_start@Base 2.7.2.0 - s6lock_startf@Base 2.7.2.0 - s6lock_update@Base 2.7.2.0 - s6lock_wait_and@Base 2.7.2.0 - s6lock_wait_or@Base 2.7.2.0 - s6lock_zero@Base 2.7.2.0 diff -Nru s6-2.10.0.2/debian/libs6-2.11.install s6-2.11.0.0/debian/libs6-2.11.install --- s6-2.10.0.2/debian/libs6-2.11.install 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/debian/libs6-2.11.install 2021-10-08 14:56:06.000000000 +0000 @@ -0,0 +1 @@ +usr/lib/*/*.so.* diff -Nru s6-2.10.0.2/debian/libs6-2.11.symbols s6-2.11.0.0/debian/libs6-2.11.symbols --- s6-2.10.0.2/debian/libs6-2.11.symbols 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/debian/libs6-2.11.symbols 2021-10-08 14:56:06.000000000 +0000 @@ -0,0 +1,69 @@ +libs6.so.2.11 libs6-2.11 #MINVER# +* Build-Depends-Package: libs6-dev + ftrigr1_zero@Base 2.7.2.0 + ftrigr_ack@Base 2.7.2.0 + ftrigr_check@Base 2.7.2.0 + ftrigr_checksa@Base 2.7.2.0 + ftrigr_end@Base 2.7.2.0 + ftrigr_start@Base 2.7.2.0 + ftrigr_startf@Base 2.7.2.0 + ftrigr_subscribe@Base 2.7.2.0 + ftrigr_unsubscribe@Base 2.7.2.0 + ftrigr_update@Base 2.7.2.0 + ftrigr_updateb@Base 2.7.2.0 + ftrigr_wait_and@Base 2.7.2.0 + ftrigr_wait_or@Base 2.7.2.0 + ftrigr_zero@Base 2.7.2.0 + ftrigw_clean@Base 2.7.2.0 + ftrigw_fifodir_make@Base 2.7.2.0 + ftrigw_notify@Base 2.7.2.0 + ftrigw_notifyb@Base 2.7.2.0 + ftrigw_notifyb_nosig@Base 2.7.2.0 + s6_accessrules_backend_cdb@Base 2.7.2.0 + s6_accessrules_backend_fs@Base 2.7.2.0 + s6_accessrules_keycheck_ip4@Base 2.7.2.0 + s6_accessrules_keycheck_ip6@Base 2.7.2.0 + s6_accessrules_keycheck_reversedns@Base 2.7.2.0 + s6_accessrules_keycheck_uidgid@Base 2.7.2.0 + s6_accessrules_params_free@Base 2.7.2.0 + s6_accessrules_uidgid_cdb@Base 2.7.2.0 + s6_accessrules_uidgid_fs@Base 2.7.2.0 + s6_dtally_pack@Base 2.7.2.0 + s6_dtally_read@Base 2.7.2.0 + s6_dtally_unpack@Base 2.7.2.0 + s6_dtally_write@Base 2.7.2.0 + s6_fdholder_delete@Base 2.7.2.0 + s6_fdholder_delete_async@Base 2.7.2.0 + s6_fdholder_end@Base 2.7.2.0 + s6_fdholder_getdump@Base 2.7.2.0 + s6_fdholder_list@Base 2.7.2.0 + s6_fdholder_list_async@Base 2.7.2.0 + s6_fdholder_list_cb@Base 2.7.2.0 + s6_fdholder_retrieve_cb@Base 2.7.2.0 + s6_fdholder_retrieve_maybe_delete@Base 2.7.2.0 + s6_fdholder_retrieve_maybe_delete_async@Base 2.7.2.0 + s6_fdholder_setdump@Base 2.7.2.0 + s6_fdholder_start@Base 2.7.2.0 + s6_fdholder_store@Base 2.7.2.0 + s6_fdholder_store_async@Base 2.7.2.0 + s6_supervise_link@Base 2.10.0.0 + s6_supervise_link_names@Base 2.11.0.0 + s6_supervise_unlink@Base 2.10.0.0 + s6_supervise_unlink_names@Base 2.11.0.0 + s6_svc_ok@Base 2.7.2.0 + s6_svc_write@Base 2.7.2.0 + s6_svc_writectl@Base 2.7.2.0 + s6_svstatus_pack@Base 2.7.2.0 + s6_svstatus_read@Base 2.7.2.0 + s6_svstatus_unpack@Base 2.7.2.0 + s6_svstatus_write@Base 2.7.2.0 + s6lock_acquire@Base 2.7.2.0 + s6lock_check@Base 2.7.2.0 + s6lock_end@Base 2.7.2.0 + s6lock_release@Base 2.7.2.0 + s6lock_start@Base 2.7.2.0 + s6lock_startf@Base 2.7.2.0 + s6lock_update@Base 2.7.2.0 + s6lock_wait_and@Base 2.7.2.0 + s6lock_wait_or@Base 2.7.2.0 + s6lock_zero@Base 2.7.2.0 diff -Nru s6-2.10.0.2/doc/index.html s6-2.11.0.0/doc/index.html --- s6-2.10.0.2/doc/index.html 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/doc/index.html 2021-09-26 14:04:15.000000000 +0000 @@ -83,11 +83,12 @@
  • A POSIX-compliant system with a standard C development environment
  • GNU make, version 3.81 or later
  • skalibs version -2.10.0.2 or later. It's a build-time requirement. It's also a run-time +2.11.0.0 or later. It's a build-time requirement. It's also a run-time requirement if you link against the shared version of the skalibs library.
  • -
  • Optional: execline version -2.7.0.1 or later. When s6 is built with execline support (which is the default), +
  • (Optional, but really recommended for full functionality): +execline version +2.8.1.0 or later. When s6 is built with execline support (which is the default), execline is a build-time requirement, and also a run-time requirement for certain binaries that spawn scripts interpreted with execlineb.
  • @@ -101,7 +102,7 @@
  • If you're using musl and want nsswitch-like functionality: nsss version -0.1.0.0 or later (build-time and boot-time)
  • +0.2.0.0 or later (build-time and boot-time)

    Licensing

    @@ -114,7 +115,7 @@

    Download

    Definitions

    @@ -346,8 +350,8 @@
    • s6 is discussed on the -supervision mailing-list.
    • -
    • There is a #s6 IRC channel on Freenode. Sometimes people are there +supervision mailing-list.
    • +
    • There is a #s6 IRC channel on OFTC. Sometimes people are there and answer questions.
    @@ -373,6 +377,10 @@

    Other init systems

    +

    + (This list hasn't been updated in a long while. I'm keeping it for reference.) +

    +
    • Felix von Leitner's minit is an init system for Linux, with process supervision capabilities.
    • @@ -385,8 +393,8 @@
    • sysvinit is the traditional init system for Linux.
    • Upstart is a well-known init system -for Linux, with complete service management, that comes with the Ubuntu -distribution. It includes a coffee machine and the kitchen sink.
    • +for Linux, with complete service management, that came with earlier versions of the Ubuntu +distribution. It is now deprecated.
    • systemd is a problem in its own category.
    • The various BSD flavors have their own style of init.
    • diff -Nru s6-2.10.0.2/doc/libs6/fdholder.html s6-2.11.0.0/doc/libs6/fdholder.html --- s6-2.10.0.2/doc/libs6/fdholder.html 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/doc/libs6/fdholder.html 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,229 @@ + + + + + + s6: the s6-fdholder library interface + + + + + + +

      +libs6
      +s6
      +Software
      +skarnet.org +

      + +

      The fdholder library interface

      + +

      + The fdholder library provides an API for clients +wanting to communicate with a +s6-fdholderd daemon. +

      + +

      Programming

      + +

      + Check the s6/fdholder.h header for the +exact function prototypes. +

      + +

      A programming example

      + +

      + The src/fdholder/s6-fdholder-*.c files in the s6 package, +for instance, illustrate how to use the fdholder library. +

      + +

      Synchronous functions with a specified maximum execution time

      + +

      + The explanation given +there applies here too: the +functions documented in this page are synchronous, but can return +early if the deadline is reached, in which case the connection to the +server should be closed immediately because no protocol consistency is +guaranteed. +

      + +

      + The s6-fdholderd server should be +very quick to answer queries, so this mechanism is provided as a simple +security against programming errors - for instance, connecting to the +wrong daemon. +

      + +

      Starting and ending a session

      + +
      +s6_fdholder_t a = S6_FDHOLDER_ZERO ;
      +int fd = 6 ;
      +
      +tain_now_g() ;
      +
      +s6_fdholder_init(&a, fd) ;
      +(...)
      +s6_fdholder_free(&a) ;
      +
      + +

      +s6_fdholder_init assumes that fd is a socket already +connected to an s6-fdholderd daemon. The a structure must be +initialized to S6_FDHOLDER_ZERO before use. +

      + +

      +tain_now_g() +initializes a global variable that keeps track of the current time, for +use with later functions. +

      + +

      +s6_fdholder_free frees the resources occupied by a. +It does not, however, close fd. You should manually close it +to end the connection to the server. Note that if your program has been +started by s6-ipcclient, both fds 6 +and 7 are open (and refer to the same socket), so you should close both. +

      + +

      + Alternatively, if your connection to s6-fdholderd has not been created yet, +you can use the following functions: +

      + +

      int s6_fdholder_start (s6_fdholder_t *a, char const *path, tain_t const *deadline, tain_t *stamp)

      + +

      + Starts a session with a s6-fdholderd +instance listening on path. a must be initialized to +S6_FDHOLDER_ZERO before calling this function. On success, returns nonzero +and a can be used as a handle for the next s6_fdholder_* +function calls. On failure, returns 0, and sets errno. +

      + +

      void s6_fdholder_end (s6_fdholder_t *a)

      + +

      + Ends the current session and frees all allocated resources. If needed, +a is immediately reusable for another s6_fdholder_start call. +

      + +

      Storing a fd

      + +
      +int r ;
      +int fd ;
      +tain_t limit = TAIN_INFINITE ;
      +char const *id = "my_identifier" ;
      +r = s6_fdholder_store_g(&a, fd, id, &limit, &deadline) ;
      +
      + +

      +s6_fdholder_store (and its variant s6_fdholder_store_g +that uses the global timestamp variable) attempts to store a copy of +descriptor fd into s6-fdholderd, using identifier id, +with an expiration date of limit. In this example, limit +is TAIN_INFINITE, which means no expiration date. The operation should +return before deadline, else it will automatically return +0 ETIMEDOUT. The result is 1 on success and 0 on failure, with an +appropriate errno code. +

      + +

      Deleting a fd

      + +
      +fd = s6_fdholder_delete_g(&a, id, &deadline) ;
      +
      + +

      +s6_fdholder_delete attempts to delete the file descriptor +identified by id. It returns 1 on success and 0 on failure, +with an +appropriate errno code. +

      + +

      Retrieving a fd

      + +
      +fd = s6_fdholder_retrieve_g(&a, id, &deadline) ;
      +
      + +

      +s6_fdholder_retrieve attempts to retrieve the file descriptor +identified by id. It returns a valid fd number on success, and +-1 on failure, with an +appropriate errno code. +

      + +

      + s6_fdholder_retrieve_delete() performs a retrieval and a +deletion at the same time, if the client is authorized to do so. +

      + +

      Listing the identifiers held by the server

      + +
      +stralloc list = STRALLOC_ZERO ;
      +int n ;
      +n = s6_fdholder_list_g(&a, &list, &deadline) ;
      +
      + +

      +s6_fdholder_list gets the list of all identifiers currently +held by the server. It stores it into the +stralloc +list, as a series of null-terminated strings, one after the other. +There are n such strings. The function returns n on +success, or -1 on failure, with an +appropriate errno code. +

      + + +

      Reading a dump

      + +
      +genalloc dump = GENALLOC_ZERO ;
      +r = s6_fdholder_getdump_g(&a, &dump, &deadline) ;
      +
      + +

      +s6_fdholder_getdump attempts to retrieve the whole set of +descriptors from the server. +It returns 1 on success, and 0 on failure, with an +appropriate errno code. +The set is stored into the +genalloc +dump, which is to be interpreted as a stralloc containing an array +of s6_fdholder_fd_t. +

      + +

      +genalloc_s(s6_fdholder_fd_t, &dump) is a pointer to this array, and +genalloc_len(s6_fdholder_fd_t, &dump) is the number of elements +in the array. A s6_fdholder_fd_t contains at least a descriptor +number, an identifier, and an expiration date, see the +s6/fdholder.h header file. +

      + +

      Writing a dump

      + +
      +unsigned int dumplen ;
      +s6_fdholder_fd_t const *dumparray ;
      +r = s6_fdholder_setdump_g(&a, &dumparray, dumplen, &deadline) ;
      +
      + +

      +s6_fdholder_setdump attempts to send a set of descriptors to the +server. The descriptors are contained in the array dumparray of +length dumplen. The function +returns 1 on success, and 0 on failure, with an +appropriate errno code. +

      + + + diff -Nru s6-2.10.0.2/doc/libs6/index.html s6-2.11.0.0/doc/libs6/index.html --- s6-2.10.0.2/doc/libs6/index.html 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/doc/libs6/index.html 2021-09-26 14:04:15.000000000 +0000 @@ -65,9 +65,9 @@ functions to subscribe to fifodirs and be notified of events.
    • The s6/ftrigw.h header provides functions to manage fifodirs and send notifications to them.
    • -
    • The s6/s6lock.h header provides +
    • The s6/lock.h header provides functions to acquire locks with a timeout.
    • -
    • The s6/s6-fdholder.h header provides +
    • The s6/fdholder.h header provides functions to communicate with a s6-fdholderd server and exchange file descriptors with it.
    • diff -Nru s6-2.10.0.2/doc/libs6/lock.html s6-2.11.0.0/doc/libs6/lock.html --- s6-2.10.0.2/doc/libs6/lock.html 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/doc/libs6/lock.html 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,239 @@ + + + + + + s6: the s6lock library interface + + + + + + +

      +libs6
      +s6
      +Software
      +skarnet.org +

      + +

      The s6lock library interface

      + +

      General information

      + +

      + s6lock is a C interface to timed locks. Unix natively provides +locks, but the locking primitives are synchronous, so either they are +unbounded in execution time or they require polling. s6lock provides +poll-free locks that can timeout during attempted acquisition. +

      + +

      Programming

      + +
        +
      • Check the s6/lock.h header +for the prototypes. The functions documented here are +often simplified macros, for instance relying on the STAMP global variable +to hold the current time. Fully reentrant functions with more control +options are usually available.
      • +
      • Given the nature of the s6lock library, it makes sense to use a +s6lockd service concurrently +accessed by several applications using such locks to gate shared +resources.
      • +
      • If you're not using an s6lockd service, +make sure your application is not disturbed by children it doesn't +know it has. Using nonblocking waits, ignoring pids you don't know, and +using a +self-pipe +if your application is built around an event loop, are good programming +practices.
      • +
      + +

      Starting and ending a session

      + +
      +s6lock_t a = S6LOCK_ZERO ;
      +tain_t deadline ;
      +
      +tain_now_g() ;
      +tain_addsec_g(&deadline, 2)
      +
      +char const *path = S6LOCK_IPCPATH ;
      +s6lock_start_g(&a, path, &deadline) ;
      +// char const *lockdir = "/tmp/lock" ;
      +// s6lock_startf_g(&a, lockdir, &deadline) ;
      +
      + +

      +s6lock_start_g starts a session by connecting to an s6lockd service +listening on path. The working directory is set by the administrator +of the service.
      +s6lock_startf_g starts a session with an s6lockd process as a child, +using lockdir as its working directory. +
      +a is an s6lock_t structure that must be declared in the stack and +initialized to S6LOCK_ZERO. +If the session initialization fails, the function returns 0 and errno is set; +else the function returns 1. +

      +

      +If the absolute time deadline is reached and the function +has not returned yet, it immediately returns 0 with errno set to ETIMEDOUT. + +Only local interprocess communications are involved; unless your system is +heavily overloaded, the function should return near-instantly. One or two +seconds of delay between the current time and deadline should be +enough: if the function takes more than that to return, then there is a +problem with the underlying processes. +

      + +

      + You can have more than one session open in parallel, by declaring +several distinct s6lock_t structures and calling +s6lock_startf_g (or s6lock_start_g) more than once. +However, one single session can handle +virtually as many concurrent locks as your application needs, so +opening several sessions is only useful if you need to acquire locks +in various distinct lock directories. +

      + +
      +s6lock_end(&a) ;
      +
      + +

      +s6lock_end frees all the resources used by the session. The +a structure is then reusable for another session. +

      + +

      Acquiring and releasing locks

      + +
      +uint16_t id ;
      +char const *file = "lockfile" ;
      +tain_t limit ;
      +tain_t deadline ;
      +
      +int r = s6lock_acquire_sh_g (&a, &id, file, &limit, &deadline) ;
      +/* int r = s6lock_acquire_ex_g (&a, &id, file, &limit, &deadline) ; */
      +r = s6lock_release_g(&a, id, &deadline) ;
      +
      + +

      +s6lock_acquire_sh_g instructs the +s6lockd daemon, related to the open +session represented by the a handle, to try and acquire a +shared lock on the +file file located under that daemon's working directory +(typically /var/lock). file will be interpreted as +relative to the daemon's working directory even if it starts with a +slash; however, slashes in the middle of file are likely to +result in an error. +

      + +

      +limit and deadline are two absolute dates. +deadline is a deadline for the execution of the +function: if by deadline the function has not returned, +then it instantly returns 0 and sets errno to ETIMEDOUT. The +function is normally near-instantaneous, so deadline can +be very close in the future and serves only as a protection against +malicious servers. limit is the acquisition deadline: if +by limit the daemon still has not been able to acquire a lock +on file, then it will report a timeout to the client. +

      + +

      +The function returns 1 in case of success, or 0 if an error occurs, +with errno set to a suitable value. If it succeeds, then a 16-bit +number is stored into *id; this number serves as an identifier +for this lock. +

      + +

      +s6lock_acquire_ex_g works just like s6lock_acquire_sh_g, +except that the daemon tries to acquire an exclusive lock. +

      + +

      +s6lock_release_g releases the lock identified by id. +It normally returns 1. It can return 0 with errno set to a suitable +value if it fails. id is not valid after the corresponding +lock has been released. The function normally returns instantly, with +deadline as a safeguard. +

      + +

      Asynchronously waiting for locks

      + +

      + (from now on, the functions are listed with their prototypes instead +of usage examples.) +

      + +
      +int s6lock_fd (s6lock_t const *a)
      +
      + +

      + Returns a file descriptor to select on for reading. Do not +read() it though. +

      + +
      +int s6lock_update (s6lock_t *a)
      +
      + +

      + Call this function whenever the fd checks readability: it will +update a's internal structures with information from the +s6lockd daemon. It returns -1 if an error +occurs; in case of success, it returns the number of identifiers for +which something happened. +

      + +

      + When s6lock_update returns, +genalloc_s(uint16_t, &a->list) points to an array of +genalloc_len(uint16_t, &a->list) 16-bit unsigned +integers. Those integers are ids waiting to be passed to +s6lock_check. +

      + +
      +int s6lock_check (s6lock_t *a, uint16_t id, char *what)
      +
      + +

      + Checks whether the lock identified by id has +been acquired. Use after a call to s6lock_update(). +

      + +
        +
      • If an error occurred, returns -1 and sets errno. The error +number may have been transmitted from +s6lockd.
      • +
      • If the lock has not been acquired yet, returns 0.
      • +
      • If the lock has been acquired, returns 1.
      • +
      + +

      Synchronously waiting for locks

      + +

      + int s6lock_wait_or_g (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain_t const *deadline)
      +Synchronously waits for one of the locks represented by the array pointed to +by idlist of length n to be acquired. Returns -1 if it fails, +or a nonnegative number on success, which is the index in idlist of the +acquired lock's id. If no result has been obtained by deadline, the +function returns -1 ETIMEDOUT. +

      + +

      + int s6lock_wait_and_g (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain_t const *deadline)
      +Synchronously waits for all of the locks represented by the array pointed to +by idlist of length n to be acquired. Returns -1 if it fails and +0 if it succeeds. If no result has been obtained by deadline, the +function returns -1 ETIMEDOUT. +

      + + + diff -Nru s6-2.10.0.2/doc/libs6/s6-fdholder.html s6-2.11.0.0/doc/libs6/s6-fdholder.html --- s6-2.10.0.2/doc/libs6/s6-fdholder.html 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/doc/libs6/s6-fdholder.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,229 +0,0 @@ - - - - - - s6: the s6-fdholder library interface - - - - - - -

      -libs6
      -s6
      -Software
      -skarnet.org -

      - -

      The s6-fdholder library interface

      - -

      - The s6-fdholder library provides an API for clients -wanting to communicate with a -s6-fdholderd daemon. -

      - -

      Programming

      - -

      - Check the s6/s6-fdholder.h header for the -exact function prototypes. -

      - -

      A programming example

      - -

      - The src/fdholder/s6-fdholder-*.c files in the s6 package, -for instance, illustrate how to use the s6-fdholder library. -

      - -

      Synchronous functions with a specified maximum execution time

      - -

      - The explanation given -there applies here too: the -functions documented in this page are synchronous, but can return -early if the deadline is reached, in which case the connection to the -server should be closed immediately because no protocol consistency is -guaranteed. -

      - -

      - The s6-fdholderd server should be -very quick to answer queries, so this mechanism is provided as a simple -security against programming errors - for instance, connecting to the -wrong daemon. -

      - -

      Starting and ending a session

      - -
      -s6_fdholder_t a = S6_FDHOLDER_ZERO ;
      -int fd = 6 ;
      -
      -tain_now_g() ;
      -
      -s6_fdholder_init(&a, fd) ;
      -(...)
      -s6_fdholder_free(&a) ;
      -
      - -

      -s6_fdholder_init assumes that fd is a socket already -connected to an s6-fdholderd daemon. The a structure must be -initialized to S6_FDHOLDER_ZERO before use. -

      - -

      -tain_now_g() -initializes a global variable that keeps track of the current time, for -use with later functions. -

      - -

      -s6_fdholder_free frees the resources occupied by a. -It does not, however, close fd. You should manually close it -to end the connection to the server. Note that if your program has been -started by s6-ipcclient, both fds 6 -and 7 are open (and refer to the same socket), so you should close both. -

      - -

      - Alternatively, if your connection to s6-fdholderd has not been created yet, -you can use the following functions: -

      - -

      int s6_fdholder_start (s6_fdholder_t *a, char const *path, tain_t const *deadline, tain_t *stamp)

      - -

      - Starts a session with a s6-fdholderd -instance listening on path. a must be initialized to -S6_FDHOLDER_ZERO before calling this function. On success, returns nonzero -and a can be used as a handle for the next s6_fdholder_* -function calls. On failure, returns 0, and sets errno. -

      - -

      void s6_fdholder_end (s6_fdholder_t *a)

      - -

      - Ends the current session and frees all allocated resources. If needed, -a is immediately reusable for another s6_fdholder_start call. -

      - -

      Storing a fd

      - -
      -int r ;
      -int fd ;
      -tain_t limit = TAIN_INFINITE ;
      -char const *id = "my_identifier" ;
      -r = s6_fdholder_store_g(&a, fd, id, &limit, &deadline) ;
      -
      - -

      -s6_fdholder_store (and its variant s6_fdholder_store_g -that uses the global timestamp variable) attempts to store a copy of -descriptor fd into s6-fdholderd, using identifier id, -with an expiration date of limit. In this example, limit -is TAIN_INFINITE, which means no expiration date. The operation should -return before deadline, else it will automatically return -0 ETIMEDOUT. The result is 1 on success and 0 on failure, with an -appropriate errno code. -

      - -

      Deleting a fd

      - -
      -fd = s6_fdholder_delete_g(&a, id, &deadline) ;
      -
      - -

      -s6_fdholder_delete attempts to delete the file descriptor -identified by id. It returns 1 on success and 0 on failure, -with an -appropriate errno code. -

      - -

      Retrieving a fd

      - -
      -fd = s6_fdholder_retrieve_g(&a, id, &deadline) ;
      -
      - -

      -s6_fdholder_retrieve attempts to retrieve the file descriptor -identified by id. It returns a valid fd number on success, and --1 on failure, with an -appropriate errno code. -

      - -

      - s6_fdholder_retrieve_delete() performs a retrieval and a -deletion at the same time, if the client is authorized to do so. -

      - -

      Listing the identifiers held by the server

      - -
      -stralloc list = STRALLOC_ZERO ;
      -int n ;
      -n = s6_fdholder_list_g(&a, &list, &deadline) ;
      -
      - -

      -s6_fdholder_list gets the list of all identifiers currently -held by the server. It stores it into the -stralloc -list, as a series of null-terminated strings, one after the other. -There are n such strings. The function returns n on -success, or -1 on failure, with an -appropriate errno code. -

      - - -

      Reading a dump

      - -
      -genalloc dump = GENALLOC_ZERO ;
      -r = s6_fdholder_getdump_g(&a, &dump, &deadline) ;
      -
      - -

      -s6_fdholder_getdump attempts to retrieve the whole set of -descriptors from the server. -It returns 1 on success, and 0 on failure, with an -appropriate errno code. -The set is stored into the -genalloc -dump, which is to be interpreted as a stralloc containing an array -of s6_fdholder_fd_t. -

      - -

      -genalloc_s(s6_fdholder_fd_t, &dump) is a pointer to this array, and -genalloc_len(s6_fdholder_fd_t, &dump) is the number of elements -in the array. A s6_fdholder_fd_t contains at least a descriptor -number, an identifier, and an expiration date, see the -s6/s6-fdholder.h header file. -

      - -

      Writing a dump

      - -
      -unsigned int dumplen ;
      -s6_fdholder_fd_t const *dumparray ;
      -r = s6_fdholder_setdump_g(&a, &dumparray, dumplen, &deadline) ;
      -
      - -

      -s6_fdholder_setdump attempts to send a set of descriptors to the -server. The descriptors are contained in the array dumparray of -length dumplen. The function -returns 1 on success, and 0 on failure, with an -appropriate errno code. -

      - - - diff -Nru s6-2.10.0.2/doc/libs6/s6lock.html s6-2.11.0.0/doc/libs6/s6lock.html --- s6-2.10.0.2/doc/libs6/s6lock.html 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/doc/libs6/s6lock.html 1970-01-01 00:00:00.000000000 +0000 @@ -1,239 +0,0 @@ - - - - - - s6: the s6lock library interface - - - - - - -

      -libs6
      -s6
      -Software
      -skarnet.org -

      - -

      The s6lock library interface

      - -

      General information

      - -

      - s6lock is a C interface to timed locks. Unix natively provides -locks, but the locking primitives are synchronous, so either they are -unbounded in execution time or they require polling. s6lock provides -poll-free locks that can timeout during attempted acquisition. -

      - -

      Programming

      - -
        -
      • Check the s6/s6lock.h header -for the prototypes. The functions documented here are -often simplified macros, for instance relying on the STAMP global variable -to hold the current time. Fully reentrant functions with more control -options are usually available.
      • -
      • Given the nature of the s6lock library, it makes sense to use a -s6lockd service concurrently -accessed by several applications using such locks to gate shared -resources.
      • -
      • If you're not using an s6lockd service, -make sure your application is not disturbed by children it doesn't -know it has. Using nonblocking waits, ignoring pids you don't know, and -using a -self-pipe -if your application is built around an event loop, are good programming -practices.
      • -
      - -

      Starting and ending a session

      - -
      -s6lock_t a = S6LOCK_ZERO ;
      -tain_t deadline ;
      -
      -tain_now_g() ;
      -tain_addsec_g(&deadline, 2)
      -
      -char const *path = S6LOCK_IPCPATH ;
      -s6lock_start_g(&a, path, &deadline) ;
      -// char const *lockdir = "/tmp/lock" ;
      -// s6lock_startf_g(&a, lockdir, &deadline) ;
      -
      - -

      -s6lock_start_g starts a session by connecting to an s6lockd service -listening on path. The working directory is set by the administrator -of the service.
      -s6lock_startf_g starts a session with an s6lockd process as a child, -using lockdir as its working directory. -
      -a is an s6lock_t structure that must be declared in the stack and -initialized to S6LOCK_ZERO. -If the session initialization fails, the function returns 0 and errno is set; -else the function returns 1. -

      -

      -If the absolute time deadline is reached and the function -has not returned yet, it immediately returns 0 with errno set to ETIMEDOUT. - -Only local interprocess communications are involved; unless your system is -heavily overloaded, the function should return near-instantly. One or two -seconds of delay between the current time and deadline should be -enough: if the function takes more than that to return, then there is a -problem with the underlying processes. -

      - -

      - You can have more than one session open in parallel, by declaring -several distinct s6lock_t structures and calling -s6lock_startf_g (or s6lock_start_g) more than once. -However, one single session can handle -virtually as many concurrent locks as your application needs, so -opening several sessions is only useful if you need to acquire locks -in various distinct lock directories. -

      - -
      -s6lock_end(&a) ;
      -
      - -

      -s6lock_end frees all the resources used by the session. The -a structure is then reusable for another session. -

      - -

      Acquiring and releasing locks

      - -
      -uint16_t id ;
      -char const *file = "lockfile" ;
      -tain_t limit ;
      -tain_t deadline ;
      -
      -int r = s6lock_acquire_sh_g (&a, &id, file, &limit, &deadline) ;
      -/* int r = s6lock_acquire_ex_g (&a, &id, file, &limit, &deadline) ; */
      -r = s6lock_release_g(&a, id, &deadline) ;
      -
      - -

      -s6lock_acquire_sh_g instructs the -s6lockd daemon, related to the open -session represented by the a handle, to try and acquire a -shared lock on the -file file located under that daemon's working directory -(typically /var/lock). file will be interpreted as -relative to the daemon's working directory even if it starts with a -slash; however, slashes in the middle of file are likely to -result in an error. -

      - -

      -limit and deadline are two absolute dates. -deadline is a deadline for the execution of the -function: if by deadline the function has not returned, -then it instantly returns 0 and sets errno to ETIMEDOUT. The -function is normally near-instantaneous, so deadline can -be very close in the future and serves only as a protection against -malicious servers. limit is the acquisition deadline: if -by limit the daemon still has not been able to acquire a lock -on file, then it will report a timeout to the client. -

      - -

      -The function returns 1 in case of success, or 0 if an error occurs, -with errno set to a suitable value. If it succeeds, then a 16-bit -number is stored into *id; this number serves as an identifier -for this lock. -

      - -

      -s6lock_acquire_ex_g works just like s6lock_acquire_sh_g, -except that the daemon tries to acquire an exclusive lock. -

      - -

      -s6lock_release_g releases the lock identified by id. -It normally returns 1. It can return 0 with errno set to a suitable -value if it fails. id is not valid after the corresponding -lock has been released. The function normally returns instantly, with -deadline as a safeguard. -

      - -

      Asynchronously waiting for locks

      - -

      - (from now on, the functions are listed with their prototypes instead -of usage examples.) -

      - -
      -int s6lock_fd (s6lock_t const *a)
      -
      - -

      - Returns a file descriptor to select on for reading. Do not -read() it though. -

      - -
      -int s6lock_update (s6lock_t *a)
      -
      - -

      - Call this function whenever the fd checks readability: it will -update a's internal structures with information from the -s6lockd daemon. It returns -1 if an error -occurs; in case of success, it returns the number of identifiers for -which something happened. -

      - -

      - When s6lock_update returns, -genalloc_s(uint16_t, &a->list) points to an array of -genalloc_len(uint16_t, &a->list) 16-bit unsigned -integers. Those integers are ids waiting to be passed to -s6lock_check. -

      - -
      -int s6lock_check (s6lock_t *a, uint16_t id, char *what)
      -
      - -

      - Checks whether the lock identified by id has -been acquired. Use after a call to s6lock_update(). -

      - -
        -
      • If an error occurred, returns -1 and sets errno. The error -number may have been transmitted from -s6lockd.
      • -
      • If the lock has not been acquired yet, returns 0.
      • -
      • If the lock has been acquired, returns 1.
      • -
      - -

      Synchronously waiting for locks

      - -

      - int s6lock_wait_or_g (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain_t const *deadline)
      -Synchronously waits for one of the locks represented by the array pointed to -by idlist of length n to be acquired. Returns -1 if it fails, -or a nonnegative number on success, which is the index in idlist of the -acquired lock's id. If no result has been obtained by deadline, the -function returns -1 ETIMEDOUT. -

      - -

      - int s6lock_wait_and_g (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain_t const *deadline)
      -Synchronously waits for all of the locks represented by the array pointed to -by idlist of length n to be acquired. Returns -1 if it fails and -0 if it succeeds. If no result has been obtained by deadline, the -function returns -1 ETIMEDOUT. -

      - - - diff -Nru s6-2.10.0.2/doc/overview.html s6-2.11.0.0/doc/overview.html --- s6-2.10.0.2/doc/overview.html 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/doc/overview.html 2021-09-26 14:04:15.000000000 +0000 @@ -389,7 +389,7 @@
      • s6-svstat gives you access to the detailed state of a service
      • -
      • s6-svperms allows you to configure +
      • s6-svperms allows you to configure what users can read that state, what users can send control commands to your service, and what users can be notified of service start/stop events
      • diff -Nru s6-2.10.0.2/doc/s6-ftrig-listen1.html s6-2.11.0.0/doc/s6-ftrig-listen1.html --- s6-2.10.0.2/doc/s6-ftrig-listen1.html 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/doc/s6-ftrig-listen1.html 2021-09-26 14:04:15.000000000 +0000 @@ -43,7 +43,7 @@ Extended Regular Expression.
      • When the series of read events matches regexp, -s6-ftrig-listen1 prints the last event it received (one byte) to stdout, +s6-ftrig-listen1 prints the last event it received to stdout (one byte followed by a newline), then exits 0.
      diff -Nru s6-2.10.0.2/doc/s6-ftrig-wait.html s6-2.11.0.0/doc/s6-ftrig-wait.html --- s6-2.10.0.2/doc/s6-ftrig-wait.html 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/doc/s6-ftrig-wait.html 2021-09-26 14:04:15.000000000 +0000 @@ -36,7 +36,7 @@ Extended Regular Expression.
    • When the series of read events matches regexp, -s6-ftrig-wait prints the last event it received (one byte) to stdout, +s6-ftrig-wait prints the last event it received to stdout (one byte followed by a newline), then exits 0.
    diff -Nru s6-2.10.0.2/doc/s6-ioconnect.html s6-2.11.0.0/doc/s6-ioconnect.html --- s6-2.10.0.2/doc/s6-ioconnect.html 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/doc/s6-ioconnect.html 2021-09-26 14:04:15.000000000 +0000 @@ -75,10 +75,6 @@ for testing purposes. s6-ioconnect is to s6-tcpclient as cat is to s6-tcpserver: a program that will just echo what it gets. -
  • On modern Linux systems, s6-ioconnect will perform zero-copy -data transmission, via the -splice -system call.
  • The s6-ioconnect utility was once part of the s6-networking suite, which is why the diff -Nru s6-2.10.0.2/doc/s6-log.html s6-2.11.0.0/doc/s6-log.html --- s6-2.10.0.2/doc/s6-log.html 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/doc/s6-log.html 2021-09-26 14:04:15.000000000 +0000 @@ -27,7 +27,7 @@

    Interface

    -     s6-log [ -d notif ] [ -q | -v ] [ -b ] [ -p ] [ -l linelimit ] logging script
    +     s6-log [ -d notif ] [ -q | -v ] [ -b ] [ -p ] [ -l linelimit ] [ -- ] logging script
     

    diff -Nru s6-2.10.0.2/doc/s6-socklog.html s6-2.11.0.0/doc/s6-socklog.html --- s6-2.10.0.2/doc/s6-socklog.html 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/doc/s6-socklog.html 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,151 @@ + + + + + + s6: the s6-socklog program + + + + + + +

    +s6
    +Software
    +skarnet.org +

    + +

    The s6-socklog program

    + +

    +s6-socklog is a minimal syslog daemon. It reads datagrams +from the /dev/log Unix domain socket, or from a Unix domain +or Internet domain socket of the user's choice, converts the encoded +syslog facility and priority names to their human-readable equivalents, +and prints the logs to its stdout. +

    + +

    +s6-socklog is a reimplementation of the +socklog program +with a few more features. +

    + +

    Interface

    + +
    +     s6-socklog [ -d notif ] [ -r ] [ -U | -u uid -g gid -G gidlist ] [ -l linelen ] [ -t lameducktimeout ] [ -x unixsocket | -i ipport ]
    +
    + +
      +
    • s6-socklog binds to /dev/log.
    • +
    • It drops its root privileges.
    • +
    • For every datagram it reads, it turns its content into a log line: +
        +
      • Messages are truncated to 1024 characters
      • +
      • Trailing nulls or newlines are removed
      • +
      • Embedded nulls or newlines are converted to ~ characters (tildes)
      • +
      • A <syslogcode> at the beginning of the line is converted to facility.priority:
      • +
    • +
    • It prints the log line to its stdout, terminated by a newline.
    • +
    • It exits 0 on a SIGTERM.
    • +
    + +

    Exit codes

    + +
      +
    • 0: SIGTERM received, clean exit
    • +
    • 99: SIGTERM received but the buffer could not be flushed in time, some logs may be lost
    • +
    • 100: wrong usage
    • +
    • 111: system call failed
    • +
    + +

    Signals

    + +

    + s6-socklog reacts to the following signals: +

    + +
      +
    • SIGTERM: exit as soon as possible
    • +
    + +

    Options

    + +
      +
    • -r : raw logging. <syslogcode> codes +will not be converted to facility/priority names.
    • +
    • -d notif : when ready +(actually bound to its socket), +write a newline to file descriptor notif then close it. +This allows s6-socklog to use the s6 +mechanism to notify readiness. notif cannot be less than 3. +If this option is not given, no readiness notification is sent.
    • +
    • -u uid : drop user id to uid
    • +
    • -g gid : drop group id to gid
    • +
    • -G gidlist : set supplementary group list +to gidlist, which must be given as a comma-separated list of numeric gids, +without spaces.
    • +
    • -U : set user id, group id and supplementary group list +to the values of the UID, GID and GIDLIST environment variables. If a -u, +-g or -G option is given after -U, the command line +value overrides the environment variable.
    • +
    • -l linelen : Set the maximum datagram size to +linelen. Default is 1024. It cannot be set to less than 76 or more than +1048576. If a datagram is bigger than linelen, it will be truncated to +linelen characters, and the logged line will end with a ... ellipsis +to show the truncation.
    • +
    • -t lameducktimeout : on receipt of a SIGTERM, give +s6-socklog a grace period of lameducktimeout milliseconds to +flush any log lines that are still in its buffer. Default is 0, which means +infinite: the program will only exit when its buffer is empty, and may wait +forever. If lameducktimeout is nonzero and the timeout expires, the +program will exit 99.
    • +
    • -x unixsocket : bind to a Unix domain socket +at unixsocket. Default is /dev/log.
    • +
    • -i ipport : bind to a UDP socket. ipport +is a combination of ip, which must be an IPv4 or IPv6 address, and +port, which must be an integer. port may be omitted, in which +case it defaults to 514. If port is given, ip and port +must be separated by a _ character (an underscore). If ip is +IPv4, a : (colon) can be used instead of an underscore. When this +option is used, s6-socklog will prepend every log line with +clientip_clientport: , clientip and +clientport being the IP address and port of the client that sent +the log datagram.
    • +
    + +

    Typical use

    + +

    + s6-socklog can be paired with s6-log to +implement syslogd functionality. s6-socklog acts as the +frontend: it reads the log lines and processes them, then pipes them +to an s6-log instance that acts as the backend, +i.e. sorts the log lines depending on regular expressions that typically involve +the facility and priority names, then stores them into the filesystem. +

    + +

    + The pipe between s6-socklog and s6-log is +typically a logging pipe automatically provided by +s6-svscan when the s6-log instance is declared as +a logger service for the s6-socklog instance. +

    + +

    + The examples/ subdirectory of the s6 package contains a turnkey +syslogd service that implements this pattern. +

    + +

    Notes

    + +
      +
    • s6-socklog cannot be used under s6-ipcserver +or another super-server. It does not implement the socklog ucspi functionality, +which is provided by the ucspilogd program instead.
    • +
    + + + diff -Nru s6-2.10.0.2/doc/s6-svlink.html s6-2.11.0.0/doc/s6-svlink.html --- s6-2.10.0.2/doc/s6-svlink.html 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/doc/s6-svlink.html 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,117 @@ + + + + + + s6: the s6-svlink program + + + + + + +

    +s6
    +Software
    +skarnet.org +

    + +

    The s6-svlink program

    + +

    + s6-svlink creates, in a scan +directory, a symlink to a service +directory, and notifies s6-svscan +that a new service has been registered. It waits until a +s6-supervise supervisor process has +been spawned to manage the new service, then exits. +

    + +

    + The point of s6-svlink is to help integrate +service directories into an existing service manager sequence and +eliminate race conditions. +

    + +

    Interface

    + +
    +     s6-svlink [ -d | -D ] [ -P ] [ -f ] [ -t timeout ] scandir servicedir [ name ]
    +
    + +
      +
    • s6-svlink expects a running s6-svscan +process on scandir and a fully functional, but unsupervised, +service directory in servicedir.
    • +
    • It symlinks servicedir into scandir. The symbolic link +is named name; if no name argument has been given, the name given +to the symbolic link is the basename of servicedir.
    • +
    • It sends a command to s6-svscan to signal it +that a new service is available.
    • +
    • It waits for an s6-supervise process to be +spawned on servicedir.
    • +
    • It exits 0.
    • +
    + +

    Exit codes

    + +
      +
    • 0: success
    • +
    • 99: timeout while waiting for the supervisor to start
    • +
    • 100: wrong usage
    • +
    • 111: system call failed
    • +
    + +

    Options

    + +
      +
    • -d : down. The supervisor will be started, but the service +itself will remain down. Any servicedir/down file will be +deleted. By default, if neither the -d nor -D options have +been given, the supervisor auto-starts the service as soon as it runs.
    • +
    • -D : down, and stay down. The supervisor will be started, +but the service itself will remain down. A servicedir/down file +will be created. By default, if neither the -d nor -D options have +been given, the supervisor auto-starts the service as soon as it runs.
    • +
    • -P : public. If servicedir/event does not +exist, it will be created as public, i.e. anyone will be able to subscribe to +this fifodir. By default, it will be created as private, +i.e. only processes running with the same gid as the s6-svscan +process will be able to susbscribe to it.
    • +
    • -f : force permissions. The presence or absence of the -P +option (i.e. the public or private state of servicedir/event) will be +enforced even if servicedir/event already exists. By default, +s6-svlink exits with an error message if servicedir/event +exists and its public/private state mismatches what is requested.
    • +
    • -t timeout : if the supervisor has not started +after timeout milliseconds, s6-svlink will print a message +to stderr and exit 99. By default, timeout is 0, which means no time +limit.
    • +
    + +

    Notes

    + +
      +
    • Using s6-svlink to start services is a suboptimal pattern: it +requires precise manipulations involving use of s6-ftrigrd +in order to avoid race conditions, so it is relatively expensive. The simpler, +more efficient pattern is to have all the supervisors already started at boot +time, so the existence of the supervisor can be relied on, and starting the +service becomes a trival and instant operation - this is, for instance, how +the s6-rc service manager behaves. +However, it can be difficult to implement this pattern with other services +managers such as OpenRC; in those cases, s6-svlink, which starts the +supervisors one at a time, can be used instead.
    • +
    • If servicedir is logged, i.e. servicedir/log +is also a valid service directory, then s6-svlink will wait until +supervisors have been spawned for both the service and its logger.
    • +
    • s6-svlink sends an s6-svscanctl -a +command to scandir, which means that the system's view of services +will be refreshed. Depending on what links exist in scandir, other +services than servicedir may also appear.
    • +
    • The symmetrical program to s6-svlink is named +s6-svunlink.
    • +
    + + + diff -Nru s6-2.10.0.2/doc/s6-svunlink.html s6-2.11.0.0/doc/s6-svunlink.html --- s6-2.10.0.2/doc/s6-svunlink.html 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/doc/s6-svunlink.html 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,95 @@ + + + + + + s6: the s6-svunlink program + + + + + + +

    +s6
    +Software
    +skarnet.org +

    + +

    The s6-svunlink program

    + +

    + s6-svunlink unlinks a service +directory from a scan directory, then +notifies s6-svscan that a service has +been unregistered. It waits until the s6-supervise +supervisor process managing the service has disappeared, then exits. +

    + +

    + The point of s6-svunlink is to help integrate +service directories into an existing service manager sequence and +eliminate race conditions. +

    + +

    Interface

    + +
    +     s6-svunlink [ -X ] [ -t timeout ] scandir name
    +
    + +
      +
    • s6-svunlink expects a running s6-svscan +process on scandir and a fully functional supervised service on +service directory in scandir/name, +which must be a symbolic link to a real directory located somewhere else.
    • +
    • It deletes the scandir/name symlink.
    • +
    • It sends a command to s6-svscan to signal it +that a service has disappeared.
    • +
    • It waits for the s6-supervise process +managing the service directory to exit.
    • +
    • It exits 0.
    • +
    + +

    Exit codes

    + +
      +
    • 0: success
    • +
    • 100: wrong usage
    • +
    • 111: system call failed
    • +
    + +

    Options

    + +
      +
    • -X : don't wait. s6-svunlink will exit right +away, without waiting for the supervisor to exit first.
    • +
    • -t timeout : if the supervisor has not exited +after timeout milliseconds, s6-svunlink will still exit. +The default is 0, meaning no time limit.
    • +
    + +

    Notes

    + +
      +
    • Using s6-svunlink to stop services is a suboptimal pattern: +starting and stopping supervisors is a heavier operation than just stopping +services. The simpler, more efficient pattern is to simply perform +s6-svc -dwD scandir/name, +which only commands, and waits for, the death of the service, without +impacting the supervisor. Nevertheless, for symmetry with +s6-svlink, this program is provided.
    • +
    • s6-svunlink is a destructor; as is, it returns 0 even in +situations that are nominal failures. For instance, it returns 0 even +if its timeout expires; the rationale is that there is no sensible action +for the user to do if this error is reported. s6-svunlink only +reports errors when they uncover a deeper problem in the system.
    • +
    • s6-svunlink sends an s6-svscanctl -an +command to scandir, which means that the system's view of services +will be refreshed and inactive services will be killed and unsupervised. +Depending on what links exist in scandir, new +services may appear, and other services than name may disappear.
    • +
    + + + diff -Nru s6-2.10.0.2/doc/s6-svwait.html s6-2.11.0.0/doc/s6-svwait.html --- s6-2.10.0.2/doc/s6-svwait.html 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/doc/s6-svwait.html 2021-09-26 14:04:15.000000000 +0000 @@ -29,7 +29,7 @@

    Interface

    -     s6-svwait [ -U | -u | -D | -d ] [ -a | -o ] [ -t timeout ] servicedir...
    +     s6-svwait [ -U | -u | -D | -d | -r | -R ] [ -a | -o ] [ -t timeout ] servicedir...
     

    @@ -70,6 +70,15 @@ servicedir/finish for every servicedir have finished executing (or have timed out and been killed).

  • +
  • -r : restart. s6-svwait will wait until the services +are down, then until they are up. If the -o option is given, it +waits until all services are down and one service is up; +otherwise it waits until all the services have restarted.
  • +
  • -R : restart and ready.. s6-svwait will wait until the services +are down, then until they are up and ready. If the -o option is given, it +waits until all services are down and one service is up and +ready; otherwise it waits until all the services have restarted and +are ready.
  • -o : or. s6-svwait will wait until one of the given services comes up or down.
  • -a : and. s6-svwait will wait until all of the diff -Nru s6-2.10.0.2/doc/servicedir.html s6-2.11.0.0/doc/servicedir.html --- s6-2.10.0.2/doc/servicedir.html 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/doc/servicedir.html 2021-09-26 14:04:15.000000000 +0000 @@ -94,6 +94,7 @@ daemon. That process must not "background itself": being run by a supervision tree already makes it a "background" task.
  • +
  • An optional executable file named finish. Like run, it can be any executable file. This finish script, if present, is executed everytime the run script dies. Generally, its main @@ -118,14 +119,17 @@ invocation of finish will (obviously) be the last, and it will run with stdin and stdout pointing to /dev/null.
  • +
  • A directory named supervise. It is automatically created by s6-supervise if it does not exist. This is where s6-supervise stores its information. The directory must be writable.
  • +
  • An optional, empty, regular file named down. If such a file exists, the default state of the service is considered down, not up: s6-supervise will not automatically start it until it receives a s6-svc -u command. If no down file exists, the default state of the service is up.
  • +
  • An optional regular file named notification-fd. If such a file exists, it means that the service supports readiness notification. The file must only @@ -140,6 +144,20 @@ s6-svlisten1 -U or s6-svlisten -U processes will be triggered.
  • + +
  • An optional regular file named lock-fd. If such a file +exists, it must contain an unsigned integer, representing a file descriptor that +will be open in the service. The service should not write to that descriptor +and should not close it. In other words, it should totally ignore it. That +file descriptor holds a lock, that will naturally be released when the service dies. +The point of this feature is to prevent s6-supervise from accidentally spawning several +copies of the service in case something goes wrong: for instance, the service +backgrounds itself (which it shouldn't do when running under a supervision suite), or +s6-supervise is killed, restarted by s6-svscan, and attempts to start another copy of +the service while the first copy is still alive. If s6-supervise detects that the lock +is held when it tries to start the service, it will print a warning message and delay +the starting attempt for 60 seconds.
  • +
  • An optional regular file named timeout-kill. If such a file exists, it must only contain an unsigned integer t. If t is nonzero, then on receipt of an s6-svc -d command, @@ -150,12 +168,14 @@ exist, or contains 0 or an invalid value, then the service is never forcibly killed (unless, of course, an s6-svc -k command is sent).
  • +
  • An optional regular file named timeout-finish. If such a file exists, it must only contain an unsigned integer, which is the number of milliseconds after which the ./finish script, if it exists, will be killed with a SIGKILL. The default is 5000: finish scripts are killed if they're still alive after 5 seconds. A value of 0 allows finish scripts to run forever.
  • +
  • An optional regular file named max-death-tally. If such a file exists, it must only contain an unsigned integer, which is the maximum number of service death events that s6-supervise will keep track of. If the service dies @@ -163,16 +183,19 @@ death events is useful, for instance, when throttling service restarts. The value cannot be greater than 4096. If the file does not exist, a default of 100 is used.
  • +
  • An optional regular file named down-signal. If such a file exists, it must only contain the name or number of a signal, followed by a newline. This signal will be used to kill the supervised process when a s6-svc -d or s6-svc -r command is used. If the file does not exist, SIGTERM will be used by default.
  • +
  • A fifodir named event. It is automatically created by s6-supervise if it does not exist. foo/event is the rendez-vous point for listeners, where s6-supervise will send notifications when the service goes up or down.
  • +
  • An optional service directory named log. If it exists and foo is in a scandir, and s6-svscan runs on that scandir, then two services are monitored: foo and diff -Nru s6-2.10.0.2/doc/upgrade.html s6-2.11.0.0/doc/upgrade.html --- s6-2.10.0.2/doc/upgrade.html 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/doc/upgrade.html 2021-09-26 14:04:15.000000000 +0000 @@ -18,6 +18,33 @@

    What has changed in s6

    +

    in 2.11.0.0

    + +
      +
    • skalibs +dependency bumped to 2.11.0.0.
    • +
    • nsss +optional dependency bumped to 0.2.0.0.
    • +
    • execline +optional dependency bumped to 2.8.1.0.
    • +
    • s6-svwait now supports the +-r and -R options, to wait for service restarts.
    • +
    • The s6/lock.h, s6/supervise.h and s6/fdholder.h +headers replace their previous versions that had an extra s6 prefix.
    • +
    • New binaries: s6-svlink, +s6-svunlink, and +s6-socklog.
    • +
    + +

    in 2.10.0.3

    + +
      +
    • skalibs +dependency bumped to 2.10.0.3.
    • +
    • execline +dependency bumped to 2.8.0.1.
    • +
    +

    in 2.10.0.2

      diff -Nru s6-2.10.0.2/examples/klogd-linux/log/run s6-2.11.0.0/examples/klogd-linux/log/run --- s6-2.10.0.2/examples/klogd-linux/log/run 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/examples/klogd-linux/log/run 2021-09-26 14:04:15.000000000 +0000 @@ -1,4 +1,4 @@ -#!/command/execlineb -P +#!/bin/execlineb -P s6-setuidgid klog exec -c s6-log -d3 t s1000000 n20 /var/log/klogd diff -Nru s6-2.10.0.2/examples/klogd-linux/run s6-2.11.0.0/examples/klogd-linux/run --- s6-2.10.0.2/examples/klogd-linux/run 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/examples/klogd-linux/run 2021-09-26 14:04:15.000000000 +0000 @@ -1,4 +1,4 @@ -#!/command/execlineb -P +#!/bin/execlineb -P fdmove -c 2 1 redirfd -r 0 /proc/kmsg exec -c diff -Nru s6-2.10.0.2/examples/s6-svscanboot s6-2.11.0.0/examples/s6-svscanboot --- s6-2.10.0.2/examples/s6-svscanboot 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/examples/s6-svscanboot 2021-09-26 14:04:15.000000000 +0000 @@ -1,9 +1,9 @@ -#!/command/execlineb -P +#!/bin/execlineb -P -/command/exec -c -/command/s6-setsid -qb -/command/redirfd -r 0 /dev/null -/command/redirfd -wnb 1 /service/s6-svscan-log/fifo -/command/fdmove -c 2 1 -/command/exec -a s6-svscan -/command/s6-svscan -t0 /service +/bin/exec -c +/bin/s6-setsid -qb +/bin/redirfd -r 0 /dev/null +/bin/redirfd -wnb 1 /service/s6-svscan-log/fifo +/bin/fdmove -c 2 1 +/bin/exec -a s6-svscan +/bin/s6-svscan -t0 /service diff -Nru s6-2.10.0.2/examples/syslogd/log/env/LOGSCRIPT s6-2.11.0.0/examples/syslogd/log/env/LOGSCRIPT --- s6-2.10.0.2/examples/syslogd/log/env/LOGSCRIPT 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/examples/syslogd/log/env/LOGSCRIPT 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,6 @@ +- +^\\serror\\. t /var/log/syslogd/error +- +^\\sauthpriv\\. t /var/log/syslogd/auth +- +^\\suser\\. t /var/log/syslogd/user +- +^\\smessages\\. t /var/log/syslogd/messages +- +^\\sdaemon\\. t /var/log/syslogd/daemon +f t /var/log/syslogd/misc diff -Nru s6-2.10.0.2/examples/syslogd/log/notification-fd s6-2.11.0.0/examples/syslogd/log/notification-fd --- s6-2.10.0.2/examples/syslogd/log/notification-fd 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/examples/syslogd/log/notification-fd 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1 @@ +3 diff -Nru s6-2.10.0.2/examples/syslogd/log/README s6-2.11.0.0/examples/syslogd/log/README --- s6-2.10.0.2/examples/syslogd/log/README 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/examples/syslogd/log/README 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,9 @@ + This logger service logs everything the syslogd service receives +into subdirectories of /var/log/syslogd/ logdir. + + The script provided in env/LOGSCRIPT emulates the default +syslogd behaviour on a majority of Linux distributions. + + Note that spaces cannot be used as is in the LOGSCRIPT file, +because they are delimiters for the splitting of $LOGSCRIPT +in the run script. So \s is used instead. diff -Nru s6-2.10.0.2/examples/syslogd/log/run s6-2.11.0.0/examples/syslogd/log/run --- s6-2.10.0.2/examples/syslogd/log/run 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/examples/syslogd/log/run 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,8 @@ +#!/bun/execlineb -P +s6-setuidgid syslog +s6-envdir -f env +importas -Cs LOGSCRIPT LOGSCRIPT +exec -c +s6-log -d3 -- $LOGSCRIPT + +# Change env/LOGSCRIPT to alter s6-log's behaviour diff -Nru s6-2.10.0.2/examples/syslogd/notification-fd s6-2.11.0.0/examples/syslogd/notification-fd --- s6-2.10.0.2/examples/syslogd/notification-fd 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/examples/syslogd/notification-fd 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1 @@ +3 diff -Nru s6-2.10.0.2/examples/syslogd/README s6-2.11.0.0/examples/syslogd/README --- s6-2.10.0.2/examples/syslogd/README 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/examples/syslogd/README 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,4 @@ +This is an example of a service directory for process supervision by s6. + +This syslogd emulation works on any Unix where syslog() is +implemented via a connection on the /dev/log Unix-domain socket. diff -Nru s6-2.10.0.2/examples/syslogd/run s6-2.11.0.0/examples/syslogd/run --- s6-2.10.0.2/examples/syslogd/run 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/examples/syslogd/run 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,4 @@ +#!/bin/execlineb -P +fdmove -c 2 1 +s6-envuidgid nobody +s6-socklog -d3 -U -t3000 diff -Nru s6-2.10.0.2/examples/syslogd-linux/log/env/LOGSCRIPT s6-2.11.0.0/examples/syslogd-linux/log/env/LOGSCRIPT --- s6-2.10.0.2/examples/syslogd-linux/log/env/LOGSCRIPT 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/examples/syslogd-linux/log/env/LOGSCRIPT 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -- +^[0-9]+:\s[0-9]+:\serror\. t /var/log/syslogd/error -- +^[0-9]+:\s[0-9]+:\sauthpriv\. t /var/log/syslogd/auth -- +^[0-9]+:\s[0-9]+:\suser\. t /var/log/syslogd/user -- +^[0-9]+:\s[0-9]+:\smessages\. t /var/log/syslogd/messages -- +^[0-9]+:\s[0-9]+:\sdaemon\. t /var/log/syslogd/daemon -f t /var/log/syslogd/misc diff -Nru s6-2.10.0.2/examples/syslogd-linux/log/notification-fd s6-2.11.0.0/examples/syslogd-linux/log/notification-fd --- s6-2.10.0.2/examples/syslogd-linux/log/notification-fd 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/examples/syslogd-linux/log/notification-fd 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -3 diff -Nru s6-2.10.0.2/examples/syslogd-linux/log/README s6-2.11.0.0/examples/syslogd-linux/log/README --- s6-2.10.0.2/examples/syslogd-linux/log/README 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/examples/syslogd-linux/log/README 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ - This logger service logs everything the syslogd service receives -into subdirectories of /var/log/syslogd/ logdir. - - The script provided in env/LOGSCRIPT emulates the default -syslogd behaviour on a majority of Linux distributions. - - Note that spaces cannot be used as is in the LOGSCRIPT file, -because they are delimiters for the splitting of $LOGSCRIPT -in the run script. So \s is used instead. diff -Nru s6-2.10.0.2/examples/syslogd-linux/log/run s6-2.11.0.0/examples/syslogd-linux/log/run --- s6-2.10.0.2/examples/syslogd-linux/log/run 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/examples/syslogd-linux/log/run 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -#!/command/execlineb -P -s6-setuidgid syslog -s6-envdir -f env -importas -Cs LOGSCRIPT LOGSCRIPT -exec -c -s6-log -d3 -- $LOGSCRIPT - -# Change env/LOGSCRIPT to alter s6-log's behaviour diff -Nru s6-2.10.0.2/examples/syslogd-linux/notification-fd s6-2.11.0.0/examples/syslogd-linux/notification-fd --- s6-2.10.0.2/examples/syslogd-linux/notification-fd 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/examples/syslogd-linux/notification-fd 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -3 diff -Nru s6-2.10.0.2/examples/syslogd-linux/README s6-2.11.0.0/examples/syslogd-linux/README --- s6-2.10.0.2/examples/syslogd-linux/README 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/examples/syslogd-linux/README 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -This is an example of a service directory for process supervision by s6. - -This syslogd emulation works on any Unix where syslog() is -implemented via a connection on the /dev/log Unix-domain socket. -It needs a Unix superserver (see s6-networking, ucspi-unix or -ucspi-ipc) and ucspilogd. -A ucspilogd process is spawned for every syslog() client. It -processes logs and sends them to stderr, i.e. the service's -logger. diff -Nru s6-2.10.0.2/examples/syslogd-linux/run s6-2.11.0.0/examples/syslogd-linux/run --- s6-2.10.0.2/examples/syslogd-linux/run 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/examples/syslogd-linux/run 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -#!/command/execlineb -P -fdmove -c 2 1 -exec -c -s6-envuidgid nobody -fdmove 1 3 -s6-ipcserver -U -1 -- /dev/log -fdmove -c 1 2 -ucspilogd IPCREMOTEEUID IPCREMOTEEGID diff -Nru s6-2.10.0.2/.gitignore s6-2.11.0.0/.gitignore --- s6-2.10.0.2/.gitignore 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/.gitignore 2021-09-26 14:04:15.000000000 +0000 @@ -28,12 +28,15 @@ /s6-svdt /s6-svdt-clear /s6-permafailon +/s6-svlink +/s6-svunlink /s6-envdir /s6-envuidgid /s6-fghack /s6-log /s6-setlock /s6-setsid +/s6-socklog /s6-softlimit /s6-tai64n /s6-tai64nlocal diff -Nru s6-2.10.0.2/INSTALL s6-2.11.0.0/INSTALL --- s6-2.10.0.2/INSTALL 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/INSTALL 2021-09-26 14:04:15.000000000 +0000 @@ -6,9 +6,11 @@ - A POSIX-compliant C development environment - GNU make version 3.81 or later - - skalibs version 2.10.0.2 or later: https://skarnet.org/software/skalibs/ - - Optional: nsss version 0.1.0.0 or later: https://skarnet.org/software/nsss/ - - Optional (but recommended): execline version 2.7.0.1 or later: https://skarnet.org/software/execline/ + - skalibs version 2.11.0.0 or later: https://skarnet.org/software/skalibs/ + - execline version 2.8.1.0 or later: https://skarnet.org/software/execline/ + (You can disable this requirement at configure time, but will + lose some functionality.) + - Optional: nsss version 0.2.0.0 or later: https://skarnet.org/software/nsss/ This software will run on any operating system that implements POSIX.1-2008, available at: diff -Nru s6-2.10.0.2/Makefile s6-2.11.0.0/Makefile --- s6-2.10.0.2/Makefile 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/Makefile 2021-09-26 14:04:15.000000000 +0000 @@ -75,10 +75,10 @@ strip: $(ALL_LIBS) $(ALL_BINS) ifneq ($(strip $(STATIC_LIBS)),) - exec $(STRIP) -x -R .note -R .comment -R .note.GNU-stack $(STATIC_LIBS) + exec $(STRIP) -x -R .note -R .comment $(STATIC_LIBS) endif ifneq ($(strip $(ALL_BINS)$(SHARED_LIBS)),) - exec $(STRIP) -R .note -R .comment -R .note.GNU-stack $(ALL_BINS) $(SHARED_LIBS) + exec $(STRIP) -R .note -R .comment $(ALL_BINS) $(SHARED_LIBS) endif install: install-dynlib install-libexec install-bin install-lib install-include diff -Nru s6-2.10.0.2/NEWS s6-2.11.0.0/NEWS --- s6-2.10.0.2/NEWS 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/NEWS 2021-09-26 14:04:15.000000000 +0000 @@ -1,5 +1,24 @@ Changelog for s6. +In 2.11.0.0 +----------- + + - Adaptation to skalibs-2.11.0.0. + - Bugfixes. + - s6-svwait now supports -r and -R options to wait for restarts. + - New service directory file: lock-fd, to take a lock before +starting a service, protecting against concurrent instances. + - s6/lock.h, s6/supervise.h, s6/fdholder.h: simpler header names + - New binaries: s6-svlink, s6-svunlink + - s6-ioconnect bugfix; does not support zero-copy anymore. + + +In 2.10.0.3 +----------- + + - Bugfixes. + + In 2.10.0.2 ----------- diff -Nru s6-2.10.0.2/package/deps.mak s6-2.11.0.0/package/deps.mak --- s6-2.10.0.2/package/deps.mak 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/package/deps.mak 2021-09-26 14:04:15.000000000 +0000 @@ -4,8 +4,8 @@ src/include/s6/compat.h: src/include/s6/config.h src/include/s6/ftrigr.h: src/include/s6/config.h -src/include/s6/s6.h: src/include/s6/accessrules.h src/include/s6/compat.h src/include/s6/ftrigr.h src/include/s6/ftrigw.h src/include/s6/s6-supervise.h src/include/s6/s6lock.h -src/include/s6/s6lock.h: src/include/s6/config.h +src/include/s6/lock.h: src/include/s6/config.h +src/include/s6/s6.h: src/include/s6/accessrules.h src/include/s6/compat.h src/include/s6/ftrigr.h src/include/s6/ftrigw.h src/include/s6/lock.h src/include/s6/supervise.h src/supervision/s6-svlisten.h: src/include/s6/ftrigr.h src/conn-tools/s6-accessrules-cdb-from-fs.o src/conn-tools/s6-accessrules-cdb-from-fs.lo: src/conn-tools/s6-accessrules-cdb-from-fs.c src/conn-tools/s6-accessrules-fs-from-cdb.o src/conn-tools/s6-accessrules-fs-from-cdb.lo: src/conn-tools/s6-accessrules-fs-from-cdb.c @@ -19,27 +19,29 @@ src/conn-tools/s6-sudo.o src/conn-tools/s6-sudo.lo: src/conn-tools/s6-sudo.c src/include/s6/config.h src/conn-tools/s6-sudoc.o src/conn-tools/s6-sudoc.lo: src/conn-tools/s6-sudoc.c src/conn-tools/s6-sudo.h src/conn-tools/s6-sudod.o src/conn-tools/s6-sudod.lo: src/conn-tools/s6-sudod.c src/conn-tools/s6-sudo.h +src/daemontools-extras/lolsyslog.o src/daemontools-extras/lolsyslog.lo: src/daemontools-extras/lolsyslog.c src/daemontools-extras/lolsyslog.h src/daemontools-extras/s6-applyuidgid.o src/daemontools-extras/s6-applyuidgid.lo: src/daemontools-extras/s6-applyuidgid.c src/daemontools-extras/s6-envdir.o src/daemontools-extras/s6-envdir.lo: src/daemontools-extras/s6-envdir.c src/daemontools-extras/s6-envuidgid.o src/daemontools-extras/s6-envuidgid.lo: src/daemontools-extras/s6-envuidgid.c src/daemontools-extras/s6-fghack.o src/daemontools-extras/s6-fghack.lo: src/daemontools-extras/s6-fghack.c src/daemontools-extras/s6-log.o src/daemontools-extras/s6-log.lo: src/daemontools-extras/s6-log.c src/include/s6/config.h -src/daemontools-extras/s6-setlock.o src/daemontools-extras/s6-setlock.lo: src/daemontools-extras/s6-setlock.c src/include/s6/config.h +src/daemontools-extras/s6-setlock.o src/daemontools-extras/s6-setlock.lo: src/daemontools-extras/s6-setlock.c src/include/s6/config.h src/include-local/s6lockd.h src/daemontools-extras/s6-setsid.o src/daemontools-extras/s6-setsid.lo: src/daemontools-extras/s6-setsid.c src/daemontools-extras/s6-setuidgid.o src/daemontools-extras/s6-setuidgid.lo: src/daemontools-extras/s6-setuidgid.c src/include/s6/config.h +src/daemontools-extras/s6-socklog.o src/daemontools-extras/s6-socklog.lo: src/daemontools-extras/s6-socklog.c src/daemontools-extras/lolsyslog.h src/daemontools-extras/s6-softlimit.o src/daemontools-extras/s6-softlimit.lo: src/daemontools-extras/s6-softlimit.c src/daemontools-extras/s6-tai64n.o src/daemontools-extras/s6-tai64n.lo: src/daemontools-extras/s6-tai64n.c src/daemontools-extras/s6-tai64nlocal.o src/daemontools-extras/s6-tai64nlocal.lo: src/daemontools-extras/s6-tai64nlocal.c -src/daemontools-extras/ucspilogd.o src/daemontools-extras/ucspilogd.lo: src/daemontools-extras/ucspilogd.c +src/daemontools-extras/ucspilogd.o src/daemontools-extras/ucspilogd.lo: src/daemontools-extras/ucspilogd.c src/daemontools-extras/lolsyslog.h src/fdholder/s6-fdholder-daemon.o src/fdholder/s6-fdholder-daemon.lo: src/fdholder/s6-fdholder-daemon.c src/include/s6/config.h -src/fdholder/s6-fdholder-delete.o src/fdholder/s6-fdholder-delete.lo: src/fdholder/s6-fdholder-delete.c src/include/s6/s6-fdholder.h -src/fdholder/s6-fdholder-getdump.o src/fdholder/s6-fdholder-getdump.lo: src/fdholder/s6-fdholder-getdump.c src/include/s6/s6-fdholder.h -src/fdholder/s6-fdholder-list.o src/fdholder/s6-fdholder-list.lo: src/fdholder/s6-fdholder-list.c src/include/s6/s6-fdholder.h -src/fdholder/s6-fdholder-retrieve.o src/fdholder/s6-fdholder-retrieve.lo: src/fdholder/s6-fdholder-retrieve.c src/include/s6/s6-fdholder.h -src/fdholder/s6-fdholder-setdump.o src/fdholder/s6-fdholder-setdump.lo: src/fdholder/s6-fdholder-setdump.c src/include/s6/s6-fdholder.h -src/fdholder/s6-fdholder-store.o src/fdholder/s6-fdholder-store.lo: src/fdholder/s6-fdholder-store.c src/include/s6/s6-fdholder.h -src/fdholder/s6-fdholder-transferdump.o src/fdholder/s6-fdholder-transferdump.lo: src/fdholder/s6-fdholder-transferdump.c src/include/s6/s6-fdholder.h -src/fdholder/s6-fdholderd.o src/fdholder/s6-fdholderd.lo: src/fdholder/s6-fdholderd.c src/include/s6/accessrules.h src/include/s6/s6-fdholder.h +src/fdholder/s6-fdholder-delete.o src/fdholder/s6-fdholder-delete.lo: src/fdholder/s6-fdholder-delete.c src/include/s6/fdholder.h +src/fdholder/s6-fdholder-getdump.o src/fdholder/s6-fdholder-getdump.lo: src/fdholder/s6-fdholder-getdump.c src/include/s6/fdholder.h +src/fdholder/s6-fdholder-list.o src/fdholder/s6-fdholder-list.lo: src/fdholder/s6-fdholder-list.c src/include/s6/fdholder.h +src/fdholder/s6-fdholder-retrieve.o src/fdholder/s6-fdholder-retrieve.lo: src/fdholder/s6-fdholder-retrieve.c src/include/s6/fdholder.h +src/fdholder/s6-fdholder-setdump.o src/fdholder/s6-fdholder-setdump.lo: src/fdholder/s6-fdholder-setdump.c src/include/s6/fdholder.h +src/fdholder/s6-fdholder-store.o src/fdholder/s6-fdholder-store.lo: src/fdholder/s6-fdholder-store.c src/include/s6/fdholder.h +src/fdholder/s6-fdholder-transferdump.o src/fdholder/s6-fdholder-transferdump.lo: src/fdholder/s6-fdholder-transferdump.c src/include/s6/fdholder.h +src/fdholder/s6-fdholderd.o src/fdholder/s6-fdholderd.lo: src/fdholder/s6-fdholderd.c src/include/s6/accessrules.h src/include/s6/fdholder.h src/libs6/ftrig1_free.o src/libs6/ftrig1_free.lo: src/libs6/ftrig1_free.c src/libs6/ftrig1.h src/libs6/ftrig1_make.o src/libs6/ftrig1_make.lo: src/libs6/ftrig1_make.c src/libs6/ftrig1.h src/libs6/ftrigr1_zero.o src/libs6/ftrigr1_zero.lo: src/libs6/ftrigr1_zero.c src/include/s6/ftrigr.h @@ -72,45 +74,48 @@ src/libs6/s6_accessrules_uidgid_cdb.o src/libs6/s6_accessrules_uidgid_cdb.lo: src/libs6/s6_accessrules_uidgid_cdb.c src/include/s6/accessrules.h src/libs6/s6_accessrules_uidgid_fs.o src/libs6/s6_accessrules_uidgid_fs.lo: src/libs6/s6_accessrules_uidgid_fs.c src/include/s6/accessrules.h src/libs6/s6_compat_el_semicolon.o src/libs6/s6_compat_el_semicolon.lo: src/libs6/s6_compat_el_semicolon.c src/include/s6/config.h -src/libs6/s6_dtally_pack.o src/libs6/s6_dtally_pack.lo: src/libs6/s6_dtally_pack.c src/include/s6/s6-supervise.h -src/libs6/s6_dtally_read.o src/libs6/s6_dtally_read.lo: src/libs6/s6_dtally_read.c src/include/s6/s6-supervise.h -src/libs6/s6_dtally_unpack.o src/libs6/s6_dtally_unpack.lo: src/libs6/s6_dtally_unpack.c src/include/s6/s6-supervise.h -src/libs6/s6_dtally_write.o src/libs6/s6_dtally_write.lo: src/libs6/s6_dtally_write.c src/include/s6/s6-supervise.h -src/libs6/s6_fdholder_delete.o src/libs6/s6_fdholder_delete.lo: src/libs6/s6_fdholder_delete.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_delete_async.o src/libs6/s6_fdholder_delete_async.lo: src/libs6/s6_fdholder_delete_async.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_end.o src/libs6/s6_fdholder_end.lo: src/libs6/s6_fdholder_end.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_getdump.o src/libs6/s6_fdholder_getdump.lo: src/libs6/s6_fdholder_getdump.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_list.o src/libs6/s6_fdholder_list.lo: src/libs6/s6_fdholder_list.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_list_async.o src/libs6/s6_fdholder_list_async.lo: src/libs6/s6_fdholder_list_async.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_list_cb.o src/libs6/s6_fdholder_list_cb.lo: src/libs6/s6_fdholder_list_cb.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_retrieve.o src/libs6/s6_fdholder_retrieve.lo: src/libs6/s6_fdholder_retrieve.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_retrieve_async.o src/libs6/s6_fdholder_retrieve_async.lo: src/libs6/s6_fdholder_retrieve_async.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_retrieve_cb.o src/libs6/s6_fdholder_retrieve_cb.lo: src/libs6/s6_fdholder_retrieve_cb.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_setdump.o src/libs6/s6_fdholder_setdump.lo: src/libs6/s6_fdholder_setdump.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_start.o src/libs6/s6_fdholder_start.lo: src/libs6/s6_fdholder_start.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_store.o src/libs6/s6_fdholder_store.lo: src/libs6/s6_fdholder_store.c src/include/s6/s6-fdholder.h -src/libs6/s6_fdholder_store_async.o src/libs6/s6_fdholder_store_async.lo: src/libs6/s6_fdholder_store_async.c src/include/s6/s6-fdholder.h -src/libs6/s6_supervise_link.o src/libs6/s6_supervise_link.lo: src/libs6/s6_supervise_link.c src/include/s6/ftrigr.h src/include/s6/ftrigw.h src/include/s6/s6-supervise.h -src/libs6/s6_supervise_unlink.o src/libs6/s6_supervise_unlink.lo: src/libs6/s6_supervise_unlink.c src/include/s6/s6-supervise.h -src/libs6/s6_svc_ok.o src/libs6/s6_svc_ok.lo: src/libs6/s6_svc_ok.c src/include/s6/s6-supervise.h -src/libs6/s6_svc_write.o src/libs6/s6_svc_write.lo: src/libs6/s6_svc_write.c src/include/s6/s6-supervise.h -src/libs6/s6_svc_writectl.o src/libs6/s6_svc_writectl.lo: src/libs6/s6_svc_writectl.c src/include/s6/s6-supervise.h -src/libs6/s6_svstatus_pack.o src/libs6/s6_svstatus_pack.lo: src/libs6/s6_svstatus_pack.c src/include/s6/s6-supervise.h -src/libs6/s6_svstatus_read.o src/libs6/s6_svstatus_read.lo: src/libs6/s6_svstatus_read.c src/include/s6/s6-supervise.h -src/libs6/s6_svstatus_unpack.o src/libs6/s6_svstatus_unpack.lo: src/libs6/s6_svstatus_unpack.c src/include/s6/s6-supervise.h -src/libs6/s6_svstatus_write.o src/libs6/s6_svstatus_write.lo: src/libs6/s6_svstatus_write.c src/include/s6/s6-supervise.h -src/libs6/s6lock_acquire.o src/libs6/s6lock_acquire.lo: src/libs6/s6lock_acquire.c src/include/s6/s6lock.h -src/libs6/s6lock_check.o src/libs6/s6lock_check.lo: src/libs6/s6lock_check.c src/include/s6/s6lock.h -src/libs6/s6lock_end.o src/libs6/s6lock_end.lo: src/libs6/s6lock_end.c src/include/s6/s6lock.h -src/libs6/s6lock_release.o src/libs6/s6lock_release.lo: src/libs6/s6lock_release.c src/include/s6/s6lock.h -src/libs6/s6lock_start.o src/libs6/s6lock_start.lo: src/libs6/s6lock_start.c src/include/s6/s6lock.h -src/libs6/s6lock_startf.o src/libs6/s6lock_startf.lo: src/libs6/s6lock_startf.c src/include/s6/s6lock.h -src/libs6/s6lock_update.o src/libs6/s6lock_update.lo: src/libs6/s6lock_update.c src/include/s6/s6lock.h -src/libs6/s6lock_wait_and.o src/libs6/s6lock_wait_and.lo: src/libs6/s6lock_wait_and.c src/include/s6/s6lock.h -src/libs6/s6lock_wait_or.o src/libs6/s6lock_wait_or.lo: src/libs6/s6lock_wait_or.c src/include/s6/s6lock.h -src/libs6/s6lock_zero.o src/libs6/s6lock_zero.lo: src/libs6/s6lock_zero.c src/include/s6/s6lock.h -src/libs6/s6lockd-helper.o src/libs6/s6lockd-helper.lo: src/libs6/s6lockd-helper.c -src/libs6/s6lockd.o src/libs6/s6lockd.lo: src/libs6/s6lockd.c src/include/s6/s6lock.h +src/libs6/s6_dtally_pack.o src/libs6/s6_dtally_pack.lo: src/libs6/s6_dtally_pack.c src/include/s6/supervise.h +src/libs6/s6_dtally_read.o src/libs6/s6_dtally_read.lo: src/libs6/s6_dtally_read.c src/include/s6/supervise.h +src/libs6/s6_dtally_unpack.o src/libs6/s6_dtally_unpack.lo: src/libs6/s6_dtally_unpack.c src/include/s6/supervise.h +src/libs6/s6_dtally_write.o src/libs6/s6_dtally_write.lo: src/libs6/s6_dtally_write.c src/include/s6/supervise.h +src/libs6/s6_fdholder_delete.o src/libs6/s6_fdholder_delete.lo: src/libs6/s6_fdholder_delete.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_delete_async.o src/libs6/s6_fdholder_delete_async.lo: src/libs6/s6_fdholder_delete_async.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_end.o src/libs6/s6_fdholder_end.lo: src/libs6/s6_fdholder_end.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_getdump.o src/libs6/s6_fdholder_getdump.lo: src/libs6/s6_fdholder_getdump.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_list.o src/libs6/s6_fdholder_list.lo: src/libs6/s6_fdholder_list.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_list_async.o src/libs6/s6_fdholder_list_async.lo: src/libs6/s6_fdholder_list_async.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_list_cb.o src/libs6/s6_fdholder_list_cb.lo: src/libs6/s6_fdholder_list_cb.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_retrieve.o src/libs6/s6_fdholder_retrieve.lo: src/libs6/s6_fdholder_retrieve.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_retrieve_async.o src/libs6/s6_fdholder_retrieve_async.lo: src/libs6/s6_fdholder_retrieve_async.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_retrieve_cb.o src/libs6/s6_fdholder_retrieve_cb.lo: src/libs6/s6_fdholder_retrieve_cb.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_setdump.o src/libs6/s6_fdholder_setdump.lo: src/libs6/s6_fdholder_setdump.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_start.o src/libs6/s6_fdholder_start.lo: src/libs6/s6_fdholder_start.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_store.o src/libs6/s6_fdholder_store.lo: src/libs6/s6_fdholder_store.c src/include/s6/fdholder.h +src/libs6/s6_fdholder_store_async.o src/libs6/s6_fdholder_store_async.lo: src/libs6/s6_fdholder_store_async.c src/include/s6/fdholder.h +src/libs6/s6_supervise_link.o src/libs6/s6_supervise_link.lo: src/libs6/s6_supervise_link.c src/include/s6/supervise.h +src/libs6/s6_supervise_link_names.o src/libs6/s6_supervise_link_names.lo: src/libs6/s6_supervise_link_names.c src/include/s6/ftrigr.h src/include/s6/ftrigw.h src/include/s6/supervise.h +src/libs6/s6_supervise_unlink.o src/libs6/s6_supervise_unlink.lo: src/libs6/s6_supervise_unlink.c src/include/s6/supervise.h +src/libs6/s6_supervise_unlink_names.o src/libs6/s6_supervise_unlink_names.lo: src/libs6/s6_supervise_unlink_names.c src/include/s6/ftrigr.h src/include/s6/supervise.h +src/libs6/s6_svc_ok.o src/libs6/s6_svc_ok.lo: src/libs6/s6_svc_ok.c src/include/s6/supervise.h +src/libs6/s6_svc_write.o src/libs6/s6_svc_write.lo: src/libs6/s6_svc_write.c src/include/s6/supervise.h +src/libs6/s6_svc_writectl.o src/libs6/s6_svc_writectl.lo: src/libs6/s6_svc_writectl.c src/include/s6/supervise.h +src/libs6/s6_svstatus_pack.o src/libs6/s6_svstatus_pack.lo: src/libs6/s6_svstatus_pack.c src/include/s6/supervise.h +src/libs6/s6_svstatus_read.o src/libs6/s6_svstatus_read.lo: src/libs6/s6_svstatus_read.c src/include/s6/supervise.h +src/libs6/s6_svstatus_unpack.o src/libs6/s6_svstatus_unpack.lo: src/libs6/s6_svstatus_unpack.c src/include/s6/supervise.h +src/libs6/s6_svstatus_write.o src/libs6/s6_svstatus_write.lo: src/libs6/s6_svstatus_write.c src/include/s6/supervise.h +src/libs6/s6lock_acquire.o src/libs6/s6lock_acquire.lo: src/libs6/s6lock_acquire.c src/include/s6/lock.h +src/libs6/s6lock_check.o src/libs6/s6lock_check.lo: src/libs6/s6lock_check.c src/include/s6/lock.h +src/libs6/s6lock_end.o src/libs6/s6lock_end.lo: src/libs6/s6lock_end.c src/include/s6/lock.h +src/libs6/s6lock_release.o src/libs6/s6lock_release.lo: src/libs6/s6lock_release.c src/include/s6/lock.h +src/libs6/s6lock_start.o src/libs6/s6lock_start.lo: src/libs6/s6lock_start.c src/include/s6/lock.h +src/libs6/s6lock_startf.o src/libs6/s6lock_startf.lo: src/libs6/s6lock_startf.c src/include/s6/lock.h +src/libs6/s6lock_update.o src/libs6/s6lock_update.lo: src/libs6/s6lock_update.c src/include/s6/lock.h +src/libs6/s6lock_wait_and.o src/libs6/s6lock_wait_and.lo: src/libs6/s6lock_wait_and.c src/include/s6/lock.h +src/libs6/s6lock_wait_or.o src/libs6/s6lock_wait_or.lo: src/libs6/s6lock_wait_or.c src/include/s6/lock.h +src/libs6/s6lock_zero.o src/libs6/s6lock_zero.lo: src/libs6/s6lock_zero.c src/include/s6/lock.h +src/libs6/s6lockd-helper.o src/libs6/s6lockd-helper.lo: src/libs6/s6lockd-helper.c src/include-local/s6lockd.h +src/libs6/s6lockd.o src/libs6/s6lockd.lo: src/libs6/s6lockd.c src/include/s6/lock.h +src/libs6/s6lockd_openandlock.o src/libs6/s6lockd_openandlock.lo: src/libs6/s6lockd_openandlock.c src/include-local/s6lockd.h src/pipe-tools/s6-cleanfifodir.o src/pipe-tools/s6-cleanfifodir.lo: src/pipe-tools/s6-cleanfifodir.c src/include/s6/ftrigw.h src/pipe-tools/s6-ftrig-listen.o src/pipe-tools/s6-ftrig-listen.lo: src/pipe-tools/s6-ftrig-listen.c src/include/s6/compat.h src/include/s6/ftrigr.h src/pipe-tools/s6-ftrig-listen1.o src/pipe-tools/s6-ftrig-listen1.lo: src/pipe-tools/s6-ftrig-listen1.c src/include/s6/ftrigr.h @@ -118,20 +123,22 @@ src/pipe-tools/s6-ftrig-wait.o src/pipe-tools/s6-ftrig-wait.lo: src/pipe-tools/s6-ftrig-wait.c src/include/s6/ftrigr.h src/pipe-tools/s6-mkfifodir.o src/pipe-tools/s6-mkfifodir.lo: src/pipe-tools/s6-mkfifodir.c src/include/s6/ftrigw.h src/supervision/s6-notifyoncheck.o src/supervision/s6-notifyoncheck.lo: src/supervision/s6-notifyoncheck.c src/include/s6/s6.h -src/supervision/s6-permafailon.o src/supervision/s6-permafailon.lo: src/supervision/s6-permafailon.c src/include/s6/s6-supervise.h -src/supervision/s6-supervise.o src/supervision/s6-supervise.lo: src/supervision/s6-supervise.c src/include/s6/ftrigw.h src/include/s6/s6-supervise.h -src/supervision/s6-svc.o src/supervision/s6-svc.lo: src/supervision/s6-svc.c src/include/s6/config.h src/include/s6/s6-supervise.h -src/supervision/s6-svdt-clear.o src/supervision/s6-svdt-clear.lo: src/supervision/s6-svdt-clear.c src/include/s6/s6-supervise.h -src/supervision/s6-svdt.o src/supervision/s6-svdt.lo: src/supervision/s6-svdt.c src/include/s6/s6-supervise.h +src/supervision/s6-permafailon.o src/supervision/s6-permafailon.lo: src/supervision/s6-permafailon.c src/include/s6/supervise.h +src/supervision/s6-supervise.o src/supervision/s6-supervise.lo: src/supervision/s6-supervise.c src/include/s6/ftrigw.h src/include/s6/supervise.h +src/supervision/s6-svc.o src/supervision/s6-svc.lo: src/supervision/s6-svc.c src/include/s6/config.h src/include/s6/supervise.h +src/supervision/s6-svdt-clear.o src/supervision/s6-svdt-clear.lo: src/supervision/s6-svdt-clear.c src/include/s6/supervise.h +src/supervision/s6-svdt.o src/supervision/s6-svdt.lo: src/supervision/s6-svdt.c src/include/s6/supervise.h +src/supervision/s6-svlink.o src/supervision/s6-svlink.lo: src/supervision/s6-svlink.c src/include/s6/supervise.h src/supervision/s6-svlisten.o src/supervision/s6-svlisten.lo: src/supervision/s6-svlisten.c src/supervision/s6-svlisten.h src/include/s6/compat.h src/supervision/s6-svlisten1.o src/supervision/s6-svlisten1.lo: src/supervision/s6-svlisten1.c src/supervision/s6-svlisten.h -src/supervision/s6-svok.o src/supervision/s6-svok.lo: src/supervision/s6-svok.c src/include/s6/s6-supervise.h -src/supervision/s6-svperms.o src/supervision/s6-svperms.lo: src/supervision/s6-svperms.c src/include/s6/s6-supervise.h -src/supervision/s6-svscan.o src/supervision/s6-svscan.lo: src/supervision/s6-svscan.c src/include/s6/config.h src/include/s6/s6-supervise.h -src/supervision/s6-svscanctl.o src/supervision/s6-svscanctl.lo: src/supervision/s6-svscanctl.c src/include/s6/s6-supervise.h -src/supervision/s6-svstat.o src/supervision/s6-svstat.lo: src/supervision/s6-svstat.c src/include/s6/s6-supervise.h +src/supervision/s6-svok.o src/supervision/s6-svok.lo: src/supervision/s6-svok.c src/include/s6/supervise.h +src/supervision/s6-svperms.o src/supervision/s6-svperms.lo: src/supervision/s6-svperms.c src/include/s6/supervise.h +src/supervision/s6-svscan.o src/supervision/s6-svscan.lo: src/supervision/s6-svscan.c src/include/s6/config.h src/include/s6/supervise.h +src/supervision/s6-svscanctl.o src/supervision/s6-svscanctl.lo: src/supervision/s6-svscanctl.c src/include/s6/supervise.h +src/supervision/s6-svstat.o src/supervision/s6-svstat.lo: src/supervision/s6-svstat.c src/include/s6/supervise.h +src/supervision/s6-svunlink.o src/supervision/s6-svunlink.lo: src/supervision/s6-svunlink.c src/include/s6/supervise.h src/supervision/s6-svwait.o src/supervision/s6-svwait.lo: src/supervision/s6-svwait.c src/supervision/s6-svlisten.h -src/supervision/s6_svlisten_loop.o src/supervision/s6_svlisten_loop.lo: src/supervision/s6_svlisten_loop.c src/supervision/s6-svlisten.h src/include/s6/ftrigr.h src/include/s6/s6-supervise.h +src/supervision/s6_svlisten_loop.o src/supervision/s6_svlisten_loop.lo: src/supervision/s6_svlisten_loop.c src/supervision/s6-svlisten.h src/include/s6/ftrigr.h src/include/s6/ftrigw.h src/include/s6/supervise.h src/supervision/s6_svlisten_signal_handler.o src/supervision/s6_svlisten_signal_handler.lo: src/supervision/s6_svlisten_signal_handler.c src/supervision/s6-svlisten.h src/usertree/s6-usertree-maker.o src/usertree/s6-usertree-maker.lo: src/usertree/s6-usertree-maker.c src/include/s6/config.h @@ -170,11 +177,13 @@ s6-log: EXTRA_LIBS := -lskarnet ${SYSCLOCK_LIB} s6-log: src/daemontools-extras/s6-log.o s6-setlock: EXTRA_LIBS := -lskarnet ${SYSCLOCK_LIB} ${SPAWN_LIB} -s6-setlock: src/daemontools-extras/s6-setlock.o +s6-setlock: src/daemontools-extras/s6-setlock.o libs6lockd.a.xyzzy s6-setsid: EXTRA_LIBS := -lskarnet s6-setsid: src/daemontools-extras/s6-setsid.o s6-setuidgid: EXTRA_LIBS := -lskarnet s6-setuidgid: src/daemontools-extras/s6-setuidgid.o +s6-socklog: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} +s6-socklog: src/daemontools-extras/s6-socklog.o src/daemontools-extras/lolsyslog.o s6-softlimit: EXTRA_LIBS := -lskarnet s6-softlimit: src/daemontools-extras/s6-softlimit.o s6-tai64n: EXTRA_LIBS := -lskarnet ${SYSCLOCK_LIB} @@ -182,7 +191,7 @@ s6-tai64nlocal: EXTRA_LIBS := -lskarnet s6-tai64nlocal: src/daemontools-extras/s6-tai64nlocal.o ucspilogd: EXTRA_LIBS := -lskarnet -ucspilogd: src/daemontools-extras/ucspilogd.o +ucspilogd: src/daemontools-extras/ucspilogd.o src/daemontools-extras/lolsyslog.o s6-fdholder-daemon: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} s6-fdholder-daemon: src/fdholder/s6-fdholder-daemon.o ${LIBS6} s6-fdholder-delete: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} @@ -202,18 +211,23 @@ s6-fdholderd: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} s6-fdholderd: src/fdholder/s6-fdholderd.o ${LIBS6} ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),) -libs6.a.xyzzy: src/libs6/ftrigr1_zero.o src/libs6/ftrigr_check.o src/libs6/ftrigr_checksa.o src/libs6/ftrigr_ack.o src/libs6/ftrigr_end.o src/libs6/ftrigr_start.o src/libs6/ftrigr_startf.o src/libs6/ftrigr_subscribe.o src/libs6/ftrigr_unsubscribe.o src/libs6/ftrigr_update.o src/libs6/ftrigr_updateb.o src/libs6/ftrigr_wait_and.o src/libs6/ftrigr_wait_or.o src/libs6/ftrigr_zero.o src/libs6/ftrigw_clean.o src/libs6/ftrigw_fifodir_make.o src/libs6/ftrigw_notify.o src/libs6/ftrigw_notifyb.o src/libs6/ftrigw_notifyb_nosig.o src/libs6/s6_accessrules_backend_cdb.o src/libs6/s6_accessrules_backend_fs.o src/libs6/s6_accessrules_keycheck_ip4.o src/libs6/s6_accessrules_keycheck_ip6.o src/libs6/s6_accessrules_keycheck_reversedns.o src/libs6/s6_accessrules_keycheck_uidgid.o src/libs6/s6_accessrules_params_free.o src/libs6/s6_accessrules_uidgid_cdb.o src/libs6/s6_accessrules_uidgid_fs.o src/libs6/s6_compat_el_semicolon.o src/libs6/s6_dtally_pack.o src/libs6/s6_dtally_unpack.o src/libs6/s6_dtally_read.o src/libs6/s6_dtally_write.o src/libs6/s6_svc_ok.o src/libs6/s6_svc_write.o src/libs6/s6_svc_writectl.o src/libs6/s6_svstatus_pack.o src/libs6/s6_svstatus_read.o src/libs6/s6_svstatus_unpack.o src/libs6/s6_svstatus_write.o src/libs6/s6lock_acquire.o src/libs6/s6lock_check.o src/libs6/s6lock_end.o src/libs6/s6lock_release.o src/libs6/s6lock_start.o src/libs6/s6lock_startf.o src/libs6/s6lock_update.o src/libs6/s6lock_wait_and.o src/libs6/s6lock_wait_or.o src/libs6/s6lock_zero.o src/libs6/s6_fdholder_delete.o src/libs6/s6_fdholder_delete_async.o src/libs6/s6_fdholder_end.o src/libs6/s6_fdholder_getdump.o src/libs6/s6_fdholder_list.o src/libs6/s6_fdholder_list_async.o src/libs6/s6_fdholder_list_cb.o src/libs6/s6_fdholder_retrieve.o src/libs6/s6_fdholder_retrieve_async.o src/libs6/s6_fdholder_retrieve_cb.o src/libs6/s6_fdholder_setdump.o src/libs6/s6_fdholder_start.o src/libs6/s6_fdholder_store.o src/libs6/s6_fdholder_store_async.o src/libs6/s6_supervise_link.o src/libs6/s6_supervise_unlink.o +libs6.a.xyzzy: src/libs6/ftrigr1_zero.o src/libs6/ftrigr_check.o src/libs6/ftrigr_checksa.o src/libs6/ftrigr_ack.o src/libs6/ftrigr_end.o src/libs6/ftrigr_start.o src/libs6/ftrigr_startf.o src/libs6/ftrigr_subscribe.o src/libs6/ftrigr_unsubscribe.o src/libs6/ftrigr_update.o src/libs6/ftrigr_updateb.o src/libs6/ftrigr_wait_and.o src/libs6/ftrigr_wait_or.o src/libs6/ftrigr_zero.o src/libs6/ftrigw_clean.o src/libs6/ftrigw_fifodir_make.o src/libs6/ftrigw_notify.o src/libs6/ftrigw_notifyb.o src/libs6/ftrigw_notifyb_nosig.o src/libs6/s6_accessrules_backend_cdb.o src/libs6/s6_accessrules_backend_fs.o src/libs6/s6_accessrules_keycheck_ip4.o src/libs6/s6_accessrules_keycheck_ip6.o src/libs6/s6_accessrules_keycheck_reversedns.o src/libs6/s6_accessrules_keycheck_uidgid.o src/libs6/s6_accessrules_params_free.o src/libs6/s6_accessrules_uidgid_cdb.o src/libs6/s6_accessrules_uidgid_fs.o src/libs6/s6_compat_el_semicolon.o src/libs6/s6_dtally_pack.o src/libs6/s6_dtally_unpack.o src/libs6/s6_dtally_read.o src/libs6/s6_dtally_write.o src/libs6/s6_svc_ok.o src/libs6/s6_svc_write.o src/libs6/s6_svc_writectl.o src/libs6/s6_svstatus_pack.o src/libs6/s6_svstatus_read.o src/libs6/s6_svstatus_unpack.o src/libs6/s6_svstatus_write.o src/libs6/s6lock_acquire.o src/libs6/s6lock_check.o src/libs6/s6lock_end.o src/libs6/s6lock_release.o src/libs6/s6lock_start.o src/libs6/s6lock_startf.o src/libs6/s6lock_update.o src/libs6/s6lock_wait_and.o src/libs6/s6lock_wait_or.o src/libs6/s6lock_zero.o src/libs6/s6_fdholder_delete.o src/libs6/s6_fdholder_delete_async.o src/libs6/s6_fdholder_end.o src/libs6/s6_fdholder_getdump.o src/libs6/s6_fdholder_list.o src/libs6/s6_fdholder_list_async.o src/libs6/s6_fdholder_list_cb.o src/libs6/s6_fdholder_retrieve.o src/libs6/s6_fdholder_retrieve_async.o src/libs6/s6_fdholder_retrieve_cb.o src/libs6/s6_fdholder_setdump.o src/libs6/s6_fdholder_start.o src/libs6/s6_fdholder_store.o src/libs6/s6_fdholder_store_async.o src/libs6/s6_supervise_link.o src/libs6/s6_supervise_link_names.o src/libs6/s6_supervise_unlink.o src/libs6/s6_supervise_unlink_names.o else -libs6.a.xyzzy: src/libs6/ftrigr1_zero.lo src/libs6/ftrigr_check.lo src/libs6/ftrigr_checksa.lo src/libs6/ftrigr_ack.lo src/libs6/ftrigr_end.lo src/libs6/ftrigr_start.lo src/libs6/ftrigr_startf.lo src/libs6/ftrigr_subscribe.lo src/libs6/ftrigr_unsubscribe.lo src/libs6/ftrigr_update.lo src/libs6/ftrigr_updateb.lo src/libs6/ftrigr_wait_and.lo src/libs6/ftrigr_wait_or.lo src/libs6/ftrigr_zero.lo src/libs6/ftrigw_clean.lo src/libs6/ftrigw_fifodir_make.lo src/libs6/ftrigw_notify.lo src/libs6/ftrigw_notifyb.lo src/libs6/ftrigw_notifyb_nosig.lo src/libs6/s6_accessrules_backend_cdb.lo src/libs6/s6_accessrules_backend_fs.lo src/libs6/s6_accessrules_keycheck_ip4.lo src/libs6/s6_accessrules_keycheck_ip6.lo src/libs6/s6_accessrules_keycheck_reversedns.lo src/libs6/s6_accessrules_keycheck_uidgid.lo src/libs6/s6_accessrules_params_free.lo src/libs6/s6_accessrules_uidgid_cdb.lo src/libs6/s6_accessrules_uidgid_fs.lo src/libs6/s6_compat_el_semicolon.lo src/libs6/s6_dtally_pack.lo src/libs6/s6_dtally_unpack.lo src/libs6/s6_dtally_read.lo src/libs6/s6_dtally_write.lo src/libs6/s6_svc_ok.lo src/libs6/s6_svc_write.lo src/libs6/s6_svc_writectl.lo src/libs6/s6_svstatus_pack.lo src/libs6/s6_svstatus_read.lo src/libs6/s6_svstatus_unpack.lo src/libs6/s6_svstatus_write.lo src/libs6/s6lock_acquire.lo src/libs6/s6lock_check.lo src/libs6/s6lock_end.lo src/libs6/s6lock_release.lo src/libs6/s6lock_start.lo src/libs6/s6lock_startf.lo src/libs6/s6lock_update.lo src/libs6/s6lock_wait_and.lo src/libs6/s6lock_wait_or.lo src/libs6/s6lock_zero.lo src/libs6/s6_fdholder_delete.lo src/libs6/s6_fdholder_delete_async.lo src/libs6/s6_fdholder_end.lo src/libs6/s6_fdholder_getdump.lo src/libs6/s6_fdholder_list.lo src/libs6/s6_fdholder_list_async.lo src/libs6/s6_fdholder_list_cb.lo src/libs6/s6_fdholder_retrieve.lo src/libs6/s6_fdholder_retrieve_async.lo src/libs6/s6_fdholder_retrieve_cb.lo src/libs6/s6_fdholder_setdump.lo src/libs6/s6_fdholder_start.lo src/libs6/s6_fdholder_store.lo src/libs6/s6_fdholder_store_async.lo src/libs6/s6_supervise_link.lo src/libs6/s6_supervise_unlink.lo +libs6.a.xyzzy: src/libs6/ftrigr1_zero.lo src/libs6/ftrigr_check.lo src/libs6/ftrigr_checksa.lo src/libs6/ftrigr_ack.lo src/libs6/ftrigr_end.lo src/libs6/ftrigr_start.lo src/libs6/ftrigr_startf.lo src/libs6/ftrigr_subscribe.lo src/libs6/ftrigr_unsubscribe.lo src/libs6/ftrigr_update.lo src/libs6/ftrigr_updateb.lo src/libs6/ftrigr_wait_and.lo src/libs6/ftrigr_wait_or.lo src/libs6/ftrigr_zero.lo src/libs6/ftrigw_clean.lo src/libs6/ftrigw_fifodir_make.lo src/libs6/ftrigw_notify.lo src/libs6/ftrigw_notifyb.lo src/libs6/ftrigw_notifyb_nosig.lo src/libs6/s6_accessrules_backend_cdb.lo src/libs6/s6_accessrules_backend_fs.lo src/libs6/s6_accessrules_keycheck_ip4.lo src/libs6/s6_accessrules_keycheck_ip6.lo src/libs6/s6_accessrules_keycheck_reversedns.lo src/libs6/s6_accessrules_keycheck_uidgid.lo src/libs6/s6_accessrules_params_free.lo src/libs6/s6_accessrules_uidgid_cdb.lo src/libs6/s6_accessrules_uidgid_fs.lo src/libs6/s6_compat_el_semicolon.lo src/libs6/s6_dtally_pack.lo src/libs6/s6_dtally_unpack.lo src/libs6/s6_dtally_read.lo src/libs6/s6_dtally_write.lo src/libs6/s6_svc_ok.lo src/libs6/s6_svc_write.lo src/libs6/s6_svc_writectl.lo src/libs6/s6_svstatus_pack.lo src/libs6/s6_svstatus_read.lo src/libs6/s6_svstatus_unpack.lo src/libs6/s6_svstatus_write.lo src/libs6/s6lock_acquire.lo src/libs6/s6lock_check.lo src/libs6/s6lock_end.lo src/libs6/s6lock_release.lo src/libs6/s6lock_start.lo src/libs6/s6lock_startf.lo src/libs6/s6lock_update.lo src/libs6/s6lock_wait_and.lo src/libs6/s6lock_wait_or.lo src/libs6/s6lock_zero.lo src/libs6/s6_fdholder_delete.lo src/libs6/s6_fdholder_delete_async.lo src/libs6/s6_fdholder_end.lo src/libs6/s6_fdholder_getdump.lo src/libs6/s6_fdholder_list.lo src/libs6/s6_fdholder_list_async.lo src/libs6/s6_fdholder_list_cb.lo src/libs6/s6_fdholder_retrieve.lo src/libs6/s6_fdholder_retrieve_async.lo src/libs6/s6_fdholder_retrieve_cb.lo src/libs6/s6_fdholder_setdump.lo src/libs6/s6_fdholder_start.lo src/libs6/s6_fdholder_store.lo src/libs6/s6_fdholder_store_async.lo src/libs6/s6_supervise_link.lo src/libs6/s6_supervise_link_names.lo src/libs6/s6_supervise_unlink.lo src/libs6/s6_supervise_unlink_names.lo endif libs6.so.xyzzy: EXTRA_LIBS := -lskarnet -libs6.so.xyzzy: src/libs6/ftrigr1_zero.lo src/libs6/ftrigr_check.lo src/libs6/ftrigr_checksa.lo src/libs6/ftrigr_ack.lo src/libs6/ftrigr_end.lo src/libs6/ftrigr_start.lo src/libs6/ftrigr_startf.lo src/libs6/ftrigr_subscribe.lo src/libs6/ftrigr_unsubscribe.lo src/libs6/ftrigr_update.lo src/libs6/ftrigr_updateb.lo src/libs6/ftrigr_wait_and.lo src/libs6/ftrigr_wait_or.lo src/libs6/ftrigr_zero.lo src/libs6/ftrigw_clean.lo src/libs6/ftrigw_fifodir_make.lo src/libs6/ftrigw_notify.lo src/libs6/ftrigw_notifyb.lo src/libs6/ftrigw_notifyb_nosig.lo src/libs6/s6_accessrules_backend_cdb.lo src/libs6/s6_accessrules_backend_fs.lo src/libs6/s6_accessrules_keycheck_ip4.lo src/libs6/s6_accessrules_keycheck_ip6.lo src/libs6/s6_accessrules_keycheck_reversedns.lo src/libs6/s6_accessrules_keycheck_uidgid.lo src/libs6/s6_accessrules_params_free.lo src/libs6/s6_accessrules_uidgid_cdb.lo src/libs6/s6_accessrules_uidgid_fs.lo src/libs6/s6_compat_el_semicolon.lo src/libs6/s6_dtally_pack.lo src/libs6/s6_dtally_unpack.lo src/libs6/s6_dtally_read.lo src/libs6/s6_dtally_write.lo src/libs6/s6_svc_ok.lo src/libs6/s6_svc_write.lo src/libs6/s6_svc_writectl.lo src/libs6/s6_svstatus_pack.lo src/libs6/s6_svstatus_read.lo src/libs6/s6_svstatus_unpack.lo src/libs6/s6_svstatus_write.lo src/libs6/s6lock_acquire.lo src/libs6/s6lock_check.lo src/libs6/s6lock_end.lo src/libs6/s6lock_release.lo src/libs6/s6lock_start.lo src/libs6/s6lock_startf.lo src/libs6/s6lock_update.lo src/libs6/s6lock_wait_and.lo src/libs6/s6lock_wait_or.lo src/libs6/s6lock_zero.lo src/libs6/s6_fdholder_delete.lo src/libs6/s6_fdholder_delete_async.lo src/libs6/s6_fdholder_end.lo src/libs6/s6_fdholder_getdump.lo src/libs6/s6_fdholder_list.lo src/libs6/s6_fdholder_list_async.lo src/libs6/s6_fdholder_list_cb.lo src/libs6/s6_fdholder_retrieve.lo src/libs6/s6_fdholder_retrieve_async.lo src/libs6/s6_fdholder_retrieve_cb.lo src/libs6/s6_fdholder_setdump.lo src/libs6/s6_fdholder_start.lo src/libs6/s6_fdholder_store.lo src/libs6/s6_fdholder_store_async.lo src/libs6/s6_supervise_link.lo src/libs6/s6_supervise_unlink.lo +libs6.so.xyzzy: src/libs6/ftrigr1_zero.lo src/libs6/ftrigr_check.lo src/libs6/ftrigr_checksa.lo src/libs6/ftrigr_ack.lo src/libs6/ftrigr_end.lo src/libs6/ftrigr_start.lo src/libs6/ftrigr_startf.lo src/libs6/ftrigr_subscribe.lo src/libs6/ftrigr_unsubscribe.lo src/libs6/ftrigr_update.lo src/libs6/ftrigr_updateb.lo src/libs6/ftrigr_wait_and.lo src/libs6/ftrigr_wait_or.lo src/libs6/ftrigr_zero.lo src/libs6/ftrigw_clean.lo src/libs6/ftrigw_fifodir_make.lo src/libs6/ftrigw_notify.lo src/libs6/ftrigw_notifyb.lo src/libs6/ftrigw_notifyb_nosig.lo src/libs6/s6_accessrules_backend_cdb.lo src/libs6/s6_accessrules_backend_fs.lo src/libs6/s6_accessrules_keycheck_ip4.lo src/libs6/s6_accessrules_keycheck_ip6.lo src/libs6/s6_accessrules_keycheck_reversedns.lo src/libs6/s6_accessrules_keycheck_uidgid.lo src/libs6/s6_accessrules_params_free.lo src/libs6/s6_accessrules_uidgid_cdb.lo src/libs6/s6_accessrules_uidgid_fs.lo src/libs6/s6_compat_el_semicolon.lo src/libs6/s6_dtally_pack.lo src/libs6/s6_dtally_unpack.lo src/libs6/s6_dtally_read.lo src/libs6/s6_dtally_write.lo src/libs6/s6_svc_ok.lo src/libs6/s6_svc_write.lo src/libs6/s6_svc_writectl.lo src/libs6/s6_svstatus_pack.lo src/libs6/s6_svstatus_read.lo src/libs6/s6_svstatus_unpack.lo src/libs6/s6_svstatus_write.lo src/libs6/s6lock_acquire.lo src/libs6/s6lock_check.lo src/libs6/s6lock_end.lo src/libs6/s6lock_release.lo src/libs6/s6lock_start.lo src/libs6/s6lock_startf.lo src/libs6/s6lock_update.lo src/libs6/s6lock_wait_and.lo src/libs6/s6lock_wait_or.lo src/libs6/s6lock_zero.lo src/libs6/s6_fdholder_delete.lo src/libs6/s6_fdholder_delete_async.lo src/libs6/s6_fdholder_end.lo src/libs6/s6_fdholder_getdump.lo src/libs6/s6_fdholder_list.lo src/libs6/s6_fdholder_list_async.lo src/libs6/s6_fdholder_list_cb.lo src/libs6/s6_fdholder_retrieve.lo src/libs6/s6_fdholder_retrieve_async.lo src/libs6/s6_fdholder_retrieve_cb.lo src/libs6/s6_fdholder_setdump.lo src/libs6/s6_fdholder_start.lo src/libs6/s6_fdholder_store.lo src/libs6/s6_fdholder_store_async.lo src/libs6/s6_supervise_link.lo src/libs6/s6_supervise_link_names.lo src/libs6/s6_supervise_unlink.lo src/libs6/s6_supervise_unlink_names.lo +ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),) +libs6lockd.a.xyzzy: src/libs6/s6lockd_openandlock.o +else +libs6lockd.a.xyzzy: src/libs6/s6lockd_openandlock.lo +endif s6-ftrigrd: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} s6-ftrigrd: src/libs6/s6-ftrigrd.o src/libs6/ftrig1_free.o src/libs6/ftrig1_make.o s6lockd: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} ${SPAWN_LIB} s6lockd: src/libs6/s6lockd.o s6lockd-helper: EXTRA_LIBS := -lskarnet -s6lockd-helper: src/libs6/s6lockd-helper.o +s6lockd-helper: src/libs6/s6lockd-helper.o libs6lockd.a.xyzzy s6-cleanfifodir: EXTRA_LIBS := -lskarnet s6-cleanfifodir: src/pipe-tools/s6-cleanfifodir.o ${LIBS6} s6-ftrig-listen: EXTRA_LIBS := ${EXECLINE_LIB} -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} ${SPAWN_LIB} @@ -238,6 +252,8 @@ s6-svdt: src/supervision/s6-svdt.o ${LIBS6} s6-svdt-clear: EXTRA_LIBS := -lskarnet s6-svdt-clear: src/supervision/s6-svdt-clear.o ${LIBS6} +s6-svlink: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} ${SPAWN_LIB} +s6-svlink: src/supervision/s6-svlink.o ${LIBS6} s6-svlisten: EXTRA_LIBS := ${EXECLINE_LIB} -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} ${SPAWN_LIB} s6-svlisten: src/supervision/s6-svlisten.o src/supervision/s6_svlisten_signal_handler.o src/supervision/s6_svlisten_loop.o ${LIBS6} s6-svlisten1: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} ${SPAWN_LIB} @@ -252,7 +268,10 @@ s6-svscanctl: src/supervision/s6-svscanctl.o ${LIBS6} s6-svstat: EXTRA_LIBS := -lskarnet ${SYSCLOCK_LIB} s6-svstat: src/supervision/s6-svstat.o ${LIBS6} +s6-svunlink: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} ${SPAWN_LIB} +s6-svunlink: src/supervision/s6-svunlink.o ${LIBS6} s6-svwait: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} ${SPAWN_LIB} s6-svwait: src/supervision/s6-svwait.o src/supervision/s6_svlisten_loop.o ${LIBS6} s6-usertree-maker: EXTRA_LIBS := -lskarnet s6-usertree-maker: src/usertree/s6-usertree-maker.o +INTERNAL_LIBS := libs6lockd.a.xyzzy diff -Nru s6-2.10.0.2/package/info s6-2.11.0.0/package/info --- s6-2.10.0.2/package/info 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/package/info 2021-09-26 14:04:15.000000000 +0000 @@ -1,4 +1,4 @@ package=s6 -version=2.10.0.2 +version=2.11.0.0 category=admin package_macro_name=S6 diff -Nru s6-2.10.0.2/package/modes s6-2.11.0.0/package/modes --- s6-2.10.0.2/package/modes 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/package/modes 2021-09-26 14:04:15.000000000 +0000 @@ -11,6 +11,8 @@ s6-svscan 0755 s6-supervise 0755 s6-svc 0755 +s6-svlink 0755 +s6-svunlink 0755 s6-svscanctl 0755 s6-svok 0755 s6-svstat 0755 @@ -31,6 +33,7 @@ s6-setsid 0755 s6-setuidgid 0700 s6-softlimit 0755 +s6-socklog 0755 s6-tai64n 0755 s6-tai64nlocal 0755 s6-accessrules-cdb-from-fs 0755 diff -Nru s6-2.10.0.2/package/targets.mak s6-2.11.0.0/package/targets.mak --- s6-2.10.0.2/package/targets.mak 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/package/targets.mak 2021-09-26 14:04:15.000000000 +0000 @@ -21,6 +21,8 @@ s6-svlisten1 \ s6-svlisten \ s6-svperms \ +s6-svlink \ +s6-svunlink \ s6-notifyoncheck \ s6-envdir \ s6-envuidgid \ @@ -29,6 +31,7 @@ s6-setlock \ s6-setsid \ s6-softlimit \ +s6-socklog \ s6-tai64n \ s6-tai64nlocal \ s6-accessrules-cdb-from-fs \ diff -Nru s6-2.10.0.2/src/conn-tools/s6-accessrules-cdb-from-fs.c s6-2.11.0.0/src/conn-tools/s6-accessrules-cdb-from-fs.c --- s6-2.10.0.2/src/conn-tools/s6-accessrules-cdb-from-fs.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/conn-tools/s6-accessrules-cdb-from-fs.c 2021-09-26 14:04:15.000000000 +0000 @@ -5,9 +5,10 @@ #include #include #include + #include #include -#include +#include #include #include #include @@ -31,7 +32,7 @@ strerr_diefu1sys(111, "stralloc_catb") ; } -static void doit (struct cdb_make *c, stralloc *sa, size_t start) +static void doit (cdbmaker *c, stralloc *sa, size_t start) { size_t tmpbase = tmp.len ; unsigned int k = sa->len ; @@ -54,10 +55,10 @@ strerr_diefu2sys(111, "access ", sa->s) ; } else return ; - else if (cdb_make_add(c, sa->s + start, k - start, "D", 1) < 0) + else if (!cdbmake_add(c, sa->s + start, k - start, "D", 1)) { cleanup() ; - strerr_diefu1sys(111, "cdb_make_add") ; + strerr_diefu1sys(111, "cdbmake_add") ; } } else @@ -93,10 +94,10 @@ if (r > 0) execlen = r ; if (execlen == 4096) strerr_warnw2x("possibly truncated file ", sa->s) ; uint16_pack_big(tmp.s + tmpbase + 3 + envlen, execlen) ; - if (cdb_make_add(c, sa->s + start, k - start, tmp.s + tmpbase, 5 + envlen + execlen) < 0) + if (!cdbmake_add(c, sa->s + start, k - start, tmp.s + tmpbase, 5 + envlen + execlen)) { cleanup() ; - strerr_diefu1sys(111, "cdb_make_add") ; + strerr_diefu1sys(111, "cdbmake_add") ; } } } @@ -104,7 +105,7 @@ int main (int argc, char const *const *argv) { stralloc sa = STRALLOC_ZERO ; - struct cdb_make c = CDB_MAKE_ZERO ; + cdbmaker c = CDBMAKER_ZERO ; DIR *dir ; size_t start ; int fd ; @@ -116,10 +117,10 @@ stralloc_catb(&tmp, SUFFIX, sizeof(SUFFIX)) ; fd = mkstemp(tmp.s) ; if (fd < 0) strerr_diefu2sys(111, "mkstemp ", tmp.s) ; - if (cdb_make_start(&c, fd) < 0) + if (!cdbmake_start(&c, fd)) { cleanup() ; - strerr_diefu1sys(111, "cdb_make_start") ; + strerr_diefu1sys(111, "cdbmake_start") ; } dir = opendir(argv[2]) ; if (!dir) @@ -173,7 +174,7 @@ strerr_diefu2sys(111, "readdir ", argv[2]) ; } dir_close(dir) ; - if (cdb_make_finish(&c) < 0) + if (!cdbmake_finish(&c)) { cleanup() ; strerr_diefu1sys(111, "cdb_make_finish") ; diff -Nru s6-2.10.0.2/src/conn-tools/s6-accessrules-fs-from-cdb.c s6-2.11.0.0/src/conn-tools/s6-accessrules-fs-from-cdb.c --- s6-2.10.0.2/src/conn-tools/s6-accessrules-fs-from-cdb.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/conn-tools/s6-accessrules-fs-from-cdb.c 2021-09-26 14:04:15.000000000 +0000 @@ -5,6 +5,7 @@ #include #include #include + #include #include #include @@ -51,11 +52,15 @@ static void touchtrunc (char const *file) { int fd = open_trunc(file) ; - if (fd < 0) strerr_diefu2sys(111, "open_trunc ", file) ; + if (fd < 0) + { + cleanup() ; + strerr_diefu2sys(111, "open_trunc ", file) ; + } fd_close(fd) ; } -static int doenv (char const *dir, size_t dirlen, char *env, size_t envlen) +static int doenv (char const *dir, size_t dirlen, char const *env, uint32_t envlen) { mode_t m = umask(0) ; size_t i = 0 ; @@ -78,12 +83,12 @@ tmp[dirlen + p + 1] = 0 ; if (p < n) { - env[i+n] = '\n' ; - if (!openwritenclose_unsafe(tmp, env + i + p + 1, n - p)) - { - cleanup() ; - strerr_diefu2sys(111, "openwritenclose_unsafe ", tmp) ; - } + struct iovec v[2] = { { .iov_base = (char *)env + i + p + 1, .iov_len = n - p - 1 }, { .iov_base = "\n", .iov_len = 1 } } ; + if (!openwritevnclose_unsafe(tmp, v, 2)) + { + cleanup() ; + strerr_diefu2sys(111, "openwritenclose_unsafe ", tmp) ; + } } else touchtrunc(tmp) ; } @@ -92,48 +97,41 @@ return 1 ; } -static int doit (struct cdb *c) +static int doit (char const *key, uint32_t klen, char const *data, uint32_t dlen) { - unsigned int klen = cdb_keylen(c) ; - unsigned int dlen = cdb_datalen(c) ; + uint16_t envlen, execlen ; + char name[basedirlen + klen + 8] ; + if (!dlen || (dlen > 8201)) return 0 ; + memcpy(name, basedir, basedirlen) ; + name[basedirlen] = '/' ; + memcpy(name + basedirlen + 1, key, klen) ; + name[basedirlen + klen + 1 + klen] = 0 ; + mkdirp(name) ; + name[basedirlen + klen + 1] = '/' ; + if (data[0] == 'A') + { + memcpy(name + basedirlen + klen + 2, "allow", 6) ; + touchtrunc(name) ; + } + else if (data[0] == 'D') + { + memcpy(name + basedirlen + klen + 2, "deny", 5) ; + touchtrunc(name) ; + } + if (dlen < 3) return 1 ; + uint16_unpack_big(data + 1, &envlen) ; + if ((envlen > 4096U) || (3U + envlen > dlen)) return 0 ; + uint16_unpack_big(data + 3 + envlen, &execlen) ; + if ((execlen > 4096U) || (5U + envlen + execlen != dlen)) return 0 ; + if (envlen) + { + memcpy(name + basedirlen + klen + 2, "env", 4) ; + if (!doenv(name, basedirlen + klen + 5, data + 3, envlen)) return 0 ; + } + if (execlen) { - uint16_t envlen, execlen ; - char name[basedirlen + klen + 8] ; - char data[dlen] ; - memcpy(name, basedir, basedirlen) ; - name[basedirlen] = '/' ; - if (!dlen || (dlen > 8201)) return (errno = EINVAL, 0) ; - if ((cdb_read(c, name+basedirlen+1, klen, cdb_keypos(c)) < 0) - || (cdb_read(c, data, dlen, cdb_datapos(c)) < 0)) - { - cleanup() ; - strerr_diefu1sys(111, "cdb_read") ; - } - name[basedirlen + klen + 1] = 0 ; - mkdirp(name) ; - name[basedirlen + klen + 1] = '/' ; - if (data[0] == 'A') - { - memcpy(name + basedirlen + klen + 2, "allow", 6) ; - touchtrunc(name) ; - } - else if (data[0] == 'D') - { - memcpy(name + basedirlen + klen + 2, "deny", 5) ; - touchtrunc(name) ; - } - if (dlen < 3) return 1 ; - uint16_unpack_big(data + 1, &envlen) ; - if ((envlen > 4096U) || (3U + envlen > dlen)) return (errno = EINVAL, 0) ; - uint16_unpack_big(data + 3 + envlen, &execlen) ; - if ((execlen > 4096U) || (5U + envlen + execlen != dlen)) return (errno = EINVAL, 0) ; - if (envlen) - { - memcpy(name + basedirlen + klen + 2, "env", 4) ; - if (!doenv(name, basedirlen + klen + 5, data + 3, envlen)) return (errno = EINVAL, 0) ; - } memcpy(name + basedirlen + klen + 2, "exec", 5) ; - if (execlen && !openwritenclose_unsafe(name, data + 5 + envlen, execlen)) + if (!openwritenclose_unsafe(name, data + 5 + envlen, execlen)) { cleanup() ; strerr_diefu2sys(111, "openwritenclose_unsafe ", name) ; @@ -144,11 +142,11 @@ int main (int argc, char const *const *argv) { - struct cdb c = CDB_ZERO ; - uint32_t kpos ; + cdb c = CDB_ZERO ; + uint32_t pos = CDB_TRAVERSE_INIT() ; PROG = "s6-accessrules-fs-from-cdb" ; if (argc < 3) strerr_dieusage(100, USAGE) ; - if (cdb_mapfile(&c, argv[2]) < 0) strerr_diefu1sys(111, "cdb_mapfile") ; + if (!cdb_init(&c, argv[2])) strerr_diefu1sys(111, "cdb_init") ; basedir = argv[1] ; basedirlen = strlen(argv[1]) ; { @@ -157,20 +155,20 @@ strerr_diefu2sys(111, "mkdir ", basedir) ; umask(m) ; } - cdb_traverse_init(&c, &kpos) ; for (;;) { - int r = cdb_nextkey(&c, &kpos) ; + cdb_data key, data ; + int r = cdb_traverse_next(&c, &key, &data, &pos) ; if (r < 0) { cleanup() ; - strerr_diefu1sys(111, "cdb_nextkey") ; + strerr_diefu1x(111, "cdb_traverse_next: invalid cdb") ; } else if (!r) break ; - else if (!doit(&c)) + else if (!doit(key.s, key.len, data.s, data.len)) { cleanup() ; - strerr_diefu1sys(111, "handle key") ; + strerr_diefu3x(111, "handle cdb record: ", argv[2], " does not contain valid accessrules data") ; } } return 0 ; diff -Nru s6-2.10.0.2/src/conn-tools/s6-ioconnect.c s6-2.11.0.0/src/conn-tools/s6-ioconnect.c --- s6-2.10.0.2/src/conn-tools/s6-ioconnect.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/conn-tools/s6-ioconnect.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,7 +1,5 @@ /* ISC license. */ -#include -#include #include #include @@ -9,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -20,35 +18,37 @@ #define USAGE "s6-ioconnect [ -t timeout ] [ -r fdr ] [ -w fdw ] [ -0 ] [ -1 ] [ -6 ] [ -7 ]" #define dieusage() strerr_dieusage(100, USAGE) -typedef struct ioblah_s ioblah_t, *ioblah_t_ref ; +#define BSIZE 8192 + +typedef struct ioblah_s ioblah, *ioblah_ref ; struct ioblah_s { - unsigned int fd ; + buffer b ; unsigned int xindex ; unsigned int flagsocket : 1 ; - unsigned int flagopen : 1 ; } ; -static ioblah_t a[2][2] = { { { 0, 4, 0, 1 }, { 7, 4, 0, 1 } }, { { 6, 4, 0, 1 }, { 1, 4, 0, 1 } } } ; -static iobuffer b[2] ; -static iopause_fd x[5] = { { -1, IOPAUSE_READ, 0 } } ; - -static void closeit (unsigned int i, unsigned int j) +static char buf[2][BSIZE] = { { '\0' }, { '\0' } } ; +static ioblah a[2][2] = { - if (a[i][j].flagsocket) { - if ((shutdown(a[i][j].fd, j) < 0) && (errno != ENOTSOCK) && (errno != ENOTCONN)) - strerr_warnwu4sys("shutdown ", i ? "incoming" : "outgoing", " socket for ", j ? "writing" : "reading") ; + { .b = BUFFER_INIT(&buffer_read, 0, buf[0], BSIZE), .xindex = 5, .flagsocket = 0 }, + { .b = BUFFER_INIT(&buffer_write, 7, buf[0], BSIZE), .xindex = 5, .flagsocket = 0 } + }, + { + { .b = BUFFER_INIT(&buffer_read, 6, buf[1], BSIZE), .xindex = 5, .flagsocket = 0 }, + { .b = BUFFER_INIT(&buffer_write, 1, buf[1], BSIZE), .xindex = 5, .flagsocket = 0 } } - fd_close(a[i][j].fd) ; - a[i][j].flagopen = 0 ; - a[i][j].xindex = 5 ; -} +} ; +static iopause_fd x[5] = { [0] = { .fd = -1, .events = IOPAUSE_READ } } ; -static inline void finishit (unsigned int i) +static void closeit (unsigned int i, unsigned int j) { - closeit(i, 1) ; - iobuffer_finish(&b[i]) ; + int fd = buffer_fd(&a[i][j].b) ; + if (a[i][j].flagsocket) fd_shutdown(fd, j) ; + fd_close(fd) ; + buffer_fd(&a[i][j].b) = -1 ; + a[i][j].xindex = 5 ; } static void handle_signals (void) @@ -71,13 +71,27 @@ } } +static int flushit (unsigned int i) +{ + int r = buffer_flush(&a[i][1].b) ; + a[i][0].b.c.p = a[i][1].b.c.p ; /* XXX: abstraction leak */ + return r ; +} + +static int fillit (unsigned int i) +{ + ssize_t r = sanitize_read(buffer_fill(&a[i][0].b)) ; + a[i][1].b.c.n = a[i][0].b.c.n ; /* XXX: abstraction leak */ + return r >= 0 ; +} + int main (int argc, char const *const *argv) { - tain_t tto ; + tain tto ; unsigned int i, j ; PROG = "s6-ioconnect" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; unsigned int t = 0 ; for (;;) { @@ -90,96 +104,108 @@ case '6' : a[1][0].flagsocket = 1 ; break ; case '7' : a[0][1].flagsocket = 1 ; break ; case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; - case 'r' : if (!uint0_scan(l.arg, &a[1][0].fd)) dieusage() ; break ; - case 'w' : if (!uint0_scan(l.arg, &a[0][1].fd)) dieusage() ; break ; + case 'r' : if (!int0_scan(l.arg, &buffer_fd(&a[1][0].b))) dieusage() ; break ; + case 'w' : if (!int0_scan(l.arg, &buffer_fd(&a[0][1].b))) dieusage() ; break ; default : dieusage() ; } } if (t) tain_from_millisecs(&tto, t) ; else tto = tain_infinite_relative ; argc -= l.ind ; argv += l.ind ; } - if ((a[0][1].fd < 3) || (a[1][0].fd < 3)) dieusage() ; + if ((buffer_fd(&a[0][1].b) < 3) || (buffer_fd(&a[1][0].b) < 3)) dieusage() ; for (i = 0 ; i < 2 ; i++) - { for (j = 0 ; j < 2 ; j++) - if (ndelay_on(a[i][j].fd) == -1) strerr_diefu1sys(111, "ndelay_on") ; - if (!iobuffer_init(&b[i], a[i][0].fd, a[i][1].fd)) strerr_diefu1sys(111, "iobuffer_init") ; - } - if (sig_ignore(SIGPIPE) == -1) strerr_diefu1sys(111, "sig_ignore") ; + if (ndelay_on(buffer_fd(&a[i][j].b)) == -1) + { + char fmt[INT_FMT] ; + fmt[int_fmt(fmt, buffer_fd(&a[i][j].b))] = 0 ; + strerr_diefu3sys(111, "set fd ", fmt, " non-blocking") ; + } + if (!sig_ignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; tain_now_set_stopwatch_g() ; x[0].fd = selfpipe_init() ; if (x[0].fd < 0) strerr_diefu1sys(111, "selfpipe_init") ; - if (selfpipe_trap(SIGTERM) < 0) + if (!selfpipe_trap(SIGTERM)) strerr_diefu1sys(111, "trap SIGTERM") ; for (;;) { - tain_t deadline ; + tain deadline ; unsigned int xlen = 1 ; - int r ; + tain_add_g(&deadline, buffer_isempty(&a[0][1].b) && buffer_isempty(&a[1][1].b) ? &tto : &tain_infinite_relative) ; - tain_add_g(&deadline, iobuffer_isempty(&b[0]) && iobuffer_isempty(&b[1]) ? &tto : &tain_infinite_relative) ; for (i = 0 ; i < 2 ; i++) { - a[i][0].xindex = 5 ; - if (a[i][0].flagopen && iobuffer_isreadable(&b[i])) + if (buffer_fd(&a[i][0].b) >= 0 && buffer_isreadable(&a[i][0].b)) { - x[xlen].fd = a[i][0].fd ; + x[xlen].fd = buffer_fd(&a[i][0].b) ; x[xlen].events = IOPAUSE_READ ; a[i][0].xindex = xlen++ ; } - a[i][1].xindex = 5 ; - if (a[i][1].flagopen) + else a[i][0].xindex = 5 ; + if (buffer_fd(&a[i][1].b) >= 0) { - x[xlen].fd = a[i][1].fd ; - x[xlen].events = IOPAUSE_EXCEPT | (iobuffer_isempty(&b[i]) ? 0 : IOPAUSE_WRITE) ; + x[xlen].fd = buffer_fd(&a[i][1].b) ; + x[xlen].events = IOPAUSE_EXCEPT | (buffer_iswritable(&a[i][1].b) ? IOPAUSE_WRITE : 0) ; a[i][1].xindex = xlen++ ; } + else a[i][1].xindex = 5 ; } - if (xlen <= 1) break ; + if (xlen == 1) break ; - r = iopause_g(x, xlen, &deadline) ; - if (r < 0) strerr_diefu1sys(111, "iopause") ; - else if (!r) return 1 ; + { + int r = iopause_g(x, xlen, &deadline) ; + if (r < 0) strerr_diefu1sys(111, "iopause") ; + else if (!r) return 1 ; + } if (x[0].revents & IOPAUSE_READ) handle_signals() ; for (i = 0 ; i < 2 ; i++) if (a[i][1].xindex < 5) { - if (x[a[i][1].xindex].revents & IOPAUSE_WRITE) + int dead = 0 ; + if (x[a[i][1].xindex].revents & IOPAUSE_EXCEPT) { - if (!iobuffer_flush(&b[i])) + if (!buffer_isempty(&a[i][1].b)) { - if (!error_isagain(errno)) x[a[i][1].xindex].revents |= IOPAUSE_EXCEPT ; + char fmt[INT_FMT] ; + fmt[int_fmt(fmt, buffer_fd(&a[i][1].b))] = 0 ; + flushit(i) ; /* sets errno */ + strerr_warnwu2sys("write to fd ", fmt) ; } - else if (!a[i][0].flagopen) finishit(i) ; + dead = 1 ; } - if (x[a[i][1].xindex].revents & IOPAUSE_EXCEPT) + else if (x[a[i][1].xindex].revents & IOPAUSE_WRITE) { - if (!iobuffer_isempty(&b[i])) + if (!flushit(i)) { - iobuffer_flush(&b[i]) ; /* sets errno */ - strerr_warnwu3sys("write ", i ? "incoming" : "outgoing", " data") ; + if (!error_isagain(errno)) dead = 1 ; } - closeit(i, 0) ; finishit(i) ; + else if (buffer_fd(&a[i][0].b) == -1) dead = 1 ; + } + if (dead) + { + if (buffer_fd(&a[i][0].b) >= 0) closeit(i, 0) ; + closeit(i, 1) ; } } for (i = 0 ; i < 2 ; i++) if (a[i][0].xindex < 5) { - if (x[a[i][0].xindex].revents & IOPAUSE_READ) + if (x[a[i][0].xindex].revents & (IOPAUSE_READ | IOPAUSE_EXCEPT)) { - if (sanitize_read(iobuffer_fill(&b[i])) < 0) + if (!fillit(i)) { - if (errno != EPIPE) strerr_warnwu3sys("read ", i ? "incoming" : "outgoing", " data") ; - x[a[i][0].xindex].revents |= IOPAUSE_EXCEPT ; + if (errno != EPIPE) + { + char fmt[INT_FMT] ; + fmt[int_fmt(fmt, buffer_fd(&a[i][0].b))] = 0 ; + strerr_warnwu2sys("read from fd ", fmt) ; + } + closeit(i, 0) ; + if (buffer_isempty(&a[i][1].b)) closeit(i, 1) ; } } - if (x[a[i][0].xindex].revents & IOPAUSE_EXCEPT) - { - closeit(i, 0) ; - if (iobuffer_isempty(&b[i])) finishit(i) ; - } } } return 0 ; diff -Nru s6-2.10.0.2/src/conn-tools/s6-ipcclient.c s6-2.11.0.0/src/conn-tools/s6-ipcclient.c --- s6-2.10.0.2/src/conn-tools/s6-ipcclient.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/conn-tools/s6-ipcclient.c 2021-09-26 14:04:15.000000000 +0000 @@ -17,7 +17,7 @@ unsigned int verbosity = 1 ; PROG = "s6-ipcclient" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "qQvp:l:", &l) ; diff -Nru s6-2.10.0.2/src/conn-tools/s6-ipcserver-access.c s6-2.11.0.0/src/conn-tools/s6-ipcserver-access.c --- s6-2.10.0.2/src/conn-tools/s6-ipcserver-access.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/conn-tools/s6-ipcserver-access.c 2021-09-26 14:04:15.000000000 +0000 @@ -75,14 +75,11 @@ static s6_accessrules_result_t check_cdb (uid_t uid, gid_t gid, char const *file, s6_accessrules_params_t *params) { - struct cdb c = CDB_ZERO ; - int fd = open_readb(file) ; + cdb c = CDB_ZERO ; s6_accessrules_result_t r ; - if (fd < 0) return -1 ; - if (cdb_init(&c, fd) < 0) strerr_diefu2sys(111, "cdb_init ", file) ; + if (!cdb_init(&c, file)) strerr_diefu2sys(111, "cdb_init ", file) ; r = s6_accessrules_uidgid_cdb(uid, gid, &c, params) ; cdb_free(&c) ; - fd_close(fd) ; return r ; } @@ -128,7 +125,7 @@ int doenv = 1 ; PROG = "s6-ipcserver-access" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "v:Eel:i:x:", &l) ; diff -Nru s6-2.10.0.2/src/conn-tools/s6-ipcserver.c s6-2.11.0.0/src/conn-tools/s6-ipcserver.c --- s6-2.10.0.2/src/conn-tools/s6-ipcserver.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/conn-tools/s6-ipcserver.c 2021-09-26 14:04:15.000000000 +0000 @@ -30,7 +30,7 @@ unsigned int socketperms = 0777 ; PROG = "s6-ipcserver" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "qQvDd1UPpc:C:b:a:u:g:G:", &l) ; diff -Nru s6-2.10.0.2/src/conn-tools/s6-ipcserverd.c s6-2.11.0.0/src/conn-tools/s6-ipcserverd.c --- s6-2.10.0.2/src/conn-tools/s6-ipcserverd.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/conn-tools/s6-ipcserverd.c 2021-09-26 14:04:15.000000000 +0000 @@ -235,7 +235,7 @@ unsigned int n = 0 ; char fmt[65 + UID_FMT + GID_FMT + UINT_FMT + rplen] ; PROG = "s6-ipcserver (child)" ; - if ((fd_move(0, s) < 0) || (fd_copy(1, 0) < 0)) + if ((fd_move(1, s) < 0) || (fd_copy(0, 1) < 0)) strerr_diefu1sys(111, "move fds") ; memcpy(fmt+n, "PROTO=IPC\0IPCREMOTEEUID", 23) ; n += 23 ; if (flaglookup) @@ -286,7 +286,6 @@ else if (!pid) { selfpipe_finish() ; - sig_restore(SIGPIPE) ; run_child(s, uid, gid, num+1, remotepath, argv) ; } @@ -311,7 +310,7 @@ iopause_fd x[2] = { { .events = IOPAUSE_READ }, { .fd = 0, .events = IOPAUSE_READ | IOPAUSE_EXCEPT } } ; PROG = "s6-ipcserverd" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; int flag1 = 0 ; for (;;) { @@ -348,7 +347,7 @@ x[0].fd = selfpipe_init() ; if (x[0].fd == -1) strerr_diefu1sys(111, "create selfpipe") ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; + if (!sig_altignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; { sigset_t set ; sigemptyset(&set) ; @@ -357,7 +356,7 @@ sigaddset(&set, SIGHUP) ; sigaddset(&set, SIGQUIT) ; sigaddset(&set, SIGABRT) ; - if (selfpipe_trapset(&set) < 0) strerr_diefu1sys(111, "trap signals") ; + if (!selfpipe_trapset(&set)) strerr_diefu1sys(111, "trap signals") ; } fmtlocalmaxconn[1+uint_fmt(fmtlocalmaxconn+1, localmaxconn)] = 0 ; diff -Nru s6-2.10.0.2/src/conn-tools/s6-ipcserver-socketbinder.c s6-2.11.0.0/src/conn-tools/s6-ipcserver-socketbinder.c --- s6-2.10.0.2/src/conn-tools/s6-ipcserver-socketbinder.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/conn-tools/s6-ipcserver-socketbinder.c 2021-09-26 14:04:15.000000000 +0000 @@ -24,7 +24,7 @@ unsigned int perms = 0777 ; PROG = "s6-ipcserver-socketbinder" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "DdMmBb:a:", &l) ; diff -Nru s6-2.10.0.2/src/conn-tools/s6-sudo.c s6-2.11.0.0/src/conn-tools/s6-sudo.c --- s6-2.10.0.2/src/conn-tools/s6-sudo.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/conn-tools/s6-sudo.c 2021-09-26 14:04:15.000000000 +0000 @@ -18,7 +18,7 @@ int nodoenv = 0 ; PROG = "s6-sudo" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "qQvp:l:et:T:", &l) ; diff -Nru s6-2.10.0.2/src/conn-tools/s6-sudoc.c s6-2.11.0.0/src/conn-tools/s6-sudoc.c --- s6-2.10.0.2/src/conn-tools/s6-sudoc.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/conn-tools/s6-sudoc.c 2021-09-26 14:04:15.000000000 +0000 @@ -29,12 +29,12 @@ { char buf6[64] ; buffer b6 = BUFFER_INIT(&buffer_read, 6, buf6, 64) ; - unixmessage_sender_t b7 = UNIXMESSAGE_SENDER_INIT(7) ; - subgetopt_t l = SUBGETOPT_ZERO ; + unixmessage_sender b7 = UNIXMESSAGE_SENDER_INIT(7) ; + subgetopt l = SUBGETOPT_ZERO ; unsigned int t = 0, T = 0 ; int doenv = 1 ; - tain_t deadline = TAIN_INFINITE_RELATIVE ; + tain deadline = TAIN_INFINITE_RELATIVE ; PROG = "s6-sudoc" ; for (;;) { @@ -76,7 +76,7 @@ { .iov_base = pack, .iov_len = 16 }, { .iov_base = 0, .iov_len = 0 }, { .iov_base = 0, .iov_len = 0 } } ; - unixmessage_v_t mv = { .v = v, .vlen = 4, .fds = fds, .nfds = 3 } ; + unixmessagev mv = { .v = v, .vlen = 4, .fds = fds, .nfds = 3 } ; stralloc sa = STRALLOC_ZERO ; size_t envlen = doenv ? env_len(envp) : 0 ; uint32_pack_big(pack, (uint32_t)argc) ; diff -Nru s6-2.10.0.2/src/conn-tools/s6-sudod.c s6-2.11.0.0/src/conn-tools/s6-sudod.c --- s6-2.10.0.2/src/conn-tools/s6-sudod.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/conn-tools/s6-sudod.c 2021-09-26 14:04:15.000000000 +0000 @@ -61,17 +61,17 @@ int main (int argc, char const *const *argv, char const *const *envp) { iopause_fd x[2] = { { .events = IOPAUSE_READ }, { .fd = 0, .events = 0, .revents = 0 } } ; - unixmessage_t m ; + unixmessage m ; unsigned int nullfds = 0 ; pid_t pid ; int wstat ; size_t envc = env_len(envp) ; uint32_t cargc, cenvc, carglen, cenvlen ; - tain_t deadline = TAIN_INFINITE_RELATIVE ; + tain deadline = TAIN_INFINITE_RELATIVE ; PROG = "s6-sudod" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; unsigned int t = 0 ; for (;;) { @@ -176,7 +176,7 @@ x[0].fd = selfpipe_init() ; if (x[0].fd < 0) strerr_diefu1sys(111, "selfpipe_init") ; - if (selfpipe_trap(SIGCHLD) < 0) strerr_diefu1sys(111, "trap SIGCHLD") ; + if (!selfpipe_trap(SIGCHLD)) strerr_diefu1sys(111, "trap SIGCHLD") ; if (pipecoe(p) < 0) strerr_diefu1sys(111, "pipe") ; pid = fork() ; if (pid < 0) strerr_diefu1sys(111, "fork") ; diff -Nru s6-2.10.0.2/src/daemontools-extras/deps-exe/s6-setlock s6-2.11.0.0/src/daemontools-extras/deps-exe/s6-setlock --- s6-2.10.0.2/src/daemontools-extras/deps-exe/s6-setlock 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/deps-exe/s6-setlock 2021-09-26 14:04:15.000000000 +0000 @@ -1,3 +1,4 @@ +libs6lockd.a.xyzzy -lskarnet ${SYSCLOCK_LIB} ${SPAWN_LIB} diff -Nru s6-2.10.0.2/src/daemontools-extras/deps-exe/s6-socklog s6-2.11.0.0/src/daemontools-extras/deps-exe/s6-socklog --- s6-2.10.0.2/src/daemontools-extras/deps-exe/s6-socklog 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/deps-exe/s6-socklog 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,4 @@ +lolsyslog.o +-lskarnet +${SOCKET_LIB} +${SYSCLOCK_LIB} diff -Nru s6-2.10.0.2/src/daemontools-extras/deps-exe/ucspilogd s6-2.11.0.0/src/daemontools-extras/deps-exe/ucspilogd --- s6-2.10.0.2/src/daemontools-extras/deps-exe/ucspilogd 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/deps-exe/ucspilogd 2021-09-26 14:04:15.000000000 +0000 @@ -1 +1,2 @@ +lolsyslog.o -lskarnet diff -Nru s6-2.10.0.2/src/daemontools-extras/lolsyslog.c s6-2.11.0.0/src/daemontools-extras/lolsyslog.c --- s6-2.10.0.2/src/daemontools-extras/lolsyslog.c 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/lolsyslog.c 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,90 @@ +/* ISC license. */ + +#undef INTERNAL_MARK +#ifndef SYSLOG_NAMES +#define SYSLOG_NAMES +#endif + +#include + +#include +#include + +#include + +#include "lolsyslog.h" + +#ifndef INTERNAL_MARK + +typedef struct CODE_s CODE, *CODE_ref ; +struct CODE_s +{ + char *c_name ; + unsigned int c_val ; +} ; + +#define LOG_PRI(p) ((p) & LOG_PRIMASK) +#define LOG_FAC(p) (((p) & LOG_FACMASK) / (LOG_PRIMASK + 1)) + +static CODE const facilitynames[] = +{ + { "kern", LOG_KERN }, + { "user", LOG_USER }, + { "mail", LOG_MAIL }, + { "news", LOG_NEWS }, + { "uucp", LOG_UUCP }, + { "daemon", LOG_DAEMON }, + { "auth", LOG_AUTH }, + { "cron", LOG_CRON }, + { "lpr", LOG_LPR }, +#ifdef LOG_SYSLOG + { "syslog", LOG_SYSLOG }, +#endif +#ifdef LOG_AUDIT + { "audit", LOG_AUDIT }, +#endif + { "local0", LOG_LOCAL0 }, + { "local1", LOG_LOCAL1 }, + { "local2", LOG_LOCAL2 }, + { "local3", LOG_LOCAL3 }, + { "local4", LOG_LOCAL4 }, + { "local5", LOG_LOCAL5 }, + { "local6", LOG_LOCAL6 }, + { "local7", LOG_LOCAL7 }, + { 0, -1 } +} ; + +static CODE const prioritynames[] = +{ + { "emerg", LOG_EMERG }, + { "alert", LOG_ALERT }, + { "crit", LOG_CRIT }, + { "err", LOG_ERR }, + { "warning", LOG_WARNING }, + { "notice", LOG_NOTICE }, + { "info", LOG_INFO }, + { "debug", LOG_DEBUG }, + { 0, -1 } +} ; + +#endif + +size_t lolsyslog_string (char *out, char const *in) +{ + size_t i ; + unsigned int fpr ; + int fp ; + CODE const *p = facilitynames ; + + if (in[0] != '<' || !(i = uint_scan(in+1, &fpr)) || in[1+i] != '>') return 0 ; + fp = LOG_FAC(fpr) << 3 ; + for (; p->c_name ; p++) if (p->c_val == fp) break ; + out = stpcpy(out, p->c_name ? p->c_name : "unknown") ; + *out++ = '.' ; + + fp = LOG_PRI(fpr) ; + for (p = prioritynames ; p->c_name ; p++) if (p->c_val == fp) break ; + out = stpcpy(out, p->c_name ? p->c_name : "unknown") ; + *out++ = ':' ; *out++ = ' ' ; *out++ = 0 ; + return i+2 ; +} diff -Nru s6-2.10.0.2/src/daemontools-extras/lolsyslog.h s6-2.11.0.0/src/daemontools-extras/lolsyslog.h --- s6-2.10.0.2/src/daemontools-extras/lolsyslog.h 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/lolsyslog.h 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,10 @@ +/* ISC license. */ + +#ifndef LOLSYSLOG_H +#define LOLSYSLOG_H + +#define LOLSYSLOG_STRING 32 + +extern size_t lolsyslog_string (char *, char const *) ; + +#endif diff -Nru s6-2.10.0.2/src/daemontools-extras/s6-applyuidgid.c s6-2.11.0.0/src/daemontools-extras/s6-applyuidgid.c --- s6-2.10.0.2/src/daemontools-extras/s6-applyuidgid.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/s6-applyuidgid.c 2021-09-26 14:04:15.000000000 +0000 @@ -24,7 +24,7 @@ int unexport = 0 ; PROG = "s6-applyuidgid" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "zUu:g:G:", &l) ; diff -Nru s6-2.10.0.2/src/daemontools-extras/s6-envdir.c s6-2.11.0.0/src/daemontools-extras/s6-envdir.c --- s6-2.10.0.2/src/daemontools-extras/s6-envdir.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/s6-envdir.c 2021-09-26 14:04:15.000000000 +0000 @@ -13,7 +13,7 @@ int main (int argc, char const *const *argv) { stralloc modifs = STRALLOC_ZERO ; - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; int insist = 1 ; unsigned int options = 0 ; char nullis = '\n' ; diff -Nru s6-2.10.0.2/src/daemontools-extras/s6-envuidgid.c s6-2.11.0.0/src/daemontools-extras/s6-envuidgid.c --- s6-2.10.0.2/src/daemontools-extras/s6-envuidgid.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/s6-envuidgid.c 2021-09-26 14:04:15.000000000 +0000 @@ -78,7 +78,7 @@ gid_t tab[NGROUPS_MAX] ; PROG = "s6-envuidgid" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, (char const *const *)argv, "ugBniD:", &l) ; diff -Nru s6-2.10.0.2/src/daemontools-extras/s6-log.c s6-2.11.0.0/src/daemontools-extras/s6-log.c --- s6-2.10.0.2/src/daemontools-extras/s6-log.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/s6-log.c 2021-09-26 14:04:15.000000000 +0000 @@ -39,7 +39,7 @@ #include #endif -#define USAGE "s6-log [ -d notif ] [ -q | -v ] [ -b ] [ -p ] [ -l linelimit ] logging_script" +#define USAGE "s6-log [ -d notif ] [ -q | -v ] [ -b ] [ -p ] [ -l linelimit ] [ -- ] logging_script" #define dieusage() strerr_dieusage(100, USAGE) #define dienomem() strerr_diefu1sys(111, "stralloc_catb") @@ -55,8 +55,8 @@ /* Data types */ -typedef int qcmpfunc_t (void const *, void const *) ; -typedef qcmpfunc_t *qcmpfunc_t_ref ; +typedef int qcmp_func (void const *, void const *) ; +typedef qcmp_func *qcmp_func_ref ; typedef enum rotstate_e rotstate_t, *rotstate_t_ref ; enum rotstate_e @@ -139,16 +139,16 @@ unsigned int actlen ; } ; -typedef void inputprocfunc_t (scriptelem_t const *, unsigned int, size_t, unsigned int) ; -typedef inputprocfunc_t *inputprocfunc_t_ref ; +typedef void inputproc_func (scriptelem_t const *, unsigned int, size_t, unsigned int) ; +typedef inputproc_func *inputproc_func_ref ; typedef struct logdir_s logdir_t, *logdir_t_ref ; struct logdir_s { bufalloc out ; unsigned int xindex ; - tain_t retrytto ; - tain_t deadline ; + tain retrytto ; + tain deadline ; uint64_t maxdirsize ; uint32_t b ; uint32_t n ; @@ -200,7 +200,7 @@ static int name_is_relevant (char const *name) { - tain_t dummy ; + tain dummy ; if (strlen(name) != 27) return 0 ; if (!timestamp_scan(name, &dummy)) return 0 ; if (name[25] != '.') return 0 ; @@ -226,8 +226,14 @@ dir_close(dir) ; return -1 ; } + if (!n) + { + dir_close(dir) ; + return 0 ; + } + rewinddir(dir) ; - if (n) + { uint64_t totalsize = 0 ; size_t dirlen = strlen(ldp->dir) ; @@ -264,7 +270,7 @@ dir_close(dir) ; if ((i <= ldp->n) && (!ldp->maxdirsize || (totalsize <= ldp->maxdirsize))) return 0 ; - qsort(archive, i, sizeof(struct filedesc_s), (qcmpfunc_t_ref)&filedesc_cmp) ; + qsort(archive, i, sizeof(struct filedesc_s), (qcmp_func_ref)&filedesc_cmp) ; n = 0 ; while ((i > ldp->n + n) || (ldp->maxdirsize && (totalsize > ldp->maxdirsize))) { @@ -329,7 +335,6 @@ if (fd < 0) strerr_diefu3sys(111, "open_trunc ", ldp->dir, "/newstate") ; if (fd_move(5, fd) < 0) strerr_diefu3sys(111, "fd_move ", ldp->dir, "/newstate") ; selfpipe_finish() ; - sig_restore(SIGPIPE) ; xexec(cargv) ; } @@ -549,7 +554,7 @@ bufalloc_flush(&ldp->out) ; } -static inline void logdir_init (unsigned int index, uint32_t s, uint32_t n, uint32_t tolerance, uint64_t maxdirsize, tain_t const *retrytto, char const *processor, char const *name, unsigned int flags) +static inline void logdir_init (unsigned int index, uint32_t s, uint32_t n, uint32_t tolerance, uint64_t maxdirsize, tain const *retrytto, char const *processor, char const *name, unsigned int flags) { logdir_t *ldp = logdirs + index ; struct stat st ; @@ -664,7 +669,7 @@ for (;;) { unsigned int i = 0 ; - tain_t deadline ; + tain deadline ; tain_addsec_g(&deadline, 2) ; for (; i < llen ; i++) if (logdirs[i].rstate != ROTSTATE_END) @@ -760,7 +765,7 @@ static inline void script_secondpass (char const *const *argv, scriptelem_t *script, sel_t *selections, act_t *actions) { - tain_t retrytto ; + tain retrytto ; unsigned int fd2_size = 200 ; unsigned int status_size = 1001 ; uint32_t s = 99999 ; @@ -901,7 +906,7 @@ char tstamp[TIMESTAMP+1] ; if (gflags & 3) { - tain_t now ; + tain now ; tain_wallclock_read(&now) ; if (gflags & 1) { @@ -910,7 +915,7 @@ } if (gflags & 2) { - localtmn_t l ; + localtmn l ; localtmn_from_tain(&l, &now, 1) ; hlen = localtmn_fmt(hstamp, &l) ; hstamp[hlen++] = ' ' ; @@ -1090,7 +1095,7 @@ } } -static inputprocfunc_t_ref handle_stdin = &normal_stdin ; +static inputproc_func_ref handle_stdin = &normal_stdin ; /* Signals */ @@ -1172,7 +1177,7 @@ int flagblock = 0 ; PROG = "s6-log" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "qvbpl:d:", &l) ; @@ -1215,7 +1220,7 @@ script_secondpass(argv, script, selections, actions) ; x[0].fd = selfpipe_init() ; if (x[0].fd < 0) strerr_diefu1sys(111, "selfpipe_init") ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "sig_ignore(SIGPIPE)") ; + if (!sig_altignore(SIGPIPE)) strerr_diefu1sys(111, "sig_ignore(SIGPIPE)") ; { sigset_t set ; sigemptyset(&set) ; @@ -1223,7 +1228,7 @@ sigaddset(&set, SIGHUP) ; sigaddset(&set, SIGALRM) ; sigaddset(&set, SIGCHLD) ; - if (selfpipe_trapset(&set) < 0) + if (!selfpipe_trapset(&set)) strerr_diefu1sys(111, "selfpipe_trapset") ; } x[0].events = IOPAUSE_READ ; @@ -1235,7 +1240,7 @@ for (;;) { - tain_t deadline ; + tain deadline ; int r = 0 ; unsigned int xindex0, xindex1 ; unsigned int i = 0, j = 1 ; diff -Nru s6-2.10.0.2/src/daemontools-extras/s6-setlock.c s6-2.11.0.0/src/daemontools-extras/s6-setlock.c --- s6-2.10.0.2/src/daemontools-extras/s6-setlock.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/s6-setlock.c 2021-09-26 14:04:15.000000000 +0000 @@ -14,6 +14,7 @@ #include #include +#include "s6lockd.h" #define USAGE "s6-setlock [ -r | -w ] [ -n | -N | -t timeout ] lockfile prog..." #define dieusage() strerr_dieusage(100, USAGE) @@ -25,7 +26,7 @@ PROG = "s6-setlock" ; for (;;) { - int opt = subgetopt(argc, argv, "nNrwt:") ; + int opt = lgetopt(argc, argv, "nNrwt:") ; if (opt == -1) break ; switch (opt) { @@ -40,21 +41,13 @@ argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ; if (argc < 2) dieusage() ; - if (nb < 2) - { - int r ; - int fd = open_create(argv[0]) ; - if (fd < 0) strerr_diefu2sys(111, "open_create ", argv[0]) ; - r = fd_lock(fd, ex, nb) ; - if (!r) errno = EBUSY ; - if (r < 1) strerr_diefu2sys(1, "lock ", argv[0]) ; - } + if (nb < 2) s6lockd_openandlock(argv[0], ex, nb) ; else { char const *cargv[4] = { "s6lockd-helper", ex ? "w" : "r", argv[0], 0 } ; char const *nullenv = { 0 } ; iopause_fd x = { .events = IOPAUSE_READ } ; - tain_t deadline ; + tain deadline ; int p[2] = { 0, 1 } ; pid_t pid ; char c ; diff -Nru s6-2.10.0.2/src/daemontools-extras/s6-setsid.c s6-2.11.0.0/src/daemontools-extras/s6-setsid.c --- s6-2.10.0.2/src/daemontools-extras/s6-setsid.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/s6-setsid.c 2021-09-26 14:04:15.000000000 +0000 @@ -17,7 +17,7 @@ unsigned int ctty = 0, what = 0, insist = 1 ; PROG = "s6-setsid" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "sbfgiIqd:", &l) ; @@ -50,14 +50,13 @@ if (what >= 2) { - if (what == 3) sig_ignore(SIGTTOU) ; + if (what == 3) sig_altignore(SIGTTOU) ; if (tcsetpgrp(ctty, getpid()) < 0) switch (insist) { case 2 : strerr_diefu1sys(111, "tcsetpgrp") ; case 1 : strerr_warnwu1sys("tcsetpgrp") ; break ; default : break ; } - if (what == 3) sig_restore(SIGTTOU) ; } } else if (setsid() < 0) switch (insist) diff -Nru s6-2.10.0.2/src/daemontools-extras/s6-socklog.c s6-2.11.0.0/src/daemontools-extras/s6-socklog.c --- s6-2.10.0.2/src/daemontools-extras/s6-socklog.c 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/s6-socklog.c 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,220 @@ +/* ISC license. */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "lolsyslog.h" + +#define USAGE "s6-socklog [ -d notif ] [ -r ] [ -U | -u uid -g gid -G gidlist ] [ -l linelen ] [ -t lameducktimeout ] [ -x socket | -i ip_port ]" +#define dieusage() strerr_dieusage(100, USAGE) + +static tain lameducktto = TAIN_INFINITE_RELATIVE ; +static int cont = 1 ; + +static inline void handle_signals (void) +{ + for (;;) switch (selfpipe_read()) + { + case -1 : strerr_diefu1sys(111, "selfpipe_read()") ; + case 0 : return ; + case SIGTERM : + cont = 0 ; + tain_add_g(&lameducktto, &lameducktto) ; + break ; + default : break ; + } +} + +int main (int argc, char const *const *argv) +{ + iopause_fd x[3] = { { .events = IOPAUSE_READ }, { .fd = 1 } } ; + int flagraw = 0 ; + char const *usock = "/dev/log" ; + unsigned int linelen = 1024 ; + PROG = "s6-socklog" ; + { + subgetopt l = SUBGETOPT_ZERO ; + unsigned int notif = 0 ; + unsigned int t = 0 ; + uid_t uid = 0 ; + gid_t gid = 0 ; + gid_t gids[NGROUPS_MAX + 1] ; + size_t gidn = (size_t)-1 ; + ip46 ip ; + uint16_t port = 514 ; + for (;;) + { + int opt = subgetopt_r(argc, argv, "rd:l:t:u:g:G:Ux:i:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case 'r' : flagraw = 1 ; break ; + case 'd' : if (!uint0_scan(l.arg, ¬if)) dieusage() ; break ; + case 'l' : if (!uint0_scan(l.arg, &linelen)) dieusage() ; break ; + case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; + case 'u' : if (!uid0_scan(l.arg, &uid)) dieusage() ; break ; + case 'g' : if (!gid0_scan(l.arg, &gid)) dieusage() ; break ; + case 'G' : if (!gid_scanlist(gids, NGROUPS_MAX, l.arg, &gidn) && *l.arg) dieusage() ; break ; + case 'U' : + { + char const *x = getenv("UID") ; + if (!x) strerr_dienotset(100, "UID") ; + if (!uid0_scan(x, &uid)) strerr_dieinvalid(100, "UID") ; + x = getenv("GID") ; + if (!x) strerr_dienotset(100, "GID") ; + if (!gid0_scan(x, &gid)) strerr_dieinvalid(100, "GID") ; + x = getenv("GIDLIST") ; + if (!x) strerr_dienotset(100, "GIDLIST") ; + if (!gid_scanlist(gids, NGROUPS_MAX+1, x, &gidn) && *x) + strerr_dieinvalid(100, "GIDLIST") ; + break ; + } + case 'x' : usock = l.arg ; break ; + case 'i' : + { + size_t pos = ip46_scan(l.arg, &ip) ; + if (!pos) dieusage() ; + if (l.arg[pos] == '_' || (!ip46_is6(&ip) && l.arg[pos] == ':')) + if (!uint160_scan(l.arg + pos + 1, &port)) dieusage() ; + usock = 0 ; + break ; + } + default : dieusage() ; + } + } + argc -= l.ind ; argv += l.ind ; + + if (linelen < 76) linelen = 76 ; + if (linelen > 1048576) linelen = 1048576 ; + if (t) tain_from_millisecs(&lameducktto, t) ; + if (notif) + { + if (notif < 3) strerr_dief1x(100, "notification fd must be 3 or more") ; + if (fcntl(notif, F_GETFD) < 0) strerr_dief1sys(100, "invalid notification fd") ; + } + + close(0) ; + if (fcntl(1, F_GETFD) < 0) strerr_dief1sys(100, "invalid stdout") ; + if (usock) + { + x[2].fd = ipc_datagram_nbcoe() ; + if (x[2].fd == -1) strerr_diefu1sys(111, "create socket") ; + if (ipc_bind_reuse_perms(x[2].fd, usock, 0777) == -1) + strerr_diefu2sys(111, "bind socket to ", usock) ; + } + else + { + x[2].fd = socket_udp46_nbcoe(ip46_is6(&ip)) ; + if (x[2].fd == -1) strerr_diefu1sys(111, "create socket") ; + if (socket_bind46_reuse(x[2].fd, &ip, port) == -1) + { + char fmti[IP46_FMT] ; + char fmtp[UINT16_FMT] ; + fmti[ip46_fmt(fmti, &ip)] = 0 ; + fmtp[uint16_fmt(fmtp, port)] = 0 ; + strerr_diefu5sys(111, "bind socket to ", "ip ", fmti, " port ", fmtp) ; + } + } + + if (gidn != (size_t)-1 && setgroups_and_gid(gid ? gid : getegid(), gidn, gids) < 0) + strerr_diefu1sys(111, "set supplementary group list") ; + if (gid && setgid(gid) < 0) + strerr_diefu1sys(111, "setgid") ; + if (uid && setuid(uid) < 0) + strerr_diefu1sys(111, "setuid") ; + + x[0].fd = selfpipe_init() ; + if (x[0].fd == -1) strerr_diefu1sys(111, "init selfpipe") ; + if (!sig_altignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; + if (!selfpipe_trap(SIGTERM)) strerr_diefu1sys(111, "trap signals") ; + + tain_now_set_stopwatch_g() ; + + if (notif) + { + fd_write(notif, "\n", 1) ; + fd_close(notif) ; + } + } + + { + char outbuf[linelen << 2] ; + buffer b1 = BUFFER_INIT(&buffer_write, 1, outbuf, linelen << 2) ; + char line[linelen + 1] ; + while (cont || buffer_len(&b1)) + { + ssize_t r ; + x[1].events = buffer_len(&b1) ? IOPAUSE_WRITE : 0 ; + x[2].events = cont && buffer_available(&b1) >= linelen + 80 ? IOPAUSE_READ : 0 ; + r = iopause_g(x, 3, cont ? &tain_infinite : &lameducktto) ; + if (r == -1) strerr_diefu1sys(111, "iopause") ; + if (!r) return 99 ; + if (x[0].revents & IOPAUSE_READ) handle_signals() ; + if (x[1].events & x[1].revents & IOPAUSE_WRITE) + if (!buffer_flush(&b1) && !error_isagain(errno)) + strerr_diefu1sys(111, "write to stdout") ; + if (x[2].events & x[2].revents & IOPAUSE_READ) + { + if (usock) + { + r = sanitize_read(fd_recv(x[2].fd, line, linelen + 1, 0)) ; + if (r == -1) strerr_diefu1sys(111, "recv") ; + } + else + { + ip46 ip ; + uint16 port ; + r = sanitize_read(socket_recv46(x[2].fd, line, linelen + 1, &ip, &port)) ; + if (r == -1) strerr_diefu1sys(111, "recv") ; + if (r) + { + char fmt[IP46_FMT + UINT16_FMT + 3] ; + size_t m = ip46_fmt(fmt, &ip) ; + fmt[m++] = '_' ; + m += uint16_fmt(fmt, port) ; + fmt[m++] = ':' ; fmt[m++] = ' ' ; + buffer_putnoflush(&b1, fmt, m) ; + } + } + if (r) + { + size_t len = r ; + size_t pos = 0 ; + while (r && (!line[r-1] || line[r-1] == '\n')) r-- ; + for (size_t i = 0 ; i < r ; i++) + if (!line[i] || line[i] == '\n') line[i] = '~' ; + if (!flagraw) + { + char sbuf[LOLSYSLOG_STRING] ; + pos = lolsyslog_string(sbuf, line) ; + if (pos) buffer_putsnoflush(&b1, sbuf) ; + } + buffer_putnoflush(&b1, line + pos, r - pos) ; + if (len == linelen+1) buffer_putnoflush(&b1, "...", 3) ; + buffer_putnoflush(&b1, "\n", 1) ; + } + } + } + } + return 0 ; +} diff -Nru s6-2.10.0.2/src/daemontools-extras/s6-softlimit.c s6-2.11.0.0/src/daemontools-extras/s6-softlimit.c --- s6-2.10.0.2/src/daemontools-extras/s6-softlimit.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/s6-softlimit.c 2021-09-26 14:04:15.000000000 +0000 @@ -27,7 +27,7 @@ int main (int argc, char const *const *argv) { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; PROG = "s6-softlimit" ; for (;;) { diff -Nru s6-2.10.0.2/src/daemontools-extras/s6-tai64nlocal.c s6-2.11.0.0/src/daemontools-extras/s6-tai64nlocal.c --- s6-2.10.0.2/src/daemontools-extras/s6-tai64nlocal.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/s6-tai64nlocal.c 2021-09-26 14:04:15.000000000 +0000 @@ -17,7 +17,7 @@ int islocal = 1 ; PROG = "s6-tai64nlocal" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "g", &l) ; @@ -42,11 +42,11 @@ else if (!r) break ; if (satmp.len > TIMESTAMP) { - tain_t a ; + tain a ; p = timestamp_scan(satmp.s, &a) ; if (p) { - localtmn_t local ; + localtmn local ; if (localtmn_from_tain(&local, &a, islocal)) { char fmt[LOCALTMN_FMT+1] ; diff -Nru s6-2.10.0.2/src/daemontools-extras/ucspilogd.c s6-2.11.0.0/src/daemontools-extras/ucspilogd.c --- s6-2.10.0.2/src/daemontools-extras/ucspilogd.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/daemontools-extras/ucspilogd.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,24 +1,18 @@ /* ISC license. */ -#undef INTERNAL_MARK -#ifndef SYSLOG_NAMES -#define SYSLOG_NAMES -#endif - -#include #include #include #include -#include -#include + #include #include #include #include #include -#include #include +#include "lolsyslog.h" + #define USAGE "ucspilogd [ -D default ] [ var... ]" #define dieusage() strerr_dieusage(100, USAGE) @@ -27,115 +21,12 @@ strerr_diefu1sys(111, "write to stdout") ; } - - /* - Hack: INTERNAL_MARK is defined by all systems that - use the CODE stuff, and not by others (Solaris). -*/ - -#ifndef INTERNAL_MARK - -typedef struct CODE_s CODE, *CODE_ref ; -struct CODE_s -{ - char *c_name ; - unsigned int c_val ; -} ; - -static CODE const prioritynames[] = -{ - { "emerg", LOG_EMERG }, - { "alert", LOG_ALERT }, - { "crit", LOG_CRIT }, - { "err", LOG_ERR }, - { "warning", LOG_WARNING }, - { "notice", LOG_NOTICE }, - { "info", LOG_INFO }, - { "debug", LOG_DEBUG }, - { 0, -1 } -} ; - -static CODE const facilitynames[] = -{ - { "kern", LOG_KERN }, - { "user", LOG_USER }, - { "mail", LOG_MAIL }, - { "news", LOG_NEWS }, - { "uucp", LOG_UUCP }, - { "daemon", LOG_DAEMON }, - { "auth", LOG_AUTH }, - { "cron", LOG_CRON }, - { "lpr", LOG_LPR }, -#ifdef LOG_SYSLOG - { "syslog", LOG_SYSLOG }, -#endif -#ifdef LOG_AUDIT - { "audit", LOG_AUDIT }, -#endif - { "local0", LOG_LOCAL0 }, - { "local1", LOG_LOCAL1 }, - { "local2", LOG_LOCAL2 }, - { "local3", LOG_LOCAL3 }, - { "local4", LOG_LOCAL4 }, - { "local5", LOG_LOCAL5 }, - { "local6", LOG_LOCAL6 }, - { "local7", LOG_LOCAL7 }, - { 0, -1 } -} ; - -#define LOG_PRI(p) ((p) & LOG_PRIMASK) -#define LOG_FAC(p) (((p) & LOG_FACMASK) / (LOG_PRIMASK + 1)) - -#endif - - -static size_t syslog_names (char const *line) -{ - size_t i ; - unsigned int fpr ; - int fp ; - CODE const *p = facilitynames ; - - if (line[0] != '<') return 0 ; - i = uint_scan(line+1, &fpr) ; - if (!i || (line[i+1] != '>')) return 0 ; - i += 2 ; - - fp = LOG_FAC(fpr) << 3 ; - for (; p->c_name ; p++) if (p->c_val == fp) break ; - if (p->c_name) - { - if ((buffer_puts(buffer_1, p->c_name) < 0) - || (buffer_put(buffer_1, ".", 1) < 1)) die() ; - } - else - { - if (buffer_put(buffer_1, "unknown.", 8) < 8) die() ; - i = 0 ; - } - - fp = LOG_PRI(fpr) ; - for (p = prioritynames ; p->c_name ; p++) if (p->c_val == fp) break ; - if (p->c_name) - { - if ((buffer_puts(buffer_1, p->c_name) < 0) - || (buffer_put(buffer_1, ": ", 2) < 2)) die() ; - } - else - { - if (buffer_put(buffer_1, "unknown: ", 9) < 9) die() ; - i = 0 ; - } - return i ; -} - - -int main (int argc, char const *const *argv, char const *const *envp) +int main (int argc, char const *const *argv) { char const *d = "" ; PROG = "ucspilogd" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "D:", &l) ; @@ -150,38 +41,43 @@ } { - char const *envs[argc] ; unsigned int i = 0 ; + stralloc sa = STRALLOC_ZERO ; + char buf[LOLSYSLOG_STRING] ; + char const *envs[argc] ; for (; i < (unsigned int)argc ; i++) { - envs[i] = env_get2(envp, argv[i]) ; + envs[i] = getenv(argv[i]) ; if (!envs[i]) envs[i] = d ; } for (;;) { size_t pos = 0 ; - satmp.len = 0 ; + size_t j ; + sa.len = 0 ; { - int r = skagetlnsep(buffer_0f1, &satmp, "\n", 2) ; + int r = skagetlnsep(buffer_0f1, &sa, "\n", 2) ; if (r < 0) { - if (errno != EPIPE || !stralloc_0(&satmp)) + if (errno != EPIPE || !stralloc_0(&sa)) strerr_diefu1sys(111, "read from stdin") ; } if (!r) break ; } - if (!satmp.len) continue ; - satmp.s[satmp.len-1] = '\n' ; - if ((satmp.s[0] == '@') && (satmp.len > 26) && (byte_chr(satmp.s, 26, ' ') == 25)) + if (!sa.len) continue ; + sa.s[sa.len-1] = 0 ; + if ((sa.s[0] == '@') && (sa.len > 26) && (byte_chr(sa.s, 26, ' ') == 25)) { - if (buffer_put(buffer_1, satmp.s, 26) < 26) die() ; + if (buffer_put(buffer_1, sa.s, 26) < 26) die() ; pos += 26 ; } for (i = 0 ; i < (unsigned int)argc ; i++) if ((buffer_puts(buffer_1, envs[i]) < 0) || (buffer_put(buffer_1, ": ", 2) < 2)) die() ; - pos += syslog_names(satmp.s + pos) ; - if (buffer_put(buffer_1, satmp.s + pos, satmp.len - pos) < (ssize_t)(satmp.len - pos)) die() ; + j = lolsyslog_string(buf, sa.s + pos) ; pos += j ; + if (j && buffer_puts(buffer_1, buf) < 0) die() ; + sa.s[sa.len-1] = '\n' ; + if (buffer_put(buffer_1, sa.s + pos, sa.len - pos) < 0) die() ; } } return 0 ; diff -Nru s6-2.10.0.2/src/fdholder/s6-fdholder-daemon.c s6-2.11.0.0/src/fdholder/s6-fdholder-daemon.c --- s6-2.10.0.2/src/fdholder/s6-fdholder-daemon.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/fdholder/s6-fdholder-daemon.c 2021-09-26 14:04:15.000000000 +0000 @@ -31,7 +31,7 @@ char const *rulesfile = 0 ; PROG = "s6-fdholder-daemon" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "Dd1Uv:c:n:b:u:g:G:t:T:i:x:", &l) ; diff -Nru s6-2.10.0.2/src/fdholder/s6-fdholderd.c s6-2.11.0.0/src/fdholder/s6-fdholderd.c --- s6-2.10.0.2/src/fdholder/s6-fdholderd.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/fdholder/s6-fdholderd.c 2021-09-26 14:04:15.000000000 +0000 @@ -12,7 +12,6 @@ #include #include -#include #include #include #include @@ -26,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -34,21 +32,22 @@ #include #include -#include +#include + +#include #define USAGE "s6-fdholderd [ -v verbosity ] [ -1 ] [ -c maxconn ] [ -n maxfds ] [ -t timeout ] [ -T lameducktimeout ] [ -i rulesdir | -x rulesfile ]" #define dieusage() strerr_dieusage(100, USAGE) ; static unsigned int verbosity = 1 ; static int cont = 1 ; -static tain_t answertto = TAIN_INFINITE_RELATIVE ; -static tain_t lameduckdeadline = TAIN_INFINITE_RELATIVE ; -static tain_t const nano1 = { .sec = TAI_ZERO, .nano = 1 } ; +static tain answertto = TAIN_INFINITE_RELATIVE ; +static tain lameduckdeadline = TAIN_INFINITE_RELATIVE ; +static tain const nano1 = { .sec = TAI_ZERO, .nano = 1 } ; static unsigned int rulestype = 0 ; static char const *rules = 0 ; -static int cdbfd = -1 ; -static struct cdb cdbmap = CDB_ZERO ; +static cdb cdbmap = CDB_ZERO ; static void handle_signals (void) { @@ -67,19 +66,10 @@ } case SIGHUP : { - int fd ; - struct cdb c = CDB_ZERO ; + cdb c = CDB_ZERO ; if (rulestype != 2) break ; - fd = open_readb(rules) ; - if (fd < 0) break ; - if (cdb_init(&c, fd) < 0) - { - fd_close(fd) ; - break ; - } + if (!cdb_init(&c, rules)) break ; cdb_free(&cdbmap) ; - fd_close(cdbfd) ; - cdbfd = fd ; cdbmap = c ; } break ; @@ -117,8 +107,8 @@ static int fds_deadline_cmp (void const *a, void const *b, void *x) { - tain_t const *aa = (tain_t const *)a ; - tain_t const *bb = (tain_t const *)b ; + tain const *aa = (tain const *)a ; + tain const *bb = (tain const *)b ; (void)x ; return tain_less(aa, bb) ? -1 : tain_less(bb, aa) ; } @@ -144,12 +134,12 @@ { uint32_t next ; uint32_t xindex ; - tain_t deadline ; + tain deadline ; regex_t rre ; regex_t wre ; unsigned int dumping ; unsigned int flags ; - unixconnection_t connection ; + unixconnection connection ; } ; static genset *clients ; @@ -181,14 +171,14 @@ static void client_setdeadline (client_t *c) { - tain_t blah ; + tain blah ; tain_half(&blah, &tain_infinite_relative) ; tain_add_g(&blah, &blah) ; if (tain_less(&blah, &c->deadline)) tain_add_g(&c->deadline, &answertto) ; } -static inline int client_prepare_iopause (uint32_t i, tain_t *deadline, iopause_fd *x, uint32_t *j) +static inline int client_prepare_iopause (uint32_t i, tain *deadline, iopause_fd *x, uint32_t *j) { client_t *c = CLIENT(i) ; if (tain_less(&c->deadline, deadline)) *deadline = c->deadline ; @@ -233,13 +223,13 @@ static int answer (client_t *c, char e) { - unixmessage_t m = { .s = &e, .len = 1, .fds = 0, .nfds = 0 } ; + unixmessage m = { .s = &e, .len = 1, .fds = 0, .nfds = 0 } ; if (!unixmessage_put(&c->connection.out, &m)) return 0 ; client_setdeadline(c) ; return 1 ; } -static int do_store (uint32_t cc, unixmessage_t const *m) +static int do_store (uint32_t cc, unixmessage const *m) { uint32_t pp, idlen ; client_t *c = CLIENT(cc) ; @@ -278,7 +268,7 @@ return 1 ; } -static int do_delete (uint32_t cc, unixmessage_t const *m) +static int do_delete (uint32_t cc, unixmessage const *m) { uint32_t pp, idlen ; client_t *c = CLIENT(cc) ; @@ -292,10 +282,10 @@ return 1 ; } -static int do_retrieve (uint32_t cc, unixmessage_t const *m) +static int do_retrieve (uint32_t cc, unixmessage const *m) { int fd ; - unixmessage_t ans = { .s = "", .len = 1, .fds = &fd, .nfds = 1 } ; + unixmessage ans = { .s = "", .len = 1, .fds = &fd, .nfds = 1 } ; uint32_t pp, idlen ; client_t *c = CLIENT(cc) ; if (c->dumping || m->len < 4 || m->nfds) return (errno = EPROTO, 0) ; @@ -319,11 +309,11 @@ return 1 ; } -static int do_list (uint32_t cc, unixmessage_t const *m) +static int do_list (uint32_t cc, unixmessage const *m) { client_t *c = CLIENT(cc) ; struct iovec v[1+numfds] ; - unixmessage_v_t ans = { .v = v, .vlen = 1+numfds, .fds = 0, .nfds = 0 } ; + unixmessagev ans = { .v = v, .vlen = 1+numfds, .fds = 0, .nfds = 0 } ; struct iovec *vp = v + 1 ; char pack[5] = "" ; if (c->dumping || m->len || m->nfds) return (errno = EPROTO, 0) ; @@ -359,7 +349,7 @@ return 1 ; } -static int do_getdump (uint32_t cc, unixmessage_t const *m) +static int do_getdump (uint32_t cc, unixmessage const *m) { uint32_t n = numfds ? 1 + ((numfds-1) / UNIXMESSAGE_MAXFDS) : 0 ; client_t *c = CLIENT(cc) ; @@ -367,7 +357,7 @@ if (!(c->flags & 1)) return answer(c, EPERM) ; { char pack[9] = "" ; - unixmessage_t ans = { .s = pack, .len = 9, .fds = 0, .nfds = 0 } ; + unixmessage ans = { .s = pack, .len = 9, .fds = 0, .nfds = 0 } ; uint32_pack_big(pack+1, n) ; uint32_pack_big(pack+5, numfds) ; if (!unixmessage_put(&c->connection.out, &ans)) return answer(c, errno) ; @@ -375,7 +365,7 @@ if (n) { uint32_t i = 0 ; - unixmessage_v_t ans[n] ; + unixmessagev ans[n] ; struct iovec v[numfds << 1] ; int fds[numfds] ; char limits[(TAIN_PACK+1) * numfds] ; @@ -414,11 +404,11 @@ return 1 ; } -static int do_setdump (uint32_t cc, unixmessage_t const *m) +static int do_setdump (uint32_t cc, unixmessage const *m) { char pack[5] = "" ; uint32_t n ; - unixmessage_t ans = { .s = pack, .len = 5, .fds = 0, .nfds = 0 } ; + unixmessage ans = { .s = pack, .len = 5, .fds = 0, .nfds = 0 } ; client_t *c = CLIENT(cc) ; if (c->dumping || m->len != 4 || m->nfds) return (errno = EPROTO, 0) ; if (!(c->flags & 2)) return answer(c, EPERM) ; @@ -431,7 +421,7 @@ return 1 ; } -static int do_setdump_data (uint32_t cc, unixmessage_t const *m) +static int do_setdump_data (uint32_t cc, unixmessage const *m) { client_t *c = CLIENT(cc) ; if (!m->nfds || m->nfds > c->dumping || m->len < m->nfds * (TAIN_PACK + 3)) @@ -478,19 +468,19 @@ return answer(c, c->dumping ? EAGAIN : 0) ; } -static int do_error (uint32_t cc, unixmessage_t const *m) +static int do_error (uint32_t cc, unixmessage const *m) { (void)cc ; (void)m ; return (errno = EPROTO, 0) ; } -typedef int parsefunc_t (uint32_t, unixmessage_t const *) ; -typedef parsefunc_t *parsefunc_t_ref ; +typedef int parse_func (uint32_t, unixmessage const *) ; +typedef parse_func *parse_func_ref ; -static inline int parse_protocol (unixmessage_t const *m, void *p) +static inline int parse_protocol (unixmessage const *m, void *p) { - static parsefunc_t_ref const f[8] = + static parse_func_ref const f[8] = { &do_store, &do_delete, @@ -501,7 +491,7 @@ &do_setdump_data, &do_error } ; - unixmessage_t mcopy = { .s = m->s + 1, .len = m->len - 1, .fds = m->fds, .nfds = m->nfds } ; + unixmessage mcopy = { .s = m->s + 1, .len = m->len - 1, .fds = m->fds, .nfds = m->nfds } ; if (!m->len) { unixmessage_drop(m) ; @@ -661,7 +651,7 @@ PROG = "s6-fdholderd" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; unsigned int t = 0, T = 0 ; for (;;) { @@ -712,20 +702,18 @@ else close(1) ; spfd = selfpipe_init() ; if (spfd < 0) strerr_diefu1sys(111, "selfpipe_init") ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; + if (!sig_ignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; { sigset_t set ; sigemptyset(&set) ; sigaddset(&set, SIGTERM) ; sigaddset(&set, SIGHUP) ; - if (selfpipe_trapset(&set) < 0) strerr_diefu1sys(111, "trap signals") ; + if (!selfpipe_trapset(&set)) strerr_diefu1sys(111, "trap signals") ; } if (rulestype == 2) { - cdbfd = open_readb(rules) ; - if (cdbfd < 0) strerr_diefu3sys(111, "open ", rules, " for reading") ; - if (cdb_init(&cdbmap, cdbfd) < 0) + if (!cdb_init(&cdbmap, rules)) strerr_diefu2sys(111, "cdb_init ", rules) ; } @@ -770,7 +758,7 @@ for (;;) { - tain_t deadline ; + tain deadline ; uint32_t j = 2 ; uint32_t i ; int r = 1 ; diff -Nru s6-2.10.0.2/src/fdholder/s6-fdholder-delete.c s6-2.11.0.0/src/fdholder/s6-fdholder-delete.c --- s6-2.10.0.2/src/fdholder/s6-fdholder-delete.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/fdholder/s6-fdholder-delete.c 2021-09-26 14:04:15.000000000 +0000 @@ -4,7 +4,7 @@ #include #include #include -#include +#include #define USAGE "s6-fdholder-delete [ -t timeout ] socket id" #define dieusage() strerr_dieusage(100, USAGE) @@ -12,11 +12,11 @@ int main (int argc, char const *const *argv) { s6_fdholder_t a = S6_FDHOLDER_ZERO ; - tain_t deadline ; + tain deadline ; PROG = "s6-fdholder-delete" ; { unsigned int t = 0 ; - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "t:", &l) ; diff -Nru s6-2.10.0.2/src/fdholder/s6-fdholder-getdump.c s6-2.11.0.0/src/fdholder/s6-fdholder-getdump.c --- s6-2.10.0.2/src/fdholder/s6-fdholder-getdump.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/fdholder/s6-fdholder-getdump.c 2021-09-26 14:04:15.000000000 +0000 @@ -11,7 +11,7 @@ #include #include -#include +#include #define USAGE "s6-fdholder-getdump [ -t timeout ] socket prog..." #define dieusage() strerr_dieusage(100, USAGE) @@ -20,11 +20,11 @@ { s6_fdholder_t a = S6_FDHOLDER_ZERO ; genalloc dump = GENALLOC_ZERO ; - tain_t deadline, halfinfinite ; + tain deadline, halfinfinite ; PROG = "s6-fdholder-getdump" ; { unsigned int t = 0 ; - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "t:", &l) ; diff -Nru s6-2.10.0.2/src/fdholder/s6-fdholder-list.c s6-2.11.0.0/src/fdholder/s6-fdholder-list.c --- s6-2.10.0.2/src/fdholder/s6-fdholder-list.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/fdholder/s6-fdholder-list.c 2021-09-26 14:04:15.000000000 +0000 @@ -8,7 +8,7 @@ #include #include #include -#include +#include #define USAGE "s6-fdholder-list [ -t timeout ] socket" #define dieusage() strerr_dieusage(100, USAGE) @@ -19,11 +19,11 @@ stralloc sa = STRALLOC_ZERO, sb = STRALLOC_ZERO ; size_t pos = 0 ; int n ; - tain_t deadline ; + tain deadline ; PROG = "s6-fdholder-list" ; { unsigned int t = 0 ; - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "t:", &l) ; diff -Nru s6-2.10.0.2/src/fdholder/s6-fdholder-retrieve.c s6-2.11.0.0/src/fdholder/s6-fdholder-retrieve.c --- s6-2.10.0.2/src/fdholder/s6-fdholder-retrieve.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/fdholder/s6-fdholder-retrieve.c 2021-09-26 14:04:15.000000000 +0000 @@ -7,7 +7,7 @@ #include #include -#include +#include #define USAGE "s6-fdholder-retrieve [ -D ] [ -t timeout ] socket id prog..." #define dieusage() strerr_dieusage(100, USAGE) @@ -15,13 +15,13 @@ int main (int argc, char const *const *argv) { s6_fdholder_t a = S6_FDHOLDER_ZERO ; - tain_t deadline ; + tain deadline ; int fd ; int dodelete = 0 ; PROG = "s6-fdholder-retrieve" ; { unsigned int t = 0 ; - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "Dt:", &l) ; diff -Nru s6-2.10.0.2/src/fdholder/s6-fdholder-setdump.c s6-2.11.0.0/src/fdholder/s6-fdholder-setdump.c --- s6-2.10.0.2/src/fdholder/s6-fdholder-setdump.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/fdholder/s6-fdholder-setdump.c 2021-09-26 14:04:15.000000000 +0000 @@ -6,7 +6,7 @@ #include #include #include -#include +#include #define USAGE "s6-fdholder-setdump [ -t timeout ] socket" #define dieusage() strerr_dieusage(100, USAGE) @@ -14,13 +14,13 @@ int main (int argc, char const *const *argv) { s6_fdholder_t a = S6_FDHOLDER_ZERO ; - tain_t deadline ; + tain deadline ; unsigned int dumplen ; char const *x ; PROG = "s6-fdholder-setdump" ; { unsigned int t = 0 ; - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "t:", &l) ; diff -Nru s6-2.10.0.2/src/fdholder/s6-fdholder-store.c s6-2.11.0.0/src/fdholder/s6-fdholder-store.c --- s6-2.10.0.2/src/fdholder/s6-fdholder-store.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/fdholder/s6-fdholder-store.c 2021-09-26 14:04:15.000000000 +0000 @@ -4,7 +4,7 @@ #include #include #include -#include +#include #define USAGE "s6-fdholder-store [ -d fd ] [ -t timeout ] [ -T fdtimeout ] socket id" #define dieusage() strerr_dieusage(100, USAGE) @@ -12,12 +12,12 @@ int main (int argc, char const *const *argv) { s6_fdholder_t a = S6_FDHOLDER_ZERO ; - tain_t deadline, limit ; + tain deadline, limit ; unsigned int fd = 0 ; PROG = "s6-fdholder-store" ; { unsigned int t = 0, T = 0 ; - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "d:t:T:", &l) ; diff -Nru s6-2.10.0.2/src/fdholder/s6-fdholder-transferdump.c s6-2.11.0.0/src/fdholder/s6-fdholder-transferdump.c --- s6-2.10.0.2/src/fdholder/s6-fdholder-transferdump.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/fdholder/s6-fdholder-transferdump.c 2021-09-26 14:04:15.000000000 +0000 @@ -5,7 +5,7 @@ #include #include #include -#include +#include #define USAGE "s6-fdholder-transferdump [ -t timeoutfrom:timeoutto ] socketfrom socketto" #define dieusage() strerr_dieusage(100, USAGE) @@ -14,11 +14,11 @@ { s6_fdholder_t a = S6_FDHOLDER_ZERO ; genalloc dump = GENALLOC_ZERO ; /* array of s6_fdholder_fd_t */ - tain_t deadline, totto ; + tain deadline, totto ; PROG = "s6-fdholder-transferdump" ; { unsigned int timeoutfrom = 0, timeoutto = 0 ; - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "t:", &l) ; diff -Nru s6-2.10.0.2/src/include/s6/accessrules.h s6-2.11.0.0/src/include/s6/accessrules.h --- s6-2.10.0.2/src/include/s6/accessrules.h 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/include/s6/accessrules.h 2021-09-26 14:04:15.000000000 +0000 @@ -35,22 +35,22 @@ S6_ACCESSRULES_NOTFOUND = 2 } ; -typedef s6_accessrules_result_t s6_accessrules_backend_func_t (char const *, size_t, void *, s6_accessrules_params_t *) ; -typedef s6_accessrules_backend_func_t *s6_accessrules_backend_func_t_ref ; +typedef s6_accessrules_result_t s6_accessrules_backend_func (char const *, size_t, void const *, s6_accessrules_params_t *) ; +typedef s6_accessrules_backend_func *s6_accessrules_backend_func_ref ; -extern s6_accessrules_backend_func_t s6_accessrules_backend_fs ; -extern s6_accessrules_backend_func_t s6_accessrules_backend_cdb ; +extern s6_accessrules_backend_func s6_accessrules_backend_fs ; +extern s6_accessrules_backend_func s6_accessrules_backend_cdb ; -typedef s6_accessrules_result_t s6_accessrules_keycheck_func_t (void const *, void *, s6_accessrules_params_t *, s6_accessrules_backend_func_t_ref) ; -typedef s6_accessrules_keycheck_func_t *s6_accessrules_keycheck_func_t_ref ; +typedef s6_accessrules_result_t s6_accessrules_keycheck_func (void const *, void const *, s6_accessrules_params_t *, s6_accessrules_backend_func_ref) ; +typedef s6_accessrules_keycheck_func *s6_accessrules_keycheck_func_ref ; -extern s6_accessrules_keycheck_func_t s6_accessrules_keycheck_uidgid ; -extern s6_accessrules_keycheck_func_t s6_accessrules_keycheck_ip4 ; -extern s6_accessrules_keycheck_func_t s6_accessrules_keycheck_ip6 ; -extern s6_accessrules_keycheck_func_t s6_accessrules_keycheck_reversedns ; -#define s6_accessrules_keycheck_ip46(key, data, params, f) (ip46_is6((ip46_t const *)(key)) ? s6_accessrules_keycheck_ip6(((ip46_t const *)(key))->ip, data, params, f) : s6_accessrules_keycheck_ip4(((ip46_t const *)(key))->ip, data, params, f)) +extern s6_accessrules_keycheck_func s6_accessrules_keycheck_uidgid ; +extern s6_accessrules_keycheck_func s6_accessrules_keycheck_ip4 ; +extern s6_accessrules_keycheck_func s6_accessrules_keycheck_ip6 ; +extern s6_accessrules_keycheck_func s6_accessrules_keycheck_reversedns ; +#define s6_accessrules_keycheck_ip46(key, data, params, f) (ip46_is6((ip46 const *)(key)) ? s6_accessrules_keycheck_ip6(((ip46 const *)(key))->ip, data, params, f) : s6_accessrules_keycheck_ip4(((ip46 const *)(key))->ip, data, params, f)) -extern s6_accessrules_result_t s6_accessrules_uidgid_cdb (uid_t, gid_t, struct cdb *, s6_accessrules_params_t *) ; +extern s6_accessrules_result_t s6_accessrules_uidgid_cdb (uid_t, gid_t, cdb const *, s6_accessrules_params_t *) ; extern s6_accessrules_result_t s6_accessrules_uidgid_fs (uid_t, gid_t, char const *, s6_accessrules_params_t *) ; #define s6_accessrules_ip4_cdb(ip4, c, params) s6_accessrules_keycheck_ip4(ip4, c, (params), &s6_accessrules_backend_cdb) #define s6_accessrules_ip4_fs(ip4, rulesdir, params) s6_accessrules_keycheck_ip4(ip4, rulesdir, (params), &s6_accessrules_backend_fs) diff -Nru s6-2.10.0.2/src/include/s6/fdholder.h s6-2.11.0.0/src/include/s6/fdholder.h --- s6-2.10.0.2/src/include/s6/fdholder.h 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/include/s6/fdholder.h 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,88 @@ +/* ISC license. */ + +#ifndef S6_FDHOLDER_H +#define S6_FDHOLDER_H + +#include +#include +#include +#include +#include + +#define S6_FDHOLDER_ID_SIZE 255 +#define S6_FDHOLDER_MAX 256 + +typedef struct s6_fdholder_s s6_fdholder_t, *s6_fdholder_t_ref ; +struct s6_fdholder_s +{ + unixconnection connection ; +} ; +#define S6_FDHOLDER_ZERO { .connection = UNIXCONNECTION_ZERO } ; + + + /* Starting and ending */ + +#define s6_fdholder_init(a, fd) unixconnection_init(&(a)->connection, fd, fd) +#define s6_fdholder_free(a) unixconnection_free(&(a)->connection) + +extern int s6_fdholder_start (s6_fdholder_t *, char const *, tain const *, tain *) ; +#define s6_fdholder_start_g(a, path, deadline) s6_fdholder_start(a, path, (deadline), &STAMP) +extern void s6_fdholder_end (s6_fdholder_t *) ; + + + /* Individual fds */ + +extern int s6_fdholder_store_async (s6_fdholder_t *, int, char const *, tain const *) ; +extern int s6_fdholder_store (s6_fdholder_t *, int, char const *, tain const *, tain const *, tain *) ; +#define s6_fdholder_store_g(a, fd, id, limit, deadline) s6_fdholder_store(a, fd, id, limit, (deadline), &STAMP) + +extern int s6_fdholder_delete_async (s6_fdholder_t *, char const *) ; +extern int s6_fdholder_delete (s6_fdholder_t *, char const *, tain const *, tain *) ; +#define s6_fdholder_delete_g(a, id, deadline) s6_fdholder_delete(a, id, (deadline), &STAMP) + +typedef struct s6_fdholder_retrieve_result_s s6_fdholder_retrieve_result_t, *s6_fdholder_retrieve_result_t_ref ; +struct s6_fdholder_retrieve_result_s +{ + int fd ; + unsigned char err ; +} ; + +extern int s6_fdholder_retrieve_maybe_delete_async (s6_fdholder_t *, char const *, int) ; +extern unixmessage_handler_func s6_fdholder_retrieve_cb ; +extern int s6_fdholder_retrieve_maybe_delete (s6_fdholder_t *, char const *, int, tain const *, tain *) ; +#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_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_delete(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 +{ + stralloc *sa ; + unsigned int n ; + unsigned char err ; +} ; + +extern int s6_fdholder_list_async (s6_fdholder_t *) ; +extern unixmessage_handler_func s6_fdholder_list_cb ; +extern int s6_fdholder_list (s6_fdholder_t *, stralloc *, tain const *, tain *) ; +#define s6_fdholder_list_g(a, sa, deadline) s6_fdholder_list(a, sa, (deadline), &STAMP) + + + /* Dumps */ + +typedef struct s6_fdholder_fd_s s6_fdholder_fd_t, *s6_fdholder_fd_t_ref ; +struct s6_fdholder_fd_s +{ + char id[S6_FDHOLDER_ID_SIZE + 1] ; + int fd ; + tain limit ; +} ; + +extern int s6_fdholder_getdump (s6_fdholder_t *, genalloc *, tain const *, tain *) ; +#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 const *, tain *) ; +#define s6_fdholder_setdump_g(a, list, n, deadline) s6_fdholder_setdump(a, list, n, (deadline), &STAMP) + +#endif diff -Nru s6-2.10.0.2/src/include/s6/ftrigr.h s6-2.11.0.0/src/include/s6/ftrigr.h --- s6-2.10.0.2/src/include/s6/ftrigr.h 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/include/s6/ftrigr.h 2021-09-26 14:04:15.000000000 +0000 @@ -18,7 +18,7 @@ #define FTRIGR_IPCPATH SKALIBS_SPROOT "/run/service/ftrigrd/s" -#define FTRIGRD_PROG S6_BINPREFIX "s6-ftrigrd" +#define FTRIGRD_PROG S6_EXTBINPREFIX "s6-ftrigrd" #define FTRIGR_BANNER1 "ftrigr v1.0 (b)\n" #define FTRIGR_BANNER1_LEN (sizeof FTRIGR_BANNER1 - 1) #define FTRIGR_BANNER2 "ftrigr v1.0 (a)\n" @@ -54,7 +54,7 @@ typedef struct ftrigr_s ftrigr, ftrigr_t, *ftrigr_ref, *ftrigr_t_ref ; struct ftrigr_s { - textclient_t connection ; + textclient connection ; genalloc list ; /* array of uint16_t */ size_t head ; gensetdyn data ; /* set of ftrigr1_t */ @@ -65,9 +65,9 @@ /* Starting and ending a session */ -extern int ftrigr_start (ftrigr_t *, char const *, tain_t const *, tain_t *) ; +extern int ftrigr_start (ftrigr_t *, char const *, tain const *, tain *) ; #define ftrigr_start_g(a, path, deadline) ftrigr_start(a, path, (deadline), &STAMP) -extern int ftrigr_startf (ftrigr_t *, tain_t const *, tain_t *) ; +extern int ftrigr_startf (ftrigr_t *, tain const *, tain *) ; #define ftrigr_startf_g(a, deadline) ftrigr_startf(a, (deadline), &STAMP) extern void ftrigr_end (ftrigr_t *) ; @@ -86,14 +86,14 @@ #define FTRIGR_REPEAT 0x0001 -extern uint16_t ftrigr_subscribe (ftrigr_t *, char const *, char const *, uint32_t, tain_t const *, tain_t *) ; +extern uint16_t ftrigr_subscribe (ftrigr_t *, char const *, char const *, uint32_t, tain const *, tain *) ; #define ftrigr_subscribe_g(a, path, re, options, deadline) ftrigr_subscribe(a, path, re, options, (deadline), &STAMP) -extern int ftrigr_unsubscribe (ftrigr_t *, uint16_t, tain_t const *, tain_t *) ; +extern int ftrigr_unsubscribe (ftrigr_t *, uint16_t, tain const *, tain *) ; #define ftrigr_unsubscribe_g(a, id, deadline) ftrigr_unsubscribe(a, id, (deadline), &STAMP) -extern int ftrigr_wait_and (ftrigr_t *, uint16_t const *, unsigned int, tain_t const *, tain_t *) ; +extern int ftrigr_wait_and (ftrigr_t *, uint16_t const *, unsigned int, tain const *, tain *) ; #define ftrigr_wait_and_g(a, list, len, deadline) ftrigr_wait_and(a, list, len, (deadline), &STAMP) -extern int ftrigr_wait_or (ftrigr_t *, uint16_t const *, unsigned int, tain_t const *, tain_t *, char *) ; +extern int ftrigr_wait_or (ftrigr_t *, uint16_t const *, unsigned int, tain const *, tain *, char *) ; #define ftrigr_wait_or_g(a, list, len, deadline, what) ftrigr_wait_or(a, list, len, deadline, &STAMP, what) #endif diff -Nru s6-2.10.0.2/src/include/s6/lock.h s6-2.11.0.0/src/include/s6/lock.h --- s6-2.10.0.2/src/include/s6/lock.h 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/include/s6/lock.h 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,75 @@ +/* ISC license. */ + +#ifndef S6_LOCK_H +#define S6_LOCK_H + +#include + +#include +#include +#include +#include + +#include + + + /* Constants */ + +#define S6LOCKD_PROG S6_EXTBINPREFIX "s6lockd" +#define S6LOCKD_HELPER_PROG S6_LIBEXECPREFIX "s6lockd-helper" + +#define S6LOCK_BANNER1 "s6lock v1.0 (b)\n" +#define S6LOCK_BANNER1_LEN (sizeof S6LOCK_BANNER1 - 1) +#define S6LOCK_BANNER2 "s6lock v1.0 (a)\n" +#define S6LOCK_BANNER2_LEN (sizeof S6LOCK_BANNER2 - 1) + + + /* The client handle */ + +typedef struct s6lock_s s6lock_t, *s6lock_t_ref ; +struct s6lock_s +{ + textclient connection ; + genalloc list ; /* array of uint16_t */ + gensetdyn data ; /* set of unsigned char */ +} ; +#define S6LOCK_ZERO { .connection = TEXTCLIENT_ZERO, .list = GENALLOC_ZERO, .data = GENSETDYN_INIT(int, 2, 0, 1) } +extern s6lock_t const s6lock_zero ; + + + /* Starting and ending a session */ + +extern int s6lock_start (s6lock_t *, char const *, tain const *, tain *) ; +#define s6lock_start_g(a, ipcpath, deadline) s6lock_start(a, ipcpath, (deadline), &STAMP) +extern int s6lock_startf (s6lock_t *, char const *, tain const *, tain *) ; +#define s6lock_startf_g(a, lockdir, deadline) s6lock_startf(a, lockdir, (deadline), &STAMP) +extern void s6lock_end (s6lock_t *) ; + + + /* Asynchronous primitives */ + +#define s6lock_fd(a) textclient_fd(&(a)->connection) +extern int s6lock_update (s6lock_t *) ; +extern int s6lock_check (s6lock_t *, uint16_t) ; + + + /* Synchronous functions */ + +#define S6LOCK_OPTIONS_SH 0x0000U +#define S6LOCK_OPTIONS_EX 0x0001U + +extern int s6lock_acquire (s6lock_t *, uint16_t *, char const *, uint32_t, tain const *, tain const *, tain *) ; +#define s6lock_acquire_g(a, id, path, options, limit, deadline) s6lock_acquire(a, id, path, options, limit, (deadline), &STAMP) +#define s6lock_acquire_sh(a, id, path, limit, deadline, stamp) s6lock_aquire(a, id, path, S6LOCK_OPTIONS_SH, limit, deadline, stamp) +#define s6lock_acquire_ex(a, id, path, limit, deadline, stamp) s6lock_aquire(a, id, path, S6LOCK_OPTIONS_EX, limit, deadline, stamp) +#define s6lock_acquire_sh_g(a, id, path, limit, deadline) s6lock_acquire_sh(a, id, path, limit, (deadline), &STAMP) +#define s6lock_acquire_ex_g(a, id, path, limit, deadline) s6lock_acquire_ex(a, id, path, limit, (deadline), &STAMP) +extern int s6lock_release (s6lock_t *, uint16_t, tain const *, tain *) ; +#define s6lock_release_g(a, id, deadline) s6lock_release(a, id, (deadline), &STAMP) + +extern int s6lock_wait_and (s6lock_t *, uint16_t const *, unsigned int, tain const *, tain *) ; +#define s6lock_wait_and_g(a, list, len, deadline) s6lock_wait_and(a, list, len, (deadline), &STAMP) +extern int s6lock_wait_or (s6lock_t *, uint16_t const *, unsigned int, tain const *, tain *) ; +#define s6lock_wait_or_g(a, list, len, deadline) s6lock_wait_or(a, list, len, (deadline), &STAMP) + +#endif diff -Nru s6-2.10.0.2/src/include/s6/s6-fdholder.h s6-2.11.0.0/src/include/s6/s6-fdholder.h --- s6-2.10.0.2/src/include/s6/s6-fdholder.h 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/include/s6/s6-fdholder.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,88 +0,0 @@ -/* ISC license. */ - -#ifndef S6_FDHOLDER_H -#define S6_FDHOLDER_H - -#include -#include -#include -#include -#include - -#define S6_FDHOLDER_ID_SIZE 255 -#define S6_FDHOLDER_MAX 256 - -typedef struct s6_fdholder_s s6_fdholder_t, *s6_fdholder_t_ref ; -struct s6_fdholder_s -{ - unixconnection_t connection ; -} ; -#define S6_FDHOLDER_ZERO { .connection = UNIXCONNECTION_ZERO } ; - - - /* Starting and ending */ - -#define s6_fdholder_init(a, fd) unixconnection_init(&(a)->connection, fd, fd) -#define s6_fdholder_free(a) unixconnection_free(&(a)->connection) - -extern int s6_fdholder_start (s6_fdholder_t *, char const *, tain_t const *, tain_t *) ; -#define s6_fdholder_start_g(a, path, deadline) s6_fdholder_start(a, path, (deadline), &STAMP) -extern void s6_fdholder_end (s6_fdholder_t *) ; - - - /* Individual fds */ - -extern int s6_fdholder_store_async (s6_fdholder_t *, int, char const *, tain_t const *) ; -extern int s6_fdholder_store (s6_fdholder_t *, int, char const *, tain_t const *, tain_t const *, tain_t *) ; -#define s6_fdholder_store_g(a, fd, id, limit, deadline) s6_fdholder_store(a, fd, id, limit, (deadline), &STAMP) - -extern int s6_fdholder_delete_async (s6_fdholder_t *, char const *) ; -extern int s6_fdholder_delete (s6_fdholder_t *, char const *, tain_t const *, tain_t *) ; -#define s6_fdholder_delete_g(a, id, deadline) s6_fdholder_delete(a, id, (deadline), &STAMP) - -typedef struct s6_fdholder_retrieve_result_s s6_fdholder_retrieve_result_t, *s6_fdholder_retrieve_result_t_ref ; -struct s6_fdholder_retrieve_result_s -{ - int fd ; - unsigned char err ; -} ; - -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_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_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_delete(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 -{ - stralloc *sa ; - unsigned int n ; - unsigned char err ; -} ; - -extern int s6_fdholder_list_async (s6_fdholder_t *) ; -extern unixmessage_handler_func_t s6_fdholder_list_cb ; -extern int s6_fdholder_list (s6_fdholder_t *, stralloc *, tain_t const *, tain_t *) ; -#define s6_fdholder_list_g(a, sa, deadline) s6_fdholder_list(a, sa, (deadline), &STAMP) - - - /* Dumps */ - -typedef struct s6_fdholder_fd_s s6_fdholder_fd_t, *s6_fdholder_fd_t_ref ; -struct s6_fdholder_fd_s -{ - char id[S6_FDHOLDER_ID_SIZE + 1] ; - int fd ; - tain_t limit ; -} ; - -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(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) - -#endif diff -Nru s6-2.10.0.2/src/include/s6/s6.h s6-2.11.0.0/src/include/s6/s6.h --- s6-2.10.0.2/src/include/s6/s6.h 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/include/s6/s6.h 2021-09-26 14:04:15.000000000 +0000 @@ -4,10 +4,10 @@ #define S6_H #include -#include +#include #include #include #include -#include +#include #endif diff -Nru s6-2.10.0.2/src/include/s6/s6lock.h s6-2.11.0.0/src/include/s6/s6lock.h --- s6-2.10.0.2/src/include/s6/s6lock.h 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/include/s6/s6lock.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -/* ISC license. */ - -#ifndef S6LOCK_H -#define S6LOCK_H - -#include -#include -#include -#include -#include -#include - - - /* Constants */ - -#define S6LOCKD_PROG S6_BINPREFIX "s6lockd" -#define S6LOCKD_HELPER_PROG S6_LIBEXECPREFIX "s6lockd-helper" - -#define S6LOCK_BANNER1 "s6lock v1.0 (b)\n" -#define S6LOCK_BANNER1_LEN (sizeof S6LOCK_BANNER1 - 1) -#define S6LOCK_BANNER2 "s6lock v1.0 (a)\n" -#define S6LOCK_BANNER2_LEN (sizeof S6LOCK_BANNER2 - 1) - - - /* The client handle */ - -typedef struct s6lock_s s6lock_t, *s6lock_t_ref ; -struct s6lock_s -{ - textclient_t connection ; - genalloc list ; /* array of uint16_t */ - gensetdyn data ; /* set of char */ -} ; -#define S6LOCK_ZERO { .connection = TEXTCLIENT_ZERO, .list = GENALLOC_ZERO, .data = GENSETDYN_INIT(int, 2, 0, 1) } -extern s6lock_t const s6lock_zero ; - - - /* Starting and ending a session */ - -extern int s6lock_start (s6lock_t *, char const *, tain_t const *, tain_t *) ; -#define s6lock_start_g(a, ipcpath, deadline) s6lock_start(a, ipcpath, (deadline), &STAMP) -extern int s6lock_startf (s6lock_t *, char const *, tain_t const *, tain_t *) ; -#define s6lock_startf_g(a, lockdir, deadline) s6lock_startf(a, lockdir, (deadline), &STAMP) -extern void s6lock_end (s6lock_t *) ; - - - /* Asynchronous primitives */ - -#define s6lock_fd(a) textclient_fd(&(a)->connection) -extern int s6lock_update (s6lock_t *) ; -extern int s6lock_check (s6lock_t *, uint16_t) ; - - - /* Synchronous functions */ - -#define S6LOCK_OPTIONS_SH 0x0000U -#define S6LOCK_OPTIONS_EX 0x0001U - -extern int s6lock_acquire (s6lock_t *, uint16_t *, char const *, uint32_t, tain_t const *, tain_t const *, tain_t *) ; -#define s6lock_acquire_g(a, id, path, options, limit, deadline) s6lock_acquire(a, id, path, options, limit, (deadline), &STAMP) -#define s6lock_acquire_sh(a, id, path, limit, deadline, stamp) s6lock_aquire(a, id, path, S6LOCK_OPTIONS_SH, limit, deadline, stamp) -#define s6lock_acquire_ex(a, id, path, limit, deadline, stamp) s6lock_aquire(a, id, path, S6LOCK_OPTIONS_EX, limit, deadline, stamp) -#define s6lock_acquire_sh_g(a, id, path, limit, deadline) s6lock_acquire_sh(a, id, path, limit, (deadline), &STAMP) -#define s6lock_acquire_ex_g(a, id, path, limit, deadline) s6lock_acquire_ex(a, id, path, limit, (deadline), &STAMP) -extern int s6lock_release (s6lock_t *, uint16_t, tain_t const *, tain_t *) ; -#define s6lock_release_g(a, id, deadline) s6lock_release(a, id, (deadline), &STAMP) - -extern int s6lock_wait_and (s6lock_t *, uint16_t const *, unsigned int, tain_t const *, tain_t *) ; -#define s6lock_wait_and_g(a, list, len, deadline) s6lock_wait_and(a, list, len, (deadline), &STAMP) -extern int s6lock_wait_or (s6lock_t *, uint16_t const *, unsigned int, tain_t const *, tain_t *) ; -#define s6lock_wait_or_g(a, list, len, deadline) s6lock_wait_or(a, list, len, (deadline), &STAMP) - -#endif diff -Nru s6-2.10.0.2/src/include/s6/s6-supervise.h s6-2.11.0.0/src/include/s6/s6-supervise.h --- s6-2.10.0.2/src/include/s6/s6-supervise.h 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/include/s6/s6-supervise.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,78 +0,0 @@ -/* ISC license. */ - -#ifndef S6_SUPERVISE_H -#define S6_SUPERVISE_H - -#include -#include - -#include - -#define S6_SUPERVISE_CTLDIR "supervise" -#define S6_SUPERVISE_EVENTDIR "event" -#define S6_SVSCAN_CTLDIR ".s6-svscan" -#define S6_SVSTATUS_FILENAME S6_SUPERVISE_CTLDIR "/status" -#define S6_SVSTATUS_SIZE 35 -#define S6_DTALLY_FILENAME S6_SUPERVISE_CTLDIR "/death_tally" -#define S6_MAX_DEATH_TALLY 4096 - -extern int s6_svc_ok (char const *) ; -extern int s6_svc_write (char const *, char const *, size_t) ; -extern int s6_svc_writectl (char const *, char const *, char const *, size_t) ; -extern int s6_svc_main (int, char const *const *, char const *, char const *, char const *) ; - -typedef struct s6_svstatus_s s6_svstatus_t, *s6_svstatus_t_ref ; -struct s6_svstatus_s -{ - tain_t stamp ; - tain_t readystamp ; - pid_t pid ; - int wstat ; - unsigned int flagpaused : 1 ; - unsigned int flagfinishing : 1 ; - unsigned int flagwant : 1 ; /* unused */ - unsigned int flagwantup : 1 ; - unsigned int flagready : 1 ; - unsigned int flagthrottled : 1 ; -} ; - -#define S6_SVSTATUS_ZERO \ -{ \ - .stamp = TAIN_ZERO, \ - .readystamp = TAIN_ZERO, \ - .pid = 0, \ - .wstat = 0, \ - .flagpaused = 0, \ - .flagfinishing = 0, \ - .flagwant = 1, \ - .flagwantup = 1, \ - .flagready = 1, \ - .flagthrottled = 0 \ -} - -extern void s6_svstatus_pack (char *, s6_svstatus_t const *) ; -extern void s6_svstatus_unpack (char const *, s6_svstatus_t *) ; -extern int s6_svstatus_read (char const *, s6_svstatus_t *) ; -extern int s6_svstatus_write (char const *, s6_svstatus_t const *) ; - -extern int s6_supervise_link (char const *, char const *const *, size_t, char const *, uint32_t, tain_t const *, tain_t *) ; -#define s6_supervise_link_g(scdir, servicedirs, n, prefix, options, deadline) s6_supervise_link(scdir, servicedirs, n, prefix, options, (deadline), &STAMP) -extern void s6_supervise_unlink (char const *, char const *, uint32_t) ; - -typedef struct s6_dtally_s s6_dtally_t, *s6_dtally_ref ; -struct s6_dtally_s -{ - tain_t stamp ; - unsigned char exitcode ; - unsigned char sig ; -} ; -#define S6_DTALLY_ZERO { .stamp = TAIN_ZERO, .exitcode = 0, .sig = 0 } - -#define S6_DTALLY_PACK (TAIN_PACK + 2) - -extern void s6_dtally_pack (char *, s6_dtally_t const *) ; -extern void s6_dtally_unpack (char const *, s6_dtally_t *) ; -extern ssize_t s6_dtally_read (char const *, s6_dtally_t *, size_t) ; -extern int s6_dtally_write (char const *, s6_dtally_t const *, size_t) ; - -#endif diff -Nru s6-2.10.0.2/src/include/s6/supervise.h s6-2.11.0.0/src/include/s6/supervise.h --- s6-2.10.0.2/src/include/s6/supervise.h 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/include/s6/supervise.h 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,78 @@ +/* ISC license. */ + +#ifndef S6_SUPERVISE_H +#define S6_SUPERVISE_H + +#include +#include + +#include + +#define S6_SUPERVISE_CTLDIR "supervise" +#define S6_SUPERVISE_EVENTDIR "event" +#define S6_SVSCAN_CTLDIR ".s6-svscan" +#define S6_SVSTATUS_FILENAME S6_SUPERVISE_CTLDIR "/status" +#define S6_SVSTATUS_SIZE 35 +#define S6_DTALLY_FILENAME S6_SUPERVISE_CTLDIR "/death_tally" +#define S6_MAX_DEATH_TALLY 4096 + +extern int s6_svc_ok (char const *) ; +extern int s6_svc_write (char const *, char const *, size_t) ; +extern int s6_svc_writectl (char const *, char const *, char const *, size_t) ; +extern int s6_svc_main (int, char const *const *, char const *, char const *, char const *) ; + +typedef struct s6_svstatus_s s6_svstatus_t, *s6_svstatus_t_ref ; +struct s6_svstatus_s +{ + tain stamp ; + tain readystamp ; + pid_t pid ; + int wstat ; + unsigned int flagpaused : 1 ; + unsigned int flagfinishing : 1 ; + unsigned int flagwantup : 1 ; + unsigned int flagready : 1 ; +} ; + +#define S6_SVSTATUS_ZERO \ +{ \ + .stamp = TAIN_ZERO, \ + .readystamp = TAIN_ZERO, \ + .pid = 0, \ + .wstat = 0, \ + .flagpaused = 0, \ + .flagfinishing = 0, \ + .flagwantup = 1, \ + .flagready = 1, \ +} + +extern void s6_svstatus_pack (char *, s6_svstatus_t const *) ; +extern void s6_svstatus_unpack (char const *, s6_svstatus_t *) ; +extern int s6_svstatus_read (char const *, s6_svstatus_t *) ; +extern int s6_svstatus_write (char const *, s6_svstatus_t const *) ; + +extern int s6_supervise_link (char const *, char const *const *, size_t, char const *, uint32_t, tain const *, tain *) ; +#define s6_supervise_link_g(scdir, servicedirs, n, prefix, options, deadline) s6_supervise_link(scdir, servicedirs, n, prefix, options, (deadline), &STAMP) +extern int s6_supervise_link_names (char const *, char const *const *, char const *const *, size_t, uint32_t, tain const *, tain *) ; +#define s6_supervise_link_names_g(scdir, servicedirs, names, n, options, deadline) s6_supervise_link_names(scdir, servicedirs, names, n, options, (deadline), &STAMP) +extern void s6_supervise_unlink (char const *, char const *, uint32_t) ; +extern int s6_supervise_unlink_names (char const *, char const *const *, size_t, uint32_t, tain const *, tain *) ; +#define s6_supervise_unlink_names_g(scdir, names, n, options, deadline) s6_supervise_unlink_names(scdir, names, n, options, (deadline), &STAMP) + +typedef struct s6_dtally_s s6_dtally_t, *s6_dtally_ref ; +struct s6_dtally_s +{ + tain stamp ; + unsigned char exitcode ; + unsigned char sig ; +} ; +#define S6_DTALLY_ZERO { .stamp = TAIN_ZERO, .exitcode = 0, .sig = 0 } + +#define S6_DTALLY_PACK (TAIN_PACK + 2) + +extern void s6_dtally_pack (char *, s6_dtally_t const *) ; +extern void s6_dtally_unpack (char const *, s6_dtally_t *) ; +extern ssize_t s6_dtally_read (char const *, s6_dtally_t *, size_t) ; +extern int s6_dtally_write (char const *, s6_dtally_t const *, size_t) ; + +#endif diff -Nru s6-2.10.0.2/src/include-local/s6lockd.h s6-2.11.0.0/src/include-local/s6lockd.h --- s6-2.10.0.2/src/include-local/s6lockd.h 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/include-local/s6lockd.h 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,8 @@ +/* ISC license. */ + +#ifndef S6LOCKD_H +#define S6LOCKD_H + +extern int s6lockd_openandlock (char const *, int, int) ; + +#endif diff -Nru s6-2.10.0.2/src/libs6/deps-exe/s6lockd-helper s6-2.11.0.0/src/libs6/deps-exe/s6lockd-helper --- s6-2.10.0.2/src/libs6/deps-exe/s6lockd-helper 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/deps-exe/s6lockd-helper 2021-09-26 14:04:15.000000000 +0000 @@ -1 +1,2 @@ +libs6lockd.a.xyzzy -lskarnet diff -Nru s6-2.10.0.2/src/libs6/deps-lib/s6 s6-2.11.0.0/src/libs6/deps-lib/s6 --- s6-2.10.0.2/src/libs6/deps-lib/s6 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/deps-lib/s6 2021-09-26 14:04:15.000000000 +0000 @@ -63,5 +63,7 @@ s6_fdholder_store.o s6_fdholder_store_async.o s6_supervise_link.o +s6_supervise_link_names.o s6_supervise_unlink.o +s6_supervise_unlink_names.o -lskarnet diff -Nru s6-2.10.0.2/src/libs6/deps-lib/s6lockd s6-2.11.0.0/src/libs6/deps-lib/s6lockd --- s6-2.10.0.2/src/libs6/deps-lib/s6lockd 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/libs6/deps-lib/s6lockd 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1 @@ +s6lockd_openandlock.o diff -Nru s6-2.10.0.2/src/libs6/ftrigr_start.c s6-2.11.0.0/src/libs6/ftrigr_start.c --- s6-2.10.0.2/src/libs6/ftrigr_start.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/ftrigr_start.c 2021-09-26 14:04:15.000000000 +0000 @@ -3,7 +3,7 @@ #include #include -int ftrigr_start (ftrigr_t *a, char const *path, tain_t const *deadline, tain_t *stamp) +int ftrigr_start (ftrigr_t *a, char const *path, tain const *deadline, tain *stamp) { return textclient_start(&a->connection, path, 0, FTRIGR_BANNER1, FTRIGR_BANNER1_LEN, FTRIGR_BANNER2, FTRIGR_BANNER2_LEN, deadline, stamp) ; } diff -Nru s6-2.10.0.2/src/libs6/ftrigr_startf.c s6-2.11.0.0/src/libs6/ftrigr_startf.c --- s6-2.10.0.2/src/libs6/ftrigr_startf.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/ftrigr_startf.c 2021-09-26 14:04:15.000000000 +0000 @@ -3,7 +3,7 @@ #include #include -int ftrigr_startf (ftrigr_t *a, tain_t const *deadline, tain_t *stamp) +int ftrigr_startf (ftrigr_t *a, tain const *deadline, tain *stamp) { static char const *const cargv[2] = { FTRIGRD_PROG, 0 } ; static char const *const cenvp[1] = { 0 } ; diff -Nru s6-2.10.0.2/src/libs6/ftrigr_subscribe.c s6-2.11.0.0/src/libs6/ftrigr_subscribe.c --- s6-2.10.0.2/src/libs6/ftrigr_subscribe.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/ftrigr_subscribe.c 2021-09-26 14:04:15.000000000 +0000 @@ -12,7 +12,7 @@ #include #include -uint16_t ftrigr_subscribe (ftrigr_t *a, char const *path, char const *re, uint32_t options, tain_t const *deadline, tain_t *stamp) +uint16_t ftrigr_subscribe (ftrigr_t *a, char const *path, char const *re, uint32_t options, tain const *deadline, tain *stamp) { size_t pathlen = strlen(path) ; size_t relen = strlen(re) ; diff -Nru s6-2.10.0.2/src/libs6/ftrigr_unsubscribe.c s6-2.11.0.0/src/libs6/ftrigr_unsubscribe.c --- s6-2.10.0.2/src/libs6/ftrigr_unsubscribe.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/ftrigr_unsubscribe.c 2021-09-26 14:04:15.000000000 +0000 @@ -7,7 +7,7 @@ #include #include -int ftrigr_unsubscribe (ftrigr_t *a, uint16_t i, tain_t const *deadline, tain_t *stamp) +int ftrigr_unsubscribe (ftrigr_t *a, uint16_t i, tain const *deadline, tain *stamp) { ftrigr1_t *p ; char pack[3] = "--U" ; diff -Nru s6-2.10.0.2/src/libs6/ftrigr_updateb.c s6-2.11.0.0/src/libs6/ftrigr_updateb.c --- s6-2.10.0.2/src/libs6/ftrigr_updateb.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/ftrigr_updateb.c 2021-09-26 14:04:15.000000000 +0000 @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -13,6 +12,8 @@ #include #include +#include + static inline int appears (uint16_t, uint16_t const *, size_t) gccattr_pure ; static inline int appears (uint16_t id, uint16_t const *list, size_t len) diff -Nru s6-2.10.0.2/src/libs6/ftrigr_wait_and.c s6-2.11.0.0/src/libs6/ftrigr_wait_and.c --- s6-2.10.0.2/src/libs6/ftrigr_wait_and.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/ftrigr_wait_and.c 2021-09-26 14:04:15.000000000 +0000 @@ -4,7 +4,7 @@ #include #include -int ftrigr_wait_and (ftrigr_t *a, uint16_t const *idlist, unsigned int n, tain_t const *deadline, tain_t *stamp) +int ftrigr_wait_and (ftrigr_t *a, uint16_t const *idlist, unsigned int n, tain const *deadline, tain *stamp) { iopause_fd x = { -1, IOPAUSE_READ, 0 } ; x.fd = ftrigr_fd(a) ; diff -Nru s6-2.10.0.2/src/libs6/ftrigr_wait_or.c s6-2.11.0.0/src/libs6/ftrigr_wait_or.c --- s6-2.10.0.2/src/libs6/ftrigr_wait_or.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/ftrigr_wait_or.c 2021-09-26 14:04:15.000000000 +0000 @@ -2,12 +2,13 @@ #include -#include #include #include -int ftrigr_wait_or (ftrigr_t *a, uint16_t const *idlist, unsigned int n, tain_t const *deadline, tain_t *stamp, char *c) +#include + +int ftrigr_wait_or (ftrigr_t *a, uint16_t const *idlist, unsigned int n, tain const *deadline, tain *stamp, char *c) { iopause_fd x = { -1, IOPAUSE_READ | IOPAUSE_EXCEPT, 0 } ; x.fd = ftrigr_fd(a) ; diff -Nru s6-2.10.0.2/src/libs6/ftrigw_notifyb.c s6-2.11.0.0/src/libs6/ftrigw_notifyb.c --- s6-2.10.0.2/src/libs6/ftrigw_notifyb.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/ftrigw_notifyb.c 2021-09-26 14:04:15.000000000 +0000 @@ -2,18 +2,20 @@ #include #include -#include + #include int ftrigw_notifyb (char const *path, char const *s, size_t len) { - struct skasigaction old ; + struct sigaction old ; + struct sigaction action = { .sa_handler = SIG_IGN, .sa_flags = SA_RESTART | SA_NOCLDSTOP } ; int r ; - if (skasigaction(SIGPIPE, &SKASIG_IGN, &old) < 0) return -1 ; + sigfillset(&action.sa_mask) ; + if (sigaction(SIGPIPE, &action, &old) == -1) return -1 ; r = ftrigw_notifyb_nosig(path, s, len) ; { int e = errno ; - skasigaction(SIGPIPE, &old, 0) ; + sigaction(SIGPIPE, &old, 0) ; errno = e ; } return r ; diff -Nru s6-2.10.0.2/src/libs6/ftrigw_notifyb_nosig.c s6-2.11.0.0/src/libs6/ftrigw_notifyb_nosig.c --- s6-2.10.0.2/src/libs6/ftrigw_notifyb_nosig.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/ftrigw_notifyb_nosig.c 2021-09-26 14:04:15.000000000 +0000 @@ -44,7 +44,7 @@ if ((r < 0) || (size_t)r < len) { if (errno == EPIPE) unlink_void(tmp) ; - /* what to do if EGAIN ? full fifo -> fix the reader ! + /* what to do if EAGAIN ? full fifo -> fix the reader ! There's a race condition in extreme cases though ; but it's still better to be nonblocking - the writer shouldn't get in trouble because of a bad reader. */ diff -Nru s6-2.10.0.2/src/libs6/s6_accessrules_backend_cdb.c s6-2.11.0.0/src/libs6/s6_accessrules_backend_cdb.c --- s6-2.10.0.2/src/libs6/s6_accessrules_backend_cdb.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_accessrules_backend_cdb.c 2021-09-26 14:04:15.000000000 +0000 @@ -3,38 +3,44 @@ #include #include #include + #include #include #include + #include -s6_accessrules_result_t s6_accessrules_backend_cdb (char const *key, size_t keylen, void *data, s6_accessrules_params_t *params) +s6_accessrules_result_t s6_accessrules_backend_cdb (char const *key, size_t keylen, void const *arg, s6_accessrules_params_t *params) { - struct cdb *c = data ; - size_t execbase ; - unsigned int n ; + cdb_data data ; + int wasnull = !params->env.s ; uint16_t envlen, execlen ; - int r = cdb_find(c, key, keylen) ; + cdb const *c = arg ; + int r = cdb_find(c, &data, key, keylen) ; if (r < 0) return S6_ACCESSRULES_ERROR ; else if (!r) return S6_ACCESSRULES_NOTFOUND ; - n = cdb_datalen(c) ; - if (!n || n > 8197) return (errno = EINVAL, S6_ACCESSRULES_ERROR) ; - if (!stralloc_readyplus(¶ms->exec, n)) return S6_ACCESSRULES_ERROR ; - execbase = params->exec.len ; - if (cdb_read(c, params->exec.s + execbase, n, cdb_datapos(c)) < 0) return S6_ACCESSRULES_ERROR ; - if (params->exec.s[execbase] == 'D') return S6_ACCESSRULES_DENY ; - else if (params->exec.s[execbase] != 'A') return S6_ACCESSRULES_NOTFOUND ; - else if (n < 5) return (errno = EINVAL, S6_ACCESSRULES_ERROR) ; - uint16_unpack_big(params->exec.s + execbase + 1, &envlen) ; - if ((envlen > 4096) || (envlen + 5 > n)) return (errno = EINVAL, S6_ACCESSRULES_ERROR) ; - uint16_unpack_big(params->exec.s + execbase + 3 + envlen, &execlen) ; - if ((execlen > 4096) || (5 + envlen + execlen != n)) return (errno = EINVAL, S6_ACCESSRULES_ERROR) ; - if (!stralloc_catb(¶ms->env, params->exec.s + execbase + 3, envlen)) return S6_ACCESSRULES_ERROR ; - memcpy(params->exec.s + execbase, params->exec.s + execbase + 5 + envlen, execlen) ; + if (!data.len || data.len > 8197) return (errno = EINVAL, S6_ACCESSRULES_ERROR) ; + if (data.s[0] == 'D') return S6_ACCESSRULES_DENY ; + if (data.s[0] != 'A') return S6_ACCESSRULES_NOTFOUND ; + if (data.len < 5) return (errno = EINVAL, S6_ACCESSRULES_ERROR) ; + uint16_unpack_big(data.s + 1, &envlen) ; + if ((envlen > 4096) || (data.len - 5 < envlen)) return (errno = EINVAL, S6_ACCESSRULES_ERROR) ; + uint16_unpack_big(data.s + 3 + envlen, &execlen) ; + if ((execlen > 4096) || (5 + envlen + execlen != data.len)) return (errno = EINVAL, S6_ACCESSRULES_ERROR) ; + if (envlen && !stralloc_catb(¶ms->env, data.s + 3, envlen)) return S6_ACCESSRULES_ERROR ; if (execlen) { - params->exec.len += execlen ; - params->exec.s[params->exec.len++] = 0 ; + if (!stralloc_readyplus(¶ms->exec, execlen + 1)) + { + if (envlen) + { + if (wasnull) stralloc_free(¶ms->env) ; + else params->env.len -= envlen ; + } + return S6_ACCESSRULES_ERROR ; + } + stralloc_catb(¶ms->exec, data.s + 5 + envlen, execlen) ; + stralloc_0(¶ms->exec) ; } return S6_ACCESSRULES_ALLOW ; } diff -Nru s6-2.10.0.2/src/libs6/s6_accessrules_backend_fs.c s6-2.11.0.0/src/libs6/s6_accessrules_backend_fs.c --- s6-2.10.0.2/src/libs6/s6_accessrules_backend_fs.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_accessrules_backend_fs.c 2021-09-26 14:04:15.000000000 +0000 @@ -8,9 +8,9 @@ #include #include -s6_accessrules_result_t s6_accessrules_backend_fs (char const *key, size_t keylen, void *data, s6_accessrules_params_t *params) +s6_accessrules_result_t s6_accessrules_backend_fs (char const *key, size_t keylen, void const *data, s6_accessrules_params_t *params) { - char *dir = data ; + char const *dir = data ; size_t dirlen = strlen(dir) ; size_t envbase = params->env.len ; int wasnull = !params->env.s ; diff -Nru s6-2.10.0.2/src/libs6/s6_accessrules_keycheck_ip4.c s6-2.11.0.0/src/libs6/s6_accessrules_keycheck_ip4.c --- s6-2.10.0.2/src/libs6/s6_accessrules_keycheck_ip4.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_accessrules_keycheck_ip4.c 2021-09-26 14:04:15.000000000 +0000 @@ -5,7 +5,7 @@ #include #include -s6_accessrules_result_t s6_accessrules_keycheck_ip4 (void const *key, void *data, s6_accessrules_params_t *params, s6_accessrules_backend_func_t_ref check1) +s6_accessrules_result_t s6_accessrules_keycheck_ip4 (void const *key, void const *data, s6_accessrules_params_t *params, s6_accessrules_backend_func_ref check1) { char fmt[IP4_FMT + UINT_FMT + 6] = "ip4/" ; uint32_t ip ; diff -Nru s6-2.10.0.2/src/libs6/s6_accessrules_keycheck_ip6.c s6-2.11.0.0/src/libs6/s6_accessrules_keycheck_ip6.c --- s6-2.10.0.2/src/libs6/s6_accessrules_keycheck_ip6.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_accessrules_keycheck_ip6.c 2021-09-26 14:04:15.000000000 +0000 @@ -6,7 +6,7 @@ #include #include -s6_accessrules_result_t s6_accessrules_keycheck_ip6 (void const *key, void *data, s6_accessrules_params_t *params, s6_accessrules_backend_func_t_ref check1) +s6_accessrules_result_t s6_accessrules_keycheck_ip6 (void const *key, void const *data, s6_accessrules_params_t *params, s6_accessrules_backend_func_ref check1) { char fmt[IP6_FMT + UINT_FMT + 6] = "ip6/" ; char ip6[16] ; diff -Nru s6-2.10.0.2/src/libs6/s6_accessrules_keycheck_reversedns.c s6-2.11.0.0/src/libs6/s6_accessrules_keycheck_reversedns.c --- s6-2.10.0.2/src/libs6/s6_accessrules_keycheck_reversedns.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_accessrules_keycheck_reversedns.c 2021-09-26 14:04:15.000000000 +0000 @@ -5,7 +5,7 @@ #include #include -s6_accessrules_result_t s6_accessrules_keycheck_reversedns (void const *key, void *data, s6_accessrules_params_t *params, s6_accessrules_backend_func_t_ref check1) +s6_accessrules_result_t s6_accessrules_keycheck_reversedns (void const *key, void const *data, s6_accessrules_params_t *params, s6_accessrules_backend_func_ref check1) { char const *name = key ; size_t len = strlen(name) ; diff -Nru s6-2.10.0.2/src/libs6/s6_accessrules_keycheck_uidgid.c s6-2.11.0.0/src/libs6/s6_accessrules_keycheck_uidgid.c --- s6-2.10.0.2/src/libs6/s6_accessrules_keycheck_uidgid.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_accessrules_keycheck_uidgid.c 2021-09-26 14:04:15.000000000 +0000 @@ -6,7 +6,7 @@ #include #include -s6_accessrules_result_t s6_accessrules_keycheck_uidgid (void const *key, void *data, s6_accessrules_params_t *params, s6_accessrules_backend_func_t_ref check1) +s6_accessrules_result_t s6_accessrules_keycheck_uidgid (void const *key, void const *data, s6_accessrules_params_t *params, s6_accessrules_backend_func_ref check1) { uidgid_t const *uidgid = key ; char fmt[4 + UINT64_FMT] = "uid/" ; diff -Nru s6-2.10.0.2/src/libs6/s6_accessrules_uidgid_cdb.c s6-2.11.0.0/src/libs6/s6_accessrules_uidgid_cdb.c --- s6-2.10.0.2/src/libs6/s6_accessrules_uidgid_cdb.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_accessrules_uidgid_cdb.c 2021-09-26 14:04:15.000000000 +0000 @@ -2,7 +2,7 @@ #include -s6_accessrules_result_t s6_accessrules_uidgid_cdb (uid_t uid, gid_t gid, struct cdb *c, s6_accessrules_params_t *params) +s6_accessrules_result_t s6_accessrules_uidgid_cdb (uid_t uid, gid_t gid, cdb const *c, s6_accessrules_params_t *params) { uidgid_t uidgid = { .left = uid, .right = gid } ; return s6_accessrules_keycheck_uidgid(&uidgid, c, params, &s6_accessrules_backend_cdb) ; diff -Nru s6-2.10.0.2/src/libs6/s6_dtally_pack.c s6-2.11.0.0/src/libs6/s6_dtally_pack.c --- s6-2.10.0.2/src/libs6/s6_dtally_pack.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_dtally_pack.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,7 +1,7 @@ /* ISC license. */ #include -#include +#include void s6_dtally_pack (char *pack, s6_dtally_t const *d) { diff -Nru s6-2.10.0.2/src/libs6/s6_dtally_read.c s6-2.11.0.0/src/libs6/s6_dtally_read.c --- s6-2.10.0.2/src/libs6/s6_dtally_read.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_dtally_read.c 2021-09-26 14:04:15.000000000 +0000 @@ -7,7 +7,7 @@ #include #include #include -#include +#include static int truncit (char const *s) { diff -Nru s6-2.10.0.2/src/libs6/s6_dtally_unpack.c s6-2.11.0.0/src/libs6/s6_dtally_unpack.c --- s6-2.10.0.2/src/libs6/s6_dtally_unpack.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_dtally_unpack.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,7 +1,7 @@ /* ISC license. */ #include -#include +#include void s6_dtally_unpack (char const *pack, s6_dtally_t *d) { diff -Nru s6-2.10.0.2/src/libs6/s6_dtally_write.c s6-2.11.0.0/src/libs6/s6_dtally_write.c --- s6-2.10.0.2/src/libs6/s6_dtally_write.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_dtally_write.c 2021-09-26 14:04:15.000000000 +0000 @@ -2,7 +2,7 @@ #include #include -#include +#include int s6_dtally_write (char const *sv, s6_dtally_t const *tab, size_t n) { diff -Nru s6-2.10.0.2/src/libs6/s6_fdholder_delete_async.c s6-2.11.0.0/src/libs6/s6_fdholder_delete_async.c --- s6-2.10.0.2/src/libs6/s6_fdholder_delete_async.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_fdholder_delete_async.c 2021-09-26 14:04:15.000000000 +0000 @@ -4,14 +4,14 @@ #include #include #include -#include +#include int s6_fdholder_delete_async (s6_fdholder_t *a, char const *id) { size_t idlen = strlen(id) ; char pack[2] = "D" ; struct iovec v[2] = { { .iov_base = pack, .iov_len = 2 }, { .iov_base = (char *)id, .iov_len = idlen + 1 } } ; - unixmessage_v_t m = { .v = v, .vlen = 2, .fds = 0, .nfds = 0 } ; + unixmessagev m = { .v = v, .vlen = 2, .fds = 0, .nfds = 0 } ; if (idlen > S6_FDHOLDER_ID_SIZE) return (errno = ENAMETOOLONG, 0) ; pack[1] = (unsigned char)idlen ; return unixmessage_putv(&a->connection.out, &m) ; diff -Nru s6-2.10.0.2/src/libs6/s6_fdholder_delete.c s6-2.11.0.0/src/libs6/s6_fdholder_delete.c --- s6-2.10.0.2/src/libs6/s6_fdholder_delete.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_fdholder_delete.c 2021-09-26 14:04:15.000000000 +0000 @@ -2,16 +2,17 @@ #include -#include #include #include #include -#include +#include + +#include -int s6_fdholder_delete (s6_fdholder_t *a, char const *id, tain_t const *deadline, tain_t *stamp) +int s6_fdholder_delete (s6_fdholder_t *a, char const *id, tain const *deadline, tain *stamp) { - unixmessage_t m ; + unixmessage m ; if (!s6_fdholder_delete_async(a, id)) return 0 ; if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return 0 ; if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return 0 ; @@ -20,5 +21,5 @@ unixmessage_drop(&m) ; return (errno = EPROTO, 0) ; } - return m.s[0] ? (errno = m.s[0], 0) : 1 ; + return m.s[0] ? (errno = (unsigned char)m.s[0], 0) : 1 ; } diff -Nru s6-2.10.0.2/src/libs6/s6_fdholder_end.c s6-2.11.0.0/src/libs6/s6_fdholder_end.c --- s6-2.10.0.2/src/libs6/s6_fdholder_end.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_fdholder_end.c 2021-09-26 14:04:15.000000000 +0000 @@ -2,7 +2,7 @@ #include #include -#include +#include void s6_fdholder_end (s6_fdholder_t *a) { diff -Nru s6-2.10.0.2/src/libs6/s6_fdholder_getdump.c s6-2.11.0.0/src/libs6/s6_fdholder_getdump.c --- s6-2.10.0.2/src/libs6/s6_fdholder_getdump.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_fdholder_getdump.c 2021-09-26 14:04:15.000000000 +0000 @@ -4,7 +4,6 @@ #include #include -#include #include #include #include @@ -12,11 +11,13 @@ #include #include -#include +#include + +#include -int s6_fdholder_getdump (s6_fdholder_t *a, genalloc *g, tain_t const *deadline, tain_t *stamp) +int s6_fdholder_getdump (s6_fdholder_t *a, genalloc *g, tain const *deadline, tain *stamp) { - unixmessage_t m = { .s = "?", .len = 1, .fds = 0, .nfds = 0 } ; + unixmessage m = { .s = "?", .len = 1, .fds = 0, .nfds = 0 } ; uint32_t ntot, n ; size_t oldlen = genalloc_len(s6_fdholder_fd_t, g) ; unsigned int i = 0 ; @@ -25,7 +26,7 @@ if (!unixmessage_sender_timed_flush(&a->connection.out, 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.s[0]) return (errno = (unsigned char)m.s[0], 0) ; if (m.len != 9) return (errno = EPROTO, 0) ; uint32_unpack_big(m.s + 1, &n) ; uint32_unpack_big(m.s + 5, &ntot) ; diff -Nru s6-2.10.0.2/src/libs6/s6_fdholder_list_async.c s6-2.11.0.0/src/libs6/s6_fdholder_list_async.c --- s6-2.10.0.2/src/libs6/s6_fdholder_list_async.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_fdholder_list_async.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,10 +1,10 @@ /* ISC license. */ #include -#include +#include int s6_fdholder_list_async (s6_fdholder_t *a) { - unixmessage_t m = { .s = "L", .len = 1, .fds = 0, .nfds = 0 } ; + unixmessage m = { .s = "L", .len = 1, .fds = 0, .nfds = 0 } ; return unixmessage_put(&a->connection.out, &m) ; } diff -Nru s6-2.10.0.2/src/libs6/s6_fdholder_list.c s6-2.11.0.0/src/libs6/s6_fdholder_list.c --- s6-2.10.0.2/src/libs6/s6_fdholder_list.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_fdholder_list.c 2021-09-26 14:04:15.000000000 +0000 @@ -5,12 +5,12 @@ #include #include #include -#include +#include -int s6_fdholder_list (s6_fdholder_t *a, stralloc *sa, tain_t const *deadline, tain_t *stamp) +int s6_fdholder_list (s6_fdholder_t *a, stralloc *sa, tain const *deadline, tain *stamp) { s6_fdholder_list_result_t res = { .sa = sa } ; - unixmessage_t m ; + unixmessage m ; if (!s6_fdholder_list_async(a)) return -1 ; if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return -1 ; if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return -1 ; diff -Nru s6-2.10.0.2/src/libs6/s6_fdholder_list_cb.c s6-2.11.0.0/src/libs6/s6_fdholder_list_cb.c --- s6-2.10.0.2/src/libs6/s6_fdholder_list_cb.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_fdholder_list_cb.c 2021-09-26 14:04:15.000000000 +0000 @@ -3,14 +3,15 @@ #include #include -#include #include #include #include #include -#include +#include + +#include -int s6_fdholder_list_cb (unixmessage_t const *m, void *p) +int s6_fdholder_list_cb (unixmessage const *m, void *p) { uint32_t n ; s6_fdholder_list_result_t *res = p ; diff -Nru s6-2.10.0.2/src/libs6/s6_fdholder_retrieve_async.c s6-2.11.0.0/src/libs6/s6_fdholder_retrieve_async.c --- s6-2.10.0.2/src/libs6/s6_fdholder_retrieve_async.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_fdholder_retrieve_async.c 2021-09-26 14:04:15.000000000 +0000 @@ -4,14 +4,14 @@ #include #include #include -#include +#include int s6_fdholder_retrieve_maybe_delete_async (s6_fdholder_t *a, char const *id, int dodelete) { size_t idlen = strlen(id) ; char pack[3] = "R" ; struct iovec v[2] = { { .iov_base = pack, .iov_len = 3 }, { .iov_base = (char *)id, .iov_len = idlen + 1 } } ; - unixmessage_v_t m = { .v = v, .vlen = 2, .fds = 0, .nfds = 0 } ; + unixmessagev m = { .v = v, .vlen = 2, .fds = 0, .nfds = 0 } ; if (idlen > S6_FDHOLDER_ID_SIZE) return (errno = ENAMETOOLONG, 0) ; pack[1] = !!dodelete ; pack[2] = (unsigned char)idlen ; diff -Nru s6-2.10.0.2/src/libs6/s6_fdholder_retrieve.c s6-2.11.0.0/src/libs6/s6_fdholder_retrieve.c --- s6-2.10.0.2/src/libs6/s6_fdholder_retrieve.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_fdholder_retrieve.c 2021-09-26 14:04:15.000000000 +0000 @@ -4,11 +4,11 @@ #include #include #include -#include +#include -int s6_fdholder_retrieve_maybe_delete (s6_fdholder_t *a, char const *id, int dodelete, tain_t const *deadline, tain_t *stamp) +int s6_fdholder_retrieve_maybe_delete (s6_fdholder_t *a, char const *id, int dodelete, tain const *deadline, tain *stamp) { - unixmessage_t m ; + unixmessage m ; 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 ; diff -Nru s6-2.10.0.2/src/libs6/s6_fdholder_retrieve_cb.c s6-2.11.0.0/src/libs6/s6_fdholder_retrieve_cb.c --- s6-2.10.0.2/src/libs6/s6_fdholder_retrieve_cb.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_fdholder_retrieve_cb.c 2021-09-26 14:04:15.000000000 +0000 @@ -2,12 +2,13 @@ #include -#include #include -#include +#include + +#include -int s6_fdholder_retrieve_cb (unixmessage_t const *m, void *p) +int s6_fdholder_retrieve_cb (unixmessage const *m, void *p) { s6_fdholder_retrieve_result_t *res = p ; if (m->len != 1) goto err ; diff -Nru s6-2.10.0.2/src/libs6/s6_fdholder_setdump.c s6-2.11.0.0/src/libs6/s6_fdholder_setdump.c --- s6-2.10.0.2/src/libs6/s6_fdholder_setdump.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_fdholder_setdump.c 2021-09-26 14:04:15.000000000 +0000 @@ -5,7 +5,6 @@ #include #include -#include #include #include #include @@ -13,9 +12,11 @@ #include #include -#include +#include + +#include -int s6_fdholder_setdump (s6_fdholder_t *a, s6_fdholder_fd_t const *list, unsigned int ntot, tain_t const *deadline, tain_t *stamp) +int s6_fdholder_setdump (s6_fdholder_t *a, s6_fdholder_fd_t const *list, unsigned int ntot, tain const *deadline, tain *stamp) { uint32_t trips ; if (!ntot) return 1 ; @@ -27,13 +28,13 @@ } { char pack[5] = "!" ; - unixmessage_t m = { .s = pack, .len = 5, .fds = 0, .nfds = 0 } ; + unixmessage m = { .s = pack, .len = 5, .fds = 0, .nfds = 0 } ; 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 (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.s[0]) return (errno = (unsigned char)m.s[0], 0) ; if (m.len != 5) return (errno = EPROTO, 0) ; uint32_unpack_big(m.s + 1, &trips) ; if (trips != 1 + (ntot-1) / UNIXMESSAGE_MAXFDS) return (errno = EPROTO, 0) ; @@ -45,7 +46,7 @@ unsigned int j = 0 ; struct iovec v[1 + (n<<1)] ; int fds[n] ; - unixmessage_v_t m = { .v = v, .vlen = 1 + (n<<1), .fds = fds, .nfds = n } ; + unixmessagev m = { .v = v, .vlen = 1 + (n<<1), .fds = fds, .nfds = n } ; char pack[n * (TAIN_PACK+1)] ; v[0].iov_base = "." ; v[0].iov_len = 1 ; for (; j < n ; j++, list++, ntot--) @@ -63,17 +64,17 @@ } if (!unixmessage_sender_timed_flush(&a->connection.out, deadline, stamp)) return 0 ; { - unixmessage_t m ; + unixmessage m ; if (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return 0 ; if (m.len != 1 || m.nfds) { unixmessage_drop(&m) ; return (errno = EPROTO, 0) ; } - if (!error_isagain(m.s[0]) && i < trips-1) - return errno = m.s[0] ? m.s[0] : EPROTO, 0 ; + if (!error_isagain((unsigned char)m.s[0]) && i < trips-1) + return errno = m.s[0] ? (unsigned char)m.s[0] : EPROTO, 0 ; if (i == trips - 1 && m.s[0]) - return errno = error_isagain(m.s[0]) ? EPROTO : m.s[0], 0 ; + return errno = error_isagain((unsigned char)m.s[0]) ? EPROTO : (unsigned char)m.s[0], 0 ; } } return 1 ; diff -Nru s6-2.10.0.2/src/libs6/s6_fdholder_start.c s6-2.11.0.0/src/libs6/s6_fdholder_start.c --- s6-2.10.0.2/src/libs6/s6_fdholder_start.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_fdholder_start.c 2021-09-26 14:04:15.000000000 +0000 @@ -3,9 +3,9 @@ #include #include -#include +#include -int s6_fdholder_start (s6_fdholder_t *a, char const *path, tain_t const *deadline, tain_t *stamp) +int s6_fdholder_start (s6_fdholder_t *a, char const *path, tain const *deadline, tain *stamp) { int fd = ipc_stream_nb() ; if (fd < 0) return 0 ; diff -Nru s6-2.10.0.2/src/libs6/s6_fdholder_store_async.c s6-2.11.0.0/src/libs6/s6_fdholder_store_async.c --- s6-2.10.0.2/src/libs6/s6_fdholder_store_async.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_fdholder_store_async.c 2021-09-26 14:04:15.000000000 +0000 @@ -5,14 +5,14 @@ #include #include #include -#include +#include -int s6_fdholder_store_async (s6_fdholder_t *a, int fd, char const *id, tain_t const *limit) +int s6_fdholder_store_async (s6_fdholder_t *a, int fd, char const *id, tain const *limit) { size_t idlen = strlen(id) ; char pack[2 + TAIN_PACK] = "S" ; struct iovec v[2] = { { .iov_base = pack, .iov_len = 2 + TAIN_PACK }, { .iov_base = (char *)id, .iov_len = idlen + 1 } } ; - unixmessage_v_t m = { .v = v, .vlen = 2, .fds = &fd, .nfds = 1 } ; + unixmessagev m = { .v = v, .vlen = 2, .fds = &fd, .nfds = 1 } ; if (idlen > S6_FDHOLDER_ID_SIZE) return (errno = ENAMETOOLONG, 0) ; tain_pack(pack + 1, limit) ; pack[1+TAIN_PACK] = (unsigned char)idlen ; diff -Nru s6-2.10.0.2/src/libs6/s6_fdholder_store.c s6-2.11.0.0/src/libs6/s6_fdholder_store.c --- s6-2.10.0.2/src/libs6/s6_fdholder_store.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_fdholder_store.c 2021-09-26 14:04:15.000000000 +0000 @@ -2,15 +2,17 @@ #include -#include #include #include #include -#include -int s6_fdholder_store (s6_fdholder_t *a, int fd, char const *id, tain_t const *limit, tain_t const *deadline, tain_t *stamp) +#include + +#include + +int s6_fdholder_store (s6_fdholder_t *a, int fd, char const *id, tain const *limit, tain const *deadline, tain *stamp) { - unixmessage_t m ; + unixmessage 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 (sanitize_read(unixmessage_timed_receive(&a->connection.in, &m, deadline, stamp)) < 0) return 0 ; @@ -19,5 +21,5 @@ unixmessage_drop(&m) ; return (errno = EPROTO, 0) ; } - return m.s[0] ? (errno = m.s[0], 0) : 1 ; + return m.s[0] ? (errno = (unsigned char)m.s[0], 0) : 1 ; } diff -Nru s6-2.10.0.2/src/libs6/s6-ftrigrd.c s6-2.11.0.0/src/libs6/s6-ftrigrd.c --- s6-2.10.0.2/src/libs6/s6-ftrigrd.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6-ftrigrd.c 2021-09-26 14:04:15.000000000 +0000 @@ -8,7 +8,6 @@ #include #include -#include #include #include #include @@ -25,6 +24,8 @@ #include "ftrig1.h" #include +#include + #define FTRIGRD_MAXREADS 32 #define FTRIGRD_BUFSIZE 17 @@ -73,9 +74,9 @@ } } -static void answer (char c) +static void answer (unsigned char c) { - if (!textmessage_put(textmessage_sender_1, &c, 1)) + if (!textmessage_put(textmessage_sender_1, (char *)&c, 1)) { cleanup() ; strerr_diefu1sys(111, "textmessage_put") ; @@ -197,10 +198,10 @@ if (ndelay_on(0) < 0) strerr_diefu2sys(111, "ndelay_on ", "0") ; if (ndelay_on(1) < 0) strerr_diefu2sys(111, "ndelay_on ", "1") ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; + if (!sig_ignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; { - tain_t deadline ; + tain deadline ; tain_now_set_stopwatch_g() ; tain_addsec_g(&deadline, 2) ; if (!textclient_server_01x_init_g(FTRIGR_BANNER1, FTRIGR_BANNER1_LEN, FTRIGR_BANNER2, FTRIGR_BANNER2_LEN, &deadline)) diff -Nru s6-2.10.0.2/src/libs6/s6lock_acquire.c s6-2.11.0.0/src/libs6/s6lock_acquire.c --- s6-2.10.0.2/src/libs6/s6lock_acquire.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6lock_acquire.c 2021-09-26 14:04:15.000000000 +0000 @@ -9,9 +9,9 @@ #include #include #include -#include +#include -int s6lock_acquire (s6lock_t *a, uint16_t *u, char const *path, uint32_t options, tain_t const *limit, tain_t const *deadline, tain_t *stamp) +int s6lock_acquire (s6lock_t *a, uint16_t *u, char const *path, uint32_t options, tain const *limit, tain const *deadline, tain *stamp) { size_t pathlen = strlen(path) ; char tmp[23] = "--<" ; @@ -35,7 +35,7 @@ errno = e ; return 0 ; } - *GENSETDYN_P(char, &a->data, i) = EAGAIN ; + *GENSETDYN_P(unsigned char, &a->data, i) = EAGAIN ; *u = i ; return 1 ; } diff -Nru s6-2.10.0.2/src/libs6/s6lock_check.c s6-2.11.0.0/src/libs6/s6lock_check.c --- s6-2.10.0.2/src/libs6/s6lock_check.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6lock_check.c 2021-09-26 14:04:15.000000000 +0000 @@ -3,11 +3,11 @@ #include #include #include -#include +#include int s6lock_check (s6lock_t *a, uint16_t id) { - char *p = GENSETDYN_P(char, &a->data, id) ; + unsigned char *p = GENSETDYN_P(unsigned char, &a->data, id) ; switch (*p) { case EBUSY : return 1 ; diff -Nru s6-2.10.0.2/src/libs6/s6lockd.c s6-2.11.0.0/src/libs6/s6lockd.c --- s6-2.10.0.2/src/libs6/s6lockd.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6lockd.c 2021-09-26 14:04:15.000000000 +0000 @@ -20,7 +20,7 @@ #include #include -#include +#include #define USAGE "s6lockd lockdir" #define X() strerr_dief1x(101, "internal inconsistency, please submit a bug-report.") @@ -30,7 +30,7 @@ { unsigned int xindex ; unsigned int pid ; - tain_t limit ; + tain limit ; int p[2] ; uint16_t id ; /* given by client */ } ; @@ -56,7 +56,7 @@ genalloc_setlen(s6lockio_t, &a, 0) ; } -static void trig (uint16_t id, char e) +static void trig (uint16_t id, unsigned char e) { char pack[3] ; uint16_pack_big(pack, id) ; @@ -68,9 +68,9 @@ } } -static void answer (char c) +static void answer (unsigned char c) { - if (!textmessage_put(textmessage_sender_1, &c, 1)) + if (!textmessage_put(textmessage_sender_1, (char *)&c, 1)) { cleanup() ; strerr_diefu1sys(111, "textmessage_put") ; @@ -179,7 +179,7 @@ int main (int argc, char const *const *argv) { - tain_t deadline ; + tain deadline ; int sfd ; PROG = "s6lockd" ; @@ -187,7 +187,7 @@ if (chdir(argv[1]) < 0) strerr_diefu2sys(111, "chdir to ", argv[1]) ; if (ndelay_on(0) < 0) strerr_diefu2sys(111, "ndelay_on ", "0") ; if (ndelay_on(1) < 0) strerr_diefu2sys(111, "ndelay_on ", "1") ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; + if (!sig_altignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; sfd = selfpipe_init() ; if (sfd < 0) strerr_diefu1sys(111, "selfpipe_init") ; @@ -200,7 +200,7 @@ sigaddset(&set, SIGHUP) ; sigaddset(&set, SIGABRT) ; sigaddset(&set, SIGINT) ; - if (selfpipe_trapset(&set) < 0) + if (!selfpipe_trapset(&set)) strerr_diefu1sys(111, "trap signals") ; } diff -Nru s6-2.10.0.2/src/libs6/s6lockd-helper.c s6-2.11.0.0/src/libs6/s6lockd-helper.c --- s6-2.10.0.2/src/libs6/s6lockd-helper.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6lockd-helper.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,25 +1,19 @@ /* ISC license. */ -#include - #include #include -#include -#define USAGE "s6lockd-helper lockfile" +#include "s6lockd.h" + +#define USAGE "s6lockd-helper r|w lockfile" #define dieusage() strerr_dieusage(100, USAGE) int main (int argc, char const *const *argv) { - int fd, r ; char c ; PROG = "s6lockd-helper" ; if (argc < 3) dieusage() ; - fd = open_create(argv[2]) ; - if (fd < 0) strerr_diefu2sys(111, "open ", argv[1]) ; - r = fd_lock(fd, argv[1][0] == 'w', 0) ; - if (!r) errno = EBUSY ; - if (r < 1) strerr_diefu2sys(111, "lock ", argv[2]) ; + s6lockd_openandlock(argv[2], argv[1][0] == 'w', 0) ; if (fd_write(1, "!", 1) <= 0) strerr_diefu1sys(111, "write to stdout") ; if (fd_read(0, &c, 1) < 0) diff -Nru s6-2.10.0.2/src/libs6/s6lockd_openandlock.c s6-2.11.0.0/src/libs6/s6lockd_openandlock.c --- s6-2.10.0.2/src/libs6/s6lockd_openandlock.c 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6lockd_openandlock.c 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,35 @@ +/* ISC license. */ + +#include + +#include +#include + +#include "s6lockd.h" + +int s6lockd_openandlock (char const *file, int ex, int nb) +{ + int fd, r ; + if (ex) + { + fd = open_create(file) ; + if (fd < 0) strerr_diefu3sys(111, "open ", file, " for writing") ; + } + else + { + fd = open_read(file) ; + if (fd < 0) + { + if (errno != ENOENT) strerr_diefu3sys(111, "open ", file, " for reading") ; + fd = open_create(file) ; + if (fd < 0) strerr_diefu2sys(111, "create ", file) ; + fd_close(fd) ; + fd = open_read(file) ; + if (fd < 0) strerr_diefu3sys(111, "open ", file, " for reading") ; + } + } + r = fd_lock(fd, ex, nb) ; + if (!r) errno = EBUSY ; + if (r < 1) strerr_diefu2sys(1, "lock ", file) ; + return fd ; +} diff -Nru s6-2.10.0.2/src/libs6/s6lock_end.c s6-2.11.0.0/src/libs6/s6lock_end.c --- s6-2.10.0.2/src/libs6/s6lock_end.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6lock_end.c 2021-09-26 14:04:15.000000000 +0000 @@ -4,7 +4,7 @@ #include #include #include -#include +#include void s6lock_end (s6lock_t *a) { diff -Nru s6-2.10.0.2/src/libs6/s6lock_release.c s6-2.11.0.0/src/libs6/s6lock_release.c --- s6-2.10.0.2/src/libs6/s6lock_release.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6lock_release.c 2021-09-26 14:04:15.000000000 +0000 @@ -5,11 +5,11 @@ #include #include #include -#include +#include -int s6lock_release (s6lock_t *a, uint16_t i, tain_t const *deadline, tain_t *stamp) +int s6lock_release (s6lock_t *a, uint16_t i, tain const *deadline, tain *stamp) { - char *p = GENSETDYN_P(char, &a->data, i) ; + unsigned char *p = GENSETDYN_P(unsigned char, &a->data, i) ; char pack[3] = "-->" ; if ((*p != EBUSY) && !error_isagain(*p)) { diff -Nru s6-2.10.0.2/src/libs6/s6lock_start.c s6-2.11.0.0/src/libs6/s6lock_start.c --- s6-2.10.0.2/src/libs6/s6lock_start.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6lock_start.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,9 +1,9 @@ /* ISC license. */ #include -#include +#include -int s6lock_start (s6lock_t *a, char const *path, tain_t const *deadline, tain_t *stamp) +int s6lock_start (s6lock_t *a, char const *path, tain const *deadline, tain *stamp) { return textclient_start(&a->connection, path, 0, S6LOCK_BANNER1, S6LOCK_BANNER1_LEN, S6LOCK_BANNER2, S6LOCK_BANNER2_LEN, deadline, stamp) ; } diff -Nru s6-2.10.0.2/src/libs6/s6lock_startf.c s6-2.11.0.0/src/libs6/s6lock_startf.c --- s6-2.10.0.2/src/libs6/s6lock_startf.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6lock_startf.c 2021-09-26 14:04:15.000000000 +0000 @@ -3,9 +3,9 @@ #include #include #include -#include +#include -int s6lock_startf (s6lock_t *a, char const *lockdir, tain_t const *deadline, tain_t *stamp) +int s6lock_startf (s6lock_t *a, char const *lockdir, tain const *deadline, tain *stamp) { char const *cargv[3] = { S6LOCKD_PROG, lockdir, 0 } ; if (!lockdir) return (errno = EINVAL, 0) ; diff -Nru s6-2.10.0.2/src/libs6/s6lock_update.c s6-2.11.0.0/src/libs6/s6lock_update.c --- s6-2.10.0.2/src/libs6/s6lock_update.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6lock_update.c 2021-09-26 14:04:15.000000000 +0000 @@ -4,24 +4,25 @@ #include #include -#include #include #include #include #include #include -#include +#include + +#include static int msghandler (struct iovec const *v, void *context) { s6lock_t *a = (s6lock_t *)context ; char const *s = v->iov_base ; - char *p ; + unsigned char *p ; uint16_t id ; if (v->iov_len != 3) return (errno = EPROTO, 0) ; uint16_unpack_big(s, &id) ; - p = GENSETDYN_P(char, &a->data, id) ; + p = GENSETDYN_P(unsigned char, &a->data, id) ; if (*p == EBUSY) *p = s[2] ; else if (error_isagain(*p)) *p = s[2] ? s[2] : EBUSY ; else return (errno = EPROTO, 0) ; diff -Nru s6-2.10.0.2/src/libs6/s6lock_wait_and.c s6-2.11.0.0/src/libs6/s6lock_wait_and.c --- s6-2.10.0.2/src/libs6/s6lock_wait_and.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6lock_wait_and.c 2021-09-26 14:04:15.000000000 +0000 @@ -2,9 +2,9 @@ #include #include -#include +#include -int s6lock_wait_and (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain_t const *deadline, tain_t *stamp) +int s6lock_wait_and (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain const *deadline, tain *stamp) { iopause_fd x = { .fd = -1, .events = IOPAUSE_READ, .revents = 0 } ; x.fd = s6lock_fd(a) ; diff -Nru s6-2.10.0.2/src/libs6/s6lock_wait_or.c s6-2.11.0.0/src/libs6/s6lock_wait_or.c --- s6-2.10.0.2/src/libs6/s6lock_wait_or.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6lock_wait_or.c 2021-09-26 14:04:15.000000000 +0000 @@ -2,12 +2,13 @@ #include -#include #include -#include +#include + +#include -int s6lock_wait_or (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain_t const *deadline, tain_t *stamp) +int s6lock_wait_or (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain const *deadline, tain *stamp) { iopause_fd x = { -1, IOPAUSE_READ | IOPAUSE_EXCEPT, 0 } ; x.fd = s6lock_fd(a) ; diff -Nru s6-2.10.0.2/src/libs6/s6lock_zero.c s6-2.11.0.0/src/libs6/s6lock_zero.c --- s6-2.10.0.2/src/libs6/s6lock_zero.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6lock_zero.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,5 +1,5 @@ /* ISC license. */ -#include +#include s6lock_t const s6lock_zero = S6LOCK_ZERO ; diff -Nru s6-2.10.0.2/src/libs6/s6_supervise_link.c s6-2.11.0.0/src/libs6/s6_supervise_link.c --- s6-2.10.0.2/src/libs6/s6_supervise_link.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_supervise_link.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,156 +1,34 @@ /* ISC license. */ -#include #include -#include -#include -#include -#include -#include -#include #include #include -#include -#include -#include +#include -static inline void do_unlink (char const *scdir, char const *prefix, size_t prefixlen, size_t maxlen, char const *names, size_t nameslen, uint32_t killopts) +int s6_supervise_link (char const *scdir, char const *const *servicedirs, size_t n, char const *prefix, uint32_t options, tain const *deadline, tain *stamp) { - char fn[prefixlen + maxlen + 1] ; - memcpy(fn, prefix, prefixlen) ; - while (nameslen) + int r ; + size_t prefixlen = strlen(prefix) ; + stralloc sa = STRALLOC_ZERO ; + char const *names[n ? n : 1] ; { - size_t len = strlen(names) + 1 ; - memcpy(fn + prefixlen, names, len) ; - s6_supervise_unlink(scdir, fn, killopts) ; - names += len ; nameslen -= len ; - } -} - -static uint16_t registerit (ftrigr_t *a, char *fn, size_t len, gid_t gid, uint32_t options, tain_t const *deadline, tain_t *stamp) -{ - if (options & 4) - { - int fd ; - memcpy(fn + len, "/down", 6) ; - fd = open_trunc(fn) ; - if (fd < 0) return 0 ; - fd_close(fd) ; - } - memcpy(fn + len, "/" S6_SUPERVISE_EVENTDIR, 1 + sizeof(S6_SUPERVISE_EVENTDIR)) ; - if (!ftrigw_fifodir_make(fn, gid, options & 1)) return 0 ; - return ftrigr_subscribe(a, fn, "s", 0, deadline, stamp) ; -} - -int s6_supervise_link (char const *scdir, char const *const *servicedirs, size_t n, char const *prefix, uint32_t options, tain_t const *deadline, tain_t *stamp) -{ - size_t maxlen = 0 ; - size_t ntotal = n ; - unsigned char locked[bitarray_div8(n)] ; - unsigned char logged[bitarray_div8(n)] ; - if (!n) return 0 ; - memset(locked, 0, bitarray_div8(n)) ; - memset(logged, 0, bitarray_div8(n)) ; - - for (size_t i = 0 ; i < n ; i++) - { - struct stat st ; - size_t len = strlen(servicedirs[i]) ; - int h ; - char subdir[len + 5] ; - if (len > maxlen) maxlen = len ; - h = s6_svc_ok(servicedirs[i]) ; - if (h < 0) return -1 ; - if (h) bitarray_set(locked, i) ; - memcpy(subdir, servicedirs[i], len) ; - memcpy(subdir + len, "/log", 5) ; - if (stat(subdir, &st) < 0) + size_t indices[n ? n : 1] ; + for (size_t i = 0 ; i < n ; i++) { - if (errno != ENOENT) return -1 ; + indices[i] = sa.len ; + if (!stralloc_catb(&sa, prefix, prefixlen) + || !sabasename(&sa, servicedirs[i], strlen(servicedirs[i])) + || !stralloc_0(&sa)) goto err ; } - else - { - int r ; - if (!S_ISDIR(st.st_mode)) return (errno = ENOTDIR, -1) ; - r = s6_svc_ok(subdir) ; - if (r < 0) return -1 ; - if (r != h) return (errno = EINVAL, -1) ; - bitarray_set(logged, i) ; - ntotal++ ; - } - } - - { - stralloc lnames = STRALLOC_ZERO ; - ftrigr_t a = FTRIGR_ZERO ; - stralloc rpsa = STRALLOC_ZERO ; - gid_t gid = options & 2 ? -1 : getegid() ; - size_t scdirlen = strlen(scdir) ; - size_t prefixlen = strlen(prefix) ; - unsigned int m = 0 ; - size_t i = 0 ; - size_t lstart = 0 ; - uint32_t killopts = 0 ; - int r ; - uint16_t ids[ntotal] ; - char lname[scdirlen + prefixlen + maxlen + 2] ; - char fn[maxlen + 5 + (sizeof(S6_SUPERVISE_EVENTDIR) > 5 ? sizeof(S6_SUPERVISE_EVENTDIR) : 5)] ; - if (!ftrigr_startf(&a, deadline, stamp)) return -1 ; - memcpy(lname, scdir, scdirlen) ; - lname[scdirlen] = '/' ; - memcpy(lname + scdirlen + 1, prefix, prefixlen) ; - for (i = 0 ; i < n ; i++) - { - char *p ; - char const *src ; - size_t len = strlen(servicedirs[i]) ; - int h = bitarray_peek(locked, i) ; - memcpy(fn, servicedirs[i], len) ; - if (!h) - { - ids[m] = registerit(&a, fn, len, gid, options, deadline, stamp) ; - if (!ids[m++]) goto err ; - if (bitarray_peek(logged, i)) - { - memcpy(fn + len, "/log", 4) ; - ids[m] = registerit(&a, fn, len + 4, gid, options, deadline, stamp) ; - if (!ids[m++]) goto err ; - } - } - fn[len] = 0 ; - p = basename(fn) ; - len = strlen(p) ; - memcpy(lname + scdirlen + 1 + prefixlen, p, len + 1) ; - lstart = lnames.len ; - if (!h && !stralloc_catb(&lnames, p, len + 1)) goto err ; - if (servicedirs[i][0] == '/') src = servicedirs[i] ; - else - { - rpsa.len = 0 ; - if (sarealpath(&rpsa, servicedirs[i]) < 0 || !stralloc_0(&rpsa)) goto errl ; - src = rpsa.s ; - } - if (symlink(src, lname) < 0 && (!h || errno != EEXIST)) goto errl ; - } - stralloc_free(&rpsa) ; - r = s6_svc_writectl(scdir, S6_SVSCAN_CTLDIR, "a", 1) ; - if (r <= 0) goto errsa ; - killopts = 3 ; - if (ftrigr_wait_and(&a, ids, m, deadline, stamp) < 0) goto errsa ; - ftrigr_end(&a) ; - stralloc_free(&lnames) ; - return m ; - - errl: - lnames.len = lstart ; - err: - stralloc_free(&rpsa) ; - errsa: - ftrigr_end(&a) ; - do_unlink(scdir, prefix, prefixlen, maxlen, lnames.s, lnames.len, killopts | (options & 4)) ; - stralloc_free(&lnames) ; - return -1 ; + for (size_t i = 0 ; i < n ; i++) names[i] = sa.s + indices[i] ; } + r = s6_supervise_link_names(scdir, servicedirs, names, n, options, deadline, stamp) ; + stralloc_free(&sa) ; + return r ; + + err: + stralloc_free(&sa) ; + return -1 ; } diff -Nru s6-2.10.0.2/src/libs6/s6_supervise_link_names.c s6-2.11.0.0/src/libs6/s6_supervise_link_names.c --- s6-2.10.0.2/src/libs6/s6_supervise_link_names.c 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_supervise_link_names.c 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,155 @@ +/* ISC license. */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +static inline void do_unlink (char const *scdir, char const *const *names, size_t n, uint32_t killopts) +{ + for (size_t i = 0 ; i < n ; i++) + s6_supervise_unlink(scdir, names[i], killopts) ; +} + +static uint16_t registerit (ftrigr_t *a, char *fn, size_t len, gid_t gid, uint32_t options, tain const *deadline, tain *stamp) +{ + if (options & 4) + { + int fd ; + memcpy(fn + len, "/down", 6) ; + fd = open_trunc(fn) ; + if (fd < 0) return 0 ; + fd_close(fd) ; + } + memcpy(fn + len, "/" S6_SUPERVISE_EVENTDIR, 1 + sizeof(S6_SUPERVISE_EVENTDIR)) ; + if (!ftrigw_fifodir_make(fn, gid, options & 1)) return 0 ; + return ftrigr_subscribe(a, fn, "s", 0, deadline, stamp) ; +} + +/* + options: bit 0: force event/ mode + bit 1: make event/ public + bit 2: don't start the service + bit 3: remove down files after starting supervisors +*/ + +int s6_supervise_link_names (char const *scdir, char const *const *servicedirs, char const *const *names, size_t n, uint32_t options, tain const *deadline, tain *stamp) +{ + size_t maxnlen = 0, maxlen = 0 ; + size_t ntotal = n ; + unsigned char locked[bitarray_div8(n)] ; + unsigned char logged[bitarray_div8(n)] ; + if (!n) return 0 ; + memset(locked, 0, bitarray_div8(n)) ; + memset(logged, 0, bitarray_div8(n)) ; + + for (size_t i = 0 ; i < n ; i++) + { + struct stat st ; + size_t len = strlen(servicedirs[i]) ; + size_t nlen = strlen(names[i]) ; + int h ; + char subdir[len + 5] ; + if (nlen > maxnlen) maxnlen = nlen ; + if (len > maxlen) maxlen = len ; + h = s6_svc_ok(servicedirs[i]) ; + if (h < 0) return -1 ; + if (h) bitarray_set(locked, i) ; + memcpy(subdir, servicedirs[i], len) ; + memcpy(subdir + len, "/log", 5) ; + if (stat(subdir, &st) < 0) + { + if (errno != ENOENT) return -1 ; + } + else + { + int r ; + if (!S_ISDIR(st.st_mode)) return (errno = ENOTDIR, -1) ; + r = s6_svc_ok(subdir) ; + if (r < 0) return -1 ; + if (r != h) return (errno = EINVAL, -1) ; + bitarray_set(logged, i) ; + ntotal++ ; + } + } + + { + ftrigr_t a = FTRIGR_ZERO ; + stralloc rpsa = STRALLOC_ZERO ; + gid_t gid = options & 2 ? -1 : getegid() ; + size_t scdirlen = strlen(scdir) ; + unsigned int m = 0 ; + size_t i = 0 ; + uint32_t killopts = 0 ; + int r ; + uint16_t ids[ntotal] ; + char lname[scdirlen + maxnlen + 7] ; + char fn[maxlen + 5 + (sizeof(S6_SUPERVISE_EVENTDIR) > 5 ? sizeof(S6_SUPERVISE_EVENTDIR) : 5)] ; + if (!ftrigr_startf(&a, deadline, stamp)) return -1 ; + memcpy(lname, scdir, scdirlen) ; + lname[scdirlen] = '/' ; + for (; i < n ; i++) + { + char const *src = servicedirs[i] ; + size_t len = strlen(servicedirs[i]) ; + int h = bitarray_peek(locked, i) ; + memcpy(fn, servicedirs[i], len) ; + if (!h) + { + ids[m] = registerit(&a, fn, len, gid, options, deadline, stamp) ; + if (!ids[m++]) goto err ; + if (bitarray_peek(logged, i)) + { + memcpy(fn + len, "/log", 4) ; + ids[m] = registerit(&a, fn, len + 4, gid, options, deadline, stamp) ; + if (!ids[m++]) goto err ; + } + } + fn[len] = 0 ; + strcpy(lname + scdirlen + 1, names[i]) ; + if (servicedirs[i][0] != '/') + { + rpsa.len = 0 ; + if (sarealpath(&rpsa, servicedirs[i]) < 0 || !stralloc_0(&rpsa)) goto err ; + src = rpsa.s ; + } + if (symlink(src, lname) < 0 && (!h || errno != EEXIST)) goto err ; + } + stralloc_free(&rpsa) ; + r = s6_svc_writectl(scdir, S6_SVSCAN_CTLDIR, "a", 1) ; + if (!r) errno = ENXIO ; + if (r <= 0) goto errsa ; + killopts = 3 ; + if (ftrigr_wait_and(&a, ids, m, deadline, stamp) < 0) goto errsa ; + ftrigr_end(&a) ; + if (options & 8) + { + for (size_t i = 0 ; i < n ; i++) + { + size_t nlen = strlen(names[i]) ; + memcpy(lname + scdirlen + 1, names[i], nlen) ; + memcpy(lname + scdirlen + 1 + nlen, "/down", 6) ; + unlink_void(lname) ; + } + } + return m ; + + err: + stralloc_free(&rpsa) ; + errsa: + ftrigr_end(&a) ; + do_unlink(scdir, names, i, killopts | (options & 4)) ; + } + return -1 ; +} diff -Nru s6-2.10.0.2/src/libs6/s6_supervise_unlink.c s6-2.11.0.0/src/libs6/s6_supervise_unlink.c --- s6-2.10.0.2/src/libs6/s6_supervise_unlink.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_supervise_unlink.c 2021-09-26 14:04:15.000000000 +0000 @@ -3,27 +3,21 @@ #include #include #include -#include +#include #include #include #include -#include - -#ifdef PATH_MAX -# define S6_PATH_MAX PATH_MAX -#else -# define S6_PATH_MAX 4096 -#endif +#include void s6_supervise_unlink (char const *scdir, char const *name, uint32_t options) { int e = errno ; - int fd = -1 ; + int fd = -1, fdlog = -1 ; size_t scdirlen = strlen(scdir) ; size_t namelen = strlen(name) ; - char fn[scdirlen + namelen + sizeof(S6_SUPERVISE_CTLDIR) + 10] ; + char fn[scdirlen + namelen + sizeof(S6_SUPERVISE_CTLDIR) + 14] ; memcpy(fn, scdir, scdirlen) ; fn[scdirlen] = '/' ; memcpy(fn + scdirlen + 1, name, namelen) ; @@ -37,7 +31,11 @@ memcpy(fn + scdirlen + 1 + namelen, "/" S6_SUPERVISE_CTLDIR, sizeof(S6_SUPERVISE_CTLDIR)) ; memcpy(fn + scdirlen + 1 + namelen + sizeof(S6_SUPERVISE_CTLDIR), "/control", 9) ; fd = open_write(fn) ; + memcpy(fn + scdirlen + 1 + namelen, "/log/" S6_SUPERVISE_CTLDIR, 4 + sizeof(S6_SUPERVISE_CTLDIR)) ; + memcpy(fn + scdirlen + 5 + namelen + sizeof(S6_SUPERVISE_CTLDIR), "/control", 9) ; + fdlog = open_write(fn) ; } + fn[scdirlen + 1 + namelen] = 0 ; unlink_void(fn) ; if (fd >= 0) @@ -45,5 +43,10 @@ fd_write(fd, "xd", 1 + !!(options & 2)) ; fd_close(fd) ; } + if (fdlog >= 0) + { + fd_write(fdlog, "xo", 1 + !!(options & 2)) ; + fd_close(fdlog) ; + } errno = e ; } diff -Nru s6-2.10.0.2/src/libs6/s6_supervise_unlink_names.c s6-2.11.0.0/src/libs6/s6_supervise_unlink_names.c --- s6-2.10.0.2/src/libs6/s6_supervise_unlink_names.c 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_supervise_unlink_names.c 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,98 @@ +/* ISC license. */ + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +static uint16_t registerit (ftrigr_t *a, char *fn, size_t len, tain const *deadline, tain *stamp) +{ + memcpy(fn + len, "/" S6_SUPERVISE_EVENTDIR, sizeof(S6_SUPERVISE_EVENTDIR) + 1) ; + return ftrigr_subscribe(a, fn, "x", 0, deadline, stamp) ; +} + +/* + options: bit 0: wait for s6-supervise to exit +*/ + +int s6_supervise_unlink_names (char const *scdir, char const *const *names, size_t n, uint32_t options, tain const *deadline, tain *stamp) +{ + size_t scdirlen = strlen(scdir) ; + size_t ntotal = n ; + unsigned char locked[bitarray_div8(n)] ; + unsigned char logged[bitarray_div8(n)] ; + if (!n) return 0 ; + memset(locked, 0, bitarray_div8(n)) ; + memset(logged, 0, bitarray_div8(n)) ; + + if (options & 1) for (size_t i = 0 ; i < n ; i++) + { + struct stat st ; + size_t nlen = strlen(names[i]) ; + int h ; + char fn[scdirlen + nlen + 6] ; + memcpy(fn, scdir, scdirlen) ; + fn[scdirlen] = '/' ; + memcpy(fn + scdirlen + 1, names[i], nlen + 1) ; + h = s6_svc_ok(fn) ; + if (h < 0) return -1 ; + if (h) bitarray_set(locked, i) ; + memcpy(fn + scdirlen + 1 + nlen, "/log", 5) ; + if (stat(fn, &st) < 0) + { + if (errno != ENOENT) return -1 ; + } + else + { + int r ; + if (!S_ISDIR(st.st_mode)) return (errno = ENOTDIR, -1) ; + r = s6_svc_ok(fn) ; + if (r < 0) return -1 ; + if (r != h) return (errno = EINVAL, -1) ; + bitarray_set(logged, i) ; + ntotal++ ; + } + } + + { + ftrigr_t a = FTRIGR_ZERO ; + unsigned int m = 0 ; + uint16_t ids[ntotal] ; + if (options & 1 && !ftrigr_startf(&a, deadline, stamp)) return -1 ; + for (size_t i = 0 ; i < n ; i++) + { + size_t nlen = strlen(names[i]) ; + char fn[scdirlen + nlen + 6 + sizeof(S6_SUPERVISE_EVENTDIR)] ; + memcpy(fn, scdir, scdirlen) ; + fn[scdirlen] = '/' ; + memcpy(fn + scdirlen + 1, names[i], nlen) ; + if (options & 1 && bitarray_peek(locked, i)) + { + ids[m] = registerit(&a, fn, scdirlen + 1 + nlen, deadline, stamp) ; + if (ids[m]) m++ ; + if (bitarray_peek(logged, i)) + { + memcpy(fn + scdirlen + 1 + nlen, "/log", 4) ; + ids[m] = registerit(&a, fn, scdirlen + 5 + nlen, deadline, stamp) ; + if (ids[m]) m++ ; + } + } + fn[scdirlen + 1 + nlen] = 0 ; + unlink_void(fn) ; + } + s6_svc_writectl(scdir, S6_SVSCAN_CTLDIR, "an", 2) ; + if (options & 1) + { + ftrigr_wait_and(&a, ids, m, deadline, stamp) ; + ftrigr_end(&a) ; + } + return m ; + } +} diff -Nru s6-2.10.0.2/src/libs6/s6_svc_ok.c s6-2.11.0.0/src/libs6/s6_svc_ok.c --- s6-2.10.0.2/src/libs6/s6_svc_ok.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_svc_ok.c 2021-09-26 14:04:15.000000000 +0000 @@ -5,7 +5,7 @@ #include -#include +#include int s6_svc_ok (char const *dir) { diff -Nru s6-2.10.0.2/src/libs6/s6_svc_write.c s6-2.11.0.0/src/libs6/s6_svc_write.c --- s6-2.10.0.2/src/libs6/s6_svc_write.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_svc_write.c 2021-09-26 14:04:15.000000000 +0000 @@ -3,7 +3,7 @@ #include #include #include -#include +#include int s6_svc_write (char const *fifo, char const *data, size_t datalen) { diff -Nru s6-2.10.0.2/src/libs6/s6_svc_writectl.c s6-2.11.0.0/src/libs6/s6_svc_writectl.c --- s6-2.10.0.2/src/libs6/s6_svc_writectl.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_svc_writectl.c 2021-09-26 14:04:15.000000000 +0000 @@ -7,7 +7,7 @@ #include #include #include -#include +#include int s6_svc_writectl (char const *service, char const *subdir, char const *s, size_t len) { diff -Nru s6-2.10.0.2/src/libs6/s6_svstatus_pack.c s6-2.11.0.0/src/libs6/s6_svstatus_pack.c --- s6-2.10.0.2/src/libs6/s6_svstatus_pack.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_svstatus_pack.c 2021-09-26 14:04:15.000000000 +0000 @@ -4,7 +4,7 @@ #include #include #include -#include +#include void s6_svstatus_pack (char *pack, s6_svstatus_t const *sv) { @@ -15,8 +15,6 @@ pack[34] = sv->flagpaused | (sv->flagfinishing << 1) | - (sv->flagwant << 2) | - (sv->flagwantup << 3) | - (sv->flagready << 4) | - (sv->flagthrottled << 5) ; + (sv->flagwantup << 2) | + (sv->flagready << 3) ; } diff -Nru s6-2.10.0.2/src/libs6/s6_svstatus_read.c s6-2.11.0.0/src/libs6/s6_svstatus_read.c --- s6-2.10.0.2/src/libs6/s6_svstatus_read.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_svstatus_read.c 2021-09-26 14:04:15.000000000 +0000 @@ -2,7 +2,7 @@ #include #include -#include +#include int s6_svstatus_read (char const *dir, s6_svstatus_t *status) { diff -Nru s6-2.10.0.2/src/libs6/s6_svstatus_unpack.c s6-2.11.0.0/src/libs6/s6_svstatus_unpack.c --- s6-2.10.0.2/src/libs6/s6_svstatus_unpack.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_svstatus_unpack.c 2021-09-26 14:04:15.000000000 +0000 @@ -4,7 +4,7 @@ #include #include #include -#include +#include void s6_svstatus_unpack (char const *pack, s6_svstatus_t *sv) { @@ -18,8 +18,6 @@ sv->wstat = wstat ; sv->flagpaused = pack[34] & 1 ; sv->flagfinishing = !!(pack[34] & 2) ; - sv->flagwant = !!(pack[34] & 4) ; - sv->flagwantup = !!(pack[34] & 8) ; - sv->flagready = !!(pack[34] & 16) ; - sv->flagthrottled = !!(pack[34] & 32) ; + sv->flagwantup = !!(pack[34] & 4) ; + sv->flagready = !!(pack[34] & 8) ; } diff -Nru s6-2.10.0.2/src/libs6/s6_svstatus_write.c s6-2.11.0.0/src/libs6/s6_svstatus_write.c --- s6-2.10.0.2/src/libs6/s6_svstatus_write.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/libs6/s6_svstatus_write.c 2021-09-26 14:04:15.000000000 +0000 @@ -2,7 +2,7 @@ #include #include -#include +#include int s6_svstatus_write (char const *dir, s6_svstatus_t const *status) { diff -Nru s6-2.10.0.2/src/pipe-tools/s6-ftrig-listen1.c s6-2.11.0.0/src/pipe-tools/s6-ftrig-listen1.c --- s6-2.10.0.2/src/pipe-tools/s6-ftrig-listen1.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/pipe-tools/s6-ftrig-listen1.c 2021-09-26 14:04:15.000000000 +0000 @@ -33,7 +33,7 @@ int main (int argc, char const *const *argv, char const *const *envp) { iopause_fd x[2] = { { -1, IOPAUSE_READ, 0 }, { -1, IOPAUSE_READ, 0 } } ; - tain_t deadline, tto ; + tain deadline, tto ; ftrigr_t a = FTRIGR_ZERO ; pid_t pid ; uint16_t id ; @@ -43,7 +43,7 @@ unsigned int t = 0 ; for (;;) { - int opt = subgetopt(argc, argv, "t:") ; + int opt = lgetopt(argc, argv, "t:") ; if (opt == -1) break ; switch (opt) { @@ -59,20 +59,18 @@ tain_now_set_stopwatch_g() ; tain_add_g(&deadline, &tto) ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "sig_ignore") ; + if (!sig_altignore(SIGPIPE)) strerr_diefu1sys(111, "sig_ignore") ; if (!ftrigr_startf_g(&a, &deadline)) strerr_diefu1sys(111, "ftrigr_startf") ; id = ftrigr_subscribe_g(&a, argv[0], argv[1], 0, &deadline) ; if (!id) strerr_diefu4sys(111, "subscribe to ", argv[0], " with regexp ", argv[1]) ; x[0].fd = selfpipe_init() ; if (x[0].fd < 0) strerr_diefu1sys(111, "selfpipe_init") ; - if (selfpipe_trap(SIGCHLD) < 0) strerr_diefu1sys(111, "selfpipe_trap") ; + if (!selfpipe_trap(SIGCHLD)) strerr_diefu1sys(111, "selfpipe_trap") ; x[1].fd = ftrigr_fd(&a) ; - sig_restore(SIGPIPE) ; pid = child_spawn0(argv[2], argv+2, envp) ; if (!pid) strerr_diefu2sys(111, "spawn ", argv[2]) ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "sig_ignore") ; for (;;) { diff -Nru s6-2.10.0.2/src/pipe-tools/s6-ftrig-listen.c s6-2.11.0.0/src/pipe-tools/s6-ftrig-listen.c --- s6-2.10.0.2/src/pipe-tools/s6-ftrig-listen.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/pipe-tools/s6-ftrig-listen.c 2021-09-26 14:04:15.000000000 +0000 @@ -34,7 +34,7 @@ int main (int argc, char const **argv, char const *const *envp) { iopause_fd x[2] = { { -1, IOPAUSE_READ, 0 }, { -1, IOPAUSE_READ, 0 } } ; - tain_t deadline, tto ; + tain deadline, tto ; ftrigr_t a = FTRIGR_ZERO ; int argc1 ; unsigned int i = 0 ; @@ -44,7 +44,7 @@ unsigned int t = 0 ; for (;;) { - int opt = subgetopt(argc, argv, "aot:") ; + int opt = lgetopt(argc, argv, "aot:") ; if (opt == -1) break ; switch (opt) { @@ -65,8 +65,8 @@ tain_add_g(&deadline, &tto) ; x[0].fd = selfpipe_init() ; if (x[0].fd < 0) strerr_diefu1sys(111, "selfpipe_init") ; - if (selfpipe_trap(SIGCHLD) < 0) strerr_diefu1sys(111, "selfpipe_trap") ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; + if (!selfpipe_trap(SIGCHLD)) strerr_diefu1sys(111, "selfpipe_trap") ; + if (!sig_altignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; if (!ftrigr_startf_g(&a, &deadline)) strerr_diefu1sys(111, "ftrigr_startf") ; x[1].fd = ftrigr_fd(&a) ; @@ -81,10 +81,8 @@ if (!ids[i]) strerr_diefu4sys(111, "subscribe to ", argv[i<<1], " with regexp ", argv[(i<<1)+1]) ; } - sig_restore(SIGPIPE) ; pid = child_spawn0(argv[argc1 + 1], argv + argc1 + 1, envp) ; if (!pid) strerr_diefu2sys(111, "spawn ", argv[argc1 + 1]) ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; for (;;) { diff -Nru s6-2.10.0.2/src/pipe-tools/s6-ftrig-wait.c s6-2.11.0.0/src/pipe-tools/s6-ftrig-wait.c --- s6-2.10.0.2/src/pipe-tools/s6-ftrig-wait.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/pipe-tools/s6-ftrig-wait.c 2021-09-26 14:04:15.000000000 +0000 @@ -13,7 +13,7 @@ int main (int argc, char const *const *argv) { - tain_t deadline, tto ; + tain deadline, tto ; ftrigr_t a = FTRIGR_ZERO ; uint16_t id ; char pack[2] = " \n" ; @@ -22,7 +22,7 @@ unsigned int t = 0 ; for (;;) { - int opt = subgetopt(argc, argv, "t:") ; + int opt = lgetopt(argc, argv, "t:") ; if (opt == -1) break ; switch (opt) { diff -Nru s6-2.10.0.2/src/pipe-tools/s6-mkfifodir.c s6-2.11.0.0/src/pipe-tools/s6-mkfifodir.c --- s6-2.10.0.2/src/pipe-tools/s6-mkfifodir.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/pipe-tools/s6-mkfifodir.c 2021-09-26 14:04:15.000000000 +0000 @@ -10,7 +10,7 @@ int main (int argc, char const *const *argv) { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; gid_t gid = -1 ; int force = 0 ; PROG = "s6-mkfifodir" ; diff -Nru s6-2.10.0.2/src/supervision/deps-exe/s6-svlink s6-2.11.0.0/src/supervision/deps-exe/s6-svlink --- s6-2.10.0.2/src/supervision/deps-exe/s6-svlink 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/supervision/deps-exe/s6-svlink 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,5 @@ +${LIBS6} +-lskarnet +${SOCKET_LIB} +${SYSCLOCK_LIB} +${SPAWN_LIB} diff -Nru s6-2.10.0.2/src/supervision/deps-exe/s6-svunlink s6-2.11.0.0/src/supervision/deps-exe/s6-svunlink --- s6-2.10.0.2/src/supervision/deps-exe/s6-svunlink 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/supervision/deps-exe/s6-svunlink 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,5 @@ +${LIBS6} +-lskarnet +${SOCKET_LIB} +${SYSCLOCK_LIB} +${SPAWN_LIB} diff -Nru s6-2.10.0.2/src/supervision/s6-notifyoncheck.c s6-2.11.0.0/src/supervision/s6-notifyoncheck.c --- s6-2.10.0.2/src/supervision/s6-notifyoncheck.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-notifyoncheck.c 2021-09-26 14:04:15.000000000 +0000 @@ -91,13 +91,13 @@ int df = 0 ; int autodetect = 1 ; int p[2] ; - tain_t globaldeadline, sleeptto, localtto, waittto ; + tain globaldeadline, sleeptto, localtto, waittto ; unsigned int tries = 7 ; uint16_t id ; PROG = "s6-notifyoncheck" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; unsigned int initialsleep = 10, globaltimeout = 0, localtimeout = 0, waitingtime = 1000 ; for (;;) { @@ -211,8 +211,8 @@ while (tries == UINT_MAX || tries--) { - tain_t deadline = globaldeadline ; - tain_t localdeadline ; + tain deadline = globaldeadline ; + tain localdeadline ; pid_t pid ; tain_add_g(&localdeadline, &sleeptto) ; diff -Nru s6-2.10.0.2/src/supervision/s6-permafailon.c s6-2.11.0.0/src/supervision/s6-permafailon.c --- s6-2.10.0.2/src/supervision/s6-permafailon.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-permafailon.c 2021-09-26 14:04:15.000000000 +0000 @@ -11,7 +11,7 @@ #include #include -#include +#include #define USAGE "s6-permafailon seconds deathcount statuslist prog..." #define dieusage() strerr_dieusage(100, USAGE) @@ -86,7 +86,7 @@ } total = st.st_size / S6_DTALLY_PACK ; { - tain_t mintime ; + tain mintime ; unsigned int matches = 0 ; s6_dtally_t tab[total] ; ssize_t r = s6_dtally_read(".", tab, total) ; @@ -98,7 +98,7 @@ if (r < n) goto cont ; tain_uint(&mintime, seconds) ; { - tain_t now ; + tain now ; tain_wallclock_read(&now) ; tain_sub(&mintime, &now, &mintime) ; } diff -Nru s6-2.10.0.2/src/supervision/s6-supervise.c s6-2.11.0.0/src/supervision/s6-supervise.c --- s6-2.10.0.2/src/supervision/s6-supervise.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-supervise.c 2021-09-26 14:04:15.000000000 +0000 @@ -25,17 +25,14 @@ #include #include -#include +#include #define USAGE "s6-supervise dir" #define CTL S6_SUPERVISE_CTLDIR "/control" #define LCK S6_SUPERVISE_CTLDIR "/lock" +#define SLCK S6_SUPERVISE_CTLDIR "/service-lock" -#ifdef PATH_MAX -# define S6_PATH_MAX PATH_MAX -#else -# define S6_PATH_MAX 4096 -#endif +#define S6_PATH_MAX 512 typedef enum trans_e trans_t, *trans_t_ref ; enum trans_e @@ -58,8 +55,8 @@ typedef void action_t (void) ; typedef action_t *action_t_ref ; -static tain_t deadline ; -static tain_t dontrespawnbefore = TAIN_EPOCH ; +static tain deadline ; +static tain dontrespawnbefore = TAIN_EPOCH ; static s6_svstatus_t status = S6_SVSTATUS_ZERO ; static state_t state = DOWN ; static int flagdying = 0 ; @@ -238,51 +235,107 @@ { int p[2] ; int notifyp[2] = { -1, -1 } ; - unsigned int fd ; + int lfd = -1 ; + int locked = 1 ; + unsigned int notif, lk ; pid_t pid ; - if (pipecoe(p) < 0) + if (read_uint("lock-fd", &lk)) { - settimeout(60) ; - strerr_warnwu1sys("pipe (waiting 60 seconds)") ; - return ; + if (lk > INT_MAX) strerr_warnw2x("invalid ", "lock-fd") ; + else + { + struct stat st ; + lfd = open_write(SLCK) ; + if (lfd == -1) + { + settimeout(60) ; + strerr_warnwu4sys("open ", SLCK, " for writing", " (waiting 60 seconds)") ; + return ; + } + if (fstat(lfd, &st) == -1) + { + settimeout(60) ; + strerr_warnwu3sys("stat ", SLCK, " (waiting 60 seconds)") ; + goto errl ; + } + if (st.st_size) + { + ftruncate(lfd, 0) ; + strerr_warnw1x("a previous instance of the service wrote to the lock file!") ; + } + locked = fd_lock(lfd, 1, 1) ; + if (locked == -1) + { + settimeout(60) ; + strerr_warnwu3sys("lock ", SLCK, " (waiting 60 seconds)") ; + goto errl ; + } + if (!locked) + strerr_warnw1x("another instance of the service is already running, child will block") ; + } } - if (read_uint("notification-fd", &fd) && pipe(notifyp) < 0) + if (read_uint("notification-fd", ¬if)) + { + if (notif > INT_MAX) strerr_warnw2x("invalid ", "notification-fd") ; + else if (lfd >= 0 && notif == lk) + { + settimeout_infinite() ; + strerr_warnwu1x("start service: notification-fd and lock-fd are the same") ; + goto errl ; + } + else if (pipe(notifyp) < 0) + { + settimeout(60) ; + strerr_warnwu2sys("pipe", " (waiting 60 seconds)") ; + goto errl ; + } + } + if (pipecoe(p) < 0) { settimeout(60) ; - strerr_warnwu1sys("pipe (waiting 60 seconds)") ; - fd_close(p[1]) ; fd_close(p[0]) ; - return ; + strerr_warnwu2sys("pipe", " (waiting 60 seconds)") ; + goto errn ; } pid = fork() ; if (pid < 0) { settimeout(60) ; - strerr_warnwu1sys("fork (waiting 60 seconds)") ; - if (notifyp[1] >= 0) fd_close(notifyp[1]) ; - if (notifyp[0] >= 0) fd_close(notifyp[0]) ; - fd_close(p[1]) ; fd_close(p[0]) ; - return ; + strerr_warnwu2sys("fork", " (waiting 60 seconds)") ; + goto errp ; } else if (!pid) { char const *cargv[2] = { "run", 0 } ; - PROG = "s6-supervise (child)" ; + ((char *)PROG)[strlen(PROG)] = ' ' ; selfpipe_finish() ; - sig_restore(SIGPIPE) ; if (notifyp[0] >= 0) close(notifyp[0]) ; close(p[0]) ; - if (notifyp[1] >= 0 && fd_move((int)fd, notifyp[1]) < 0) + if (notifyp[1] >= 0 && fd_move(notif, notifyp[1]) < 0) { failcoe(p[1]) ; strerr_diefu1sys(127, "move notification descriptor") ; } + if (lfd >= 0) + { + if (fd_move(lk, lfd) < 0) + { + failcoe(p[1]) ; + strerr_diefu1sys(127, "move lock descriptor") ; + } + if (!locked && fd_lock(lk, 1, 0) == -1) + { + failcoe(p[1]) ; + strerr_diefu2sys(127, "lock ", SLCK) ; + } + } setsid() ; execv("./run", (char *const *)cargv) ; failcoe(p[1]) ; strerr_dieexec(127, "run") ; } - if (notifyp[1] >= 0) fd_close(notifyp[1]) ; fd_close(p[1]) ; + if (notifyp[1] >= 0) fd_close(notifyp[1]) ; + if (lfd >= 0) fd_close(lfd) ; { char c ; switch (fd_read(p[0], &c, 1)) @@ -312,6 +365,19 @@ tain_addsec_g(&dontrespawnbefore, 1) ; announce() ; ftrigw_notifyb_nosig(S6_SUPERVISE_EVENTDIR, "u", 1) ; + return ; + + errp: + fd_close(p[1]) ; + fd_close(p[0]) ; + errn: + if (notifyp[1] >= 0) + { + fd_close(notifyp[1]) ; + fd_close(notifyp[0]) ; + } + errl: + if (lfd >= 0) fd_close(lfd) ; } static void downtimeout (void) @@ -350,7 +416,6 @@ status.wstat = (int)status.pid ; status.flagpaused = 0 ; status.flagready = 0 ; - status.flagthrottled = 0 ; flagdying = 0 ; tain_wallclock_read(&status.stamp) ; if (notifyfd >= 0) @@ -392,7 +457,6 @@ char fmt1[UINT_FMT] ; char *cargv[4] = { "finish", fmt0, fmt1, 0 } ; selfpipe_finish() ; - sig_restore(SIGPIPE) ; fmt0[uint_fmt(fmt0, WIFSIGNALED(status.wstat) ? 256 : WEXITSTATUS(status.wstat))] = 0 ; fmt1[uint_fmt(fmt1, WTERMSIG(status.wstat))] = 0 ; setsid() ; @@ -403,7 +467,7 @@ announce() ; ftrigw_notifyb_nosig(S6_SUPERVISE_EVENTDIR, "d", 1) ; { - tain_t tto ; + tain tto ; unsigned int timeout ; if (!read_uint("timeout-finish", &timeout)) timeout = 5000 ; if (timeout && tain_from_millisecs(&tto, timeout)) @@ -446,7 +510,7 @@ static void up_d (void) { - tain_t tto ; + tain tto ; unsigned int timeout ; status.flagwantup = 0 ; killr() ; @@ -541,11 +605,11 @@ static inline void handle_notifyfd (void) { - char buf[4096] ; + char buf[512] ; ssize_t r = 1 ; while (r > 0) { - r = sanitize_read(fd_read(notifyfd, buf, 4096)) ; + r = sanitize_read(fd_read(notifyfd, buf, 512)) ; if (r > 0 && memchr(buf, '\n', r)) { tain_wallclock_read(&status.readystamp) ; @@ -704,16 +768,17 @@ { size_t proglen = strlen(PROG) ; size_t namelen = strlen(argv[1]) ; - char progname[proglen + namelen + 2] ; + char progname[proglen + namelen + 10] ; memcpy(progname, PROG, proglen) ; progname[proglen] = ' ' ; memcpy(progname + proglen + 1, argv[1], namelen + 1) ; + memcpy(progname + proglen + 2 + namelen, "(child)", 8) ; PROG = progname ; if (!fd_sanitize()) strerr_diefu1sys(111, "sanitize stdin and stdout") ; x[1].fd = control_init() ; x[0].fd = selfpipe_init() ; if (x[0].fd == -1) strerr_diefu1sys(111, "init selfpipe") ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; + if (!sig_altignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; { sigset_t set ; sigemptyset(&set) ; @@ -722,7 +787,7 @@ sigaddset(&set, SIGHUP) ; sigaddset(&set, SIGQUIT) ; sigaddset(&set, SIGINT) ; - if (selfpipe_trapset(&set) < 0) strerr_diefu1sys(111, "trap signals") ; + if (!selfpipe_trapset(&set)) strerr_diefu1sys(111, "trap signals") ; } if (!ftrigw_clean(S6_SUPERVISE_EVENTDIR)) diff -Nru s6-2.10.0.2/src/supervision/s6-svc.c s6-2.11.0.0/src/supervision/s6-svc.c --- s6-2.10.0.2/src/supervision/s6-svc.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-svc.c 2021-09-26 14:04:15.000000000 +0000 @@ -10,7 +10,7 @@ #include #include -#include +#include #define USAGE "s6-svc [ -wu | -wU | -wd | -wD | -wr | -wR ] [ -T timeout ] [ -abqhkti12pcyroduxOX ] servicedir" #define dieusage() strerr_dieusage(100, USAGE) @@ -25,7 +25,7 @@ char updown[3] = "-\0" ; PROG = "s6-svc" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "abqhkti12pcyroduxOT:w:", &l) ; diff -Nru s6-2.10.0.2/src/supervision/s6-svdt.c s6-2.11.0.0/src/supervision/s6-svdt.c --- s6-2.10.0.2/src/supervision/s6-svdt.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-svdt.c 2021-09-26 14:04:15.000000000 +0000 @@ -6,7 +6,7 @@ #include #include #include -#include +#include #define USAGE "s6-svdt [ -S | -s ] [ -n maxentries ] servicedir" #define dieusage() strerr_dieusage(100, USAGE) @@ -18,7 +18,7 @@ int num = 0 ; PROG = "s6-svdt" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "Ssn:", &l) ; diff -Nru s6-2.10.0.2/src/supervision/s6-svdt-clear.c s6-2.11.0.0/src/supervision/s6-svdt-clear.c --- s6-2.10.0.2/src/supervision/s6-svdt-clear.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-svdt-clear.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,7 +1,7 @@ /* ISC license. */ #include -#include +#include #define USAGE "s6-svdt-clear servicedir" #define dieusage() strerr_dieusage(100, USAGE) diff -Nru s6-2.10.0.2/src/supervision/s6-svlink.c s6-2.11.0.0/src/supervision/s6-svlink.c --- s6-2.10.0.2/src/supervision/s6-svlink.c 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-svlink.c 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,118 @@ +/* ISC license. */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#define USAGE "s6-svlink [ -d | -D ] [ -f ] [ -P ] [ -t timeout ] scandir servicedir [ name ]" +#define dieusage() strerr_dieusage(100, USAGE) + +static inline void checkscandir (char const *s) +{ + int r ; + int fd ; + size_t len = strlen(s) ; + char fn[len + 6 + sizeof(S6_SVSCAN_CTLDIR)] ; + memcpy(fn, s, len) ; + memcpy(fn + len, "/" S6_SVSCAN_CTLDIR "/lock", 6 + sizeof(S6_SVSCAN_CTLDIR)) ; + fd = open_read(fn) ; + if (fd < 0) strerr_diefu2sys(111, "open ", fn) ; + r = fd_islocked(fd) ; + if (r < 0) strerr_diefu2sys(111, "check lock on ", fn) ; + if (!r) strerr_dief2x(1, "s6-svscan not running on ", s) ; + fd_close(fd) ; +} + +static inline void checkservicedir (char const *s) +{ + int r ; + struct stat st ; + size_t len = strlen(s) ; + char fn[len + 9] ; + memcpy(fn, s, len) ; + memcpy(fn + len, "/run", 5) ; + if (stat(fn, &st) == -1) strerr_diefu2sys(111, "stat ", fn) ; + if (!(st.st_mode & S_IXUSR)) strerr_dief2x(100, fn, " is not executable") ; + r = s6_svc_ok(s) ; + if (r < 0) strerr_diefu2sys(111, "check supervision status of ", s) ; + if (r) strerr_warnw2x("supervisor already running on ", s) ; + memcpy(fn + len + 1, "log", 4) ; + if (stat(fn, &st) == -1) + { + if (errno != ENOENT) strerr_diefu2sys(111, "stat ", fn) ; + } + else + { + if (!S_ISDIR(st.st_mode)) strerr_dief2x(100, fn, " is not a directory") ; + memcpy(fn + len + 4, "/run", 5) ; + if (stat(fn, &st) == -1) strerr_diefu2sys(111, "stat ", fn) ; + if (!(st.st_mode & S_IXUSR)) strerr_dief2x(100, fn, " is not executable") ; + fn[len + 4] = 0 ; + r = s6_svc_ok(fn) ; + if (r < 0) strerr_diefu2sys(111, "check supervision status of ", fn) ; + if (r) strerr_warnw2x("supervisor already running on ", fn) ; + } +} + +int main (int argc, char const *const *argv) +{ + tain tto = TAIN_INFINITE_RELATIVE ; + uint32_t options = 0 ; + char const *name ; + PROG = "s6-svlink" ; + { + unsigned int t = 0 ; + subgetopt l = SUBGETOPT_ZERO ; + for (;;) + { + int opt = subgetopt_r(argc, argv, "dDfPt:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case 'd' : options |= 12 ; break ; + case 'D' : options |= 4 ; options &= ~8U ; break ; + case 'f' : options |= 1 ; break ; + case 'P' : options |= 2 ; break ; + case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; + default : dieusage() ; + } + } + argc -= l.ind ; argv += l.ind ; + if (t) tain_from_millisecs(&tto, t) ; + } + if (argc < 2) dieusage() ; + + if (argv[2]) name = argv[2] ; + else + { + stralloc sa = STRALLOC_ZERO ; + if (!stralloc_cats(&sa, argv[1]) || !stralloc_0(&sa)) + strerr_diefu1sys(111, "stralloc_cats") ; + name = basename(sa.s) ; + } + if (!argv[0][0]) strerr_dief1x(100, "invalid scandir") ; + if (!argv[1][0]) strerr_dief1x(100, "invalid servicedir") ; + if (!name[0] || name[0] == '.' || name[0] == '/') + strerr_dief1x(100, "invalid name") ; + checkscandir(argv[0]) ; + checkservicedir(argv[1]) ; + + tain_now_set_stopwatch_g() ; + tain_add_g(&tto, &tto) ; + + if (s6_supervise_link_names_g(argv[0], argv + 1, &name, 1, options, &tto) == -1) + strerr_diefu6sys(errno == ETIMEDOUT ? 99 : 111, "link servicedir ", argv[1], " into scandir ", argv[0], " with name ", name) ; + return 0 ; +} diff -Nru s6-2.10.0.2/src/supervision/s6-svlisten1.c s6-2.11.0.0/src/supervision/s6-svlisten1.c --- s6-2.10.0.2/src/supervision/s6-svlisten1.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-svlisten1.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,11 +1,9 @@ /* ISC license. */ #include -#include #include #include -#include #include #include #include @@ -18,7 +16,7 @@ int main (int argc, char const *const *argv, char const *const *envp) { s6_svlisten_t foo = S6_SVLISTEN_ZERO ; - tain_t deadline, tto ; + tain deadline, tto ; pid_t pid ; int spfd ; int e ; @@ -27,7 +25,7 @@ unsigned char upstate, readystate ; PROG = "s6-svlisten1" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; unsigned int t = 0 ; for (;;) { @@ -53,10 +51,8 @@ tain_add_g(&deadline, &tto) ; spfd = s6_svlisten_selfpipe_init() ; s6_svlisten_init(1, argv, &foo, &id, &upstate, &readystate, &deadline) ; - sig_restore(SIGPIPE) ; pid = child_spawn0(argv[1], argv + 1, envp) ; if (!pid) strerr_diefu2sys(111, "spawn ", argv[1]) ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; if (wantrestart) s6_svlisten_loop(&foo, 0, 1, 1, &deadline, spfd, &s6_svlisten_signal_handler) ; e = s6_svlisten_loop(&foo, wantup, wantready, 1, &deadline, spfd, &s6_svlisten_signal_handler) ; if (e < 0) strerr_dief1x(102, "supervisor died") ; diff -Nru s6-2.10.0.2/src/supervision/s6-svlisten.c s6-2.11.0.0/src/supervision/s6-svlisten.c --- s6-2.10.0.2/src/supervision/s6-svlisten.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-svlisten.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,12 +1,10 @@ /* ISC license. */ #include -#include #include #include #include -#include #include #include #include @@ -19,14 +17,14 @@ int main (int argc, char const **argv, char const *const *envp) { - tain_t deadline, tto ; + tain deadline, tto ; int spfd ; int argc1 ; int or = 0 ; int wantup = 1, wantready = 0, wantrestart = 0 ; PROG = "s6-svlisten" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; unsigned int t = 0 ; for (;;) { @@ -71,10 +69,8 @@ unsigned char upstate[bitarray_div8(argc1)] ; unsigned char readystate[bitarray_div8(argc1)] ; s6_svlisten_init(argc1, argv, &foo, ids, upstate, readystate, &deadline) ; - sig_restore(SIGPIPE) ; pid = child_spawn0(argv[argc1 + 1], argv + argc1 + 1, envp) ; if (!pid) strerr_diefu2sys(111, "spawn ", argv[argc1 + 1]) ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; if (wantrestart) s6_svlisten_loop(&foo, 0, 1, or, &deadline, spfd, &s6_svlisten_signal_handler) ; e = s6_svlisten_loop(&foo, wantup, wantready, or, &deadline, spfd, &s6_svlisten_signal_handler) ; if (e < 0) strerr_dief1x(102, "supervisor died") ; diff -Nru s6-2.10.0.2/src/supervision/s6-svlisten.h s6-2.11.0.0/src/supervision/s6-svlisten.h --- s6-2.10.0.2/src/supervision/s6-svlisten.h 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-svlisten.h 2021-09-26 14:04:15.000000000 +0000 @@ -7,8 +7,8 @@ #include #include -typedef void action_func_t (void) ; -typedef action_func_t *action_func_t_ref ; +typedef void action_func (void) ; +typedef action_func *action_func_ref ; typedef struct s6_svlisten_s s6_svlisten_t, *s6_svlisten_t_ref ; struct s6_svlisten_s @@ -23,7 +23,7 @@ extern void s6_svlisten_signal_handler (void) ; extern int s6_svlisten_selfpipe_init (void) ; -extern void s6_svlisten_init (int, char const *const *, s6_svlisten_t *, uint16_t *, unsigned char *, unsigned char *, tain_t const *) ; -extern int s6_svlisten_loop (s6_svlisten_t *, int, int, int, tain_t const *, int, action_func_t_ref) ; +extern void s6_svlisten_init (int, char const *const *, s6_svlisten_t *, uint16_t *, unsigned char *, unsigned char *, tain const *) ; +extern int s6_svlisten_loop (s6_svlisten_t *, int, int, int, tain const *, int, action_func_ref) ; #endif diff -Nru s6-2.10.0.2/src/supervision/s6_svlisten_loop.c s6-2.11.0.0/src/supervision/s6_svlisten_loop.c --- s6-2.10.0.2/src/supervision/s6_svlisten_loop.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6_svlisten_loop.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,18 +1,23 @@ /* ISC license. */ #include +#include + #include #include #include #include #include #include + +#include #include -#include +#include #include "s6-svlisten.h" -void s6_svlisten_init (int argc, char const *const *argv, s6_svlisten_t *foo, uint16_t *ids, unsigned char *upstate, unsigned char *readystate, tain_t const *deadline) +void s6_svlisten_init (int argc, char const *const *argv, s6_svlisten_t *foo, uint16_t *ids, unsigned char *upstate, unsigned char *readystate, tain const *deadline) { + gid_t gid = getegid() ; unsigned int i = 0 ; foo->n = (unsigned int)argc ; foo->ids = ids ; @@ -27,6 +32,7 @@ memcpy(s, argv[i], len) ; s[len] = '/' ; memcpy(s + len + 1, S6_SUPERVISE_EVENTDIR, sizeof(S6_SUPERVISE_EVENTDIR)) ; + ftrigw_fifodir_make(s, gid, 0) ; foo->ids[i] = ftrigr_subscribe_g(&foo->a, s, "[DuUdOx]", FTRIGR_REPEAT, deadline) ; if (!foo->ids[i]) strerr_diefu2sys(111, "subscribe to events for ", argv[i]) ; if (!s6_svstatus_read(argv[i], &status)) strerr_diefu1sys(111, "s6_svstatus_read") ; @@ -45,7 +51,7 @@ return (bitarray_first(t, foo->n, or) < foo->n) == or ; } -int s6_svlisten_loop (s6_svlisten_t *foo, int wantup, int wantready, int or, tain_t const *deadline, int spfd, action_func_t_ref handler) +int s6_svlisten_loop (s6_svlisten_t *foo, int wantup, int wantready, int or, tain const *deadline, int spfd, action_func_ref handler) { iopause_fd x[2] = { { .fd = ftrigr_fd(&foo->a), .events = IOPAUSE_READ }, { .fd = spfd, .events = IOPAUSE_READ, .revents = 0 } } ; unsigned int e = 0 ; diff -Nru s6-2.10.0.2/src/supervision/s6_svlisten_signal_handler.c s6-2.11.0.0/src/supervision/s6_svlisten_signal_handler.c --- s6-2.10.0.2/src/supervision/s6_svlisten_signal_handler.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6_svlisten_signal_handler.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,18 +1,20 @@ /* ISC license. */ #include + #include #include #include #include + #include "s6-svlisten.h" int s6_svlisten_selfpipe_init (void) { int spfd = selfpipe_init() ; if (spfd < 0) strerr_diefu1sys(111, "selfpipe_init") ; - if (selfpipe_trap(SIGCHLD) < 0) strerr_diefu1sys(111, "selfpipe_trap") ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; + if (!selfpipe_trap(SIGCHLD)) strerr_diefu1sys(111, "selfpipe_trap") ; + if (!sig_altignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; return spfd ; } @@ -26,4 +28,3 @@ default : strerr_dief1x(101, "unexpected data in selfpipe") ; } } - diff -Nru s6-2.10.0.2/src/supervision/s6-svok.c s6-2.11.0.0/src/supervision/s6-svok.c --- s6-2.10.0.2/src/supervision/s6-svok.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-svok.c 2021-09-26 14:04:15.000000000 +0000 @@ -1,7 +1,7 @@ /* ISC license. */ #include -#include +#include #define USAGE "s6-svok servicedir" diff -Nru s6-2.10.0.2/src/supervision/s6-svperms.c s6-2.11.0.0/src/supervision/s6-svperms.c --- s6-2.10.0.2/src/supervision/s6-svperms.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-svperms.c 2021-09-26 14:04:15.000000000 +0000 @@ -12,7 +12,7 @@ #include #include -#include +#include #define USAGE "s6-svperms [ -v ] [ -u | -g group | -G group | -o | -O group ] [ -e | -E group ] servicedir..." #define dieusage() strerr_dieusage(100, USAGE) @@ -237,7 +237,7 @@ unsigned int what = 0 ; PROG = "s6-svperms" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "vug:G:oO:eE:", &l) ; diff -Nru s6-2.10.0.2/src/supervision/s6-svscan.c s6-2.11.0.0/src/supervision/s6-svscan.c --- s6-2.10.0.2/src/supervision/s6-svscan.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-svscan.c 2021-09-26 14:04:15.000000000 +0000 @@ -22,7 +22,7 @@ #include #include -#include +#include #define USAGE "s6-svscan [ -c maxservices ] [ -t timeout ] [ -d notif ] [ -X consoleholder ] [ dir ]" #define dieusage() strerr_dieusage(100, USAGE) @@ -42,7 +42,7 @@ { dev_t dev ; ino_t ino ; - tain_t restartafter[2] ; + tain restartafter[2] ; pid_t pid[2] ; int p[2] ; unsigned int flagactive : 1 ; @@ -52,7 +52,7 @@ static struct svinfo_s *services ; static unsigned int max = 500 ; static unsigned int n = 0 ; -static tain_t deadline, defaulttimeout ; +static tain deadline, defaulttimeout ; static int wantreap = 1 ; static int wantscan = 1 ; static unsigned int wantkill = 0 ; @@ -239,7 +239,7 @@ static void reap (void) { - tain_t nextscan ; + tain nextscan ; if (!wantreap) return ; wantreap = 0 ; tain_addsec_g(&nextscan, 1) ; @@ -342,7 +342,7 @@ static void retrydirlater (void) { - tain_t a ; + tain a ; tain_addsec_g(&a, DIR_RETRY_TIMEOUT) ; if (tain_less(&a, &deadline)) deadline = a ; } @@ -532,7 +532,7 @@ int notif = -1 ; PROG = "s6-svscan" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; unsigned int t = 0 ; for (;;) { @@ -570,7 +570,7 @@ x[0].fd = selfpipe_init() ; if (x[0].fd < 0) strerr_diefu1sys(111, "selfpipe_init") ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; + if (!sig_altignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; { sigset_t set ; sigemptyset(&set) ; @@ -589,7 +589,7 @@ #ifdef SIGWINCH sigaddset(&set, SIGWINCH) ; #endif - if (selfpipe_trapset(&set) < 0) strerr_diefu1sys(111, "trap signals") ; + if (!selfpipe_trapset(&set)) strerr_diefu1sys(111, "trap signals") ; } if (notif >= 0) { diff -Nru s6-2.10.0.2/src/supervision/s6-svscanctl.c s6-2.11.0.0/src/supervision/s6-svscanctl.c --- s6-2.10.0.2/src/supervision/s6-svscanctl.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-svscanctl.c 2021-09-26 14:04:15.000000000 +0000 @@ -2,7 +2,7 @@ #include #include -#include +#include #define USAGE "s6-svscanctl [ -zabhitqnN ] svscandir" #define dieusage() strerr_dieusage(100, USAGE) @@ -15,7 +15,7 @@ unsigned int datalen = 0 ; PROG = "s6-svscanctl" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "phratszbnNiq0678", &l) ; diff -Nru s6-2.10.0.2/src/supervision/s6-svstat.c s6-2.11.0.0/src/supervision/s6-svstat.c --- s6-2.10.0.2/src/supervision/s6-svstat.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-svstat.c 2021-09-26 14:04:15.000000000 +0000 @@ -13,7 +13,7 @@ #include #include #include -#include +#include #define USAGE "s6-svstat [ -uwNrpest | -o up,wantedup,normallyup,ready,paused,pid,exitcode,signal,signum,updownsince,readysince,updownfor,readyfor ] [ -n ] servicedir" #define dieusage() strerr_dieusage(100, USAGE) @@ -23,19 +23,19 @@ static int normallyup ; -typedef void prfunc_t (buffer *, s6_svstatus_t const *) ; -typedef prfunc_t * prfunc_t_ref ; +typedef void pr_func (buffer *, s6_svstatus_t const *) ; +typedef pr_func * pr_func_ref ; typedef struct funcmap_s funcmap_t ; struct funcmap_s { char const *s ; - prfunc_t_ref f ; + pr_func_ref f ; } ; static void pr_up (buffer *b, s6_svstatus_t const *st) { - buffer_putsnoflush(b, st->pid && !st->flagfinishing ? st->flagthrottled ? "throttled" : "true" : "false") ; + buffer_putsnoflush(b, st->pid && !st->flagfinishing ? "true" : "false") ; } static void pr_wantedup (buffer *b, s6_svstatus_t const *st) @@ -63,7 +63,7 @@ else buffer_putsnoflush(b, "-1") ; } -static void pr_tain (buffer *b, tain_t const *a) +static void pr_tain (buffer *b, tain const *a) { char fmt[TIMESTAMP] ; buffer_putnoflush(b, fmt, timestamp_fmt(fmt, a)) ; @@ -79,9 +79,9 @@ pr_tain(b, &st->readystamp) ; } -static void pr_seconds (buffer *b, tain_t const *a) +static void pr_seconds (buffer *b, tain const *a) { - tain_t d ; + tain d ; char fmt[UINT64_FMT] ; tain_sub(&d, &STAMP, a) ; buffer_putnoflush(b, fmt, uint64_fmt(fmt, tai_sec(tain_secp(&d)))) ; @@ -150,7 +150,7 @@ } ; -static unsigned int parse_options (char const *arg, prfunc_t_ref *fields, unsigned int n) +static unsigned int parse_options (char const *arg, pr_func_ref *fields, unsigned int n) { while (*arg) { @@ -210,8 +210,6 @@ buffer_putnoflush(buffer_1small, fmt, uint64_fmt(fmt, status.stamp.sec.x)) ; buffer_putnoflush(buffer_1small, " seconds", 8) ; - if (isup && status.flagthrottled) - buffer_putnoflush(buffer_1small, ", throttled", 11) ; if (isup && !normallyup) buffer_putnoflush(buffer_1small, ", normally down", 15) ; if (!isup && normallyup) @@ -236,12 +234,12 @@ { s6_svstatus_t status ; int flagnum = 0 ; - prfunc_t_ref fields[MAXFIELDS] ; + pr_func_ref fields[MAXFIELDS] ; unsigned int n = 0 ; PROG = "s6-svstat" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, argv, "no:uwNrpest", &l) ; diff -Nru s6-2.10.0.2/src/supervision/s6-svunlink.c s6-2.11.0.0/src/supervision/s6-svunlink.c --- s6-2.10.0.2/src/supervision/s6-svunlink.c 1970-01-01 00:00:00.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-svunlink.c 2021-09-26 14:04:15.000000000 +0000 @@ -0,0 +1,49 @@ +/* ISC license. */ + +#include + +#include +#include +#include +#include +#include + +#include + +#define USAGE "s6-svunlink [ -X ] [ -t timeout ] scandir servicename" +#define dieusage() strerr_dieusage(100, USAGE) + +int main (int argc, char const *const *argv) +{ + tain tto = TAIN_INFINITE_RELATIVE ; + uint32_t options = 1 ; + PROG = "s6-svunlink" ; + { + unsigned int t = 0 ; + subgetopt l = SUBGETOPT_ZERO ; + for (;;) + { + int opt = subgetopt_r(argc, argv, "Xt:", &l) ; + if (opt == -1) break ; + switch (opt) + { + case 'X' : options &= ~1U ; break ; + case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; + default : dieusage() ; + } + } + argc -= l.ind ; argv += l.ind ; + if (t) tain_from_millisecs(&tto, t) ; + } + if (argc < 2) dieusage() ; + + if (!argv[1][0] || argv[1][0] == '.' || argv[1][0] == '/') + strerr_dief1x(100, "invalid service name") ; + + tain_now_set_stopwatch_g() ; + tain_add_g(&tto, &tto) ; + + if (s6_supervise_unlink_names_g(argv[0], argv + 1, 1, options, &tto) == -1) + strerr_diefu4sys(111, "prepare unlinking of service ", argv[1], " in scandir ", argv[0]) ; + return 0 ; +} diff -Nru s6-2.10.0.2/src/supervision/s6-svwait.c s6-2.11.0.0/src/supervision/s6-svwait.c --- s6-2.10.0.2/src/supervision/s6-svwait.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/supervision/s6-svwait.c 2021-09-26 14:04:15.000000000 +0000 @@ -12,21 +12,21 @@ #include "s6-svlisten.h" -#define USAGE "s6-svwait [ -U | -u | -d | -D ] [ -a | -o ] [ -t timeout ] servicedir..." +#define USAGE "s6-svwait [ -U | -u | -d | -D | -r | -R ] [ -a | -o ] [ -t timeout ] servicedir..." #define dieusage() strerr_dieusage(100, USAGE) int main (int argc, char const *const *argv) { - tain_t deadline, tto ; + tain deadline ; int or = 0 ; int wantup = 1, wantready = 0 ; PROG = "s6-svwait" ; { - subgetopt_t l = SUBGETOPT_ZERO ; unsigned int t = 0 ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { - int opt = subgetopt_r(argc, argv, "UudDaot:", &l) ; + int opt = subgetopt_r(argc, argv, "UudDrRaot:", &l) ; if (opt == -1) break ; switch (opt) { @@ -34,6 +34,8 @@ case 'u' : wantup = 1 ; wantready = 0 ; break ; case 'd' : wantup = 0 ; wantready = 0 ; break ; case 'D' : wantup = 0 ; wantready = 1 ; break ; + case 'r' : wantup = 2 ; wantready = 0 ; break ; + case 'R' : wantup = 2 ; wantready = 1 ; break ; case 'a' : or = 0 ; break ; case 'o' : or = 1 ; break ; case 't' : if (!uint0_scan(l.arg, &t)) dieusage() ; break ; @@ -41,12 +43,11 @@ } } argc -= l.ind ; argv += l.ind ; - if (t) tain_from_millisecs(&tto, t) ; else tto = tain_infinite_relative ; + if (t) tain_from_millisecs(&deadline, t) ; else deadline = tain_infinite_relative ; } if (!argc) dieusage() ; - tain_now_set_stopwatch_g() ; - tain_add_g(&deadline, &tto) ; + tain_add_g(&deadline, &deadline) ; { s6_svlisten_t foo = S6_SVLISTEN_ZERO ; @@ -54,8 +55,15 @@ uint16_t ids[argc] ; unsigned char upstate[bitarray_div8(argc)] ; unsigned char readystate[bitarray_div8(argc)] ; - if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ; + if (!sig_ignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; s6_svlisten_init(argc, argv, &foo, ids, upstate, readystate, &deadline) ; + if (wantup == 2) + { + wantup = 1 ; + e = s6_svlisten_loop(&foo, 0, 0, 0, &deadline, -1, 0) ; + if (e < 0) strerr_dief1x(102, "supervisor died") ; + else if (e > 0) strerr_dief1x(e, "some services reported permanent failure") ; + } e = s6_svlisten_loop(&foo, wantup, wantready, or, &deadline, -1, 0) ; if (e < 0) strerr_dief1x(102, "supervisor died") ; else if (e > 0) strerr_dief1x(e, "some services reported permanent failure") ; diff -Nru s6-2.10.0.2/src/usertree/s6-usertree-maker.c s6-2.11.0.0/src/usertree/s6-usertree-maker.c --- s6-2.10.0.2/src/usertree/s6-usertree-maker.c 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/src/usertree/s6-usertree-maker.c 2021-09-26 14:04:15.000000000 +0000 @@ -224,10 +224,11 @@ uint64_t maxsize = 0 ; size_t dirlen ; size_t varlen = 0 ; + mode_t m ; char const *vars[VARS_MAX] ; PROG = "s6-usertree-maker" ; { - subgetopt_t l = SUBGETOPT_ZERO ; + subgetopt l = SUBGETOPT_ZERO ; for (;;) { int opt = subgetopt_r(argc, (char const *const *)argv, "d:p:E:e:r:l:t:n:s:S:", &l) ; @@ -278,8 +279,8 @@ if (strchr(rcinfo[2], '/')) strerr_dief2x(100, "slashes", " are forbidden in s6-rc names") ; } } - mask = umask(0) ; - mask = ~mask & 0666 ; + m = umask(0) ; + mask = ~m & 0666 ; dirlen = strlen(argv[2]) ; if (rcinfo[0]) @@ -295,7 +296,7 @@ if (mkdir(dir, 0755) < 0) strerr_diefu2sys(111, "mkdir ", dir) ; memcpy(dir + dirlen + 1, rcinfo[1], loglen + 1) ; if (mkdir(dir, 0755) < 0) strerr_diefu2sys(111, "mkdir ", dir) ; - umask(mask) ; + umask(m) ; write_logger(dir, loguser, argv[1], stamptype, nfiles, filesize, maxsize, rcinfo[0], rcinfo[2]) ; memcpy(dir + dirlen + 1, rcinfo[0], svclen + 1) ; write_service(dir, argv[0], userscandir, rcinfo[1], path, userenvdir, vars, varlen) ; @@ -307,7 +308,7 @@ memcpy(dir + dirlen, "/log", 5) ; if (mkdir(argv[2], 0755) < 0) strerr_diefu2sys(111, "mkdir ", argv[2]) ; if (mkdir(dir, 0755) < 0) strerr_diefu2sys(111, "mkdir ", argv[2]) ; - umask(mask) ; + umask(m) ; write_service(argv[2], argv[0], userscandir, 0, path, userenvdir, vars, varlen) ; write_logger(dir, loguser, argv[1], stamptype, nfiles, filesize, maxsize, 0, 0) ; } diff -Nru s6-2.10.0.2/tools/gen-deps.sh s6-2.11.0.0/tools/gen-deps.sh --- s6-2.10.0.2/tools/gen-deps.sh 2021-02-15 19:31:26.000000000 +0000 +++ s6-2.11.0.0/tools/gen-deps.sh 2021-09-26 14:04:15.000000000 +0000 @@ -7,6 +7,8 @@ echo '#' echo +internal_libs= + for dir in src/include/${package} src/* ; do for file in $(ls -1 $dir | grep -- \\.h$) ; do { @@ -70,8 +72,12 @@ echo else echo "lib${file}.a.xyzzy:$(echo "$deps" | sed 's/\.o/.lo/g')" echo endif - echo "lib${file}.so.xyzzy: EXTRA_LIBS :=$libs" - echo "lib${file}.so.xyzzy:$(echo "$deps" | sed 's/\.o/.lo/g')" + if grep -F "LIB_DEFS :=" package/targets.mak | grep -qF "$file" ; then + echo "lib${file}.so.xyzzy: EXTRA_LIBS :=$libs" + echo "lib${file}.so.xyzzy:$(echo "$deps" | sed 's/\.o/.lo/g')" + else + internal_libs="$internal_libs lib${file}.a.xyzzy" + fi done for file in $(ls -1 src/$dir/deps-exe) ; do @@ -91,3 +97,4 @@ echo "$file: src/$dir/$file.o$deps" done done +echo "INTERNAL_LIBS :=$internal_libs"