diff --git a/src/common/daemonize.c b/src/common/daemonize.c index e4603c41acdcb6a1f6ebcd5b9cb5a4d5cb55fcf9..53d25073ee3a4aaf6b712f1b366d0493a9c3af99 100644 --- a/src/common/daemonize.c +++ b/src/common/daemonize.c @@ -36,7 +36,6 @@ #include "src/common/fd.h" #include "src/common/log.h" #include "src/common/macros.h" -#include "src/common/safeopen.h" #include "src/common/xassert.h" /* closeall FDs >= a specified value */ @@ -158,7 +157,6 @@ create_pidfile(const char *pidfile) xassert(pidfile != NULL); xassert(pidfile[0] == '/'); - (void) mkdir_parent(pidfile, 0755); if (!(fp = fopen(pidfile, "w"))) { error("Unable to open pidfile `%s': %m", pidfile); return -1; diff --git a/src/common/log.c b/src/common/log.c index 2dee8d415ba9fd5d75779cc21ede747df505c3d4..3c66406fb673b35b2c3f718e9ffbb74bc3a4d454 100644 --- a/src/common/log.c +++ b/src/common/log.c @@ -183,7 +183,6 @@ _log_init(char *prog, log_options_t opt, log_facility_t fac, char *logfile ) if (logfile && (log->opt.logfile_level > LOG_LEVEL_QUIET)) { FILE *fp; - (void) mkdir_parent(logfile, 0700); fp = safeopen(logfile, "a", SAFEOPEN_LINK_OK); if (!fp) { diff --git a/src/common/safeopen.c b/src/common/safeopen.c index 613513eda705f6053347a77190eb419abeed02df..5221b66ce7ee6192366802e463653950e7c14b7a 100644 --- a/src/common/safeopen.c +++ b/src/common/safeopen.c @@ -58,36 +58,3 @@ FILE * safeopen(const char *path, const char *mode, int flags) } -int -mkdir_parent(const char *path_name, mode_t mode) -{ - char *dir_path, *tmp_ptr; - int i, rc = 0; - - xassert(path_name); - xassert(path_name[0] == '/'); - - /* copy filename and strip off final element */ - dir_path = xstrdup(path_name); - tmp_ptr = strrchr(dir_path, (int)'/'); - tmp_ptr[0] = (char) 0; - - /* now create the parent directories */ - for (i=1; ; i++) { - if (dir_path[i] == (char) 0) { - if (mkdir(dir_path, mode) && (errno != EEXIST)) - rc = -1; - break; - } - if (dir_path[i] == '/') { - dir_path[i] = (char) 0; - if (mkdir(dir_path, mode) && (errno != EEXIST)) - rc = -1; - dir_path[i] = '/'; - } - } - - xfree(dir_path); - return rc; -} - diff --git a/src/common/safeopen.h b/src/common/safeopen.h index 0f7fe1d5c02aea4bebce5d72f4ad920f8e4b294b..f5815218ed124612294810105d03200bfacd933b 100644 --- a/src/common/safeopen.h +++ b/src/common/safeopen.h @@ -24,14 +24,4 @@ */ FILE *safeopen(const char *path, const char *mode, int flags); -/* - * create parent directories as needed so that a specified - * file or directory can later be create - * path_name IN - path name of the file or directory to be later - * created, only its parents are created - * mode IN - permission mode to be used in creating directories - * RET - zero on success, -1 on failure with errno set - */ -extern int mkdir_parent(const char *path_name, mode_t mode); - #endif /* _SAFEOPEN_H */