From 02ccfbfaf0cc627aa3aec8ef7ed5cfeec5b43f63 Mon Sep 17 00:00:00 2001 From: Michael Steinert Date: Fri, 4 Dec 2015 10:05:44 -0600 Subject: [PATCH] [ci skip] Update documentation --- README.md | 8 +----- example/.gitignore | 1 - example/example.go => example_test.go | 35 ++++++++++----------------- transaction.go | 1 + 4 files changed, 15 insertions(+), 30 deletions(-) delete mode 100644 example/.gitignore rename example/example.go => example_test.go (68%) diff --git a/README.md b/README.md index 21851ed..66b3820 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,7 @@ # Go PAM -This is a Go wrapper for the PAM application API. There's not much -else to be said. PAM is a simple API and now it's available for use in Go -applications. - -There's an example of a "fake login" program in the examples directory. -Look at the pam module's [godocs][1] for details about the Go API, or refer -to the official [PAM documentation][2]. +This is a Go wrapper for the PAM application API. ## Testing diff --git a/example/.gitignore b/example/.gitignore deleted file mode 100644 index 6f30a3a..0000000 --- a/example/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/example diff --git a/example/example.go b/example_test.go similarity index 68% rename from example/example.go rename to example_test.go index 82f9b57..aca24a1 100644 --- a/example/example.go +++ b/example_test.go @@ -1,23 +1,4 @@ -// This is a fake login implementation. It uses whatever default -// PAM service configuration is available on the system, and tries -// to authenticate any user. This should cause PAM to ask its -// conversation handler for a username and password, in sequence. -// -// This application will handle those requests by displaying the -// PAM-provided prompt and sending back the first line of stdin input -// it can read for each. -// -// Keep in mind that unless run as root (or setuid root), the only -// user's authentication that can succeed is that of the process owner. -// -// It's not a real login for several reasons: -// -// It doesn't switch users. -// It's not a real login. -// -// It does however demonstrate a simple but powerful use of PAM. - -package main +package pam_test import ( "bufio" @@ -30,7 +11,17 @@ import ( "github.com/msteinert/pam" ) -func main() { +// This example uses whatever default PAM service configuration is available +// on the system, and tries to authenticate any user. This should cause PAM +// to ask its conversation handler for a username and password, in sequence. +// +// This application will handle those requests by displaying the +// PAM-provided prompt and sending back the first line of stdin input +// it can read for each. +// +// Keep in mind that unless run as root (or setuid root), the only +// user's authentication that can succeed is that of the process owner. +func Example_authenticate() { t, err := pam.StartFunc("", "", func(s pam.Style, msg string) (string, error) { switch s { case pam.PromptEchoOff: @@ -58,5 +49,5 @@ func main() { if err != nil { log.Fatalf("Authenticate: %s", err.Error()) } - log.Print("Authentication succeeded!") + fmt.Println("Authentication succeeded!") } diff --git a/transaction.go b/transaction.go index e4eface..cda848e 100644 --- a/transaction.go +++ b/transaction.go @@ -1,3 +1,4 @@ +// Package pam provides a wrapper for the PAM application API. package pam //#include