install: fix "-D -t DIR1/DIR2/DIR3" creating only DIR1/DIR2, closes 11106
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 22 Jun 2018 16:59:10 +0000 (18:59 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 22 Jun 2018 16:59:10 +0000 (18:59 +0200)
function                                             old     new   delta
install_main                                         758     767      +9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
coreutils/install.c

index 2e4dc257f6e89717de0246d06e73453fe26b2d93..8270490bd47c00cc563408bcf9036d2066f63147 100644 (file)
@@ -214,7 +214,11 @@ int install_main(int argc, char **argv)
                        dest = last;
                        if (opts & OPT_MKDIR_LEADING) {
                                char *ddir = xstrdup(dest);
-                               bb_make_directory(dirname(ddir), 0755, mkdir_flags);
+                               /*
+                                * -D -t DIR1/DIR2/F3 FILE: create DIR1/DIR2/F3, copy FILE there
+                                * -D FILE DIR1/DIR2/F3: create DIR1/DIR2, copy FILE there as F3
+                                */
+                               bb_make_directory((opts & OPT_TARGET) ? ddir : dirname(ddir), 0755, mkdir_flags);
                                /* errors are not checked. copy_file
                                 * will fail if dir is not created.
                                 */