From 2924dd8ff07b31a81c4a81254ae1e1f81b39595e Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Sat, 24 Jun 2017 11:55:50 -0700 Subject: [PATCH 01/10] common/macros.h: fix pdsh bool definition A version of the `bool` type was defined in a couple places in pdsh, and on some systems (OSX), different source files were seeing different sizes for this type (int vs byte?), and this caused segfaults when passing a structure full of bool types to a function defined in another source file. Fix this by including `stdbool.h` in macros.h and make sure all sources using bool pull in macros.h, and remove any other bool typedefs from pdsh sources. --- src/common/macros.h | 2 ++ src/pdsh/wcoll.h | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/common/macros.h b/src/common/macros.h index 5b545d0c..67448858 100644 --- a/src/common/macros.h +++ b/src/common/macros.h @@ -35,6 +35,8 @@ #include #endif +#include + #define LINEBUFSIZE 2048 #ifndef MAXHOSTNAMELEN diff --git a/src/pdsh/wcoll.h b/src/pdsh/wcoll.h index cae38ab5..7e4cdc27 100644 --- a/src/pdsh/wcoll.h +++ b/src/pdsh/wcoll.h @@ -33,13 +33,9 @@ #include /* FILE * */ +#include "src/common/macros.h" #include "src/common/hostlist.h" -#ifndef _BOOL_DEFINED -#define _BOOL_DEFINED -typedef enum { false, true } bool; -#endif /* !_BOOL_DEFINED */ - hostlist_t read_wcoll(char *, FILE *); /* From 8c173e645dfc5cb6619c4d0647f3fe495ad4ce7f Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Fri, 23 Jun 2017 09:59:18 -0700 Subject: [PATCH 02/10] common/hostlist: fix invalid assignment Fix assignment of char to char * in hostname_create_with_suffix() --- src/common/hostlist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/hostlist.c b/src/common/hostlist.c index ccc1361a..d7c9bb99 100644 --- a/src/common/hostlist.c +++ b/src/common/hostlist.c @@ -466,7 +466,7 @@ static int host_prefix_end(const char *hostname) static hostname_t hostname_create_with_suffix (const char *hostname, int idx) { hostname_t hn = NULL; - char *p = '\0'; + char *p = "\0"; assert(hostname != NULL); From 1a7b985941bdefb757b50941ae057267065adc66 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Fri, 23 Jun 2017 10:54:35 -0700 Subject: [PATCH 03/10] modules/netgroup: no need to use getnetgrent_r Drop getnetgrent_r in favor of more widely supported getnetgrent(). This function is called before threaded dsh context. --- src/modules/netgroup.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/modules/netgroup.c b/src/modules/netgroup.c index 820d6e61..40a0c1f5 100644 --- a/src/modules/netgroup.c +++ b/src/modules/netgroup.c @@ -119,12 +119,11 @@ static hostlist_t _read_netgroup (const char *group) { hostlist_t hl = NULL; char *host, *user, *domain; - char buf[4096]; int rc; setnetgrent (group); - while ((rc = getnetgrent_r (&host, &user, &domain, buf, sizeof (buf)))) { + while ((rc = getnetgrent (&host, &user, &domain))) { if (hl == NULL) hl = hostlist_create (host); else From 9676fb830a6a7891c87b5477921404e27937f4d3 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Fri, 23 Jun 2017 10:56:34 -0700 Subject: [PATCH 04/10] pdsh/mod.c: avoid initializing modules from empty list Do not bother initializing modules in _mod_initialize_modules_by_name when an empty list is passed to the function. This may also avoid a potential segfault in list_split. --- src/pdsh/mod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pdsh/mod.c b/src/pdsh/mod.c index 4df9cbef..e5b5d3c6 100644 --- a/src/pdsh/mod.c +++ b/src/pdsh/mod.c @@ -342,7 +342,7 @@ static int _mod_initialize_modules_by_name (char *names, List m) { List l; - if (names == NULL) + if (names == NULL || strlen(names) == 0) return (0); l = list_split (",", names); From f06d8d4711d35bb15239010d0247d768d64f32ab Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Sat, 24 Jun 2017 17:59:52 -0700 Subject: [PATCH 05/10] pdsh/opt.c: fix unused variable warning on OSX In opt_args_early(), local variable pc is only used on linux systems with GNU getopt to track setting of POSIXLY_CORRECT environment variable. Suppress warnings on Mac OSX by wrapping the definition of this variable in #ifdef __linux as with the rest of the code. --- src/pdsh/opt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pdsh/opt.c b/src/pdsh/opt.c index 9e68e385..790fa2db 100644 --- a/src/pdsh/opt.c +++ b/src/pdsh/opt.c @@ -501,7 +501,9 @@ void opt_args_early (opt_t * opt, int argc, char *argv[]) extern int optind; extern char *optarg; extern int opterr; +#ifdef __linux int pc = 0; +#endif /* * Disable error reporting from getopt during early processing, From 3cde420a9f5f604b29685b6535cda2101353b143 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Sat, 24 Jun 2017 18:16:14 -0700 Subject: [PATCH 06/10] dsh: fix useless use of parentheses Fix a useless use of parentheses (compiler warning on osx) and also bad formatting when checking for DSH_READING state. --- src/pdsh/dsh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pdsh/dsh.c b/src/pdsh/dsh.c index cb2f65bd..3b960351 100644 --- a/src/pdsh/dsh.c +++ b/src/pdsh/dsh.c @@ -263,8 +263,8 @@ static void _fwd_signal(int signum) dsh_mutex_lock(&thd_mutex); for (i = 0; t[i].host != NULL; i++) { - if ((t[i].state == DSH_READING)) - rcmd_signal(t[i].rcmd, signum); + if (t[i].state == DSH_READING) + rcmd_signal(t[i].rcmd, signum); } dsh_mutex_unlock(&thd_mutex); From aa14687bbccbd1bae00212fa51545aaf02b3e32a Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Sat, 24 Jun 2017 18:17:04 -0700 Subject: [PATCH 07/10] dsh: fix bad use of SIG_BLOCK instead of SIG_IGN Probably meant to ignore SIGPIPE not block it. --- src/pdsh/dsh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pdsh/dsh.c b/src/pdsh/dsh.c index 3b960351..6b7273f9 100644 --- a/src/pdsh/dsh.c +++ b/src/pdsh/dsh.c @@ -647,7 +647,7 @@ static void *_rsh_thread(void *args) if (a->rcmd->opts->resolve_hosts) _gethost(a->host, a->addr); #endif - _xsignal (SIGPIPE, SIG_BLOCK); + _xsignal (SIGPIPE, SIG_IGN); /* establish the connection */ dsh_mutex_lock(&thd_mutex); From dccca8a760e773eca2534fc15491dda6dab3db7c Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Sat, 24 Jun 2017 12:26:40 -0700 Subject: [PATCH 08/10] tests: t6036-long-output-lines: portability changes Check for missing base64 program and fall back to openssl if not found. Since `openssl base64` outputs in PEM format with newlines, use tr(1) to remove newlines and then wrap at desired long line length. --- tests/t6036-long-output-lines.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tests/t6036-long-output-lines.sh b/tests/t6036-long-output-lines.sh index 0d85c6aa..11707149 100755 --- a/tests/t6036-long-output-lines.sh +++ b/tests/t6036-long-output-lines.sh @@ -6,15 +6,26 @@ Test that pdsh does not truncate very long lines' . ${srcdir:-.}/test-lib.sh -test_expect_success 'pdsh does not truncate very long lines' ' - dd if=/dev/urandom bs=1024 count=100 | base64 -w8000 > testfile && - pdsh -w foo -N -Rexec cat testfile > output && - test_cmp testfile output -' -test_expect_success 'pdsh does not truncate even longer lines' ' - dd if=/dev/urandom bs=1024 count=100 | base64 -w80000 > testfile && +if which base64 >/dev/null; then + base64="base64" +elif which openssl >/dev/null; then + base64="openssl base64" +else + skip_all 'failed to find base64 program' +fi + + +test_expect_success 'pdsh does not truncate very long lines' " + dd if=/dev/urandom bs=1024 count=100 | $base64 | tr -d '\n' | fold -w8000 > testfile && + echo >>testfile && pdsh -w foo -N -Rexec cat testfile > output && test_cmp testfile output -' +" +test_expect_success 'pdsh does not truncate even longer lines' " + dd if=/dev/urandom bs=1024 count=100 | $base64 | tr -d '\n' | fold -w80000 > testfile2 && + echo >>testfile2 && + pdsh -w foo -N -Rexec cat testfile2 > output2 && + test_cmp testfile2 output2 +" test_done From fbd8fdd47ab8571d1ebe403a250b9d5d93d73a9f Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Fri, 23 Jun 2017 09:17:09 -0700 Subject: [PATCH 09/10] travis-ci: build on osx Add OSX to travis-ci builds. Do not attempt to use the travis-ci builder to install dependencies, which proabably aren't needed or won't be used on OSX anyway. --- .travis.yml | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 39baeaa2..d041ce58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,16 +19,26 @@ cache: - $HOME/local - $HOME/.local -env: - - CC=gcc - - CC=clang - - CC=gcc-6 - - CC=clang-3.8 +matrix: + include: + - os: linux + env: CC=gcc + - os: linux + env: CC=clang + - os: linux + env: CC=gcc-6 + - os: linux + env: CC=clang-3.8 + - os: osx + language: c + osx_image: xcode8.3 script: - - export CFLAGS=-Werror - - scripts/travis-ci-deps.sh - - eval $(scripts/travis-ci-deps.sh --printenv) + - if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then + scripts/travis-ci-deps.sh; + eval $(scripts/travis-ci-deps.sh --printenv); + fi + - export CFLAGS="-Werror -Wno-error=deprecated-declarations" - ./bootstrap - ./configure --with-exec --with-ssh --with-mrsh --with-genders --with-dshgroups --with-netgroup --with-machines - make -j 2 check From 042c1d469c5ec9145f6de547dd11956a39dfe108 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Fri, 23 Jun 2017 14:13:20 -0700 Subject: [PATCH 10/10] travis-ci: display test-suite.log after failure --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index d041ce58..736db150 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,9 @@ script: - ./configure --with-exec --with-ssh --with-mrsh --with-genders --with-dshgroups --with-netgroup --with-machines - make -j 2 check +after_failure: + - cat tests/test-suite.log + before_deploy: - make dist - export TAG_URI="https://github.com/${TRAVIS_REPO_SLUG}/blob/${TRAVIS_TAG}"