summaryrefslogtreecommitdiff
path: root/transaction.go
diff options
context:
space:
mode:
authorMichael Steinert <[email protected]>2015-12-04 09:21:38 -0600
committerMichael Steinert <[email protected]>2015-12-04 09:21:38 -0600
commit7f5fc62ba4a6fc7ea64b3da094269d05d89f60b9 (patch)
tree4e868741bb5209ccf781e7fa763acd10cda383bd /transaction.go
parent4314ed7dcc2ce5728603fa8c8385510fa74829fc (diff)
Remove dead code
Diffstat (limited to 'transaction.go')
-rw-r--r--transaction.go30
1 files changed, 8 insertions, 22 deletions
diff --git a/transaction.go b/transaction.go
index 458804d..54e285c 100644
--- a/transaction.go
+++ b/transaction.go
@@ -50,30 +50,15 @@ func (f ConversationFunc) RespondPAM(s Style, msg string) (string, error) {
return f(s, msg)
}
-// Constructs a new conversation object with a given handler and a newly
-// allocated pam_conv struct that uses this object as its appdata_ptr.
-func newConversation(handler ConversationHandler) (*C.struct_pam_conv, int, C.int) {
- c := cbAdd(handler)
- conv := &C.struct_pam_conv{}
- C.init_pam_conv(conv, C.long(c))
- return conv, c, C.PAM_SUCCESS
-}
-
-// Go-side function for processing a single conversational message. Ultimately
-// this calls the associated ConversationHandler's ResponsePAM callback with data
-// coming in from a C-side call.
+// cbPAMConv is a wrapper for the conversation callback function.
//export cbPAMConv
func cbPAMConv(s C.int, msg *C.char, c int) (*C.char, C.int) {
var r string
- var err error
+ var err error = nil
v := cbGet(c)
switch cb := v.(type) {
- case ConversationFunc:
- r, err = cb(Style(s), C.GoString(msg))
case ConversationHandler:
r, err = cb.RespondPAM(Style(s), C.GoString(msg))
- default:
- return nil, C.PAM_CONV_ERR
}
if err != nil {
return nil, C.PAM_CONV_ERR
@@ -89,7 +74,8 @@ type Transaction struct {
c int
}
-// Finalize a PAM transaction.
+// transactionFinalizer cleans up the PAM handle and deletes the callback
+// function.
func transactionFinalizer(t *Transaction) {
C.pam_end(t.handle, t.status)
cbDelete(t.c)
@@ -101,11 +87,11 @@ func transactionFinalizer(t *Transaction) {
// All application calls to PAM begin with Start (or StartFunc). The returned
// transaction provides an interface to the remainder of the API.
func Start(service, user string, handler ConversationHandler) (*Transaction, error) {
- t := &Transaction{}
- t.conv, t.c, t.status = newConversation(handler)
- if t.status != C.PAM_SUCCESS {
- return nil, t
+ t := &Transaction{
+ conv: &C.struct_pam_conv{},
+ c: cbAdd(handler),
}
+ C.init_pam_conv(t.conv, C.long(t.c))
runtime.SetFinalizer(t, transactionFinalizer)
s := C.CString(service)
defer C.free(unsafe.Pointer(s))