Changeset 538


Ignore:
Timestamp:
01/24/10 19:55:24 (2 years ago)
Author:
eagle
Message:
  • options are parsed sequentially (-f and -I first)
  • config file is always read from SYSCONFDIR (usually /etc or /usr/local/etc)
  • changed Makefile.am to not install header files
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r536 r538  
    11* version 0.2.2 
     2 - options are parsed sequentially (-f and -I first) 
     3 - config file is always read from SYSCONFDIR (usually /etc or /usr/local/etc) 
     4 - changed Makefile.am to not install header files 
    25 - separate name for connect log and pid file for OC/GC. 
    36 - mode detection (OC/GC) improved 
  • trunk/configure

    r536 r538  
    11#! /bin/sh 
    22# Guess values for system-dependent variables and create Makefiles. 
    3 # Generated by GNU Autoconf 2.62 for onioncat 0.2.2.r536. 
     3# Generated by GNU Autoconf 2.62 for onioncat 0.2.2.r538. 
    44# 
    55# Report bugs to <rahra@cypherpunk.at>. 
     
    597597PACKAGE_NAME='onioncat' 
    598598PACKAGE_TARNAME='onioncat' 
    599 PACKAGE_VERSION='0.2.2.r536' 
    600 PACKAGE_STRING='onioncat 0.2.2.r536' 
     599PACKAGE_VERSION='0.2.2.r538' 
     600PACKAGE_STRING='onioncat 0.2.2.r538' 
    601601PACKAGE_BUGREPORT='rahra@cypherpunk.at' 
    602602 
     
    12611261  # This message is too long to be a string in the A/UX 3.1 sh. 
    12621262  cat <<_ACEOF 
    1263 \`configure' configures onioncat 0.2.2.r536 to adapt to many kinds of systems. 
     1263\`configure' configures onioncat 0.2.2.r538 to adapt to many kinds of systems. 
    12641264 
    12651265Usage: $0 [OPTION]... [VAR=VALUE]... 
     
    13311331if test -n "$ac_init_help"; then 
    13321332  case $ac_init_help in 
    1333      short | recursive ) echo "Configuration of onioncat 0.2.2.r536:";; 
     1333     short | recursive ) echo "Configuration of onioncat 0.2.2.r538:";; 
    13341334   esac 
    13351335  cat <<\_ACEOF 
     
    14231423if $ac_init_version; then 
    14241424  cat <<\_ACEOF 
    1425 onioncat configure 0.2.2.r536 
     1425onioncat configure 0.2.2.r538 
    14261426generated by GNU Autoconf 2.62 
    14271427 
     
    14371437running configure, to aid debugging if configure makes a mistake. 
    14381438 
    1439 It was created by onioncat $as_me 0.2.2.r536, which was 
     1439It was created by onioncat $as_me 0.2.2.r538, which was 
    14401440generated by GNU Autoconf 2.62.  Invocation command line was 
    14411441 
     
    20862086# Define the identity of the package. 
    20872087 PACKAGE='onioncat' 
    2088  VERSION='0.2.2.r536' 
     2088 VERSION='0.2.2.r538' 
    20892089 
    20902090 
     
    22372237 
    22382238cat >>confdefs.h <<\_ACEOF 
    2239 #define SVN_REVISION "536" 
     2239#define SVN_REVISION "538" 
    22402240_ACEOF 
    22412241 
     
    52215221# values after options handling. 
    52225222ac_log=" 
    5223 This file was extended by onioncat $as_me 0.2.2.r536, which was 
     5223This file was extended by onioncat $as_me 0.2.2.r538, which was 
    52245224generated by GNU Autoconf 2.62.  Invocation command line was 
    52255225 
     
    52745274cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 
    52755275ac_cs_version="\\ 
    5276 onioncat config.status 0.2.2.r536 
     5276onioncat config.status 0.2.2.r538 
    52775277configured by $0, generated by GNU Autoconf 2.62, 
    52785278  with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" 
  • trunk/src/Makefile.am

    r534 r538  
    11bin_PROGRAMS = ocat 
    22ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c ocatsetup.c ocatipv4route.c ocateth.c ocatsocks.c ocatlibe.c ocatctrl.c ocatipv6route.c ocaticmp.c ocat_wintuntap.c ocat_netdesc.c 
    3 include_HEADERS = ocat.h ocat_netdesc.h strlcpy.c strlcat.c 
     3noinst_HEADERS = ocat.h ocat_netdesc.h strlcpy.c strlcat.c 
     4AM_CFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\" 
    45 
    56install-exec-hook: 
  • trunk/src/Makefile.in

    r534 r538  
    4040bin_PROGRAMS = ocat$(EXEEXT) 
    4141subdir = src 
    42 DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \ 
     42DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ 
    4343        $(srcdir)/Makefile.in 
    4444ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 
     
    5050CONFIG_HEADER = $(top_builddir)/config.h 
    5151CONFIG_CLEAN_FILES = 
    52 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)" 
     52am__installdirs = "$(DESTDIR)$(bindir)" 
    5353binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) 
    5454PROGRAMS = $(bin_PROGRAMS) 
     
    7171SOURCES = $(ocat_SOURCES) 
    7272DIST_SOURCES = $(ocat_SOURCES) 
    73 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; 
    74 am__vpath_adj = case $$p in \ 
    75     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ 
    76     *) f=$$p;; \ 
    77   esac; 
    78 am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; 
    79 includeHEADERS_INSTALL = $(INSTALL_HEADER) 
    80 HEADERS = $(include_HEADERS) 
     73HEADERS = $(noinst_HEADERS) 
    8174ETAGS = etags 
    8275CTAGS = ctags 
     
    171164target_alias = @target_alias@ 
    172165ocat_SOURCES = ocat.c ocatlog.c ocatroute.c ocatthread.c ocattun.c ocatv6conv.c ocatcompat.c ocatpeer.c ocatsetup.c ocatipv4route.c ocateth.c ocatsocks.c ocatlibe.c ocatctrl.c ocatipv6route.c ocaticmp.c ocat_wintuntap.c ocat_netdesc.c 
    173 include_HEADERS = ocat.h ocat_netdesc.h strlcpy.c strlcat.c 
     166noinst_HEADERS = ocat.h ocat_netdesc.h strlcpy.c strlcat.c 
     167AM_CFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\" 
    174168all: all-am 
    175169 
     
    271265@am__fastdepCC_FALSE@   $(COMPILE) -c `$(CYGPATH_W) '$<'` 
    272266uninstall-info-am: 
    273 install-includeHEADERS: $(include_HEADERS) 
    274         @$(NORMAL_INSTALL) 
    275         test -z "$(includedir)" || $(mkdir_p) "$(DESTDIR)$(includedir)" 
    276         @list='$(include_HEADERS)'; for p in $$list; do \ 
    277           if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ 
    278           f=$(am__strip_dir) \ 
    279           echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \ 
    280           $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \ 
    281         done 
    282  
    283 uninstall-includeHEADERS: 
    284         @$(NORMAL_UNINSTALL) 
    285         @list='$(include_HEADERS)'; for p in $$list; do \ 
    286           f=$(am__strip_dir) \ 
    287           echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \ 
    288           rm -f "$(DESTDIR)$(includedir)/$$f"; \ 
    289         done 
    290267 
    291268ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 
     
    368345all-am: Makefile $(PROGRAMS) $(HEADERS) 
    369346installdirs: 
    370         for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(includedir)"; do \ 
     347        for dir in "$(DESTDIR)$(bindir)"; do \ 
    371348          test -z "$$dir" || $(mkdir_p) "$$dir"; \ 
    372349        done 
     
    415392info-am: 
    416393 
    417 install-data-am: install-includeHEADERS 
     394install-data-am: 
    418395 
    419396install-exec-am: install-binPROGRAMS 
     
    444421ps-am: 
    445422 
    446 uninstall-am: uninstall-binPROGRAMS uninstall-includeHEADERS \ 
    447         uninstall-info-am 
     423uninstall-am: uninstall-binPROGRAMS uninstall-info-am 
    448424 
    449425.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ 
     
    452428        html-am info info-am install install-am install-binPROGRAMS \ 
    453429        install-data install-data-am install-exec install-exec-am \ 
    454         install-exec-hook install-includeHEADERS install-info \ 
    455         install-info-am install-man install-strip installcheck \ 
    456         installcheck-am installdirs maintainer-clean \ 
    457         maintainer-clean-generic mostlyclean mostlyclean-compile \ 
    458         mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ 
    459         uninstall-am uninstall-binPROGRAMS uninstall-includeHEADERS \ 
     430        install-exec-hook install-info install-info-am install-man \ 
     431        install-strip installcheck installcheck-am installdirs \ 
     432        maintainer-clean maintainer-clean-generic mostlyclean \ 
     433        mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ 
     434        tags uninstall uninstall-am uninstall-binPROGRAMS \ 
    460435        uninstall-info-am 
    461436 
  • trunk/src/cygwin/Makefile.am

    r486 r538  
    1 include_HEADERS = ocat_cygwin.h openbsd_netinet_icmp6.h openbsd_netinet_if_ether.h openbsd_netinet_ip6.h 
     1noinst_HEADERS = ocat_cygwin.h openbsd_netinet_icmp6.h openbsd_netinet_if_ether.h openbsd_netinet_ip6.h 
    22 
  • trunk/src/cygwin/Makefile.in

    r534 r538  
    3838host_triplet = @host@ 
    3939subdir = src/cygwin 
    40 DIST_COMMON = $(include_HEADERS) $(srcdir)/Makefile.am \ 
     40DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ 
    4141        $(srcdir)/Makefile.in 
    4242ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 
     
    5050SOURCES = 
    5151DIST_SOURCES = 
    52 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; 
    53 am__vpath_adj = case $$p in \ 
    54     $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ 
    55     *) f=$$p;; \ 
    56   esac; 
    57 am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; 
    58 am__installdirs = "$(DESTDIR)$(includedir)" 
    59 includeHEADERS_INSTALL = $(INSTALL_HEADER) 
    60 HEADERS = $(include_HEADERS) 
     52HEADERS = $(noinst_HEADERS) 
    6153ETAGS = etags 
    6254CTAGS = ctags 
     
    150142sysconfdir = @sysconfdir@ 
    151143target_alias = @target_alias@ 
    152 include_HEADERS = ocat_cygwin.h openbsd_netinet_icmp6.h openbsd_netinet_if_ether.h openbsd_netinet_ip6.h 
     144noinst_HEADERS = ocat_cygwin.h openbsd_netinet_icmp6.h openbsd_netinet_if_ether.h openbsd_netinet_ip6.h 
    153145all: all-am 
    154146 
     
    184176        cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 
    185177uninstall-info-am: 
    186 install-includeHEADERS: $(include_HEADERS) 
    187         @$(NORMAL_INSTALL) 
    188         test -z "$(includedir)" || $(mkdir_p) "$(DESTDIR)$(includedir)" 
    189         @list='$(include_HEADERS)'; for p in $$list; do \ 
    190           if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ 
    191           f=$(am__strip_dir) \ 
    192           echo " $(includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \ 
    193           $(includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \ 
    194         done 
    195  
    196 uninstall-includeHEADERS: 
    197         @$(NORMAL_UNINSTALL) 
    198         @list='$(include_HEADERS)'; for p in $$list; do \ 
    199           f=$(am__strip_dir) \ 
    200           echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \ 
    201           rm -f "$(DESTDIR)$(includedir)/$$f"; \ 
    202         done 
    203178 
    204179ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 
     
    281256all-am: Makefile $(HEADERS) 
    282257installdirs: 
    283         for dir in "$(DESTDIR)$(includedir)"; do \ 
    284           test -z "$$dir" || $(mkdir_p) "$$dir"; \ 
    285         done 
    286258install: install-am 
    287259install-exec: install-exec-am 
     
    326298info-am: 
    327299 
    328 install-data-am: install-includeHEADERS 
     300install-data-am: 
    329301 
    330302install-exec-am: 
     
    352324ps-am: 
    353325 
    354 uninstall-am: uninstall-includeHEADERS uninstall-info-am 
     326uninstall-am: uninstall-info-am 
    355327 
    356328.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ 
     
    358330        dvi-am html html-am info info-am install install-am \ 
    359331        install-data install-data-am install-exec install-exec-am \ 
    360         install-includeHEADERS install-info install-info-am \ 
    361         install-man install-strip installcheck installcheck-am \ 
    362         installdirs maintainer-clean maintainer-clean-generic \ 
    363         mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags \ 
    364         uninstall uninstall-am uninstall-includeHEADERS \ 
    365         uninstall-info-am 
     332        install-info install-info-am install-man install-strip \ 
     333        installcheck installcheck-am installdirs maintainer-clean \ 
     334        maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ 
     335        pdf-am ps ps-am tags uninstall uninstall-am uninstall-info-am 
    366336 
    367337# Tell versions [3.59,3.63) of GNU make to not export all variables. 
  • trunk/src/ocat.c

    r536 r538  
    3232         "   -C                    disable local controller interface\n" 
    3333         "   -d <n>                set debug level to n, default = %d\n" 
    34          "   -f <config_file>      read config from config_file\n" 
     34         "   -f <config_file>      read config from config_file (default = %s)\n" 
    3535         "   -i                    convert onion hostname to IPv6 and exit\n" 
    3636         "   -I                    GarliCat mode, use I2P instead of Tor\n" 
     
    5353         OCAT_DIR, NDESC(clog_file), CNF(create_clog),  
    5454         CNF(daemon), CNF(daemon) ^ 1, 
    55          CNF(debug_level), NDESC(listen_port), 
     55         CNF(debug_level), CNF(config_file), NDESC(listen_port), 
    5656         CNF(pid_file), 
    5757         CNF(ocat_dest_port), ntohs(CNF(socks_dst)->sin_port),  
     
    271271 
    272272 
    273 int main(int argc, char *argv[]) 
    274 { 
    275    char *s, ip6addr[INET6_ADDRSTRLEN], hw[20], def[100], pwdbuf[SIZE_1K]; 
    276    int c, runasroot = 0; 
    277    struct passwd *pwd, pwdm; 
    278    int urlconv = 0, mode_detect = 0; 
    279  
    280    init_setup(); 
    281    // detect network type by command file name 
    282    // FIXME: this should be not hardcoded in that way 
    283    // FIXME: basename() should better be used instead of strstr() 
    284    if (strstr(argv[0], "gcat")) 
    285    { 
    286       CNF(net_type) = NTYPE_I2P; 
    287       snprintf(def, 100, "127.0.0.1:%d", NDESC(listen_port)); 
    288       post_init_setup(); 
    289       mode_detect = 1; 
    290    } 
    291  
    292    while ((c = getopt(argc, argv, "abBCd:f:hrRiIopl:t:T:s:u:4L:P:")) != -1) 
     273void parse_opt_early(int argc, char *argv[]) 
     274{ 
     275   int c; 
     276 
     277   opterr = 0; 
     278   while ((c = getopt(argc, argv, "f:hI")) != -1) 
    293279      switch (c) 
    294280      { 
     281         case 'f': 
     282            free(CNF(config_file)); 
     283            CNF(config_file) = optarg; 
     284            CNF(config_read) = 0; 
     285            break; 
     286 
     287         case 'I': 
     288            CNF(net_type) = NTYPE_I2P; 
     289            break; 
     290         case 'h': 
     291            usage(argv[0]); 
     292            exit(1); 
     293         case '?': 
     294            break; 
     295      } 
     296} 
     297 
     298  
     299int parse_opt(int argc, char *argv[]) 
     300{ 
     301   int c, urlconv = 0; 
     302 
     303   opterr = 1; 
     304   optind = 1; 
     305   while ((c = getopt(argc, argv, "f:IabBCd:rRiopl:t:T:s:u:4L:P:")) != -1) 
     306      switch (c) 
     307      { 
     308         // those options are parsed in parse_opt_early() 
     309         case 'f': 
     310         case 'I': 
     311            break; 
     312 
    295313         case 'a': 
    296314            CNF(create_clog) = 1; 
     
    313331            break; 
    314332 
    315          case 'f': 
    316             CNF(config_file) = optarg; 
    317             CNF(config_read) = 0; 
    318             break; 
    319  
    320333         case 'i': 
    321334            urlconv = 1; 
    322             break; 
    323  
    324          case 'I': 
    325             CNF(net_type) = NTYPE_I2P; 
    326335            break; 
    327336 
     
    354363 
    355364         case 'r': 
    356             runasroot = 1; 
     365            CNF(runasroot) = 1; 
    357366            CNF(usrname) = "root"; 
    358367            break; 
     
    385394            break; 
    386395 
    387          case 'h': 
    388396         default: 
    389397            usage(argv[0]); 
     
    391399      } 
    392400 
    393    if (!mode_detect) 
    394    { 
     401   return urlconv; 
     402} 
     403 
     404 
     405int main(int argc, char *argv[]) 
     406{ 
     407   char *s, ip6addr[INET6_ADDRSTRLEN], hw[20], def[100], pwdbuf[SIZE_1K]; 
     408   int c; 
     409   struct passwd *pwd, pwdm; 
     410   int urlconv = 0, mode_detect = 0; 
     411 
     412   init_setup(); 
     413   // detect network type by command file name 
     414   // FIXME: this should be not hardcoded in that way 
     415   // FIXME: basename() should better be used instead of strstr() 
     416   if (strstr(argv[0], "gcat")) 
     417   { 
     418      CNF(net_type) = NTYPE_I2P; 
    395419      snprintf(def, 100, "127.0.0.1:%d", NDESC(listen_port)); 
    396420      post_init_setup(); 
    397    } 
     421      mode_detect = 1; 
     422   } 
     423 
     424   parse_opt_early(argc, argv); 
     425 
     426   if (!mode_detect) 
     427   { 
     428      snprintf(def, 100, "127.0.0.1:%d", NDESC(listen_port)); 
     429      post_init_setup(); 
     430   } 
     431 
     432   if ((c = open(CNF(config_file), O_RDONLY)) == -1) 
     433      CNF(config_failed) = errno; 
     434   else 
     435      ctrl_handler((void*) (long) c); 
     436 
     437   urlconv = parse_opt(argc, argv); 
    398438 
    399439   // usage output must be after mode detection (Tor/I2P) 
     
    417457   (void) init_ocat_thread("main"); 
    418458   detach_thread(); 
     459 
     460   if (CNF(config_failed)) 
     461      log_msg(LOG_NOTICE, "could not open config file %s: %s", CNF(config_file), strerror(CNF(config_failed))); 
    419462 
    420463   if (urlconv == 2) 
     
    461504 
    462505   log_msg(LOG_INFO, "%s", CNF(version)); 
    463  
    464 #if 0 
    465    if (CNF(config_file)) 
    466    { 
    467       log_msg(LOG_INFO, "reading config file %s", CNF(config_file)); 
    468       if ((c = open(CNF(config_file), O_RDONLY)) == -1) 
    469          log_msg(LOG_ERR, "error opening file: %s", strerror(errno)), exit(1); 
    470       ctrl_handler((void*) c); 
    471    } 
    472 #endif 
    473506 
    474507   memcpy(&CNF(ocat_hwaddr[3]), &CNF(ocat_addr.s6_addr[13]), 3); 
     
    528561      mk_pid_file(pwd->pw_uid); 
    529562 
    530    if (!runasroot && !getuid()) 
     563   if (!CNF(runasroot) && !getuid()) 
    531564   { 
    532565      log_msg(LOG_INFO, "running as root, changing uid/gid to %s (uid %d/gid %d)", CNF(usrname), pwd->pw_uid, pwd->pw_gid); 
     
    562595#endif 
    563596 
    564    // reading config file 
    565    if (CNF(config_file)) 
    566    { 
    567       log_msg(LOG_INFO, "reading config file %s", CNF(config_file)); 
    568       if ((c = open(CNF(config_file), O_RDONLY)) == -1) 
    569          log_msg(LOG_ERR, "error opening file: %s", strerror(errno)), exit(1); 
    570       ctrl_handler((void*) (long) c); 
    571    } 
    572  
    573597   // install signal handler 
    574598   install_sig(); 
  • trunk/src/ocat.h

    r536 r538  
    220220#define NTYPE_I2P 1 
    221221 
     222#ifndef SYSCONFDIR 
     223#define SYSCONFDIR "/etc" 
     224#endif 
    222225 
    223226struct OcatSetup 
     
    257260   char *config_file; 
    258261   int config_read; 
     262   int config_failed; 
    259263   int use_tap; 
    260264   //! local OnionCat MAC address 
  • trunk/src/ocat_netdesc.c

    r536 r538  
    3333      TOR_OCAT_CONNECT_LOG, 
    3434      TOR_PID_FILE, 
     35      "ocat.conf", 
    3536   }, 
    3637   { 
     
    4546      I2P_OCAT_CONNECT_LOG, 
    4647      I2P_PID_FILE, 
     48      "gcat.conf", 
    4749   }, 
    4850}; 
  • trunk/src/ocat_netdesc.h

    r536 r538  
    3939   char *clog_file; 
    4040   char *pid_file; 
     41   char *config_file; 
    4142}; 
    4243 
  • trunk/src/ocatctrl.c

    r535 r538  
    3838   int fd, c; 
    3939   FILE *ff, *fo; 
    40    char buf[FRAME_SIZE], addrstr[INET6_ADDRSTRLEN], onionstr[NDESC(name_size)], timestr[32], *s, *tokbuf; 
     40   char buf[FRAME_SIZE], addrstr[INET6_ADDRSTRLEN], onionstr[NDESC(name_size)], timestr[32], *s, *tokbuf, *bufp; 
    4141   int rlen, cfd; 
    4242   struct tm *tm; 
     
    7272      } 
    7373      log_debug("fd %d fdopen'ed \"r\"", fd); 
    74       fo = CNF(logf); 
     74      fo = CNF(logf) ? CNF(logf) : stderr; 
    7575      //CNF(config_read) = 1; 
    7676   } 
     
    133133         continue; 
    134134 
    135       if (!strtok_r(buf, " \t\r\n", &tokbuf)) 
     135      if (!(bufp = strtok_r(buf, " \t\r\n", &tokbuf))) 
    136136         continue; 
    137137 
    138138      // "exit"/"quit" => terminate thread 
    139       if (!strncmp(buf, "exit", 4) || !strncmp(buf, "quit", 4)) 
     139      if (!strncmp(bufp, "exit", 4) || !strncmp(bufp, "quit", 4)) 
    140140         break; 
    141141      // "status" 
    142       else if (!strcmp(buf, "status")) 
     142      else if (!strcmp(bufp, "status")) 
    143143      { 
    144144         lock_peers(); 
     
    159159         unlock_peers(); 
    160160      } 
    161       else if (!strcmp(buf, "close")) 
    162       { 
    163          cfd = atoi(&buf[6]); 
     161      else if (!strcmp(bufp, "close")) 
     162      { 
     163         cfd = atoi(bufp +6); 
    164164         lock_peers(); 
    165165         for (peer = get_first_peer(); peer; peer = peer->next) 
     
    178178         unlock_peers(); 
    179179      } 
    180       else if (!strcmp(buf, "threads")) 
     180      else if (!strcmp(bufp, "threads")) 
    181181      { 
    182182         print_threads(ff); 
    183183      } 
    184       else if (!strcmp(buf, "terminate")) 
     184      else if (!strcmp(bufp, "terminate")) 
    185185      { 
    186186         log_msg(LOG_INFO, "terminate request from control port"); 
    187187         kill(getpid(), SIGINT); 
    188188      } 
    189       else if (!strcmp(buf, "route")) 
     189      else if (!strcmp(bufp, "route")) 
    190190      { 
    191191         if (rlen > 6) 
    192192         { 
    193             if ((c = parse_route(&buf[6])) == E_RT_SYNTAX) 
    194                if ((c = ipv6_parse_route(&buf[6])) > 0) 
     193            if ((c = parse_route(bufp + 6)) == E_RT_SYNTAX) 
     194               if ((c = ipv6_parse_route(bufp + 6)) > 0) 
    195195                  c = 0; 
    196196            switch (c) 
     
    224224         } 
    225225      } 
    226       else if (!strcmp(buf, "connect")) 
     226      else if (!strcmp(bufp, "connect")) 
    227227      { 
    228228         if ((s = strtok_r(NULL, " \t\r\n", &tokbuf))) 
    229229         { 
    230230            if ((strlen(s) != 16) || (oniontipv6(s, &in6) == -1)) 
    231                fprintf(ff, "ERR \"%s\" not valid .onion-URL\n", &buf[8]); 
     231               fprintf(ff, "ERR \"%s\" not valid .onion-URL\n", bufp + 8); 
    232232            else 
    233233            { 
     
    243243            fprintf(ff, "ERR missing args\n"); 
    244244      } 
    245       else if (!strcmp(buf, "macs")) 
     245      else if (!strcmp(bufp, "macs")) 
    246246      { 
    247247         print_mac_tbl(ff); 
    248248      } 
    249       else if (!strcmp(buf, "queue")) 
     249      else if (!strcmp(bufp, "queue")) 
    250250      { 
    251251         print_socks_queue((FILE*) (long) pfd[1]); 
     
    258258         } 
    259259      } 
    260       else if (!strcmp(buf, "setup")) 
     260      else if (!strcmp(bufp, "setup")) 
    261261      { 
    262262         print_setup_struct(ff); 
    263263      } 
    264       else if (!strcmp(buf, "version")) 
     264      else if (!strcmp(bufp, "version")) 
    265265      { 
    266266         fprintf(ff, "%s\n", CNF(version)); 
    267267      } 
    268       else if (!strcmp(buf, "help") || !strcmp(buf, "?")) 
     268      else if (!strcmp(bufp, "help") || !strcmp(bufp, "?")) 
    269269      { 
    270270         fprintf(fo, 
  • trunk/src/ocatsetup.c

    r536 r538  
    5757   //ADDR4_PREFIX, ADDR4_MASK 
    5858   {0}, 0, 
    59    NULL, 1, 
     59   // config_file, config_read, config_failed 
     60   NULL, 0, 0, 
    6061#ifdef __CYGWIN__ 
    6162   1, 
     
    148149void post_init_setup(void) 
    149150{ 
     151   size_t l; 
    150152   setup_.ocat_addr4 = NDESC(prefix4); 
    151153   setup_.ocat_addr4_mask = NDESC(addr4_mask); 
    152154   setup_.ocat_dest_port = NDESC(vdest_port); 
    153155   setup_.ocat_ctrl_port = NDESC(ctrl_port); 
     156 
     157   l = strlen(SYSCONFDIR) + strlen(NDESC(config_file)) + 2; 
     158   if ((setup_.config_file = malloc(l)) != NULL) 
     159      snprintf(setup_.config_file, l, "%s/%s", SYSCONFDIR, NDESC(config_file)); 
     160   else 
     161      log_msg(LOG_WARNING, "could not get memory for config file string: \"%s\"", strerror(errno)); 
    154162 
    155163   if (!setup_.socks_dst->sin_port) 
Note: See TracChangeset for help on using the changeset viewer.