Hi!
There seems to be a bug in the install applet. Possibly long standing.
If you install a file with -s (strip symbols) and -p (preserve date/time
etc.), it does first copy the file (preserving the date and time
correctly) and afterwards strip is called, just as the last step. But
stripping always changes the date and time of the file to the current
date and time, and not only the time gets tampered, strip clears suid or
sgid bits which may have been set with -m.
The date and time can be preserved by using "strip -s", but some
reordering of the existing code is required to preserve the suid/sgid bits.
Patch to fix the bug in install appended, but I don't know if strip or
my code reordering may produce any conflict with setting the security
context (I don't use SELinux). So could anybody with SELinux be so
kindly to check this, please?
Harald
diff -bdur busybox-20100221/coreutils/install.c
busybox-20100221-hb/coreutils/install.c
--- busybox-20100221/coreutils/install.c 2010-02-19 09:16:33.000000000
+0100
+++ busybox-20100221-hb/coreutils/install.c 2010-02-21 11:22:02.000000000
+0100
@@ -149,6 +149,7 @@
while ((arg = *argv++) != NULL) {
char *dest = last;
+
if (opts & OPT_DIRECTORY) {
dest = arg;
/* GNU coreutils 6.9 does not set uid:gid
@@ -175,16 +176,20 @@
}
}
- /* Set the file mode (always, not only with -m).
- * GNU coreutils 6.10 is not affected by umask. */
- if (chmod(dest, mode) == -1) {
- bb_perror_msg("can't change %s of %s", "permissions",
dest);
+ if (opts & OPT_STRIP) {
+ char *args[4];
+ char **p;
+ *(p=args) = (char*)"strip";
+ if (opts & OPT_PRESERVE_TIME)
+ *(++p) = (char*)"-p";
+ *(++p) = dest;
+ *(++p) = NULL;
+ if (spawn_and_wait(args)) {
+ bb_perror_msg("strip");
ret = EXIT_FAILURE;
}
-#if ENABLE_SELINUX
- 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
@@ -192,16 +197,19 @@
bb_perror_msg("can't change %s of %s", "ownership",
dest);
ret = EXIT_FAILURE;
}
- if (opts & OPT_STRIP) {
- char *args[3];
- args[0] = (char*)"strip";
- args[1] = dest;
- args[2] = NULL;
- if (spawn_and_wait(args)) {
- bb_perror_msg("strip");
+
+ /* Set the file mode (always, not only with -m).
+ * GNU coreutils 6.10 is not affected by umask. */
+ if (chmod(dest, mode) == -1) {
+ bb_perror_msg("can't change %s of %s", "permissions",
dest);
ret = EXIT_FAILURE;
}
- }
+
+#if ENABLE_SELINUX
+ if (use_default_selinux_context)
+ setdefaultfilecon(dest);
+#endif
+
next:
if (ENABLE_FEATURE_CLEAN_UP && isdir)
free(dest);
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox