Merge pull request #17 from msteinert/update-example
Update example code to call Transaction.End
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
|||||||
// should cause PAM to ask its conversation handler for a username and password
|
// should cause PAM to ask its conversation handler for a username and password
|
||||||
// in sequence.
|
// in sequence.
|
||||||
func Example() {
|
func Example() {
|
||||||
t, err := pam.StartFunc("", "", func(s pam.Style, msg string) (string, error) {
|
t, err := pam.StartFunc("passwd", "", func(s pam.Style, msg string) (string, error) {
|
||||||
switch s {
|
switch s {
|
||||||
case pam.PromptEchoOff:
|
case pam.PromptEchoOff:
|
||||||
fmt.Print(msg)
|
fmt.Print(msg)
|
||||||
@@ -40,12 +40,19 @@ func Example() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "start: %s\n", err.Error())
|
fmt.Fprintf(os.Stderr, "start: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
err := t.End()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "end: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}()
|
||||||
err = t.Authenticate(0)
|
err = t.Authenticate(0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "authenticate: %s\n", err.Error())
|
fmt.Fprintf(os.Stderr, "authenticate: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
fmt.Println("authentication succeeded!")
|
fmt.Println("authentication succeeded!")
|
||||||
|
|||||||
Reference in New Issue
Block a user