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

%t not supported #29

Closed
jamie-at-sas opened this issue Jul 13, 2018 · 7 comments
Closed

%t not supported #29

jamie-at-sas opened this issue Jul 13, 2018 · 7 comments
Milestone

Comments

@jamie-at-sas
Copy link

Service files support ""%t" unit specifier that stands for the runtime directory."

This was throwing me for a bit with a service that had a value similar to

%t/foo/socket

in it. I had to change it to explicit

/run/foo/socket

In order to get systemctl.py to properly start the service, with the socket being created. Of course, /run/foo had to be created and permissions set first.

@gdraheim
Copy link
Owner

gdraheim commented Aug 3, 2018

by the way, how to push the directory value as configuration item to the started service? Is there any documentation that %t relates to a standard system configuration value / environment variable? Everybody knows $HOME but what about this one?

@jamie-at-sas
Copy link
Author

jamie-at-sas commented Aug 3, 2018

"%t" Runtime directory root This is either /run (for the system manager) or the path "$XDG_RUNTIME_DIR" resolves to (for user managers).

From this page: systemd.unit

Lots of other % specifiers as well, all listed in a nice table on that page.

@gdraheim
Copy link
Owner

While checking I had notice that the path itself was wrong ... instead of /run it was targetting /var.

I don't know if that is a good idea as /run may possibly not be present in docker containers.

Another thing is that I have implemented user_mode for the environment variables as well, but the systemd documention is incomplete (again). It just says to use the XDG variables but if you look into that freedesktop standard then applications are asked to assume default values for XDG variables when they are not present. So in user mode, shall systemctl.py fallback to the systemd's system-level values or to freedesktop's user-level values. Hmm.

https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

@jamie-at-sas
Copy link
Author

Containers based on centos, at least, have /var/run -> /run, so either would work. I think most versions of Unix have an equivalent. The only problem is if neither one is there.

To start, I would look for /run. If it exists, use it. If not, look for /var/run. If it exists, use it. If neither one exists... ???

That page seems fairly clear as to how to handle things if the XDG variables are not set, such as

"If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used."

There is a phrase like this for each of the variables, stating the default location if the variable isn't set.

I would implement user_mode values based on that page, and cite the link for people to look up the details.

Making your code work to the freedesktop standards is not a bad thing. :-)

@gdraheim
Copy link
Owner

Well, I know the freedesktop standard but I am unsure if those defaults apply to user-mode of systemctl.py. The systemd's documentation may be read as "if $XDG_xy does exist".

On a second thought I do basically have to make a differentiation here for user-mode. In USERMODE.md I do describe that system-services may also be run in user containers, and the env-vars is a place where I do simply have to check whether the target service as originally meant to be a system-service or user-service. That's the point I was missing here as in the later case it makes fully sense to use XDG defaults and not system defaults.

@gdraheim
Copy link
Owner

Done the implementation. The test_3260 does also show that %t is expanded differently for --user mode. The %t had been already part of test_3250 for --system mode, with the value corrected.

Please confirm that this fixes your request. :)

@gdraheim
Copy link
Owner

So far my tests seem to be okay, so I'll keep it that way for the upcoming release 1.4

@gdraheim gdraheim added this to the M1.4 milestone Aug 30, 2018
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

2 participants