Bug 1583159 - Sample service file vncserver@.service is out of date with systemd changes
Summary: Sample service file vncserver@.service is out of date with systemd changes
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: tigervnc
Version: 28
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jan Grulich
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-28 11:12 UTC by Alexander Korsunsky
Modified: 2018-06-16 20:16 UTC (History)
4 users (show)

Fixed In Version: tigervnc-1.8.0-10.fc27 tigervnc-1.8.0-10.fc28
Clone Of:
Environment:
Last Closed: 2018-06-16 19:32:44 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Proposed Unit file for the Tiger VNC service (637 bytes, text/plain)
2018-05-28 13:57 UTC, Alexander Korsunsky
no flags Details
Proposed vncserver.service file (1.65 KB, text/plain)
2018-06-13 09:18 UTC, Jan Grulich
no flags Details

Description Alexander Korsunsky 2018-05-28 11:12:53 UTC
Description of problem:

The current version of the sample file for the VNC service configuration (/lib/systemd/system/vncserver@.service) does not work with the current version of SystemD:


The service file runs as root, but the PID file is created as a user. In newer versions, systemd refuses to take a PID file that is not owned by root as the PID for the root service:

vncserver-myusername@:1.service: New main PID 2095 does not belong to service, and PID file is not owned by root. Refusing.

This is probably because of the changes in commit https://github.com/systemd/systemd/commit/db256aab13d8a89d583ecd2bacf0aca87c66effc .


If I add 
User=myusername
Group=myusername

to the service file, I get the following errors:


Mai 28 12:02:51 mymachine.local runuser[1635]: runuser: darf von Benutzern ohne Administratorrechte nicht verwendet werden
Mai 28 12:02:51 mymachine.local systemd[1]: vncserver-myusername@:4.service: Control process exited, code=exited status=1
Mai 28 12:02:51 mymachine.local systemd[1]: vncserver-myusername@:4.service: Failed with result 'exit-code'.
Mai 28 12:02:51 mymachine.local systemd[1]: Failed to start Remote desktop service (VNC).


The fix is to remove the `runuser` invocation from the ExecStart= key, start vncserver directly and instead set the User= and Group= keys in the service section:


[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking
User=<USER>
Group=<USER>

# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=//usr/bin/vncserver %i
PIDFile=/home/<USER>/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target



Version-Release number of selected component (if applicable):
tigervnc-server-1.8.0-7.fc28.x86_64


How reproducible:
Every time


Steps to Reproduce:
1. Follow the instructions in /lib/systemd/system/vncserver@.service to create service units
2.
3.

Actual results:
Obtain defunct service unit

Expected results:
Obtain functional service unit

Additional info:

Comment 1 Alexander Korsunsky 2018-05-28 13:57:35 UTC
Created attachment 1443332 [details]
Proposed Unit file for the Tiger VNC service

For that matter, here's our unit file for a VNC server that runs as a "service":

 * Start and Stop are properly detected
 * Logging out of the server causes the service to be marked as stop
 * 15 seconds after logout, the service is restart to permit a new login

Comment 2 Jan Grulich 2018-06-13 09:18:54 UTC
Created attachment 1450824 [details]
Proposed vncserver.service file

What about this one?

Few questions regarding your version. Why do you use "type=notify" under [Service] section, I think it should stay on "type=forking". I see there is problem when using runuser, it was there as Gnome had problems to fully start without it. I was suggested once to use e.g. "PAMName=login" instead, but now it seems that neither of them is needed.

Comment 3 Alexander Korsunsky 2018-06-13 10:14:42 UTC
This one looks good too.

> Why do you use "type=notify" under [Service] section, I think it should stay on "type=forking".

You are right, forking is probably better. The reason I had notify in there is that I wanted to avoid the whole PIDFile business due to Bug 1418463 and let the desktop sessions communicate their status via sd_notify. However, that requires NotifyAccess=all because it's not vncserver who sends the sd_notify, but the GNOME/XFCE session. This may or may not be awkward for security.

> I was suggested once to use e.g. "PAMName=login" instead, but now it seems that neither of them is needed.

It certainly seems so. If the SELinux policy is amended to allow systemd to access .vnc directories, the unit file works pretty well.

Comment 4 Fedora Update System 2018-06-13 11:29:45 UTC
tigervnc-1.8.0-10.fc28 has been submitted as an update to Fedora 28. https://bodhi.fedoraproject.org/updates/FEDORA-2018-f67d10ae9e

Comment 5 Fedora Update System 2018-06-13 11:50:39 UTC
tigervnc-1.8.0-10.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2018-817f36c368

Comment 6 Fedora Update System 2018-06-13 23:00:34 UTC
tigervnc-1.8.0-10.fc28 has been pushed to the Fedora 28 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-f67d10ae9e

Comment 7 Fedora Update System 2018-06-14 13:48:20 UTC
tigervnc-1.8.0-10.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2018-817f36c368

Comment 8 Fedora Update System 2018-06-16 19:32:44 UTC
tigervnc-1.8.0-10.fc27 has been pushed to the Fedora 27 stable repository. If problems still persist, please make note of it in this bug report.

Comment 9 Fedora Update System 2018-06-16 20:16:50 UTC
tigervnc-1.8.0-10.fc28 has been pushed to the Fedora 28 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.