diff mbox

[02/13] libnsdb: nsdb_update_nsdb() doesn't create /var/lib/fedfs/nsdbcerts

Message ID 20130108172723.65133.57698.stgit@seurat.1015granger.net
State Accepted
Headers show

Commit Message

Chuck Lever Jan. 8, 2013, 5:27 p.m. UTC
"nsdbparams update -f foo -t 1 nsdb.example.net" fails if the
nsdbcerts directory does not already exist.  Create it
automatically.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 src/libnsdb/nsdb.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/src/libnsdb/nsdb.c b/src/libnsdb/nsdb.c
index 3f10c4d..7ef39d3 100644
--- a/src/libnsdb/nsdb.c
+++ b/src/libnsdb/nsdb.c
@@ -563,6 +563,13 @@  nsdb_new_certfile(const char *certdata, const unsigned int certlen,
 		goto out;
 	}
 
+	if (mkdir(fedfs_nsdbcerts_dirname, FEDFS_BASE_DIRMODE) == -1) {
+		if (errno != EEXIST) {
+			xlog(L_ERROR, "Failed to create certfile directory: %m");
+			return FEDFS_ERR_SVRFAULT;
+		}
+	}
+
 	fd = open(pathbuf, O_WRONLY | O_SYNC | O_CREAT | O_EXCL,
 						S_IRUSR | S_IWUSR | S_IRGRP);
 	if (fd == -1) {