diff -Nru pseudo-1.9.0+git20190515+996bead/ChangeLog.txt pseudo-1.9.0+git20200626+067950b/ChangeLog.txt --- pseudo-1.9.0+git20190515+996bead/ChangeLog.txt 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/ChangeLog.txt 2020-06-26 10:44:05.000000000 +0000 @@ -1,3 +1,10 @@ +2019-08-02: + * (seebs) Pass flags & O_NOFOLLOW, also use that to influence + stat types. Note. &. Not |. + +2019-08-01: + * (seebs) Pass flags|O_NOFOLLOW on when resolving paths with openat. + 2019-05-15: * (RP) Add SDPX license headers to source files. diff -Nru pseudo-1.9.0+git20190515+996bead/debian/changelog pseudo-1.9.0+git20200626+067950b/debian/changelog --- pseudo-1.9.0+git20190515+996bead/debian/changelog 2020-03-31 18:49:10.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/debian/changelog 2020-07-12 09:38:55.000000000 +0000 @@ -1,8 +1,26 @@ -pseudo (1.9.0+git20190515+996bead-2ubuntu1) focal; urgency=medium +pseudo (1.9.0+git20200626+067950b-2) unstable; urgency=medium - * Build using python2. + * Fix the Python 3 build dependency (Closes: #964918). - -- Matthias Klose Tue, 31 Mar 2020 20:49:10 +0200 + -- Andrej Shadura Sun, 12 Jul 2020 11:38:55 +0200 + +pseudo (1.9.0+git20200626+067950b-1) unstable; urgency=medium + + * New upstream snapshot (Closes: #943180). + * debian/watch: Track both the HEAD and oe-core branch + * Refresh the patches. + * Bump Standards-Version to 4.5.0. + * Set upstream metadata fields: Repository. + + -- Andrej Shadura Fri, 10 Jul 2020 18:53:31 +0200 + +pseudo (1.9.0+git20190802+060058b-1) unstable; urgency=medium + + * New upstream snapshot. + * Use rather than the deprecated from libattr + (Closes: #953906). + + -- Andrej Shadura Sat, 14 Mar 2020 20:28:38 +0100 pseudo (1.9.0+git20190515+996bead-2) unstable; urgency=medium diff -Nru pseudo-1.9.0+git20190515+996bead/debian/control pseudo-1.9.0+git20200626+067950b/debian/control --- pseudo-1.9.0+git20190515+996bead/debian/control 2020-03-31 18:49:09.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/debian/control 2020-07-12 09:38:55.000000000 +0000 @@ -7,8 +7,8 @@ debhelper-compat (= 12), libattr1-dev, libsqlite3-dev, - python2, -Standards-Version: 4.3.0 + python3, +Standards-Version: 4.5.0 Homepage: https://www.yoctoproject.org/software-item/pseudo/ Vcs-Browser: https://salsa.debian.org/debian/pseudo Vcs-Git: https://salsa.debian.org/debian/pseudo.git diff -Nru pseudo-1.9.0+git20190515+996bead/debian/patches/0001-Use-sys-xattr.h-rather-than-the-deprecated-attr-xatt.patch pseudo-1.9.0+git20200626+067950b/debian/patches/0001-Use-sys-xattr.h-rather-than-the-deprecated-attr-xatt.patch --- pseudo-1.9.0+git20190515+996bead/debian/patches/0001-Use-sys-xattr.h-rather-than-the-deprecated-attr-xatt.patch 1970-01-01 00:00:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/debian/patches/0001-Use-sys-xattr.h-rather-than-the-deprecated-attr-xatt.patch 2020-07-12 09:38:55.000000000 +0000 @@ -0,0 +1,68 @@ +From: Andrej Shadura +Date: Sat, 14 Mar 2020 20:08:43 +0100 +Subject: Use rather than the deprecated from + libattr + +In the Debian bug #953906 Guillem Jover writes: + +> The former header has been removed in upstream libattr, but got +> reintroduced in Debian to avoid breakage just before the Debian buster +> freeze. But I'd like to be able to remove it in Debian too, so that +> the interface can be synced with upstream. + +Bug-Debian: https://bugs.debian.org/953906 +--- + ports/linux/subports | 3 +-- + ports/linux/xattr/portdefs.h | 1 - + ports/linux/xattr/pseudo_wrappers.c | 4 ++-- + 3 files changed, 3 insertions(+), 5 deletions(-) + +diff --git a/ports/linux/subports b/ports/linux/subports +index 740ec83..115a4f1 100755 +--- a/ports/linux/subports ++++ b/ports/linux/subports +@@ -30,11 +30,10 @@ if $port_xattr; then + cat > dummy.c < + #include +-#include + int i; + EOF + if ! ${CC} -c -o dummy.o dummy.c >/dev/null 2>&1; then +- echo >&2 "Warning: Can't compile trivial program using ". ++ echo >&2 "Warning: Can't compile trivial program using ". + echo >&2 " xattr support will require that header." + fi + echo "linux/xattr" +diff --git a/ports/linux/xattr/portdefs.h b/ports/linux/xattr/portdefs.h +index 068d39a..cd2e2f5 100644 +--- a/ports/linux/xattr/portdefs.h ++++ b/ports/linux/xattr/portdefs.h +@@ -3,5 +3,4 @@ + * + */ + #include +-#include + #include +diff --git a/ports/linux/xattr/pseudo_wrappers.c b/ports/linux/xattr/pseudo_wrappers.c +index 3e122d9..6965a61 100644 +--- a/ports/linux/xattr/pseudo_wrappers.c ++++ b/ports/linux/xattr/pseudo_wrappers.c +@@ -135,7 +135,7 @@ static ssize_t shared_getxattr(const char *path, int fd, const char *name, void + path ? path : "", fd, name); + pseudo_msg_t *result = pseudo_client_op(OP_GET_XATTR, 0, fd, -1, path, &buf, name); + if (result->result != RESULT_SUCCEED) { +- errno = ENOATTR; ++ errno = ENODATA; + return -1; + } + +@@ -256,7 +256,7 @@ static ssize_t shared_listxattr(const char *path, int fd, char *list, size_t siz + pseudo_msg_t *result = pseudo_client_op(OP_LIST_XATTR, 0, fd, -1, path, &buf); + if (result->result != RESULT_SUCCEED) { + pseudo_debug(PDBGF_XATTR, "listxattr: no success.\n"); +- errno = ENOATTR; ++ errno = ENODATA; + return -1; + } + if (list) { diff -Nru pseudo-1.9.0+git20190515+996bead/debian/patches/0002-disable-bitwidth-guessing.patch pseudo-1.9.0+git20200626+067950b/debian/patches/0002-disable-bitwidth-guessing.patch --- pseudo-1.9.0+git20190515+996bead/debian/patches/0002-disable-bitwidth-guessing.patch 2019-07-28 19:24:03.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/debian/patches/0002-disable-bitwidth-guessing.patch 2020-07-12 09:38:55.000000000 +0000 @@ -1,17 +1,17 @@ -From: Andrew Shadura +From: Andrej Shadura Date: Fri, 29 Apr 2016 12:14:08 +0200 X-Dgit-Generated: 1.7.5-2 505a1b005eb8b429ec5823fbf246578372f140c7 -Subject: [PATCH] Disable bitwidth guessing. +Subject: Disable bitwidth guessing. --- configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure b/configure -index e5ef9ce..2be0644 100755 +index 39b5fbe..ccbafe8 100755 --- a/configure +++ b/configure -@@ -32,8 +32,8 @@ opt_xattrdb=false +@@ -22,8 +22,8 @@ opt_xattrdb=false opt_profile=false opt_passwd_fallback='""' @@ -22,7 +22,7 @@ usage() { -@@ -193,7 +193,7 @@ if [ -z "$opt_bits" ]; then +@@ -191,7 +191,7 @@ if [ -z "$opt_bits" ]; then fi case $opt_bits in @@ -31,6 +31,3 @@ 32) opt_mark64=;; *) echo >&2 "Unknown bit size $opt_bits (only 32 and 64 known)." ;; --- -2.7.4 - diff -Nru pseudo-1.9.0+git20190515+996bead/debian/patches/python2.diff pseudo-1.9.0+git20200626+067950b/debian/patches/python2.diff --- pseudo-1.9.0+git20190515+996bead/debian/patches/python2.diff 2020-03-31 18:49:10.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/debian/patches/python2.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,20 +0,0 @@ -Index: b/maketables -=================================================================== ---- a/maketables -+++ b/maketables -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/python2 - # - # Copyright (c) 2008-2010, 2013 Wind River Systems, Inc. - # -Index: b/makewrappers -=================================================================== ---- a/makewrappers -+++ b/makewrappers -@@ -1,4 +1,4 @@ --#!/usr/bin/env python -+#!/usr/bin/python2 - # - # Copyright (c) 2008-2011,2013 Wind River Systems, Inc. - # diff -Nru pseudo-1.9.0+git20190515+996bead/debian/patches/series pseudo-1.9.0+git20200626+067950b/debian/patches/series --- pseudo-1.9.0+git20190515+996bead/debian/patches/series 2020-03-31 18:49:10.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/debian/patches/series 2020-07-12 09:38:55.000000000 +0000 @@ -1,2 +1,2 @@ +0001-Use-sys-xattr.h-rather-than-the-deprecated-attr-xatt.patch 0002-disable-bitwidth-guessing.patch -python2.diff diff -Nru pseudo-1.9.0+git20190515+996bead/debian/upstream/metadata pseudo-1.9.0+git20200626+067950b/debian/upstream/metadata --- pseudo-1.9.0+git20190515+996bead/debian/upstream/metadata 1970-01-01 00:00:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/debian/upstream/metadata 2020-07-12 09:38:55.000000000 +0000 @@ -0,0 +1 @@ +Repository: git://git.yoctoproject.org/pseudo diff -Nru pseudo-1.9.0+git20190515+996bead/debian/watch pseudo-1.9.0+git20200626+067950b/debian/watch --- pseudo-1.9.0+git20190515+996bead/debian/watch 2019-07-28 19:24:03.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/debian/watch 2020-07-12 09:38:55.000000000 +0000 @@ -7,3 +7,7 @@ opts="mode=git, pgpmode=none, pretty=1.9.0+git%cd+%h, repack, compression=xz" \ https://git.yoctoproject.org/git/pseudo \ HEAD + +opts="mode=git, pgpmode=none, pretty=1.9.0+git%cd+%h, repack, compression=xz" \ + https://git.yoctoproject.org/git/pseudo \ + heads/oe-core diff -Nru pseudo-1.9.0+git20190515+996bead/maketables pseudo-1.9.0+git20200626+067950b/maketables --- pseudo-1.9.0+git20190515+996bead/maketables 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/maketables 2020-06-26 10:44:05.000000000 +0000 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2008-2010, 2013 Wind River Systems, Inc. # diff -Nru pseudo-1.9.0+git20190515+996bead/makewrappers pseudo-1.9.0+git20200626+067950b/makewrappers --- pseudo-1.9.0+git20190515+996bead/makewrappers 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/makewrappers 2020-06-26 10:44:05.000000000 +0000 @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2008-2011,2013 Wind River Systems, Inc. # diff -Nru pseudo-1.9.0+git20190515+996bead/ports/linux/guts/openat.c pseudo-1.9.0+git20200626+067950b/ports/linux/guts/openat.c --- pseudo-1.9.0+git20190515+996bead/ports/linux/guts/openat.c 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/ports/linux/guts/openat.c 2020-06-26 10:44:05.000000000 +0000 @@ -55,9 +55,13 @@ if (flags & O_CREAT) { save_errno = errno; #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - rc = real___xstat64(_STAT_VER, path, &buf); + if (flags & O_NOFOLLOW) { + rc = real___lxstat64(_STAT_VER, path, &buf); + } else { + rc = real___xstat64(_STAT_VER, path, &buf); + } #else - rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, 0); + rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, (flags & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0); #endif existed = (rc != -1); if (!existed) @@ -72,9 +76,13 @@ if (!(flags & O_NONBLOCK) && ((flags & (O_WRONLY | O_RDONLY | O_RDWR)) != O_RDWR)) { save_errno = errno; #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - rc = real___xstat64(_STAT_VER, path, &buf); + if (flags & O_NOFOLLOW) { + rc = real___lxstat64(_STAT_VER, path, &buf); + } else { + rc = real___xstat64(_STAT_VER, path, &buf); + } #else - rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, 0); + rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, (flags & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0); #endif if (rc != -1 && S_ISFIFO(buf.st_mode)) { overly_magic_nonblocking = 1; @@ -126,11 +134,17 @@ } #endif #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS - stat_rc = real___xstat64(_STAT_VER, path, &buf); + if (flags & O_NOFOLLOW) { + stat_rc = real___lxstat64(_STAT_VER, path, &buf); + } else { + stat_rc = real___xstat64(_STAT_VER, path, &buf); + } #else - stat_rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, 0); + stat_rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, (flags & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0); #endif + pseudo_debug(PDBGF_FILE, "openat(path %s), flags %o, stat rc %d, stat mode %o\n", + path, flags, stat_rc, buf.st_mode); if (stat_rc != -1) { buf.st_mode = PSEUDO_DB_MODE(buf.st_mode, mode); if (!existed) { diff -Nru pseudo-1.9.0+git20190515+996bead/ports/linux/portdefs.h pseudo-1.9.0+git20200626+067950b/ports/linux/portdefs.h --- pseudo-1.9.0+git20190515+996bead/ports/linux/portdefs.h 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/ports/linux/portdefs.h 2020-06-26 10:44:05.000000000 +0000 @@ -32,3 +32,5 @@ #include #include +#include +#include diff -Nru pseudo-1.9.0+git20190515+996bead/ports/linux/pseudo_wrappers.c pseudo-1.9.0+git20200626+067950b/ports/linux/pseudo_wrappers.c --- pseudo-1.9.0+git20190515+996bead/ports/linux/pseudo_wrappers.c 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/ports/linux/pseudo_wrappers.c 2020-06-26 10:44:05.000000000 +0000 @@ -57,6 +57,7 @@ long syscall(long number, ...) { long rc = -1; + va_list ap; if (!pseudo_check_wrappers() || !real_syscall) { /* rc was initialized to the "failure" value */ @@ -77,6 +78,20 @@ (void) number; #endif +#ifdef SYS_seccomp + /* pseudo and seccomp are incompatible as pseudo uses different syscalls + * so pretend to enable seccomp but really do nothing */ + if (number == SYS_seccomp) { + unsigned long cmd; + va_start(ap, number); + cmd = va_arg(ap, unsigned long); + va_end(ap); + if (cmd == SECCOMP_SET_MODE_FILTER) { + return 0; + } + } +#endif + /* gcc magic to attempt to just pass these args to syscall. we have to * guess about the number of args; the docs discuss calling conventions * up to 7, so let's try that? @@ -92,3 +107,44 @@ (void) ap; return -1; } + +int +prctl(int option, ...) { + int rc = -1; + va_list ap; + + if (!pseudo_check_wrappers() || !real_prctl) { + /* rc was initialized to the "failure" value */ + pseudo_enosys("prctl"); + return rc; + } + +#ifdef SECCOMP_SET_MODE_FILTER + /* pseudo and seccomp are incompatible as pseudo uses different syscalls + * so pretend to enable seccomp but really do nothing */ + if (option == PR_SET_SECCOMP) { + unsigned long cmd; + va_start(ap, option); + cmd = va_arg(ap, unsigned long); + va_end(ap); + if (cmd == SECCOMP_SET_MODE_FILTER) { + return 0; + } + } +#endif + + /* gcc magic to attempt to just pass these args to prctl. we have to + * guess about the number of args; the docs discuss calling conventions + * up to 5, so let's try that? + */ + void *res = __builtin_apply((void (*)()) real_prctl, __builtin_apply_args(), sizeof(long) * 5); + __builtin_return(res); +} + +/* unused. + */ +static int wrap_prctl(int option, va_list ap) { + (void) option; + (void) ap; + return -1; +} diff -Nru pseudo-1.9.0+git20190515+996bead/ports/linux/statx/guts/statx.c pseudo-1.9.0+git20200626+067950b/ports/linux/statx/guts/statx.c --- pseudo-1.9.0+git20190515+996bead/ports/linux/statx/guts/statx.c 1970-01-01 00:00:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/ports/linux/statx/guts/statx.c 2020-06-26 10:44:05.000000000 +0000 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2019 Linux Foundation + * Author: Richard Purdie + * + * SPDX-License-Identifier: LGPL-2.1-only + * + * int + * statx(int dirfd, const char *pathname, int flags, unsigned int mask, struct statx *statxbuf) { + * int rc = -1; + */ + pseudo_msg_t *msg; + PSEUDO_STATBUF buf; + int save_errno; + + rc = real_statx(dirfd, pathname, flags, mask, statxbuf); + save_errno = errno; + if (rc == -1) { + return rc; + } + + buf.st_uid = statxbuf->stx_uid; + buf.st_gid = statxbuf->stx_gid; + buf.st_dev = makedev(statxbuf->stx_dev_major, statxbuf->stx_dev_minor); + buf.st_ino = statxbuf->stx_ino; + buf.st_mode = statxbuf->stx_mode; + buf.st_rdev = makedev(statxbuf->stx_rdev_major, statxbuf->stx_rdev_minor); + buf.st_nlink = statxbuf->stx_nlink; + msg = pseudo_client_op(OP_STAT, 0, -1, dirfd, pathname, &buf); + if (msg && msg->result == RESULT_SUCCEED) { + pseudo_debug(PDBGF_FILE, "statx(path %s), flags %o, stat rc %d, stat uid %o\n", pathname, flags, rc, statxbuf->stx_uid); + statxbuf->stx_uid = msg->uid; + statxbuf->stx_gid = msg->gid; + statxbuf->stx_mode = msg->mode; + statxbuf->stx_rdev_major = major(msg->rdev); + statxbuf->stx_rdev_minor = minor(msg->rdev); + } else { + pseudo_debug(PDBGF_FILE, "statx(path %s) failed, flags %o, stat rc %d, stat uid %o\n", pathname, flags, rc, statxbuf->stx_uid); + } + errno = save_errno; +/* return rc; + * } + */ diff -Nru pseudo-1.9.0+git20190515+996bead/ports/linux/statx/portdefs.h pseudo-1.9.0+git20200626+067950b/ports/linux/statx/portdefs.h --- pseudo-1.9.0+git20190515+996bead/ports/linux/statx/portdefs.h 1970-01-01 00:00:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/ports/linux/statx/portdefs.h 2020-06-26 10:44:05.000000000 +0000 @@ -0,0 +1,6 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-only + * + */ +#include +#include diff -Nru pseudo-1.9.0+git20190515+996bead/ports/linux/statx/wrapfuncs.in pseudo-1.9.0+git20200626+067950b/ports/linux/statx/wrapfuncs.in --- pseudo-1.9.0+git20190515+996bead/ports/linux/statx/wrapfuncs.in 1970-01-01 00:00:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/ports/linux/statx/wrapfuncs.in 2020-06-26 10:44:05.000000000 +0000 @@ -0,0 +1 @@ +int statx(int dirfd, const char *pathname, int flags, unsigned int mask, struct statx *statxbuf); diff -Nru pseudo-1.9.0+git20190515+996bead/ports/linux/subports pseudo-1.9.0+git20200626+067950b/ports/linux/subports --- pseudo-1.9.0+git20190515+996bead/ports/linux/subports 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/ports/linux/subports 2020-06-26 10:44:05.000000000 +0000 @@ -29,11 +29,12 @@ if $port_xattr; then cat > dummy.c < -#include +#include +#include int i; EOF if ! ${CC} -c -o dummy.o dummy.c >/dev/null 2>&1; then - echo >&2 "Warning: Can't compile trivial program using ". + echo >&2 "Warning: Can't compile trivial program using ". echo >&2 " xattr support will require that header." fi echo "linux/xattr" @@ -54,3 +55,13 @@ fi rm -f dummy.c dummy.o +cat > dummy.c < +struct statx x; +EOF +if ${CC} -c -o dummy.o dummy.c >/dev/null 2>&1; then + echo "linux/statx" +fi +rm -f dummy.c dummy.o + diff -Nru pseudo-1.9.0+git20190515+996bead/ports/linux/wrapfuncs.in pseudo-1.9.0+git20200626+067950b/ports/linux/wrapfuncs.in --- pseudo-1.9.0+git20190515+996bead/ports/linux/wrapfuncs.in 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/ports/linux/wrapfuncs.in 2020-06-26 10:44:05.000000000 +0000 @@ -1,12 +1,12 @@ -int open(const char *path, int flags, ...{mode_t mode}); /* flags=0 */ +int open(const char *path, int flags, ...{mode_t mode}); /* flags=flags&O_NOFOLLOW */ char *get_current_dir_name(void); int __xstat(int ver, const char *path, struct stat *buf); int __lxstat(int ver, const char *path, struct stat *buf); /* flags=AT_SYMLINK_NOFOLLOW */ int __fxstat(int ver, int fd, struct stat *buf); int lchown(const char *path, uid_t owner, gid_t group); /* flags=AT_SYMLINK_NOFOLLOW */ int __fxstatat(int ver, int dirfd, const char *path, struct stat *buf, int flags); -int openat(int dirfd, const char *path, int flags, ...{mode_t mode}); /* flags=0 */ -int __openat_2(int dirfd, const char *path, int flags); /* flags=0 */ +int openat(int dirfd, const char *path, int flags, ...{mode_t mode}); /* flags=flags&O_NOFOLLOW */ +int __openat_2(int dirfd, const char *path, int flags); /* flags=flags&O_NOFOLLOW */ int mknod(const char *path, mode_t mode, dev_t dev); /* real_func=pseudo_mknod */ int mknodat(int dirfd, const char *path, mode_t mode, dev_t dev); /* real_func=pseudo_mknodat */ int __xmknod(int ver, const char *path, mode_t mode, dev_t *dev); /* flags=AT_SYMLINK_NOFOLLOW */ @@ -15,9 +15,9 @@ # just so we know the inums of symlinks char *canonicalize_file_name(const char *filename); int eaccess(const char *path, int mode); -int open64(const char *path, int flags, ...{mode_t mode}); /* flags=0 */ -int openat64(int dirfd, const char *path, int flags, ...{mode_t mode}); /* flags=0 */ -int __openat64_2(int dirfd, const char *path, int flags); /* flags=0 */ +int open64(const char *path, int flags, ...{mode_t mode}); /* flags=flags&O_NOFOLLOW */ +int openat64(int dirfd, const char *path, int flags, ...{mode_t mode}); /* flags=flags&O_NOFOLLOW */ +int __openat64_2(int dirfd, const char *path, int flags); /* flags=flags&O_NOFOLLOW */ int creat64(const char *path, mode_t mode); int stat(const char *path, struct stat *buf); /* real_func=pseudo_stat */ int lstat(const char *path, struct stat *buf); /* real_func=pseudo_lstat, flags=AT_SYMLINK_NOFOLLOW */ @@ -56,3 +56,4 @@ int capset(cap_user_header_t hdrp, const cap_user_data_t datap); /* real_func=pseudo_capset */ long syscall(long nr, ...); /* hand_wrapped=1 */ int renameat2(int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags); /* flags=AT_SYMLINK_NOFOLLOW */ +int prctl(int option, ...); /* hand_wrapped=1 */ diff -Nru pseudo-1.9.0+git20190515+996bead/ports/linux/xattr/portdefs.h pseudo-1.9.0+git20200626+067950b/ports/linux/xattr/portdefs.h --- pseudo-1.9.0+git20190515+996bead/ports/linux/xattr/portdefs.h 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/ports/linux/xattr/portdefs.h 2020-06-26 10:44:05.000000000 +0000 @@ -2,5 +2,6 @@ * SPDX-License-Identifier: LGPL-2.1-only * */ -#include +#include +#include #include diff -Nru pseudo-1.9.0+git20190515+996bead/ports/linux/xattr/pseudo_wrappers.c pseudo-1.9.0+git20200626+067950b/ports/linux/xattr/pseudo_wrappers.c --- pseudo-1.9.0+git20190515+996bead/ports/linux/xattr/pseudo_wrappers.c 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/ports/linux/xattr/pseudo_wrappers.c 2020-06-26 10:44:05.000000000 +0000 @@ -197,7 +197,7 @@ mode |= get_special_bits(path, fd); pseudo_debug(PDBGF_XATTR, "posix_acl_access translated to mode %04o. Remaining attribute(s): %d.\n", mode, extra); - buf.st_mode = mode; + /* we want to actually issue a corresponding chmod, * as well, or else the file ends up 0600 on the * host. Using the slightly-less-efficient wrap_chmod diff -Nru pseudo-1.9.0+git20190515+996bead/ports/linux/xattr/wrapfuncs.in pseudo-1.9.0+git20200626+067950b/ports/linux/xattr/wrapfuncs.in --- pseudo-1.9.0+git20190515+996bead/ports/linux/xattr/wrapfuncs.in 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/ports/linux/xattr/wrapfuncs.in 2020-06-26 10:44:05.000000000 +0000 @@ -1,12 +1,12 @@ -ssize_t getxattr(const char *path, const char *name, void *value, size_t size); /* flags=0 */ -ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size); /* flags=AT_SYMLINK_NOFOLLOW */ -ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size); -int setxattr(const char *path, const char *name, const void *value, size_t size, int xflags); /* flags=0 */ -int lsetxattr(const char *path, const char *name, const void *value, size_t size, int xflags); /* flags=AT_SYMLINK_NOFOLLOW */ -int fsetxattr(int filedes, const char *name, const void *value, size_t size, int xflags); -ssize_t listxattr(const char *path, char *list, size_t size); /* flags=0 */ -ssize_t llistxattr(const char *path, char *list, size_t size); /* flags=AT_SYMLINK_NOFOLLOW */ -ssize_t flistxattr(int filedes, char *list, size_t size); -int removexattr(const char *path, const char *name); /* flags=0 */ -int lremovexattr(const char *path, const char *name); /* flags=AT_SYMLINK_NOFOLLOW */ -int fremovexattr(int filedes, const char *name); +ssize_t getxattr(const char *path, const char *name, void *value, size_t size); /* flags=0, version="GLIBC_2.3" */ +ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size); /* flags=AT_SYMLINK_NOFOLLOW, version="GLIBC_2.3" */ +ssize_t fgetxattr(int filedes, const char *name, void *value, size_t size); /* version="GLIBC_2.3" */ +int setxattr(const char *path, const char *name, const void *value, size_t size, int xflags); /* flags=0, version="GLIBC_2.3" */ +int lsetxattr(const char *path, const char *name, const void *value, size_t size, int xflags); /* flags=AT_SYMLINK_NOFOLLOW, version="GLIBC_2.3" */ +int fsetxattr(int filedes, const char *name, const void *value, size_t size, int xflags); /* version="GLIBC_2.3" */ +ssize_t listxattr(const char *path, char *list, size_t size); /* flags=0, version="GLIBC_2.3" */ +ssize_t llistxattr(const char *path, char *list, size_t size); /* flags=AT_SYMLINK_NOFOLLOW, version="GLIBC_2.3" */ +ssize_t flistxattr(int filedes, char *list, size_t size); /* version="GLIBC_2.3" */ +int removexattr(const char *path, const char *name); /* flags=0, version="GLIBC_2.3" */ +int lremovexattr(const char *path, const char *name); /* flags=AT_SYMLINK_NOFOLLOW, version="GLIBC_2.3" */ +int fremovexattr(int filedes, const char *name); /* version="GLIBC_2.3" */ diff -Nru pseudo-1.9.0+git20190515+996bead/ports/unix/guts/realpath.c pseudo-1.9.0+git20200626+067950b/ports/unix/guts/realpath.c --- pseudo-1.9.0+git20190515+996bead/ports/unix/guts/realpath.c 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/ports/unix/guts/realpath.c 2020-06-26 10:44:05.000000000 +0000 @@ -14,7 +14,14 @@ errno = ENAMETOOLONG; return NULL; } - if ((len = strlen(rname)) >= pseudo_sys_path_max()) { + len = strlen(rname); + char *ep = rname + len - 1; + while (ep > rname && *ep == '/') { + --len; + *(ep--) = '\0'; + } + + if (len >= pseudo_sys_path_max()) { errno = ENAMETOOLONG; return NULL; } diff -Nru pseudo-1.9.0+git20190515+996bead/pseudo.c pseudo-1.9.0+git20200626+067950b/pseudo.c --- pseudo-1.9.0+git20190515+996bead/pseudo.c 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/pseudo.c 2020-06-26 10:44:05.000000000 +0000 @@ -1087,9 +1087,15 @@ int fixup_needed = 0; pseudo_debug(PDBGF_DB, "Checking <%s>\n", m->path); if (lstat(m->path, &buf)) { - errors = EXIT_FAILURE; - pseudo_diag("can't stat <%s>\n", m->path); - continue; + if (!fix) { + pseudo_diag("can't stat <%s>\n", m->path); + errors = EXIT_FAILURE; + continue; + } else { + pseudo_debug(PDBGF_DB, "can't stat <%s>\n", m->path); + fixup_needed = 2; + goto do_fixup; + } } /* can't check for device type mismatches, uid/gid, or * permissions, because those are the very things we @@ -1125,6 +1131,7 @@ S_ISDIR(m->mode)); fixup_needed = 2; } + do_fixup: if (fixup_needed) { /* in fixup mode, either delete (mismatches) or * correct (dev/ino). diff -Nru pseudo-1.9.0+git20190515+996bead/pseudo_client.c pseudo-1.9.0+git20200626+067950b/pseudo_client.c --- pseudo-1.9.0+git20190515+996bead/pseudo_client.c 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/pseudo_client.c 2020-06-26 10:44:05.000000000 +0000 @@ -1271,7 +1271,7 @@ } } -#define PSEUDO_RETRIES 20 +#define PSEUDO_RETRIES 250 static pseudo_msg_t * pseudo_client_request(pseudo_msg_t *msg, size_t len, const char *path) { pseudo_msg_t *response = 0; diff -Nru pseudo-1.9.0+git20190515+996bead/pseudo_ipc.h pseudo-1.9.0+git20200626+067950b/pseudo_ipc.h --- pseudo-1.9.0+git20190515+996bead/pseudo_ipc.h 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/pseudo_ipc.h 2020-06-26 10:44:05.000000000 +0000 @@ -29,7 +29,7 @@ char path[]; } pseudo_msg_t; -enum { +typedef enum { PSA_EXEC = 1, PSA_WRITE = (PSA_EXEC << 1), PSA_READ = (PSA_WRITE << 1), diff -Nru pseudo-1.9.0+git20190515+996bead/pseudo_server.c pseudo-1.9.0+git20200626+067950b/pseudo_server.c --- pseudo-1.9.0+git20190515+996bead/pseudo_server.c 2019-05-15 21:33:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/pseudo_server.c 2020-06-26 10:44:05.000000000 +0000 @@ -792,6 +792,7 @@ struct sigaction eat_usr2 = { .sa_handler = set_do_list_clients }; + int hitmaxfiles; clients = malloc(16 * sizeof(*clients)); @@ -810,6 +811,7 @@ active_clients = 1; max_clients = 16; highest_client = 0; + hitmaxfiles = 0; pseudo_debug(PDBGF_SERVER, "server loop started.\n"); if (listen_fd < 0) { @@ -868,10 +870,15 @@ } else { serve_client(i); } + } else if (hitmaxfiles) { + /* Only close one per loop iteration in the interests of caution */ + close_client(i); + hitmaxfiles = 0; } if (die_forcefully) break; } + hitmaxfiles = 0; if (!die_forcefully && (FD_ISSET(clients[0].fd, &events) || FD_ISSET(clients[0].fd, &reads))) { @@ -893,6 +900,9 @@ */ pseudo_server_timeout = DEFAULT_PSEUDO_SERVER_TIMEOUT; die_peacefully = 0; + } else if (errno == EMFILE) { + hitmaxfiles = 1; + pseudo_debug(PDBGF_SERVER, "Hit max open files, dropping a client.\n"); } } pseudo_debug(PDBGF_SERVER, "server loop complete [%d clients left]\n", active_clients); diff -Nru pseudo-1.9.0+git20190515+996bead/test/test-acl.sh pseudo-1.9.0+git20200626+067950b/test/test-acl.sh --- pseudo-1.9.0+git20190515+996bead/test/test-acl.sh 1970-01-01 00:00:00.000000000 +0000 +++ pseudo-1.9.0+git20200626+067950b/test/test-acl.sh 2020-06-26 10:44:05.000000000 +0000 @@ -0,0 +1,188 @@ +#!/bin/bash +# +# SPDX-License-Identifier: LGPL-2.1-only +# + +# Return vals: 2 - Unable to run ACL commands, assertion failure +# 1 - Invalid return value +# 0 - Pass + +# NOTE: these test exclusively test setfacl -m + +set -u + +check_owner () { + local file="$1" + local expected="$2" + local msg="$3" + local actual=$(stat -c "%U" "$file") + if [ "$actual" != "$expected" ] + then + echo "$msg" "Fail, '$file' unexpected owner '$actual'" + exit 2 + fi +} + +check_group () { + local file="$1" + local expected="$2" + local msg="$3" + local actual=$(stat -c "%G" "$file") + if [ "$actual" != "$expected" ] + then + echo "$msg" "Fail, '$file' unexpected group '$actual'" + exit 2 + fi +} + +check_acl_contains () { + local file="$1" + local acl="$2" + local msg="$3" + IFS=',' read -ra acls <<< "$acl" + for pattern in "${acls[@]}"; do + result=$(getfacl -c "$file" | grep -o "^$pattern") + if [ "$result" != "$pattern" ] + then + echo "$msg" "Fail, did not find desired acl '$pattern' in '$file'" + exit 2 + fi + done +} + +check_acl_minimal () { + local file="$1" + local msg="${2:-''}" + local acls + acls=$(getfacl -c "${file}" | grep -v "::") + if [ -n "$acls" ] + then + echo "$msg" "Fail, '$file' unexpected getfacl result '$acls'" + exit 1 + fi +} + +test_modify_once () { + local file="$1" + local acl="$2" + local msg="${3:-''}" + # ensure that file is pristine + check_acl_minimal "$file" "$msg precondition:" + check_owner "$file" root "$msg precondition:" + check_group "$file" root "$msg precondition:" + if ! setfacl -m "$acl" "$file" + then + echo "$msg" "Fail, unable to call setfacl" + exit 2 + fi + check_acl_contains "$file" "$acl" "$msg: acl not set:" + check_owner "$file" root "$msg owner corrupted:" + check_group "$file" root "$msg group corrupted:" +} + + +trap "rm -rf testdir" EXIT +mkdir testdir || exit 1 + + +# user +touch testdir/f1 || exit 1 +mkdir testdir/d1 || exit 1 +# regular file +test_modify_once testdir/f1 "user:root:r" "$LINENO:" +# directory +test_modify_once testdir/d1 "user:root:r" "$LINENO:" +rm -rf testdir/f1 testdir/d1 + +#group +rm -rf testdir/f1 testdir/d1 +touch testdir/f1 || exit 1 +mkdir testdir/d1 || exit 1 +# regular file +test_modify_once testdir/f1 "group:root:r" "$LINENO:" +# directory +test_modify_once testdir/d1 "group:root:r" "$LINENO:" +rm -rf testdir/f1 testdir/d1 + +# multiple users +touch testdir/f1 || exit 1 +mkdir testdir/d1 || exit 1 +# regular file +test_modify_once testdir/f1 "user:root:r,group:root:r,user:bin:rw" "$LINENO:" +# directory +test_modify_once testdir/d1 "user:root:r,group:root:r,user:bin:rw" "$LINENO:" +rm -rf testdir/f1 testdir/d1 + + +# setfacl default acls +mkdir testdir/d1 || exit 1 +test_modify_once testdir/d1 "default:user:root:r,user:root:r" "$LINENO:" +rm -rf testdir/d1 + + +# multiple calls to setfacl -m on same file +touch testdir/f1 || exit 1 +mkdir testdir/d1 || exit 1 +check_owner testdir/f1 root "$LINENO: precondition:" +check_group testdir/f1 root "$LINENO: precondition:" +check_acl_minimal testdir/f1 "$LINENO: precondition:" + +acl1="user:root:r" +acl2="user:bin:rw" + +if ! setfacl -m "$acl1" testdir/f1 # first setfacl +then + echo "$LINENO:" "Fail, unable to call setfacl" + exit 2 +fi +check_acl_contains testdir/f1 "$acl1" "$LINENO: acl1 not set:" +check_owner testdir/f1 root "$LINENO: owner corrupted:" +check_group testdir/f1 root "$LINENO: group corrupted:" + +if ! setfacl -m "$acl2" testdir/f1 # second setfacl +then + echo "$LINENO:" "Fail, unable to call setfacl" + exit 2 +fi + +check_acl_contains testdir/f1 "$acl1" "$LINENO: acl1 not set:" +check_acl_contains testdir/f1 "$acl2" "$LINENO: acl2 not set:" +check_owner testdir/f1 root "$LINENO: owner corrupted:" +check_group testdir/f1 root "$LINENO: group corrupted:" +rm -rf testdir/f1 testdir/d1 + +# setfacl recursive +test_modify_recursive () { + local root_dir="$1" + local acl="$2" + local msg="${3:-''}" + + find "$root_dir" | while read -r file; do + check_owner "$file" root "$msg precondition:" + check_group "$file" root "$msg precondition:" + check_acl_minimal "$file" "$msg precondition:" + done + if ! setfacl -R -m "$acl" "$root_dir" + then + echo "$msg" "Fail, unable to call setfacl" + exit 2 + fi + find "$root_dir" | while read -r file; do + check_owner "$file" root "$msg owner corrupted:" + check_group "$file" root "$msg group corrupted:" + check_acl_contains "$file" "$acl" "$msg acl not set:" + done +} + +mkdir -p testdir/d1/d2 || exit 1 +touch testdir/d1/d2/f1 || exit 1 +test_modify_recursive testdir/d1 "user:root:r,group:root:r,user:bin:rw" "$LINENO:" +rm -rf testdir/d1 + +mkdir -p testdir/d1/d2 || exit 1 +mkdir -p testdir/d1/d3 || exit 1 +test_modify_recursive testdir/d1 "default:user:root:rwx,user:root:r,group:root:r,user:bin:rw" "$LINENO:" +rm -rf testdir/d1 + +#echo "Passed." +exit 0