Imported Upstream version 2.5.0p2
[debian/amanda] / client-src / rundump.c
index 26814e6173a93e42a6b087d0f9df47115d319b01..347da0a356e4c27ea914b0125d91e2ef0b616abf 100644 (file)
@@ -24,7 +24,7 @@
  * file named AUTHORS, in the root directory of this distribution.
  */
 /*
- * $Id: rundump.c,v 1.23.2.3.6.1 2002/10/27 14:31:18 martinea Exp $
+ * $Id: rundump.c,v 1.28 2006/01/14 04:37:18 paddy_s Exp $
  *
  * runs DUMP program as root
  */
@@ -34,6 +34,7 @@
 int main P((int argc, char **argv));
 
 #if defined(VDUMP) || defined(XFSDUMP)
+#  undef USE_RUNDUMP
 #  define USE_RUNDUMP
 #endif
 
@@ -56,22 +57,15 @@ char **argv;
     int i;
     char *e;
 #endif /* ERRMSG */
-    int fd;
-
-    for(fd = 3; fd < FD_SETSIZE; fd++) {
-       /*
-        * Make sure nobody spoofs us with a lot of extra open files
-        * that would cause an open we do to get a very high file
-        * descriptor, which in turn might be used as an index into
-        * an array (e.g. an fd_set).
-        */
-       close(fd);
-    }
 
+    safe_fd(-1, 0);
     safe_cd();
 
     set_pname("rundump");
 
+    /* Don't die when child closes pipe */
+    signal(SIGPIPE, SIG_IGN);
+
     dbopen();
     dbprintf(("%s: version %s\n", argv[0], version()));
 
@@ -89,13 +83,11 @@ char **argv;
     }
 
 #ifdef FORCE_USERID
-    if (getuid() != client_uid) {
+    if (getuid() != client_uid)
        error("error [must be invoked by %s]\n", CLIENT_LOGIN);
-    }
 
-    if (geteuid() != 0) {
+    if (geteuid() != 0)
        error("error [must be setuid root]\n");
-    }
 #endif /* FORCE_USERID */
 
 #if !defined (DONT_SUID_ROOT)
@@ -148,7 +140,7 @@ char **argv;
     execve(dump_program, argv, safe_env());
 
     e = strerror(errno);
-    dbprintf(("execve of %s failed (%s)\n", dump_program, e));
+    dbprintf(("failed (%s)\n", e));
     dbclose();
 
     fprintf(stderr, "rundump: could not exec %s: %s\n", dump_program, e);