00001
00002
00003
00004
00005
00006
00007
00008 #include "reGlobalsExtern.h"
00009 #include "icatHighLevelRoutines.h"
00010 #include "generalAdmin.h"
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 int msiCreateUser(ruleExecInfo_t *rei)
00053 {
00054 int i;
00055
00056 if (reTestFlag > 0 ) {
00057 if (reTestFlag == COMMAND_TEST_1 || reTestFlag == HTML_TEST_1) {
00058 print_uoi(rei->uoio);
00059 }
00060 else {
00061 rodsLog (LOG_NOTICE," Calling msiCreateUser For \n");
00062 print_uoi(rei->uoio);
00063 }
00064 if (reLoopBackFlag > 0) {
00065 rodsLog (LOG_NOTICE,
00066 " Test mode, returning without performing normal operations (chlRegUserRE)");
00067 return(0);
00068 }
00069 }
00070
00071
00072 #ifdef RODS_CAT
00073 i = chlRegUserRE(rei->rsComm, rei->uoio);
00074 #else
00075 i = SYS_NO_ICAT_SERVER_ERR;
00076 #endif
00077 return(i);
00078 }
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 int msiCreateCollByAdmin(msParam_t* xparColl, msParam_t* xchildName, ruleExecInfo_t *rei)
00116 {
00117 int i;
00118 collInfo_t collInfo;
00119 char *parColl;
00120 char *childName;
00121
00122 parColl = (char *) xparColl->inOutStruct;
00123 childName = (char *) xchildName->inOutStruct;
00124
00125 if (reTestFlag > 0 ) {
00126 if (reTestFlag == COMMAND_TEST_1 || reTestFlag == HTML_TEST_1) {
00127 fprintf(stdout," NewCollection =%s/%s\n",
00128 parColl,childName);
00129 }
00130 else {
00131 rodsLog (LOG_NOTICE," Calling msiCreateCollByAdmin Coll: %s/%s\n",
00132 parColl,childName);
00133 }
00134 if (reLoopBackFlag > 0) {
00135 rodsLog (LOG_NOTICE,
00136 " Test mode, returning without performing normal operations (chlRegCollByAdmin)");
00137 return(0);
00138 }
00139 }
00140
00141 memset(&collInfo, 0, sizeof(collInfo_t));
00142 snprintf(collInfo.collName, sizeof(collInfo.collName),
00143 "%s/%s",parColl,childName);
00144 snprintf(collInfo.collOwnerName, sizeof(collInfo.collOwnerName),
00145 "%s",rei->uoio->userName);
00146 snprintf(collInfo.collOwnerZone, sizeof(collInfo.collOwnerZone),
00147 "%s",rei->uoio->rodsZone);
00148
00149
00150 #ifdef RODS_CAT
00151 i = chlRegCollByAdmin(rei->rsComm, &collInfo );
00152 #else
00153 i = SYS_NO_RCAT_SERVER_ERR;
00154 #endif
00155 return(i);
00156 }
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193 int msiDeleteCollByAdmin(msParam_t* xparColl, msParam_t* xchildName, ruleExecInfo_t *rei)
00194 {
00195 int i;
00196 collInfo_t collInfo;
00197 char *parColl;
00198 char *childName;
00199
00200 parColl = (char *) xparColl->inOutStruct;
00201 childName = (char *) xchildName->inOutStruct;
00202
00203 if (reTestFlag > 0 ) {
00204 if (reTestFlag == COMMAND_TEST_1 || reTestFlag == HTML_TEST_1) {
00205 fprintf(stdout," NewCollection =%s/%s\n",
00206 parColl,childName);
00207 }
00208 else {
00209 rodsLog (LOG_NOTICE," Calling msiDeleteCallByAdmin Coll: %s/%s\n",
00210 parColl,childName);
00211 }
00212 rodsLog (LOG_NOTICE,
00213 " Test mode, returning without performing normal operations (chlDelCollByAdmin)");
00214 return(0);
00215 }
00216
00217
00218 snprintf(collInfo.collName, sizeof(collInfo.collName),
00219 "%s/%s",parColl,childName);
00220 snprintf(collInfo.collOwnerName, sizeof(collInfo.collOwnerName),
00221 "%s",rei->uoio->userName);
00222 snprintf(collInfo.collOwnerZone, sizeof(collInfo.collOwnerZone),
00223 "%s",rei->uoio->rodsZone);
00224
00225 #ifdef RODS_CAT
00226 i = chlDelCollByAdmin(rei->rsComm, &collInfo );
00227 #else
00228 i = SYS_NO_RCAT_SERVER_ERR;
00229 #endif
00230 if (i == CAT_UNKNOWN_COLLECTION) {
00231
00232
00233
00234 freeRErrorContent(&rei->rsComm->rError);
00235 return(0);
00236 }
00237 return(i);
00238 }
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273 int
00274 msiDeleteUser(ruleExecInfo_t *rei)
00275 {
00276 int i;
00277
00278 if (reTestFlag > 0 ) {
00279 if (reTestFlag == COMMAND_TEST_1 || reTestFlag == HTML_TEST_1) {
00280 print_uoi(rei->uoio);
00281 }
00282 else {
00283 rodsLog (LOG_NOTICE," Calling chlDeleteUser For \n");
00284 print_uoi(rei->uoio);
00285 }
00286 rodsLog (LOG_NOTICE,
00287 " Test mode, returning without performing normal operations (chlDelUserRE)");
00288 return(0);
00289 }
00290
00291
00292 #ifdef RODS_CAT
00293 i = chlDelUserRE(rei->rsComm, rei->uoio);
00294 #else
00295 i = SYS_NO_RCAT_SERVER_ERR;
00296 #endif
00297 return(i);
00298 }
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334 int
00335 msiAddUserToGroup(msParam_t *msParam, ruleExecInfo_t *rei)
00336 {
00337 int i;
00338 #ifdef RODS_CAT
00339 char *groupName;
00340 #endif
00341 if (reTestFlag > 0 ) {
00342 if (reTestFlag == COMMAND_TEST_1 || reTestFlag == HTML_TEST_1) {
00343 print_uoi(rei->uoio);
00344 }
00345 else {
00346 rodsLog (LOG_NOTICE," Calling chlModGroup For \n");
00347 print_uoi(rei->uoio);
00348 }
00349 rodsLog (LOG_NOTICE,
00350 " Test mode, returning without performing normal operations (chlModGroup)");
00351 return(0);
00352 }
00353 #ifdef RODS_CAT
00354 if (strncmp(rei->uoio->userType,"rodsgroup",9)==0) {
00355 return(0);
00356 }
00357 groupName = (char *) msParam->inOutStruct;
00358 i = chlModGroup(rei->rsComm, groupName, "add", rei->uoio->userName,
00359 rei->uoio->rodsZone);
00360 #else
00361 i = SYS_NO_RCAT_SERVER_ERR;
00362 #endif
00363 return(i);
00364 }
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401 int
00402 msiRenameLocalZone(msParam_t* oldName, msParam_t* newName, ruleExecInfo_t *rei)
00403 {
00404 int status;
00405 char *oldNameStr;
00406 char *newNameStr;
00407
00408 oldNameStr = (char *) oldName->inOutStruct;
00409 newNameStr = (char *) newName->inOutStruct;
00410 #ifdef RODS_CAT
00411 status = chlRenameLocalZone(rei->rsComm, oldNameStr, newNameStr);
00412 #else
00413 status = SYS_NO_RCAT_SERVER_ERR;
00414 #endif
00415 return(status);
00416 }
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453 int
00454 msiRenameCollection(msParam_t* oldName, msParam_t* newName, ruleExecInfo_t *rei)
00455 {
00456 int status;
00457 char *oldNameStr;
00458 char *newNameStr;
00459
00460 oldNameStr = (char *) oldName->inOutStruct;
00461 newNameStr = (char *) newName->inOutStruct;
00462 #ifdef RODS_CAT
00463 status = chlRenameColl(rei->rsComm, oldNameStr, newNameStr);
00464 #else
00465 status = SYS_NO_RCAT_SERVER_ERR;
00466 #endif
00467 return(status);
00468 }
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508 int
00509 msiAclPolicy(msParam_t *msParam, ruleExecInfo_t *rei)
00510 {
00511 #if 0
00512 msParamArray_t *myMsParamArray;
00513 int flag=1;
00514 #endif
00515 char *inputArg;
00516
00517 inputArg = (char *) msParam->inOutStruct;
00518 if (inputArg != NULL) {
00519 if (strncmp(inputArg,"STRICT",6)==0) {
00520 #if 0
00521
00522
00523
00524
00525
00526
00527 myMsParamArray = mallocAndZero (sizeof (msParamArray_t));
00528 addMsParamToArray (myMsParamArray, "STRICT", INT_MS_T, &flag,
00529 NULL, 0);
00530 rei->inOutMsParamArray=*myMsParamArray;
00531 #endif
00532 #ifdef RODS_CAT
00533 chlGenQueryAccessControlSetup(NULL, NULL, 0, 2);
00534 #endif
00535 }
00536 }
00537 else {
00538 #ifdef RODS_CAT
00539 chlGenQueryAccessControlSetup(NULL, NULL, 0, 0);
00540 #endif
00541 }
00542 return (0);
00543 }
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586 int
00587 msiSetQuota(msParam_t *type, msParam_t *name, msParam_t *resource, msParam_t *value, ruleExecInfo_t *rei)
00588 {
00589 generalAdminInp_t generalAdminInp;
00590 char quota[21];
00591 int status;
00592
00593
00594
00595 RE_TEST_MACRO (" Calling msiSetQuota")
00596
00597
00598 if (rei == NULL || rei->rsComm == NULL)
00599 {
00600 rodsLog (LOG_ERROR, "msiSetQuota: input rei or rsComm is NULL.");
00601 return (SYS_INTERNAL_NULL_INPUT_ERR);
00602 }
00603
00604
00605
00606 if (rei->uoic->authInfo.authFlag < LOCAL_PRIV_USER_AUTH)
00607 {
00608 status = CAT_INSUFFICIENT_PRIVILEGE_LEVEL;
00609 rodsLog (LOG_ERROR, "msiSetQuota: User %s is not local admin. Status = %d",
00610 rei->uoic->userName, status);
00611 return(status);
00612 }
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627 memset (&generalAdminInp, 0, sizeof(generalAdminInp_t));
00628 generalAdminInp.arg0 = "set-quota";
00629
00630
00631 generalAdminInp.arg1 = parseMspForStr(type);
00632 if (strcmp(generalAdminInp.arg1, "user") && strcmp(generalAdminInp.arg1, "group"))
00633 {
00634 status = USER_BAD_KEYWORD_ERR;
00635 rodsLog (LOG_ERROR, "msiSetQuota: Invalid user type: %s. Valid types are \"user\" and \"group\"",
00636 generalAdminInp.arg1);
00637 return(status);
00638 }
00639
00640
00641 generalAdminInp.arg2 = parseMspForStr(name);
00642
00643
00644 if ((generalAdminInp.arg3 = parseMspForStr(resource)) == NULL)
00645 {
00646 generalAdminInp.arg3 = "total";
00647 }
00648
00649
00650 if (value->type && !strcmp(value->type, STR_MS_T))
00651 {
00652 generalAdminInp.arg4 = (char *)value->inOutStruct;
00653 }
00654 else if (value->type && !strcmp(value->type, INT_MS_T) )
00655 {
00656 snprintf(quota, 11,"%d", *(int *)value->inOutStruct);
00657 generalAdminInp.arg4 = quota;
00658 }
00659 else if (value->type && !strcmp(value->type, DOUBLE_MS_T))
00660 {
00661 snprintf(quota, 21,"%lld", *(rodsLong_t *)value->inOutStruct);
00662 generalAdminInp.arg4 = quota;
00663 }
00664 else
00665 {
00666 status = USER_PARAM_TYPE_ERR;
00667 rodsLog (LOG_ERROR, "msiSetQuota: Invalid type for param value. Status = %d", status);
00668 return(status);
00669 }
00670
00671
00672 generalAdminInp.arg5 = "";
00673 generalAdminInp.arg6 = "";
00674 generalAdminInp.arg7 = "";
00675 generalAdminInp.arg8 = "";
00676 generalAdminInp.arg9 = "";
00677
00678
00679
00680 status = rsGeneralAdmin (rei->rsComm, &generalAdminInp);
00681
00682
00683
00684 return status;
00685 }
00686