#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);
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;
}
-/*
- *=====================================================================
- * 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.
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.