2 * FreeBSD install - a package for the installation and maintainance
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.
19 * $FreeBSD: src/usr.sbin/pkg_install/add/futil.c,v 1.9.2.4 2002/08/20 06:35:07 obrien Exp $
20 * $DragonFly: src/usr.sbin/pkg_install/add/Attic/futil.c,v 1.2 2003/06/17 04:29:59 dillon Exp $
28 * Assuming dir is a desired directory name, make it and all intervening
29 * directories necessary.
33 make_hierarchy(char *dir)
42 if ((cp2 = strchr(cp1, '/')) !=NULL )
52 if (vsystem("mkdir %s", dir)) {
57 apply_perms(NULL, dir);
68 /* Using permission defaults, apply them as necessary */
70 apply_perms(const char *dir, const char *arg)
74 if (!dir || *arg == '/') /* absolute path? */
80 if (vsystem("cd %s && chmod -R %s %s", cd_to, Mode, arg))
81 warnx("couldn't change modes of '%s' to '%s'", arg, Mode);
83 if (vsystem("cd %s && chown -R %s:%s %s", cd_to, Owner, Group, arg))
84 warnx("couldn't change owner/group of '%s' to '%s:%s'",
89 if (vsystem("cd %s && chown -R %s %s", cd_to, Owner, arg))
90 warnx("couldn't change owner of '%s' to '%s'", arg, Owner);
93 if (vsystem("cd %s && chgrp -R %s %s", cd_to, Group, arg))
94 warnx("couldn't change group of '%s' to '%s'", arg, Group);