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)
12 + /* Set the user and group id */
13 + if ((opts & (OPT_OWNER|OPT_GROUP))
14 + && lchown(dest, uid, gid) == -1
16 + bb_perror_msg("can't change %s of %s", "ownership", dest);
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);
27 - /* Set the user and group id */
28 - if ((opts & (OPT_OWNER|OPT_GROUP))
29 - && lchown(dest, uid, gid) == -1
31 - bb_perror_msg("can't change %s of %s", "ownership", dest);
35 if (ENABLE_FEATURE_CLEAN_UP && isdir)