summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor van Poppelen <[email protected]>2014-04-03 13:11:40 -0400
committerVictor van Poppelen <[email protected]>2014-04-03 13:17:27 -0400
commit4c91b63e1eca9592ffb979742be91713b1b05434 (patch)
treef5340bc720da2cbeab5cb09e6c2d853685b0035b
parentae2ede3e7633809e6364cae47e69b3f66df68e61 (diff)
Updated to match current code.google.com/p/gopam
-rw-r--r--Makefile20
-rw-r--r--README14
-rw-r--r--examples/Makefile11
-rw-r--r--examples/fakelogin.go74
-rw-r--r--gopam.c (renamed from pam/gopam.c)1
-rw-r--r--gopam.h (renamed from pam/gopam.h)0
-rw-r--r--pam.go (renamed from pam/pam.go)4
-rw-r--r--pam/Makefile16
-rw-r--r--pamdefs.c (renamed from pam/pamdefs.c)0
-rw-r--r--pamdefs.go (renamed from pam/pamdefs.go)2
10 files changed, 3 insertions, 139 deletions
diff --git a/Makefile b/Makefile
deleted file mode 100644
index 730a2c4..0000000
--- a/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-include $(GOROOT)/src/Make.inc
-
-.PHONY: all pam install examples clean
-
-all: install examples
-
-pam:
- gomake -C pam
-
-install: pam
- gomake -C pam install
-
-examples:
- gomake -C examples
-
-clean:
- gomake -C pam clean
- gomake -C examples clean
-
-
diff --git a/README b/README
deleted file mode 100644
index 52cf817..0000000
--- a/README
+++ /dev/null
@@ -1,14 +0,0 @@
-It's Go! It's PAM (Pluggable Authentication Modules)! It's GoPAM!
-
-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 for details about the Go
-API; for a more general PAM application API reference, peep
-
-http://www.kernel.org/pub/linux/libs/pam/Linux-PAM-html/adg-interface-by-app-expected.html
-
-In the future, maybe the module API will be wrapped too. I don't know!
-
diff --git a/examples/Makefile b/examples/Makefile
deleted file mode 100644
index fe7cd10..0000000
--- a/examples/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright 2009 The Go Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file.
-
-include $(GOROOT)/src/Make.inc
-
-TARG=fakelogin
-GOFILES=\
- fakelogin.go
-
-include $(GOROOT)/src/Make.cmd
diff --git a/examples/fakelogin.go b/examples/fakelogin.go
deleted file mode 100644
index cee2377..0000000
--- a/examples/fakelogin.go
+++ /dev/null
@@ -1,74 +0,0 @@
-// 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:
-//
-// (!WARNING!) It echos your password to the terminal (!WARNING!)
-// It doesn't switch users.
-// It's not a real login.
-//
-// It does however demonstrate a simple but powerful use of Go PAM.
-
-package main
-
-import(
- "fmt"
- "github.com/krockot/gopam/pam"
- "os"
- "bufio"
-)
-
-func GetLine(prompt string) (string,bool) {
- fmt.Print(prompt)
- in := bufio.NewReader(os.Stdin)
- input,err := in.ReadString('\n')
- if err != nil {
- return "",false
- }
- return input[:len(input)-1],true
-}
-
-// Echo on/off is ignored; echo will always happen.
-func DumbPrompter(style int, msg string) (string,bool) {
- switch style {
- case pam.PROMPT_ECHO_OFF:
- return GetLine(msg)
- case pam.PROMPT_ECHO_ON:
- return GetLine(msg)
- case pam.ERROR_MSG:
- fmt.Fprintf(os.Stderr, "Error: %s\n", msg)
- return "",true
- case pam.TEXT_INFO:
- fmt.Println(msg)
- return "",true
- }
- return "",false
-}
-
-func main() {
- t,status := pam.Start("", "", pam.ResponseFunc(DumbPrompter))
- if status != pam.SUCCESS {
- fmt.Fprintf(os.Stderr, "Start() failed: %s\n", t.Error(status))
- return
- }
- defer func(){ t.End(status) }()
-
- status = t.Authenticate(0)
- if status != pam.SUCCESS {
- fmt.Fprintf(os.Stderr, "Auth failed: %s\n", t.Error(status))
- return
- }
-
- fmt.Printf("Authentication succeeded!\n")
- fmt.Printf("Goodbye, friend.\n")
-}
-
diff --git a/pam/gopam.c b/gopam.c
index 90d3de3..ea5fd88 100644
--- a/pam/gopam.c
+++ b/gopam.c
@@ -2,7 +2,6 @@
#include <security/pam_appl.h>
#include <stdlib.h>
#include <string.h>
-#include "gopam.h"
#include "_cgo_export.h"
/* Simplification of pam_get_item to remove type ambiguity. Will never
diff --git a/pam/gopam.h b/gopam.h
index a9c7b99..a9c7b99 100644
--- a/pam/gopam.h
+++ b/gopam.h
diff --git a/pam/pam.go b/pam.go
index 60f751f..9c21037 100644
--- a/pam/pam.go
+++ b/pam.go
@@ -1,6 +1,6 @@
// Package pam provides a wrapper for the application layer of the
// Pluggable Authentication Modules library.
-package pam
+package gopam
import (
//#include "gopam.h"
@@ -188,7 +188,7 @@ func (t* Transaction) GetEnvList() map[string]string {
for *(*uintptr)(unsafe.Pointer(list)) != 0 {
entry := *(*uintptr)(unsafe.Pointer(list))
nameval := C.GoString((*C.char)(unsafe.Pointer(entry)))
- chunks := strings.Split(nameval, "=", 2)
+ chunks := strings.SplitN(nameval, "=", 2)
env[chunks[0]] = chunks[1]
list += (uintptr)(unsafe.Sizeof(list))
}
diff --git a/pam/Makefile b/pam/Makefile
deleted file mode 100644
index 9239acf..0000000
--- a/pam/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-include $(GOROOT)/src/Make.inc
-TARG=pam
-GOFILES:=pamdefs.go
-CGOFILES:=pam.go
-CGO_LDFLAGS:=-lpam
-CGO_OFILES:=gopam.o
-
-include $(GOROOT)/src/Make.pkg
-
-DOLLAR:="$"
-
-pamdefs.go: pamdefs.c
- godefs `echo -n $(CGO_FLAGS) | sed 's/\(^ ^$(DOLLAR)]*\)/-f \1/g'` -g pam pamdefs.c > pamdefs.go
- gofmt -w pamdefs.go
-
-
diff --git a/pam/pamdefs.c b/pamdefs.c
index ef0bbc3..ef0bbc3 100644
--- a/pam/pamdefs.c
+++ b/pamdefs.c
diff --git a/pam/pamdefs.go b/pamdefs.go
index 06fbd79..0b1ee58 100644
--- a/pam/pamdefs.go
+++ b/pamdefs.go
@@ -2,7 +2,7 @@
// MACHINE GENERATED - DO NOT EDIT.
-package pam
+package gopam
// Constants
const (