Impl. setting stored UID/GID if EUID 0

This commit is contained in:
Stephen Seo 2024-09-27 16:09:23 +09:00
parent b273d91896
commit 3d58f466af

View file

@ -2463,6 +2463,13 @@ int simple_archiver_parse_archive_version_1(FILE *in_f, int_fast8_t do_extract,
SIMPLE_ARCHIVER_PLATFORM == SIMPLE_ARCHIVER_PLATFORM_LINUX
if (chmod(file_info->filename, permissions) == -1) {
return SDAS_INTERNAL_ERROR;
} else if (geteuid() == 0 &&
chown(file_info->filename, file_info->uid,
file_info->gid) != 0) {
fprintf(stderr,
"ERROR Failed to set UID/GID as EUID 0 of file \"%s\"!\n",
file_info->filename);
return SDAS_INTERNAL_ERROR;
}
#endif
} else {