aboutsummaryrefslogtreecommitdiff
path: root/pam
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2022-04-16 22:31:32 -0700
committerEric Biggers <ebiggers3@gmail.com>2022-04-16 22:37:20 -0700
commitf0c1cae003dd216ba706d7ef14df83d311c82034 (patch)
tree253576bb86950de1c760046ab3d38abfbff64c4f /pam
parent53dc5f37339f40e78cd0e91b358322cc9e589185 (diff)
Try to detect process being forked during PAM transaction
Update https://github.com/google/fscrypt/issues/350
Diffstat (limited to 'pam')
-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)