1PAM_SET_DATA(3) Linux-PAM Manual PAM_SET_DATA(3)
2
3
4
6 pam_set_data - set module internal data
7
9 #include <security/pam_modules.h>
10
11 int pam_set_data(pam_handle_t *pamh, const char *module_data_name,
12 void *data,
13 void (*cleanup)(pam_handle_t *pamh, void *data, int error_status));
14
16 The pam_set_data function associates a pointer to an object with the
17 (hopefully) unique string module_data_name in the PAM context specified
18 by the pamh argument.
19
20 PAM modules may be dynamically loadable objects. In general such files
21 should not contain static variables. This function and its counterpart
22 pam_get_data(3), provide a mechanism for a module to associate some
23 data with the handle pamh. Typically a module will call the
24 pam_set_data function to register some data under a (hopefully) unique
25 module_data_name. The data is available for use by other modules too
26 but not by an application. Since this functions stores only a pointer
27 to the data, the module should not modify or free the content of it.
28
29 The function cleanup() is associated with the data and, if non-NULL, it
30 is called when this data is over-written or following a call to
31 pam_end(3).
32
33 The error_status argument is used to indicate to the module the sort of
34 action it is to take in cleaning this data item. As an example,
35 Kerberos creates a ticket file during the authentication phase, this
36 file might be associated with a data item. When pam_end(3) is called by
37 the module, the error_status carries the return value of the
38 pam_authenticate(3) or other libpam function as appropriate. Based on
39 this value the Kerberos module may choose to delete the ticket file
40 (authentication failure) or leave it in place.
41
42 The error_status may have been logically OR'd with either of the
43 following two values:
44
45 PAM_DATA_REPLACE
46 When a data item is being replaced (through a second call to
47 pam_set_data) this mask is used. Otherwise, the call is assumed to
48 be from pam_end(3).
49
50 PAM_DATA_SILENT
51 Which indicates that the process would prefer to perform the
52 cleanup() quietly. That is, discourages logging/messages to the
53 user. It is generally used to indicate that the current closing of
54 the library is in a fork(2)ed process, and that the parent will
55 take care of cleaning up things that exist outside of the current
56 process space (files etc.).
57
59 PAM_BUF_ERR
60 Memory buffer error.
61
62 PAM_SUCCESS
63 Data was successful stored.
64
65 PAM_SYSTEM_ERR
66 A NULL pointer was submitted as PAM handle or the function was
67 called by an application.
68
70 pam_end(3), pam_get_data(3), pam_strerror(3)
71
72
73
74Linux-PAM 05/07/2023 PAM_SET_DATA(3)