
Make sure the chroot directory is available before it is used.  Solves
BTS issue #424614.  Patch from Mads Chr. Olesen.

--- a/nstxd.c
+++ b/nstxd.c
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
+#include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <fcntl.h>
@@ -127,6 +128,13 @@
    if (dir) {
 	/* Open the log-socket now (with LOG_NDELAY) before chroot-ing */
 	openlog(argv[0], LOG_PERROR|LOG_PID|LOG_CONS|LOG_NDELAY, LOG_DAEMON);
+
+	/* Make sure the chroot dir exists */
+	if (mkdir(dir, 0755) < 0 && errno != EEXIST) {
+		syslog(LOG_ERR, "Can't create chroot dir %s: %m", dir);
+		exit(EXIT_FAILURE);
+	}
+
 	if (chroot(dir)) {
 		syslog(LOG_ERR, "Can't chroot to %s: %m", dir);
 		exit(EXIT_FAILURE); /* Too many possible causes */
