[lxc-devel] [lxd-pkg-snap/latest-edge] commands: don't try to access USER variable if it is not set

morphis on Github lxc-bot at linuxcontainers.org
Mon Oct 29 11:39:10 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 647 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181029/4d1ed78a/attachment.bin>
-------------- next part --------------
From e475080b311630bc5b31b4890cfd41eadd16020f Mon Sep 17 00:00:00 2001
From: Simon Fels <simon.fels at canonical.com>
Date: Mon, 29 Oct 2018 12:36:47 +0100
Subject: [PATCH] commands: don't try to access USER variable if it is not set

In environments were USER isn't set the lxc script fail when trying to
access the variable:

/snap/lxd/9348/commands/lxc: 22: /snap/lxd/9348/commands/lxc: USER: parameter not set
---
 snapcraft/commands/lxc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/snapcraft/commands/lxc b/snapcraft/commands/lxc
index 57fec64..88e1677 100755
--- a/snapcraft/commands/lxc
+++ b/snapcraft/commands/lxc
@@ -19,7 +19,7 @@ if [ -n "${HOME:-}" ] && [ ! -d "${HOME}/.config/lxc" ]; then
     mkdir -p "${HOME}/.config"
     if [ -n "${USER:-}" ] && [ -d "/home/${USER}/.config/lxc" ]; then
         cp -r "/home/${USER}/.config/lxc" "${HOME}/.config/lxc" || true
-    elif [ "${USER}" = "root" ] && [ -d "/root/.config/lxc" ]; then
+    elif [ "${USER:-}" = "root" ] && [ -d "/root/.config/lxc" ]; then
         cp -r "/root/.config/lxc" "${HOME}/.config/lxc" || true
     fi
 fi


More information about the lxc-devel mailing list