Bug 1155488

Summary: The env parameter $XDG_RUNTIME_DIR should get the cocrret value automatically while su - to usermode
Product: Red Hat Enterprise Linux 7 Reporter: Pei Zhang <pzhang>
Component: systemdAssignee: systemd-maint
Status: CLOSED NOTABUG QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: dyuan, jdenemar, msekleta, mzhan, shyu, systemd-maint-list, xuzhang, ydu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-22 11:19:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Pei Zhang 2014-10-22 08:44:23 UTC
Description:
While su - to usermode, the env parameter $XDG_RUNTIME_DIR is NULL,it should get the correct value automatically.

using  su -  and  ssh two different ways to switch to user mode  in two terminal,
guest status is different . the change to the guest can not be synchronized

Product Version:
kernel-3.10.0-188.el7.x86_64
qemu-kvm-rhev-2.1.2-3.el7.x86_64
libvirt-1.2.8-5.el7.x86_64

How producible:
100%

Steps:
1. root login into host ;

add a test user.
#useradd test

#pwd
/home/test

prepare a img and xml which belong to test .

# ls -al domain.xml r7new.img
-rw-r--r--. 1 test test       3281 Oct 16 11:09 domain.xml
-rw-r--r--. 1 test test 3863478272 Oct 16 11:07 r7new.img

2. in terminal 1, using ssh to switch to user mdoe:

#ssh -X test@localhost

$ virsh define domain.xml
Domain r7user defined from domain.xml


[test@184 ~]$ virsh start r7user
Domain r7user started

[test@184 ~]$ virsh list --all
 Id    Name                           State
----------------------------------------------------
 2     r7user                         running


[test@184 ~]$  echo $XDG_RUNTIME_DIR
/run/user/1001


3. in terminal2, using su - test to switch to user mode :

[root@184 test]# su - test

to check the guest status:

[test@184 ~]$ virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     r7user                         shut off

check $XDG_RUNTIME_DIR, nothing out put.
[test@184 ~]$  echo $XDG_RUNTIME_DIR 


if start guest
#virsh start r7user
it will hang

ctrl + c to stop then

#virsh start r7user
error: Domain is already active

[test@184 ~]$ virsh list --all
 Id    Name                           State
----------------------------------------------------
 2     r7user                         shut off


4. check with qemu , it has two qemu process.
[test@184 ~]$ ps -ef | grep qemu
test      9567     1  1 11:56 ? .......
test      9601     1  0 11:56 ?.......


5. set the value of $XDG_RUNTIME_DIR manually same with the one in step 2, the guest status will be sync with step 2.
[test@184 ~]$ export XDG_RUNTIME_DIR='/run/user/1001'
[test@184 ~]$  echo $XDG_RUNTIME_DIR
/run/user/1001
[test@184 ~]$ virsh list --all
 Id    Name                           State
----------------------------------------------------
 2     r7user                         running


Actual Result:
In step 3, using  su -  switch to user mode , the environment parameter  XDG_RUNTIME_DIR is empty. libvirt guest can not get correct status .
  
Expected Result:
In step 3, using  su -  switch to user mode , the environment parameter  XDG_RUNTIME_DIR should get the cocrret value automatically. libvirt guest can get correct status. 
The guest status should be synced while using ssh and su to the usermode.


additonal information:
There is one similar bug for you reference, which is verified.
https://bugzilla.redhat.com/show_bug.cgi?id=955470

Comment 1 Michal Sekletar 2014-10-22 11:19:57 UTC
Semantics of /bin/su - are very vaguely defined and doesn't mention XDG_RUNTIME_DIR explicitly. We don't leave XDG_RUNTIME_DIR set unconditionally. We undefine it when newly logged in user is not the same as the one which owns the session. If you want a full session use mechanism which will provide you one. Calling /bin/su - just doesn't cut it. Sorry. Closing as NOTABUG for now.

Comment 2 Xuesong Zhang 2014-10-31 06:53:16 UTC
hi, Jiri,

libvirt is not working well while su - to usermode, it's one systemd bug. But the systemd developer closed as NOTABUG, is it ok for libvirt side? Would you please kindly have a look at this bug? Thanks in advanced.

Comment 3 Jiri Denemark 2014-11-05 12:09:15 UTC
Well, I think libvirt doesn't really care.