[Pkg-privacy-commits] [obfs4proxy] 31/151: Use os.MkdirAll() for creating the pt state directory.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:59:36 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository obfs4proxy.

commit 50cc180084f086ccd2a81034a06c51c0fab36ba2
Author: Yawning Angel <yawning at schwanenlied.me>
Date:   Thu May 15 06:12:31 2014 +0000

    Use os.MkdirAll() for creating the pt state directory.
---
 obfs4proxy/obfs4proxy.go | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/obfs4proxy/obfs4proxy.go b/obfs4proxy/obfs4proxy.go
index 016a0bb..ff53863 100644
--- a/obfs4proxy/obfs4proxy.go
+++ b/obfs4proxy/obfs4proxy.go
@@ -297,31 +297,23 @@ func ptIsServer() bool {
 	return env != ""
 }
 
-func ptGetStateDir() string {
-	dir := os.Getenv("TOR_PT_STATE_LOCATION")
+func ptGetStateDir() (dir string, err error) {
+	dir = os.Getenv("TOR_PT_STATE_LOCATION")
 	if dir == "" {
-		return dir
+		return
 	}
 
-	stat, err := os.Stat(dir)
+	err = os.MkdirAll(dir, 0755)
 	if err != nil {
-		if !os.IsNotExist(err) {
-			log.Fatalf("[ERROR] Failed to stat path: %s", err)
-		}
-		err = os.Mkdir(dir, 0755)
-		if err != nil {
-			log.Fatalf("[ERROR] Failed to create path: %s", err)
-		}
-	} else if !stat.IsDir() {
-		log.Fatalf("[ERROR] Pluggable Transport state location is not a directory")
+		log.Fatalf("[ERROR] Failed to create path: %s", err)
 	}
 
-	return dir
+	return
 }
 
 func ptInitializeLogging() {
-	dir := ptGetStateDir()
-	if dir == "" {
+	dir, err := ptGetStateDir()
+	if err != nil || dir == "" {
 		return
 	}
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/obfs4proxy.git



More information about the Pkg-privacy-commits mailing list