Skip to content

Commit

Permalink
Merge pull request #96 from ebiggers/unset_item_fix
Browse files Browse the repository at this point in the history
pam: return error when PAM info item is unset
  • Loading branch information
josephlr authored Apr 19, 2018
2 parents 3ef69aa + 81942ab commit 6c4ba88
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions pam/pam.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,18 @@ func (h *Handle) GetString(name string) (string, error) {
return C.GoString((*C.char)(data)), nil
}

// GetItem retrieves a PAM information item. This a pointer directory to the
// GetItem retrieves a PAM information item. This is a pointer directly to the
// data, so it shouldn't be modified.
func (h *Handle) GetItem(i Item) (unsafe.Pointer, error) {
var data unsafe.Pointer
h.status = C.pam_get_item(h.handle, C.int(i), &data)
return data, h.err()
if err := h.err(); err != nil {
return nil, err
}
if data == nil {
return nil, errors.New("item not found")
}
return data, nil
}

// StartAsPamUser sets the effective privileges to that of the PAM user, and
Expand Down

0 comments on commit 6c4ba88

Please sign in to comment.