prepare for upload
[debian/amanda] / common-src / file.c
index a03197e2793cae42613368103f79bf9485a98cfa..cadcf0a31499b47c240a68451a75d59f71422ce5 100644 (file)
@@ -31,7 +31,6 @@
 #include "amanda.h"
 #include "util.h"
 
-void amanda_setup(int argc, char **argv, int setup_flags);
 static int mk1dir(const char *, mode_t, uid_t, gid_t);
 static void areads_getbuf(const char *s, int l, int fd);
 
@@ -54,8 +53,8 @@ mk1dir(
     int rc;    /* return code */
 
     if((rc = mkdir(dir, mode)) == 0) {
-       if ((rc = chmod(dir, mode)) == 0) { /* mkdir() affected by the umask */
-           rc = chown(dir, uid, gid);
+       if ((rc = chown(dir, uid, gid)) == 0) { /* mkdir() affected by the umask */
+           rc = chmod(dir, mode);
        }
     } else {                   /* maybe someone beat us to it */
        int serrno;
@@ -156,28 +155,6 @@ rmpdir(
 }
 
 
-/*
- *=====================================================================
- * Do Amanda setup for all programs.
- *
- * void amanda_setup (int argc, char **argv, int setup_flags)
- *
- * entry:      setup_flags (see AMANDA_SETUP_FLAG_xxx)
- * exit:       none
- *=====================================================================
- */
-
-void
-amanda_setup (
-    int                argc,
-    char **    argv,
-    int                setup_flags)
-{
-    (void)argc;                /* Quiet unused parameter warning */
-    (void)argv;                /* Quiet unused parameter warning */
-    (void)setup_flags; /* Quiet unused parameter warning */
-}
-
 /*
  *=====================================================================
  * Change directory to a "safe" location and set some base environment.
@@ -400,6 +377,35 @@ sanitise_filename(
     return buf;
 }
 
+/* duplicate '_' */
+char *
+old_sanitise_filename(
+    char *     inp)
+{
+    char *buf;
+    size_t buf_size;
+    char *s, *d;
+    int ch;
+
+    buf_size = 2*strlen(inp) + 1;              /* worst case */
+    buf = alloc(buf_size);
+    d = buf;
+    s = inp;
+    while((ch = *s++) != '\0') {
+       if(ch == '_') {
+           *d++ = (char)ch;
+       }
+       if(ch == '/') {
+           ch = '_';   /* convert "bad" to "_" */
+       }
+       *d++ = (char)ch;
+    }
+    assert(d < buf + buf_size);
+    *d = '\0';
+
+    return buf;
+}
+
 /*
  *=====================================================================
  * Get the next line of input from a stdio file.