[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi] logname fails
From: |
Greg Chicares |
Subject: |
[lmi] logname fails |
Date: |
Mon, 24 Feb 2020 18:35:23 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
If I
sudo [... whatever]
schroot [...whatever]
then 'logname' returns my unprivileged login name on my debian machine,
but not on a corporate redhat server. See this branch:
http://git.savannah.nongnu.org/cgit/lmi.git/log/?h=odd/rh_server
The only purpose of this email is preemptively to answer the question:
"can't you get that information with pstree though?". Here, I'll just
use ps directly, because I already have that installed in the chroot.
First, debian:
/[0]#ps -p$$ -ouser,ppid,pid,comm
USER PPID PID COMMAND
root 1460 1461 zsh
/[0]#ps -p1461 -ouser,ppid,pid,comm
USER PPID PID COMMAND
root 1460 1461 zsh
/[0]#ps -p1460 -ouser,ppid,pid,comm
USER PPID PID COMMAND
root 1455 1460 su
/[0]#ps -p1455 -ouser,ppid,pid,comm
USER PPID PID COMMAND
greg 1448 1455 zsh
/[0]#ps -p1448 -ouser,ppid,pid,comm
USER PPID PID COMMAND
greg 1 1448 konsole
/[0]#ps -p1 -ouser,ppid,pid,comm
USER PPID PID COMMAND
root 0 1 systemd
So I am still 'greg' after all. But that doesn't work on the server,
presumably because it uses LDAP or something [I've obfuscated the
output to hide my user name and UID]:
/opt/lmi/src/lmi[0]$sudo zsh
/opt/lmi/src/lmi[0]#schroot --chroot=chroot:lmi --user=MY_UNAME --directory=/tmp
$ whoami
whoami: cannot find name for user ID MY_UID
$ ps -p$$ -ouser,ppid,pid
USER PPID PID
MY_UID 5178 5179
$ ps -p$$ -ouser,ppid,pid,comm
USER PPID PID COMMAND
MY_UID 5178 5179 bash
$ ps -p5178 -ouser,ppid,pid,comm
USER PPID PID COMMAND
root 4419 5178 schroot
$ ps -p4419 -ouser,ppid,pid,comm
USER PPID PID COMMAND
root 4418 4419 zsh
$ ps -p4418 -ouser,ppid,pid,comm
USER PPID PID COMMAND
root 4152 4418 sudo
$ ps -p4152 -ouser,ppid,pid,comm
USER PPID PID COMMAND
MY_UID 4151 4152 zsh
$ ps -p4151 -ouser,ppid,pid,comm
USER PPID PID COMMAND
MY_UID 4078 4151 sshd
$ ps -p4078 -ouser,ppid,pid,comm
USER PPID PID COMMAND
root 1727 4078 sshd
$ echo $LOGNAME
MY_UNAME
$ id -un $LOGNAME
id: 'MY_UNAME': no such user
$ whoami
whoami: cannot find name for user ID MY_UID
So it seems that, with effort, I can get my numeric user ID, but I can't
get my alphanumeric user name. And I'm not in /etc/passwd , so I can't
just look it up there either. The next thing to try is to move from a
'plain' schroot to another type that supports setup scripts (as we
probably should have been doing already, anyway).
- [lmi] logname fails,
Greg Chicares <=