00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 #include "lcas_config.h"
00085 #include <stdio.h>
00086 #include <stdlib.h>
00087 #include <string.h>
00088
00089 #if HAVE_MALLOC_H
00090 #include <malloc.h>
00091 #endif
00092
00093 #include "lcas_modules.h"
00094 #include "lcas_gridlist.h"
00095
00096
00097
00098
00099 static char * modname="lcas_userban.mod";
00100 static char * userban_db = NULL;
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 #if 0
00116 int plugin_initialize(char * plugin_db)
00117 #endif
00118 int plugin_initialize(int argc, char ** argv)
00119 {
00120 int i;
00121
00122 lcas_log_debug(2,"%s-plugin_initialize(): passed arguments:\n",modname);
00123 for (i=0; i < argc; i++)
00124 {
00125 lcas_log_debug(2,"%s-plugin_initialize(): arg %d is %s\n",
00126 modname,i,argv[i]);
00127 }
00128
00129 if (argc > 1)
00130 userban_db = lcas_findfile(argv[1]);
00131
00132
00133 if (userban_db == NULL)
00134 {
00135 lcas_log(0,"\t%s-plugin_initialize() error: banned user file required !\n",
00136 modname);
00137 return LCAS_MOD_NOFILE;
00138 }
00139 if (lcas_getfexist(1,userban_db) == NULL)
00140 {
00141 lcas_log(0,
00142 "\t%s-plugin_initialize() error: Cannot find banned user file: %s\n",
00143 modname,userban_db
00144 );
00145 return LCAS_MOD_NOFILE;
00146 }
00147 return LCAS_MOD_SUCCESS;
00148 }
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 int
00163 plugin_confirm_authorization(lcas_request_t request, lcas_cred_id_t lcas_cred)
00164 {
00165 int rc;
00166 char * dummy = NULL;
00167 char * user_dn = NULL;
00168
00169
00170
00171
00172 if ( (user_dn = lcas_get_dn(lcas_cred)) == NULL)
00173 {
00174 lcas_log(0, "lcas.mod-lcas_get_fabric_authorization() error: user DN empty\n");
00175 goto lcas_userban_noauth;
00176 }
00177
00178
00179 lcas_log_debug(0,"\t%s-plugin_confirm_authorization(): checking banned users in %s\n",
00180 modname,userban_db);
00181
00182 rc = lcas_gridlist(user_dn, &dummy, userban_db, MATCH_ONLY_DN, NULL, NULL);
00183
00184 if ( rc == LCAS_MOD_ENTRY )
00185 {
00186
00187 lcas_log_debug(0,"\t%s-plugin_confirm_authorization(): entry found for %s\n",
00188 modname,user_dn);
00189 goto lcas_userban_noauth;
00190 }
00191 else if ( rc == LCAS_MOD_NOFILE )
00192 {
00193
00194 lcas_log(0,
00195 "\t%s-plugin_confirm_authorization() error: Cannot find banned user file: %s\n",
00196 modname,userban_db);
00197 goto lcas_userban_nofile;
00198 }
00199
00200 lcas_userban_auth:
00201
00202 if (dummy != NULL) free(dummy);
00203 return LCAS_MOD_SUCCESS;
00204
00205 lcas_userban_noauth:
00206
00207 if (dummy != NULL) free(dummy);
00208 return LCAS_MOD_FAIL;
00209
00210 lcas_userban_nofile:
00211
00212 if (dummy != NULL) free(dummy);
00213 return LCAS_MOD_NOFILE;
00214 }
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226 int plugin_terminate()
00227 {
00228 lcas_log_debug(1,"%s-plugin_terminate(): terminating\n",modname);
00229 if (userban_db) { free(userban_db); userban_db=NULL; }
00230
00231 return LCAS_MOD_SUCCESS;
00232 }