[lxc-devel] [lxc-templates/master] Current

TanyaEleventhGoddess on Github lxc-bot at linuxcontainers.org
Sun Jul 5 17:19:08 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 744 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200705/bfac47b3/attachment.bin>
-------------- next part --------------
From 9bc1ba1c898ac9334ed287aa875edd4fb5b5913b Mon Sep 17 00:00:00 2001
From: Tanya Degurechaff
 <34323200+TanyaEleventhGoddess at users.noreply.github.com>
Date: Sat, 4 Jul 2020 15:40:23 +0200
Subject: [PATCH 1/8] Improved apt gpg management

---
 templates/lxc-debian.in | 43 +++++++++++++++++++++++++++--------------
 templates/lxc-kali.in   | 29 ++++++++++++++++++++-------
 2 files changed, 51 insertions(+), 21 deletions(-)

diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in
index fd26d5e..84b1fb3 100644
--- a/templates/lxc-debian.in
+++ b/templates/lxc-debian.in
@@ -40,6 +40,7 @@ LOCALSTATEDIR="@LOCALSTATEDIR@"
 LXC_TEMPLATE_CONFIG="@LXCTEMPLATECONFIG@"
 # Allows the lxc-cache directory to be set by environment variable
 LXC_CACHE_PATH=${LXC_CACHE_PATH:-"$LOCALSTATEDIR/cache/lxc"}
+[ -z "$DOWNLOAD_KEYRING" ] && DOWNLOAD_KEYRING=1
 
 find_interpreter()
 {
@@ -347,18 +348,32 @@ openssh-server
 
     # If debian-archive-keyring isn't installed, fetch GPG keys directly
     releasekeyring=/usr/share/keyrings/debian-archive-keyring.gpg
-    if [ ! -f $releasekeyring ]; then
-        releasekeyring="$cache/archive-key.gpg"
-        case $release in
-            "wheezy")
-                gpgkeyname="archive-key-7.0"
-                ;;
-            *)
-                gpgkeyname="archive-key-8"
-                ;;
-        esac
-        wget https://ftp-master.debian.org/keys/${gpgkeyname}.asc -O - --quiet \
-            | gpg --import --no-default-keyring --keyring="${releasekeyring}"
+    lreleasekeyring=/etc/apt/trusted.gpg.d/debian-archive-$release-stable.gpg
+    if [ -f "$releasekeyring" ]; then
+        apt_gpg_opt="--keyring=${releasekeyring}"
+    elif [ -f "$lreleasekeyring" ]; then
+        apt_gpg_opt="--keyring=${lreleasekeyring}"
+    elif [ "$DOWNLOAD_KEYRING" = 1 ]; then 
+        [ ! -d "/etc/apt/trusted.gpg.d" ] && lreleasekeyring="$cache/archive-key.gpg"
+        if [[ "$(id -u)" == "0" ]]; then
+            case $release in
+                "wheezy")
+                    gpgkeyname="archive-key-7.0"
+                    ;;
+                *)
+                    gpgkeyname="archive-key-8"
+                    ;;
+            esac
+            wget https://ftp-master.debian.org/keys/${gpgkeyname}.asc -O - --quiet \
+                | gpg --import --no-default-keyring --keyring="${lreleasekeyring}"
+            apt_gpg_opt="--keyring=${lreleasekeyring}"
+        else
+           echo "Must be root (sudo) to save $lreleasekeyring"
+        fi
+    fi
+    if [ -z "$apt_gpg_opt" ]; then
+        echo "WARNING: No GPG check"
+        apt_gpg_opt='--no-check-gpg'
     fi
     # check the mini debian was not already downloaded
     try_mksubvolume "$cache/partial-$release-$arch"
@@ -371,7 +386,7 @@ openssh-server
     echo "Downloading debian minimal ..."
     if [ "$interpreter" = "" ] ; then
         debootstrap --verbose --variant=minbase --arch="$arch" \
