1
0

konfd.c 16 KB

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