Skip to contentSkip to conversation

Add common_name to the conv method. This allows the common_name to be accessible in PAM.

PATCH In review Antonio Quartulli 3 participants 4 messages Sep 17, 2022 – Sep 19, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add common_name to the conv method. This allows the common_name to be accessible in PAM.

From: Michael Karvan <[email protected]...>

---
 src/plugins/auth-pam/auth-pam.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
src/plugins/auth-pam/auth-pam.c +8 -1
index 70339445..9f37c8c0 100644
@@ -746,8 +746,15 @@ my_conv(int n, const struct pam_message **msg_array,
                     }
                     break;
 
-                case PAM_ERROR_MSG:
                 case PAM_TEXT_INFO:
+                    aresp[i].resp = strdup(up->common_name);
+                    if (aresp[i].resp == NULL)
+                    {
+                        ret = PAM_CONV_ERR;
+                    }
+                    break;
+
+                case PAM_ERROR_MSG:
                     break;
 
                 default:
Signature · 1 line
2.35.1
#1 lore raw

Hi,

Quoted 14 lines · Antonio Quartulli

From: Michael Karvan <[email protected]...>

---
 src/plugins/auth-pam/auth-pam.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
src/plugins/auth-pam/auth-pam.c +0 -0
index 70339445..9f37c8c0 100644
@@ -746,8 +746,15 @@ my_conv(int n, const struct pam_message **msg_array,
                     }
                     break;

src/plugins/auth-pam/auth-pam.c my_conv(int n, const struct pam_message **msg_array, · line 756

Quoted 10 lines
src/plugins/auth-pam/auth-pam.c +7 -1
 
-                case PAM_ERROR_MSG:
                 case PAM_TEXT_INFO:
+                    aresp[i].resp = strdup(up->common_name);
+                    if (aresp[i].resp == NULL)
+                    {
+                        ret = PAM_CONV_ERR;
+                    }
+                    break;
+

Not sure I understand the intricaticies of PAM enough, but this seems hackish and not really correct to me.

Linux' "man pam_conv" suggests that PAM_TEXT_INFO is to "Display some text", but just having the common_name there only makes sense if you have a PAM module that actually knows what to do with it, and displays this in a nice way. No?

Can you elaborate more on this patch, how it is interacting with specific PAM modules, and what is happening where?

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#2 lore raw
In reply to Antonio Quartulli
Quoted 19 lines · Antonio Quartulli

From: Michael Karvan <[email protected]...>

---
 src/plugins/auth-pam/auth-pam.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
src/plugins/auth-pam/auth-pam.c +1 -1
index 70339445..9f37c8c0 100644
@@ -746,8 +746,15 @@ my_conv(int n, const struct pam_message **msg_array,
                     }
                     break;
 
-                case PAM_ERROR_MSG:
                 case PAM_TEXT_INFO:
+                    aresp[i].resp = strdup(up->common_name);

src/plugins/auth-pam/auth-pam.c my_conv(int n, const struct pam_message **msg_array, · line 760

Quoted 10 lines
src/plugins/auth-pam/auth-pam.c +7 -0
+                    if (aresp[i].resp == NULL)
+                    {
+                        ret = PAM_CONV_ERR;
+                    }
+                    break;
+
+                case PAM_ERROR_MSG:
                     break;
 
 

To add to what Gert's comment, we already support COMMONNAME in addition to USERNAME, PASSWORD and
OTP via text replacements for pam prompts specified in the config file. Like:

plugin openvpn-auth-pam.so "openvpn user USERNAME password PASSWORD cn
COMMONNAME"

and have the PAM module prompt for "user', "password" and "cn", for example.

So why do we need this non-standard stuff ?

In fact, IMO, we should be getting rid of this whole "else {}" clause starting line 728 that tries to guess the prompts based on echo-off ( to mean password) echo-on (to mean username) etc. Instead, require that the plugin line in the config file must specify expected prompts and replacement strings as above.

Selva

#3 lore raw

Hi,

Quoted 39 lines · Selva Nair

On Sat, Sep 17, 2022 at 10:09 AM Antonio Quartulli <[email protected]... <mailto:[email protected]...>> wrote:

    From: Michael Karvan <[email protected]...
    <mailto:[email protected]...>>

    Signed-off-by: Michael Karvan <[email protected]...
    <mailto:[email protected]...>>
    ---
      src/plugins/auth-pam/auth-pam.c | 9 ++++++++-
      1 file changed, 8 insertions(+), 1 deletion(-)

    diff --git a/src/plugins/auth-pam/auth-pam.c
    b/src/plugins/auth-pam/auth-pam.c
    index 70339445..9f37c8c0 100644
    --- a/src/plugins/auth-pam/auth-pam.c
    +++ b/src/plugins/auth-pam/auth-pam.c
    @@ -746,8 +746,15 @@ my_conv(int n, const struct pam_message
    **msg_array,
                          }
                          break;

    -                case PAM_ERROR_MSG:
                      case PAM_TEXT_INFO:
    +                    aresp[i].resp = strdup(up->common_name);
    +                    if (aresp[i].resp == NULL)
    +                    {
    +                        ret = PAM_CONV_ERR;
    +                    }
    +                    break;
    +
    +                case PAM_ERROR_MSG:
                          break;

To add to what Gert's comment, we already support COMMONNAME in addition to USERNAME, PASSWORD and OTP via text replacements for pam prompts specified in the config file. Like:

Quoted 6 lines

 plugin openvpn-auth-pam.so "openvpn user USERNAME password PASSWORD cn
COMMONNAME"

and have the PAM module prompt for "user', "password" and "cn", for example.

So why do we need this non-standard stuff ?

Right. This means that this patch is *obsolete*, as we already have a way to convey the common name.

Quoted 2 lines

In fact, IMO, we should be getting rid of this whole "else {}" clause starting line 728 that tries to guess the prompts based on echo-off ( to mean password) echo-on (to mean username) etc. Instead, require that the plugin line in the config file must specify expected prompts and replacement strings as above.

Agreed. If we have a "clean" way to gather those details, we should get rid of the hack.

Cheers,

Signature · 1 line
Antonio Quartulli