[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

proftpd-dfsg: FTBFS on hurd-i386 (for review)



Source: proftpd-dfsg
Version: 1.3.5~rc4-1
Severity: important
Tags: patch
User: debian-hurd@lists.debian.org
Usertags: hurd

Hi,

Currently proftpd-dfsg fails to build from source due to PIPE_BUF being
used, and that constant is not defined on GNU/Hurd. The attached patch
avoid using PIPE_BUF by deriving file descriptor buffer sizes with
fpatchconf(), allocating buffers by malloc and free them when
not needed any longer.

Thanks!
--- a/contrib/mod_exec.c
+++ b/contrib/mod_exec.c
@@ -735,6 +735,7 @@ static int exec_ssystem(cmd_rec *cmd, co
 
         if (fds >= 0) {
           int buflen;
+#ifdef PIPE_BUF
           char buf[PIPE_BUF];
 
           /* The child sent us something.  How thoughtful. */
@@ -743,6 +744,19 @@ static int exec_ssystem(cmd_rec *cmd, co
             memset(buf, '\0', sizeof(buf));
 
             buflen = read(exec_stdout_pipe[0], buf, sizeof(buf)-1);
+#else
+	  size_t len = fpathconf(exec_stdout_pipe[0], _PC_PIPE_BUF) - 1;
+	  char *buf = malloc(len) + 1;
+	    if (buf == NULL)
+	      exec_log("malloc failed: %s", strerror(errno));
+
+          /* The child sent us something.  How thoughtful. */
+
+          if (FD_ISSET(exec_stdout_pipe[0], &readfds)) {
+            memset(buf, '\0', len + 1);
+
+	    buflen = read(exec_stdout_pipe[0], buf, len);
+#endif
             if (buflen > 0) {
               if (exec_opts & EXEC_OPT_SEND_STDOUT) {
 
@@ -789,9 +803,15 @@ static int exec_ssystem(cmd_rec *cmd, co
           }
 
           if (FD_ISSET(exec_stderr_pipe[0], &readfds)) {
+#ifdef PIPE_BUF
             memset(buf, '\0', sizeof(buf));
 
             buflen = read(exec_stderr_pipe[0], buf, sizeof(buf)-1);
+#else
+            memset(buf, '\0', len);
+
+	    buflen = read(exec_stdout_pipe[0], buf, len);
+#endif
             if (buflen > 0) {
 
               /* Trim trailing CRs and LFs. */
@@ -821,6 +841,9 @@ static int exec_ssystem(cmd_rec *cmd, co
               }
             }
           }
+#ifndef PIPE_BUF
+	  free(buf);
+#endif
         }
 
         res = waitpid(pid, &status, WNOHANG);
--- a/contrib/mod_tls.c
+++ b/contrib/mod_tls.c
@@ -1765,10 +1765,18 @@ static int tls_exec_passphrase_provider(
 
         if (FD_ISSET(stderr_pipe[0], &readfds)) {
           int stderrlen;
+#ifdef PIPE_BUF
           char stderrbuf[PIPE_BUF];
-
           memset(stderrbuf, '\0', sizeof(stderrbuf));
           stderrlen = read(stderr_pipe[0], stderrbuf, sizeof(stderrbuf)-1);
+#else
+	  size_t len = fpathconf(stderr_pipe[0], _PC_PIPE_BUF) - 1;
+	  char *stderrbuf = malloc(len) + 1;
+	  if (stderrbuf == NULL)
+	    tls_log("malloc failed: %s", strerror(errno));
+          memset(stderrbuf, '\0', len + 1);
+          stderrlen = read(stderr_pipe[0], stderrbuf, len);
+#endif
           if (stderrlen > 0) {
             while (stderrlen &&
                    (stderrbuf[stderrlen-1] == '\r' ||
@@ -1785,6 +1793,9 @@ static int tls_exec_passphrase_provider(
               ": error reading stderr from '%s': %s",
               tls_passphrase_provider, strerror(errno));
           }
+#ifndef PIPE_BUF
+	  free(stderrbuf);
+#endif
         }
       }
 
--- a/contrib/mod_sftp/keys.c
+++ b/contrib/mod_sftp/keys.c
@@ -413,10 +413,20 @@ static int exec_passphrase_provider(serv
 
         if (FD_ISSET(stderr_pipe[0], &readfds)) {
           int stderrlen;
+#ifdef PIPE_BUF
           char stderrbuf[PIPE_BUF];
 
           memset(stderrbuf, '\0', sizeof(stderrbuf));
           stderrlen = read(stderr_pipe[0], stderrbuf, sizeof(stderrbuf)-1);
+#else
+	  size_t len = fpathconf(stderr_pipe[0], _PC_PIPE_BUF) - 1;
+	  char *stderrbuf = malloc(len) + 1;
+	  if (stderrbuf == NULL)
+	    pr_log_pri(PR_LOG_ALERT, MOD_SFTP_VERSION ": Out of memory!");
+	  memset(stderrbuf, '\0', len + 1);
+	  stderrlen = read(stderr_pipe[0], stderrbuf, len);
+
+#endif
           if (stderrlen > 0) {
             while (stderrlen &&
                    (stderrbuf[stderrlen-1] == '\r' ||
@@ -433,6 +443,9 @@ static int exec_passphrase_provider(serv
               ": error reading stderr from '%s': %s",
               passphrase_provider, strerror(errno));
           }
+#ifndef PIPE_BUF
+	  free(stderrbuf);
+#endif
         }
       }
 

Reply to: