Changeset 1ba47323bb855f603913d7d0f5728743f990f3d8

Show
Ignore:
Timestamp:
09/07/08 21:22:50 (6 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1220822570 +0000
git-parent:

[6cf2b311d937456b0dabb544e010af9834f6e100]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1220822570 +0000
Message:

fixes #31

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure.in

    rdb656f3 r1ba4732  
    275275                 sys/resource.h pthread.h semaphore.h pwd.h stdio.h stdlib.h string.h \ 
    276276                 ctype.h unistd.h time.h sys/stat.h sys/event.h libkern/OSAtomic.h \ 
    277                  term.h termio.h termios.h curses.h sys/cdefs.h pwd.h netinet/in_systm.h \ 
     277                 term.h termio.h termios.h curses.h sys/cdefs.h grp.h netinet/in_systm.h \ 
    278278                 sys/ioctl_compat.h sys/filio.h util.h sys/time.h sys/mman.h \ 
    279279                 stropts.h sys/stream.h alloca.h sys/wait.h) 
     280 
     281GETPWNAM_R_POSIX 
     282GETGRNAM_R_POSIX 
    280283 
    281284AC_MSG_CHECKING(for tputs() function final argument type) 
  • src/noitd.c

    r387ec00 r1ba4732  
    1616#include "utils/noit_log.h" 
    1717#include "utils/noit_hash.h" 
     18#include "utils/noit_security.h" 
    1819#include "noit_listener.h" 
    1920#include "noit_console.h" 
     
    2829 
    2930static char *config_file = ETC_DIR "/" APPNAME ".conf"; 
     31static const char *droptouser = NULL; 
     32static const char *droptogroup = NULL; 
     33static const char *chrootpath = NULL; 
    3034static int foreground = 0; 
    3135static int debug = 0; 
    3236 
     37static void usage(const char *progname) { 
     38  printf("Usage for %s:\n", progname); 
     39#ifdef NOITD_USAGE 
     40  write(FILENO_STDOUT, NOITD_USAGE, sizeof(NOITD_USAGE)-1); 
     41#else 
     42  printf("\nError in usage, build problem.\n"); 
     43#endif 
     44  return; 
     45} 
    3346void parse_clargs(int argc, char **argv) { 
    3447  int c; 
    35   while((c = getopt(argc, argv, "c:dD")) != EOF) { 
     48  while((c = getopt(argc, argv, "hc:dDu:g:t:")) != EOF) { 
    3649    switch(c) { 
     50      case 'h': 
     51        usage(argv[0]); 
     52        exit(1); 
     53        break; 
     54      case 'u': 
     55        droptouser = strdup(optarg); 
     56        break; 
     57      case 'g': 
     58        droptogroup = strdup(optarg); 
     59        break; 
     60      case 't': 
     61        chrootpath = strdup(optarg); 
     62        break; 
    3763      case 'c': 
    3864        config_file = strdup(optarg); 
     
    179205 
    180206  noit_module_init(); 
     207 
     208  /* Drop privileges */ 
     209  if(chrootpath && noit_security_chroot(chrootpath)) { 
     210    noitL(noit_stderr, "Failed to chroot(), exiting.\n"); 
     211    exit(-1); 
     212  } 
     213  if(noit_security_usergroup(droptouser, droptogroup)) { 
     214    noitL(noit_stderr, "Failed to drop privileges, exiting.\n"); 
     215    exit(-1); 
     216  } 
     217 
     218  /* Prepare for launch... */ 
    181219  noit_filters_init(); 
    182220  noit_poller_init(); 
  • src/utils/Makefile.in

    rf1321ac r1ba4732  
    1111 
    1212OBJS=noit_hash.o noit_skiplist.o noit_log.o noit_sem.o noit_str.o \ 
    13         noit_b64.o
     13        noit_b64.o noit_security.o
    1414        @ATOMIC_OBJS@ 
    1515