aboutsummaryrefslogtreecommitdiff
path: root/runit
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-08-22 14:56:12 +0100
committerRon Yorston <rmy@pobox.com>2017-08-22 14:56:12 +0100
commitce9af1cc5ea23f754587448cf35b5120c77bfeef (patch)
tree69e5eaba5e75ab909ed92d5045393471b8ff3c13 /runit
parentc170026700eabb10147dd848c45c06995b43a32e (diff)
parente837a0dbbebf4229306df98fe9ee3b9bb30630c4 (diff)
downloadbusybox-w32-ce9af1cc5ea23f754587448cf35b5120c77bfeef.tar.gz
busybox-w32-ce9af1cc5ea23f754587448cf35b5120c77bfeef.tar.bz2
busybox-w32-ce9af1cc5ea23f754587448cf35b5120c77bfeef.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'runit')
-rw-r--r--runit/chpst.c21
-rw-r--r--runit/runit_lib.h2
-rw-r--r--runit/runsv.c2
-rw-r--r--runit/runsvdir.c5
-rw-r--r--runit/sv.c32
-rw-r--r--runit/svlogd.c9
6 files changed, 38 insertions, 33 deletions
diff --git a/runit/chpst.c b/runit/chpst.c
index 3a2f9e616..3ecb85cba 100644
--- a/runit/chpst.c
+++ b/runit/chpst.c
@@ -13,7 +13,7 @@ modification, are permitted provided that the following conditions are met:
13 3. The name of the author may not be used to endorse or promote products 13 3. The name of the author may not be used to endorse or promote products
14 derived from this software without specific prior written permission. 14 derived from this software without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 18MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
@@ -59,12 +59,12 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59//config: help 59//config: help
60//config: Sets soft resource limits as specified by options 60//config: Sets soft resource limits as specified by options
61 61
62//applet:IF_CHPST(APPLET(chpst, BB_DIR_USR_BIN, BB_SUID_DROP)) 62//applet:IF_CHPST( APPLET_NOEXEC(chpst, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, chpst))
63// APPLET_ODDNAME:name main location suid_type help 63// APPLET_NOEXEC:name main location suid_type help
64//applet:IF_ENVDIR( APPLET_ODDNAME(envdir, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envdir)) 64//applet:IF_ENVDIR( APPLET_NOEXEC(envdir, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envdir))
65//applet:IF_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envuidgid)) 65//applet:IF_ENVUIDGID(APPLET_NOEXEC(envuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envuidgid))
66//applet:IF_SETUIDGID(APPLET_ODDNAME(setuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, setuidgid)) 66//applet:IF_SETUIDGID(APPLET_NOEXEC(setuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, setuidgid))
67//applet:IF_SOFTLIMIT(APPLET_ODDNAME(softlimit, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, softlimit)) 67//applet:IF_SOFTLIMIT(APPLET_NOEXEC(softlimit, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, softlimit))
68 68
69//kbuild:lib-$(CONFIG_CHPST) += chpst.o 69//kbuild:lib-$(CONFIG_CHPST) += chpst.o
70//kbuild:lib-$(CONFIG_ENVDIR) += chpst.o 70//kbuild:lib-$(CONFIG_ENVDIR) += chpst.o
@@ -301,9 +301,10 @@ int chpst_main(int argc UNUSED_PARAM, char **argv)
301 // FIXME: can we live with int-sized limits? 301 // FIXME: can we live with int-sized limits?
302 // can we live with 40000 days? 302 // can we live with 40000 days?
303 // if yes -> getopt converts strings to numbers for us 303 // if yes -> getopt converts strings to numbers for us
304 opt_complementary = "-1"; 304 opt = getopt32(argv, "^+"
305 opt = getopt32(argv, "+a:+c:+d:+f:+l:+m:+o:+p:+r:+s:+t:+u:U:e:" 305 "a:+c:+d:+f:+l:+m:+o:+p:+r:+s:+t:+u:U:e:"
306 IF_CHPST("/:n:vP012"), 306 IF_CHPST("/:n:vP012")
307 "\0" "-1",
307 &limita, &limitc, &limitd, &limitf, &limitl, 308 &limita, &limitc, &limitd, &limitf, &limitl,
308 &limitm, &limito, &limitp, &limitr, &limits, &limitt, 309 &limitm, &limito, &limitp, &limitr, &limits, &limitt,
309 &set_user, &set_user, &env_dir 310 &set_user, &set_user, &env_dir
diff --git a/runit/runit_lib.h b/runit/runit_lib.h
index c36ea4ca5..c54561616 100644
--- a/runit/runit_lib.h
+++ b/runit/runit_lib.h
@@ -13,7 +13,7 @@ modification, are permitted provided that the following conditions are met:
13 3. The name of the author may not be used to endorse or promote products 13 3. The name of the author may not be used to endorse or promote products
14 derived from this software without specific prior written permission. 14 derived from this software without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 18MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
diff --git a/runit/runsv.c b/runit/runsv.c
index ad7d82cb8..a67280b4b 100644
--- a/runit/runsv.c
+++ b/runit/runsv.c
@@ -13,7 +13,7 @@ modification, are permitted provided that the following conditions are met:
13 3. The name of the author may not be used to endorse or promote products 13 3. The name of the author may not be used to endorse or promote products
14 derived from this software without specific prior written permission. 14 derived from this software without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 18MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
diff --git a/runit/runsvdir.c b/runit/runsvdir.c
index b4f5c303b..11ab40abf 100644
--- a/runit/runsvdir.c
+++ b/runit/runsvdir.c
@@ -13,7 +13,7 @@ modification, are permitted provided that the following conditions are met:
13 3. The name of the author may not be used to endorse or promote products 13 3. The name of the author may not be used to endorse or promote products
14 derived from this software without specific prior written permission. 14 derived from this software without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 18MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
@@ -248,10 +248,9 @@ int runsvdir_main(int argc UNUSED_PARAM, char **argv)
248 248
249 INIT_G(); 249 INIT_G();
250 250
251 opt_complementary = "-1";
252 opt_s_argv[0] = NULL; 251 opt_s_argv[0] = NULL;
253 opt_s_argv[2] = NULL; 252 opt_s_argv[2] = NULL;
254 getopt32(argv, "Ps:", &opt_s_argv[0]); 253 getopt32(argv, "^" "Ps:" "\0" "-1", &opt_s_argv[0]);
255 argv += optind; 254 argv += optind;
256 255
257 i_am_init = (getpid() == 1); 256 i_am_init = (getpid() == 1);
diff --git a/runit/sv.c b/runit/sv.c
index 2d5b466bf..1d0809be8 100644
--- a/runit/sv.c
+++ b/runit/sv.c
@@ -13,7 +13,7 @@ modification, are permitted provided that the following conditions are met:
13 3. The name of the author may not be used to endorse or promote products 13 3. The name of the author may not be used to endorse or promote products
14 derived from this software without specific prior written permission. 14 derived from this software without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 18MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
@@ -175,8 +175,8 @@ Exit Codes
175//config: svc controls the state of services monitored by the runsv supervisor. 175//config: svc controls the state of services monitored by the runsv supervisor.
176//config: It is comaptible with daemontools command with the same name. 176//config: It is comaptible with daemontools command with the same name.
177 177
178//applet:IF_SV(APPLET(sv, BB_DIR_USR_BIN, BB_SUID_DROP)) 178//applet:IF_SV( APPLET_NOEXEC(sv, sv, BB_DIR_USR_BIN, BB_SUID_DROP, sv ))
179//applet:IF_SVC(APPLET(svc, BB_DIR_USR_BIN, BB_SUID_DROP)) 179//applet:IF_SVC(APPLET_NOEXEC(svc, svc, BB_DIR_USR_BIN, BB_SUID_DROP, svc))
180 180
181//kbuild:lib-$(CONFIG_SV) += sv.o 181//kbuild:lib-$(CONFIG_SV) += sv.o
182//kbuild:lib-$(CONFIG_SVC) += sv.o 182//kbuild:lib-$(CONFIG_SVC) += sv.o
@@ -193,7 +193,7 @@ struct globals {
193/* "Bernstein" time format: unix + 0x400000000000000aULL */ 193/* "Bernstein" time format: unix + 0x400000000000000aULL */
194 uint64_t tstart, tnow; 194 uint64_t tstart, tnow;
195 svstatus_t svstatus; 195 svstatus_t svstatus;
196 unsigned islog; 196 smallint islog;
197} FIX_ALIASING; 197} FIX_ALIASING;
198#define G (*(struct globals*)bb_common_bufsiz1) 198#define G (*(struct globals*)bb_common_bufsiz1)
199#define acts (G.acts ) 199#define acts (G.acts )
@@ -203,7 +203,11 @@ struct globals {
203#define tnow (G.tnow ) 203#define tnow (G.tnow )
204#define svstatus (G.svstatus ) 204#define svstatus (G.svstatus )
205#define islog (G.islog ) 205#define islog (G.islog )
206#define INIT_G() do { setup_common_bufsiz(); } while (0) 206#define INIT_G() do { \
207 setup_common_bufsiz(); \
208 /* need to zero out, svc calls sv() repeatedly */ \
209 memset(&G, 0, sizeof(G)); \
210} while (0)
207 211
208 212
209#define str_equal(s,t) (strcmp((s), (t)) == 0) 213#define str_equal(s,t) (strcmp((s), (t)) == 0)
@@ -502,8 +506,9 @@ static int sv(char **argv)
502 x = getenv("SVWAIT"); 506 x = getenv("SVWAIT");
503 if (x) waitsec = xatou(x); 507 if (x) waitsec = xatou(x);
504 508
505 opt_complementary = "vv"; /* -w N, -v is a counter */ 509 getopt32(argv, "^" "w:+v" "\0" "vv" /* -w N, -v is a counter */,
506 getopt32(argv, "w:+v", &waitsec, &verbose); 510 &waitsec, &verbose
511 );
507 argv += optind; 512 argv += optind;
508 action = *argv++; 513 action = *argv++;
509 if (!action || !*argv) bb_show_usage(); 514 if (!action || !*argv) bb_show_usage();
@@ -701,8 +706,6 @@ int svc_main(int argc UNUSED_PARAM, char **argv)
701 const char *optstring; 706 const char *optstring;
702 unsigned opts; 707 unsigned opts;
703 708
704 INIT_G();
705
706 optstring = "udopchaitkx"; 709 optstring = "udopchaitkx";
707 opts = getopt32(argv, optstring); 710 opts = getopt32(argv, optstring);
708 argv += optind; 711 argv += optind;
@@ -718,15 +721,16 @@ int svc_main(int argc UNUSED_PARAM, char **argv)
718 argv[1] = command; 721 argv[1] = command;
719 command[1] = '\0'; 722 command[1] = '\0';
720 723
721 /* getopt32() was already called:
722 * reset the libc getopt() function, which keeps internal state.
723 */
724 GETOPT_RESET();
725
726 do { 724 do {
727 if (opts & 1) { 725 if (opts & 1) {
728 int r; 726 int r;
727
729 command[0] = *optstring; 728 command[0] = *optstring;
729
730 /* getopt() was already called by getopt32():
731 * reset the libc getopt() function's internal state.
732 */
733 GETOPT_RESET();
730 r = sv(argv); 734 r = sv(argv);
731 if (r) 735 if (r)
732 return 1; 736 return 1;
diff --git a/runit/svlogd.c b/runit/svlogd.c
index 8dbf67106..739483356 100644
--- a/runit/svlogd.c
+++ b/runit/svlogd.c
@@ -13,7 +13,7 @@ modification, are permitted provided that the following conditions are met:
13 3. The name of the author may not be used to endorse or promote products 13 3. The name of the author may not be used to endorse or promote products
14 derived from this software without specific prior written permission. 14 derived from this software without specific prior written permission.
15 15
16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 16THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 18MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
@@ -1037,9 +1037,10 @@ int svlogd_main(int argc, char **argv)
1037 1037
1038 INIT_G(); 1038 INIT_G();
1039 1039
1040 opt_complementary = "tt:vv"; 1040 opt = getopt32(argv, "^"
1041 opt = getopt32(argv, "r:R:l:b:tv", 1041 "r:R:l:b:tv" "\0" "tt:vv",
1042 &r, &replace, &l, &b, &timestamp, &verbose); 1042 &r, &replace, &l, &b, &timestamp, &verbose
1043 );
1043 if (opt & 1) { // -r 1044 if (opt & 1) { // -r
1044 repl = r[0]; 1045 repl = r[0];
1045 if (!repl || r[1]) 1046 if (!repl || r[1])