Browse code

dockerd: call StickRuntimeDirContents only in rootless mode

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>

Akihiro Suda authored on 2019/02/14 12:48:41
Showing 1 changed files
... ...
@@ -143,10 +143,12 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
143 143
 		}()
144 144
 	}
145 145
 
146
-	// Set sticky bit if XDG_RUNTIME_DIR is set && the file is actually under XDG_RUNTIME_DIR
147
-	if _, err := homedir.StickRuntimeDirContents(potentiallyUnderRuntimeDir); err != nil {
148
-		// StickRuntimeDirContents returns nil error if XDG_RUNTIME_DIR is just unset
149
-		logrus.WithError(err).Warn("cannot set sticky bit on files under XDG_RUNTIME_DIR")
146
+	if cli.Config.IsRootless() {
147
+		// Set sticky bit if XDG_RUNTIME_DIR is set && the file is actually under XDG_RUNTIME_DIR
148
+		if _, err := homedir.StickRuntimeDirContents(potentiallyUnderRuntimeDir); err != nil {
149
+			// StickRuntimeDirContents returns nil error if XDG_RUNTIME_DIR is just unset
150
+			logrus.WithError(err).Warn("cannot set sticky bit on files under XDG_RUNTIME_DIR")
151
+		}
150 152
 	}
151 153
 
152 154
 	serverConfig, err := newAPIServerConfig(cli)