Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into modify_1400
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaudill authored Apr 22, 2024
2 parents 4996b4e + 649c710 commit feee043
Show file tree
Hide file tree
Showing 23 changed files with 364 additions and 86 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ jobs:
steps:
- uses: actions/checkout@v3

# This allows SSH access to the GitHub Actions VM to debug things that
# only happen on CI. Comment out unless needed. WARNING: tmate.io has
# access to unencrypted SSH traffic.
# See: https://github.com/marketplace/actions/debugging-with-tmate
#- name: set up tmate session
# uses: mxschmitt/action-tmate@v3
# with:
# detached: true

- name: early setup & validation
run: |
[[ -n $CH_TEST_BUILDER ]]
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.37~pre
0.38~pre
3 changes: 2 additions & 1 deletion bin/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ if HAVE_LIBSQUASHFUSE
ch_run_SOURCES += ch_fuse.h ch_fuse.c
endif

ch_run_CFLAGS = $(CFLAGS) $(PTHREAD_CFLAGS)
# additional build flags for ch-run
ch_run_CFLAGS = $(PTHREAD_CFLAGS)
ch_run_LDADD = $(CH_RUN_LIBS)


Expand Down
2 changes: 2 additions & 0 deletions bin/ch-image.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ if (__name__ == "__main__"):
for (opt, arg) in zip(sys.argv[1:], sys.argv[2:] + [None]):
(opt, _, arg_eq) = opt.partition("=")
if (opt == "--break"):
if (not sys.stdin.isatty()):
ch.FATAL("--break: standard input must be a terminal")
if (arg_eq != ""):
arg = arg_eq
try:
Expand Down
12 changes: 12 additions & 0 deletions bin/ch-run.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,12 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
exit(0);
#else
exit(ERR_CHRUN);
#endif
} else if (!strcmp(arg, "overlayfs")) {
#ifdef HAVE_OVERLAYFS
exit(0);
#else
exit(1);
#endif
} else if (!strcmp(arg, "seccomp")) {
#ifdef HAVE_SECCOMP
Expand All @@ -458,6 +464,12 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
exit(0);
#else
exit(ERR_CHRUN);
#endif
} else if (!strcmp(arg, "tmpfs-xattrs")) {
#ifdef HAVE_TMPFS_XATTRS
exit(0);
#else
exit(1);
#endif
}
else
Expand Down
45 changes: 33 additions & 12 deletions bin/ch_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,27 @@
/* Timeout in seconds for waiting for join semaphore. */
#define JOIN_TIMEOUT 30

/* Maximum length of paths we're willing to deal with. (Note that
/* Maximum length of paths were willing to deal with. (Note that
system-defined PATH_MAX isn't reliable.) */
#define PATH_CHARS 4096

/* Mount point for the tmpfs used by -W. We want this to be (a) always
available [1], (b) short, (c) not used by anything else we care about
during container setup, and (d) not wildly confusing if users see it in an
error message. Must be a string literal because we use C’s literal
concatenation feature. Options considered (all of these required by FHS):
/boot Not present if host is booted in some strange way?
/etc Likely very reliable but seems risky
/mnt Used for images on GitHub Actions and causes CI failures
/opt Seems very omittable
/srv I’ve never actually seen it used; reliable?
/var Too aggressive?
/var/spool Long; omittable for lightweight hosts?
[1]: https://www.pathname.com/fhs/pub/fhs-2.3.pdf */
#define WF_MNT "/srv"


/** Constants **/

Expand Down Expand Up @@ -306,26 +323,30 @@ void enter_udss(struct container *c)
// https://www.kernel.org/doc/html/v5.11/filesystems/tmpfs.html
// https://www.kernel.org/doc/html/v5.11/filesystems/overlayfs.html
if (c->overlay_size != NULL) {
VERBOSE("overlaying tmpfs for --write-fake (%s)", c->overlay_size);
char *options;
struct stat st;
VERBOSE("overlaying tmpfs for --write-fake (%s)", c->overlay_size);
T_ (1 <= asprintf(&options, "size=%s", c->overlay_size));
Zf (mount(NULL, "/mnt", "tmpfs", 0, options), // host should have /mnt
Zf (mount(NULL, WF_MNT, "tmpfs", 0, options),
"cannot mount tmpfs for overlay");
free(options);
Z_ (mkdir("/mnt/upper", 0700));
Z_ (mkdir("/mnt/work", 0700));
Z_ (mkdir("/mnt/merged", 0700));
mkdir_scratch = "/mnt/mkdir_overmount";
Z_ (mkdir(WF_MNT "/upper", 0700));
Z_ (mkdir(WF_MNT "/work", 0700));
Z_ (mkdir(WF_MNT "/merged", 0700));
mkdir_scratch = WF_MNT "/mkdir_overmount";
Z_ (mkdir(mkdir_scratch, 0700));
T_ (1 <= asprintf(&options, "lowerdir=%s,upperdir=%s,workdir=%s,"
"index=on,userxattr,volatile",
c->newroot, "/mnt/upper", "/mnt/work"));
T_ (1 <= asprintf(&options, ("lowerdir=%s,upperdir=%s,workdir=%s,"
"index=on,userxattr,volatile"),
c->newroot, WF_MNT "/upper", WF_MNT "/work"));
// update newroot
c->newroot = "/mnt/merged";
Zf (stat(c->newroot, &st),
"can't stat new root; overmounted by tmpfs for -W?: %s", c->newroot);
c->newroot = WF_MNT "/merged";
free(nr_parent);
free(nr_base);
path_split(c->newroot, &nr_parent, &nr_base);
Zf (mount(NULL, c->newroot, "overlay", 0, options), "can't overlay");
Zf (mount(NULL, c->newroot, "overlay", 0, options),
"can't overlay: %s, %s", c->newroot, options);
VERBOSE("newroot updated: %s", c->newroot);
free(options);
}
Expand Down
5 changes: 5 additions & 0 deletions bin/ch_fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
// SquashFUSE redefines __le16 unless HAVE_LINUX_TYPES_LE16 is defined. We are
// assuming it is defined in <linux/types.h> on your machine.
#define HAVE_LINUX_TYPES_LE16
// The forget operation in libfuse3 takes uint64_t as third parameter,
// while SquashFUSE defaults to unsigned long as used in libfuse2.
// This causes a mess on arches with different size of these types,
// so explicitly switch to the libfuse3 variant.
#define HAVE_FUSE_LL_FORGET_OP_64T
// Now we can include ll.h.
#include <squashfuse/ll.h>

Expand Down
34 changes: 19 additions & 15 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ MKDIR_P=${MKDIR_P:-install -d -m 0755}

AM_INIT_AUTOMAKE([1.13 -Wall -Werror foreign subdir-objects])

# Check for “pkg-config”. It’s here because we use PKG_CHECK_MODULES
# conditionally later and we want to make sure this always happens [1, §3.4].
#
# [1]: https://autotools.info/pkgconfig/pkg_check_modules.html
PKG_PROG_PKG_CONFIG

AC_CONFIG_HEADERS([bin/config.h])
AC_CONFIG_FILES([Makefile
bin/Makefile
Expand Down Expand Up @@ -349,6 +343,7 @@ AC_MSG_RESULT($have_userns)
AC_DEFUN([CH_OVERLAY_C], [[
#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -491,17 +486,22 @@ have_libfuse3=n/a
have_libsquashfuse_ll=n/a
have_ll_h=n/a
AS_IF([test $want_libsquashfuse = yes], [
# libfuse3. Must use pkg-config because as of version 0.5.0 SquashFUSE’s
# ll.h won’t build without an appropriate -I [1]. This macro defines some
# variables that we use here; see this third-party documentation [2]. (I
# could not find first-party docs for it.)
# libfuse3. As of version 0.5.0, SquashFUSE’s ll.h won’t build without an
# appropriate -I [1]. Presently we use pkg-config to find it, but see #1844.
#
# We avoid PKG_CHECK_MODULES because it introduces a dependency on
# pkg-config at autogen.sh time, with impressively incomprehensible error
# messages if it’s not met [2]. The approach below also seems simpler [3]?
#
# [1]: https://github.com/vasi/squashfuse/commit/eca5764
# [2]: https://autotools.info/pkgconfig/pkg_check_modules.html
PKG_CHECK_MODULES([fuse3], [fuse3], [
# libfuse3 found
# [2]: https://ae1020.github.io/undefined-macro-pkg-config/
# [3]: https://tirania.org/blog/archive/2012/Oct-20.html
AC_CHECK_PROG(have_pkg_config, pkg-config, yes, no)
AS_IF([test $have_pkg_config != yes],
[AC_MSG_ERROR([need pkg-config to find libfuse3; try --with-libsquashfuse=no or see issue @%:@1844])])
AS_IF([pkg-config --exists fuse3], [
have_libfuse3=yes
CFLAGS="$CFLAGS $fuse3_CFLAGS"
CFLAGS="$CFLAGS $(pkg-config --cflags fuse3)"
# libsquashfuse?
AC_CHECK_LIB([squashfuse_ll], [sqfs_ll_mount],
[have_libsquashfuse_ll=yes],
Expand Down Expand Up @@ -787,6 +787,10 @@ AC_SUBST([CH_RUN_LIBS])
AC_SUBST([PYTHON_SHEBANG])
AC_SUBST([SPHINX])

AS_IF([test $have_overlayfs = yes],
[AC_DEFINE([HAVE_OVERLAYFS], [1], [unprivileged overlayfs])])
AS_IF([test $have_tmpfs_xattrs = yes],
[AC_DEFINE([HAVE_TMPFS_XATTRS], [1], [tmpfs user xattrs])])
AS_IF([test $have_fnm_extmatch = yes],
[AC_DEFINE([HAVE_FNM_EXTMATCH], [1], [extended globs supported])])
AS_IF([test $have_seccomp = yes],
Expand Down Expand Up @@ -942,7 +946,7 @@ Building Charliecloud
test suite ... ${enable_test}
required:
C99 compiler ... ${CC} ${CC_VERSION}
C99 compiler ... ${CC} ${CFLAGS}
optional:
extended glob patterns in --unset-env ... ${have_fnm_extmatch}
Expand Down
14 changes: 7 additions & 7 deletions doc/_loc.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
.. Do not edit this file — it’s auto-generated.
We pride ourselves on keeping Charliecloud lightweight and simple. The lines
of code as of version 0.36 is:
of code as of version 0.37 is:

.. list-table::

* - Program itself
- 8924
- 9079
* - Test suite & examples
- 11941
- 12019
* - Documentation
- 6311
- 6416
* - Build system
- 1289
- 1294
* - Packaging
- 628
- 629
* - Miscellaneous
- 506
* - Total
- 29599
- 29943

These include code only, excluding blank lines and comments. They were counted
using `cloc <https://github.com/AlDanial/cloc>`_ version 1.96.
Expand Down
Loading

0 comments on commit feee043

Please sign in to comment.