[systemd-devel] [PATCH 1/5] backlight: don't hardcode path in binary
Lennart Poettering
lennart at poettering.net
Mon Feb 24 07:50:12 PST 2014
On Mon, 24.02.14 15:59, Michal Sekletar (msekleta at redhat.com) wrote:
> Not that we are going to move things around but it is nicer to have paths
> configurable rather than hardcoded in the source.
> ---
> Makefile.am | 2 ++
> src/backlight/backlight.c | 6 +++---
> units/systemd-backlight at .service.in | 2 +-
> 3 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/Makefile.am b/Makefile.am
> index 0b879f1..c9e1e74 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -169,6 +169,7 @@ AM_CPPFLAGS = \
> -DROOTPREFIX=\"$(rootprefix)\" \
> -DRANDOM_SEED_DIR=\"$(localstatedir)/lib/systemd/\" \
> -DRANDOM_SEED=\"$(localstatedir)/lib/systemd/random-seed\" \
> + -DBACKLIGHT_DIR=\"$(localstatedir)/lib/systemd/backlight\" \
> -DSYSTEMD_CRYPTSETUP_PATH=\"$(rootlibexecdir)/systemd-cryptsetup\" \
> -DSYSTEM_GENERATOR_PATH=\"$(systemgeneratordir)\" \
> -DUSER_GENERATOR_PATH=\"$(usergeneratordir)\" \
> @@ -4527,6 +4528,7 @@ substitutions = \
> '|PACKAGE_URL=$(PACKAGE_URL)|' \
> '|RANDOM_SEED_DIR=$(localstatedir)/lib/systemd/|' \
> '|RANDOM_SEED=$(localstatedir)/lib/systemd/random-seed|' \
> + '|BACKLIGHT_DIR=$(localstatedir)/lib/systemd/backlight|' \
> '|prefix=$(prefix)|' \
> '|exec_prefix=$(exec_prefix)|' \
> '|libdir=$(libdir)|' \
> diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c
> index 86f10cc..19dd86c 100644
> --- a/src/backlight/backlight.c
> +++ b/src/backlight/backlight.c
> @@ -210,7 +210,7 @@ int main(int argc, char *argv[]) {
>
> umask(0022);
>
> - r = mkdir_p("/var/lib/systemd/backlight", 0755);
> + r = mkdir_p(BACKLIGHT_DIR, 0755);
> if (r < 0) {
> log_error("Failed to create backlight directory: %s", strerror(-r));
> return EXIT_FAILURE;
> @@ -272,9 +272,9 @@ int main(int argc, char *argv[]) {
> return EXIT_FAILURE;
> }
>
> - saved = strjoin("/var/lib/systemd/backlight/", escaped_path_id, ":", escaped_ss, ":", escaped_sysname, NULL);
> + saved = strjoin(BACKLIGHT_DIR, escaped_path_id, ":",
> escaped_ss, ":", escaped_sysname, NULL);
Hmm, you defined BACKLIGHT_DIR without a trailing slash, so isn't a
trailing slash missing here?
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list