backoff_db creation

Jeffrey M. Vinocur jeff at litech.org
Wed May 30 16:50:10 UTC 2001


As per TODO:

* If backoffdb is set in inn.conf and that directory doesn't exist, nnrpd
  refuses to start.  Either the directory should be created by the install
  process or nnrpd should just create it if it can.

Didn't get exhaustive testing -- somebody more familiar with file control
stuff in C should look at it to make sure I didn't do anything really
dumb.

Also, I didn't think about what permissions backoffdb should have, so it
just takes whatever the umask wants...that may not be right.


-- 
Jeffrey M. Vinocur
jeff at litech.org


-- Attached file included as plaintext by Listar --
-- File: nnrpd-backoffdb

diff -ur inn-CURRENT-20010529/nnrpd/misc.c inn-CURRENT-20010529-modified/nnrpd/misc.c
--- inn-CURRENT-20010529/nnrpd/misc.c	Tue May 29 05:01:15 2001
+++ inn-CURRENT-20010529-modified/nnrpd/misc.c	Wed May 30 12:32:07 2001
@@ -526,9 +526,21 @@
   /* Need this database for backing off */
   (void)strncpy(postrec_dir,PERMaccessconf->backoff_db,SMBUF);
   if (stat(postrec_dir, &st) < 0) {
-    syslog(L_ERROR, "%s cannot stat backoff_db '%s': %s",ClientHost,postrec_dir,strerror(errno));
+    if (ENOENT == errno) {
+      if (mkdir("/tmp/footest",0777) < 0 || stat("/tmp/footest", &st) < 0) {
+        syslog(L_ERROR, "%s cannot create backoff_db '%s': %s",ClientHost,postrec_dir,strerror(errno));
+        return;
+      }
+    } else {
+      syslog(L_ERROR, "%s cannot stat backoff_db '%s': %s",ClientHost,postrec_dir,strerror(errno));
+      return;
+    }
+  }
+  if (!S_ISDIR(st.st_mode)) {
+    syslog(L_ERROR, "%s backoff_db '%s' is not a directory",ClientHost,postrec_dir);
     return;
   }
+
   BACKOFFenabled = TRUE;
 
   return;



More information about the inn-patches mailing list