Avoid writing to /etc/passwd unless needed
Port #461 by mac-chaffee to v4 branch.
This commit is contained in:
parent
65a5bc7f90
commit
c6c19dc61a
|
|
@ -29,6 +29,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"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
|
// 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.
|
// assumes that we have the permissions to write to it.
|
||||||
func addUser() error {
|
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")
|
home := os.Getenv("HOME")
|
||||||
if home == "" {
|
if home == "" {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue