Running initctl as root broken

Bug #1318679 reported by Robin McCorkell
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
upstart
New
Undecided
Unassigned

Bug Description

Running initctl with the UPSTART_SESSION environment variable set causes the --user option to be implicitly set. This fails when the user is logged in as root, as any calls to initctl that affect system services (such as start, stop, restart) fail with 'Unknown job'. Unsetting UPSTART_SESSION restores functionality. This does not affect running initctl under sudo as sudo removes all environment variables.

Alternative to unsetting UPSTART_SESSION one can use "--system" to operate against system init. (Even as a normal user, e.g. to query status of system jobs)

Upstart version 1.12.1-0ubuntu4 on Ubuntu 14.04 amd64

Revision history for this message
James Hunt (jamesodhunt) wrote :

This implies you are logging into a graphical session as root. In which case, you will be running upstart as a Session Init to manage that root graphical session. So, to switch to managing the system instead, yes you will need to unset UPSTART_SESSION.

As you say, sudo does not suffer from the issue, neither does logging in as root via a console (as would commonly be done on server systems) since no Session Init is started.

As outlined in the Trusty Release notes [1], you can also specify --system to the initctl command as an alternative to unsetting UPSTART_SESSION.

[1] - https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes/TechnicalOverviewUpstart.

Changed in upstart:
status: New → Invalid
Revision history for this message
Robin McCorkell (xenopathic) wrote :

The expected behaviour when running as root is always to manage the system. Perhaps a method of forwarding initctl commands to the system init if session init failed?

Revision history for this message
Robin McCorkell (xenopathic) wrote :

Actually, this also affects users with an Upstart user instance that `su` into root.

Changed in upstart:
status: Invalid → New
Revision history for this message
Sir Anthony (a4thony) wrote :

Confirm this.
Using elevated privileges (like setuid) with upstart also impossible for user without cleaning environment.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

The expectation here, is that root user is able to control any user-sessions of any user, by setting appropriate UPSTART_SESSION variable.

If you wish to control system init, please either:
1) pass --system argument
2) unset, or set to empty UPSTART_SESSION

Alternatively we can fix this by:
1) if root, use system init irrespective of UPSTART_SESSION environment variable
2) if root, and "--session" argument is passed, operate against UPSTART_SESSION or bail out if one was not specified / does not exist.

Revision history for this message
Robin McCorkell (xenopathic) wrote :

Fix number 1 would be my preference. It seems natural to me that root should be able to, by default, affect the system settings and not just its own.

description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.