Retrieving tcp socket port in PAM module

Sudarshan Soma <[email protected]> Wed, 20 Dec 2017 00:04:16 +0530
Newsgroups gmane.linux.pam
Message-ID <CAHJvL=ZYDCiG=O9dSRn7pDCRZ2DEBOYsxNBPY4qfSu9MUW+zGA@mail.gmail.com>
--===============3954963890621572728==
Content-Type: multipart/alternative; boundary="001a1135b4fadd7fa60560b5b678"

--001a1135b4fadd7fa60560b5b678
Content-Type: text/plain; charset="UTF-8"

Hi,
I am invoking my own login shell /bin/myshell once  PAM authentication is
successfull.

My login shell, /bin/myshell requires remote ip (of client) , remote port
(socket opened on node, where PAM module is sitting.

I could get remote host, from PAM_RHOST

retval = pam_get_item(pamh, PAM_RHOST, (const void **) &rhost);


Can somebody please suggest, how to get port. I know sshd has this
information as i cna see in the sshd logs, but how do i retrieve it in PAM
module .


sshd logs has port no, 50469

Oct  9 07:20:43 x86-hw auth.info sshd[13128]: Accepted none for secadmin
from 10.220.82.17 port 50469 ssh2




Regards,
Ivan.

--001a1135b4fadd7fa60560b5b678
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,=C2=A0<div>I am invoking my own login shell /bin/myshel=
l once=C2=A0 PAM authentication is successfull.=C2=A0</div><div><br></div><=
div>My login shell, /bin/myshell requires remote ip (of client) , remote po=
rt (socket opened on node, where PAM module is sitting.=C2=A0</div><div><br=
></div><div>I could get remote host, from PAM_RHOST</div><div><br></div><di=
v><div>retval =3D pam_get_item(pamh, PAM_RHOST, (const void **) &amp;rhost)=
;</div><div></div></div><div><br></div><div><br></div><div>Can somebody ple=
ase suggest, how to get port. I know sshd has this information as i cna see=
 in the sshd logs, but how do i retrieve it in PAM module .</div><div><br><=
/div><div><br></div><div>sshd logs has port no, 50469=C2=A0</div><div><br><=
/div><div>Oct=C2=A0 9 07:20:43 x86-hw <a href=3D"http://auth.info">auth.inf=
o</a> sshd[13128]: Accepted none for secadmin from 10.220.82.17 port 50469 =
ssh2<br></div><div><br></div><div><br></div><div><br></div><div><br></div><=
div>Regards,</div><div>Ivan.=C2=A0</div></div>

--001a1135b4fadd7fa60560b5b678--


--===============3954963890621572728==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Pam-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/pam-list
--===============3954963890621572728==--