Changeset cb0464fd269dd989e20f86700d81579090bf8cc8

Show
Ignore:
Timestamp:
09/08/08 15:54:05 (6 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
  • src/man/Makefile.in

    r66c613e rcb0464f  
    1919top_srcdir=@top_srcdir@ 
    2020 
    21 all:    noitd.8 noitd.usage.h 
     21all:    noitd.8 noitd.usage.h \ 
     22        stratcond.8 stratcond.usage.h 
    2223 
    2324noitd.8:        $(top_srcdir)/docs/executable/noitd.xml 
     
    2728        $(NROFF)  -mandoc ./noitd.8 | ../../buildtools/xml2h NOITD_USAGE > noitd.usage.h 
    2829 
     30stratcond.8:    $(top_srcdir)/docs/executable/stratcond.xml 
     31        $(XSLTPROC) --nonet $(top_srcdir)/docs/docbook-xsl/manpages/docbook.xsl $< 
     32 
     33stratcond.usage.h:      stratcond.8 
     34        $(NROFF)  -mandoc ./stratcond.8 | ../../buildtools/xml2h STRATCOND_USAGE > stratcond.usage.h 
     35 
    2936install:        all 
    3037        $(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 
    3239 
    3340clean: 
    34         rm -f noitd.8 noitd.usage.h 
     41        rm -f noitd.8 noitd.usage.h stratcond.8 stratcond.usage.h 
    3542 
  • src/stratcond.c

    rdc66527 rcb0464f  
    1111#include "utils/noit_log.h" 
    1212#include "utils/noit_hash.h" 
     13#include "utils/noit_security.h" 
    1314#include "noit_listener.h" 
    1415#include "noit_console.h" 
     
    2021#define APPNAME "stratcon" 
    2122static char *config_file = ETC_DIR "/" APPNAME ".conf"; 
     23static const char *droptouser = NULL; 
     24static const char *droptogroup = NULL; 
     25static const char *chrootpath = NULL; 
     26static int foreground = 0; 
    2227static int debug = 0; 
    23 static int foreground = 0; 
     28 
     29#include "man/stratcond.usage.h" 
     30static 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
    2439 
    2540void parse_clargs(int argc, char **argv) { 
    2641  int c; 
    27   while((c = getopt(argc, argv, "c:dD")) != EOF) { 
     42  while((c = getopt(argc, argv, "hc:dDu:g:t:")) != EOF) { 
    2843    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; 
    2957      case 'c': 
    3058        config_file = strdup(optarg); 
     
    114142  noit_console_init(); 
    115143  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 
    116155  stratcon_jlog_streamer_init(APPNAME); 
    117156