diff options
31 files changed, 87 insertions, 1097 deletions
@@ -1,13 +1,13 @@ Changelog for s6. -In 2.11.4.0 +In 2.12.0.0 ----------- - New option to s6-svc: -s, to specify a signal by name (or number). - New option to s6-log: -t, to specify a timeout for partial last lines. - s6-svscan rewrite: no more quadratic reaps, no more forced 1s wait on shutdown - Eliminated fork() wherever possible on systems supporting posix_spawn() - - New s6_ucspiserver_spawn() library function + - Obsolete s6lockd subsystem removed. In 2.11.3.2 diff --git a/doc/index.html b/doc/index.html index 4753a6b..9fdd34c 100644 --- a/doc/index.html +++ b/doc/index.html @@ -115,7 +115,7 @@ want nsswitch-like functionality: <h3> Download </h3> <ul> - <li> The current released version of s6 is <a href="s6-2.11.4.0.tar.gz">2.11.4.0</a>. </li> + <li> The current released version of s6 is <a href="s6-2.12.0.0.tar.gz">2.12.0.0</a>. </li> <li> Alternatively, you can checkout a copy of the <a href="//git.skarnet.org/cgi-bin/cgit.cgi/s6/">s6 git repository</a>: @@ -283,14 +283,6 @@ synchronization</a>. <li><a href="s6-instance-list.html">The <tt>s6-instance-list</tt> program</a></li> </ul> -<h4> Timed lock acquisition </h4> - -<ul> -<li><a href="s6-setlock.html">The <tt>s6-setlock</tt> program</a></li> -<li><a href="libs6/s6lockd.html">The <tt>s6lockd</tt> program</a></li> -<li><a href="libs6/s6lockd-helper.html">The <tt>s6lockd-helper</tt> internal program</a></li> -</ul> - <h4> fd-holding, a.k.a. the sensible part of socket activation </h4> <ul> diff --git a/doc/libs6/index.html b/doc/libs6/index.html index 1db2e5e..c934110 100644 --- a/doc/libs6/index.html +++ b/doc/libs6/index.html @@ -65,8 +65,6 @@ provides functions to check credentials against configuration files. </li> functions to subscribe to fifodirs and be notified of events. </li> <li> The <a href="ftrigw.html">s6/ftrigw.h</a> header provides functions to manage fifodirs and send notifications to them. </li> - <li> The <a href="lock.html">s6/lock.h</a> header provides -functions to acquire locks with a timeout. </li> <li> The <a href="fdholder.html">s6/fdholder.h</a> header provides functions to communicate with a <a href="../s6-fdholderd.html">s6-fdholderd</a> server and exchange diff --git a/doc/libs6/lock.html b/doc/libs6/lock.html deleted file mode 100644 index 1cc896d..0000000 --- a/doc/libs6/lock.html +++ /dev/null @@ -1,239 +0,0 @@ -<html> - <head> - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <meta http-equiv="Content-Language" content="en" /> - <title>s6: the s6lock library interface</title> - <meta name="Description" content="s6: the s6lock library interface" /> - <meta name="Keywords" content="s6 timed lock s6lock libs6 library interface" /> - <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> --> - </head> -<body> - -<p> -<a href="index.html">libs6</a><br /> -<a href="../">s6</a><br /> -<a href="//skarnet.org/software/">Software</a><br /> -<a href="//skarnet.org/">skarnet.org</a> -</p> - -<h1> The <tt>s6lock</tt> library interface </h1> - -<h2> General information </h2> - -<p> - <tt>s6lock</tt> 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. -</p> - -<h2> Programming </h2> - -<ul> - <li> Check the <tt>s6/lock.h</tt> 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. </li> - <li> Given the nature of the s6lock library, it makes sense to use a -<a href="../localservice.html">s6lockd service</a> concurrently -accessed by several applications using such locks to gate shared -resources. </li> - <li> 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 -<a href="//skarnet.org/software/skalibs/libstddjb/selfpipe.html">self-pipe</a> -if your application is built around an event loop, are good programming -practices. </li> -</ul> - -<h3> Starting and ending a session </h3> - -<pre> -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) ; -</pre> - -<p> -<tt>s6lock_start_g</tt> starts a session by connecting to an s6lockd service -listening on <em>path</em>. The working directory is set by the administrator -of the service. <br /> -<tt>s6lock_startf_g</tt> starts a session with an s6lockd process as a child, -using <em>lockdir</em> as its working directory. -<br /> -<tt>a</tt> 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. -</p> -<p> -If the absolute time <tt>deadline</tt> 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 <tt>deadline</tt> should be -enough: if the function takes more than that to return, then there is a -problem with the underlying processes. -</p> - -<p> - You can have more than one session open in parallel, by declaring -several distinct <tt>s6lock_t</tt> structures and calling -<tt>s6lock_startf_g</tt> (or <tt>s6lock_start_g</tt>) 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. -</p> - -<pre> -s6lock_end(&a) ; -</pre> - -<p> -<tt>s6lock_end</tt> frees all the resources used by the session. The -<tt>a</tt> structure is then reusable for another session. -</p> - -<h3> Acquiring and releasing locks </h3> - -<pre> -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) ; -</pre> - -<p> -<tt>s6lock_acquire_sh_g</tt> instructs the -<a href="s6lockd.html">s6lockd daemon</a>, related to the open -session represented by the <tt>a</tt> handle, to try and acquire a -shared lock on the -<em>file</em> file located under that daemon's working directory -(typically <tt>/var/lock</tt>). <em>file</em> will be interpreted as -relative to the daemon's working directory even if it starts with a -slash; however, slashes in the middle of <em>file</em> are likely to -result in an error. -</p> - -<p> -<em>limit</em> and <em>deadline</em> are two absolute dates. -<em>deadline</em> is a deadline for the execution of the -function: if by <em>deadline</em> the function has not returned, -then it instantly returns 0 and sets errno to ETIMEDOUT. The -function is normally near-instantaneous, so <em>deadline</em> can -be very close in the future and serves only as a protection against -malicious servers. <em>limit</em> is the acquisition deadline: if -by <em>limit</em> the daemon still has not been able to acquire a lock -on <em>file</em>, then it will report a timeout to the client. -</p> - -<p> -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 *<em>id</em>; this number serves as an identifier -for this lock. -</p> - -<p> -<tt>s6lock_acquire_ex_g</tt> works just like <tt>s6lock_acquire_sh_g</tt>, -except that the daemon tries to acquire an exclusive lock. -</p> - -<p> -<tt>s6lock_release_g</tt> releases the lock identified by <em>id</em>. -It normally returns 1. It can return 0 with errno set to a suitable -value if it fails. <em>id</em> is not valid after the corresponding -lock has been released. The function normally returns instantly, with -<em>deadline</em> as a safeguard. -</p> - -<h3> Asynchronously waiting for locks </h3> - -<p> -<em> (from now on, the functions are listed with their prototypes instead -of usage examples.) </em> -</p> - -<pre> -int s6lock_fd (s6lock_t const *a) -</pre> - -<p> - Returns a file descriptor to select on for reading. Do not -<tt>read()</tt> it though. -</p> - -<pre> -int s6lock_update (s6lock_t *a) -</pre> - -<p> - Call this function whenever the fd checks readability: it will -update <em>a</em>'s internal structures with information from the -<a href="s6lockd.html">s6lockd</a> daemon. It returns -1 if an error -occurs; in case of success, it returns the number of identifiers for -which something happened. -</p> - -<p> - When <tt>s6lock_update</tt> returns, -<tt>genalloc_s(uint16_t, &a->list)</tt> points to an array of -<tt>genalloc_len(uint16_t, &a->list)</tt> 16-bit unsigned -integers. Those integers are ids waiting to be passed to -<tt>s6lock_check</tt>. -</p> - -<pre> -int s6lock_check (s6lock_t *a, uint16_t id, char *what) -</pre> - -<p> - Checks whether the lock identified by <em>id</em> has -been acquired. Use after a call to <tt>s6lock_update()</tt>. -</p> - -<ul> - <li> If an error occurred, returns -1 and sets errno. The error -number may have been transmitted from -<a href="s6lockd.html">s6lockd</a>. </li> - <li> If the lock has not been acquired yet, returns 0. </li> - <li> If the lock has been acquired, returns 1. </li> -</ul> - -<h3> Synchronously waiting for locks </h3> - -<p> -<code> int s6lock_wait_or_g (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain_t const *deadline) </code> <br /> -Synchronously waits for <em>one</em> of the locks represented by the array pointed to -by <em>idlist</em> of length <em>n</em> to be acquired. Returns -1 if it fails, -or a nonnegative number on success, which is the index in <em>idlist</em> of the -acquired lock's id. If no result has been obtained by <em>deadline</em>, the -function returns -1 ETIMEDOUT. -</p> - -<p> -<code> int s6lock_wait_and_g (s6lock_t *a, uint16_t const *idlist, unsigned int n, tain_t const *deadline) </code> <br /> -Synchronously waits for <em>all</em> of the locks represented by the array pointed to -by <em>idlist</em> of length <em>n</em> to be acquired. Returns -1 if it fails and -0 if it succeeds. If no result has been obtained by <em>deadline</em>, the -function returns -1 ETIMEDOUT. -</p> - -</body> -</html> diff --git a/doc/libs6/s6lockd-helper.html b/doc/libs6/s6lockd-helper.html deleted file mode 100644 index bc3d1a5..0000000 --- a/doc/libs6/s6lockd-helper.html +++ /dev/null @@ -1,56 +0,0 @@ -<html> - <head> - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <meta http-equiv="Content-Language" content="en" /> - <title>s6: the s6lockd-helper internal program</title> - <meta name="Description" content="s6: the s6lockd-helper internal program" /> - <meta name="Keywords" content="s6 s6lockd-helper lockd asynchronous timed lock daemon helper" /> - <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> --> - </head> -<body> - -<p> -<a href="index.html">libs6</a><br /> -<a href="../">s6</a><br /> -<a href="//skarnet.org/software/">Software</a><br /> -<a href="//skarnet.org/">skarnet.org</a> -</p> - -<h1> The <tt>s6lockd-helper</tt> program </h1> - -<p> -<tt>s6lockd-helper</tt> is a helper program for the s6lock daemon. -It just acquires a lock and holds it until it is killed or told to -exit by its parent daemon. -</p> - -<h2> Interface </h2> - -<p> - s6lockd-helper is not meant to be invoked directly by the user: -it will be spawned by the -<a href="s6lockd.html">s6lockd</a> program. -</p> - -<h2> Notes </h2> - -<ul> - <li> s6lockd-helper blocks on lock acquisition until it succeeds. It then -notifies its parent. It exits when its parent tells him to (i.e. when the -client asks for lock release). During the lock acquisition phase, it can -be killed if its parent detects a timeout. </li> - <li> One s6lockd-helper process per lock is the only way (apart from -threads) to implement timed lock acquisition. This can lead to a lot of -s6lockd-helper processes, but this is not a problem: - <ul> - <li> Processes are not a scarce resource. Today's schedulers work in O(1), -or in O(a function of the number of runnable processes), which means that a -sleeping process takes no scheduling time at all </li> - <li> s6lockd-helper is extremely tiny. Every instance should use up at -most one or two pages of non-sharable memory. </li> - </ul> </li> -</ul> - -</body> -</html> diff --git a/doc/libs6/s6lockd.html b/doc/libs6/s6lockd.html deleted file mode 100644 index 089de57..0000000 --- a/doc/libs6/s6lockd.html +++ /dev/null @@ -1,75 +0,0 @@ -<html> - <head> - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> - <meta http-equiv="Content-Language" content="en" /> - <title>s6: the s6lockd internal program</title> - <meta name="Description" content="s6: the s6lockd internal program" /> - <meta name="Keywords" content="s6 s6lockd lockd asynchronous timed lock daemon" /> - <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> --> - </head> -<body> - -<p> -<a href="index.html">libs6</a><br /> -<a href="../">s6</a><br /> -<a href="//skarnet.org/software/">Software</a><br /> -<a href="//skarnet.org/">skarnet.org</a> -</p> - -<h1> The <tt>s6lockd</tt> program </h1> - -<p> -<tt>s6lockd</tt> is the s6lock daemon. It is a program that manages -a set of lock files in a given directory, and associated timeouts. -</p> - -<h2> Interface </h2> - -<p> - s6lockd does not fork, does not background itself automatically, -and does not use syslog. It is not meant to be run directly by the -user: it will be spawned by the -<a href="s6lock.html">s6lock client library</a>. -</p> - -<p> - There are 2 ways to use s6lockd: -</p> - -<ol> - <li> Use the <tt>s6lock_startf()</tt> library call. -An <tt>s6lockd</tt> child will then be spawned from your -calling process, and automatically reaped when you call -<tt>s6lock_end()</tt>. It requires care with applications that -trap SIGCHLD. It also requires care with lock file permissions: -an s6lockd instance might not be able -to open a lock file created by a former instance run by another -client with different permissions. </li> - <li> Use the <tt>s6lock_start()</tt> library call, together with a -<a href="../localservice.html">s6lockd service</a>. -For once, <em>this is the recommended setup</em>: s6lockd creates empty -lock files, and having all s6lockd instances run under the same user -simplifies permissions management considerably. </li> -</ol> - -<p> -When run as a service, s6lockd has no "standalone" mode: it is -designed to work with a Unix -domain super-server, like -<a href="../s6-ipcserver.html">s6-ipcserver</a>. -s6lockd follows the <a href="https://cr.yp.to/proto/ucspi.txt">UCSPI</a> -interface, it can be directly executed from the super-server. -</p> - -<h2> Notes </h2> - -<ul> - <li> Unix does not natively provide a way to stop blocking on a lock -acquisition after a timeout. To emulate such behaviour, s6lockd actually -spawns an <a href="s6lockd-helper.html">s6lockd-helper</a> child per -requested lock. </li> -</ul> - -</body> -</html> diff --git a/doc/s6-setlock.html b/doc/s6-setlock.html index c2e8fbf..91e2fcc 100644 --- a/doc/s6-setlock.html +++ b/doc/s6-setlock.html @@ -25,7 +25,7 @@ s6-setlock takes a lock on a file, then executes into another program. <h2> Interface </h2> <pre> - s6-setlock [ -n | -N | -t <em>timeout</em> ] [ -r | -w ] <em>file</em> <em>prog...</em> + s6-setlock [ -n | -N ] [ -t <em>timeout</em> ] [ -d <em>fd</em> ] [ -r | -w ] <em>file</em> <em>prog...</em> </pre> <ul> @@ -46,20 +46,20 @@ the lock after <em>timeout</em> milliseconds, it will exit 1. </li> <li> <tt>-r</tt> : shared lock. Other shared locks on the same file will not prevent the lock from being acquired (but an exclusive lock will). </li> <li> <tt>-w</tt> : exclusive lock. This is the default. </li> + <li> <tt>-d <em>fd</em></tt> : make the lock visible in <em>prog</em> +on file descriptor <em>fd</em>. </li> </ul> <h2> Notes </h2> <ul> - <li> s6-setlock leaks an open file descriptor into the <em>prog</em> + <li> +s6-setlock leaks an open file descriptor into the <em>prog</em> execution. This is intended: the fd holds the lock, which is released when <em>prog</em> exits. <em>prog</em> must not touch fds it does not -know about. </li> - <li> If the timed lock option is chosen, s6-setlock does not acquire the lock -itself. Instead, it spawns a <a href="libs6/s6lockd-helper.html">s6lockd-helper</a> -process that acquires the lock while s6-setlock controls the timeout; the -s6lockd-helper process then holds the lock and lives as long as -<em>prog</em>. </li> +know about; by default it has no need to know the descriptor that holds +the lock. But if you need to officialize the presence of the lock in +<em>prog</em>, that's where the <tt>-d</tt> option comes in. </li> </ul> </body> diff --git a/doc/upgrade.html b/doc/upgrade.html index 2c184a6..f440d90 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -18,7 +18,7 @@ <h1> What has changed in s6 </h1> -<h2> in 2.11.4.0 </h2> +<h2> in 2.12.0.0 </h2> <ul> <li> <a href="//skarnet.org/software/skalibs/">skalibs</a> @@ -31,6 +31,10 @@ recommended dependency bumped to 2.9.4.0. </li> <li> New <tt>-t</tt> option to <a href="s6-log.html">s6-log</a>. </li> <li> <a href="s6-svscan.html">s6-svscan</a> rewrite; new options <tt>-C</tt> and <tt>-L</tt>. </li> + <li> Obsolete <tt>s6lockd</tt> subsystem removed. </li> + <li> <a href="s6-setlock.html">s6-setlock</a> now has a <tt>-d</tt> +option to pin the lock to a fixed descriptor. Timeout management also +simplified. </li> </ul> <h2> in 2.11.3.2 </h2> diff --git a/package/deps.mak b/package/deps.mak index 0948039..a42c027 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -15,7 +15,7 @@ src/conn-tools/s6-ipcclient.o src/conn-tools/s6-ipcclient.lo: src/conn-tools/s6- src/conn-tools/s6-ipcserver-access.o src/conn-tools/s6-ipcserver-access.lo: src/conn-tools/s6-ipcserver-access.c src/include/s6/accessrules.h src/include/s6/config.h src/conn-tools/s6-ipcserver-socketbinder.o src/conn-tools/s6-ipcserver-socketbinder.lo: src/conn-tools/s6-ipcserver-socketbinder.c src/conn-tools/s6-ipcserver.o src/conn-tools/s6-ipcserver.lo: src/conn-tools/s6-ipcserver.c src/include/s6/config.h -src/conn-tools/s6-ipcserverd.o src/conn-tools/s6-ipcserverd.lo: src/conn-tools/s6-ipcserverd.c src/include/s6/ucspiserver.h +src/conn-tools/s6-ipcserverd.o src/conn-tools/s6-ipcserverd.lo: src/conn-tools/s6-ipcserverd.c 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 @@ -25,7 +25,7 @@ src/daemontools-extras/s6-envdir.o src/daemontools-extras/s6-envdir.lo: src/daem 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/include-local/s6lockd.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-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 @@ -119,19 +119,6 @@ src/libs6/s6_svstatus_read.o src/libs6/s6_svstatus_read.lo: src/libs6/s6_svstatu 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/s6_ucspiserver_spawn.o src/libs6/s6_ucspiserver_spawn.lo: src/libs6/s6_ucspiserver_spawn.c src/include/s6/ucspiserver.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 @@ -175,7 +162,7 @@ s6-ipcserver-access: src/conn-tools/s6-ipcserver-access.o ${LIBS6} s6-ipcserver-socketbinder: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} s6-ipcserver-socketbinder: src/conn-tools/s6-ipcserver-socketbinder.o s6-ipcserverd: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} -s6-ipcserverd: src/conn-tools/s6-ipcserverd.o ${LIBS6} +s6-ipcserverd: src/conn-tools/s6-ipcserverd.o s6-sudo: EXTRA_LIBS := -lskarnet s6-sudo: src/conn-tools/s6-sudo.o s6-sudoc: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} ${SYSCLOCK_LIB} @@ -192,8 +179,8 @@ s6-fghack: EXTRA_LIBS := -lskarnet s6-fghack: src/daemontools-extras/s6-fghack.o 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 libs6lockd.a.xyzzy +s6-setlock: EXTRA_LIBS := -lskarnet ${TIMER_LIB} +s6-setlock: src/daemontools-extras/s6-setlock.o s6-setsid: EXTRA_LIBS := -lskarnet s6-setsid: src/daemontools-extras/s6-setsid.o s6-setuidgid: EXTRA_LIBS := -lskarnet @@ -239,12 +226,12 @@ s6-instance-maker: src/instance/s6-instance-maker.o libs6auto.a.xyzzy s6-instance-status: EXTRA_LIBS := -lskarnet s6-instance-status: src/instance/s6-instance-status.o 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_instance_chdirservice.o src/libs6/s6_servicedir_file_list.o src/libs6/s6_servicedir_instances_recreate_offline.o src/libs6/s6_servicedir_instances_recreate_offline_tmp.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 src/libs6/s6_ucspiserver_spawn.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_instance_chdirservice.o src/libs6/s6_servicedir_file_list.o src/libs6/s6_servicedir_instances_recreate_offline.o src/libs6/s6_servicedir_instances_recreate_offline_tmp.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/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 src/libs6/s6_ucspiserver_spawn.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_instance_chdirservice.lo src/libs6/s6_servicedir_file_list.lo src/libs6/s6_servicedir_instances_recreate_offline.lo src/libs6/s6_servicedir_instances_recreate_offline_tmp.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 src/libs6/s6_ucspiserver_spawn.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_instance_chdirservice.lo src/libs6/s6_servicedir_file_list.lo src/libs6/s6_servicedir_instances_recreate_offline.lo src/libs6/s6_servicedir_instances_recreate_offline_tmp.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/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 src/libs6/s6_ucspiserver_spawn.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_instance_chdirservice.lo src/libs6/s6_servicedir_file_list.lo src/libs6/s6_servicedir_instances_recreate_offline.lo src/libs6/s6_servicedir_instances_recreate_offline_tmp.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 src/libs6/s6_ucspiserver_spawn.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_instance_chdirservice.lo src/libs6/s6_servicedir_file_list.lo src/libs6/s6_servicedir_instances_recreate_offline.lo src/libs6/s6_servicedir_instances_recreate_offline_tmp.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/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 src/libs6/s6_ucspiserver_spawn.lo ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),) libs6auto.a.xyzzy: src/libs6/s6_auto_write_logger.o src/libs6/s6_auto_write_logger_tmp.o src/libs6/s6_auto_write_logrun.o src/libs6/s6_auto_write_logrun_tmp.o src/libs6/s6_auto_write_service.o else @@ -252,11 +239,6 @@ libs6auto.a.xyzzy: src/libs6/s6_auto_write_logger.lo src/libs6/s6_auto_write_log endif libs6auto.so.xyzzy: EXTRA_LIBS := libs6auto.so.xyzzy: src/libs6/s6_auto_write_logger.lo src/libs6/s6_auto_write_logger_tmp.lo src/libs6/s6_auto_write_logrun.lo src/libs6/s6_auto_write_logrun_tmp.lo src/libs6/s6_auto_write_service.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} @@ -309,4 +291,4 @@ 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 libs6auto.a.xyzzy -INTERNAL_LIBS := libs6lockd.a.xyzzy +INTERNAL_LIBS := diff --git a/package/info b/package/info index d9cc30e..cf1b9b6 100644 --- a/package/info +++ b/package/info @@ -1,4 +1,4 @@ package=s6 -version=2.11.4.0 +version=2.12.0.0 category=admin package_macro_name=S6 diff --git a/package/modes b/package/modes index 2207dab..837f0a2 100644 --- a/package/modes +++ b/package/modes @@ -4,8 +4,6 @@ s6-ftrig-listen1 0755 s6-ftrig-listen 0755 s6-ftrig-notify 0755 s6-ftrig-wait 0755 -s6lockd 0755 -s6lockd-helper 0755 s6-cleanfifodir 0755 s6-mkfifodir 0755 s6-svscan 0755 diff --git a/package/targets.mak b/package/targets.mak index ba6c353..d4e0376 100644 --- a/package/targets.mak +++ b/package/targets.mak @@ -5,7 +5,6 @@ s6-ftrig-listen1 \ s6-ftrig-listen \ s6-ftrig-notify \ s6-ftrig-wait \ -s6lockd \ s6-cleanfifodir \ s6-mkfifodir \ s6-svscan \ @@ -63,8 +62,6 @@ s6-instance-control \ s6-instance-status \ s6-instance-list -LIBEXEC_TARGETS := s6lockd-helper - LIB_DEFS := S6=s6 ifneq ($(EXECLINE_LIB),) diff --git a/src/conn-tools/deps-exe/s6-ipcserverd b/src/conn-tools/deps-exe/s6-ipcserverd index bfcb622..19869b2 100644 --- a/src/conn-tools/deps-exe/s6-ipcserverd +++ b/src/conn-tools/deps-exe/s6-ipcserverd @@ -1,3 +1,2 @@ -${LIBS6} -lskarnet ${SOCKET_LIB} diff --git a/src/conn-tools/s6-ipcserverd.c b/src/conn-tools/s6-ipcserverd.c index 2987763..3190985 100644 --- a/src/conn-tools/s6-ipcserverd.c +++ b/src/conn-tools/s6-ipcserverd.c @@ -20,9 +20,8 @@ #include <skalibs/selfpipe.h> #include <skalibs/iopause.h> #include <skalibs/socket.h> -#include <skalibs/exec.h> - -#include <s6/ucspiserver.h> +#include <skalibs/env.h> +#include <skalibs/cspawn.h> #define USAGE "s6-ipcserverd [ -v verbosity ] [ -1 ] [ -P | -p ] [ -c maxconn ] [ -C localmaxconn ] prog..." @@ -55,9 +54,6 @@ static unsigned int numconn = 0 ; static uidnum_t *uidnum ; static unsigned int uidlen = 0 ; - - /* Utility functions */ - static inline void dieusage () { strerr_dieusage(100, USAGE) ; @@ -68,9 +64,6 @@ static inline void X (void) strerr_dief1x(101, "internal inconsistency. Please submit a bug-report.") ; } - - /* Lookup primitives */ - static unsigned int lookup_pid (pid_t pid) { unsigned int i = 0 ; @@ -85,9 +78,6 @@ static inline unsigned int lookup_uid (uid_t uid) return i ; } - - /* Logging */ - static inline void log_start (void) { strerr_warni1x("starting") ; @@ -147,9 +137,6 @@ static inline void log_close (pid_t pid, uid_t uid, int w) strerr_warni6x("end pid ", fmtpid, " uid ", fmtuid, WIFSIGNALED(w) ? " signal " : " exitcode ", fmtw) ; } - - /* Signal handling */ - static void killthem (int sig) { unsigned int i = 0 ; @@ -227,9 +214,6 @@ static inline void handle_signals (void) } } - - /* New connection handling */ - static void new_connection (int s, char const *remotepath, char const *const *argv, char const *const *envp, size_t envlen) { uid_t uid = 0 ; @@ -238,6 +222,12 @@ static void new_connection (int s, char const *remotepath, char const *const *ar size_t rplen = strlen(remotepath) + 1 ; pid_t pid ; unsigned int num, i ; + cspawn_fileaction fa[2] = + { + [0] = { .type = CSPAWN_FA_MOVE, .x = { .fd2 = { [0] = 0, [1] = s } } }, + [1] = { .type = CSPAWN_FA_COPY, .x = { .fd2 = { [0] = 1, [1] = 0 } } } + } ; + char const *newenvp[envlen + 6] ; char fmt[65 + UID_FMT + GID_FMT + UINT_FMT + rplen] ; if (flaglookup && (getpeereid(s, &uid, &gid) < 0)) @@ -272,8 +262,8 @@ static void new_connection (int s, char const *remotepath, char const *const *ar fmt[m++] = 0 ; memcpy(fmt + m, "IPCREMOTEPATH=", 14) ; m += 14 ; memcpy(fmt + m, remotepath, rplen) ; m += rplen ; - - pid = s6_ucspiserver_spawn(s, argv, envp, envlen, fmt, m, 5) ; + env_mergen(newenvp, envlen + 6, envp, envlen, fmt, m, 5) ; + pid = cspawn(argv[0], argv, newenvp, CSPAWN_FLAGS_SELFPIPE_FINISH, fa, 2) ; if (!pid) { if (verbosity) strerr_warnwu2sys("spawn ", argv[0]) ; @@ -295,7 +285,6 @@ static void new_connection (int s, char const *remotepath, char const *const *ar } } - int main (int argc, char const *const *argv) { iopause_fd x[2] = { { .events = IOPAUSE_READ }, { .fd = 0, .events = IOPAUSE_READ | IOPAUSE_EXCEPT } } ; diff --git a/src/daemontools-extras/deps-exe/s6-setlock b/src/daemontools-extras/deps-exe/s6-setlock index 9bb3918..3dc5bdf 100644 --- a/src/daemontools-extras/deps-exe/s6-setlock +++ b/src/daemontools-extras/deps-exe/s6-setlock @@ -1,4 +1,2 @@ -libs6lockd.a.xyzzy -lskarnet -${SYSCLOCK_LIB} -${SPAWN_LIB} +${TIMER_LIB} diff --git a/src/daemontools-extras/s6-setlock.c b/src/daemontools-extras/s6-setlock.c index fea6a11..673caaf 100644 --- a/src/daemontools-extras/s6-setlock.c +++ b/src/daemontools-extras/s6-setlock.c @@ -4,30 +4,40 @@ #include <errno.h> #include <signal.h> -#include <skalibs/allreadwrite.h> #include <skalibs/sgetopt.h> #include <skalibs/strerr.h> #include <skalibs/types.h> #include <skalibs/tai.h> -#include <skalibs/iopause.h> -#include <skalibs/cspawn.h> +#include <skalibs/sig.h> +#include <skalibs/alarm.h> #include <skalibs/djbunix.h> #include <skalibs/exec.h> #include <s6/config.h> -#include "s6lockd.h" -#define USAGE "s6-setlock [ -r | -w ] [ -n | -N | -t timeout ] lockfile prog..." +#define USAGE "s6-setlock [ -r | -w ] [ -n | -N ] [ -t timeout ] [ -d fd ] lockfile prog..." #define dieusage() strerr_dieusage(100, USAGE) +static char const *file ; + +static void sigalrm_handler (int sig) +{ + (void)sig ; + strerr_dief3x(1, "lock ", file, ": timed out") ; +} + int main (int argc, char const *const *argv) { unsigned int nb = 0, ex = 1 ; unsigned int timeout = 0 ; + int dest = -1 ; + int fd ; + int r ; PROG = "s6-setlock" ; + for (;;) { - int opt = lgetopt(argc, argv, "nNrwt:") ; + int opt = lgetopt(argc, argv, "nNrwt:d:") ; if (opt == -1) break ; switch (opt) { @@ -35,47 +45,50 @@ int main (int argc, char const *const *argv) case 'N' : nb = 0 ; break ; case 'r' : ex = 0 ; break ; case 'w' : ex = 1 ; break ; - case 't' : if (!uint0_scan(subgetopt_here.arg, &timeout)) dieusage() ; nb = 2 ; break ; + case 't' : if (!uint0_scan(subgetopt_here.arg, &timeout)) dieusage() ; break ; + case 'd' : { unsigned int u ; if (!uint0_scan(subgetopt_here.arg, &u)) dieusage() ; dest = u ; break ; } default : dieusage() ; } } argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ; if (argc < 2) dieusage() ; + file = argv[0] ; - if (nb < 2) s6lockd_openandlock(argv[0], ex, nb) ; + if (ex) + { + fd = open_create(file) ; + if (fd == -1) strerr_diefu3sys(111, "open ", file, " for writing") ; + } else { - char const *cargv[4] = { "s6lockd-helper", ex ? "w" : "r", argv[0], 0 } ; - char const *nullenv = { 0 } ; - iopause_fd x = { .events = IOPAUSE_READ } ; - tain deadline ; - int p[2] = { 0, 1 } ; - pid_t pid ; - char c ; - tain_now_set_stopwatch_g() ; - tain_from_millisecs(&deadline, timeout) ; - tain_add_g(&deadline, &deadline) ; - pid = child_spawn2(S6_LIBEXECPREFIX "s6lockd-helper", cargv, &nullenv, p) ; - if (!pid) strerr_diefu2sys(111, "spawn ", S6_LIBEXECPREFIX "s6lockd-helper") ; - x.fd = p[0] ; - for (;;) + fd = open_read(file) ; + if (fd == -1) { - ssize_t rr ; - int r = iopause_g(&x, 1, &deadline) ; - if (r < 0) strerr_diefu1sys(111, "iopause") ; - if (!r) - { - kill(pid, SIGTERM) ; - errno = ETIMEDOUT ; - strerr_diefu1sys(1, "acquire lock") ; - } - rr = sanitize_read(fd_read(p[0], &c, 1)) ; - if (rr < 0) strerr_diefu1sys(111, "read ack from helper") ; - if (rr) break ; + if (errno != ENOENT) strerr_diefu3sys(111, "open ", file, " for reading") ; + fd = open_create(file) ; + if (fd == -1) strerr_diefu2sys(111, "create ", file) ; + fd_close(fd) ; + fd = open_read(file) ; + if (fd == -1) strerr_diefu3sys(111, "open ", file, " for reading") ; } - if (c != '!') strerr_dief1x(111, "helper sent garbage ack") ; - fd_close(p[0]) ; - if (uncoe(p[1]) < 0) strerr_diefu1sys(111, "uncoe fd to helper") ; } + + if (timeout) + { + tain tto ; + tain_from_millisecs(&tto, timeout) ; + if (!sig_catch(SIGALRM, &sigalrm_handler)) + strerr_diefu1sys(111, "set SIGALRM handler") ; + if (!alarm_timeout(&tto)) + strerr_diefu1sys(111, "set timer") ; + } + r = fd_lock(fd, ex, nb) ; + if (timeout) alarm_disable() ; + + if (!r) errno = EBUSY ; + if (r < 1) strerr_diefu2sys(1, "lock ", file) ; + + if (dest >= 0 && fd_move(dest, fd) == -1) + strerr_diefu1sys(111, "move lock descriptor") ; xexec(argv+1) ; } diff --git a/src/libs6/deps-lib/s6 b/src/libs6/deps-lib/s6 index 13b9a83..59999be 100644 --- a/src/libs6/deps-lib/s6 +++ b/src/libs6/deps-lib/s6 @@ -42,16 +42,6 @@ s6_svstatus_pack.o s6_svstatus_read.o s6_svstatus_unpack.o s6_svstatus_write.o -s6lock_acquire.o -s6lock_check.o -s6lock_end.o -s6lock_release.o -s6lock_start.o -s6lock_startf.o -s6lock_update.o -s6lock_wait_and.o -s6lock_wait_or.o -s6lock_zero.o s6_fdholder_delete.o s6_fdholder_delete_async.o s6_fdholder_end.o diff --git a/src/libs6/deps-lib/s6lockd b/src/libs6/deps-lib/s6lockd deleted file mode 100644 index 22cea80..0000000 --- a/src/libs6/deps-lib/s6lockd +++ /dev/null @@ -1 +0,0 @@ -s6lockd_openandlock.o diff --git a/src/libs6/s6lock_acquire.c b/src/libs6/s6lock_acquire.c deleted file mode 100644 index 890f892..0000000 --- a/src/libs6/s6lock_acquire.c +++ /dev/null @@ -1,41 +0,0 @@ -/* ISC license. */ - -#include <sys/uio.h> -#include <string.h> -#include <stdint.h> -#include <errno.h> -#include <skalibs/uint16.h> -#include <skalibs/uint32.h> -#include <skalibs/tai.h> -#include <skalibs/gensetdyn.h> -#include <skalibs/textclient.h> -#include <s6/lock.h> - -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] = "--<" ; - struct iovec v[2] = { { .iov_base = tmp, .iov_len = 23 }, { .iov_base = (char *)path, .iov_len = pathlen + 1 } } ; - uint32_t i ; - if (pathlen > UINT32_MAX) return (errno = ENAMETOOLONG, 0) ; - if (!gensetdyn_new(&a->data, &i)) return 0 ; - if (i > UINT16_MAX) - { - gensetdyn_delete(&a->data, i) ; - return (errno = EMFILE, 0) ; - } - uint16_pack_big(tmp, (uint16_t)i) ; - uint32_pack_big(tmp+3, options) ; - tain_pack(tmp+7, limit) ; - uint32_pack_big(tmp+19, (uint32_t)pathlen) ; - if (!textclient_commandv(&a->connection, v, 2, deadline, stamp)) - { - int e = errno ; - gensetdyn_delete(&a->data, i) ; - errno = e ; - return 0 ; - } - *GENSETDYN_P(unsigned char, &a->data, i) = EAGAIN ; - *u = i ; - return 1 ; -} diff --git a/src/libs6/s6lock_check.c b/src/libs6/s6lock_check.c deleted file mode 100644 index 0602d40..0000000 --- a/src/libs6/s6lock_check.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ISC license. */ - -#include <errno.h> -#include <skalibs/error.h> -#include <skalibs/gensetdyn.h> -#include <s6/lock.h> - -int s6lock_check (s6lock_t *a, uint16_t id) -{ - unsigned char *p = GENSETDYN_P(unsigned char, &a->data, id) ; - switch (*p) - { - case EBUSY : return 1 ; - case EINVAL : return (errno = EINVAL, -1) ; - default : - { - if (error_isagain(*p)) return 0 ; - errno = *p ; - *p = EINVAL ; - gensetdyn_delete(&a->data, id) ; - return -1 ; - } - } -} diff --git a/src/libs6/s6lock_end.c b/src/libs6/s6lock_end.c deleted file mode 100644 index 8611289..0000000 --- a/src/libs6/s6lock_end.c +++ /dev/null @@ -1,15 +0,0 @@ -/* ISC license. */ - -#include <stdint.h> -#include <skalibs/genalloc.h> -#include <skalibs/gensetdyn.h> -#include <skalibs/textclient.h> -#include <s6/lock.h> - -void s6lock_end (s6lock_t *a) -{ - gensetdyn_free(&a->data) ; - genalloc_free(uint16_t, &a->list) ; - textclient_end(&a->connection) ; - *a = s6lock_zero ; -} diff --git a/src/libs6/s6lock_release.c b/src/libs6/s6lock_release.c deleted file mode 100644 index 2c045a6..0000000 --- a/src/libs6/s6lock_release.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ISC license. */ - -#include <errno.h> -#include <skalibs/error.h> -#include <skalibs/uint16.h> -#include <skalibs/gensetdyn.h> -#include <skalibs/textclient.h> -#include <s6/lock.h> - -int s6lock_release (s6lock_t *a, uint16_t i, tain const *deadline, tain *stamp) -{ - unsigned char *p = GENSETDYN_P(unsigned char, &a->data, i) ; - char pack[3] = "-->" ; - if ((*p != EBUSY) && !error_isagain(*p)) - { - s6lock_check(a, i) ; - return 1 ; - } - uint16_pack_big(pack, i) ; - if (!textclient_command(&a->connection, pack, 3, deadline, stamp)) return 0 ; - *p = EINVAL ; - return gensetdyn_delete(&a->data, i) ; -} diff --git a/src/libs6/s6lock_start.c b/src/libs6/s6lock_start.c deleted file mode 100644 index ca8fcc8..0000000 --- a/src/libs6/s6lock_start.c +++ /dev/null @@ -1,9 +0,0 @@ -/* ISC license. */ - -#include <skalibs/textclient.h> -#include <s6/lock.h> - -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 --git a/src/libs6/s6lock_startf.c b/src/libs6/s6lock_startf.c deleted file mode 100644 index be6e0c8..0000000 --- a/src/libs6/s6lock_startf.c +++ /dev/null @@ -1,13 +0,0 @@ -/* ISC license. */ - -#include <errno.h> -#include <skalibs/posixplz.h> -#include <skalibs/textclient.h> -#include <s6/lock.h> - -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) ; - return textclient_startf(&a->connection, cargv, (char const *const *)environ, TEXTCLIENT_OPTION_WAITPID, S6LOCK_BANNER1, S6LOCK_BANNER1_LEN, S6LOCK_BANNER2, S6LOCK_BANNER2_LEN, deadline, stamp) ; -} diff --git a/src/libs6/s6lock_update.c b/src/libs6/s6lock_update.c deleted file mode 100644 index e345230..0000000 --- a/src/libs6/s6lock_update.c +++ /dev/null @@ -1,37 +0,0 @@ -/* ISC license. */ - -#include <sys/uio.h> -#include <stdint.h> -#include <errno.h> - -#include <skalibs/error.h> -#include <skalibs/uint16.h> -#include <skalibs/genalloc.h> -#include <skalibs/gensetdyn.h> -#include <skalibs/textclient.h> - -#include <s6/lock.h> - -#include <skalibs/posixishard.h> - -static int msghandler (struct iovec const *v, void *context) -{ - s6lock_t *a = (s6lock_t *)context ; - char const *s = v->iov_base ; - unsigned char *p ; - uint16_t id ; - if (v->iov_len != 3) return (errno = EPROTO, 0) ; - uint16_unpack_big(s, &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) ; - if (!genalloc_append(uint16_t, &a->list, &id)) return 0 ; - return 1 ; -} - -int s6lock_update (s6lock_t *a) -{ - genalloc_setlen(uint16_t, &a->list, 0) ; - return textclient_update(&a->connection, &msghandler, a) ; -} diff --git a/src/libs6/s6lock_wait_and.c b/src/libs6/s6lock_wait_and.c deleted file mode 100644 index eca7946..0000000 --- a/src/libs6/s6lock_wait_and.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ISC license. */ - -#include <errno.h> -#include <skalibs/iopause.h> -#include <s6/lock.h> - -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) ; - for (; n ; n--, idlist++) - { - for (;;) - { - int r = s6lock_check(a, *idlist) ; - if (r < 0) return r ; - else if (r) break ; - r = iopause_stamp(&x, 1, deadline, stamp) ; - if (r < 0) return r ; - else if (!r) return (errno = ETIMEDOUT, -1) ; - else if (s6lock_update(a) < 0) return -1 ; - } - } - return 0 ; -} diff --git a/src/libs6/s6lock_wait_or.c b/src/libs6/s6lock_wait_or.c deleted file mode 100644 index 4e2a501..0000000 --- a/src/libs6/s6lock_wait_or.c +++ /dev/null @@ -1,32 +0,0 @@ -/* ISC license. */ - -#include <errno.h> - -#include <skalibs/iopause.h> - -#include <s6/lock.h> - -#include <skalibs/posixishard.h> - -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) ; - if (x.fd < 0) return -1 ; - for (;;) - { - unsigned int i = 0 ; - int r ; - for (; i < n ; i++) - { - r = s6lock_check(a, idlist[i]) ; - if (r < 0) return r ; - else if (r) return i ; - } - r = iopause_stamp(&x, 1, deadline, stamp) ; - if (r < 0) return 0 ; - else if (!r) return (errno = ETIMEDOUT, -1) ; - else if (s6lock_update(a) < 0) return -1 ; - } - return (errno = EPROTO, -1) ; /* can't happen */ -} diff --git a/src/libs6/s6lock_zero.c b/src/libs6/s6lock_zero.c deleted file mode 100644 index 3d35d40..0000000 --- a/src/libs6/s6lock_zero.c +++ /dev/null @@ -1,5 +0,0 @@ -/* ISC license. */ - -#include <s6/lock.h> - -s6lock_t const s6lock_zero = S6LOCK_ZERO ; diff --git a/src/libs6/s6lockd-helper.c b/src/libs6/s6lockd-helper.c deleted file mode 100644 index 7bfcf38..0000000 --- a/src/libs6/s6lockd-helper.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ISC license. */ - -#include <skalibs/allreadwrite.h> -#include <skalibs/strerr.h> - -#include "s6lockd.h" - -#define USAGE "s6lockd-helper r|w lockfile" -#define dieusage() strerr_dieusage(100, USAGE) - -int main (int argc, char const *const *argv) -{ - char c ; - PROG = "s6lockd-helper" ; - if (argc < 3) dieusage() ; - 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) - strerr_diefu1sys(111, "read from stdin") ; - return 0 ; -} diff --git a/src/libs6/s6lockd.c b/src/libs6/s6lockd.c deleted file mode 100644 index 8cc767a..0000000 --- a/src/libs6/s6lockd.c +++ /dev/null @@ -1,318 +0,0 @@ -/* ISC license. */ - -#include <sys/uio.h> -#include <stdint.h> -#include <unistd.h> -#include <errno.h> -#include <signal.h> - -#include <skalibs/posixishard.h> -#include <skalibs/types.h> -#include <skalibs/allreadwrite.h> -#include <skalibs/error.h> -#include <skalibs/strerr.h> -#include <skalibs/genalloc.h> -#include <skalibs/sig.h> -#include <skalibs/selfpipe.h> -#include <skalibs/tai.h> -#include <skalibs/cspawn.h> -#include <skalibs/djbunix.h> -#include <skalibs/iopause.h> -#include <skalibs/textmessage.h> -#include <skalibs/textclient.h> - -#include <s6/lock.h> - -#define USAGE "s6lockd lockdir" -#define X() strerr_dief1x(101, "internal inconsistency, please submit a bug-report.") - -typedef struct s6lockio_s s6lockio_t, *s6lockio_t_ref ; -struct s6lockio_s -{ - unsigned int xindex ; - unsigned int pid ; - tain limit ; - int p[2] ; - uint16_t id ; /* given by client */ -} ; -#define S6LOCKIO_ZERO { 0, 0, TAIN_ZERO, { -1, -1 }, 0 } -static s6lockio_t const szero = S6LOCKIO_ZERO ; - -static genalloc a = GENALLOC_ZERO ; /* array of s6lockio_t */ - -static void s6lockio_free (s6lockio_t *p) -{ - int e = errno ; - fd_close(p->p[1]) ; - fd_close(p->p[0]) ; - kill(p->pid, SIGTERM) ; - *p = szero ; - errno = e ; -} - -static void cleanup (void) -{ - size_t i = genalloc_len(s6lockio_t, &a) ; - for (; i ; i--) s6lockio_free(genalloc_s(s6lockio_t, &a) + i - 1) ; - genalloc_setlen(s6lockio_t, &a, 0) ; -} - -static void trig (uint16_t id, unsigned char e) -{ - char pack[3] ; - uint16_pack_big(pack, id) ; - pack[2] = e ; - if (!textmessage_put(textmessage_sender_x, pack, 3)) - { - cleanup() ; - strerr_diefu1sys(111, "build answer") ; - } -} - -static void answer (unsigned char c) -{ - if (!textmessage_put(textmessage_sender_1, (char *)&c, 1)) - { - cleanup() ; - strerr_diefu1sys(111, "textmessage_put") ; - } -} - -static void remove (unsigned int i) -{ - size_t n = genalloc_len(s6lockio_t, &a) - 1 ; - s6lockio_free(genalloc_s(s6lockio_t, &a) + i) ; - genalloc_s(s6lockio_t, &a)[i] = genalloc_s(s6lockio_t, &a)[n] ; - genalloc_setlen(s6lockio_t, &a, n) ; -} - -static void handle_signals (void) -{ - for (;;) - { - switch (selfpipe_read()) - { - case -1 : cleanup() ; strerr_diefu1sys(111, "selfpipe_read") ; - case 0 : return ; - case SIGTERM : - case SIGQUIT : - case SIGHUP : - case SIGABRT : - case SIGINT : cleanup() ; _exit(0) ; - case SIGCHLD : wait_reap() ; break ; - default : cleanup() ; X() ; - } - } -} - -static int parse_protocol (struct iovec const *v, void *context) -{ - char *s = v->iov_base ; - uint16_t id ; - if (v->iov_len < 3) - { - cleanup() ; - strerr_dief1x(100, "invalid client request") ; - } - uint16_unpack_big(s, &id) ; - switch (s[2]) - { - case '>' : /* release */ - { - size_t i = genalloc_len(s6lockio_t, &a) ; - for (; i ; i--) if (genalloc_s(s6lockio_t, &a)[i-1].id == id) break ; - if (i) - { - remove(i-1) ; - answer(0) ; - } - else answer(ENOENT) ; - break ; - } - case '<' : /* lock path */ - { - s6lockio_t f = S6LOCKIO_ZERO ; - char const *cargv[4] = { S6LOCKD_HELPER_PROG, "r", 0, 0 } ; - char const *nullenv = 0 ; - uint32_t options, pathlen ; - if (v->iov_len < 23) - { - answer(EPROTO) ; - break ; - } - uint32_unpack_big(s + 3, &options) ; - tain_unpack(s + 7, &f.limit) ; - uint32_unpack_big(s + 19, &pathlen) ; - if (pathlen + 23 != v->iov_len || s[v->iov_len - 1]) - { - answer(EPROTO) ; - break ; - } - f.id = id ; - s[21] = '.' ; - s[22] = '/' ; - if (options & S6LOCK_OPTIONS_EX) cargv[1] = "w" ; - cargv[2] = (char const *)s + 21 ; - f.pid = child_spawn2(cargv[0], cargv, &nullenv, f.p) ; - if (!f.pid) - { - answer(errno) ; - break ; - } - if (!genalloc_append(s6lockio_t, &a, &f)) - { - s6lockio_free(&f) ; - answer(errno) ; - break ; - } - answer(0) ; - break ; - } - default : - { - cleanup() ; - strerr_dief1x(100, "invalid client request") ; - } - } - (void)context ; - return 1 ; -} - -int main (int argc, char const *const *argv) -{ - tain deadline ; - PROG = "s6lockd" ; - - if (argc < 2) strerr_dieusage(100, USAGE) ; - 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_altignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ; - - if (selfpipe_init() == -1) strerr_diefu1sys(111, "selfpipe_init") ; - { - sigset_t set ; - sigemptyset(&set) ; - sigaddset(&set, SIGCHLD) ; - sigaddset(&set, SIGTERM) ; - sigaddset(&set, SIGQUIT) ; - sigaddset(&set, SIGHUP) ; - sigaddset(&set, SIGABRT) ; - sigaddset(&set, SIGINT) ; - if (!selfpipe_trapset(&set)) - strerr_diefu1sys(111, "trap signals") ; - } - - tain_now_set_stopwatch_g() ; - tain_addsec_g(&deadline, 2) ; - - if (!textclient_server_01x_init_g(S6LOCK_BANNER1, S6LOCK_BANNER1_LEN, S6LOCK_BANNER2, S6LOCK_BANNER2_LEN, &deadline)) - strerr_diefu1sys(111, "sync with client") ; - - for (;;) - { - size_t n = genalloc_len(s6lockio_t, &a) ; - iopause_fd x[4 + n] ; - unsigned int i = 0 ; - int r ; - - tain_add_g(&deadline, &tain_infinite_relative) ; - x[0].fd = 0 ; x[0].events = IOPAUSE_EXCEPT | IOPAUSE_READ ; - x[1].fd = 1 ; x[1].events = IOPAUSE_EXCEPT | (textmessage_sender_isempty(textmessage_sender_1) ? 0 : IOPAUSE_WRITE ) ; - x[2].fd = textmessage_sender_fd(textmessage_sender_x) ; - x[2].events = IOPAUSE_EXCEPT | (textmessage_sender_isempty(textmessage_sender_x) ? 0 : IOPAUSE_WRITE) ; - x[3].fd = selfpipe_fd() ; x[3].events = IOPAUSE_READ ; - for (; i < n ; i++) - { - s6lockio_t *p = genalloc_s(s6lockio_t, &a) + i ; - x[4+i].fd = p->p[0] ; - x[4+i].events = IOPAUSE_READ ; - if (p->limit.sec.x && tain_less(&p->limit, &deadline)) deadline = p->limit ; - p->xindex = 4+i ; - } - - r = iopause_g(x, 4 + n, &deadline) ; - if (r < 0) - { - cleanup() ; - strerr_diefu1sys(111, "iopause") ; - } - - /* timeout => seek and destroy */ - if (!r) - { - for (i = 0 ; i < n ; i++) - { - s6lockio_t *p = genalloc_s(s6lockio_t, &a) + i ; - if (p->limit.sec.x && !tain_future(&p->limit)) break ; - } - if (i < n) - { - trig(genalloc_s(s6lockio_t, &a)[i].id, ETIMEDOUT) ; - remove(i) ; - } - continue ; - } - - /* client closed */ - if ((x[0].revents | x[1].revents) & IOPAUSE_EXCEPT) break ; - - /* client is reading */ - if (x[1].revents & IOPAUSE_WRITE) - if (!textmessage_sender_flush(textmessage_sender_1) && !error_isagain(errno)) - { - cleanup() ; - strerr_diefu1sys(111, "flush stdout") ; - } - if (x[2].revents & IOPAUSE_WRITE) - if (!textmessage_sender_flush(textmessage_sender_x) && !error_isagain(errno)) - { - cleanup() ; - strerr_diefu1sys(111, "flush asyncout") ; - } - - /* scan children for successes */ - for (i = 0 ; i < genalloc_len(s6lockio_t, &a) ; i++) - { - s6lockio_t *p = genalloc_s(s6lockio_t, &a) + i ; - if (p->p[0] < 0) continue ; - if (x[p->xindex].revents & IOPAUSE_READ) - { - char c ; - ssize_t r = sanitize_read(fd_read(p->p[0], &c, 1)) ; - if (!r) continue ; - if (r < 0) - { - trig(p->id, errno) ; - remove(i--) ; - } - else if (c != '!') - { - trig(p->id, EPROTO) ; - remove(i--) ; - } - else - { - trig(p->id, 0) ; - p->limit = tain_zero ; - } - } - } - - /* signals arrived */ - if (x[3].revents & (IOPAUSE_READ | IOPAUSE_EXCEPT)) handle_signals() ; - - /* client is writing */ - if (!textmessage_receiver_isempty(textmessage_receiver_0) || x[0].revents & IOPAUSE_READ) - { - if (textmessage_handle(textmessage_receiver_0, &parse_protocol, 0) < 0) - { - if (errno == EPIPE) break ; /* normal exit */ - cleanup() ; - strerr_diefu1sys(111, "handle messages from client") ; - } - } - } - cleanup() ; - return 0 ; -} diff --git a/src/libs6/s6lockd_openandlock.c b/src/libs6/s6lockd_openandlock.c deleted file mode 100644 index ca51934..0000000 --- a/src/libs6/s6lockd_openandlock.c +++ /dev/null @@ -1,35 +0,0 @@ -/* ISC license. */ - -#include <errno.h> - -#include <skalibs/strerr.h> -#include <skalibs/djbunix.h> - -#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 ; -} |