Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/tmp/run ownership problem #141

Open
PenelopeFudd opened this issue Mar 11, 2022 · 0 comments
Open

/tmp/run ownership problem #141

PenelopeFudd opened this issue Mar 11, 2022 · 0 comments

Comments

@PenelopeFudd
Copy link

I've encountered a small bug:

$ sudo -u rabbitmq systemctl
.... some output ....

$ sudo -u postgres systemctl

Traceback (most recent call last):
  File "/usr/bin/systemctl", line 6408, in <module>
    systemctl_debug_log = os_path(_root, expand_path(SYSTEMCTL_DEBUG_LOG, not _user_mode))
  File "/usr/bin/systemctl", line 420, in expand_path
    RUN = get_RUN(root)
  File "/usr/bin/systemctl", line 334, in get_RUN
    os.makedirs(path) # "/tmp/run"
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 17] File exists: '/tmp/run'

Looking at the code, it appeared that systemctl should have detected that the user was not "root" and used /tmp/run-$user, but on closer inspection it's actually setting root=True if the --user CLI option isn't set.

Essentially there's confusion about what the root flag means:

  • Running with euid=0
  • Running systemctl on "system" units (versus "user" units)

Possible solutions:

  • Maybe use /tmp/run.{os.geteuid()} ?
  • I would have suggested removing /tmp/run after execution completes, but if there's two copies running at the same time, that would break things even more.
  • Use tempfile.TemporaryDirectory ?
  • Perhaps /tmp/run.{os.getpid()} and remove it after?

Thanks for taking the time to write this package, it's really helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant