# HG changeset patch # User Paul Fisher # Date 1445737718 14400 # Node ID faf4aad86fc9ae935d6e8ca7b3915f5821723a84 # Parent c18bc7b9d1d964730fb96edc87fedcb89f88678f Make checkpassword work; fix minor bug in add. diff -r c18bc7b9d1d9 -r faf4aad86fc9 multipass-add.go --- 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()) diff -r c18bc7b9d1d9 -r faf4aad86fc9 multipass-checkpassword.go --- 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)