From 1d60388f5dc5a2e29fb821301b4f2ad831710115 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Fri, 27 Sep 2024 16:09:23 +0900 Subject: [PATCH] Impl. setting stored UID/GID if EUID 0 --- src/archiver.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/archiver.c b/src/archiver.c index a5ffc23..c9076bd 100644 --- a/src/archiver.c +++ b/src/archiver.c @@ -2318,6 +2318,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 {