summaryrefslogtreecommitdiffstats
path: root/src/run-generator
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2023-08-12 19:15:20 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2023-08-19 02:15:01 +0200
commit121ce4a6879b0222cb7a9c27730a27e4fbfe5fb2 (patch)
treed47e19cadd3ed73d675cee76cd981573d74d8b56 /src/run-generator
parentMerge pull request #28871 from ssahani/route-hoplimit (diff)
downloadsystemd-121ce4a6879b0222cb7a9c27730a27e4fbfe5fb2.tar.xz
systemd-121ce4a6879b0222cb7a9c27730a27e4fbfe5fb2.zip
generators: use generator_open_unit_file where appropriate
Diffstat (limited to 'src/run-generator')
-rw-r--r--src/run-generator/run-generator.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/run-generator/run-generator.c b/src/run-generator/run-generator.c
index dda7c36159..5692b7a58e 100644
--- a/src/run-generator/run-generator.c
+++ b/src/run-generator/run-generator.c
@@ -63,13 +63,11 @@ static int generate(void) {
if (strv_isempty(arg_commands) && !arg_success_action)
return 0;
- p = strjoina(arg_dest, "/kernel-command-line.service");
- f = fopen(p, "wxe");
- if (!f)
- return log_error_errno(errno, "Failed to create unit file %s: %m", p);
+ r = generator_open_unit_file(arg_dest, /* source = */ NULL, "kernel-command-line.service", &f);
+ if (r < 0)
+ return r;
- fputs("# Automatically generated by systemd-run-generator\n\n"
- "[Unit]\n"
+ fputs("[Unit]\n"
"Description=Command from Kernel Command Line\n"
"Documentation=man:systemd-run-generator(8)\n"
"SourcePath=/proc/cmdline\n", f);
@@ -99,7 +97,7 @@ static int generate(void) {
r = fflush_and_check(f);
if (r < 0)
- return log_error_errno(r, "Failed to write unit file %s: %m", p);
+ return log_error_errno(r, "Failed to write unit kernel-command-line.service: %m");
/* Let's create a target we can link "default.target" to */
p = strjoina(arg_dest, "/kernel-command-line.target");