| 1 |
.\" Copyright 2016, Michael Kerrisk <[email protected]> |
| 2 |
.\" Copyright 2016, Eugene Syromyatnikov <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH KEYCTL_JOIN_SESSION_KEYRING 2const 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
KEYCTL_JOIN_SESSION_KEYRING |
| 10 |
\- |
| 11 |
replace the session keyring this process subscribes to with a new one |
| 12 |
.SH LIBRARY |
| 13 |
Standard C library |
| 14 |
.RI ( libc ,\~ \-lc ) |
| 15 |
.SH SYNOPSIS |
| 16 |
.nf |
| 17 |
.BR "#include <linux/keyctl.h>" " /* Definition of " KEY* " constants */" |
| 18 |
.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */" |
| 19 |
.B #include <unistd.h> |
| 20 |
.P |
| 21 |
.B long syscall(SYS_keyctl, KEYCTL_JOIN_SESSION_KEYRING, |
| 22 |
.BI " char *_Nullable " desc ); |
| 23 |
.fi |
| 24 |
.SH DESCRIPTION |
| 25 |
Replace the session keyring this process subscribes to with |
| 26 |
a new session keyring. |
| 27 |
.\" This may be useful in conjunction with some sort of |
| 28 |
.\" session management framework that is employed by the application. |
| 29 |
.P |
| 30 |
If |
| 31 |
.I desc |
| 32 |
is NULL, |
| 33 |
an anonymous keyring with the description "_ses" is created |
| 34 |
and the process is subscribed to that keyring as its session keyring, |
| 35 |
displacing the previous session keyring. |
| 36 |
.P |
| 37 |
Otherwise, |
| 38 |
.I desc |
| 39 |
is treated as the description (name) of a keyring, |
| 40 |
and the behavior is as follows: |
| 41 |
.IP \[bu] 3 |
| 42 |
If a keyring with a matching description exists, |
| 43 |
the process will attempt to subscribe to that keyring |
| 44 |
as its session keyring if possible; |
| 45 |
if that is not possible, an error is returned. |
| 46 |
In order to subscribe to the keyring, |
| 47 |
the caller must have |
| 48 |
.I search |
| 49 |
permission on the keyring. |
| 50 |
.IP \[bu] |
| 51 |
If a keyring with a matching description does not exist, |
| 52 |
then a new keyring with the specified description is created, |
| 53 |
and the process is subscribed to that keyring as its session keyring. |
| 54 |
.SH RETURN VALUE |
| 55 |
On success, |
| 56 |
the ID of the joined session keyring. |
| 57 |
.P |
| 58 |
On error, \-1 is returned, and |
| 59 |
.I errno |
| 60 |
is set to indicate the error. |
| 61 |
.SH VERSIONS |
| 62 |
A wrapper is provided in the |
| 63 |
.I libkeyutils |
| 64 |
library: |
| 65 |
.BR keyctl_join_session_keyring (3). |
| 66 |
.SH STANDARDS |
| 67 |
Linux. |
| 68 |
.SH HISTORY |
| 69 |
Linux 2.6.10. |
| 70 |
.SH SEE ALSO |
| 71 |
.BR keyctl (2), |
| 72 |
.BR keyctl_join_session_keyring (3) |