summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/cross_linux.cc7
-rw-r--r--src/lib/exceptions.h10
2 files changed, 14 insertions, 3 deletions
diff --git a/src/lib/cross_linux.cc b/src/lib/cross_linux.cc
index 28b8a4b41..e17f188b9 100644
--- a/src/lib/cross_linux.cc
+++ b/src/lib/cross_linux.cc
@@ -379,11 +379,9 @@ unprivileged ()
uid_t ruid, euid, suid;
if (getresuid(&ruid, &euid, &suid) == -1) {
cerr << "getresuid() failed.\n";
- exit (EXIT_FAILURE);
}
if (seteuid(ruid) == -1) {
cerr << "seteuid() failed.\n";
- exit (EXIT_FAILURE);
}
}
@@ -394,7 +392,10 @@ PrivilegeEscalator::~PrivilegeEscalator ()
PrivilegeEscalator::PrivilegeEscalator ()
{
- seteuid (0);
+ int const r = seteuid(0);
+ if (r < 0) {
+ throw PrivilegeError (String::compose("seteuid() call failed with %1", errno));
+ }
}
boost::filesystem::path
diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h
index 98534bb32..05cda9659 100644
--- a/src/lib/exceptions.h
+++ b/src/lib/exceptions.h
@@ -369,4 +369,14 @@ private:
std::string _message;
int _number;
};
+
+
+class PrivilegeError : public std::runtime_error
+{
+public:
+ explicit PrivilegeError (std::string s)
+ : std::runtime_error (s)
+ {}
+};
+
#endif