Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/runit/chpst.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 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
Note:
See TracChangeset
for help on using the changeset viewer.