konfd.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. /*
  2. * konfd.c
  3. *
  4. * The konfd daemon to store user configuration commands.
  5. *
  6. */
  7. #ifdef HAVE_CONFIG_H
  8. #include "config.h"
  9. #endif /* HAVE_CONFIG_H */
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <unistd.h>
  13. #include <sys/types.h>
  14. #include <sys/stat.h>
  15. #include <fcntl.h>
  16. #include <sys/wait.h>
  17. #include <errno.h>
  18. #include <assert.h>
  19. #include <sys/socket.h>
  20. #include <sys/un.h>
  21. #include <string.h>
  22. #include <sys/select.h>
  23. #include <signal.h>
  24. #include <syslog.h>
  25. #if WITH_INTERNAL_GETOPT
  26. #include "libc/getopt.h"
  27. #else
  28. #ifdef HAVE_GETOPT_H
  29. #include <getopt.h>
  30. #endif
  31. #endif
  32. #ifdef HAVE_PWD_H
  33. #include <pwd.h>
  34. #endif
  35. #ifdef HAVE_GRP_H
  36. #include <grp.h>
  37. #endif
  38. #include "clish/internal.h"
  39. #include "konf/tree.h"
  40. #include "konf/query.h"
  41. #include "konf/buf.h"
  42. #include "lub/argv.h"
  43. #include "lub/string.h"
  44. #include "lub/log.h"
  45. #ifndef VERSION
  46. #define VERSION 1.2.2
  47. #endif
  48. #define QUOTE(t) #t
  49. #define version(v) printf("%s\n", v)
  50. #define KONFD_PIDFILE "/var/run/konfd.pid"
  51. /* UNIX socket path */
  52. /* Don't use UNIX_PATH_MAX due to portability issues */
  53. #define USOCK_PATH_MAX sizeof(((struct sockaddr_un *)0)->sun_path)
  54. /* OpenBSD has no MSG_NOSIGNAL flag */
  55. #ifndef MSG_NOSIGNAL
  56. #define MSG_NOSIGNAL 0
  57. #endif
  58. /* Global signal vars */
  59. static volatile int sigterm = 0;
  60. static void sighandler(int signo);
  61. static void help(int status, const char *argv0);
  62. static char * process_query(int sock, konf_tree_t * conf, char *str);
  63. int answer_send(int sock, char *command);
  64. static int dump_running_config(int sock, konf_tree_t *conf, konf_query_t *query);
  65. int daemonize(int nochdir, int noclose);
  66. struct options *opts_init(void);
  67. void opts_free(struct options *opts);
  68. static int opts_parse(int argc, char *argv[], struct options *opts);
  69. /* Command line options */
  70. struct options {
  71. char *socket_path;
  72. char *pidfile;
  73. char *chroot;
  74. int debug; /* Don't daemonize in debug mode */
  75. uid_t uid;
  76. gid_t gid;
  77. int log_facility;
  78. };
  79. /*--------------------------------------------------------- */
  80. int main(int argc, char **argv)
  81. {
  82. int retval = -1;
  83. int i;
  84. char *str;
  85. konf_tree_t *conf;
  86. lub_bintree_t bufs;
  87. konf_buf_t *tbuf;
  88. struct options *opts = NULL;
  89. int pidfd = -1;
  90. /* Network vars */
  91. int sock = -1;
  92. struct sockaddr_un laddr;
  93. struct sockaddr_un raddr;
  94. fd_set active_fd_set, read_fd_set;
  95. const int reuseaddr = 1;
  96. /* Signal vars */
  97. struct sigaction sig_act, sigpipe_act;
  98. sigset_t sig_set, sigpipe_set;
  99. /* Parse command line options */
  100. opts = opts_init();
  101. if (opts_parse(argc, argv, opts))
  102. goto err;
  103. /* Initialize syslog */
  104. openlog(argv[0], LOG_CONS, opts->log_facility);
  105. syslog(LOG_ERR, "Start daemon.\n");
  106. /* Fork the daemon */
  107. if (!opts->debug) {
  108. /* Daemonize */
  109. if (daemonize(0, 0) < 0) {
  110. syslog(LOG_ERR, "Can't daemonize\n");
  111. goto err;
  112. }
  113. /* Write pidfile */
  114. if ((pidfd = open(opts->pidfile,
  115. O_WRONLY | O_CREAT | O_EXCL | O_TRUNC,
  116. S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) {
  117. syslog(LOG_WARNING, "Can't open pidfile %s: %s",
  118. opts->pidfile, strerror(errno));
  119. } else {
  120. char str[20];
  121. snprintf(str, sizeof(str), "%u\n", getpid());
  122. if (write(pidfd, str, strlen(str)) < 0)
  123. syslog(LOG_WARNING, "Can't write to %s: %s",
  124. opts->pidfile, strerror(errno));
  125. close(pidfd);
  126. }
  127. }
  128. /* Create listen socket */
  129. if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
  130. syslog(LOG_ERR, "Can't create listen socket: %s\n",
  131. strerror(errno));
  132. goto err;
  133. }
  134. if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
  135. &reuseaddr, sizeof(reuseaddr))) {
  136. syslog(LOG_ERR, "Can't set socket options: %s\n", strerror(errno));
  137. goto err;
  138. }
  139. laddr.sun_family = AF_UNIX;
  140. strncpy(laddr.sun_path, opts->socket_path, USOCK_PATH_MAX);
  141. laddr.sun_path[USOCK_PATH_MAX - 1] = '\0';
  142. if (bind(sock, (struct sockaddr *)&laddr, sizeof(laddr))) {
  143. syslog(LOG_ERR, "Can't bind socket: %s\n",
  144. strerror(errno));
  145. goto err;
  146. }
  147. if (chown(opts->socket_path, opts->uid, opts->gid)) {
  148. syslog(LOG_ERR, "Can't chown UNIX socket: %s\n",
  149. strerror(errno));
  150. goto err;
  151. }
  152. listen(sock, 5);
  153. /* Change GID */
  154. if (opts->gid != getgid()) {
  155. if (setgid(opts->gid)) {
  156. syslog(LOG_ERR, "Can't set GID to %u: %s",
  157. opts->gid, strerror(errno));
  158. goto err;
  159. }
  160. }
  161. #ifdef HAVE_CHROOT
  162. /* Chroot */
  163. if (opts->chroot) {
  164. if (chroot(opts->chroot) < 0) {
  165. syslog(LOG_ERR, "Can't chroot to %s: %s",
  166. opts->chroot, strerror(errno));
  167. goto err;
  168. }
  169. }
  170. #endif
  171. /* Change UID */
  172. if (opts->uid != getuid()) {
  173. if (setuid(opts->uid)) {
  174. syslog(LOG_ERR, "Can't set UID to %u: %s",
  175. opts->uid, strerror(errno));
  176. goto err;
  177. }
  178. }
  179. /* Create configuration tree */
  180. conf = konf_tree_new("", 0);
  181. /* Initialize the tree of buffers */
  182. lub_bintree_init(&bufs,
  183. konf_buf_bt_offset(),
  184. konf_buf_bt_compare, konf_buf_bt_getkey);
  185. /* Set signal handler */
  186. sigemptyset(&sig_set);
  187. sigaddset(&sig_set, SIGTERM);
  188. sigaddset(&sig_set, SIGINT);
  189. sigaddset(&sig_set, SIGQUIT);
  190. sig_act.sa_flags = 0;
  191. sig_act.sa_mask = sig_set;
  192. sig_act.sa_handler = &sighandler;
  193. sigaction(SIGTERM, &sig_act, NULL);
  194. sigaction(SIGINT, &sig_act, NULL);
  195. sigaction(SIGQUIT, &sig_act, NULL);
  196. /* Ignore SIGPIPE */
  197. sigemptyset(&sigpipe_set);
  198. sigaddset(&sigpipe_set, SIGPIPE);
  199. sigpipe_act.sa_flags = 0;
  200. sigpipe_act.sa_mask = sigpipe_set;
  201. sigpipe_act.sa_handler = SIG_IGN;
  202. sigaction(SIGPIPE, &sigpipe_act, NULL);
  203. /* Initialize the set of active sockets. */
  204. FD_ZERO(&active_fd_set);
  205. FD_SET(sock, &active_fd_set);
  206. /* Main loop */
  207. while (!sigterm) {
  208. int num;
  209. /* Block until input arrives on one or more active sockets. */
  210. read_fd_set = active_fd_set;
  211. num = select(FD_SETSIZE, &read_fd_set, NULL, NULL, NULL);
  212. if (num < 0) {
  213. if (EINTR == errno)
  214. continue;
  215. break;
  216. }
  217. if (0 == num)
  218. continue;
  219. /* Service all the sockets with input pending. */
  220. for (i = 0; i < FD_SETSIZE; ++i) {
  221. if (!FD_ISSET(i, &read_fd_set))
  222. continue;
  223. if (i == sock) {
  224. /* Connection request on listen socket. */
  225. int new;
  226. socklen_t size = sizeof(raddr);
  227. new = accept(sock,
  228. (struct sockaddr *)&raddr, &size);
  229. if (new < 0) {
  230. fprintf(stderr, "accept");
  231. continue;
  232. }
  233. #ifdef DEBUG
  234. fprintf(stderr, "Connection established %u\n", new);
  235. #endif
  236. konf_buftree_remove(&bufs, new);
  237. tbuf = konf_buf_new(new);
  238. /* insert it into the binary tree for this conf */
  239. lub_bintree_insert(&bufs, tbuf);
  240. FD_SET(new, &active_fd_set);
  241. } else {
  242. int nbytes;
  243. /* Data arriving on an already-connected socket. */
  244. if ((nbytes = konf_buftree_read(&bufs, i)) <= 0) {
  245. close(i);
  246. FD_CLR(i, &active_fd_set);
  247. konf_buftree_remove(&bufs, i);
  248. continue;
  249. }
  250. while ((str = konf_buftree_parse(&bufs, i))) {
  251. char *answer;
  252. if (!(answer = process_query(i, conf, str)))
  253. answer = strdup("-e");
  254. free(str);
  255. answer_send(i, answer);
  256. free(answer);
  257. }
  258. }
  259. }
  260. }
  261. /* Free resources */
  262. konf_tree_delete(conf);
  263. /* delete each buf */
  264. while ((tbuf = lub_bintree_findfirst(&bufs))) {
  265. /* remove the buf from the tree */
  266. lub_bintree_remove(&bufs, tbuf);
  267. /* release the instance */
  268. konf_buf_delete(tbuf);
  269. }
  270. retval = 0;
  271. err:
  272. /* Close listen socket */
  273. if (sock >= 0) {
  274. close(sock);
  275. unlink(opts->socket_path);
  276. }
  277. /* Remove pidfile */
  278. if (pidfd >= 0) {
  279. if (unlink(opts->pidfile) < 0) {
  280. syslog(LOG_ERR, "Can't remove pid-file %s: %s\n",
  281. opts->pidfile, strerror(errno));
  282. }
  283. }
  284. /* Free command line options */
  285. opts_free(opts);
  286. syslog(LOG_ERR, "Stop daemon.\n");
  287. return retval;
  288. }
  289. /*--------------------------------------------------------- */
  290. static char * process_query(int sock, konf_tree_t * conf, char *str)
  291. {
  292. int i;
  293. int res;
  294. konf_tree_t *iconf;
  295. konf_tree_t *tmpconf;
  296. konf_query_t *query;
  297. char *retval = NULL;
  298. konf_query_op_t ret = KONF_QUERY_OP_ERROR;
  299. #ifdef DEBUG
  300. fprintf(stderr, "----------------------\n");
  301. fprintf(stderr, "REQUEST: %s\n", str);
  302. #endif
  303. /* Parse query */
  304. query = konf_query_new();
  305. res = konf_query_parse_str(query, str);
  306. if (res < 0) {
  307. konf_query_free(query);
  308. return NULL;
  309. }
  310. #ifdef DEBUG
  311. konf_query_dump(query);
  312. #endif
  313. /* Go through the pwd */
  314. iconf = conf;
  315. for (i = 0; i < konf_query__get_pwdc(query); i++) {
  316. if (!(iconf = konf_tree_find_conf(iconf,
  317. konf_query__get_pwd(query, i), 0, 0))) {
  318. iconf = NULL;
  319. break;
  320. }
  321. }
  322. if (!iconf) {
  323. fprintf(stderr, "Unknown path\n");
  324. konf_query_free(query);
  325. return NULL;
  326. }
  327. switch (konf_query__get_op(query)) {
  328. case KONF_QUERY_OP_SET:
  329. if (konf_query__get_unique(query)) {
  330. int exist = 0;
  331. exist = konf_tree_del_pattern(iconf,
  332. konf_query__get_line(query),
  333. konf_query__get_unique(query),
  334. konf_query__get_pattern(query),
  335. konf_query__get_priority(query),
  336. konf_query__get_seq(query),
  337. konf_query__get_seq_num(query));
  338. if (exist < 0)
  339. break;
  340. if (exist > 0) {
  341. ret = KONF_QUERY_OP_OK;
  342. break;
  343. }
  344. }
  345. tmpconf = konf_tree_new_conf(iconf,
  346. konf_query__get_line(query), konf_query__get_priority(query),
  347. konf_query__get_seq(query), konf_query__get_seq_num(query));
  348. if (!tmpconf)
  349. break;
  350. konf_tree__set_splitter(tmpconf, konf_query__get_splitter(query));
  351. konf_tree__set_depth(tmpconf, konf_query__get_pwdc(query));
  352. ret = KONF_QUERY_OP_OK;
  353. break;
  354. case KONF_QUERY_OP_UNSET:
  355. if (konf_tree_del_pattern(iconf,
  356. NULL,
  357. BOOL_TRUE,
  358. konf_query__get_pattern(query),
  359. konf_query__get_priority(query),
  360. konf_query__get_seq(query),
  361. konf_query__get_seq_num(query)) < 0)
  362. break;
  363. ret = KONF_QUERY_OP_OK;
  364. break;
  365. case KONF_QUERY_OP_DUMP:
  366. if (dump_running_config(sock, iconf, query))
  367. break;
  368. ret = KONF_QUERY_OP_OK;
  369. break;
  370. default:
  371. break;
  372. }
  373. #ifdef DEBUG
  374. /* Print whole tree */
  375. konf_tree_fprintf(conf, stderr, NULL, -1, -1, BOOL_TRUE, 0);
  376. #endif
  377. /* Free resources */
  378. konf_query_free(query);
  379. switch (ret) {
  380. case KONF_QUERY_OP_OK:
  381. lub_string_cat(&retval, "-o");
  382. break;
  383. case KONF_QUERY_OP_ERROR:
  384. lub_string_cat(&retval, "-e");
  385. break;
  386. default:
  387. lub_string_cat(&retval, "-e");
  388. break;
  389. };
  390. #ifdef DEBUG
  391. fprintf(stderr, "ANSWER: %s\n", retval);
  392. #endif
  393. return retval;
  394. }
  395. /*--------------------------------------------------------- */
  396. /*
  397. * Signal handler for temination signals (like SIGTERM, SIGINT, ...)
  398. */
  399. static void sighandler(int signo)
  400. {
  401. sigterm = 1;
  402. signo = signo; /* Happy compiler */
  403. }
  404. /*--------------------------------------------------------- */
  405. int answer_send(int sock, char *command)
  406. {
  407. return send(sock, command, strlen(command) + 1, MSG_NOSIGNAL);
  408. }
  409. /*--------------------------------------------------------- */
  410. static int dump_running_config(int sock, konf_tree_t *conf, konf_query_t *query)
  411. {
  412. FILE *fd;
  413. char *filename;
  414. int dupsock = -1;
  415. if ((filename = konf_query__get_path(query))) {
  416. if (!(fd = fopen(filename, "w")))
  417. return -1;
  418. } else {
  419. if ((dupsock = dup(sock)) < 0)
  420. return -1;
  421. fd = fdopen(dupsock, "w");
  422. }
  423. if (!filename) {
  424. fprintf(fd, "-t\n");
  425. #ifdef DEBUG
  426. fprintf(stderr, "ANSWER: -t\n");
  427. #endif
  428. }
  429. konf_tree_fprintf(conf,
  430. fd,
  431. konf_query__get_pattern(query),
  432. konf_query__get_pwdc(query) - 1,
  433. konf_query__get_depth(query),
  434. konf_query__get_seq(query),
  435. 0);
  436. if (!filename) {
  437. fprintf(fd, "\n");
  438. #ifdef DEBUG
  439. fprintf(stderr, "SEND DATA: \n");
  440. #endif
  441. }
  442. fclose(fd);
  443. return 0;
  444. }
  445. /*--------------------------------------------------------- */
  446. /* Implement own simple daemon() to don't use Non-POSIX */
  447. int daemonize(int nochdir, int noclose)
  448. {
  449. int fd;
  450. int pid;
  451. pid = fork();
  452. if (-1 == pid)
  453. return -1;
  454. if (pid > 0)
  455. _exit(0); /* Exit parent */
  456. if (setsid() == -1)
  457. return -1;
  458. if (!nochdir) {
  459. if (chdir("/"))
  460. return -1;
  461. }
  462. if (!noclose) {
  463. fd = open("/dev/null", O_RDWR, 0);
  464. if (fd < 0)
  465. return -1;
  466. dup2(fd, STDIN_FILENO);
  467. dup2(fd, STDOUT_FILENO);
  468. dup2(fd, STDERR_FILENO);
  469. if (fd > 2)
  470. close(fd);
  471. }
  472. return 0;
  473. }
  474. /*--------------------------------------------------------- */
  475. /* Initialize option structure by defaults */
  476. struct options *opts_init(void)
  477. {
  478. struct options *opts = NULL;
  479. opts = malloc(sizeof(*opts));
  480. assert(opts);
  481. opts->debug = 0; /* daemonize by default */
  482. opts->socket_path = strdup(KONFD_SOCKET_PATH);
  483. opts->pidfile = strdup(KONFD_PIDFILE);
  484. opts->chroot = NULL;
  485. opts->uid = getuid();
  486. opts->gid = getgid();
  487. opts->log_facility = LOG_DAEMON;
  488. return opts;
  489. }
  490. /*--------------------------------------------------------- */
  491. /* Free option structure */
  492. void opts_free(struct options *opts)
  493. {
  494. if (opts->socket_path)
  495. free(opts->socket_path);
  496. if (opts->pidfile)
  497. free(opts->pidfile);
  498. if (opts->chroot)
  499. free(opts->chroot);
  500. free(opts);
  501. }
  502. /*--------------------------------------------------------- */
  503. /* Parse command line options */
  504. static int opts_parse(int argc, char *argv[], struct options *opts)
  505. {
  506. static const char *shortopts = "hvs:p:u:g:dr:O:";
  507. #ifdef HAVE_GETOPT_LONG
  508. static const struct option longopts[] = {
  509. {"help", 0, NULL, 'h'},
  510. {"version", 0, NULL, 'v'},
  511. {"socket", 1, NULL, 's'},
  512. {"pid", 1, NULL, 'p'},
  513. {"user", 1, NULL, 'u'},
  514. {"group", 1, NULL, 'g'},
  515. {"debug", 0, NULL, 'd'},
  516. {"chroot", 1, NULL, 'r'},
  517. {"facility", 1, NULL, 'O'},
  518. {NULL, 0, NULL, 0}
  519. };
  520. #endif
  521. optind = 1;
  522. while(1) {
  523. int opt;
  524. #ifdef HAVE_GETOPT_LONG
  525. opt = getopt_long(argc, argv, shortopts, longopts, NULL);
  526. #else
  527. opt = getopt(argc, argv, shortopts);
  528. #endif
  529. if (-1 == opt)
  530. break;
  531. switch (opt) {
  532. case 's':
  533. if (opts->socket_path)
  534. free(opts->socket_path);
  535. opts->socket_path = strdup(optarg);
  536. break;
  537. case 'p':
  538. if (opts->pidfile)
  539. free(opts->pidfile);
  540. opts->pidfile = strdup(optarg);
  541. break;
  542. case 'r':
  543. #ifdef HAVE_CHROOT
  544. if (opts->chroot)
  545. free(opts->chroot);
  546. opts->chroot = strdup(optarg);
  547. #else
  548. fprintf(stderr, "Error: The --chroot option is not supported.\n");
  549. return -1;
  550. #endif
  551. break;
  552. case 'd':
  553. opts->debug = 1;
  554. break;
  555. case 'u': {
  556. #ifdef HAVE_PWD_H
  557. struct passwd *pwd = getpwnam(optarg);
  558. if (!pwd) {
  559. fprintf(stderr, "Error: Can't identify user \"%s\"\n",
  560. optarg);
  561. return -1;
  562. }
  563. opts->uid = pwd->pw_uid;
  564. #else
  565. fprintf(stderr, "The --user option is not supported.\n");
  566. return -1;
  567. #endif
  568. break;
  569. }
  570. case 'g': {
  571. #ifdef HAVE_GRP_H
  572. struct group *grp = getgrnam(optarg);
  573. if (!grp) {
  574. fprintf(stderr, "Can't identify group \"%s\"\n",
  575. optarg);
  576. return -1;
  577. }
  578. opts->gid = grp->gr_gid;
  579. #else
  580. fprintf(stderr, "The --group option is not supported.\n");
  581. return -1;
  582. #endif
  583. break;
  584. }
  585. case 'O':
  586. if (lub_log_facility(optarg, &(opts->log_facility))) {
  587. fprintf(stderr, "Error: Illegal syslog facility %s.\n", optarg);
  588. help(-1, argv[0]);
  589. exit(-1);
  590. }
  591. break;
  592. case 'h':
  593. help(0, argv[0]);
  594. exit(0);
  595. break;
  596. case 'v':
  597. version(VERSION);
  598. exit(0);
  599. break;
  600. default:
  601. help(-1, argv[0]);
  602. exit(-1);
  603. break;
  604. }
  605. }
  606. return 0;
  607. }
  608. /*--------------------------------------------------------- */
  609. /* Print help message */
  610. static void help(int status, const char *argv0)
  611. {
  612. const char *name = NULL;
  613. if (!argv0)
  614. return;
  615. /* Find the basename */
  616. name = strrchr(argv0, '/');
  617. if (name)
  618. name++;
  619. else
  620. name = argv0;
  621. if (status != 0) {
  622. fprintf(stderr, "Try `%s -h' for more information.\n",
  623. name);
  624. } else {
  625. printf("Usage: %s [options]\n", name);
  626. printf("Daemon to store user configuration (i.e. commands). "
  627. "The part of the klish project.\n");
  628. printf("Options:\n");
  629. printf("\t-v, --version\tPrint version.\n");
  630. printf("\t-h, --help\tPrint this help.\n");
  631. printf("\t-d, --debug\tDebug mode. Don't daemonize.\n");
  632. printf("\t-s <path>, --socket=<path>\tSpecify the UNIX socket "
  633. "filesystem path to listen on.\n");
  634. printf("\t-p <path>, --pid=<path>\tFile to save daemon's PID to.\n");
  635. printf("\t-r <path>, --chroot=<path>\tDirectory to chroot.\n");
  636. printf("\t-u <user>, --user=<user>\tExecute process as"
  637. " specified user.\n");
  638. printf("\t-g <group>, --group=<group>\tExecute process as"
  639. " specified group.\n");
  640. printf("\t-O, --facility\tSyslog facility. Default is DAEMON.\n");
  641. }
  642. }