diff options
author | Werner Koch <[email protected]> | 2006-09-14 11:17:33 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2006-09-14 11:17:33 +0000 |
commit | f4f90811735b1f599e207e49d449abfa9d47897d (patch) | |
tree | b509639246290da27975771f95b8d46cf57ec60c /src/assuan-connect.c | |
parent | More tweaks for descriptor passing. (diff) | |
download | libassuan-0.9.0.tar.gz libassuan-0.9.0.zip |
Preparing a new releaselibassuan-0.9.0
Diffstat (limited to '')
-rw-r--r-- | src/assuan-connect.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/assuan-connect.c b/src/assuan-connect.c index a9d9eeb..92995d8 100644 --- a/src/assuan-connect.c +++ b/src/assuan-connect.c @@ -50,10 +50,30 @@ assuan_disconnect (assuan_context_t ctx) } } -/* Return the PID of the peer or -1 if not known. */ +/* Return the PID of the peer or -1 if not known. This function works + in some situations where assuan_get_ucred fails. */ pid_t assuan_get_pid (assuan_context_t ctx) { return (ctx && ctx->pid)? ctx->pid : -1; } + +/* Return user credentials. PID, UID and GID amy be gived as NULL if + you are not interested in this value. For getting the pid of the + peer the assuan_get_pid is usually better suited. */ +assuan_error_t +assuan_get_peercred (assuan_context_t ctx, pid_t *pid, uid_t *uid, gid_t *gid) +{ + if (!ctx) + return _assuan_error (ASSUAN_Invalid_Value); + if (!ctx->peercred.valid) + return _assuan_error (ASSUAN_General_Error); + if (pid) + *pid = ctx->peercred.pid; + if (uid) + *uid = ctx->peercred.uid; + if (gid) + *gid = ctx->peercred.gid; + return 0; +} |