Package: distcc Version: 3.1-4 Severity: normal Tags: patch User: [email protected] Usertags: hurd
Hi, Distcc fails to build on hurd-i386 because it relies on PATH_MAX being defined. The attached patch (against the debian source) fixes this. I also attach the standalone .dpatch file for your alternative convenience. -- Jeremie Koenig <[email protected]> http://jk.fr.eu.org
commit ca56932b7c945bdd51d055228f66f205e49cfeb9 Author: Jeremie Koenig <[email protected]> Date: Wed Aug 17 22:13:59 2011 +0000 * New patch 05_path_max fixes FTBFS on hurd-i386. Closes: #nnnnnn. diff --git a/debian/patches/00list b/debian/patches/00list index 2ff8924..9fef902 100644 --- a/debian/patches/00list +++ b/debian/patches/00list @@ -1,3 +1,4 @@ 02_distccmongnome_man 03_do_not_install_redhat_config 04_fix_pumps_include_server_path +05_path_max diff --git a/debian/patches/05_path_max.dpatch b/debian/patches/05_path_max.dpatch new file mode 100644 index 0000000..a214c2f --- /dev/null +++ b/debian/patches/05_path_max.dpatch @@ -0,0 +1,111 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 05_path_max.dpatch by Jeremie Koenig <[email protected]> +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Don't rely on PATH_MAX being defined. + +@DPATCH@ + +diff --git a/source/src/stringmap.c b/source/src/stringmap.c +index 924e18c..aac2170 100644 +--- a/source/src/stringmap.c ++++ b/source/src/stringmap.c +@@ -20,24 +20,28 @@ + + #include <stdio.h> + #include <stdlib.h> + #include <string.h> + #include <limits.h> + #include <assert.h> + #include "stringmap.h" + + #ifndef NULL + #define NULL 0 + #endif + ++#ifndef PATH_MAX ++#define PATH_MAX 4096 ++#endif ++ + /* Load the given list of strings into the key/value map. + * The key for each string is the numFinalWordsToMatch of the string; + * the value for each string is the entire string. + * FIXME: doesn't work for utf-8 strings, since it scans raw chars for / + */ + stringmap_t *stringmap_load(const char *filename, int numFinalWordsToMatch) + { + stringmap_t *result = calloc(1, sizeof(*result)); + FILE *fp = fopen(filename, "r"); + char buf[2*PATH_MAX]; + int n; + +diff --git a/source/src/zeroconf.c b/source/src/zeroconf.c +index 414ddc4..59f0dab 100644 +--- a/source/src/zeroconf.c ++++ b/source/src/zeroconf.c +@@ -505,38 +505,43 @@ static int get_zeroconf_dir(char **dir_ret) { + *dir_ret = cached; + return 0; + } else { + ret = dcc_get_subdir("zeroconf", dir_ret); + if (ret == 0) + cached = *dir_ret; + return ret; + } + } + + /* Get the host list from zeroconf */ + int dcc_zeroconf_add_hosts(struct dcc_hostdef **ret_list, int *ret_nhosts, int n_slots, struct dcc_hostdef **ret_prev) { +- char host_file[PATH_MAX], lock_file[PATH_MAX], *s = NULL; ++ char *host_file = NULL, *lock_file = NULL, *s = NULL; + int lock_fd = -1, host_fd = -1; + int fork_daemon = 0; + int r = -1; + char *dir; + struct stat st; + + if (get_zeroconf_dir(&dir) != 0) { + rs_log_crit("failed to get zeroconf dir.\n"); + goto finish; + } + +- snprintf(lock_file, sizeof(lock_file), "%s/lock", dir); +- snprintf(host_file, sizeof(host_file), "%s/hosts", dir); ++ lock_file = malloc(strlen(dir) + sizeof("/lock")); ++ assert(lock_file); ++ sprintf(lock_file, "%s/lock", dir); ++ ++ host_file = malloc(strlen(dir) + sizeof("/hosts")); ++ assert(host_file); ++ sprintf(host_file, "%s/hosts", dir); + + /* Open lock file */ + if ((lock_fd = open(lock_file, O_RDWR|O_CREAT, 0666)) < 0) { + rs_log_crit("open('%s') failed: %s\n", lock_file, strerror(errno)); + goto finish; + } + + /* Try to lock the lock file */ + if (generic_lock(lock_fd, 1, 1, 0) >= 0) { + /* The lock succeeded => there's no daemon running yet! */ + fork_daemon = 1; + generic_lock(lock_fd, 1, 0, 0); +@@ -621,16 +626,18 @@ int dcc_zeroconf_add_hosts(struct dcc_hostdef **ret_list, int *ret_nhosts, int n + rs_log_crit("failed to parse host file.\n"); + goto finish; + } + + r = 0; + + finish: + if (host_fd >= 0) { + generic_lock(host_fd, 0, 0, 1); + close(host_fd); + } + ++ free(lock_file); ++ free(host_file); + free(s); + + return r; + }
#! /bin/sh /usr/share/dpatch/dpatch-run ## 05_path_max.dpatch by Jeremie Koenig <[email protected]> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Don't rely on PATH_MAX being defined. @DPATCH@ diff --git a/source/src/stringmap.c b/source/src/stringmap.c index 924e18c..aac2170 100644 --- a/source/src/stringmap.c +++ b/source/src/stringmap.c @@ -20,24 +20,28 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> #include <assert.h> #include "stringmap.h" #ifndef NULL #define NULL 0 #endif +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif + /* Load the given list of strings into the key/value map. * The key for each string is the numFinalWordsToMatch of the string; * the value for each string is the entire string. * FIXME: doesn't work for utf-8 strings, since it scans raw chars for / */ stringmap_t *stringmap_load(const char *filename, int numFinalWordsToMatch) { stringmap_t *result = calloc(1, sizeof(*result)); FILE *fp = fopen(filename, "r"); char buf[2*PATH_MAX]; int n; diff --git a/source/src/zeroconf.c b/source/src/zeroconf.c index 414ddc4..59f0dab 100644 --- a/source/src/zeroconf.c +++ b/source/src/zeroconf.c @@ -505,38 +505,43 @@ static int get_zeroconf_dir(char **dir_ret) { *dir_ret = cached; return 0; } else { ret = dcc_get_subdir("zeroconf", dir_ret); if (ret == 0) cached = *dir_ret; return ret; } } /* Get the host list from zeroconf */ int dcc_zeroconf_add_hosts(struct dcc_hostdef **ret_list, int *ret_nhosts, int n_slots, struct dcc_hostdef **ret_prev) { - char host_file[PATH_MAX], lock_file[PATH_MAX], *s = NULL; + char *host_file = NULL, *lock_file = NULL, *s = NULL; int lock_fd = -1, host_fd = -1; int fork_daemon = 0; int r = -1; char *dir; struct stat st; if (get_zeroconf_dir(&dir) != 0) { rs_log_crit("failed to get zeroconf dir.\n"); goto finish; } - snprintf(lock_file, sizeof(lock_file), "%s/lock", dir); - snprintf(host_file, sizeof(host_file), "%s/hosts", dir); + lock_file = malloc(strlen(dir) + sizeof("/lock")); + assert(lock_file); + sprintf(lock_file, "%s/lock", dir); + + host_file = malloc(strlen(dir) + sizeof("/hosts")); + assert(host_file); + sprintf(host_file, "%s/hosts", dir); /* Open lock file */ if ((lock_fd = open(lock_file, O_RDWR|O_CREAT, 0666)) < 0) { rs_log_crit("open('%s') failed: %s\n", lock_file, strerror(errno)); goto finish; } /* Try to lock the lock file */ if (generic_lock(lock_fd, 1, 1, 0) >= 0) { /* The lock succeeded => there's no daemon running yet! */ fork_daemon = 1; generic_lock(lock_fd, 1, 0, 0); @@ -621,16 +626,18 @@ int dcc_zeroconf_add_hosts(struct dcc_hostdef **ret_list, int *ret_nhosts, int n rs_log_crit("failed to parse host file.\n"); goto finish; } r = 0; finish: if (host_fd >= 0) { generic_lock(host_fd, 0, 0, 1); close(host_fd); } + free(lock_file); + free(host_file); free(s); return r; }

