Skip to content

Commit

Permalink
dinitcheck: warn about non-absolute executable path
Browse files Browse the repository at this point in the history
dinit's behavior depends on PATH environment if a service contains
command with non-absolute executable path. dinitcheck may not even find
correct executables in this case.

Such services may lead to security problems, systemd has been searching
executables only in compilation-time specified paths. As similar
features do not exist in dinit and aren't very meaningful, we just warn
about dangerous usage.

References: https://www.man7.org/linux/man-pages/man5/systemd.service.5.html#COMMAND_LINES
Signed-off-by: Yao Zi <[email protected]>
  • Loading branch information
ziyao233 committed Sep 28, 2024
1 parent cca31c4 commit dd60064
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/dinitcheck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,10 @@ service_record *load_service(service_set_t &services, const std::string &name,

auto check_command = [&](const char *setting_name, const char *command) {
struct stat command_stat;
if (fstatat(dirfd, command, &command_stat, 0) == -1) {
if (command[0] != '/') {
report_service_description_err(name,
std::string("executable '") + command + "' is not an absolute path");
} else if (fstatat(dirfd, command, &command_stat, 0) == -1) {
report_service_description_err(name,
std::string("could not stat ") + setting_name + " executable '" + command
+ "': " + strerror(errno));
Expand Down

0 comments on commit dd60064

Please sign in to comment.