diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-07-26 23:08:01 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-07-26 23:08:01 +0200 |
| commit | 16d50c8309bad5547bd07a3a6e78b404d490d93d (patch) | |
| tree | 31885fe771d5da21dddb7e1aa7e103787753ae3c /src/lib/cross_linux.cc | |
| parent | 69da43180e638518ed47424f2eba20cd25f2e093 (diff) | |
Better error handling with Linux privilege escalator.
Diffstat (limited to 'src/lib/cross_linux.cc')
| -rw-r--r-- | src/lib/cross_linux.cc | 7 |
1 files changed, 4 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 |
