ceph: use absolute binary paths instead of relative paths

While trying to mount CephFS using libceph and systemd, mount.ceph tries to call "modinfo", "modprobe", and "grep", but fails with the error "sh: line 1: modprobe: command not found". This is because ceph calls these binaries by running the command "sh -c -- <application> %s %s", which does not pass the PATH environment variable through. This isn't usually a problem, because ceph, by default, calls the paths of these binaries as they would be in debian, in /sbin and /bin, but a change was made to replace these with relative paths, thus breaking the mounting process entirely. Replacing these relative paths with absolute store paths alleviates this issue whilst preserving all functionality.
This commit is contained in:
Kartik Gokte 2023-12-11 19:09:26 +05:30
parent 33576fdfce
commit 68221c35ff

View file

@ -28,8 +28,10 @@
, doxygen
, gperf
, graphviz
, gnugrep
, gtest
, icu
, kmod
, libcap
, libcap_ng
, libnl
@ -294,10 +296,14 @@ in rec {
pythonPath = [ ceph-python-env "${placeholder "out"}/${ceph-python-env.sitePackages}" ];
# replace /sbin and /bin based paths with direct nix store paths
# increase the `command` buffer size since 2 nix store paths cannot fit within 128 characters
preConfigure =''
substituteInPlace src/common/module.c --replace "/sbin/modinfo" "modinfo"
substituteInPlace src/common/module.c --replace "/sbin/modprobe" "modprobe"
substituteInPlace src/common/module.c --replace "/bin/grep" "grep"
substituteInPlace src/common/module.c \
--replace "char command[128];" "char command[256];" \
--replace "/sbin/modinfo" "${kmod}/bin/modinfo" \
--replace "/sbin/modprobe" "${kmod}/bin/modprobe" \
--replace "/bin/grep" "${gnugrep}/bin/grep"
# install target needs to be in PYTHONPATH for "*.pth support" check to succeed
# set PYTHONPATH, so the build system doesn't silently skip installing ceph-volume and others