aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2025-11-01 19:08:03 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2025-11-01 19:08:03 +0100
commitc875326bfb48f7bba297eeb983dab04823ed0070 (patch)
treeef6b7d6ae47a3d05ffd65769e4c7ffbcd9e8deb5 /FICS
parent389a20be460e24340b1cf5a6e170e138915d71c2 (diff)
Usage of strerror()
Diffstat (limited to 'FICS')
-rw-r--r--FICS/prep_dir_for_privdrop.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/FICS/prep_dir_for_privdrop.cpp b/FICS/prep_dir_for_privdrop.cpp
index 7d65973..85d3dfb 100644
--- a/FICS/prep_dir_for_privdrop.cpp
+++ b/FICS/prep_dir_for_privdrop.cpp
@@ -122,12 +122,18 @@ prep_dir_for_privdrop(const char *path)
constexpr mode_t file_mode = (S_IRUSR|S_IWUSR|S_IRGRP|
S_IROTH);
- if (get_uid_and_gid(uid, gid) == -1)
+ 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");
+ } else if (chown(path, uid, gid) != 0) {
+ std::string str("chown() error: ");
+ str.append(strerror(errno));
+ throw std::runtime_error(str);
+ } else if (chmod(path, dir_mode) != 0) {
+ std::string str("chmod() error: ");
+ str.append(strerror(errno));
+ throw std::runtime_error(str);
+ }
+
for (auto const &dir_ent : dir_it) {
const std::string str(dir_ent.path().string());