diff --git a/usr.sbin/pkg_install/add/futil.c b/usr.sbin/pkg_install/add/futil.c index e68d817df6e6..075095fe5741 100644 --- a/usr.sbin/pkg_install/add/futil.c +++ b/usr.sbin/pkg_install/add/futil.c @@ -45,12 +45,18 @@ make_hierarchy(char *dir) if ((cp2 = index(cp1, '/')) !=NULL ) *cp2 = '\0'; if (fexists(dir)) { - if (!isdir(dir)) + if (!isdir(dir)) { + if (cp2) + *cp2 = '/'; return FAIL; + } } else { - if (vsystem("mkdir %s", dir)) + if (vsystem("mkdir %s", dir)) { + if (cp2) + *cp2 = '/'; return FAIL; + } apply_perms(NULL, dir); } /* Put it back */