hi,
On 19.07.2012 09:28, Markus Fischer wrote:
> Working sudo:
> Jul 19 09:06:31 server sudo: theuser : TTY=pts/2 ; PWD=/tmp ; USER=root
> ; COMMAND=/bin/ls
>
> sudo not working:
> Jul 19 09:00:16 server sudo: theuser : TTY=unknown ; PWD=/tmp; USER=root
> ; COMMAND=/bin/ls
This, and one of the comment [1] on the SO question gave me a new
direction to search for the problem: "I think it means that sudo is not
the root cause of the problem; the apparent lack of a terminal is."
I also realized the whole time I never described how I did enter the
guest system to have this problems. I used "sudo vserver <vserver> exec
su - theuser".
With a small C program to get the current users tty:
#include <unistd.h>
#include <stdio.h>
int main() {
char *name = ttyname(0);
printf("ttyname = '%s'\n", name);
return 0;
}
I did the following tests (excutable put inside guest in /tmp/ttyname):
theuser@host:~$ sudo vserver guest01 exec /tmp/ttyname
ttyname = '(null)'
theuser@host:~$ sudo vserver guest01 enter
guest01:~# /tmp/ttyname
ttyname = '/dev/pts/12'
guest01:~# logout
theuser@host:~$ sudo vserver guest01 exec su - theuser
theuser@guest01:~$ /tmp/ttyname
ttyname = '(null)'
theuser@guest01:~$ logout
theuser@host:~$ sudo vserver guest01 enter
guest01:~# su - theuser
theuser@guest01:~$ /tmp/ttyname
ttyname = '/dev/pts/12'
So, whenever I used "enter" to get in the system, my user has a valid tty.
But when I use "exec", there's none. And I used "su - theuser" all the
time to enter the system as my user directly.
sudo was working whenever my user had a TTY but didn't worked when I had
none.
I also did another test: installed openssh inside guest01 and logged in
via SSH; the result was that my user was having a tty and thus sudo
worked too.
I've then tested this on a Lenny guest system:
theuser@host:~$ sudo vserver lenny01 exec su - theuser
theuser@lenny01:~$ /tmp/ttyname
ttyname = '/dev/pts/5'
And apparently sudo was working there too.
Now I wonder: what could be the reason that "exec" does give me a TTY in
Lenny, but none in Squeeze?
thx,
- Markus
[1] http://serverfault.com/questions/406010
Received on Fri Jul 20 21:22:01 2012