From 2e4fa2d0d5d9df3b38b34e96eda0978470535ce1 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Thu, 16 Nov 2023 11:51:53 -0800 Subject: [PATCH 1/8] imp: include sys/wait.h instead of wait.h Problem: Some source files in src/imp include wait.h directly when the more portable solution is to include sys/wait.h. Update the locations in which wait.h is included to instead include sys/wait.h. --- src/imp/exec/exec.c | 2 +- src/imp/test/pidinfo.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/imp/exec/exec.c b/src/imp/exec/exec.c index b7461723..acb33ab2 100644 --- a/src/imp/exec/exec.c +++ b/src/imp/exec/exec.c @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include "src/libutil/kv.h" diff --git a/src/imp/test/pidinfo.c b/src/imp/test/pidinfo.c index 6f0cd4f7..74d021a4 100644 --- a/src/imp/test/pidinfo.c +++ b/src/imp/test/pidinfo.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include From e846ff770fddd73d06953ea63be374732cee1b12 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Thu, 16 Nov 2023 11:54:13 -0800 Subject: [PATCH 2/8] imp: define TMPFS_MAGIC and CGROUP_SUPER_MAGIC if needed Problem: Some systems may not have the definitions of TMPFS_MAGIC and CGROUP_SUPER_MAGIC available (for example musl libc). Add definitions for these two values as found in linux/magic.h in RHEL 8. --- src/imp/pidinfo.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/imp/pidinfo.c b/src/imp/pidinfo.c index 3659ab07..10771f7e 100644 --- a/src/imp/pidinfo.c +++ b/src/imp/pidinfo.c @@ -29,6 +29,12 @@ #ifdef HAVE_LINUX_MAGIC_H #include #endif +#ifndef TMPFS_MAGIC +#define TMPFS_MAGIC 0x01021994 /* from linux/magic.h */ +#endif +#ifndef CGROUP_SUPER_MAGIC +#define CGROUP_SUPER_MAGIC 0x27e0eb +#endif #include #include From 697d549750667b22294f8fd784770198daef135c Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Thu, 16 Nov 2023 11:57:43 -0800 Subject: [PATCH 3/8] add missing stdint.h include Problem: A couple sources are missing a required stdint.h include. --- src/lib/sign.h | 2 ++ t/src/sign.c | 1 + 2 files changed, 3 insertions(+) diff --git a/src/lib/sign.h b/src/lib/sign.h index fcbf44e9..4549c686 100644 --- a/src/lib/sign.h +++ b/src/lib/sign.h @@ -11,6 +11,8 @@ #ifndef _FLUX_SECURITY_SIGN_H #define _FLUX_SECURITY_SIGN_H +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/t/src/sign.c b/t/src/sign.c index 69666d75..165a2966 100644 --- a/t/src/sign.c +++ b/t/src/sign.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "src/lib/context.h" #include "src/lib/sign.h" From f5324a9d049cf525d31794cf1a784fd0ab210801 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Thu, 16 Nov 2023 12:32:51 -0800 Subject: [PATCH 4/8] libutil: replace %F in str[pf]time() with %Y-%m-%d Problem: The %F format specifier used in strptime(3) and strftime(3) is a non-POSIX alias for %Y-%m-%d, so it fails in systems based on musl libc. Replace the %F alias with the full format %T-%m-%d. --- src/libutil/test/cf.c | 2 +- src/libutil/test/tomltk.c | 2 +- src/libutil/timestamp.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libutil/test/cf.c b/src/libutil/test/cf.c index 5de0ae6f..581008e7 100644 --- a/src/libutil/test/cf.c +++ b/src/libutil/test/cf.c @@ -79,7 +79,7 @@ static time_t strtotime (const char *s) { struct tm tm; time_t t; - if (!strptime (s, "%FT%TZ", &tm)) + if (!strptime (s, "%Y-%m-%dT%TZ", &tm)) BAIL_OUT ("strptime: %s failed", s); if ((t = timegm (&tm)) < 0) BAIL_OUT ("timegm: %s failed", s); diff --git a/src/libutil/test/tomltk.c b/src/libutil/test/tomltk.c index ce28a7e3..7f920c1d 100644 --- a/src/libutil/test/tomltk.c +++ b/src/libutil/test/tomltk.c @@ -72,7 +72,7 @@ static bool check_ts (json_t *ts, const char *timestr) return false; if (!gmtime_r (&t, &tm)) return false; - if (strftime (buf, sizeof (buf), "%FT%TZ", &tm) == 0) + if (strftime (buf, sizeof (buf), "%Y-%m-%dT%TZ", &tm) == 0) return false; diag ("%s: %s ?= %s", __FUNCTION__, buf, timestr); return !strcmp (buf, timestr); diff --git a/src/libutil/timestamp.c b/src/libutil/timestamp.c index f3f5caf9..8b598f72 100644 --- a/src/libutil/timestamp.c +++ b/src/libutil/timestamp.c @@ -21,7 +21,7 @@ int timestamp_tostr (time_t t, char *buf, int size) struct tm tm; if (t < 0 || !gmtime_r (&t, &tm)) return -1; - if (strftime (buf, size, "%FT%TZ", &tm) == 0) + if (strftime (buf, size, "%Y-%m-%dT%TZ", &tm) == 0) return -1; return 0; } @@ -30,7 +30,7 @@ int timestamp_fromstr (const char *s, time_t *tp) { struct tm tm; time_t t; - if (!strptime (s, "%FT%TZ", &tm)) + if (!strptime (s, "%Y-%m-%dT%TZ", &tm)) return -1; if ((t = timegm (&tm)) < 0) return -1; From 460a7065111e1674dd16640a30403855af644778 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Thu, 16 Nov 2023 13:00:18 -0800 Subject: [PATCH 5/8] libutil: test/cf.c: skip glob read error test if necessary Problem: The glob(3) implementation on musl libc does not return GLOB_ABORTED when the parent directory of the pattern does not exist, but a unit test for cf_update_glob() depends on this behavior. Skip the test if glob(3) doesn't behave as expected in this situation. --- src/libutil/test/cf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libutil/test/cf.c b/src/libutil/test/cf.c index 581008e7..c23d0b94 100644 --- a/src/libutil/test/cf.c +++ b/src/libutil/test/cf.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "src/libtap/tap.h" #include "cf.h" @@ -528,6 +529,7 @@ void test_update_glob (void) char path3[PATH_MAX + 1]; char invalid[PATH_MAX + 1]; char p [8192]; + glob_t gl; cf_t *cf; const cf_t *cf2, *cf3; @@ -567,18 +569,24 @@ void test_update_glob (void) ok ((cf3 = cf_get_in (cf, "tab3")) != NULL, "found tab3 table in cf"); + errno = 0; ok ((cf_update_glob (cf, "/noexist*", &error) == 0), "cf_update_glob returns 0 on no match"); diag ("%s: %d: %s", error.filename, error.lineno, error.errbuf); like (error.errbuf, "[nN]o [mM]atch", "got expected error text"); - + /* Only run the following tests if this implementation of glob(3) + * returns GLOB_ABORTED when parent dir does not exist. This occurs + * for example on the musl libc version of glob(3). + */ + skip (glob ("/noexist/*", GLOB_ERR, NULL, &gl) != GLOB_ABORTED, 2); errno = 0; ok ((cf_update_glob (cf, "/noexist/*", &error) < 0) && errno == EINVAL, "cf_update_glob fails on read error"); diag ("%s: %d: %s", error.filename, error.lineno, error.errbuf); like (error.errbuf, "[rR]ead [eE]rror", "got expected error text"); + end_skip; cf_destroy (cf); From a7b5a7e0860410484217891ca89021ce70f79e95 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Thu, 16 Nov 2023 13:02:51 -0800 Subject: [PATCH 6/8] testsuite: allow t/src/getpwuid.c to compile against musl Problem: musl libc doesn't have fgetpwent_r(3), so compilation of t/src/getpwuid.c fails. The program is not multithreaded, so switch to fgetpwent(3) and getpwuid(3). --- t/src/getpwuid.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/t/src/getpwuid.c b/t/src/getpwuid.c index 3c09bc9e..f457d77d 100644 --- a/t/src/getpwuid.c +++ b/t/src/getpwuid.c @@ -24,14 +24,12 @@ struct passwd *getpwuid (uid_t uid) { const char *filename; - static char buf[4096]; - static struct passwd pw; struct passwd *pwp = NULL; if ((filename = getenv ("TEST_PASSWD_FILE"))) { FILE *f; if ((f = fopen (filename, "r"))) { - while (fgetpwent_r (f, &pw, buf, sizeof (buf), &pwp) == 0) { + while ((pwp = fgetpwent (f))) { if (pwp->pw_uid == uid) break; } @@ -39,7 +37,7 @@ struct passwd *getpwuid (uid_t uid) } } else - getpwuid_r (uid, &pw, buf, sizeof (buf), &pwp); + pwp = getpwuid (uid); if (pwp == NULL) errno = ENOENT; From a39a431a5b54798e6328340f69d7de9f4fd110a8 Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Thu, 16 Nov 2023 13:07:11 -0800 Subject: [PATCH 7/8] ci: add alpine linux build to ci Problem: flux-security is not tested on the musl libc based alpine distribution. Add an alpine build to generate-matrix.py. --- src/test/generate-matrix.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/test/generate-matrix.py b/src/test/generate-matrix.py index f1765b97..3d703434 100755 --- a/src/test/generate-matrix.py +++ b/src/test/generate-matrix.py @@ -155,4 +155,11 @@ def __str__(self): args="--enable-sanitizers", pam=False, # asan not compatible with PAM tests ) + +# alpine +matrix.add_build( + name="alpine", + image="alpine", +) + print(matrix) From 30b82cbb5613583ef7e24020ea315eff051ee18b Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Thu, 16 Nov 2023 13:26:04 -0800 Subject: [PATCH 8/8] readthedocs: add missing build section to config Problem: The build.os parameter is now required for readthedocs. Add a build section to readthedocs.yml. --- .readthedocs.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 7d293e8e..99271bfe 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,6 +1,11 @@ # Required version: 2 +build: + os: ubuntu-22.04 + tools: + python: "3.11" + # Build documentation in the docs/ directory with Sphinx sphinx: configuration: doc/conf.py