Merge pull request #462 from thockin/master
Avoid writing to /etc/passwd unless needed
This commit is contained in:
commit
eb822be2e5
|
|
@ -29,6 +29,7 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"os/signal"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -772,6 +773,10 @@ func handleError(log *logging.Logger, printUsage bool, format string, a ...inter
|
|||
// Put the current UID/GID into /etc/passwd so SSH can look it up. This
|
||||
// assumes that we have the permissions to write to it.
|
||||
func addUser() error {
|
||||
// Skip if the UID already exists. The Dockerfile already adds the default UID/GID.
|
||||
if _, err := user.LookupId(strconv.Itoa(os.Getuid())); err == nil {
|
||||
return nil
|
||||
}
|
||||
home := os.Getenv("HOME")
|
||||
if home == "" {
|
||||
cwd, err := os.Getwd()
|
||||
|
|
|
|||
Loading…
Reference in New Issue