-            --include=$packages --keyring="${releasekeyring}" \
+            --include=$packages "${apt_gpg_opt}" \
             "$release" "$cache/partial-$release-$arch" "$MIRROR"
         if [ $? -ne 0 ]; then
             echo "Failed to download the rootfs, aborting."
@@ -379,7 +394,7 @@ openssh-server
         fi
     else
         debootstrap --foreign --verbose --variant=minbase --arch="$arch" \
-            --include=$packages --keyring="${releasekeyring}" \
+            --include=$packages "${apt_gpg_opt}" \
             "$release" "$cache/partial-$release-$arch" "$MIRROR"
         if [ $? -ne 0 ]; then
             echo "Failed to download the rootfs, aborting."
diff --git a/templates/lxc-kali.in b/templates/lxc-kali.in
index 44f242f..d198fb5 100755
--- a/templates/lxc-kali.in
+++ b/templates/lxc-kali.in
@@ -41,6 +41,7 @@ LOCALSTATEDIR="@LOCALSTATEDIR@"
 LXC_TEMPLATE_CONFIG="@LXCTEMPLATECONFIG@"
 # Allows the lxc-cache directory to be set by environment variable
 LXC_CACHE_PATH=${LXC_CACHE_PATH:-"$LOCALSTATEDIR/cache/lxc"}
