31
31
jobrep_assign_userid(struct jr_db_handle_s *db_handle, STACK_OF(X509) *px509_chain, char *eec_subject_dn) {
32
int user_id = -1, cert_id = -1;
33
34
int i = 0, depth = 0;
35
36
char *subject_DN = NULL, *issuer_DN = NULL;
233
235
goto fail_jobrep;
235
237
/* The VOMS FQAN must exist in the database! */
236
if (SQL_Query(db_handle) < 0) {
238
ret=SQL_Query(db_handle);
239
if (!SQL_SUCCEEDED(ret)) {
237
240
lcmaps_log(LOG_ERR, "%s: Failed to execute the query to fetch the voms_fqan_id from the voms_fqans.\n", __func__);
238
241
goto fail_jobrep;
263
266
return voms_fqan_id;
269
/* Next function is not used, commenting out */
267
272
jobrep_get_unix_uid_id_from_uid(struct jr_db_handle_s *db_handle, uid_t uid, char *uid_name) {
268
int unix_uid_id = -1;
273
long unix_uid_id = -1;
270
if ((db_handle == NULL) || (uid < 0)) {
276
if (db_handle == NULL) {
294
300
/* The (Unix) UID must exist in the database! */
295
if (SQL_Query(db_handle) < 0) {
301
ret=SQL_Query(db_handle);
302
if (!SQL_SUCCEEDED(ret)) {
296
303
lcmaps_log(LOG_ERR, "%s: Failed to execute the query to fetch the unix_uid_id from the unix_uids.\n", __func__);
297
304
goto fail_jobrep;
353
362
/* The (Unix) GID must exist in the database! */
354
if (SQL_Query(db_handle) < 0) {
363
ret=SQL_Query(db_handle);
364
if (!SQL_SUCCEEDED(ret)) {
355
365
lcmaps_log(LOG_ERR, "%s: Failed to execute the query to fetch the unix_gid_id from the unix_gids.\n", __func__);
356
366
goto fail_jobrep;
381
391
return unix_gid_id;
385
jobrep_insert_unix_uid_voms_fqans(struct jr_db_handle_s *db_handle, int voms_fqan_id, int unix_uid_id) {
395
jobrep_insert_unix_uid_voms_fqans(struct jr_db_handle_s *db_handle, long voms_fqan_id, long unix_uid_id) {
386
396
char *reg_datetime = NULL;
387
int unix_uid_voms_fqan_id = -1;
397
long unix_uid_voms_fqan_id = -1;
389
399
if ((db_handle == NULL) || (voms_fqan_id < 0) || (unix_uid_id < 0)) {
467
jobrep_insert_unix_gid_voms_fqans(struct jr_db_handle_s *db_handle, int voms_fqan_id, int unix_gid_id, int is_primary) {
477
jobrep_insert_unix_gid_voms_fqans(struct jr_db_handle_s *db_handle, long voms_fqan_id, long unix_gid_id, int is_primary) {
468
478
char *reg_datetime = NULL;
469
int unix_gid_voms_fqan_id = -1;
479
long unix_gid_voms_fqan_id = -1;
471
481
if ((db_handle == NULL) || (voms_fqan_id < 0) || (unix_gid_id < 0)) {
557
567
jobrep_create_effective_credentials_main(struct jr_db_handle_s *db_handle) {
558
568
char *reg_datetime = NULL;
559
int eff_cred_id = -1;
569
long eff_cred_id = -1;
561
571
/*** Insert the effective_credentials ***/
562
572
if (SQL_Prepare(db_handle,
618
jobrep_push_voms_fqans(struct jr_db_handle_s *db_handle, int eff_cred_id) {
628
jobrep_push_compute_job_info(struct jr_db_handle_s *db_handle, long eff_cred_id, char *gatekeeper_jm_id) {
629
if (db_handle == NULL || eff_cred_id == -1 || gatekeeper_jm_id == NULL) {
633
/*** Insert the effective_credentials ***/
634
if (SQL_Prepare(db_handle,
635
(unsigned char *)"insert into compute_jobs (eff_cred_id, gatekeeper_jm_id) values (?, ?)") < 0) {
636
lcmaps_log(LOG_ERR, "%s: Failed to prepare a query to insert a compute_jobs record into \"compute_jobs\"\n", __func__);
640
/* Bind data to Query */
641
if (SQL_BindParam(db_handle, 1, SQL_C_LONG, SQL_INTEGER, &eff_cred_id) < 0) {
642
lcmaps_log(LOG_ERR, "%s: Unable to bind the \"eff_cred_id\" value to the query\n", __func__);
645
if (SQL_BindParam(db_handle, 2, SQL_C_CHAR, SQL_VARCHAR, gatekeeper_jm_id) < 0) {
646
lcmaps_log(LOG_ERR, "%s: Unable to bind the \"GATEKEEPER_JM_ID\" value to the query\n", __func__);
650
/* Fail on existance */
654
SQL_QueryCloseAndClean(db_handle);
662
jobrep_push_voms_fqans(struct jr_db_handle_s *db_handle, long eff_cred_id) {
620
664
lcmaps_vo_mapping_t *vo_mapping = NULL;
621
665
int cnt_vo_mapping = 0;
622
int voms_fqan_id = -1;
623
int unix_gid_id = -1;
666
long voms_fqan_id = -1;
667
long unix_gid_id = -1;
624
668
int is_primary = 0;
625
int unix_gid_voms_fqan_id = -1;
669
long unix_gid_voms_fqan_id = -1;
627
671
if (db_handle == NULL) {
708
jobrep_push_effective_credential_user(struct jr_db_handle_s *db_handle, int user_id, int eff_cred_id) {
752
jobrep_push_effective_credential_user(struct jr_db_handle_s *db_handle, long user_id, long eff_cred_id) {
709
753
if ((db_handle == NULL) || (user_id < 0) || (eff_cred_id < 0)) {
744
jobrep_push_effective_credential_unix_uid(struct jr_db_handle_s *db_handle, int unix_uid_id, int eff_cred_id) {
788
jobrep_push_effective_credential_unix_uid(struct jr_db_handle_s *db_handle, long unix_uid_id, long eff_cred_id) {
746
790
lcmaps_vo_mapping_t *vo_mapping = NULL;
747
791
int cnt_vo_mapping = 0;
748
int voms_fqan_id = -1;
792
long voms_fqan_id = -1;
749
793
/* int unix_uid_id = -1; */
750
int unix_uid_voms_fqan_id = -1;
794
long unix_uid_voms_fqan_id = -1;
752
796
if ((db_handle == NULL) || (unix_uid_id < 0) || (eff_cred_id < 0)) {
828
jobrep_push_effective_credential_unix_gid(struct jr_db_handle_s *db_handle, int unix_gid_id, int eff_cred_id, int is_primary) {
872
jobrep_push_effective_credential_unix_gid(struct jr_db_handle_s *db_handle, long unix_gid_id, long eff_cred_id, int is_primary) {
829
873
if ((db_handle == NULL) || (unix_gid_id < 0) || (eff_cred_id < 0)) {
868
jobrep_push_effective_credential_unix_gids(struct jr_db_handle_s *db_handle, int eff_cred_id) {
912
jobrep_push_effective_credential_unix_gids(struct jr_db_handle_s *db_handle, long eff_cred_id) {
870
914
gid_t *priGid = NULL;
871
915
int cntPriGid = 0;
872
916
gid_t *secGid = NULL;
873
917
int cntSecGid = 0;
874
918
struct group *group_info = NULL;
875
int unix_gid_id = -1;
919
long unix_gid_id = -1;
877
921
if ((db_handle == NULL) || (eff_cred_id < 0)) {
1224
temp = serialNumberDER = malloc(serialLen);
1269
/* Note: serialLen is int and >0 */
1270
temp = serialNumberDER = malloc((size_t)serialLen);
1225
1271
if (serialNumberDER == NULL) {
1226
1272
lcmaps_log(LOG_DEBUG, "%s: Could not allocate %d bytes\n", serialLen);
1230
1276
serialLen = i2c_ASN1_INTEGER(cert_Serial, &temp);
1232
1278
/* Allocate as a Hex decimal + null-terminator */
1233
len = serialLen * 2 + 1;
1279
len = (size_t)serialLen * 2 + 1;
1234
1280
serialStr = malloc(len);
1235
1281
if (serialStr == NULL) {
1236
1282
lcmaps_log(LOG_DEBUG, "%s: Could not allocate %d bytes\n", len);