Merge pull request #28673 from YHNdnzj/hibernate-resume-escape-node

hibernate-resume-generator: escape device path passed to hibernate-resume
This commit is contained in:
Luca Boccassi 2023-08-04 16:46:56 +01:00 committed by GitHub
commit 0e387e1295
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -1060,7 +1060,7 @@
specified, see
<citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
The default is <literal>infinity</literal> (job timeouts disabled), except for device units where
<varname>JobRunningTimeoutSec=</varname> defaults to <varname>DefaultTimeoutStartSec=</varname>.
<varname>JobRunningTimeoutSec=</varname> defaults to <varname>DefaultDeviceTimeoutSec=</varname>.
</para>
<para>Note: these timeouts are independent from any unit-specific timeouts (for example, the timeout

View file

@ -11,6 +11,7 @@
#include "device-nodes.h"
#include "dropin.h"
#include "efivars.h"
#include "escape.h"
#include "fd-util.h"
#include "fileio.h"
#include "fstab-util.h"
@ -196,7 +197,7 @@ static int parse_efi_hibernate_location(void) {
}
static int process_resume(void) {
_cleanup_free_ char *device_unit = NULL;
_cleanup_free_ char *device_unit = NULL, *device_escaped = NULL;
_cleanup_fclose_ FILE *f = NULL;
int r;
@ -214,6 +215,10 @@ static int process_resume(void) {
if (r < 0)
log_warning_errno(r, "Failed to write device timeout drop-in, ignoring: %m");
device_escaped = cescape(arg_resume_device);
if (!device_escaped)
return log_oom();
r = generator_open_unit_file(arg_dest, NULL, SPECIAL_HIBERNATE_RESUME_SERVICE, &f);
if (r < 0)
return r;
@ -233,7 +238,7 @@ static int process_resume(void) {
"Type=oneshot\n"
"ExecStart=" LIBEXECDIR "/systemd-hibernate-resume %2$s %3$" PRIu64 "\n",
device_unit,
arg_resume_device,
device_escaped,
arg_resume_offset);
r = fflush_and_check(f);