You are not logged in.
Hey guys,
I understand that when you login to a tty and execute `systemctl reboot` or `systemctl poweroff` you won't be prompted to authenticate due to the way the policy is configured in org.freedesktop.login1.
I've also seen this work when within an X11 session (I'm not sure on the exact requirements for it to work though).
However, I manage my x11 session by starting systemd --user and then logging out of the tty, so when I run `systemctl reboot` it will ask me to authenticate as root.
Is there something I can configure so that I can reboot/power-off from within my X session?
Thanks,
Edit: The "general" solution to this is to make sure X is running on the same TTY as one of your user session (see loginctl). But for my specific solution dealing with systemd --login see post #10
Last edited by EvanPurkhiser (2013-07-24 11:08:26)
Offline
Just reboot ??
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way
Offline
I use systemd --user to boot directly into an X11 session. There is no display manager, and I have user-session@wonderwoofy.service conflict with getty@tty1.service. With this setup I obtain an active logind session.
So I think you need to provide a bit more info here. You use systemd --user, but as there is no formal way of implementing that as of yet, how exactly do you have this set up? I would imagine that different methods have the potential to have different results.
If you run "loginctl" you will get a printout of all the logged in users. There should be one entry for your X11 session. Take note of the number session number and run "loginctl show-session <session #>". If in that output it says "Active=yes" then it *should* be working. But if not, then something you have set up is keeping you from having a valid logind session. Also, if you have more than one user logged in (even if it is your user and root), then you are going to have to authenticate before shutting down anyway. But if you have multiple sessions all under the same user, it should still work.
Offline
Running `loginctl` I see I'm the I'm the only session logged in. Running `loginctl session-status 1` I see the output
1 - evan (1000)
Since: Sun 2013-07-14 18:27:26 EDT; 2min 32s ago
Leader: 333
Seat: seat0; vc1
TTY: tty1
Service: login; type tty; class user
State: closing
CGroup: systemd:/user/1000.user/1.session
└─systemd-486
├─486 /usr/lib/systemd/systemd --user --log-target=journal --unit=graphical.target
...
└─ssh-agent.service
└─497 /usr/bin/ssh-agent -a /run/user/1000/ssh-agentSo it doesn't look like my session is "Active"
Here's how I start my systemd --user session (from .profile)
# Default systemd to the console target
target="console"
# If we're logging in from VT1 start the graphical target
if [[ $XDG_VTNR == 1 ]] && ! systemctl --user -q is-active graphical.target &> /dev/null
then
target="graphical"
fi
# Bring up systemd --user to the specified target
if ! systemctl --user &> /dev/null
then
# Double-fork the systemd process. This is done by executing a
# sub-shell (using ()) to ensure we're not the process leader, and
# then starting systemd using setsid to detach it from the
# controlling tty. Finally & to fork again to the background
(setsid /usr/lib/systemd/systemd --user --log-target=journal --unit=${target}.target &)
else
# Systemd is already active, start the target
(setsid systemctl --user start ${target}.target &)
fi
# Logout of the terminal if we're starting the graphical target
[[ $target == "graphical" ]] && sleep 1 && logout
# Source the bashrc if we're starting an interactive environment
source "$HOME/.bashrc"If I comment out the line that logs me out when starting the graphical target then my session-status looks like this:
2 - evan (1000)
Since: Sun 2013-07-14 18:34:22 EDT; 12s ago
Leader: 736 (login)
Seat: seat0; vc1
TTY: tty1
Service: login; type tty; class user
State: online
CGroup: systemd:/user/1000.user/2.session
├─736 login -- evan
├─858 -bash
└─systemd-868
├─868 /usr/lib/systemd/systemd --user --log-target=journal --unit=graphical.target
...
└─ssh-agent.service
└─877 /usr/bin/ssh-agent -a /run/user/1000/ssh-agentSo now my status is "online", however It still makes me authenticate to reboot
What are the conditions to having an "Active" login session?
Offline
Well... you didn't enter the command correctly, so there is no reasonable expectation to find output that says whether the session is active or not.
Offline
Oh my, I feel very stupid ![]()
Sorry about that! You're right, I see "Active=no", here's the full output
Id=1
Timestamp=Sun 2013-07-14 19:38:17 EDT
TimestampMonotonic=9510506
DefaultControlGroup=systemd:/user/1000.user/1.session
VTNr=1
TTY=tty1
Remote=no
Service=login
Leader=391
Audit=1
Type=tty
Class=user
Active=no
State=online
KillProcesses=no
IdleHint=yes
IdleSinceHint=1373845096523537
IdleSinceHintMonotonic=8177129
Name=evanI see the same thing when not logging out of the tty after X starts
Last edited by EvanPurkhiser (2013-07-15 00:14:30)
Offline
I see the same thing when not logging out of the tty after X starts
You run x on a different tty?
I don't have polkit nor use any of the logind features - but I do know that if I wanted to, I'd need to run X on the same tty I logged in on.
Last edited by Trilby (2013-07-15 01:46:53)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Yes, I have my systemd --user session to run X on tty1. The service conflicts with getty@tty1, so if I boot the graphical.target, I get X. But if I boot to multi-user.target (or isolate multi-user.target), getty@tty1 reapprears.
Offline
Thanks guys, I'm starting to understand better how systemd-logind works now, and it's making a little more sense.
You're correct Trilby, I am starting X on a different vt than the one I login with, which I see is why when I switch to X my session is no longer "Active".
Starting X on the same vt as the one I login at does show my session as "Active" within X, but it causes some other strange issues (can't switch to different vts within X, graphical corruption during shutdown). I kind of like having X start of vt4 and having the first 3 vts free.
I'm going to poke around a little more and see if it's possible to login from one tty, but reassign the session to a different VT (If that makes sense).
Offline
Finally coming back to this. My solution was more or less to re-work the way I started my systemd --user session.
In order for your session to be active you do have to currently be on the tty that is registered with the logind session. See here.
Instead of starting my systemd --user instance from my .profile after, forking, and then logging out, I'm instead starting the systemd --user instance as a systemd service under my user with the default target just requiring dbus. The service file includes PAMName=login which will start a new session in logind and TTYPath=/dev/tty5 which starts the session on tty5 (which X will also be started on) See here.
In my .profile, if logging into VT1, I bring up the graphical.target for my systemd --user instance and then exit the session. The session will be active because X will be on tty5, which isn't interfered with by a getty, and leaves my first 4 VTs open.
Hopefully my post can help someone else trying to setup systemd --user like me in the future ![]()
Offline