From 389a20be460e24340b1cf5a6e170e138915d71c2 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sat, 1 Nov 2025 16:24:18 +0100 Subject: prep_dir_for_privdrop: chown() and chmod() 'path' --- FICS/prep_dir_for_privdrop.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'FICS') diff --git a/FICS/prep_dir_for_privdrop.cpp b/FICS/prep_dir_for_privdrop.cpp index 4b1d66b..7d65973 100644 --- a/FICS/prep_dir_for_privdrop.cpp +++ b/FICS/prep_dir_for_privdrop.cpp @@ -124,6 +124,10 @@ prep_dir_for_privdrop(const char *path) if (get_uid_and_gid(uid, gid) == -1) throw std::runtime_error("failed to get uid/gid"); + else if (chown(path, uid, gid) != 0) + throw std::runtime_error("chown() error"); + else if (chmod(path, dir_mode) != 0) + throw std::runtime_error("chmod() error"); for (auto const &dir_ent : dir_it) { const std::string str(dir_ent.path().string()); -- cgit v1.2.3