Expand environment variables for external auth program

Use os.Environ() as a base instead of empty variable. Currently the environment of executed external auth program only contains SFTPGO_AUTHD* variables and therefore the program lacks additional context when started.
This commit is contained in:
Paweł K 2020-01-09 02:45:22 +01:00 committed by drakkan
parent 8e604f888a
commit 37c602a477

View file

@ -698,6 +698,7 @@ func doExternalAuth(username, password, pubKey string) (User, error) {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel() defer cancel()
cmd := exec.CommandContext(ctx, config.ExternalAuthProgram) cmd := exec.CommandContext(ctx, config.ExternalAuthProgram)
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, fmt.Sprintf("SFTPGO_AUTHD_USERNAME=%v", username)) cmd.Env = append(cmd.Env, fmt.Sprintf("SFTPGO_AUTHD_USERNAME=%v", username))
if len(password) > 0 { if len(password) > 0 {
cmd.Env = append(cmd.Env, fmt.Sprintf("SFTPGO_AUTHD_PASSWORD=%v", password)) cmd.Env = append(cmd.Env, fmt.Sprintf("SFTPGO_AUTHD_PASSWORD=%v", password))