Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

lcmaps_gss_assist_gridmap.c

Go to the documentation of this file.
00001 /*                                                                                                            
00002  * Copyright (c) 2001 EU DataGrid.                                                                             
00003  * For license conditions see http://www.eu-datagrid.org/license.html                                          
00004  *
00005  * Copyright (c) 2001, 2002 by 
00006  *     Martijn Steenbakkers <martijn@nikhef.nl>,
00007  *     David Groep <davidg@nikhef.nl>,
00008  *     NIKHEF Amsterdam, the Netherlands
00009  */
00010 
00022 #include "lcmaps_config.h"
00023 #include <stdio.h>
00024 #include <stdlib.h>
00025 #include <string.h>
00026 #include <gssapi.h>
00027 #include <pwd.h>
00028 
00029 /* LCMAPS includes */
00030 #include "lcmaps.h"
00031 #include "lcmaps_log.h"
00032 #include "lcmaps_cred_data.h"
00033 
00034 int
00035 globus_gss_assist_gridmap(
00036     char *   globusidp,
00037     char **  useridp
00038 )
00039 {
00040     uid_t *          uid;
00041     int              cntUid;
00042     struct passwd *  user_info   = NULL;
00043 
00044     FILE *   usrlog_fp=stderr;
00045     int retval;
00046 
00047     fprintf(stderr,"Using globus_gss_assist_gridmap interface of LCMAPS\n");
00048     if (useridp == NULL)
00049         return 1;
00050 
00051     *useridp = NULL;
00052 
00053     /* Initialize, do user mapping and terminate LCMAPS */
00054     retval=lcmaps_init(usrlog_fp);
00055     if (retval)
00056     {
00057         fprintf(stderr,"LCMAPS initialization failure.\n");
00058         return 1;
00059     }
00060     retval=lcmaps_run_without_credentials(globusidp);
00061     if (retval)
00062     {
00063         fprintf(stderr,"LCMAPS failed to map the user credential\n");
00064         return 1;
00065     }
00066     /* Now try to get the userid drom the credential data */
00067     uid    = getCredentialData(UID,     &cntUid);
00068     if (uid)
00069     {
00070         if ( (user_info = getpwuid(uid[0])) == NULL )
00071         {
00072             fprintf(stderr,"LCMAPS could not find the username related to uid: %d\n",uid[0]);
00073             return 1;
00074         }
00075         (*useridp) = strdup(user_info->pw_name);
00076     }
00077     else
00078     {
00079         fprintf(stderr,"LCMAPS could not find any uid\n");
00080         return 1;
00081     }
00082 
00083     retval=lcmaps_term();
00084     if (retval)
00085     {
00086         fprintf(stderr,"LCMAPS termination failure\n");
00087         return 1;
00088     }
00089     fprintf(stderr,"globus_gss_assist_gridmap interface of LCMAPS done\n");
00090 
00091     return 0;
00092 }
00093 
00094 /******************************************************************************
00095 CVS Information:
00096     $Source: /cvs/fabric_mgt/gridification/lcmaps/src/lcmaps_gss_assist_gridmap.c,v $
00097     $Date: 2003/08/19 14:50:34 $
00098     $Revision: 1.3 $
00099     $Author: martijn $
00100 ******************************************************************************/

Generated at Thu Mar 4 17:39:03 2004 for edg-lcmaps by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001