logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

runtool.8 (8602B)


  1. .\" runtool.8
  2. .\" wcm, 2009.12.11 - 2009.12.15
  3. .\" ===
  4. .TH runtool 8 "January 2013" "runtools-2.07" "runtools"
  5. .SH NAME
  6. runtool \- run a program in a configured process environment
  7. .SH SYNOPSIS
  8. .B runtool [\-hV] [\-0
  9. .I argv0\c
  10. .B ] [\<\-a | \-A>
  11. .I argfile\c
  12. .B ] [\-c
  13. .I chdir\c
  14. .B ] [\-C
  15. .I chroot\c
  16. .B ] [\-d] [<\-e | \-E>
  17. .I envfile\c
  18. .B ] [\-F
  19. .I fdset\c
  20. .B ] [\-L [:]\c
  21. .I lockfile
  22. .B | \-P [:]\c
  23. .I pidlock\c
  24. .B ] [\-m
  25. .I umask\c
  26. .B ] [\-R <a|c|d|f|m|o|p|r|s|t>=<\c
  27. .I num\c
  28. .B |!>[:\c
  29. .I ...\c
  30. .B ]] [\- s] [\-S
  31. .I altpath\c
  32. .B ] [\-u
  33. .I user\c
  34. .B ] [\-U
  35. .I user\c
  36. .B ] [\-W] [\-z
  37. .I secs\c
  38. .B ]
  39. .I program
  40. .B [
  41. .I args ...\c
  42. .B ]
  43. .SH DESCRIPTION
  44. .B runtool
  45. modifies a process environment according to its options,
  46. then runs
  47. .I program
  48. with any additional
  49. .IR args .
  50. .PP
  51. If
  52. .I program
  53. does not contain a ``/'' slash character,
  54. .B runtool
  55. will perform a shell-like search for the executable using the
  56. .B PATH
  57. variable in the current environment.
  58. .SH OPTIONS
  59. .B runtool
  60. combines the functions of several individual
  61. .BR runtools_intro (8)
  62. into a single utility.
  63. The corresponding utility is noted in each option description,
  64. and may be referenced there for more complete information.
  65. .TP
  66. .B \-0 argv0
  67. .BR runargv0 (8).
  68. Sets up
  69. .I program
  70. to run with an argv[0] of
  71. .IR argv0 .
  72. .TP
  73. .B <\-a|\-A> argfile
  74. .BR runargs (8).
  75. Runs
  76. .I program
  77. with arguments specified in
  78. .IR argfile .
  79. The
  80. .B \-a
  81. form of the option sets up any arguments taken from
  82. .I argfile
  83. to preceed any arguments given by
  84. .IR args .
  85. The
  86. .B \-A
  87. form of the option inverts this order,
  88. so that any options taken from
  89. .I argfile
  90. will follow any arguments given by
  91. .IR args .
  92. .TP
  93. .B \-c chdir
  94. .BR chdir (2).
  95. Changes the current working directory to
  96. .I chdir
  97. before running
  98. .IR program .
  99. .TP
  100. .B \-C chroot
  101. .BR chroot (2).
  102. Sets up the root directory to
  103. .I chroot
  104. before running
  105. .IR program .
  106. .TP
  107. .B \-d
  108. .BR rundetach (8).
  109. Detaches from the controlling terminal to run
  110. .I program
  111. in the background.
  112. .TP
  113. .B <\-e|\-E> envfile
  114. .BR runenv (8).
  115. Sets up the environmental variables in the process of
  116. .I program
  117. according to definitions in
  118. .IR envfile .
  119. The
  120. .B \-e
  121. form of the option merges any variables defined in
  122. .I envfile
  123. with the existing environment.
  124. The
  125. .B \-E
  126. form of the option defines the new environment exclusively according to
  127. .I envfile
  128. and ignores any existing environment.
  129. As with
  130. .BR runenv (8),
  131. the argument
  132. .I envfile
  133. may be either a file or a directory.
  134. .PP
  135. .B \-F fdset
  136. .RS
  137. Sets up file descriptors according to the specification
  138. .IR fdset ,
  139. given as a single contiguous string in the form:
  140. .PP
  141. .RS
  142. <fd> <op> <target> [: ...]
  143. .RE
  144. .PP
  145. Where:
  146. .TP
  147. .IR fd :
  148. single ascii file descriptor numeral, 0..9
  149. .TP
  150. .IR op :
  151. a single character from the set `<', `>', '+', or '='
  152. .TP
  153. .IR target :
  154. Depends on
  155. .I op
  156. as follows:
  157. If
  158. .I op
  159. is redirection operator '<', `>', or '+',
  160. .I target
  161. is an absolute pathname (must begin with `/'),
  162. or the special character `%'.
  163. Otherwise, if
  164. .I op
  165. is the duplication operator '=',
  166. .I target
  167. is a single ascii file descriptor numeral, 0..9,
  168. or the special character '!'.
  169. .PP
  170. The operator character `<'
  171. is used to specify redirection of input to
  172. .I fd
  173. from the file argument given in
  174. .IR target .
  175. The operator characters `>' and `+'
  176. are used to specify redirection of output from
  177. .I fd
  178. to the file argument given by
  179. .IR target .
  180. The `>' redirection causes
  181. .I target
  182. to be overwritten,
  183. while the `+' operator appends to any
  184. .I target
  185. that may already exist.
  186. The special
  187. .I target
  188. character `%'
  189. may be used as shorthand to represent the file
  190. .I /dev/null
  191. for either input or output redirection.
  192. .PP
  193. The operator character `='
  194. is used to specify duplication of the file descriptor given in
  195. .I fd
  196. to the file descriptor given in
  197. .IR target .
  198. The special
  199. .I target
  200. character `!'
  201. is used to close the file descriptor given in
  202. .IR fd .
  203. .PP
  204. Normally the
  205. .I fdset
  206. argument string will be enclosed in quotes to protect it from shell processing.
  207. .RE
  208. .TP
  209. .B \-L [:]lockfile
  210. .BR runlock (8).
  211. Sets up a
  212. .I lockfile
  213. before running
  214. .IR program .
  215. If the name of the
  216. .I lockfile
  217. is prefixed by the `:' character,
  218. .B runtool
  219. will block until a lock can be acquired.
  220. Otherwise,
  221. .B runtool
  222. will exit immediately if an existing lock is found on the
  223. .IR lockfile .
  224. To write the pid of the process into
  225. .IR lockfile ,
  226. use the
  227. .B \-P
  228. option instead.
  229. .TP
  230. .B \-m umask
  231. .BR umask (2).
  232. Sets up the file creation mask for
  233. .IR program .
  234. .TP
  235. .B \-P [:]pidlock
  236. .BR runlock (8).
  237. Same as the description for the
  238. .B \-L
  239. option,
  240. except that the pid for the process is written into the lock file
  241. .IR pidlock .
  242. .PP
  243. .B \-R rlims
  244. .RS
  245. .BR runlimit (8).
  246. Sets up the soft resource limits for
  247. .I program
  248. where
  249. .I rlims
  250. is given as a single contiguous string in the form:
  251. .PP
  252. .RS
  253. <rlim> = <value> [: ...]
  254. .RE
  255. .PP
  256. Where:
  257. .TP
  258. .IR rlim :
  259. single character in the set
  260. `a', `c', `d', `f', `m', `o', `p', `r', `s', or `t'.
  261. .TP
  262. .RI ` = ':
  263. the literal character `='.
  264. .TP
  265. .IR value :
  266. A positive numeric value for the resource limit,
  267. or the special character `!' used to specify ``unlimited'',
  268. that is, sets the soft limit equal to the current hard limit.
  269. .PP
  270. The
  271. .I rlim
  272. arguments and their meanings are described in the
  273. .BR runlimit (8)
  274. manual.
  275. Multiple rlimit specifications may be concatenated with the `:' character.
  276. Normally the
  277. .I rlims
  278. argument string will be enclosed in quotes to protect it from shell processing.
  279. .RE
  280. .TP
  281. .B \-s
  282. .BR runsession (8).
  283. Runs
  284. .I program
  285. in a separate session and new process group.
  286. .TP
  287. .B \-S altpath
  288. .B runtool
  289. will use a PATH-like string given in
  290. .I altpath
  291. to search for the executable
  292. .IR program ,
  293. rather than within the PATH variable.
  294. The
  295. .I altpath
  296. is only used to search for
  297. .IR program ,
  298. and does not affect any PATH variable that may already be set,
  299. nor does
  300. .I altpath
  301. persist in the environment of
  302. .IR program .
  303. .TP
  304. .B \-u user
  305. .BR runuid (8).
  306. Sets up
  307. .I program
  308. to run as the user-id and group-id of the system account given by
  309. .IR user .
  310. .TP
  311. .B \-U user
  312. .BR runenv (8).
  313. Sets up the two variables UID and GID in the environment of
  314. .I program
  315. with the user-id and group-id of the system account given by
  316. .IR user .
  317. IMPORTANT:
  318. This option does not, by itself, change the permissions with which
  319. .I program
  320. runs.
  321. It only sets up a couple of environmental variables that some programs
  322. may use to subsequently change their own permissions.
  323. .TP
  324. .B \-z secs
  325. .BR runpause (8).
  326. Sleep for
  327. .I secs
  328. seconds, or until interrrupted by a signal,
  329. before running
  330. .IR program .
  331. An argument of 0 will cause
  332. .B runtool
  333. to pause indefinitely, or until interrupted by a signal,
  334. before running
  335. .IR program .
  336. .PP
  337. .B runtool
  338. also provides the following standard
  339. .BR runtools_intro (8)
  340. options:
  341. .TP
  342. .B \-h
  343. Help.
  344. Print a brief usage message to stderr and exit.
  345. .TP
  346. .B \-V
  347. Version.
  348. Print the version number to stderr and exit.
  349. .SH OPERATING SEQUENCE
  350. The order in which
  351. .B runtool
  352. applies its operations is independent of the order in which the options are given
  353. on the command line.
  354. The sequence that
  355. .B runtool
  356. takes is:
  357. .IP \(bu 4
  358. process
  359. .I argfile
  360. and
  361. .I argv0
  362. .IP \(bu 4
  363. process
  364. .I envfile
  365. .IP \(bu 4
  366. process
  367. .B \-U
  368. .I user
  369. .IP \(bu 4
  370. detach
  371. .IP \(bu 4
  372. setsid
  373. .IP \(bu 4
  374. acquire lockfile/pidlock
  375. .IP \(bu 4
  376. set umask
  377. .IP \(bu 4
  378. setup file descriptors according to
  379. .I fdset
  380. .IP \(bu 4
  381. setup resource limits
  382. .IP \(bu 4
  383. chdir
  384. .IP \(bu 4
  385. chroot
  386. .IP \(bu 4
  387. setuid
  388. .IP \(bu 4
  389. sleep
  390. .IP \(bu 4
  391. finally execute
  392. .I program
  393. .PP
  394. When necessary to achieve a different sequence of operations,
  395. more than one
  396. .B runtool
  397. invocation may be combined in an exec chain, and/or
  398. combined in an exec chain with one or more of the other purpose-specific utilities
  399. of the
  400. .BR runtools_intro (8)
  401. suite.
  402. .SH EXIT STATUS
  403. .B runtool
  404. exits with one of the following values:
  405. .TP
  406. 0
  407. .I program
  408. was invoked and completed successfully.
  409. In this case,
  410. the exit code is returned by the
  411. .IR program ,
  412. rather than by
  413. .B runtool
  414. itself.
  415. .TP
  416. 100
  417. .B runtool
  418. failed because of a usage error,
  419. such as an invalid command\-line option or argument.
  420. In this case,
  421. .B runtool
  422. prints a brief error message and usage help to stderr on exit.
  423. .TP
  424. 111
  425. .B runtool
  426. failed due to some system or resource error.
  427. In this case,
  428. .B runtool
  429. prints a brief diagnostic message to stderr on exit.
  430. .TP
  431. 1\-127
  432. .I program
  433. was invoked and failed with its own non-zero exit status.
  434. .SH AUTHOR
  435. Wayne Marshall, http://b0llix.net/perp/
  436. .SH SEE ALSO
  437. .nh
  438. .BR runtools_intro (8),
  439. .BR runargs (8),
  440. .BR runargv0 (8),
  441. .BR runchoom (8),
  442. .BR rundetach (8),
  443. .BR rundeux (8),
  444. .BR runenv (8),
  445. .BR runfile (8),
  446. .BR runlimit (8),
  447. .BR runlock (8),
  448. .BR runpause (8),
  449. .BR runsession (8),
  450. .BR runtrap (8),
  451. .BR runuid (8)
  452. .\" EOF