Send output from external_auth_hook to logs

Signed-off-by: Felix Eckhofer <felix@eckhofer.com>
This commit is contained in:
Felix Eckhofer
2023-02-25 20:04:04 +01:00
committed by Nicola Murino
parent 71f691b208
commit ec67b67e9e
2 changed files with 22 additions and 1 deletions

View File

@@ -3979,7 +3979,26 @@ func getExternalAuthResponse(username, password, pkey, keyboardInteractive, ip,
fmt.Sprintf("SFTPGO_AUTHD_PROTOCOL=%v", protocol),
fmt.Sprintf("SFTPGO_AUTHD_TLS_CERT=%v", strings.ReplaceAll(tlsCert, "\n", "\\n")),
fmt.Sprintf("SFTPGO_AUTHD_KEYBOARD_INTERACTIVE=%v", keyboardInteractive))
return cmd.Output()
var stdout bytes.Buffer
cmd.Stdout = &stdout
stderr, err := cmd.StderrPipe()
if err != nil {
return nil, err
}
err = cmd.Start()
if err != nil {
return nil, err
}
in := bufio.NewScanner(stderr)
for in.Scan() {
logger.Log(logger.LevelWarn, "external_auth_hook", "", "%s", in.Text())
}
return stdout.Bytes(), cmd.Wait()
}
func updateUserFromExtAuthResponse(user *User, password, pkey string) {