From 7a5aac8d0bcb3c532c788af891e839abdf13455d Mon Sep 17 00:00:00 2001 From: Chris Dunlap Date: Wed, 5 Jun 2024 15:48:46 -0700 Subject: [PATCH 1/3] WIP: Build: Replace libmissing.la with portable libobj dir Work in progress. Reference: - https://www.eyrie.org/~eagle/notes/style/build.html --- Make-inc.mk | 1 - Makefile.am | 1 - configure.ac | 4 +-- src/libmissing/URL => portable/README | 1 + {src/libmissing => portable}/inet_ntop.c | 0 {src/libmissing => portable}/inet_ntop.h | 14 ++++----- {src/libmissing => portable}/strlcat.c | 0 {src/libmissing => portable}/strlcat.h | 11 +++++-- {src/libmissing => portable}/strlcpy.c | 0 {src/libmissing => portable}/strlcpy.h | 11 +++++-- src/Makefile.am | 1 - src/libmissing/Makefile.am | 28 ------------------ src/libmissing/missing.h | 37 ------------------------ src/munge/Makefile.am | 8 ++--- src/munge/unmunge.c | 2 +- src/munged/Makefile.am | 4 +-- src/munged/conf.c | 3 +- src/munged/munged.c | 2 +- src/mungekey/Makefile.am | 2 -- src/mungekey/conf.c | 1 - 20 files changed, 35 insertions(+), 96 deletions(-) rename src/libmissing/URL => portable/README (63%) rename {src/libmissing => portable}/inet_ntop.c (100%) rename {src/libmissing => portable}/inet_ntop.h (90%) rename {src/libmissing => portable}/strlcat.c (100%) rename {src/libmissing => portable}/strlcat.h (73%) rename {src/libmissing => portable}/strlcpy.c (100%) rename {src/libmissing => portable}/strlcpy.h (66%) delete mode 100644 src/libmissing/Makefile.am delete mode 100644 src/libmissing/missing.h diff --git a/Make-inc.mk b/Make-inc.mk index 17005b09..22a5d0c9 100644 --- a/Make-inc.mk +++ b/Make-inc.mk @@ -6,7 +6,6 @@ # Dependencies to ensure libraries get rebuilt. # $(top_builddir)/src/libcommon/libcommon.la \ -$(top_builddir)/src/libmissing/libmissing.la \ $(top_builddir)/src/libmunge/libmunge.la \ $(top_builddir)/src/libtap/libtap.la \ : force-dependency-check diff --git a/Makefile.am b/Makefile.am index 8f19bb13..53613121 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,7 +65,6 @@ MAINTAINERCLEANFILES = \ src/Makefile.in \ src/etc/Makefile.in \ src/libcommon/Makefile.in \ - src/libmissing/Makefile.in \ src/libmunge/Makefile.in \ src/munge/Makefile.in \ src/munged/Makefile.in \ diff --git a/configure.ac b/configure.ac index f67cc9cd..dac164ad 100644 --- a/configure.ac +++ b/configure.ac @@ -12,6 +12,7 @@ AC_SUBST([DATE], m4_esyscmd([build-aux/gen-date])) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_LIBOBJ_DIR([portable]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([src/libmunge/munge.h]) AC_REQUIRE_AUX_FILE([tap-driver.sh]) @@ -25,7 +26,7 @@ X_AC_WITH_LOGROTATEDDIR X_AC_WITH_PKGCONFIGDIR X_AC_HUMOR -AM_INIT_AUTOMAKE([1.12 foreign dist-xz no-dist-gzip]) +AM_INIT_AUTOMAKE([1.12 foreign dist-xz no-dist-gzip subdir-objects]) AM_MAINTAINER_MODE AM_SILENT_RULES([yes]) AC_USE_SYSTEM_EXTENSIONS @@ -121,7 +122,6 @@ AC_CONFIG_FILES( \ src/common/Makefile \ src/etc/Makefile \ src/libcommon/Makefile \ - src/libmissing/Makefile \ src/libmunge/Makefile \ src/libtap/Makefile \ src/munge/Makefile \ diff --git a/src/libmissing/URL b/portable/README similarity index 63% rename from src/libmissing/URL rename to portable/README index a70fd296..f60fbecf 100644 --- a/src/libmissing/URL +++ b/portable/README @@ -1 +1,2 @@ +strlcat & strlcpy source from: ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/ diff --git a/src/libmissing/inet_ntop.c b/portable/inet_ntop.c similarity index 100% rename from src/libmissing/inet_ntop.c rename to portable/inet_ntop.c diff --git a/src/libmissing/inet_ntop.h b/portable/inet_ntop.h similarity index 90% rename from src/libmissing/inet_ntop.h rename to portable/inet_ntop.h index 6dc790b5..a72b8fc8 100644 --- a/src/libmissing/inet_ntop.h +++ b/portable/inet_ntop.h @@ -25,22 +25,22 @@ *****************************************************************************/ -#ifndef INET_NTOP_H -#define INET_NTOP_H +#ifndef MUNGE_INET_NTOP_H +#define MUNGE_INET_NTOP_H #if HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif /* HAVE_CONFIG_H */ #ifndef INET_ADDRSTRLEN -# define INET_ADDRSTRLEN 16 +#define INET_ADDRSTRLEN 16 #endif /* !INET_ADDRSTRLEN */ #if HAVE_INET_NTOP -# include +#include #else /* !HAVE_INET_NTOP */ -# include +#include const char *inet_ntop (int af, const void *src, char *dst, socklen_t cnt); #endif /* !HAVE_INET_NTOP */ -#endif /* !INET_NTOP_H */ +#endif /* !MUNGE_INET_NTOP_H */ diff --git a/src/libmissing/strlcat.c b/portable/strlcat.c similarity index 100% rename from src/libmissing/strlcat.c rename to portable/strlcat.c diff --git a/src/libmissing/strlcat.h b/portable/strlcat.h similarity index 73% rename from src/libmissing/strlcat.h rename to portable/strlcat.h index 1c7fd252..f2ea9734 100644 --- a/src/libmissing/strlcat.h +++ b/portable/strlcat.h @@ -1,8 +1,13 @@ +#ifndef MUNGE_STRLCAT_H +#define MUNGE_STRLCAT_H + #if HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif /* HAVE_CONFIG_H */ -#if !HAVE_STRLCAT +#if HAVE_STRLCAT +#include +#else /* !HAVE_STRLCAT */ size_t strlcat(char *dst, const char *src, size_t siz); /* * Appends src to string dst of size siz (unlike strncat, siz is the @@ -12,3 +17,5 @@ size_t strlcat(char *dst, const char *src, size_t siz); * If retval >= siz, truncation occurred. */ #endif /* !HAVE_STRLCAT */ + +#endif /* !MUNGE_STRLCAT_H */ diff --git a/src/libmissing/strlcpy.c b/portable/strlcpy.c similarity index 100% rename from src/libmissing/strlcpy.c rename to portable/strlcpy.c diff --git a/src/libmissing/strlcpy.h b/portable/strlcpy.h similarity index 66% rename from src/libmissing/strlcpy.h rename to portable/strlcpy.h index 42ed5f0c..384c079f 100644 --- a/src/libmissing/strlcpy.h +++ b/portable/strlcpy.h @@ -1,8 +1,13 @@ +#ifndef MUNGE_STRLCPY_H +#define MUNGE_STRLCPY_H + #if HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif /* HAVE_CONFIG_H */ -#if !HAVE_STRLCPY +#if HAVE_STRLCPY +#include +#else /* !HAVE_STRLCPY */ size_t strlcpy(char *dst, const char *src, size_t siz); /* * Copy src to string dst of size siz. At most siz-1 characters @@ -10,3 +15,5 @@ size_t strlcpy(char *dst, const char *src, size_t siz); * Returns strlen(src); if retval >= siz, truncation occurred. */ #endif /* !HAVE_STRLCPY */ + +#endif /* !MUNGE_STRLCPY_H */ diff --git a/src/Makefile.am b/src/Makefile.am index e9d17d6b..54176b77 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,7 +9,6 @@ SUBDIRS = \ common \ etc \ libcommon \ - libmissing \ libmunge \ libtap \ munge \ diff --git a/src/libmissing/Makefile.am b/src/libmissing/Makefile.am deleted file mode 100644 index 6a975a60..00000000 --- a/src/libmissing/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -# MUNGE src/libmissing/Makefile.am -# -# This file is part of the MUNGE Uid 'N' Gid Emporium (MUNGE). -# For details, see . - -include $(top_srcdir)/Make-inc.mk - -noinst_LTLIBRARIES = \ - libmissing.la \ - # End of noinst_LTLIBRARIES - -libmissing_la_LIBADD = \ - $(LTLIBOBJS) \ - # End of libmissing_la_LIBADD - -libmissing_la_SOURCES = \ - missing.h \ - # End of libmissing_la_SOURCES - -EXTRA_libmissing_la_SOURCES = \ - inet_ntop.h \ - strlcat.h \ - strlcpy.h \ - # End of EXTRA_libmissing_la_SOURCES - -EXTRA_DIST = \ - URL \ - # End of EXTRA_DIST diff --git a/src/libmissing/missing.h b/src/libmissing/missing.h deleted file mode 100644 index 2553cb74..00000000 --- a/src/libmissing/missing.h +++ /dev/null @@ -1,37 +0,0 @@ -/***************************************************************************** - * Copyright (C) 2007-2024 Lawrence Livermore National Security, LLC. - * Copyright (C) 2002-2007 The Regents of the University of California. - * UCRL-CODE-155910. - * - * This file is part of the MUNGE Uid 'N' Gid Emporium (MUNGE). - * For details, see . - * - * MUNGE is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free - * Software Foundation, either version 3 of the License, or (at your option) - * any later version. Additionally for the MUNGE library (libmunge), you - * can redistribute it and/or modify it under the terms of the GNU Lesser - * General Public License as published by the Free Software Foundation, - * either version 3 of the License, or (at your option) any later version. - * - * MUNGE is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * and GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * and GNU Lesser General Public License along with MUNGE. If not, see - * . - *****************************************************************************/ - - -#ifndef MUNGE_MISSING_H -#define MUNGE_MISSING_H - -/* These contain prototypes and whatnot for libmissing. - */ -#include "inet_ntop.h" -#include "strlcat.h" -#include "strlcpy.h" - -#endif /* !MUNGE_MISSING_H */ diff --git a/src/munge/Makefile.am b/src/munge/Makefile.am index 6a439a3f..ea7a8463 100644 --- a/src/munge/Makefile.am +++ b/src/munge/Makefile.am @@ -41,13 +41,11 @@ bin_PROGRAMS = \ munge_CPPFLAGS = \ -I$(top_srcdir)/src/common \ -I$(top_srcdir)/src/libcommon \ - -I$(top_srcdir)/src/libmissing \ -I$(top_srcdir)/src/libmunge \ # End of munge_CPPFLAGS munge_LDADD = \ $(top_builddir)/src/libcommon/libcommon.la \ - $(top_builddir)/src/libmissing/libmissing.la \ $(top_builddir)/src/libmunge/libmunge.la \ # End of munge_LDADD @@ -69,13 +67,11 @@ remunge_CPPFLAGS = \ -DWITH_PTHREADS \ -I$(top_srcdir)/src/common \ -I$(top_srcdir)/src/libcommon \ - -I$(top_srcdir)/src/libmissing \ -I$(top_srcdir)/src/libmunge \ # End of remunge_CPPFLAGS remunge_LDADD = \ $(top_builddir)/src/libcommon/libcommon.la \ - $(top_builddir)/src/libmissing/libmissing.la \ $(top_builddir)/src/libmunge/libmunge.la \ $(LIBPTHREAD) \ # End of remunge_LDADD @@ -93,15 +89,15 @@ remunge_SOURCES = \ # End of remunge_SOURCES unmunge_CPPFLAGS = \ + -I$(top_srcdir)/portable \ -I$(top_srcdir)/src/common \ -I$(top_srcdir)/src/libcommon \ - -I$(top_srcdir)/src/libmissing \ -I$(top_srcdir)/src/libmunge \ # End of unmunge_CPPFLAGS unmunge_LDADD = \ + $(LIBOBJS) \ $(top_builddir)/src/libcommon/libcommon.la \ - $(top_builddir)/src/libmissing/libmissing.la \ $(top_builddir)/src/libmunge/libmunge.la \ # End of unmunge_LDADD diff --git a/src/munge/unmunge.c b/src/munge/unmunge.c index 7493a7c0..7de38b37 100644 --- a/src/munge/unmunge.c +++ b/src/munge/unmunge.c @@ -48,9 +48,9 @@ #include #include #include "common.h" +#include "inet_ntop.h" #include "license.h" #include "log.h" -#include "missing.h" /* for inet_ntop() */ #include "read.h" #include "version.h" #include "xsignal.h" diff --git a/src/munged/Makefile.am b/src/munged/Makefile.am index 6a2bf339..ce753acc 100644 --- a/src/munged/Makefile.am +++ b/src/munged/Makefile.am @@ -40,15 +40,15 @@ munged_CPPFLAGS = \ -DRUNSTATEDIR='"$(runstatedir)"' \ -DSYSCONFDIR='"$(sysconfdir)"' \ -DWITH_PTHREADS \ + -I$(top_srcdir)/portable \ -I$(top_srcdir)/src/common \ -I$(top_srcdir)/src/libcommon \ - -I$(top_srcdir)/src/libmissing \ -I$(top_srcdir)/src/libmunge \ # End of munged_CPPFLAGS munged_LDADD = \ + $(LIBOBJS) \ $(top_builddir)/src/libcommon/libcommon.la \ - $(top_builddir)/src/libmissing/libmissing.la \ $(top_builddir)/src/libmunge/libmunge.la \ $(LIBPTHREAD) \ $(LIBBZ2) \ diff --git a/src/munged/conf.c b/src/munged/conf.c index 4b5b5de6..28daaecf 100644 --- a/src/munged/conf.c +++ b/src/munged/conf.c @@ -29,7 +29,6 @@ # include #endif /* HAVE_CONFIG_H */ -#include /* for inet_ntop() */ #include #include #include @@ -45,11 +44,11 @@ #include #include "clock.h" #include "conf.h" +#include "inet_ntop.h" #include "license.h" #include "lock.h" #include "log.h" #include "md.h" -#include "missing.h" /* for inet_ntop() */ #include "munge_defs.h" #include "net.h" #include "path.h" diff --git a/src/munged/munged.c b/src/munged/munged.c index 90e664b6..62e52cb3 100644 --- a/src/munged/munged.c +++ b/src/munged/munged.c @@ -58,12 +58,12 @@ #include "lock.h" #include "log.h" #include "md.h" -#include "missing.h" #include "munge_defs.h" #include "path.h" #include "random.h" #include "replay.h" #include "str.h" +#include "strlcpy.h" #include "timer.h" #include "xsignal.h" diff --git a/src/mungekey/Makefile.am b/src/mungekey/Makefile.am index b7a0ea9e..62ec4353 100644 --- a/src/mungekey/Makefile.am +++ b/src/mungekey/Makefile.am @@ -39,13 +39,11 @@ mungekey_CPPFLAGS = \ -DSYSCONFDIR='"$(sysconfdir)"' \ -I$(top_srcdir)/src/common \ -I$(top_srcdir)/src/libcommon \ - -I$(top_srcdir)/src/libmissing \ -I$(top_srcdir)/src/libmunge \ # End of mungekey_CPPFLAGS mungekey_LDADD = \ $(top_builddir)/src/libcommon/libcommon.la \ - $(top_builddir)/src/libmissing/libmissing.la \ $(top_builddir)/src/libmunge/libmunge.la \ $(CRYPTO_LIBS) \ # End of mungekey_LDADD diff --git a/src/mungekey/conf.c b/src/mungekey/conf.c index 047bd7d1..25905219 100644 --- a/src/mungekey/conf.c +++ b/src/mungekey/conf.c @@ -40,7 +40,6 @@ #include "conf.h" #include "license.h" #include "log.h" -#include "missing.h" #include "munge_defs.h" #include "version.h" From ddf656e44cb976ed7e82372a115104d5c35d6c9d Mon Sep 17 00:00:00 2001 From: Chris Dunlap Date: Tue, 11 Jun 2024 22:47:06 -0700 Subject: [PATCH 2/3] WIP: Fix distcheck --- Makefile.am | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile.am b/Makefile.am index 53613121..75f4280d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,6 +35,9 @@ EXTRA_DIST = \ build-aux/gen-version \ build-aux/tap-driver.sh \ doc \ + portable/inet_ntop.h \ + portable/strlcat.h \ + portable/strlcpy.h \ $(TEMPLATE_FILES) \ # End of EXTRA_DIST From 7f8bab19452b681abfa0c882f3a7f335e8db49ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Tue, 18 Jun 2024 10:24:51 +0200 Subject: [PATCH 3/3] chore: add support for github action --- .github/workflows/build.yml | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..ac5e9068 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,38 @@ +name: C Project CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-test: + name: Build and Test on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up dependencies + run: | + if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then + sudo apt-get update + sudo apt-get install -y build-essential + elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then + brew update + brew install gcc + fi + + - name: Build project + run: | + ./configure + make + make check + make install