[ovs-dev] [ovs-pki fixes 2/3] ovs-pki: Create log directory if it does not exist.

Ben Pfaff blp at nicira.com
Fri Aug 6 17:24:54 UTC 2010


Otherwise "ovs-pki init" can create the pkidir and then fail when it tries
to create the log file, if it is in a directory that does not exist.
---
 utilities/ovs-pki.in |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/utilities/ovs-pki.in b/utilities/ovs-pki.in
index b91d061..e0cfa2a 100755
--- a/utilities/ovs-pki.in
+++ b/utilities/ovs-pki.in
@@ -176,6 +176,15 @@ case $log in
     *) $log="$PWD/$log" ;;
 esac
 
+logdir=$(dirname "$log")
+if test ! -d "$logdir"; then
+    mkdir "$logdir" 2>/dev/null || true
+    if test ! -d "$logdir"; then
+        echo "$0: log directory $logdir does not exist and cannot be created" >&2
+        exit 1
+    fi
+fi
+
 if test "$command" = "init"; then
     if test -e "$pkidir" && test "$force" != "yes"; then
         echo "$0: $pkidir already exists and --force not specified" >&2
-- 
1.7.1





More information about the dev mailing list