Skip to content
Snippets Groups Projects
Commit 3c63f88d authored by Moe Jette's avatar Moe Jette
Browse files

Remove remnants of mkdir_parent on log file and pid file create.

Just log open failure and continue.
parent 6fed5da4
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "src/common/fd.h" #include "src/common/fd.h"
#include "src/common/log.h" #include "src/common/log.h"
#include "src/common/macros.h" #include "src/common/macros.h"
#include "src/common/safeopen.h"
#include "src/common/xassert.h" #include "src/common/xassert.h"
/* closeall FDs >= a specified value */ /* closeall FDs >= a specified value */
...@@ -158,7 +157,6 @@ create_pidfile(const char *pidfile) ...@@ -158,7 +157,6 @@ create_pidfile(const char *pidfile)
xassert(pidfile != NULL); xassert(pidfile != NULL);
xassert(pidfile[0] == '/'); xassert(pidfile[0] == '/');
(void) mkdir_parent(pidfile, 0755);
if (!(fp = fopen(pidfile, "w"))) { if (!(fp = fopen(pidfile, "w"))) {
error("Unable to open pidfile `%s': %m", pidfile); error("Unable to open pidfile `%s': %m", pidfile);
return -1; return -1;
......
...@@ -183,7 +183,6 @@ _log_init(char *prog, log_options_t opt, log_facility_t fac, char *logfile ) ...@@ -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)) { if (logfile && (log->opt.logfile_level > LOG_LEVEL_QUIET)) {
FILE *fp; FILE *fp;
(void) mkdir_parent(logfile, 0700);
fp = safeopen(logfile, "a", SAFEOPEN_LINK_OK); fp = safeopen(logfile, "a", SAFEOPEN_LINK_OK);
if (!fp) { if (!fp) {
......
...@@ -58,36 +58,3 @@ FILE * safeopen(const char *path, const char *mode, int flags) ...@@ -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;
}
...@@ -24,14 +24,4 @@ ...@@ -24,14 +24,4 @@
*/ */
FILE *safeopen(const char *path, const char *mode, int flags); 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 */ #endif /* _SAFEOPEN_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment