Bug 1309164

Summary: polkit uselessly noisy on a shutdown
Product: Red Hat Enterprise Linux 7 Reporter: Jarrod Petz <jlpetz>
Component: systemdAssignee: systemd-maint
Status: CLOSED INSUFFICIENT_DATA QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: btotty, cleaver-redhat, davdunc, dmaziuk, extras-qa, jlpetz, jsynacek, michal, mitr, oded, pratikjt, roel.vandepaar, rsawhill, sardella, systemd-maint-list, udovdh, vincent
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1205008 Environment:
Last Closed: 2016-06-06 10:36:06 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:
Attachments:
Description Flags
strace logs none

Description Jarrod Petz 2016-02-17 03:21:08 UTC
Created attachment 1127827 [details]
strace logs

+++ This bug was initially created as a clone of Bug #1205008 +++

Duplicating the above Bug report as I think the problem is likely with systemctl and therefore the systemd component/team. This is also for RedHat 7.2 instead of Fedora.

Description of problem:

Per Bug #1205008. When restarting, the session is spammed with the below text depending on command used.
---------------------------------------------------
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.
---------------------------------------------------

I used a brand new RedHat 7.2 instance on AWS EC2.

$ uname -a
Linux ip-172-31-10-82.ap-southeast-2.compute.internal 3.10.0-327.4.5.el7.x86_64 #1 SMP Thu Jan 21 04:10:29 EST 2016 x86_64 x86_64 x86_64 GNU/Linux

These are the three different commands I tired(below) which are essentially all the same given the sym link to underlying executable "/bin/systemctl".

1.
# ls -la /bin/systemctl
-rwxr-xr-x. 1 root root 645664 Oct 12 08:39 /bin/systemctl

2.
# ls -la /sbin/reboot
lrwxrwxrwx. 1 root root 16 Nov  9 20:25 /sbin/reboot -> ../bin/systemctl

3. 
# ls -la /sbin/shutdown
lrwxrwxrwx. 1 root root 16 Nov  9 20:25 /sbin/shutdown -> ../bin/systemctl

If you use "sudo systemctl reboot" or "sudo reboot". Then I get
---------------------------------------------------
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.
---------------------------------------------------

If I use "sudo shutdown -r now" OR "sudo shutdown -r --no-wall now" it doesn't appear.

Also doing "sudo su -" then running "systemctl reboot" or "reboot" also doesn't show the message.

Given this behaviour I suspect systemctl is doing something different depending on how it was called. When called via "reboot" or "systemctl" this something different doesn't seem to like the environment it is running in when run with sudo.

Strace logs attached for these three commands.
   1.  sudo nohup strace reboot > ./reboot_output.txt &
   2.  sudo nohup strace systemctl reboot > ./systemctl_output.txt &
   3.  sudo nohup strace shutdown -r --no-wall now > ./shutdown_output.txt &

Hopefully they help track down where it is doing things different. From what I can tell all three look the same/similar up to line 125 in the logs
-------------------------------------------
Line 125: ioctl(1, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0x7fff976b8d70) = -1 ENOTTY (Inappropriate ioctl for device)
-------------------------------------------

Comment 2 Miloslav Trmač 2016-02-18 14:29:27 UTC
(See also #1249627; not sure what is the better place to track this.)

The messages in question are from polkitagentlistener.c, perhaps through /usr/bin/pkttyagent.

So there are two basic directions of inquiry:

* Which process are they from? systemctl seems a plausible case, it does create an /usr/bin/pkttyagent fork, and the behavior differences with different ways to invoke systemctl described in comment#0 would suggest that this is somehow governed from systemctl.

OTOH none of the attached straces show systemctl forking an agent; and the socket communication patterns seem very similar in all three cases.

Jarrod, a bit more precise information could help here:
* What are the exact starting environments, in particular {real,effective} [UG]ID
  - And if (sudo) vs. (su - ) vs. (ssh) matters, is perhaps sudoers configured differently ? What does (sudo id -a) say?
* What are the exact commands?
* straces should exactly match the commands showing the difference, or the difference in behavior should be in the straced processes. (I.e. if the straces are using nohup, does the same behavior difference show up when running (nohup $command) without strace?)
* Also, much larger string sizes of strace might be useful to actually show the DBus operations being performed.


* Why is polkitd terminating before whatever process is running the agent listener (i.e. probably before some users’ session)?

Comment 3 David Duncan 2016-03-09 00:34:22 UTC
Addressed for the reporter in RH customer case 01588086.

Comment 4 Jan Synacek 2016-06-06 10:36:06 UTC
Closing for the to lack of input and information.