Skip to content

Commit

Permalink
Make apache run properly on Windows, fixes #1109 (#1111)
Browse files Browse the repository at this point in the history
* Add uid_0 and gid_0 to /etc/passwd to fix root usage on windows, fixes #1109
* Change to run windows as user 1000 instead of 0
  • Loading branch information
rfay committed Sep 20, 2018
1 parent 02111c5 commit 62d15da
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions containers/ddev-webserver/files/etc/group
@@ -1,5 +1,6 @@
root:x:0:
nginx:x:0:
gid_0:x:0:
gid_1:x:1:
gid_2:x:2:
gid_3:x:3:
Expand Down
1 change: 1 addition & 0 deletions containers/ddev-webserver/files/etc/passwd
@@ -1,5 +1,6 @@
root:x:0:0:root:/home:/bin/bash
nginx:x:0:0:root:/home:/bin/bash
uid_0:x:0:0:root:/home:/bin/bash
uid_1:x:1:1:gid_1:/home:/bin/bash
uid_2:x:2:2:gid_2:/home:/bin/bash
uid_3:x:3:3:gid_3:/home:/bin/bash
Expand Down
12 changes: 6 additions & 6 deletions pkg/ddevapp/ddevapp.go
Expand Up @@ -705,13 +705,13 @@ func (app *DdevApp) DockerEnv() {
UIDStr = curUser.Uid
GIDStr = curUser.Gid
// For windows the UIDStr/GIDStr are usually way outside linux range (ends at 60000)
// so we have to run as root. We may have a host UIDStr/GIDStr greater in other contexts,
// bail and run as root.
// so we have to run as arbitrary user 1000. We may have a host UIDStr/GIDStr greater in other contexts,
// 1000 seems not to cause file permissions issues at least on docker-for-windows.
if UIDInt, err = strconv.Atoi(curUser.Uid); err != nil {
UIDStr = "0"
UIDStr = "1000"
}
if GIDInt, err = strconv.Atoi(curUser.Gid); err != nil {
GIDStr = "0"
GIDStr = "1000"
}

// Warn about running as root if we're not on windows.
Expand All @@ -721,8 +721,8 @@ func (app *DdevApp) DockerEnv() {

// If the UIDStr or GIDStr is outside the range possible in container, use root
if UIDInt > 60000 || GIDInt > 60000 {
UIDStr = "0"
GIDStr = "0"
UIDStr = "1000"
GIDStr = "1000"
}

envVars := map[string]string{
Expand Down
2 changes: 1 addition & 1 deletion pkg/version/version.go
Expand Up @@ -23,7 +23,7 @@ var DockerComposeFileFormatVersion = "3.6"
var WebImg = "drud/ddev-webserver"

// WebTag defines the default web image tag for drud dev
var WebTag = "20180911_apache_supervisor" // Note that this can be overridden by make
var WebTag = "20180913_apache_broken_on_windows" // Note that this can be overridden by make

// DBImg defines the default db image used for applications.
var DBImg = "drud/ddev-dbserver"
Expand Down

0 comments on commit 62d15da

Please sign in to comment.