summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2014-05-22 09:13:02 +0200
committerNeilBrown <neilb@suse.de>2014-05-22 09:13:02 +0200
commit85945e1986837e1e34247a03c99039593fbceb8b (patch)
tree453d176c911ae229c7dc81b9cbc414187f3b54ee
parentmdcheck: new script to help with regular checks of md arrays. (diff)
downloadmdadm-85945e1986837e1e34247a03c99039593fbceb8b.tar.xz
mdadm-85945e1986837e1e34247a03c99039593fbceb8b.zip
install: use BINDIR consistently to locate mdadm and mdmon
Every place where the paths for mdadm or mdmon is explicit, it should use the BINDIR setting, not "/sbin/". Reported-by: member graysky <graysky@archlinux.us> (https://bugs.archlinux.org/task/37330) Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--Makefile28
-rw-r--r--policy.c4
-rw-r--r--systemd/mdadm-grow-continue@.service2
-rw-r--r--systemd/mdadm-last-resort@.service2
-rw-r--r--systemd/mdadm.shutdown2
-rw-r--r--systemd/mdmon@.service2
-rw-r--r--systemd/mdmonitor.service2
-rw-r--r--udev-md-raid-arrays.rules2
-rw-r--r--udev-md-raid-assembly.rules6
-rw-r--r--util.c2
10 files changed, 32 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index 3af030b5..b52cffd2 100644
--- a/Makefile
+++ b/Makefile
@@ -57,6 +57,7 @@ ifdef DEFAULT_OLD_METADATA
else
DEFAULT_METADATA=1.2
endif
+CPPFLAGS += -DBINDIR=\"$(BINDIR)\"
PKG_CONFIG ?= pkg-config
@@ -280,16 +281,27 @@ install-man: mdadm.8 md.4 mdadm.conf.5 mdmon.8
$(INSTALL) -D -m 644 mdadm.conf.5 $(DESTDIR)$(MAN5DIR)/mdadm.conf.5
install-udev: udev-md-raid-arrays.rules udev-md-raid-assembly.rules
- $(INSTALL) -D -m 644 udev-md-raid-arrays.rules $(DESTDIR)$(UDEVDIR)/rules.d/63-md-raid-arrays.rules
- $(INSTALL) -D -m 644 udev-md-raid-assembly.rules $(DESTDIR)$(UDEVDIR)/rules.d/64-md-raid-assembly.rules
+ @for file in 63-md-raid-arrays.rules 64-md-raid-assembly.rules ; \
+ do sed -e 's,BINDIR,$(BINDIR),g' udev-$${file#??-} > .install.tmp && \
+ echo $(INSTALL) -D -m 644 udev-$${file#??-} $(DESTDIR)$(UDEVDIR)/rules.d/$$file ; \
+ $(INSTALL) -D -m 644 .install.tmp $(DESTDIR)$(UDEVDIR)/rules.d/$$file ; \
+ rm -f .install.tmp; \
+ done
install-systemd: systemd/mdmon@.service
- $(INSTALL) -D -m 644 systemd/mdmon@.service $(DESTDIR)$(SYSTEMD_DIR)/mdmon@.service
- $(INSTALL) -D -m 644 systemd/mdmonitor.service $(DESTDIR)$(SYSTEMD_DIR)/mdmonitor.service
- $(INSTALL) -D -m 644 systemd/mdadm-last-resort@.timer $(DESTDIR)$(SYSTEMD_DIR)/mdadm-last-resort@.timer
- $(INSTALL) -D -m 644 systemd/mdadm-last-resort@.service $(DESTDIR)$(SYSTEMD_DIR)/mdadm-last-resort@.service
- $(INSTALL) -D -m 644 systemd/mdadm-grow-continue@.service $(DESTDIR)$(SYSTEMD_DIR)/mdadm-grow-continue@.service
- $(INSTALL) -D -m 755 systemd/mdadm.shutdown $(DESTDIR)$(SYSTEMD_DIR)-shutdown/mdadm.shutdown
+ @for file in mdmon@.service mdmonitor.service mdadm-last-resort@.timer \
+ mdadm-last-resort@.service ; \
+ do sed -e 's,BINDIR,$(BINDIR),g' systemd/$$file > .install.tmp && \
+ echo $(INSTALL) -D -m 644 systemd/$$file $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \
+ $(INSTALL) -D -m 644 .install.tmp $(DESTDIR)$(SYSTEMD_DIR)/$$file ; \
+ rm -f .install.tmp; \
+ done
+ @for file in mdadm.shutdown ; \
+ do sed -e 's,BINDIR,$(BINDIR),g' systemd/$$file > .install.tmp && \
+ echo $(INSTALL) -D -m 755 systemd/$$file $(DESTDIR)$(SYSTEMD_DIR)-shutdown/$$file ; \
+ $(INSTALL) -D -m 755 .install.tmp $(DESTDIR)$(SYSTEMD_DIR)-shutdown/$$file ; \
+ rm -f .install.tmp; \
+ done
if [ -f /etc/SuSE-release -o -n "$(SUSE)" ] ;then $(INSTALL) -D -m 755 systemd/SUSE-mdadm_env.sh $(DESTDIR)$(SYSTEMD_DIR)/../scripts/mdadm_env.sh ;fi
uninstall:
diff --git a/policy.c b/policy.c
index 104695d3..ef83621a 100644
--- a/policy.c
+++ b/policy.c
@@ -799,12 +799,12 @@ char *find_rule(struct rule *rule, char *rule_type)
#define UDEV_RULE_FORMAT \
"ACTION==\"add\", SUBSYSTEM==\"block\", " \
"ENV{DEVTYPE}==\"%s\", ENV{ID_PATH}==\"%s\", " \
-"RUN+=\"/sbin/mdadm --incremental $env{DEVNAME}\"\n"
+"RUN+=\"" BINDIR "/mdadm --incremental $env{DEVNAME}\"\n"
#define UDEV_RULE_FORMAT_NOTYPE \
"ACTION==\"add\", SUBSYSTEM==\"block\", " \
"ENV{ID_PATH}==\"%s\", " \
-"RUN+=\"/sbin/mdadm --incremental $env{DEVNAME}\"\n"
+"RUN+=\"" BINDIR "/mdadm --incremental $env{DEVNAME}\"\n"
/* Write rule in the rule file. Use format from UDEV_RULE_FORMAT */
int write_rule(struct rule *rule, int fd, int force_part)
diff --git a/systemd/mdadm-grow-continue@.service b/systemd/mdadm-grow-continue@.service
index 314a4fa0..5c667d2a 100644
--- a/systemd/mdadm-grow-continue@.service
+++ b/systemd/mdadm-grow-continue@.service
@@ -10,7 +10,7 @@ Description=Manage MD Reshape on /dev/%I
DefaultDependencies=no
[Service]
-ExecStart=/sbin/mdadm --grow --continue /dev/%I
+ExecStart=BINDIR/mdadm --grow --continue /dev/%I
StandardInput=null
StandardOutput=null
StandardError=null
diff --git a/systemd/mdadm-last-resort@.service b/systemd/mdadm-last-resort@.service
index 45d3c2a1..5179f194 100644
--- a/systemd/mdadm-last-resort@.service
+++ b/systemd/mdadm-last-resort@.service
@@ -4,4 +4,4 @@ DefaultDependencies=no
[Service]
Type=oneshot
-ExecStart=/sbin/mdadm --run /dev/%i
+ExecStart=BINDIR/mdadm --run /dev/%i
diff --git a/systemd/mdadm.shutdown b/systemd/mdadm.shutdown
index 1bbbb6f8..33f27783 100644
--- a/systemd/mdadm.shutdown
+++ b/systemd/mdadm.shutdown
@@ -1,4 +1,4 @@
#!/bin/sh
# We need to ensure all md arrays with external metadata
# (e.g. IMSM, DDF) are clean before completing the shutdown.
-/sbin/mdadm --wait-clean --scan
+BINDIR/mdadm --wait-clean --scan
diff --git a/systemd/mdmon@.service b/systemd/mdmon@.service
index af0a2a33..85a3a7c5 100644
--- a/systemd/mdmon@.service
+++ b/systemd/mdmon@.service
@@ -19,7 +19,7 @@ Environment=IMSM_NO_PLATFORM=1
# 'takeover'. As the '--offroot --takeover' don't hurt when
# not necessary, are are useful with root-on-md in dracut,
# have them always present.
-ExecStart=/sbin/mdmon --offroot --takeover %I
+ExecStart=BINDIR/mdmon --offroot --takeover %I
Type=forking
# Don't set the PIDFile. It isn't necessary (systemd can work
# it out) and systemd will remove it when transitioning from
diff --git a/systemd/mdmonitor.service b/systemd/mdmonitor.service
index 11aaeff2..c7cff3e4 100644
--- a/systemd/mdmonitor.service
+++ b/systemd/mdmonitor.service
@@ -13,4 +13,4 @@ DefaultDependencies=no
Environment= MDADM_MONITOR_ARGS=--scan
EnvironmentFile=-/run/sysconfig/mdadm
ExecStartPre=-/usr/lib/systemd/scripts/mdadm_env.sh
-ExecStart=/sbin/mdadm --monitor $MDADM_MONITOR_ARGS
+ExecStart=BINDIR/mdadm --monitor $MDADM_MONITOR_ARGS
diff --git a/udev-md-raid-arrays.rules b/udev-md-raid-arrays.rules
index 92aec36e..c95ec7b1 100644
--- a/udev-md-raid-arrays.rules
+++ b/udev-md-raid-arrays.rules
@@ -17,7 +17,7 @@ TEST!="md/array_state", ENV{SYSTEMD_READY}="0", GOTO="md_end"
ATTR{md/array_state}=="|clear|inactive", ENV{SYSTEMD_READY}="0", GOTO="md_end"
LABEL="md_ignore_state"
-IMPORT{program}="/sbin/mdadm --detail --export $devnode"
+IMPORT{program}="BINDIR/mdadm --detail --export $devnode"
ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace"
ENV{DEVTYPE}=="disk", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}"
ENV{DEVTYPE}=="disk", ENV{MD_DEVNAME}=="?*", SYMLINK+="md/$env{MD_DEVNAME}"
diff --git a/udev-md-raid-assembly.rules b/udev-md-raid-assembly.rules
index 824e7a9b..d0d440a6 100644
--- a/udev-md-raid-assembly.rules
+++ b/udev-md-raid-assembly.rules
@@ -27,9 +27,9 @@ LABEL="md_inc"
# remember you can limit what gets auto/incrementally assembled by
# mdadm.conf(5)'s 'AUTO' and selectively whitelist using 'ARRAY'
-ACTION=="add|change", IMPORT{program}="/sbin/mdadm --incremental --export $devnode --offroot ${DEVLINKS}"
+ACTION=="add|change", IMPORT{program}="BINDIR/mdadm --incremental --export $devnode --offroot ${DEVLINKS}"
ACTION=="add|change", ENV{MD_STARTED}=="*unsafe*", ENV{MD_FOREIGN}=="no", ENV{SYSTEMD_WANTS}+="mdadm-last-resort@$env{MD_DEVICE}.timer"
-ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}"
-ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If $name"
+ACTION=="remove", ENV{ID_PATH}=="?*", RUN+="BINDIR/mdadm -If $name --path $env{ID_PATH}"
+ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="BINDIR/mdadm -If $name"
LABEL="md_inc_end"
diff --git a/util.c b/util.c
index afb2bb11..7937eb6e 100644
--- a/util.c
+++ b/util.c
@@ -1688,7 +1688,7 @@ int start_mdmon(char *devnm)
char pathbuf[1024];
char *paths[4] = {
pathbuf,
- "/sbin/mdmon",
+ BINDIR "/mdmon",
"./mdmon",
NULL
};