From 49e942b2bc9fdedba79cd266a076ce9c9d91fc13 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Tue, 10 Apr 2012 21:54:31 +0200 Subject: rename basic.la to shared.la and put selinux deps in shared-selinx.la Only 34 of 74 tools need libselinux linked, and libselinux is a pain with its unconditional library constructor. --- src/shared/util.c | 68 ------------------------------------------------------- 1 file changed, 68 deletions(-) (limited to 'src/shared/util.c') diff --git a/src/shared/util.c b/src/shared/util.c index 563853fad6..fef58d5f30 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -1591,74 +1591,6 @@ char *file_in_same_dir(const char *path, const char *filename) { return r; } -int safe_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid) { - struct stat st; - - if (label_mkdir(path, mode) >= 0) - if (chmod_and_chown(path, mode, uid, gid) < 0) - return -errno; - - if (lstat(path, &st) < 0) - return -errno; - - if ((st.st_mode & 0777) != mode || - st.st_uid != uid || - st.st_gid != gid || - !S_ISDIR(st.st_mode)) { - errno = EEXIST; - return -errno; - } - - return 0; -} - - -int mkdir_parents(const char *path, mode_t mode) { - const char *p, *e; - - assert(path); - - /* Creates every parent directory in the path except the last - * component. */ - - p = path + strspn(path, "/"); - for (;;) { - int r; - char *t; - - e = p + strcspn(p, "/"); - p = e + strspn(e, "/"); - - /* Is this the last component? If so, then we're - * done */ - if (*p == 0) - return 0; - - if (!(t = strndup(path, e - path))) - return -ENOMEM; - - r = label_mkdir(t, mode); - free(t); - - if (r < 0 && errno != EEXIST) - return -errno; - } -} - -int mkdir_p(const char *path, mode_t mode) { - int r; - - /* Like mkdir -p */ - - if ((r = mkdir_parents(path, mode)) < 0) - return r; - - if (label_mkdir(path, mode) < 0 && errno != EEXIST) - return -errno; - - return 0; -} - int rmdir_parents(const char *path, const char *stop) { size_t l; int r = 0; -- cgit v1.2.3-54-g00ecf