Debian Codegraph @

debian/patches/lib_security_multiarch_compat

raw
1 From: Sam Hartman <[email protected]>
2 Date: Mon, 11 Sep 2023 14:00:42 -0600
3 Subject: lib_security_multiarch_compat
4
5 Unqualified module paths should always be looked up in *both* the default
6 module dir, *and* the ISA dir. That's what paths are for.
7
8 This lets us have a soft transition to multiarch for modules without having
9 to rewrite /etc/pam.d/ files or add ugly symlinks.
10
11 Authors: Steve Langasek <[email protected]>
12
13 Upstream status: not ready to be committed - this needs tweaked, we're
14 currently abusing the existing variables and inverting their meaning in
15 order to get everything installed where we want it and get absolute paths
16 the way we want them.
17 ---
18 libpam/pam_handlers.c | 40 +++++++++++++++++++++++++---------------
19 1 file changed, 25 insertions(+), 15 deletions(-)
20
21 diff --git a/libpam/pam_handlers.c b/libpam/pam_handlers.c
22 index 1df5e40..9838fb2 100644
23 --- a/libpam/pam_handlers.c
24 +++ b/libpam/pam_handlers.c
25 @@ -667,10 +667,30 @@ _pam_load_module(pam_handle_t *pamh, const char *mod_path, int handler_type)
26 /* Be pessimistic... */
27 success = PAM_ABORT;
28
29 - D(("_pam_dlopen(%s)", mod_path));
30 - mod->dl_handle = _pam_dlopen(mod_path);
31 - D(("_pam_dlopen'ed"));
32 - D(("dlopen'ed"));
33 + D(("_pam_load_module: _pam_dlopen(%s)", mod_path));
34 + if (mod_path[0] == '/') {
35 + mod->dl_handle = _pam_dlopen(mod_path);
36 + } else {
37 + char *mod_full_path = NULL;
38 + if (asprintf(&mod_full_path, "%s%s",
39 + DEFAULT_MODULE_PATH, mod_path) >= 0) {
40 + mod->dl_handle = _pam_dlopen(mod_full_path);
41 + _pam_drop(mod_full_path);
42 + } else {
43 + pam_syslog(pamh, LOG_CRIT, "cannot malloc full mod path");
44 + }
45 + if (!mod->dl_handle) {
46 + if (asprintf(&mod_full_path, "%s/%s",
47 + _PAM_ISA, mod_path) >= 0) {
48 + mod->dl_handle = _pam_dlopen(mod_full_path);
49 + _pam_drop(mod_full_path);
50 + } else {
51 + pam_syslog(pamh, LOG_CRIT, "cannot malloc full mod path");
52 + }
53 + }
54 + }
55 + D(("_pam_load_module: _pam_dlopen'ed"));
56 + D(("_pam_load_module: dlopen'ed"));
57 if (mod->dl_handle == NULL) {
58 const char *isa = strstr(mod_path, "$ISA");
59 size_t isa_len = strlen("$ISA");
60 @@ -736,7 +756,6 @@ static int _pam_add_handler(pam_handle_t *pamh
61 struct handler **handler_p2;
62 struct handlers *the_handlers;
63 const char *sym, *sym2;
64 - char *mod_full_path;
65 servicefn func, func2;
66 int mod_type = PAM_MT_FAULTY_MOD;
67
68 @@ -748,16 +767,7 @@ static int _pam_add_handler(pam_handle_t *pamh
69
70 if ((handler_type == PAM_HT_MODULE || handler_type == PAM_HT_SILENT_MODULE) &&
71 mod_path != NULL) {
72 - if (mod_path[0] == '/') {
73 - mod = _pam_load_module(pamh, mod_path, handler_type);
74 - } else if (asprintf(&mod_full_path, "%s%s",
75 - DEFAULT_MODULE_PATH, mod_path) >= 0) {
76 - mod = _pam_load_module(pamh, mod_full_path, handler_type);
77 - _pam_drop(mod_full_path);
78 - } else {
79 - pam_syslog(pamh, LOG_CRIT, "cannot malloc full mod path");
80 - return PAM_ABORT;
81 - }
82 + mod = _pam_load_module(pamh, mod_path, handler_type);
83
84 if (mod == NULL) {
85 /* if we get here with NULL it means allocation error */