Changeset cb0464fd269dd989e20f86700d81579090bf8cc8
- Timestamp:
- 09/08/08 15:54:05
(5 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1220889245 +0000
- git-parent:
[66c613e1604818b3d967f3e69ae30abd04be5a8b]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1220889245 +0000
- Message:
integrate command line docs as usage, refs #21
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r66c613e |
rcb0464f |
|
| 19 | 19 | top_srcdir=@top_srcdir@ |
|---|
| 20 | 20 | |
|---|
| 21 | | all: noitd.8 noitd.usage.h |
|---|
| | 21 | all: noitd.8 noitd.usage.h \ |
|---|
| | 22 | stratcond.8 stratcond.usage.h |
|---|
| 22 | 23 | |
|---|
| 23 | 24 | noitd.8: $(top_srcdir)/docs/executable/noitd.xml |
|---|
| … | … | |
| 27 | 28 | $(NROFF) -mandoc ./noitd.8 | ../../buildtools/xml2h NOITD_USAGE > noitd.usage.h |
|---|
| 28 | 29 | |
|---|
| | 30 | stratcond.8: $(top_srcdir)/docs/executable/stratcond.xml |
|---|
| | 31 | $(XSLTPROC) --nonet $(top_srcdir)/docs/docbook-xsl/manpages/docbook.xsl $< |
|---|
| | 32 | |
|---|
| | 33 | stratcond.usage.h: stratcond.8 |
|---|
| | 34 | $(NROFF) -mandoc ./stratcond.8 | ../../buildtools/xml2h STRATCOND_USAGE > stratcond.usage.h |
|---|
| | 35 | |
|---|
| 29 | 36 | install: all |
|---|
| 30 | 37 | $(top_srcdir)/buildtools/mkinstalldirs $(DESTDIR)$(mandir) |
|---|
| 31 | | $(INSTALL) -m 0644 noitd.8 $(DESTDIR)$(mandir)/man8/noitd.8 |
|---|
| | 38 | $(INSTALL) -m 0644 noitd.8 $(DESTDIR)$(mandir)/$(mansubdir)8/noitd.8 |
|---|
| 32 | 39 | |
|---|
| 33 | 40 | clean: |
|---|
| 34 | | rm -f noitd.8 noitd.usage.h |
|---|
| | 41 | rm -f noitd.8 noitd.usage.h stratcond.8 stratcond.usage.h |
|---|
| 35 | 42 | |
|---|
| rdc66527 |
rcb0464f |
|
| 11 | 11 | #include "utils/noit_log.h" |
|---|
| 12 | 12 | #include "utils/noit_hash.h" |
|---|
| | 13 | #include "utils/noit_security.h" |
|---|
| 13 | 14 | #include "noit_listener.h" |
|---|
| 14 | 15 | #include "noit_console.h" |
|---|
| … | … | |
| 20 | 21 | #define APPNAME "stratcon" |
|---|
| 21 | 22 | static char *config_file = ETC_DIR "/" APPNAME ".conf"; |
|---|
| | 23 | static const char *droptouser = NULL; |
|---|
| | 24 | static const char *droptogroup = NULL; |
|---|
| | 25 | static const char *chrootpath = NULL; |
|---|
| | 26 | static int foreground = 0; |
|---|
| 22 | 27 | static int debug = 0; |
|---|
| 23 | | static int foreground = 0; |
|---|
| | 28 | |
|---|
| | 29 | #include "man/stratcond.usage.h" |
|---|
| | 30 | static void usage(const char *progname) { |
|---|
| | 31 | printf("Usage for %s:\n", progname); |
|---|
| | 32 | #ifdef STRATCOND_USAGE |
|---|
| | 33 | write(STDOUT_FILENO, STRATCOND_USAGE, sizeof(STRATCOND_USAGE)-1); |
|---|
| | 34 | #else |
|---|
| | 35 | printf("\nError in usage, build problem.\n"); |
|---|
| | 36 | #endif |
|---|
| | 37 | return; |
|---|
| | 38 | } |
|---|
| 24 | 39 | |
|---|
| 25 | 40 | void parse_clargs(int argc, char **argv) { |
|---|
| 26 | 41 | int c; |
|---|
| 27 | | while((c = getopt(argc, argv, "c:dD")) != EOF) { |
|---|
| | 42 | while((c = getopt(argc, argv, "hc:dDu:g:t:")) != EOF) { |
|---|
| 28 | 43 | switch(c) { |
|---|
| | 44 | case 'h': |
|---|
| | 45 | usage(argv[0]); |
|---|
| | 46 | exit(1); |
|---|
| | 47 | break; |
|---|
| | 48 | case 'u': |
|---|
| | 49 | droptouser = strdup(optarg); |
|---|
| | 50 | break; |
|---|
| | 51 | case 'g': |
|---|
| | 52 | droptogroup = strdup(optarg); |
|---|
| | 53 | break; |
|---|
| | 54 | case 't': |
|---|
| | 55 | chrootpath = strdup(optarg); |
|---|
| | 56 | break; |
|---|
| 29 | 57 | case 'c': |
|---|
| 30 | 58 | config_file = strdup(optarg); |
|---|
| … | … | |
| 114 | 142 | noit_console_init(); |
|---|
| 115 | 143 | noit_listener_init(APPNAME); |
|---|
| | 144 | |
|---|
| | 145 | /* Drop privileges */ |
|---|
| | 146 | if(chrootpath && noit_security_chroot(chrootpath)) { |
|---|
| | 147 | noitL(noit_stderr, "Failed to chroot(), exiting.\n"); |
|---|
| | 148 | exit(-1); |
|---|
| | 149 | } |
|---|
| | 150 | if(noit_security_usergroup(droptouser, droptogroup)) { |
|---|
| | 151 | noitL(noit_stderr, "Failed to drop privileges, exiting.\n"); |
|---|
| | 152 | exit(-1); |
|---|
| | 153 | } |
|---|
| | 154 | |
|---|
| 116 | 155 | stratcon_jlog_streamer_init(APPNAME); |
|---|
| 117 | 156 | |
|---|