[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [meek/bug18371] fixup! Bug 18371: symlinks incompatible with Gatekeeper signing



commit 675eba207124e1bc183880909d3422c2f3c21f63
Author: Kathy Brade <brade@xxxxxxxxxxxxxxxxx>
Date:   Wed Mar 9 09:53:08 2016 -0500

    fixup! Bug 18371: symlinks incompatible with Gatekeeper signing
    
    Fix a problem where copying the profile from the template failed
    if TorBrowser-Data/Tor/PluggableTransports/ did not already exist
    (before calling ioutil.TempDir(), the parent directory must exist).
    
    Remove trailing semicolons and unneeded parens.
---
 meek-client-torbrowser/meek-client-torbrowser.go | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/meek-client-torbrowser/meek-client-torbrowser.go b/meek-client-torbrowser/meek-client-torbrowser.go
index 8a3809d..8647d5d 100644
--- a/meek-client-torbrowser/meek-client-torbrowser.go
+++ b/meek-client-torbrowser/meek-client-torbrowser.go
@@ -104,15 +104,22 @@ func ensureProfileExists(profilePath string) error {
 
 	// If profileTemplatePath is not set, we are running on a platform that
 	// expects the profile to already exist.
-	if (profileTemplatePath == "") {
-		return err;
+	if profileTemplatePath == "" {
+		return err
 	}
 
 	log.Printf("creating profile by copying files from %s to %s\n", profileTemplatePath, profilePath)
-	tmpPath, err := ioutil.TempDir(filepath.Dir(profilePath), "tmpMeekProfile")
+	profileParentPath := filepath.Dir(profilePath)
+	err = os.MkdirAll(profileParentPath, os.ModePerm)
+	if err != nil {
+		return err
+	}
+
+	tmpPath, err := ioutil.TempDir(profileParentPath, "tmpMeekProfile")
 	if err != nil {
 		return err
 	}
+
 	err = os.MkdirAll(tmpPath, os.ModePerm)
 	if err != nil {
 		return err
@@ -120,7 +127,7 @@ func ensureProfileExists(profilePath string) error {
 
 	// Remove the temporary directory before returning.
 	defer func() {
-		os.RemoveAll(tmpPath);
+		os.RemoveAll(tmpPath)
 	}()
 
 	templatePath, err := filepath.Abs(profileTemplatePath)
@@ -130,13 +137,13 @@ func ensureProfileExists(profilePath string) error {
 
 	visit := func(path string, info os.FileInfo, err error) error {
 		relativePath := strings.TrimPrefix(path, templatePath)
-		if (relativePath == "") {
+		if relativePath == "" {
 			return nil	// skip the root directory
 		}
 
 		// If relativePath is a directory, create it; if it is a file, copy it.
-		destPath := filepath.Join(tmpPath, relativePath);
-		if (info.IsDir()) {
+		destPath := filepath.Join(tmpPath, relativePath)
+		if info.IsDir() {
 			err = os.MkdirAll(destPath, info.Mode())
 		} else {
 			err = copyFile(path, info.Mode(), destPath)
@@ -150,7 +157,7 @@ func ensureProfileExists(profilePath string) error {
 		return err
 	}
 
-	return os.Rename(tmpPath, profilePath);
+	return os.Rename(tmpPath, profilePath)
 }
 
 

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits