diff options
| author | Joseph Richey <joerichey@google.com> | 2018-04-19 11:11:33 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-19 11:11:33 -0700 |
| commit | 6c4ba88620db97ab90736595ede937f3610f161d (patch) | |
| tree | 1df58e59595ea964928c57ae78136dd53e647d51 /pam | |
| parent | 3ef69aaafcfe6df03097d9ebdc8e4c7f7516999b (diff) | |
| parent | 81942ab75c02e720970d6af069e8b8cf3ef847bb (diff) | |
Merge pull request #96 from ebiggers/unset_item_fix
pam: return error when PAM info item is unset
Diffstat (limited to 'pam')
| -rw-r--r-- | pam/pam.go | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -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 |