When launching a 16.04 container, I could sudo to root.
$ lxc launch ubuntu:x old
Creating old
Starting old
$ lxc exec old -- sudo --user ubuntu --login
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
ubuntu@old:~$ sudo su -
mesg: ttyname failed: Success
root@old:~#
But when I try with LXD 3.0 and a container with 18.04, I cannot anymore.
$ lxc launch images:ubuntu/18.04 openvpn
Creating openvpn
Starting openvpn
$ lxc exec openvpn -- sudo --user ubuntu --login
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
ubuntu@openvpn:~$ sudo su -
sudo: no tty present and no askpass program specified
ubuntu@openvpn:~$
@brauner this even happens on up to date Ubuntu 18.04 with the current kernel, any idea what’s going on here? Smells like our favorite kernel/glibc interaction but I thought you sorted that out.
I am trying lxc-attach commands in lxc and getting this error. Was looking to find an answer on here but looks like you guys are coming up short too :(.
My initial command to run a python script within the container doesn’t need sudo however the script itself wants sudo for running openvpn. Maybe I will have to look into running openvpn as non sudo if there is no clear solution to this or just run as root.
How come you can sudo within the container normally but not via lxc-attach?
As I mentioned earlier, I see it on current Ubuntu 18.04 with the latest kernel, so that should be the new libc with the kernel using your commits, unless they haven’t made it yet somehow.
ubuntu@bionic:~$ logout
root@vm06:~# lxc launch images:ubuntu/18.04 openvpn
Creating openvpn
Starting openvpn
root@vm06:~# lxc exec openvpn -- sudo --user ubuntu --login
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
ubuntu@openvpn:~$ sudo su -
sudo: no tty present and no askpass program specified
ubuntu@openvpn:~$ uname -a
Linux openvpn 4.15.0-19-generic #20-Ubuntu SMP Sun Apr 22 00:03:34 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
ubuntu@openvpn:~$
root@vm06:~# lxc launch ubuntu:16.04 cloud-16
Creating cloud-16
Starting cloud-16
root@vm06:~# lxc launch ubuntu-daily:18.04 cloud-18
Creating cloud-18
Starting cloud-18
root@vm06:~# lxc launch images:ubuntu/16.04 images-16
Creating images-16
Starting images-16
root@vm06:~# lxc launch images:ubuntu/18.04 images-18
Creating images-18
Starting images-18
root@vm06:~# lxc exec cloud-16 -- sudo -u ubuntu -i
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
ubuntu@cloud-16:~$ sudo su -
mesg: ttyname failed: Success
root@cloud-16:~# logout
ubuntu@cloud-16:~$ logout
root@vm06:~# lxc exec cloud-18 -- sudo -u ubuntu -i
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
ubuntu@cloud-18:~$ sudo su -
mesg: ttyname failed: No such device
root@cloud-18:~# logout
ubuntu@cloud-18:~$ logout
root@vm06:~# lxc exec images-16 -- sudo -u ubuntu -i
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
ubuntu@images-16:~$ sudo su -
sudo: no tty present and no askpass program specified
ubuntu@images-16:~$ logout
root@vm06:~# lxc exec images-18 -- sudo -u ubuntu -i
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
ubuntu@images-18:~$ sudo su -
sudo: no tty present and no askpass program specified
ubuntu@images-18:~$ logout