test: recognize /path/to/[ case too
[oweals/busybox.git] / coreutils / install.c
index 1f65407b12b809e80b49d89654a83c5ae1b7f99b..7f168d2fd271be324d09b9acbecb26e0f5e6f22a 100644 (file)
@@ -9,11 +9,12 @@
  *           owner/group, will probably modify bb_make_directory(...)
  */
 
-#include "busybox.h"
-#include "libcoreutils/coreutils.h"
 #include <libgen.h>
 #include <getopt.h> /* struct option */
 
+#include "libbb.h"
+#include "libcoreutils/coreutils.h"
+
 #if ENABLE_FEATURE_INSTALL_LONG_OPTIONS
 static const struct option install_long_options[] = {
        { "directory",           0, NULL, 'd' },
@@ -35,13 +36,14 @@ static const struct option install_long_options[] = {
 #if ENABLE_SELINUX
 static bool use_default_selinux_context = 1;
 
-static void setdefaultfilecon(const char *path) {
+static void setdefaultfilecon(const char *path)
+{
        struct stat s;
        security_context_t scontext = NULL;
 
        if (!is_selinux_enabled()) {
                return;
-       }       
+       }
        if (lstat(path, &s) != 0) {
                return;
        }
@@ -101,7 +103,7 @@ int install_main(int argc, char **argv)
        /* -c exists for backwards compatibility, it's needed */
 
        flags = getopt32(argc, argv, "cdpsg:m:o:" USE_SELINUX("Z:"), &gid_str, &mode_str, &uid_str USE_SELINUX(, &scontext));
-       
+
 #if ENABLE_SELINUX
        if (flags & OPT_PRESERVE_SECURITY_CONTEXT) {
                use_default_selinux_context = 0;
@@ -110,9 +112,7 @@ int install_main(int argc, char **argv)
        }
        if (flags & OPT_SET_SECURITY_CONTEXT) {
                selinux_or_die();
-               if (setfscreatecon(scontext) < 0) {
-                       bb_error_msg_and_die("setfscreatecon(%s)", scontext); // perror?
-               }
+               setfscreatecon_or_die(scontext);
                use_default_selinux_context = 0;
                copy_flags |= FILEUTILS_SET_SECURITY_CONTEXT;
        }