Merge branch 'upstream'
[debian/amanda] / restore-src / amidxtaped.c
index 73338545b7b9ca72a5eeb30c96ff384ca9150dec..7b82c68d28a498a52d3cece31323755c147b56bf 100644 (file)
@@ -186,7 +186,7 @@ void
 check_security_buffer(
     char *     buffer)
 {
-    socklen_t i;
+    socklen_t_equiv i;
     struct sockaddr_in addr;
     char *s, *fp, ch;
     char *errstr = NULL;
@@ -222,7 +222,7 @@ check_security_buffer(
        /*NOTREACHED*/
     }
     skip_whitespace(s, ch);
-    if (!check_security((struct sockaddr_storage *)&addr, s-1, 0, &errstr)) {
+    if (!check_security((sockaddr_union *)&addr, s-1, 0, &errstr)) {
        error(_("security check failed: %s"), errstr);
        /*NOTREACHED*/
     }
@@ -236,7 +236,7 @@ main(
     char *buf = NULL;
     int data_sock = -1;
     in_port_t data_port = (in_port_t)-1;
-    socklen_t socklen;
+    socklen_t_equiv socklen;
     struct sockaddr_in addr;
     GSList *dumpspecs;
     tapelist_t *tapes = NULL;
@@ -298,6 +298,25 @@ main(
        safe_fd(-1, 0);
     }
 
+#ifdef FORCE_USERID
+
+    /* we'd rather not run as root */
+
+    if(geteuid() == 0) {
+       if(client_uid == (uid_t) -1) {
+           error("error [cannot find user %s in passwd file]\n", CLIENT_LOGIN);
+           /*NOTREACHED*/
+       }
+
+       /*@ignore@*/
+       initgroups(CLIENT_LOGIN, client_gid);
+       /*@end@*/
+       setgid(client_gid);
+       setuid(client_uid);
+    }
+
+#endif /* FORCE_USERID */
+
     /* initialize */
     /* close stderr first so that debug file becomes it - amrestore
        chats to stderr, which we don't want going to client */
@@ -435,6 +454,14 @@ main(
     }
     amfree(buf);
 
+    if(!tapes && rst_flags->alt_tapedev){
+       dbprintf(("%s: Looks like we're restoring from a holding file...\n", debug_prefix_time(NULL)));
+        tapes = unmarshal_tapelist_str(rst_flags->alt_tapedev);
+       tapes->isafile = 1;
+       amfree(rst_flags->alt_tapedev);
+       rst_flags->alt_tapedev = NULL;
+    }
+
     if(re_config) {
        config_init(CONFIG_INIT_EXPLICIT_NAME | CONFIG_INIT_FATAL, re_config);
        dbrename(re_config, DBG_SUBDIR_SERVER);