2 * FreeBSD install - a package for the installation and maintenance
3 * of non-core utilities.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
17 * Miscellaneous file access utilities.
21 #include <sys/cdefs.h>
22 __FBSDID("$FreeBSD$");
29 * Assuming dir is a desired directory name, make it and all intervening
30 * directories necessary.
34 make_hierarchy(char *dir, Boolean set_perm)
43 if ((cp2 = strchr(cp1, '/')) !=NULL )
53 if (mkdir(dir, 0777) < 0) {
59 apply_perms(NULL, dir);
70 /* Using permission defaults, apply them as necessary */
72 apply_perms(const char *dir, const char *arg)
76 if (!dir || *arg == '/') /* absolute path? */
82 if (vsystem("cd %s && /bin/chmod -R %s %s", cd_to, Mode, arg))
83 warnx("couldn't change modes of '%s' to '%s'", arg, Mode);
85 if (vsystem("cd %s && /usr/sbin/chown -R %s:%s %s", cd_to, Owner, Group, arg))
86 warnx("couldn't change owner/group of '%s' to '%s:%s'",
91 if (vsystem("cd %s && /usr/sbin/chown -R %s %s", cd_to, Owner, arg))
92 warnx("couldn't change owner of '%s' to '%s'", arg, Owner);
95 if (vsystem("cd %s && /usr/bin/chgrp -R %s %s", cd_to, Group, arg))
96 warnx("couldn't change group of '%s' to '%s'", arg, Group);