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

jobrep_test.c

00001 /* LCMAPS includes */
00002 #include "lcmaps_types.h"
00003 #include "lcmaps_log.h"
00004 #include "../../src/pluginmanager/_lcmaps_log.h"
00005 #include "lcmaps_arguments.h"
00006 #include "../../src/pluginmanager/_lcmaps_cred_data.h"
00007 #include <stdlib.h>
00008 #include <stdio.h>
00009 #include "jobrep_test.h"
00010 #include "gssapi.h"
00011 #include "globus_gss_assist.h"
00012 #include <pwd.h>
00013 
00014 #define DO_USRLOG           ((unsigned short)0x0001) 
00016 #define DO_SYSLOG           ((unsigned short)0x0002) 
00019 #define USE_VOMS_TEST_PROXY 1
00020 
00021 #if USE_VOMS_TEST_PROXY
00022 static gss_cred_id_t credential_handle = GSS_C_NO_CREDENTIAL;
00023 #endif
00024 
00025 
00026 int main()
00027 {
00028     int argc;
00029     char *              username    = "okoeroo";
00030     char *              job_request = "JOBREQUEST \" blabla \", dkdkdka";
00031     struct passwd       *user_info  = NULL;
00032     int                 i           = 0;
00033     //int                 cnt_sec_gid = 0;
00034     gid_t               sec_gid     = 0; 
00035     lcmaps_argument_t *args      = NULL;
00036     char              *init_argv[] = {"voms.mod", "-vomsdir", "/etc/grid-security", "-certdir", "/etc/grid-security/certificates",
00037 //                                      "DSN=jobrep", "HOST=tbn13.nikhef.nl", "USER=root", "PASS=nikhef"};
00038                                       "HOST=tbn13.nikhef.nl", "USER=lcmaps_jobrep", "PASS=jobrep_lcmaps", "DRIVER=/usr/local/lib/libmyodbc3.so"};
00039 
00040 
00041     char              *user_dn   = "/O=dutchgrid/O=users/O=nikhef/CN=Oscar Koeroo";
00042         setenv("X509_USER_PROXY","/tmp/x509up_u505",1); // okoeroo
00043 //    char              *user_dn   = "/O=dutchgrid/O=users/O=nikhef/CN=Martijn Steenbakkers";
00044 //        setenv("X509_USER_PROXY","/home/okoeroo/x509up_u500",1); // martijn
00045 //    char              *user_dn   = "/O=dutchgrid/O=users/O=nikhef/CN=Gerben Michiel Venekamp";
00046 //        setenv("X509_USER_PROXY","/home/okoeroo/x509up_u506",1); // venekamp
00047 
00048 
00049     if (lcmaps_log_open(NULL,stdout,DO_USRLOG)) return 1;
00050 
00051     lcmaps_log_debug(0,"\n");
00052     lcmaps_log(LOG_NOTICE,"Initialization test\n");
00053 
00054 #if USE_VOMS_TEST_PROXY
00055     {
00056         OM_uint32 major_status;
00057         OM_uint32 minor_status;
00058     
00059         major_status = globus_gss_assist_acquire_cred(&minor_status,
00060                                                       GSS_C_INITIATE, /* or GSS_C_ACCEPT */
00061                                                       &credential_handle);
00062 
00063         if (major_status != GSS_S_COMPLETE)
00064         {
00065             globus_gss_assist_display_status(stderr,
00066                                              "Some failure message here",
00067                                              major_status,
00068                                              minor_status,
00069                                              0);
00070             return 1;
00071         }
00072     }
00073 #endif
00074 
00075     user_info = getpwnam(username);
00076 
00077     addCredentialData(UID, &(user_info->pw_uid));
00078     addCredentialData(PRI_GID, &(user_info->pw_gid));
00079     /*
00080      * Retrieve secondary group id's
00081      */
00082     sec_gid = (user_info->pw_gid);
00083     for (i = 0; i < 10; i++)
00084     {
00085         addCredentialData(SEC_GID, &sec_gid);
00086         sec_gid++;
00087     }
00088 
00089     plugin_initialize(9, init_argv);
00090     plugin_introspect(&argc, &args);
00091     
00092 
00093     if (lcmaps_setArgValue("job_request", "char *", (void *) &job_request, argc, &args) != 0)
00094     {
00095         lcmaps_log(0,
00096                "lcmaps.mod-runPluginManager(): could not SET requested variable \"%s\" of type \"%s\" for plugin \"%s\"\n",
00097                "job_request", "char *", "jobrepository");
00098         return 1;
00099     }
00100 
00101 
00102     if (lcmaps_setArgValue("user_dn", "char *", (void *) &user_dn, argc, &args) != 0)
00103     {
00104         lcmaps_log(0,
00105                "lcmaps.mod-runPluginManager(): could not SET requested variable \"%s\" of type \"%s\" for plugin \"%s\"\n",
00106                "user_dn", "char *", "jobrep");
00107         return 1;
00108     }
00109     if (lcmaps_setArgValue("user_cred", "gss_cred_id_t", (void *) &credential_handle, argc, &args) != 0)
00110     {
00111         lcmaps_log(0,
00112                "lcmaps.mod-runPluginManager(): could not SET requested variable \"%s\" of type \"%s\" for plugin \"%s\"\n",
00113                "user_cred", "gss_cred_id_t", "jobrep");
00114         return 1;
00115     }
00116     plugin_run(argc,args);
00117 
00118     // printCredData();
00119     if (cleanCredentialData()!=0)
00120     {
00121         lcmaps_log(0,"lcmaps.mod-stopPluginManager() error: could not clean credential data list\n");
00122         return 1;
00123     }
00124     plugin_terminate();
00125     return 0;
00126 }

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