-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
core: Allow preserving contents of RuntimeDirectory over process restart #6328
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
Conversation
man/systemd.exec.xml
Outdated
| <varlistentry> | ||
| <term><varname>RuntimeDirectoryPreserve=</varname></term> | ||
|
|
||
| <listitem><para>Takes one of <option>never</option>, <option>restart</option>, or <option>always</option>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it "no" or "never" or both ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only never. Current implimentation does not allow boolean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be fixed here though, as you do suggest using "no" in the current version
man/systemd.exec.xml
Outdated
| are always removed when the service stops. If set to <option>restart</option> the directories are preserved | ||
| when the service is both automatically and manually restarted. Here, the automatic restart means the operation | ||
| specified in <varname>Restart=</varname>, and manual restart means the one triggered by | ||
| <command>systemctl restart foo.service</command>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC always means the directory is never removed, except on reboot (it's a tmpfs after all)
it might be worth saying that explicitely...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I forgot to mention it. Thanks.
poettering
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks excellent already, just minor fixes, and please add the support for "systemd-run -p …" as described, thanks!
|
|
||
| return 1; | ||
|
|
||
| } else if (streq(name, "RuntimeDirectoryPreserve")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, could you also add the counterparts for this to src/shared/bus-unit-util.c's bus_append_unit_property_assignment()? We should really make sure that all new options come with that right-away (we are still missing some prop hookups for older props, and we should fix that too, but let's get this right right-away for the new ones).
Adding this means the new functionality can be tested easily using:
systemd-run -t -p RuntimeDirectory=foo -p RuntimeDirectoryPreserve=always /bin/sh
src/core/dbus-execute.c
Outdated
| if (mode != UNIT_CHECK) { | ||
| c->runtime_directory_mode = m; | ||
|
|
||
| unit_write_drop_in_private_format(u, mode, name, "RuntimeDirectoryMode=%u", m); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be output with %040o rather than %u, after all creation modes are usually written in octal style.
man/systemd.exec.xml
Outdated
| <varname>$XDG_RUNTIME_DIR</varname> (for user services) when | ||
| the unit is started, and removed when the unit is stopped. The | ||
| the unit is started, and removed when the unit is stopped. | ||
| It is possible to preserve the direcotries if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
direcotries → directories
man/systemd.exec.xml
Outdated
| <varlistentry> | ||
| <term><varname>RuntimeDirectoryPreserve=</varname></term> | ||
|
|
||
| <listitem><para>Takes one of <option>never</option>, <option>restart</option>, or <option>always</option>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to be fixed here though, as you do suggest using "no" in the current version
|
@boucman @poettering Thank you for your comments. I've force-pushed the updated version. In the updated commits, I use a boolean argument rather than |
|
resolved fails to start: |
|
@fsateler Thank you for testing my code. I have a question. In your testing environment, only resolved fails? networkd and timesyncd works well? |
|
@yuwata I did not test it myself, I'm just copying a snippet from he failed s390x autopkgtest. But it appears only resolved is failing |
|
@fsateler OK. I will read the log in detail. Recently in many PR the network related test have been failed on xenial-s390x. So I did not check the s390x log. Thanks. |
b758b74 to
7030367
Compare
|
It seems that dropping privileges from networkd, resolved, and tymesyncd require more work. So, I will propose it in another PR. Now, the commits just add |
poettering
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks excellent already, just one minor issue left
src/core/load-fragment.c
Outdated
| } | ||
|
|
||
| if (!filename_is_valid(k)) { | ||
| if (!path_is_safe(k)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I think we should not permit absolute paths here, just to avoid confusion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've add path_is_absolute() here in the revised version.
src/shared/bus-unit-util.c
Outdated
|
|
||
| r = sd_bus_message_append(m, "v", "u", mode); | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spurious newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
…tart This introduces RuntimeDirectoryPreserve= option which takes a boolean argument or 'restart'. Closes systemd#6087.
|
@poettering Thank you for your review. Updated. |
|
thanks! lgtm! |
|
I've just filed #6391 about not calling |
This introduces
RuntimeDirectoryPreserve=option which takes a boolean argument orrestart.Closes #6087.