prepare to upload
[debian/amanda] / amandad-src / amandad.c
index cfb7a47948ec7edeb04786fe85e9058f389a468c..8d9b3d6b680133603cc551655523d55d9fde2b91 100644 (file)
@@ -445,12 +445,19 @@ main(
 
     if (getuid() == 0) {
        if (strcasecmp(auth, "krb5") != 0) {
-           error(_("Amanda must be run as user '%s' when using '%s' authentication"),
-                 CLIENT_LOGIN, auth);
+           struct passwd *pwd;
+           /* lookup our local user name */
+           if ((pwd = getpwnam(CLIENT_LOGIN)) == NULL) {
+               error(_("getpwnam(%s) failed."), CLIENT_LOGIN);
+           }
+           if (pwd->pw_uid != 0) {
+               error(_("'amandad' must be run as user '%s' when using '%s' authentication"),
+                     CLIENT_LOGIN, auth);
+           }
        }
     } else {
        if (strcasecmp(auth, "krb5") == 0) {
-           error(_("Amanda must be run as user 'root' when using 'krb5' authentication"));
+           error(_("'amandad' must be run as user 'root' when using 'krb5' authentication"));
        }
     }
 
@@ -1255,7 +1262,7 @@ errfd_recv(
     }
 
     /* for each line terminate by '\n' */
-    while (as->errbuf != NULL  && (r = index(as->errbuf, '\n')) != NULL) {
+    while (as->errbuf != NULL  && (r = strchr(as->errbuf, '\n')) != NULL) {
        char *s;
 
        *r = '\0';
@@ -1670,6 +1677,21 @@ service_new(
                data_write[i + 1][0] = newfd;
            }
        }
+       while(data_write[4][0] >= DATA_FD_OFFSET &&
+             data_write[4][0] <= DATA_FD_OFFSET + DATA_FD_COUNT*2 - 1) {
+           newfd = dup(data_write[4][0]);
+           if (newfd == -1)
+               error(_("Can't dup out off DATA_FD range"));
+           data_write[4][0] = newfd;
+       }
+       while(data_write[4][1] >= DATA_FD_OFFSET &&
+             data_write[4][1] <= DATA_FD_OFFSET + DATA_FD_COUNT*2 - 1) {
+           newfd = dup(data_write[4][1]);
+           if (newfd == -1)
+               error(_("Can't dup out off DATA_FD range"));
+           data_write[4][1] = newfd;
+       }
+
        for (i = 0; i < DATA_FD_COUNT*2; i++)
            close(DATA_FD_OFFSET + i);