Bryan Drewery 22 سال پیش
والد
کامیت
e8cc799a7d
3فایلهای تغییر یافته به همراه36 افزوده شده و 14 حذف شده
  1. 22 9
      src/conf.c
  2. 1 1
      src/conf.h
  3. 13 4
      src/main.c

+ 22 - 9
src/conf.c

@@ -207,7 +207,11 @@ void init_conf() {
   conffile.bots->next = NULL;
   conffile.bots->next = NULL;
   conffile.bot = NULL;
   conffile.bot = NULL;
 
 
+#ifdef CYGWIN_HACKS
+  conffile.autocron = 0;
+#else
   conffile.autocron = 1;
   conffile.autocron = 1;
+#endif /* CYGWIN_HACKS */
   conffile.autouname = 0;
   conffile.autouname = 0;
 #ifdef CYGWIN_HACKS
 #ifdef CYGWIN_HACKS
   conffile.binpath = strdup(homedir());
   conffile.binpath = strdup(homedir());
@@ -408,30 +412,38 @@ int parseconf() {
   return 0;
   return 0;
 }
 }
 
 
-int readconf(char *cfile)
+int readconf(char *cfile, int bits)
 {
 {
   FILE *f = NULL;
   FILE *f = NULL;
-  int i = 0;
+  int i = 0, enc = (bits & CONF_ENC) ? 1 : 0;
   char inbuf[8192] = "";
   char inbuf[8192] = "";
 
 
-  sdprintf("readconf(%s)", cfile);
+  sdprintf("readconf(%s, %d)", cfile, enc);
   Context;
   Context;
   if (!(f = fopen(cfile, "r")))
   if (!(f = fopen(cfile, "r")))
     fatal("Cannot read config", 0);
     fatal("Cannot read config", 0);
 
 
   while (fgets(inbuf, sizeof inbuf, f) != NULL) {
   while (fgets(inbuf, sizeof inbuf, f) != NULL) {
-    char *line = NULL, *temp_ptr = NULL;
-    line = temp_ptr = decrypt_string(SALT1, inbuf);
+    char *line = NULL, *temp_ptr = NULL, *p = NULL;
+
+    if (p = strchr(inbuf, '\n'))
+      *p = 0;
+
+    if (enc)
+      line = temp_ptr = decrypt_string(SALT1, inbuf);
+    else
+      line = inbuf;
 
 
     if ((line && !line[0]) || line[0] == '\n') {
     if ((line && !line[0]) || line[0] == '\n') {
-      free(line);
+      if (enc)
+        free(line);
       continue;
       continue;
     }
     }
 
 
     i++;
     i++;
 
 
-    /* sdprintf("CONF LINE: %s", line); */
-    if (!strchr("*/#-+!abcdefghijklmnopqrstuvwxyzABDEFGHIJKLMNOPWRSTUVWXYZ", line[0])) {
+    sdprintf("CONF LINE: %s", line);
+    if (enc && !strchr("*/#-+!abcdefghijklmnopqrstuvwxyzABDEFGHIJKLMNOPWRSTUVWXYZ", line[0])) {
       sdprintf(STR("line %d, char %c "), i, line[0]);
       sdprintf(STR("line %d, char %c "), i, line[0]);
       werr(ERR_CONFBADENC);
       werr(ERR_CONFBADENC);
     } else {                    /* line is good to parse */
     } else {                    /* line is good to parse */
@@ -529,7 +541,8 @@ int readconf(char *cfile)
         conf_addbot(nick, ip, host, ipsix);
         conf_addbot(nick, ip, host, ipsix);
       }
       }
     }
     }
-    free(temp_ptr);
+    if (enc)
+      free(temp_ptr);
   } /* while(fgets()) */
   } /* while(fgets()) */
   fclose(f);
   fclose(f);
 
 

+ 1 - 1
src/conf.h

@@ -55,7 +55,7 @@ pid_t checkpid(char *, conf_bot *);
 void showconf();
 void showconf();
 void init_conf();
 void init_conf();
 void free_conf();
 void free_conf();
-int readconf(char *);
+int readconf(char *, int);
 int parseconf();
 int parseconf();
 int writeconf(char *, FILE *, int);
 int writeconf(char *, FILE *, int);
 void fillconf(conf_t *);
 void fillconf(conf_t *);

+ 13 - 4
src/main.c

@@ -489,12 +489,20 @@ static void event_resettraffic()
 
 
 static void startup_checks() {
 static void startup_checks() {
   char cfile[DIRMAX] = "";
   char cfile[DIRMAX] = "";
+  int enc = CONF_ENC;
 
 
+#ifdef LEAF
+  egg_snprintf(cfile, sizeof cfile, STR("%s/.known_hosts"), confdir());
+#endif /* LEAF */
 #ifdef HUB
 #ifdef HUB
   egg_snprintf(cfile, sizeof cfile, STR("%s/conf"), confdir());
   egg_snprintf(cfile, sizeof cfile, STR("%s/conf"), confdir());
-#else /* LEAF */
-  egg_snprintf(cfile, sizeof cfile, STR("%s/.known_hosts"), confdir());
 #endif /* HUB */
 #endif /* HUB */
+
+#ifdef CYGWIN_HACKS
+  egg_snprintf(cfile, sizeof cfile, STR("%s/conf.txt"), confdir());
+  enc =~ CONF_ENC;
+#endif /* CYGWIN_HACKS */
+
   if (!can_stat(confdir())) {
   if (!can_stat(confdir())) {
 #ifdef LEAF
 #ifdef LEAF
     if (mkdir(confdir(),  S_IRUSR | S_IWUSR | S_IXUSR)) {
     if (mkdir(confdir(),  S_IRUSR | S_IWUSR | S_IXUSR)) {
@@ -528,7 +536,8 @@ static void startup_checks() {
     werr(ERR_TMPMOD);
     werr(ERR_TMPMOD);
 
 
   if (can_stat(cfile))
   if (can_stat(cfile))
-    readconf(cfile);
+    readconf(cfile, enc);
+      
 #ifdef LEAF
 #ifdef LEAF
   if (localhub)
   if (localhub)
 #endif /* LEAF */
 #endif /* LEAF */
@@ -542,7 +551,7 @@ static void startup_checks() {
 #ifdef LEAF
 #ifdef LEAF
   if (localhub)
   if (localhub)
 #endif /* LEAF */
 #endif /* LEAF */
-    writeconf(cfile, NULL, CONF_ENC);
+    writeconf(cfile, NULL, enc);
 
 
   if (!can_stat(binname))
   if (!can_stat(binname))
    werr(ERR_BINSTAT);
    werr(ERR_BINSTAT);