Mercurial > go > multipass
changeset 1:faf4aad86fc9
Make checkpassword work; fix minor bug in add.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sat, 24 Oct 2015 21:48:38 -0400 |
parents | c18bc7b9d1d9 |
children | a4fa4f28b472 |
files | multipass-add.go multipass-checkpassword.go |
diffstat | 2 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/multipass-add.go Sat Oct 24 21:32:03 2015 -0400 +++ b/multipass-add.go Sat Oct 24 21:48:38 2015 -0400 @@ -20,6 +20,7 @@ fmt.Println(err.Error()) return } + text = text[:-1] entry, password, err := auth.NewEntry(text) if err != nil { fmt.Println(err.Error())
--- a/multipass-checkpassword.go Sat Oct 24 21:32:03 2015 -0400 +++ b/multipass-checkpassword.go Sat Oct 24 21:48:38 2015 -0400 @@ -2,6 +2,7 @@ import ( "bufio" + "fmt" "os" "os/user" "syscall" @@ -15,16 +16,19 @@ ) func main() { - //infile = os.NewFile(3, "") + infile = os.NewFile(3, "") reader := bufio.NewReader(os.Stdin) username, err := reader.ReadString('\n') if err != nil { os.Exit(InternalError) } + username = username[:len(username)-1] pass, err := reader.ReadString('\n') if err != nil { os.Exit(InternalError) } + pass = pass[:len(pass)-1] + infile.Close() passfile, err := file.ForUser(username) if err != nil { os.Exit(Failed) @@ -34,7 +38,6 @@ os.Exit(Failed) } user, err := user.Lookup(username) - err = os.Setenv("USER", user.HomeDir) if err != nil { os.Exit(Failed) } @@ -42,8 +45,10 @@ os.Setenv("userdb_gid", user.Gid) os.Setenv("EXTRA", "userdb_uid userdb_gid") environ := []string{ + "USER=" + user.Username "userdb_uid=" + user.Uid, "userdb_gid=" + user.Gid, + "HOME=" + user.HomeDir, "EXTRA=userdb_uid userdb_gid", } syscall.Exec(os.Args[1], os.Args[1:], environ)