git » remoteu2f » commit 5c2f5fa

cli: Use $PAM_USER for the user message in PAM mode

author Alberto Bertogli
2015-10-24 23:55:46 UTC
committer Alberto Bertogli
2015-10-25 00:01:01 UTC
parent bcdf947e1d75c1f71a0a80c06a876e9dbcb5969c

cli: Use $PAM_USER for the user message in PAM mode

When remoteu2f-cli is called in PAM mode, it usually will be running as a
different user than the one it's authenticating.

The PAM mode generally considers this, but for displaying the message
remoteu2f-cli is using the username; this patch makes it to use $PAM_USER
instead.

remoteu2f-cli/main.go +5 -2

diff --git a/remoteu2f-cli/main.go b/remoteu2f-cli/main.go
index d66123c..3c4a156 100644
--- a/remoteu2f-cli/main.go
+++ b/remoteu2f-cli/main.go
@@ -334,8 +334,11 @@ func PAM(ctx *cli.Context) {
 
 	c := mustGRPCClient(conf.Addr, conf.Token, ctx.GlobalString("ca_file"))
 
-	user, hostname := mustUserInfo()
-	msg := fmt.Sprintf("%s@%s", user, hostname)
+	hostname, err := os.Hostname()
+	if err != nil {
+		fatalf("Error getting hostname: %v", err)
+	}
+	msg := fmt.Sprintf("%s@%s", username, hostname)
 
 	pa, err := c.PrepareAuthentication(
 		msg, conf.AppID, conf.RegistrationValues())