[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] install: Fix chown resetting suid/sgid bits from chmod
From: Denys Vlasenko <vda.linux () googlemail ! com>
Date: 2023-10-02 12:27:18
Message-ID: CAK1hOcMALEBioPs56wsQB_YcU7x3e+iigxGo0W_dak9-NqnvNg () mail ! gmail ! com
[Download RAW message or body]
Applied, thank you.
On Sat, Sep 23, 2023 at 1:57 PM Nero <nero@w1r3.net> wrote:
>
> Since Linux 2.2.13, chown(2) resets the suid/gid bits for all users.
> This patch changes the ordering so that chmod gets called after chown.
>
> This behavior follows GNU coreutils.
>
> Signed-off-by: Nero <nero@w1r3.net>
> ---
> coreutils/install.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/coreutils/install.c b/coreutils/install.c
> index c0f1c538a..a81a5a1ef 100644
> --- a/coreutils/install.c
> +++ b/coreutils/install.c
> @@ -244,6 +244,14 @@ int install_main(int argc, char **argv)
> }
> }
>
> + /* Set the user and group id */
> + if ((opts & (OPT_OWNER|OPT_GROUP))
> + && lchown(dest, uid, gid) == -1
> + ) {
> + bb_perror_msg("can't change %s of %s", "ownership", dest);
> + ret = EXIT_FAILURE;
> + }
> +
> /* Set the file mode (always, not only with -m).
> * GNU coreutils 6.10 is not affected by umask. */
> if (chmod(dest, mode) == -1) {
> @@ -254,13 +262,6 @@ int install_main(int argc, char **argv)
> if (use_default_selinux_context)
> setdefaultfilecon(dest);
> #endif
> - /* Set the user and group id */
> - if ((opts & (OPT_OWNER|OPT_GROUP))
> - && lchown(dest, uid, gid) == -1
> - ) {
> - bb_perror_msg("can't change %s of %s", "ownership", dest);
> - ret = EXIT_FAILURE;
> - }
> next:
> if (ENABLE_FEATURE_CLEAN_UP && isdir)
> free(dest);
> --
> 2.42.0
>
>
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic