21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

each of these pieces of information in a single structure rather than adding several<br />

additional arguments to our authentication functions.<br />

#include <br />

typedef struct {<br />

krb5_context ctx;<br />

krb5_auth_context auth_ctx;<br />

krb5_ticket *ticket;<br />

} spc_krb5bundle_t;<br />

On the client side, only the ctx and auth_ctx fields will be initialized. On the server<br />

side, all three fields will be initialized. Before passing an spc_krb5bundle_t object to<br />

either spc_krb5_client( ) or spc_krb5_server( ), you must ensure that auth_ctx and<br />

ticket are initialized to NULL. If the ctx field is not NULL, it should be a valid krb5_<br />

context object, which will be used instead of creating a new one.<br />

Both the client and the server must be able to handle using Kerberos authentication.<br />

The code required for each side of the connection is very similar. On the client side,<br />

spc_krb5_client( ) will attempt to authenticate with the server. The code assumes<br />

that the user has already obtained a ticket-granting ticket from the appropriate Key<br />

Distribution Center (KDC), and that a credentials cache exists.<br />

The function spc_krb5_client( ) has the following signature:<br />

krb5_error_code spc_krb5_client(int sockfd, spc_krb5bundle_t *bundle,<br />

char *service, char *host, char *version);<br />

This function has the following arguments:<br />

sockfd<br />

Socket descriptor over which the authentication should be performed. The connection<br />

to the server should already be established, and the socket should be in<br />

blocking mode.<br />

bundle<br />

spc_krb5bundle_t object that will be loaded with information if the authentication<br />

with the server is successful. Before calling spc_krb5_client( ), you should<br />

be sure to zero the contents of this structure. If the structure contains a pointer<br />

to a Kerberos context object, spc_krb5_client( ) will use it instead of creating a<br />

new one.<br />

service<br />

Name component of the server’s principal. It is combined with the server’s hostname<br />

or instance to build the principal for the server. The server’s principal will<br />

be of the form service/host@REALM. The realm is assumed to be the user’s default<br />

realm.<br />

host<br />

Hostname of the server. It is used as the instance component of the server’s principal.<br />

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

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.<br />

Authenticating with Kerberos | 415

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

Saved successfully!

Ooh no, something went wrong!