Skip to content
Snippets Groups Projects
Commit c831eb43 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

More consistent logging of errno value (and descriptions)

Should use safe_strerror() here instead... later.
parent 04efb20c
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4489 passed
...@@ -359,8 +359,7 @@ static BOOL do_seteuid(BOOL to_new) ...@@ -359,8 +359,7 @@ static BOOL do_seteuid(BOOL to_new)
pthread_mutex_unlock(&setid_mutex); pthread_mutex_unlock(&setid_mutex);
if(!result) { if(!result) {
lputs(LOG_ERR,"!seteuid FAILED"); lprintf(LOG_ERR,"!seteuid FAILED with error %d (%s)", errno, strerror(errno));
lputs(LOG_ERR,strerror(errno));
} }
return result; return result;
} }
...@@ -393,31 +392,26 @@ BOOL do_setuid(BOOL force) ...@@ -393,31 +392,26 @@ BOOL do_setuid(BOOL force)
if(getegid()!=old_gid) { if(getegid()!=old_gid) {
if(setregid(-1,old_gid) != 0) if(setregid(-1,old_gid) != 0)
lputs(LOG_ERR, "!setregid FAILED"); lprintf(LOG_ERR, "!setregid FAILED with error %d (%s)", errno, strerror(errno));
} }
if(geteuid()!=old_gid) { if(geteuid()!=old_gid) {
if(setreuid(-1,old_uid) != 0) if(setreuid(-1,old_uid) != 0)
lputs(LOG_ERR, "!setreuid FAILED"); lprintf(LOG_ERR, "!setreuid FAILED with error %d (%s)", errno, strerror(errno));
} }
if(getgid() != new_gid || getegid() != new_gid) { if(getgid() != new_gid || getegid() != new_gid) {
if(setregid(new_gid,new_gid)) if(setregid(new_gid,new_gid)) {
{ lprintf(LOG_ERR,"!setgid FAILED with error %d (%s)", errno, strerror(errno));
lputs(LOG_ERR,"!setgid FAILED");
lputs(LOG_ERR,strerror(errno));
result=FALSE; result=FALSE;
} }
} }
if(getuid() != new_uid || geteuid() != new_uid) { if(getuid() != new_uid || geteuid() != new_uid) {
if(initgroups(new_uid_name, new_gid)) { if(initgroups(new_uid_name, new_gid)) {
lputs(LOG_ERR,"!initgroups FAILED"); lprintf(LOG_ERR,"!initgroups FAILED with error %d (%s)", errno, strerror(errno));
lputs(LOG_ERR,strerror(errno));
result=FALSE; result=FALSE;
} }
if(setreuid(new_uid,new_uid)) if(setreuid(new_uid,new_uid)) {
{ lprintf(LOG_ERR,"!setuid FAILED with error %d (%s)", errno, strerror(errno));
lputs(LOG_ERR,"!setuid FAILED");
lputs(LOG_ERR,strerror(errno));
result=FALSE; result=FALSE;
} }
} }
...@@ -492,8 +486,7 @@ static int linux_keepcaps(void) ...@@ -492,8 +486,7 @@ static int linux_keepcaps(void)
*/ */
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0) { if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0) {
if (errno != EINVAL) { if (errno != EINVAL) {
lputs(LOG_ERR,"linux_keepcaps FAILED"); lprintf(LOG_ERR,"linux_keepcaps FAILED with error %d (%s)", errno, strerror(errno));
lputs(LOG_ERR,strerror(errno));
} }
return(-1); return(-1);
} }
...@@ -1774,8 +1767,7 @@ int main(int argc, char** argv) ...@@ -1774,8 +1767,7 @@ int main(int argc, char** argv)
whoami(); whoami();
if(list_caps() && linux_initialprivs()) { if(list_caps() && linux_initialprivs()) {
if(linux_keepcaps() < 0) { if(linux_keepcaps() < 0) {
lputs(LOG_ERR,"linux_keepcaps() FAILED"); lprintf(LOG_ERR,"linux_keepcaps() FAILED with error %d (%s)", errno, strerror(errno));
lputs(LOG_ERR,strerror(errno));
} }
else { else {
if(!change_user()) { if(!change_user()) {
...@@ -1783,8 +1775,7 @@ int main(int argc, char** argv) ...@@ -1783,8 +1775,7 @@ int main(int argc, char** argv)
} }
else { else {
if(!linux_minprivs()) { if(!linux_minprivs()) {
lputs(LOG_ERR,"linux_minprivs() FAILED"); lprintf(LOG_ERR,"linux_minprivs() FAILED with error %d (%s)", errno, strerror(errno));
lputs(LOG_ERR,strerror(errno));
} }
else { else {
capabilities_set=TRUE; capabilities_set=TRUE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment