aboutsummaryrefslogtreecommitdiff
path: root/pam/pam.go
diff options
context:
space:
mode:
Diffstat (limited to 'pam/pam.go')
-rw-r--r--pam/pam.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/pam/pam.go b/pam/pam.go
index dab4a55..ea1c34e 100644
--- a/pam/pam.go
+++ b/pam/pam.go
@@ -127,6 +127,15 @@ func (h *Handle) GetItem(i Item) (unsafe.Pointer, error) {
return data, nil
}
+// GetServiceName retrieves the name of the application running the PAM transaction.
+func (h *Handle) GetServiceName() string {
+ data, err := h.GetItem(Service)
+ if err != nil {
+ return "[unknown service]"
+ }
+ return C.GoString((*C.char)(data))
+}
+
// StartAsPamUser sets the effective privileges to that of the PAM user.
func (h *Handle) StartAsPamUser() error {
userPrivs, err := security.UserPrivileges(h.PamUser)