summaryrefslogtreecommitdiffstats
path: root/src/fsck
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2023-04-13 22:54:54 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2023-04-15 11:29:50 +0200
commita108fcbacee859036f5613177321889bc34fd597 (patch)
treebbcd4cbddd97b9be226e4dc42c49ca0ba8422cd0 /src/fsck
parentMerge pull request #27273 from mrc0mmand/test-generators (diff)
downloadsystemd-a108fcbacee859036f5613177321889bc34fd597.tar.xz
systemd-a108fcbacee859036f5613177321889bc34fd597.zip
fsck: look for fsck binary not just in /sbin
This removes remaining hardcoded occurences of `/sbin/fsck`, and instead uses `find_executable` to find `fsck`. We also use `fsck_exists_for_fstype` to check for the `fsck.*` executable, which also checks in `$PATH`, so it's fair to assume fsck itself is also available.
Diffstat (limited to 'src/fsck')
-rw-r--r--src/fsck/fsck.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
index cfdc6b24bf..4d29babbd3 100644
--- a/src/fsck/fsck.c
+++ b/src/fsck/fsck.c
@@ -345,6 +345,7 @@ static int run(int argc, char *argv[]) {
if (r == 0) {
char dash_c[STRLEN("-C") + DECIMAL_STR_MAX(int) + 1];
int progress_socket = -1;
+ _cleanup_free_ char *fsck_path = NULL;
const char *cmdline[9];
int i = 0;
@@ -365,7 +366,13 @@ static int run(int argc, char *argv[]) {
} else
dash_c[0] = 0;
- cmdline[i++] = "/sbin/fsck";
+ r = find_executable("fsck", &fsck_path);
+ if (r < 0) {
+ log_error_errno(r, "Cannot find fsck binary: %m");
+ _exit(FSCK_OPERATIONAL_ERROR);
+ }
+
+ cmdline[i++] = fsck_path;
cmdline[i++] = arg_repair;
cmdline[i++] = "-T";