From: Stephen Seo Date: Tue, 24 Dec 2024 01:47:14 +0000 (+0900) Subject: Minor tweaks, set uid/gid if euid is 0 X-Git-Tag: 1.10^2~15 X-Git-Url: https://git.seodisparate.com/stephenseo/annotated.html?a=commitdiff_plain;h=954deeac8ded973f38636e117860ea591396eba1;p=SimpleArchiver Minor tweaks, set uid/gid if euid is 0 --- diff --git a/src/archiver.c b/src/archiver.c index 7964f80..4534ca6 100644 --- a/src/archiver.c +++ b/src/archiver.c @@ -5224,7 +5224,8 @@ int simple_archiver_parse_archive_version_1(FILE *in_f, int_fast8_t do_extract, errno); } } - if (state->parsed->flags & 0x400 || state->parsed->flags & 0x800) { + if (geteuid() == 0 + && (state->parsed->flags & 0x400 || state->parsed->flags & 0x800)) { ret = fchownat( AT_FDCWD, link_name, @@ -5233,7 +5234,7 @@ int simple_archiver_parse_archive_version_1(FILE *in_f, int_fast8_t do_extract, AT_SYMLINK_NOFOLLOW); if (ret == -1) { fprintf(stderr, - "WARNING: Failed to force set UID/GID of symlink \"%s\"" + " WARNING: Failed to force set UID/GID of symlink \"%s\"" "(errno %d)!\n", link_name, errno); @@ -5576,7 +5577,7 @@ int simple_archiver_parse_archive_version_1(FILE *in_f, int_fast8_t do_extract, 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", + " ERROR Failed to set UID/GID of file \"%s\"!\n", file_info->filename); return SDAS_INTERNAL_ERROR; } @@ -5717,7 +5718,7 @@ int simple_archiver_parse_archive_version_1(FILE *in_f, int_fast8_t do_extract, 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", + " ERROR Failed to set UID/GID of file \"%s\"!\n", file_info->filename); return SDAS_INTERNAL_ERROR; }