Re: problem getting password in a pam module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

does your code implement pam_sm_open_session()?
I think the password is only accessable in pam_sm_authenticate().
If you want to use the password later in pam_sm_open_session(),
you need to store it in pam_sm_authenticate() using pam_set_item(),
and retrieve it in pam_sm_open_session() using pam_get_item().

Best regards, Fabian.

> Hi,
> I use the below code to get user and password from pam, but there is a
> problem for password.
> Password is (null) when I call "rc = pam_get_item (pamh, PAM_AUTHTOK,
> (const
> void **) &p);"
> what is the problem with the code?
>
> Regards,
>
>
>  53   D(("get user returned error: %s", pam_strerror(pamh,retval)));
>  55   int rc;
>  56   char *user=NULL;
>  57   char *p=NULL;
>  58   int use_first_pass = 0, try_first_pass = 0;
>  59   int i;
>  60
>  61   for (i = 0; i < argc; i++)
>  62   {
>  63     if (!strcmp (argv[i], "use_first_pass"))
>  64       use_first_pass = 1;
>  65     else if (!strcmp (argv[i], "try_first_pass"))
>  66       try_first_pass = 1;
>  72   }
>  73   rc = pam_get_user(pamh,(const char **) &user, NULL);
>  74   if (rc != PAM_SUCCESS)
>  75   {
>  76     D(("get user returned error: %s", pam_strerror(pamh,rc)));
>  78     return rc;
>  79   }
>
>  82   if (user == NULL || *user == '\0')
>  83   {
>  84     D(("username not known"));
>  85     rc = pam_set_item(pamh, PAM_USER, (const char *) DEFAULT_USER);
>  86     if (rc != PAM_SUCCESS)
>  87       return PAM_USER_UNKNOWN;
>  88   }
>  89   //user = NULL;                                            /* clean
> up
> */
>  90
>  91   rc = pam_get_item (pamh, PAM_AUTHTOK, (const void **) &p);
>  92   syslog (LOG_ERR, "pass: %s", p);
>  93   syslog (LOG_ERR, "user: %s", user);
>  94   return PAM_SUCCESS;
>  95   if (rc == PAM_SUCCESS && (use_first_pass || try_first_pass))
> _______________________________________________
> Pam-list mailing list
> Pam-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/pam-list


_______________________________________________
Pam-list mailing list
Pam-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/pam-list

[Index of Archives]     [Fedora Users]     [Kernel]     [Red Hat Install]     [Linux for the blind]     [Gimp]

  Powered by Linux