Yeah, you are reminding me that I rolled my own for this package.  The
reason is that my amanda server is 2.5.0 still which seems to be
incompatible with 2.5.1, yet i needed a fix that went into 2.5.1 for
gnutar's listed-incremental files.

The specific patch I needed to add your your 2.5.0p2-1 package just in
case you are interested:

--- amanda-2.5.0p2.orig/client-src/sendsize.c
+++ amanda-2.5.0p2/client-src/sendsize.c
@@ -1454,6 +1454,9 @@
     char *file_exclude = NULL;
     char *file_include = NULL;
     times_t start_time;
+    int infd, outfd;
+    ssize_t nb;
+    char buf[32768];
 
     if(options->exclude_file) nb_exclude += options->exclude_file->nb_element;
     if(options->exclude_list) nb_exclude += options->exclude_list->nb_element;
@@ -1497,7 +1500,8 @@
         * be true for a level 0), arrange to read from /dev/null.
         */
        baselevel = level;
-       while (in == NULL) {
+       infd = -1;
+       while (infd == -1) {
            if (--baselevel >= 0) {
                snprintf(number, sizeof(number), "%d", baselevel);
                inputname = newvstralloc(inputname,
@@ -1505,7 +1509,7 @@
            } else {
                inputname = newstralloc(inputname, "/dev/null");
            }
-           if ((in = fopen(inputname, "r")) == NULL) {
+           if ((infd = open(inputname, O_RDONLY)) == -1) {
                int save_errno = errno;
 
                dbprintf(("%s: gnutar: error opening %s: %s\n",
@@ -1519,40 +1523,36 @@
        /*
         * Copy the previous listed incremental file to the new one.
         */
-       if ((out = fopen(incrname, "w")) == NULL) {
+       if ((outfd = open(incrname, O_WRONLY|O_CREAT, 0600)) == -1) {
            dbprintf(("%s: opening %s: %s\n",
                      debug_prefix(NULL), incrname, strerror(errno)));
            goto common_exit;
        }
 
-       for (; (line = agets(in)) != NULL; free(line)) {
-           if (fputs(line, out) == EOF || putc('\n', out) == EOF) {
+       while ((nb = read(infd, &buf, SIZEOF(buf))) > 0) {
+           if (fullwrite(outfd, &buf, (size_t)nb) < nb) {
                dbprintf(("%s: writing to %s: %s\n",
                           debug_prefix(NULL), incrname, strerror(errno)));
                goto common_exit;
            }
        }
-       amfree(line);
-
-       if (ferror(in)) {
+       
+       if (nb < 0) {
            dbprintf(("%s: reading from %s: %s\n",
                      debug_prefix(NULL), inputname, strerror(errno)));
            goto common_exit;
        }
-       if (fclose(in) == EOF) {
+       
+       if (close(infd) != 0) {
            dbprintf(("%s: closing %s: %s\n",
                      debug_prefix(NULL), inputname, strerror(errno)));
-           in = NULL;
            goto common_exit;
        }
-       in = NULL;
-       if (fclose(out) == EOF) {
+       if (close(outfd) != 0) {
            dbprintf(("%s: closing %s: %s\n",
                      debug_prefix(NULL), incrname, strerror(errno)));
-           out = NULL;
            goto common_exit;
        }
-       out = NULL;
 
        amfree(inputname);
        amfree(basename);
--- amanda-2.5.0p2.orig/client-src/sendbackup-gnutar.c
+++ amanda-2.5.0p2/client-src/sendbackup-gnutar.c
@@ -147,6 +147,10 @@
     char *encryptopt = skip_argument;
     char *quoted;
     char *qdisk;
+    int infd, outfd;
+    ssize_t nb;
+    char buf[32768];
+
 
     error_pn = stralloc2(get_pname(), "-smbclient");
 @@ -240,7 +246,8 @@
         * be true for a level 0), arrange to read from /dev/null.
         */
        baselevel = level;
-       while (in == NULL) {
+       infd = -1;
+       while (infd == -1) {
            if (--baselevel >= 0) {
                snprintf(number, sizeof(number), "%d", baselevel);
                inputname = newvstralloc(inputname,
@@ -248,51 +255,61 @@
            } else {
                inputname = newstralloc(inputname, "/dev/null");
            }
-           if ((in = fopen(inputname, "r")) == NULL) {
+           if ((infd = open(inputname, O_RDONLY)) == -1) {
                int save_errno = errno;
+               char *qname = quote_string(inputname);
 
                dbprintf(("%s: error opening %s: %s\n",
                          debug_prefix_time("-gnutar"),
-                         inputname,
+                         qname,
                          strerror(save_errno)));
                if (baselevel < 0) {
                    error("error [opening %s: %s]", inputname, 
strerror(save_errno));
+                   /*NOTREACHED*/
                }
+               amfree(qname);
            }
        }
 
        /*
         * Copy the previous listed incremental file to the new one.
         */
-       if ((out = fopen(incrname, "w")) == NULL) {
+       if ((outfd = open(incrname, O_WRONLY|O_CREAT, 0600)) == -1) {
            error("error [opening %s: %s]", incrname, strerror(errno));
+           /*NOTREACHED*/
        }
-
-       for (; (line = agets(in)) != NULL; free(line)) {
-           if(fputs(line, out) == EOF || putc('\n', out) == EOF) {
-               error("error [writing to %s: %s]", incrname, strerror(errno));
+       while ((nb = read(infd, &buf, SIZEOF(buf))) > 0) {
+           if (fullwrite(outfd, &buf, (size_t)nb) < nb) {
+               error("error [writing to '%s': %s]", incrname,
+                      strerror(errno));
+               /*NOTREACHED*/
            }
        }
-       amfree(line);
-
-       if (ferror(in)) {
-           error("error [reading from %s: %s]", inputname, strerror(errno));
-       }
-       if (fclose(in) == EOF) {
-           error("error [closing %s: %s]", inputname, strerror(errno));
+       
+       if (nb < 0) {
+           error("error [reading from '%s': %s]", inputname, strerror(errno));
+           /*NOTREACHED*/
        }
-       in = NULL;
-       if (fclose(out) == EOF) {
-           error("error [closing %s: %s]", incrname, strerror(errno));
+       
+       if (close(infd) != 0) {
+           error("error [closing '%s': %s]", inputname, strerror(errno));
+           /*NOTREACHED*/
+       }
+       if (close(outfd) != 0) {
+           error("error [closing '%s': %s]", incrname, strerror(errno));
+           /*NOTREACHED*/
        }
-       out = NULL;
-
+       
        dbprintf(("%s: doing level %d dump as listed-incremental",
                  debug_prefix_time("-gnutar"), level));
        if(baselevel >= 0) {
-           dbprintf((" from %s", inputname));
-       }
-       dbprintf((" to %s\n", incrname));
+           quoted = quote_string(inputname);
+           dbprintf((" from '%s'", quoted));
+           amfree(quoted);
+       }
+       quoted = quote_string(incrname);
+       dbprintf((" to '%s'\n", quoted));
+       amfree(quoted);
        amfree(inputname);
        amfree(basename);
     }

-- 
[apport] apport-gtk crashed with TypeError in thread_collect_info()
https://bugs.launchpad.net/bugs/98961
You received this bug notification because you are a member of Ubuntu
Bugs, which is the bug contact for Ubuntu.

-- 
ubuntu-bugs mailing list
[EMAIL PROTECTED]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to