+[ -z "$DOWNLOAD_KEYRING" ] && DOWNLOAD_KEYRING=1
 
 find_interpreter()
 {
@@ -330,11 +331,25 @@ kali-archive-keyring
 
     # If kali-archive-keyring isn't installed, fetch GPG keys directly
     releasekeyring=/usr/share/keyrings/kali-archive-keyring.gpg
-    if [ ! -f $releasekeyring ]; then
-        releasekeyring="$cache/archive-key.gpg"
-        gpgkeyname="archive-key"
-        wget https://archive.kali.org/${gpgkeyname}.asc -O - --quiet \
-            | gpg --import --no-default-keyring --keyring="${releasekeyring}"
+    lreleasekeyring=/etc/apt/trusted.gpg.d/kali-archive-keyring.gpg
+    if [ -f "$releasekeyring" ]; then
+        apt_gpg_opt="--keyring=${releasekeyring}"
+    elif [ -f "$lreleasekeyring" ]; then
+        apt_gpg_opt="--keyring=${lreleasekeyring}"
+    elif [ "$DOWNLOAD_KEYRING" = 1 ]; then 
+        [ ! -d "/etc/apt/trusted.gpg.d" ] && lreleasekeyring="$cache/archive-key.gpg"
+        if [[ "$(id -u)" == "0" ]]; then
+            gpgkeyname="archive-key"
+            wget https://archive.kali.org/${gpgkeyname}.asc -O - --quiet \
+                | gpg --import --no-default-keyring --keyring="${lreleasekeyring}"
+            apt_gpg_opt="--keyring=${lreleasekeyring}"
+        else
+           echo "Must be root (sudo) to save $lreleasekeyring"
+        fi
+    fi
+    if [ -z "$apt_gpg_opt" ]; then
+        echo "WARNING: No GPG check"
+        apt_gpg_opt='--no-check-gpg'
     fi
     # check the mini kali was not already downloaded
     try_mksubvolume "$cache/partial-$release-$arch"
@@ -347,7 +362,7 @@ kali-archive-keyring
     echo "Downloading kali minimal ..."
     if [ "$interpreter" = "" ] ; then
         debootstrap --verbose --variant=minbase --arch="$arch" \
-            --include=$packages --keyring="${releasekeyring}" \
+            --include=$packages "${apt_gpg_opt}" \
             "$release" "$cache/partial-$release-$arch" "$MIRROR"
         if [ $? -ne 0 ]; then
             echo "Failed to download the rootfs, aborting."
@@ -355,7 +370,7 @@ kali-archive-keyring
         fi
     else
         debootstrap --foreign --verbose --variant=minbase --arch="$arch" \
-            --include=$packages --keyring="${releasekeyring}" \
+            --include=$packages "${apt_gpg_opt}" \
             "$release" "$cache/partial-$release-$arch" "$MIRROR"
         if [ $? -ne 0 ]; then
             echo "Failed to download the rootfs, aborting."

From e9301f5ce51f9c35c277cfa3e1e59a60742abd70 Mon Sep 17 00:00:00 2001
From: Tanya Degurechaff
 <34323200+TanyaEleventhGoddess at users.noreply.github.com>
Date: Sat, 4 Jul 2020 15:48:51 +0200
Subject: [PATCH 2/8] Added proper copyrights to fixes authors

---
 templates/lxc-debian.in | 2 ++
 templates/lxc-kali.in   | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in
index 84b1fb3..a1c7701 100644
--- a/templates/lxc-debian.in
+++ b/templates/lxc-debian.in
@@ -5,6 +5,8 @@
 
 # Authors:
 # Daniel Lezcano <daniel.lezcano at free.fr>
+# Greg Olsen     <gregolsen at computer.org>  (lxc-devuan)
+# Tanya          <tanyadegurechaff at waifu.club>
 
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
diff --git a/templates/lxc-kali.in b/templates/lxc-kali.in
index d198fb5..265f465 100755
--- a/templates/lxc-kali.in
+++ b/templates/lxc-kali.in
@@ -5,7 +5,9 @@
 
 # Authors:
 # Daniel Lezcano <daniel.lezcano at free.fr>
-# Re4son <re4son at kali.org>
+# Re4son         <re4son at kali.org>
+# Greg Olsen     <gregolsen at computer.org>  (lxc-devuan)
+# Tanya          <tanyadegurechaff at waifu.club>
 
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public

From cac2a761fccb63444a097abc57180ee27c237fad Mon Sep 17 00:00:00 2001
From: Tanya Degurechaff
 <34323200+TanyaEleventhGoddess at users.noreply.github.com>
Date: Sat, 4 Jul 2020 16:33:11 +0200
Subject: [PATCH 3/8] Added DOWNLOAD_KEYRING in usage

---
 templates/lxc-debian.in | 2 ++
 templates/lxc-kali.in   | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in
index a1c7701..0cd3dfc 100644
--- a/templates/lxc-debian.in
+++ b/templates/lxc-debian.in
@@ -649,6 +649,8 @@ Environment variables:
                          Defaults to '$MIRROR'
   SECURITY_MIRROR        The Debian package security mirror to use. See also the --security-mirror switch above.
                          Defaults to '$SECURITY_MIRROR'
+  DOWNLOAD_KEYRING       Sets whether to download keyring when missing or ignore keyring checks
+                         Defaults to '1'
 
 EOF
     return 0
diff --git a/templates/lxc-kali.in b/templates/lxc-kali.in
index 265f465..7da3d0c 100755
--- a/templates/lxc-kali.in
+++ b/templates/lxc-kali.in
@@ -621,6 +621,8 @@ Environment variables:
 
   MIRROR                 The Kali package mirror to use. See also the --mirror switch above.
                          Defaults to '$MIRROR'
+  DOWNLOAD_KEYRING       Sets whether to download keyring when missing or ignore keyring checks
+                         Defaults to '1'
 EOF
     return 0
 }

From 1bdc186ea0d8618c944d0d480347e0b1327aa934 Mon Sep 17 00:00:00 2001
From: Tanya Degurechaff
 <34323200+TanyaEleventhGoddess at users.noreply.github.com>
Date: Sat, 4 Jul 2020 16:57:18 +0200
Subject: [PATCH 4/8] Quotation marks makes you think it's a string

---
 templates/lxc-debian.in | 2 +-
 templates/lxc-kali.in   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in
index 0cd3dfc..6193c3d 100644
--- a/templates/lxc-debian.in
+++ b/templates/lxc-debian.in
@@ -650,7 +650,7 @@ Environment variables:
   SECURITY_MIRROR        The Debian package security mirror to use. See also the --security-mirror switch above.
                          Defaults to '$SECURITY_MIRROR'
   DOWNLOAD_KEYRING       Sets whether to download keyring when missing or ignore keyring checks
