Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/runit
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- Location:
- branches/3.2/mindi-busybox/runit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/runit/chpst.c
r2725 r3232 29 29 /* Dependencies on runit_lib.c removed */ 30 30 31 //usage:#define chpst_trivial_usage 32 //usage: "[-vP012] [-u USER[:GRP]] [-U USER[:GRP]] [-e DIR]\n" 33 //usage: " [-/ DIR] [-n NICE] [-m BYTES] [-d BYTES] [-o N]\n" 34 //usage: " [-p N] [-f BYTES] [-c BYTES] PROG ARGS" 35 //usage:#define chpst_full_usage "\n\n" 36 //usage: "Change the process state, run PROG\n" 37 //usage: "\n -u USER[:GRP] Set uid and gid" 38 //usage: "\n -U USER[:GRP] Set $UID and $GID in environment" 39 //usage: "\n -e DIR Set environment variables as specified by files" 40 //usage: "\n in DIR: file=1st_line_of_file" 41 //usage: "\n -/ DIR Chroot to DIR" 42 //usage: "\n -n NICE Add NICE to nice value" 43 //usage: "\n -m BYTES Same as -d BYTES -s BYTES -l BYTES" 44 //usage: "\n -d BYTES Limit data segment" 45 //usage: "\n -o N Limit number of open files per process" 46 //usage: "\n -p N Limit number of processes per uid" 47 //usage: "\n -f BYTES Limit output file sizes" 48 //usage: "\n -c BYTES Limit core file size" 49 //usage: "\n -v Verbose" 50 //usage: "\n -P Create new process group" 51 //usage: "\n -0 Close stdin" 52 //usage: "\n -1 Close stdout" 53 //usage: "\n -2 Close stderr" 54 //usage: 55 //usage:#define envdir_trivial_usage 56 //usage: "DIR PROG ARGS" 57 //usage:#define envdir_full_usage "\n\n" 58 //usage: "Set various environment variables as specified by files\n" 59 //usage: "in the directory DIR, run PROG" 60 //usage: 61 //usage:#define envuidgid_trivial_usage 62 //usage: "USER PROG ARGS" 63 //usage:#define envuidgid_full_usage "\n\n" 64 //usage: "Set $UID to USER's uid and $GID to USER's gid, run PROG" 65 //usage: 66 //usage:#define setuidgid_trivial_usage 67 //usage: "USER PROG ARGS" 68 //usage:#define setuidgid_full_usage "\n\n" 69 //usage: "Set uid and gid to USER's uid and gid, drop supplementary group ids,\n" 70 //usage: "run PROG" 71 //usage: 72 //usage:#define softlimit_trivial_usage 73 //usage: "[-a BYTES] [-m BYTES] [-d BYTES] [-s BYTES] [-l BYTES]\n" 74 //usage: " [-f BYTES] [-c BYTES] [-r BYTES] [-o N] [-p N] [-t N]\n" 75 //usage: " PROG ARGS" 76 //usage:#define softlimit_full_usage "\n\n" 77 //usage: "Set soft resource limits, then run PROG\n" 78 //usage: "\n -a BYTES Limit total size of all segments" 79 //usage: "\n -m BYTES Same as -d BYTES -s BYTES -l BYTES -a BYTES" 80 //usage: "\n -d BYTES Limit data segment" 81 //usage: "\n -s BYTES Limit stack segment" 82 //usage: "\n -l BYTES Limit locked memory size" 83 //usage: "\n -o N Limit number of open files per process" 84 //usage: "\n -p N Limit number of processes per uid" 85 //usage: "\nOptions controlling file sizes:" 86 //usage: "\n -f BYTES Limit output file sizes" 87 //usage: "\n -c BYTES Limit core file size" 88 //usage: "\nEfficiency opts:" 89 //usage: "\n -r BYTES Limit resident set size" 90 //usage: "\n -t N Limit CPU time, process receives" 91 //usage: "\n a SIGXCPU after N seconds" 92 31 93 #include "libbb.h" 94 #include <sys/resource.h> /* getrlimit */ 32 95 33 96 /* … … 344 407 edir(env_dir); 345 408 346 // FIXME: chrooted jail must have /etc/passwd if we move this after chroot! 347 // OTOH chroot fails for non-roots! 348 // SOLUTION: cache uid/gid before chroot, apply uid/gid after 409 if (opt & (OPT_u|OPT_U)) 410 xget_uidgid(&ugid, set_user); 411 412 // chrooted jail must have /etc/passwd if we move this after chroot. 413 // OTOH chroot fails for non-roots. 414 // Solution: cache uid/gid before chroot, apply uid/gid after. 349 415 if (opt & OPT_U) { 350 xget_uidgid(&ugid, env_user);351 416 xsetenv("GID", utoa(ugid.gid)); 352 417 xsetenv("UID", utoa(ugid.uid)); 353 418 } 354 419 355 if (opt & OPT_u) {356 xget_uidgid(&ugid, set_user);357 }358 359 420 if (opt & OPT_root) { 360 xchdir(root); 361 xchroot("."); 421 xchroot(root); 362 422 } 363 423 -
branches/3.2/mindi-busybox/runit/runsv.c
r2725 r3232 28 28 /* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */ 29 29 /* TODO: depends on runit_lib.c - review and reduce/eliminate */ 30 31 //usage:#define runsv_trivial_usage 32 //usage: "DIR" 33 //usage:#define runsv_full_usage "\n\n" 34 //usage: "Start and monitor a service and optionally an appendant log service" 30 35 31 36 #include <sys/poll.h> … … 140 145 } 141 146 142 /* libbb candidate */143 static char *bb_stpcpy(char *p, const char *to_add)144 {145 while ((*p = *to_add) != '\0') {146 p++;147 to_add++;148 }149 return p;150 }151 152 147 static int open_trunc_or_warn(const char *name) 153 148 { … … 178 173 close(fd); 179 174 if (rename_or_warn("supervise/pid.new", 180 175 s->islog ? "log/supervise/pid" : "log/supervise/pid"+4)) 181 176 return; 182 177 pidchanged = 0; … … 193 188 switch (s->state) { 194 189 case S_DOWN: 195 p = bb_stpcpy(p, "down");190 p = stpcpy(p, "down"); 196 191 break; 197 192 case S_RUN: 198 p = bb_stpcpy(p, "run");193 p = stpcpy(p, "run"); 199 194 break; 200 195 case S_FINISH: 201 p = bb_stpcpy(p, "finish");196 p = stpcpy(p, "finish"); 202 197 break; 203 198 } 204 199 if (s->ctrl & C_PAUSE) 205 p = bb_stpcpy(p, ", paused");200 p = stpcpy(p, ", paused"); 206 201 if (s->ctrl & C_TERM) 207 p = bb_stpcpy(p, ", got TERM");202 p = stpcpy(p, ", got TERM"); 208 203 if (s->state != S_DOWN) 209 204 switch (s->sd_want) { 210 205 case W_DOWN: 211 p = bb_stpcpy(p, ", want down");206 p = stpcpy(p, ", want down"); 212 207 break; 213 208 case W_EXIT: 214 p = bb_stpcpy(p, ", want exit");209 p = stpcpy(p, ", want exit"); 215 210 break; 216 211 } -
branches/3.2/mindi-busybox/runit/runsvdir.c
r2725 r3232 29 29 /* TODO: depends on runit_lib.c - review and reduce/eliminate */ 30 30 31 //usage:#define runsvdir_trivial_usage 32 //usage: "[-P] [-s SCRIPT] DIR" 33 //usage:#define runsvdir_full_usage "\n\n" 34 //usage: "Start a runsv process for each subdirectory. If it exits, restart it.\n" 35 //usage: "\n -P Put each runsv in a new session" 36 //usage: "\n -s SCRIPT Run SCRIPT <signo> after signal is processed" 37 31 38 #include <sys/poll.h> 32 39 #include <sys/file.h> … … 69 76 #define pfd (G.pfd ) 70 77 #define stamplog (G.stamplog ) 71 #define INIT_G() do { \ 72 } while (0) 78 #define INIT_G() do { } while (0) 73 79 74 80 static void fatal2_cannot(const char *m1, const char *m2) -
branches/3.2/mindi-busybox/runit/sv.c
r2725 r3232 154 154 /* TODO: depends on runit_lib.c - review and reduce/eliminate */ 155 155 156 //usage:#define sv_trivial_usage 157 //usage: "[-v] [-w SEC] CMD SERVICE_DIR..." 158 //usage:#define sv_full_usage "\n\n" 159 //usage: "Control services monitored by runsv supervisor.\n" 160 //usage: "Commands (only first character is enough):\n" 161 //usage: "\n" 162 //usage: "status: query service status\n" 163 //usage: "up: if service isn't running, start it. If service stops, restart it\n" 164 //usage: "once: like 'up', but if service stops, don't restart it\n" 165 //usage: "down: send TERM and CONT signals. If ./run exits, start ./finish\n" 166 //usage: " if it exists. After it stops, don't restart service\n" 167 //usage: "exit: send TERM and CONT signals to service and log service. If they exit,\n" 168 //usage: " runsv exits too\n" 169 //usage: "pause, cont, hup, alarm, interrupt, quit, 1, 2, term, kill: send\n" 170 //usage: "STOP, CONT, HUP, ALRM, INT, QUIT, USR1, USR2, TERM, KILL signal to service" 171 156 172 #include <sys/poll.h> 157 173 #include <sys/file.h> … … 422 438 int sv_main(int argc UNUSED_PARAM, char **argv) 423 439 { 424 unsigned opt;425 440 char *x; 426 441 char *action; … … 443 458 444 459 opt_complementary = "w+:vv"; /* -w N, -v is a counter */ 445 opt =getopt32(argv, "w:v", &waitsec, &verbose);460 getopt32(argv, "w:v", &waitsec, &verbose); 446 461 argv += optind; 447 462 action = *argv++; -
branches/3.2/mindi-busybox/runit/svlogd.c
r2725 r3232 126 126 */ 127 127 128 //usage:#define svlogd_trivial_usage 129 //usage: "[-ttv] [-r C] [-R CHARS] [-l MATCHLEN] [-b BUFLEN] DIR..." 130 //usage:#define svlogd_full_usage "\n\n" 131 //usage: "Continuously read log data from stdin and write to rotated log files in DIRs" 132 //usage: "\n" 133 //usage: "\n""DIR/config file modifies behavior:" 134 //usage: "\n""sSIZE - when to rotate logs" 135 //usage: "\n""nNUM - number of files to retain" 136 /*usage: "\n""NNUM - min number files to retain" - confusing */ 137 /*usage: "\n""tSEC - rotate file if it get SEC seconds old" - confusing */ 138 //usage: "\n""!PROG - process rotated log with PROG" 139 /*usage: "\n""uIPADDR - send log over UDP" - unsupported */ 140 /*usage: "\n""UIPADDR - send log over UDP and DONT log" - unsupported */ 141 /*usage: "\n""pPFX - prefix each line with PFX" - unsupported */ 142 //usage: "\n""+,-PATTERN - (de)select line for logging" 143 //usage: "\n""E,ePATTERN - (de)select line for stderr" 144 128 145 #include <sys/poll.h> 129 146 #include <sys/file.h> … … 171 188 172 189 void* (*memRchr)(const void *, int, size_t); 190 char *shell; 173 191 174 192 smallint exitasap; … … 366 384 sv_ch = ld->fnsave[26]; 367 385 386 if (!G.shell) 387 G.shell = xstrdup(get_shell_name()); 388 368 389 while ((pid = vfork()) == -1) 369 390 pause2cannot("vfork for processor", ld->name); … … 400 421 xmove_fd(fd, 5); 401 422 402 // getenv("SHELL")? 403 execl(DEFAULT_SHELL, DEFAULT_SHELL_SHORT_NAME, "-c", ld->processor, (char*) NULL); 423 execl(G.shell, G.shell, "-c", ld->processor, (char*) NULL); 404 424 bb_perror_msg_and_die(FATAL"can't %s processor %s", "run", ld->name); 405 425 } … … 582 602 while (fchdir(ld->fddir) == -1) 583 603 pause2cannot("change directory, want remove old logfile", 584 604 ld->name); 585 605 oldest[0] = 'A'; 586 606 oldest[1] = oldest[27] = '\0'; 587 607 while (!(d = opendir("."))) 588 608 pause2cannot("open directory, want remove old logfile", 589 609 ld->name); 590 610 errno = 0; 591 611 while ((f = readdir(d)))
Note:
See TracChangeset
for help on using the changeset viewer.