← Back to team overview

touch-packages team mailing list archive

Re: [Bug 1513698] [NEW] $HOME variable set incorrectly inside container

 

Right, this is mentioned in the manpage.  You can force environment
to be cleared by passing --clear-env.  Actually setting HOME to what
a login shell would do would require lxc-attach to make assumptions
about the container.  However you can

lxc-attach -n trusty-vimprobable --clear-env -- su - root

to get su (inside the container) to do the things you want.

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to lxc in Ubuntu.
https://bugs.launchpad.net/bugs/1513698

Title:
  $HOME variable set incorrectly inside container

Status in lxc package in Ubuntu:
  New

Bug description:
  I have lxc containers set up as an unprivileged user.

  When I start my containers, the root user has the $HOME environmental
  variable set, pointing at the unprivileged user.

  This is the faulty session:

  sputnik is the host, lamp2 is the lxc container

  ruben@sputnik:~$ echo $HOME
  /home/ruben
  ruben@sputnik:~$ lxc-start -n lamp2 -d
  ruben@sputnik:~$ lxc-attach -n lamp2
  root@lamp2:/# echo $HOME
  /home/ruben
  root@lamp2:/# exit
  ruben@sputnik:~$ TEST_VAR="THIS IS A TEST"
  ruben@sputnik:~$ lxc-stop -n lamp2
  ruben@sputnik:~$ lxc-start -n lamp2 -d
  ruben@sputnik:~$ lxc-attach -n lamp2

  root@lamp2:/# echo $TEST_VAR

  root@lamp2:/# echo $HOME 
  /home/ruben

  at least the $HOME variable is set incorrectly inside the container,
  whilte TEST_VAR is correcty unset inside.

  
  1) The release of Ubuntu you are using, via 'lsb_release -rd' or System -> About Ubuntu

  in the host:
  ruben@sputnik:~$ lsb_release
  LSB Version:	core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:core-4.1-amd64:core-4.1-noarch:security-4.0-amd64:security-4.0-noarch:security-4.1-amd64:security-4.1-noarch

  in the container:
  root@lamp2:/# lsb_release 
  No LSB modules are available.

  this is a trusty container, created with a downloaded template (lxc-
  create ... -t download)

  2) The version of the package you are using, via 'apt-cache policy
  pkgname' or by checking in Software Center

  ruben@sputnik:~$ apt-cache policy lxc
  lxc:
    Instalados: 1.0.7-0ubuntu0.9
    Candidato:  1.0.7-0ubuntu0.9
    Tabla de versión:
       1.1.4-0ubuntu1.1~ubuntu14.04.2 0
          100 http://mx.archive.ubuntu.com/ubuntu/ trusty-backports/main amd64 Packages
   *** 1.0.7-0ubuntu0.9 0
          500 http://mx.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
          100 /var/lib/dpkg/status
       1.0.7-0ubuntu0.7 0
          500 http://security.ubuntu.com/ubuntu/ trusty-security/main amd64 Packages
       1.0.3-0ubuntu3 0
          500 http://mx.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

  3) What you expected to happen

  The user root should have it's $HOME set to /root inside the container

  
  4) What happened instead

  The user root has it's $HOME set to the unprivileged user's

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1513698/+subscriptions


References