Pārlūkot izejas kodu

* fixmod() was simply returning bad results

svn: 971
Bryan Drewery 22 gadi atpakaļ
vecāks
revīzija
53cf103f93
3 mainītis faili ar 11 papildinājumiem un 13 dzēšanām
  1. 1 0
      doc/UPDATES
  2. 7 6
      src/main.c
  3. 3 7
      src/misc_file.c

+ 1 - 0
doc/UPDATES

@@ -26,6 +26,7 @@ This is a summary of ChangeLog basically.
 21.The AES core should be slightly faster now.
 22.Added channel flag +autoop (users only, +private accounted for).
 23.Added user flag for autoop (+O).
+24.Fixed a problem with my chmod() function.
 
 1.1.5
 

+ 7 - 6
src/main.c

@@ -487,7 +487,6 @@ static void core_halfhourly()
 }
 
 static void startup_checks() {
-  char cfile[DIRMAX] = "";
   int enc = CONF_ENC;
 
 #ifdef LEAF
@@ -514,13 +513,13 @@ static void startup_checks() {
     }
 #endif /* LEAF */
   }
-  if (!fixmod(confdir()))
+  if (fixmod(confdir()))
     werr(ERR_CONFDIRMOD);
   /*technically no longer needed? 
    else if (!can_stat(cfile))
      werr(ERR_NOCONF);
   */
-  else if (can_stat(cfile) && !fixmod(cfile))
+  else if (fixmod(cfile))
     werr(ERR_CONFMOD);
 
   if (!can_stat(tempdir)) {
@@ -531,7 +530,7 @@ static void startup_checks() {
           werr(ERR_TMPSTAT);
     }
   }
-  if (!fixmod(tempdir))
+  if (fixmod(tempdir))
     werr(ERR_TMPMOD);
 
   /* test tempdir: it's vital */
@@ -572,7 +571,7 @@ static void startup_checks() {
 
   if (!can_stat(binname))
    werr(ERR_BINSTAT);
-  else if (!fixmod(binname))
+  else if (fixmod(binname))
    werr(ERR_BINMOD);
 
 #ifdef LEAF
@@ -606,7 +605,7 @@ static void startup_checks() {
          ok = 0;
       }
 
-      if (ok && !fixmod(newbin)) {
+      if (ok && fixmod(newbin)) {
           unlink(newbin);
           ok = 0;
       }
@@ -826,9 +825,11 @@ int main(int argc, char **argv)
 #ifndef CYGWIN_HACKS
     setpgid(0, 0);
 #endif /* !CYGWIN_HACKS */
+    /*
     freopen("/dev/null", "r", stdin);
     freopen("/dev/null", "w", stdout);
     freopen("/dev/null", "w", stderr);
+    */
 #ifdef CYGWIN_HACKS
     FreeConsole();
 #endif /* CYGWIN_HACKS */

+ 3 - 7
src/misc_file.c

@@ -8,6 +8,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <errno.h>
 #include "stat.h"
 
 
@@ -137,14 +138,9 @@ int is_dir(const char *s)
 int fixmod(const char *s)
 {
 #ifndef CYGWIN_HACKS
-  int i;
-
   if (!can_stat(s))
-    return 0;
-  i = chmod(s, S_IRUSR | S_IWUSR | S_IXUSR);
-  if (i < 0)
-    return 0;
-  return 1;
+    return 1;
+  return chmod(s, S_IRUSR | S_IWUSR | S_IXUSR);
 #else
   return 0;
 #endif /* !CYGWIN_HACKS */