Browse code

Revert "resolve the config file from the sudo user"

This reverts commit afde6450ee7bd4a43765fdc0a9799b411276d9e4.

Signed-off-by: Antonio Murdaca <runcom@redhat.com>

Antonio Murdaca authored on 2016/02/29 21:40:45
Showing 4 changed files
... ...
@@ -29,20 +29,9 @@ var (
29 29
 	configDir = os.Getenv("DOCKER_CONFIG")
30 30
 )
31 31
 
32
-func getDefaultConfigDir(confFile string) string {
33
-	confDir := filepath.Join(homedir.Get(), confFile)
34
-	// if the directory doesn't exist, maybe we called docker with sudo
35
-	if _, err := os.Stat(confDir); err != nil {
36
-		if os.IsNotExist(err) {
37
-			return filepath.Join(homedir.GetWithSudoUser(), confFile)
38
-		}
39
-	}
40
-	return confDir
41
-}
42
-
43 32
 func init() {
44 33
 	if configDir == "" {
45
-		configDir = getDefaultConfigDir(".docker")
34
+		configDir = filepath.Join(homedir.Get(), ".docker")
46 35
 	}
47 36
 }
48 37
 
... ...
@@ -189,7 +178,7 @@ func Load(configDir string) (*ConfigFile, error) {
189 189
 	}
190 190
 
191 191
 	// Can't find latest config file so check for the old one
192
-	confFile := getDefaultConfigDir(oldConfigfile)
192
+	confFile := filepath.Join(homedir.Get(), oldConfigfile)
193 193
 	if _, err := os.Stat(confFile); err != nil {
194 194
 		return &configFile, nil //missing file is not an error
195 195
 	}
... ...
@@ -78,9 +78,6 @@ For example:
78 78
 Instructs Docker to use the configuration files in your `~/testconfigs/`
79 79
 directory when running the `ps` command.
80 80
 
81
-> **Note**: If you run docker commands with `sudo`, Docker first looks for a configuration
82
-> file in `/root/.docker/`, before looking in `~/.docker/` for the user that did the sudo call.
83
-
84 81
 Docker manages most of the files in the configuration directory
85 82
 and you should not modify them. However, you *can modify* the
86 83
 `config.json` file to control certain aspects of how the `docker`
... ...
@@ -142,7 +142,7 @@ func rawJSON(value interface{}) *json.RawMessage {
142 142
 // ValidateID checks whether an ID string is a valid image ID.
143 143
 func ValidateID(id string) error {
144 144
 	if ok := validHex.MatchString(id); !ok {
145
-		return fmt.Errorf("image ID %q is invalid", id)
145
+		return fmt.Errorf("image ID '%s' is invalid ", id)
146 146
 	}
147 147
 	return nil
148 148
 }
... ...
@@ -29,19 +29,6 @@ func Get() string {
29 29
 	return home
30 30
 }
31 31
 
32
-// GetWithSudoUser returns the home directory of the user who called sudo (if
33
-// available, retrieved from $SUDO_USER). It fallbacks to Get if any error occurs.
34
-// Returned path should be used with "path/filepath" to form new paths.
35
-func GetWithSudoUser() string {
36
-	sudoUser := os.Getenv("SUDO_USER")
37
-	if sudoUser != "" {
38
-		if user, err := user.LookupUser(sudoUser); err == nil {
39
-			return user.Home
40
-		}
41
-	}
42
-	return Get()
43
-}
44
-
45 32
 // GetShortcutString returns the string that is shortcut to user's home directory
46 33
 // in the native shell of the platform running on.
47 34
 func GetShortcutString() string {