-                         Defaults to '1'
+                         Defaults to 1
 
 EOF
     return 0
diff --git a/templates/lxc-kali.in b/templates/lxc-kali.in
index 7da3d0c..a8ab0b8 100755
--- a/templates/lxc-kali.in
+++ b/templates/lxc-kali.in
@@ -622,7 +622,7 @@ Environment variables:
   MIRROR                 The Kali package mirror to use. See also the --mirror switch above.
                          Defaults to '$MIRROR'
   DOWNLOAD_KEYRING       Sets whether to download keyring when missing or ignore keyring checks
-                         Defaults to '1'
+                         Defaults to 1
 EOF
     return 0
 }

From bd0a95e688de5b002797b787890b415ecc207619 Mon Sep 17 00:00:00 2001
From: Tanya Degurechaff
 <34323200+TanyaEleventhGoddess at users.noreply.github.com>
Date: Sat, 4 Jul 2020 19:41:17 +0200
Subject: [PATCH 5/8] Force hostname inclusion in /etc/hosts

---
 templates/lxc-debian.in | 11 +++++++++++
 templates/lxc-kali.in   | 11 +++++++++++
 2 files changed, 22 insertions(+)

diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in
index 6193c3d..a3603c1 100644
--- a/templates/lxc-debian.in
+++ b/templates/lxc-debian.in
@@ -120,6 +120,17 @@ EOF
     # set the hostname
     cat <<EOF > $rootfs/etc/hostname
 $hostname
+EOF
+
+    # set minimal hosts
+    cat <<EOF > $rootfs/etc/hosts
+127.0.0.1   localhost
+127.0.1.1   $hostname
+
+# The following lines are desirable for IPv6 capable hosts
+::1     localhost ip6-localhost ip6-loopback
+ff02::1 ip6-allnodes
+ff02::2 ip6-allrouters
 EOF
 
     # reconfigure some services
diff --git a/templates/lxc-kali.in b/templates/lxc-kali.in
index a8ab0b8..491198e 100755
--- a/templates/lxc-kali.in
+++ b/templates/lxc-kali.in
@@ -121,6 +121,17 @@ EOF
     # set the hostname
     cat <<EOF > $rootfs/etc/hostname
 $hostname
+EOF
+
+    # set minimal hosts
+    cat <<EOF > $rootfs/etc/hosts
+127.0.0.1   localhost
+127.0.1.1   $hostname
+
+# The following lines are desirable for IPv6 capable hosts
+::1     localhost ip6-localhost ip6-loopback
+ff02::1 ip6-allnodes
+ff02::2 ip6-allrouters
 EOF
 
     # reconfigure some services

From bbe7c4cf6f0a985f85519e246c63c915573b29a4 Mon Sep 17 00:00:00 2001
From: Tanya Degurechaff
 <34323200+TanyaEleventhGoddess at users.noreply.github.com>
Date: Sat, 4 Jul 2020 22:14:12 +0200
Subject: [PATCH 6/8] Fix timezone configuration

---
 templates/lxc-debian.in | 2 ++
 templates/lxc-kali.in   | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in
index a3603c1..ca767ab 100644
--- a/templates/lxc-debian.in
+++ b/templates/lxc-debian.in
@@ -186,10 +186,12 @@ EOF
     # set initial timezone as on host
     if [ -f /etc/timezone ]; then
         cat /etc/timezone > "$rootfs/etc/timezone"
+        rm -f "$rootfs/etc/localtime"
         chroot "$rootfs" dpkg-reconfigure -f noninteractive tzdata
     elif [ -f /etc/sysconfig/clock ]; then
         . /etc/sysconfig/clock
         echo "$ZONE" > "$rootfs/etc/timezone"
+        rm -f "$rootfs/etc/localtime"
         chroot "$rootfs" dpkg-reconfigure -f noninteractive tzdata
     else
         echo "Timezone in container is not configured. Adjust it manually."
diff --git a/templates/lxc-kali.in b/templates/lxc-kali.in
index 491198e..89338f6 100755
--- a/templates/lxc-kali.in
+++ b/templates/lxc-kali.in
@@ -181,10 +181,12 @@ EOF
     # set initial timezone as on host
     if [ -f /etc/timezone ]; then
         cat /etc/timezone > "$rootfs/etc/timezone"
+        rm -f "$rootfs/etc/localtime"
         chroot "$rootfs" dpkg-reconfigure -f noninteractive tzdata
     elif [ -f /etc/sysconfig/clock ]; then
         . /etc/sysconfig/clock
         echo "$ZONE" > "$rootfs/etc/timezone"
+        rm -f "$rootfs/etc/localtime"
         chroot "$rootfs" dpkg-reconfigure -f noninteractive tzdata
     else
         echo "Timezone in container is not configured. Adjust it manually."

From 38e12778a8edf198f9ce23e9e33f48328d179e7d Mon Sep 17 00:00:00 2001
From: Tanya Degurechaff
 <34323200+TanyaEleventhGoddess at users.noreply.github.com>
Date: Sat, 4 Jul 2020 22:19:13 +0200
Subject: [PATCH 7/8] Fix indentation

---
 templates/lxc-debian.in | 2 +-
 templates/lxc-kali.in   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in
index ca767ab..97a38a9 100644
--- a/templates/lxc-debian.in
+++ b/templates/lxc-debian.in
@@ -226,7 +226,7 @@ write_sourceslist()
     fi
 
     cat >> "${rootfs}/etc/apt/sources.list" << EOF
-${prefix} $MIRROR          ${release}         main${non_main}
+${prefix} $MIRROR ${release} main${non_main}
 EOF
 
     if [ "$release" != "unstable" -a "$release" != "sid" ]; then
diff --git a/templates/lxc-kali.in b/templates/lxc-kali.in
index 89338f6..68a66fe 100755
--- a/templates/lxc-kali.in
+++ b/templates/lxc-kali.in
@@ -221,7 +221,7 @@ write_sourceslist()
     fi
 
     cat >> "${rootfs}/etc/apt/sources.list" << EOF
-${prefix} $MIRROR          ${release}         main${non_main}
+${prefix} $MIRROR ${release} main${non_main}
 EOF
 
 }

From 76a1b3eb86d161d5b956a4ec07fd31bc6bbe09c0 Mon Sep 17 00:00:00 2001
From: Tanya Degurechaff
 <34323200+TanyaEleventhGoddess at users.noreply.github.com>
Date: Sun, 5 Jul 2020 11:10:51 +0200
Subject: [PATCH 8/8] Avoid warning 'stdin not a tty' in some cases

---
 templates/lxc-debian.in | 5 +++++
 templates/lxc-kali.in   | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in
index 97a38a9..49073b0 100644
--- a/templates/lxc-debian.in
+++ b/templates/lxc-debian.in
@@ -594,6 +594,11 @@ EOF
 
     # Re-enable service startup
     rm "${rootfs}/usr/sbin/policy-rc.d"
+
+    # Fix by Greg Olsen, avoid warning 'stdin not a tty' in some cases
+    if [[ -f "${rootfs}/root/.profile" ]]; then
+       sed -i -e 's/^mesg n/test -t 0 \&\& mesg n/g' ${rootfs}/root/.profile
+    fi
     
     # end
 }
diff --git a/templates/lxc-kali.in b/templates/lxc-kali.in
index 68a66fe..ef8cd01 100755
--- a/templates/lxc-kali.in
+++ b/templates/lxc-kali.in
@@ -570,6 +570,11 @@ EOF
 
     # Re-enable service startup
     rm "${rootfs}/usr/sbin/policy-rc.d"
+
+    # Fix by Greg Olsen, avoid warning 'stdin not a tty' in some cases
+    if [[ -f "${rootfs}/root/.profile" ]]; then
+       sed -i -e 's/^mesg n/test -t 0 \&\& mesg n/g' ${rootfs}/root/.profile
+    fi
     
     # end
 }


More information about the lxc-devel mailing list