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

Chuck Lever chuck.lever at oracle.com
Tue Jan 8 09:27:24 PST 2013


"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 at oracle.com>
---

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

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) {




More information about the fedfs-utils-devel mailing list