[Piuparts-devel] [Git][debian/piuparts][helmutg/feature-nonroot] Add autopkgtest for unshared piuparts

Nicolas Dandrimont (@olasd) gitlab at salsa.debian.org
Wed May 15 21:24:54 BST 2024



Nicolas Dandrimont pushed to branch helmutg/feature-nonroot at Debian / piuparts


Commits:
cc3782c4 by Nicolas Dandrimont at 2024-05-15T22:23:59+02:00
Add autopkgtest for unshared piuparts

- - - - -


2 changed files:

- debian/tests/control
- + debian/tests/unshare


Changes:

=====================================
debian/tests/control
=====================================
@@ -5,3 +5,7 @@ Restrictions: needs-root
 Tests: all-python-versions
 Depends: piuparts, python3-all
 Restrictions: needs-root
+
+Tests: unshare
+Depends: piuparts, uidmap
+Restrictions: needs-root, skippable


=====================================
debian/tests/unshare
=====================================
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+set -eu
+
+if [ -z "$AUTOPKGTEST_NORMAL_USER" ]; then
+    echo "No normal user available, test cannot be run"
+    exit 77
+fi
+
+AUTOPKGTEST_NORMAL_UID="$(id -u "$AUTOPKGTEST_NORMAL_USER")"
+AUTOPKGTEST_NORMAL_GID="$(id -g "$AUTOPKGTEST_NORMAL_USER")"
+
+if ! grep -qx "$AUTOPKGTEST_NORMAL_UID:.*" /etc/subuid; then
+    echo "Adding a subuid allocation for $AUTOPKGTEST_NORMAL_USER"
+    echo "$AUTOPKGTEST_NORMAL_UID:1000000:65536" >> /etc/subuid
+fi
+
+if ! grep -qx "$AUTOPKGTEST_NORMAL_GID:.*" /etc/subgid; then
+    echo "Adding a subgid allocation for $AUTOPKGTEST_NORMAL_USER's group"
+    echo "$AUTOPKGTEST_NORMAL_GID:1000000:65536" >> /etc/subgid
+fi
+
+if ! unshare --user --map-auto --setuid 0 --setgid 0 --mount --pid --fork true; then
+    echo "Unshare failed, bailing"
+    exit 77
+fi
+
+. "$(dirname "$0")/common.sh"
+
+echo running "$0"
+
+test_this piuparts --version
+
+cd "$AUTOPKGTEST_TMP"
+
+create_packages
+
+chown "$AUTOPKGTEST_NORMAL_USER:" t.deb f.deb
+
+test_this runuser -u "$AUTOPKGTEST_NORMAL_USER" -- piuparts t.deb



View it on GitLab: https://salsa.debian.org/debian/piuparts/-/commit/cc3782c4bdbc090fb129dccf6066870eb131cb19

-- 
View it on GitLab: https://salsa.debian.org/debian/piuparts/-/commit/cc3782c4bdbc090fb129dccf6066870eb131cb19
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/piuparts-devel/attachments/20240515/9a7e18ce/attachment-0001.htm>


More information about the Piuparts-devel mailing list