Hi, all,<br><div class="gmail_quote"><br>I am a newbie to PAM. Recently, I am planning to design a c/s program which needs auth/session management module.<br>I thought of PAM. Since i am new to it, things below puzzle me.<br>
<br><br><b>[1] About pam session</b><br><br>In pam, we get two functions ,pam_open_session pam_close_session<br><br>My puzzle is----<br>after calling pam_open_session, what have i got?<br><br>Does that mean I get a fresh env?<br>
<br>In a c/s design, how can i maintain the session?<br><br>(I have some exp on web-program design in which i get a structure called session that can maintain the relationship between a browser user and web server). But in pam, how can i know the session runs out of time? <br>
Do I have to write a feature to fulfill it? E.g. Store a time_t variable. Fresh it when a users send some tcp/udp package to the server.<br><br><br><b>[2] About credential</b><br><br>Cite some pam doc lines here:<br><br><span style="background-color: rgb(192, 192, 192);"> On a Linux system 
the user's UID and GID's are credentials too. However, it has been 
decided that these properties (along with the default supplementary 
groups of which the user is a member) are credentials that should be set
 directly by the application and not by PAM. Such credentials should be 
established, by the application, prior to a call to this function. For 
example, initgroups(2) (or equivalent) should have been performed.<br><br></span>Here, the pam_setcred does not set uid or gid. I've no idea what the function can do?<br>How can I use it?<br><br><span style="background-color: rgb(192, 192, 192);"></span><br>

<br style="background-color: rgb(192, 192, 192);"><span style="background-color: rgb(192, 192, 192);">int pam_setcred(pamh,  </span><br style="background-color: rgb(192, 192, 192);"><span style="background-color: rgb(192, 192, 192);"> flags); </span><br style="background-color: rgb(192, 192, 192);">

<span style="background-color: rgb(192, 192, 192);">pam_handle_t *pamh;</span><br style="background-color: rgb(192, 192, 192);"><span style="background-color: rgb(192, 192, 192);">int flags;</span><br style="background-color: rgb(192, 192, 192);">

<span style="background-color: rgb(192, 192, 192);"> </span><br style="background-color: rgb(192, 192, 192);"><br style="background-color: rgb(192, 192, 192);"><span style="background-color: rgb(192, 192, 192);">3.1.8.1. DESCRIPTION</span><br style="background-color: rgb(192, 192, 192);">

<br style="background-color: rgb(192, 192, 192);"><span style="background-color: rgb(192, 192, 192);">The pam_setcred function is used to establish, maintain and delete the credentials of a user. It should be called to set the credentials after a user has been authenticated and before a session is opened for the user (with pam_open_session(3)). The credentials should be deleted after the session has been closed (with pam_close_session(3)).</span><br style="background-color: rgb(192, 192, 192);">

<br style="background-color: rgb(192, 192, 192);"><span style="background-color: rgb(192, 192, 192);">A credential is something that the user possesses. It is some property, such as a Kerberos ticket, or a supplementary group membership that make up the uniqueness of a given user. On a Linux system the user's UID and GID's are credentials too. However, it has been decided that these properties (along with the default supplementary groups of which the user is a member) are credentials that should be set directly by the application and not by PAM. Such credentials should be established, by the application, prior to a call to this function. For example, initgroups(2) (or equivalent) should have been performed.</span><br>

<br><br><br><br>Thanks a million.<br><br>--<br>Regards,<br><font color="#888888">Guannan<br>
<br>
</font></div><br><br>