install-fix-chown.patch (1106B)
1 chown must precede chmod because on some systems, 2 chown clears the set[ug]id bits for non-superusers, 3 resulting in incorrect permissions. 4 diff --git a/coreutils/install.c b/coreutils/install.c 5 index 8270490..0256aeb 100644 6 --- a/coreutils/install.c 7 +++ b/coreutils/install.c 8 @@ -244,6 +244,14 @@ int install_main(int argc, char **argv) 9 } 10 } 11 12 + /* Set the user and group id */ 13 + if ((opts & (OPT_OWNER|OPT_GROUP)) 14 + && lchown(dest, uid, gid) == -1 15 + ) { 16 + bb_perror_msg("can't change %s of %s", "ownership", dest); 17 + ret = EXIT_FAILURE; 18 + } 19 + 20 /* Set the file mode (always, not only with -m). 21 * GNU coreutils 6.10 is not affected by umask. */ 22 if (chmod(dest, mode) == -1) { 23 @@ -254,13 +262,6 @@ int install_main(int argc, char **argv) 24 if (use_default_selinux_context) 25 setdefaultfilecon(dest); 26 #endif 27 - /* Set the user and group id */ 28 - if ((opts & (OPT_OWNER|OPT_GROUP)) 29 - && lchown(dest, uid, gid) == -1 30 - ) { 31 - bb_perror_msg("can't change %s of %s", "ownership", dest); 32 - ret = EXIT_FAILURE; 33 - } 34 next: 35 if (ENABLE_FEATURE_CLEAN_UP && isdir) 36 free(dest);