21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

After the authentication is successful, you should maintain the pam_handle_t object<br />

returned by spc_pam_login( ) until the user logs out from your application, at which<br />

point you should call spc_pam_logout( ) to allow PAM to perform anything it needs<br />

to do to log the user out.<br />

void spc_pam_logout(pam_handle_t *hndl) {<br />

if (!hndl) return;<br />

pam_close_session(hndl, 0);<br />

pam_end(hndl, PAM_SUCCESS);<br />

}<br />

See Also<br />

• “Pluggable Authentication Modules” by A. G. Morgan: http://www.kernel.org/<br />

pub/linux/libs/pam/pre/doc/current-draft.txt<br />

• OpenPAM home page: http://openpam.sourceforge.net<br />

• Linux PAM home page: http://www.kernel.org/pub/linux/libs/pam/<br />

• Solaris PAM home page: http://wwws.sun.com/software/solaris/pam/<br />

8.13 Authenticating with Kerberos<br />

<strong>Problem</strong><br />

You need to authenticate using Kerberos.<br />

Solution<br />

If the client and the server are operating within the same Kerberos realm (or in separate<br />

realms, but cross-realm authentication is possible), you can use the user’s credentials<br />

to authenticate from the client with the server. Both the client and the server<br />

must support this authentication method.<br />

The code presented in this recipe assumes you are using either the Heimdal or the<br />

MIT Kerberos implementation. It further assumes you are using Version 5, which we<br />

consider reasonable because Version 4 has been obsolete for so many years. We do<br />

not cover the Windows interface to Kerberos in this book because of the significant<br />

difference in the API compared to Heimdal and MIT implementations, as well as the<br />

complexity of the SSPI API that is required on Windows. We do, however, present<br />

an equivalent recipe for Windows on the book’s web site.<br />

Discussion<br />

First, we define a structure primarily for convenience. After a successful authentication,<br />

several pieces of information are passed back from the Kerberos API. We store<br />

414 | Chapter 8: Authentication and Key Exchange<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!