[PATCH] Add initial Travis CI support
by Dmitry V. Levin
This runs "make distcheck" using gcc-9, gcc-8, gcc-7, and clang
on x86_64, x86, x32, aarch64, s390x, and ppc64le architectures.
* .travis.yml: New file.
* ci/install-dependencies.sh: Likewise.
* ci/run-build-and-tests.sh: Likewise.
Resolves: https://github.com/linux-pam/linux-pam/issues/28
---
I've also pushed it to ldv/travis-ci branch.
.travis.yml | 115 +++++++++++++++++++++++++++++++++++++
ci/install-dependencies.sh | 83 ++++++++++++++++++++++++++
ci/run-build-and-tests.sh | 88 ++++++++++++++++++++++++++++
3 files changed, 286 insertions(+)
create mode 100644 .travis.yml
create mode 100755 ci/install-dependencies.sh
create mode 100755 ci/run-build-and-tests.sh
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 00000000..ae627ed4
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,115 @@
+language: c
+
+dist: bionic
+
+before_install: ci/install-dependencies.sh
+
+script: ci/run-build-and-tests.sh
+
+sudo: required
+
+git:
+ depth: 2147483647
+
+env:
+ global:
+ - VERBOSE=1
+
+matrix:
+ include:
+ - compiler: gcc
+ arch: amd64
+ env:
+ - TARGET=x86_64
+ - compiler: gcc-9
+ arch: amd64
+ env:
+ - TARGET=x86_64
+ - compiler: gcc-8
+ arch: amd64
+ env:
+ - TARGET=x86_64
+ - compiler: clang
+ arch: amd64
+ env:
+ - TARGET=x86_64
+ - compiler: gcc
+ arch: amd64
+ env:
+ - TARGET=x86
+ - compiler: gcc-9
+ arch: amd64
+ env:
+ - TARGET=x86
+ - compiler: gcc-8
+ arch: amd64
+ env:
+ - TARGET=x86
+ - compiler: clang
+ arch: amd64
+ env:
+ - TARGET=x86
+ - compiler: gcc
+ arch: amd64
+ env:
+ - TARGET=x32
+ - compiler: gcc-9
+ arch: amd64
+ env:
+ - TARGET=x32
+ - compiler: gcc-8
+ arch: amd64
+ env:
+ - TARGET=x32
+ - compiler: clang
+ arch: amd64
+ env:
+ - TARGET=x32
+ - compiler: gcc
+ arch: arm64
+ env:
+ - TARGET=aarch64
+ - compiler: gcc-9
+ arch: arm64
+ env:
+ - TARGET=aarch64
+ - compiler: gcc-8
+ arch: arm64
+ env:
+ - TARGET=aarch64
+ - compiler: clang
+ arch: arm64
+ env:
+ - TARGET=aarch64
+ - compiler: gcc
+ arch: s390x
+ env:
+ - TARGET=s390x
+ - compiler: gcc-9
+ arch: s390x
+ env:
+ - TARGET=s390x
+ - compiler: gcc-8
+ arch: s390x
+ env:
+ - TARGET=s390x
+ - compiler: clang
+ arch: s390x
+ env:
+ - TARGET=s390x
+ - compiler: gcc
+ arch: ppc64le
+ env:
+ - TARGET=ppc64le
+ - compiler: gcc-9
+ arch: ppc64le
+ env:
+ - TARGET=ppc64le
+ - compiler: gcc-8
+ arch: ppc64le
+ env:
+ - TARGET=ppc64le
+ - compiler: clang
+ arch: ppc64le
+ env:
+ - TARGET=ppc64le
diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh
new file mode 100755
index 00000000..aaeaf389
--- /dev/null
+++ b/ci/install-dependencies.sh
@@ -0,0 +1,83 @@
+#!/bin/sh -ex
+#
+# Copyright (c) 2018-2019 The strace developers.
+# All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+j=-j`nproc` || j=
+type sudo >/dev/null 2>&1 && sudo=sudo || sudo=
+packages="
+autoconf
+automake
+autopoint
+bison
+bzip2
+docbook-xml
+docbook-xsl
+flex
+gettext
+libaudit-dev
+libcrack2-dev
+libdb-dev
+libfl-dev
+libselinux1-dev
+libtool
+libxcrypt-dev
+libxml2-utils
+make
+pkg-config
+sed
+w3m
+xsltproc
+xz-utils
+$CC"
+
+retry_if_failed()
+{
+ for i in `seq 0 99`; do
+ "$@" && i= && break || sleep 1
+ done
+ [ -z "$i" ]
+}
+
+updated=
+apt_get_install()
+{
+ [ -n "$updated" ] || {
+ retry_if_failed $sudo apt-get -qq update
+ updated=1
+ }
+ retry_if_failed $sudo \
+ apt-get -qq --no-install-suggests --no-install-recommends \
+ install -y "$@"
+}
+
+case "$CC" in
+ gcc-*)
+ retry_if_failed \
+ $sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
+ ;;
+esac
+
+case "$TARGET" in
+ x32|x86)
+ packages="$packages gcc-multilib"
+ case "$CC" in
+ gcc-*) packages="$packages $CC-multilib" ;;
+ esac
+ ;;
+esac
+
+apt_get_install $packages
+
+case "${CHECK-}" in
+ coverage)
+ apt_get_install lcov python-pip python-setuptools
+ retry_if_failed \
+ pip install --user codecov
+ ;;
+ valgrind)
+ apt_get_install valgrind
+ ;;
+esac
diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh
new file mode 100755
index 00000000..db55bdd0
--- /dev/null
+++ b/ci/run-build-and-tests.sh
@@ -0,0 +1,88 @@
+#!/bin/sh -ex
+#
+# Copyright (c) 2018-2019 The strace developers.
+# All rights reserved.
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+DISTCHECK_CONFIGURE_FLAGS='--disable-dependency-tracking'
+export DISTCHECK_CONFIGURE_FLAGS
+
+case "${TARGET-}" in
+ x32)
+ CC="$CC -mx32"
+ ;;
+ x86)
+ CC="$CC -m32"
+ DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --build=i686-pc-linux-gnu --target=i686-pc-linux-gnu"
+ ;;
+esac
+
+CPPFLAGS=
+
+case "${CHECK-}" in
+ coverage)
+ DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --enable-code-coverage"
+ CFLAGS='-g -O0'
+ CFLAGS_FOR_BUILD="$CFLAGS"
+ export CFLAGS CFLAGS_FOR_BUILD
+ ;;
+ valgrind)
+ DISTCHECK_CONFIGURE_FLAGS="$DISTCHECK_CONFIGURE_FLAGS --enable-valgrind"
+ ;;
+esac
+
+echo 'BEGIN OF BUILD ENVIRONMENT INFORMATION'
+uname -a |head -1
+libc="$(ldd /bin/sh |sed -n 's|^[^/]*\(/[^ ]*/libc\.so[^ ]*\).*|\1|p' |head -1)"
+$libc |head -1
+$CC --version |head -1
+make --version |head -1
+autoconf --version |head -1
+automake --version |head -1
+libtoolize --version |head -1
+kver="$(printf '%s\n%s\n' '#include <linux/version.h>' 'LINUX_VERSION_CODE' | $CC $CPPFLAGS -E -P -)"
+printf 'kernel-headers %s.%s.%s\n' $(($kver/65536)) $(($kver/256%256)) $(($kver%256))
+echo 'END OF BUILD ENVIRONMENT INFORMATION'
+
+export CC_FOR_BUILD="$CC"
+
+./autogen.sh
+./configure $DISTCHECK_CONFIGURE_FLAGS \
+ || {
+ rc=$?
+ cat config.log
+ echo "$CC -dumpspecs follows"
+ $CC -dumpspecs
+ exit $rc
+}
+
+j=-j`nproc` || j=
+
+case "${CHECK-}" in
+ coverage)
+ make -k $j all VERBOSE=${VERBOSE-}
+ make -k $j check VERBOSE=${VERBOSE-}
+ codecov --gcov-args=-abcp ||:
+ echo 'BEGIN OF TEST SUITE INFORMATION'
+ tail -n 99999 -- tests*/test-suite.log
+ echo 'END OF TEST SUITE INFORMATION'
+ ;;
+ valgrind)
+ make -k $j all VERBOSE=${VERBOSE-}
+ rc=$?
+ for n in ${VALGRIND_TOOLS:-memcheck helgrind drd}; do
+ make -k $j -C "${VALGRIND_TESTDIR:-.}" \
+ check-valgrind-$n VERBOSE=${VERBOSE-} ||
+ rc=$?
+ done
+ echo 'BEGIN OF TEST SUITE INFORMATION'
+ tail -n 99999 -- tests*/test-suite*.log ||
+ rc=$?
+ echo 'END OF TEST SUITE INFORMATION'
+ [ "$rc" -eq 0 ]
+ ;;
+ *)
+ make -k $j distcheck VERBOSE=${VERBOSE-}
+ ;;
+esac
--
ldv
3 years, 11 months
Regression in pam_unix caused by using pam_modutil_sanitize_fd
by Tomas Mraz
The pam_modutil_sanitize_fd() when called to provide a dummy pipes for
stdout and stderr closes the read end of the newly created dummy pipe.
This is wrong as any writes to such pipe will trigger SIGPIPE. The
original code did a trick to avoid that by dup2-ing the read end of the
pipe as stdin. However it does not necessarily have to be stdin, we
just need to ensure the read end of the pipe is not closed.
The attached patch implements the fix. OK to commit?
--
Tomáš Mráz
No matter how far down the wrong road you've gone, turn back.
Turkish proverb
[You'll know whether the road is wrong if you carefully listen to your
conscience.]
4 years, 1 month
Multiple pam_env cleanups
by Tomas Mraz
The pam_env code is fairly ugly, this improves it only a little bit.
Please review.
--
Tomáš Mráz
No matter how far down the wrong road you've gone, turn back.
Turkish proverb
[You'll know whether the road is wrong if you carefully listen to your
conscience.]
4 years, 1 month
Regression by using pam_modutil_sanitize_helper_fds
by Tomas Mraz
The original code in pam_unix redirected the stderr of the unix_chkpwd
process to the stdin via a pipe. The current code of
pam_modutil_sanitize_helper_fds still uses pipe for stdin/stderr
however it closes the read-end of the stderr pipe which breaks when
something is printed on stderr from the unix_chkpwd helper (such as
LD_PRELOAD error messages). The reason is the process receives SIGPIPE
and terminates.
This patch instead of redirecting the stderr to stdin just leaves the
stderr pipe read-end open.
Please review.
--
Tomáš Mráz
No matter how far down the wrong road you've gone, turn back.
Turkish proverb
[You'll know whether the road is wrong if you carefully listen to your
conscience.]
4 years, 2 months
[PATCH] _pam_mkargv: add const qualifier to the first argument
by Dmitry V. Levin
Also fix the following compilation warning:
tests/tst-pam_mkargv.c:21:22: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
char *argvstring = "user = XENDT\\userα user=XENDT\\user1";
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* libpam/pam_misc.c (_pam_mkargv): Add const qualifier to the first
argument.
* libpam/pam_private.h (_pam_mkargv): Likewise.
* tests/tst-pam_mkargv.c (main): Convert argvstring from a pointer into
a static const string, make argvresult array static const.
---
libpam/pam_misc.c | 2 +-
libpam/pam_private.h | 2 +-
tests/tst-pam_mkargv.c | 8 ++++----
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/libpam/pam_misc.c b/libpam/pam_misc.c
index aac0e923..996f23ce 100644
--- a/libpam/pam_misc.c
+++ b/libpam/pam_misc.c
@@ -163,7 +163,7 @@ char *_pam_memdup(const char *x, int len)
/* Generate argv, argc from s */
/* caller must free(argv) */
-int _pam_mkargv(char *s, char ***argv, int *argc)
+int _pam_mkargv(const char *s, char ***argv, int *argc)
{
int l;
int argvlen = 0;
diff --git a/libpam/pam_private.h b/libpam/pam_private.h
index 8cb77528..ed02bb02 100644
--- a/libpam/pam_private.h
+++ b/libpam/pam_private.h
@@ -271,7 +271,7 @@ char *_pam_strdup(const char *s);
char *_pam_memdup(const char *s, int len);
-int _pam_mkargv(char *s, char ***argv, int *argc);
+int _pam_mkargv(const char *s, char ***argv, int *argc);
void _pam_sanitize(pam_handle_t *pamh);
diff --git a/tests/tst-pam_mkargv.c b/tests/tst-pam_mkargv.c
index d3e7a616..cb005e5f 100644
--- a/tests/tst-pam_mkargv.c
+++ b/tests/tst-pam_mkargv.c
@@ -18,16 +18,16 @@
/* Simple program to see if _pam_mkargv() would succeed. */
int main(void)
{
- char *argvstring = "user = XENDT\\userα user=XENDT\\user1";
- const char *argvresult[] = {"user", "=", "XENDT\\userα",
- "user=XENDT\\user1"};
+ static const char argvstring[] = "user = XENDT\\userα user=XENDT\\user1";
+ static const char * const argvresult[] = {"user", "=", "XENDT\\userα",
+ "user=XENDT\\user1"};
int myargc;
char **myargv;
int argvlen;
int explen;
int i;
- explen = (strlen(argvstring) + 1) * ((sizeof(char)) + sizeof(char *));
+ explen = sizeof(argvstring) * ((sizeof(char)) + sizeof(char *));
argvlen = _pam_mkargv(argvstring, &myargv, &myargc);
#if 0
--
ldv
4 years, 2 months
Further fixes for warnings
by Tomas Mraz
In many cases it is impossible to avoid casting out the const so I had
to add -Wno-cast-qual to individual CFLAGS.
IMO explicit cast out should be allowed so we might as well consider
dropping this warning flag from the configure.
OK to commit as is? Or alternatively I can drop -Wcast-qual from
configure.
--
Tomáš Mráz
No matter how far down the wrong road you've gone, turn back.
Turkish proverb
[You'll know whether the road is wrong if you carefully listen to your
conscience.]
4 years, 2 months