00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "reGlobalsExtern.h"
00011 #include "icatHighLevelRoutines.h"
00012 #include "generalAdmin.h"
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
00053
00054 int msiCreateUser(ruleExecInfo_t *rei)
00055 {
00056 int i;
00057
00058 if (reTestFlag > 0 ) {
00059 if (reTestFlag == COMMAND_TEST_1 || reTestFlag == HTML_TEST_1) {
00060 print_uoi(rei->uoio);
00061 }
00062 else {
00063 rodsLog (LOG_NOTICE," Calling msiCreateUser For \n");
00064 print_uoi(rei->uoio);
00065 }
00066 if (reLoopBackFlag > 0) {
00067 rodsLog (LOG_NOTICE,
00068 " Test mode, returning without performing normal operations (chlRegUserRE)");
00069 return(0);
00070 }
00071 }
00072
00073
00074 #ifdef RODS_CAT
00075 i = chlRegUserRE(rei->rsComm, rei->uoio);
00076 #else
00077 i = SYS_NO_ICAT_SERVER_ERR;
00078 #endif
00079 return(i);
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
00116
00117 int msiCreateCollByAdmin(msParam_t* xparColl, msParam_t* xchildName, ruleExecInfo_t *rei)
00118 {
00119 int i;
00120 collInfo_t collInfo;
00121 char *parColl;
00122 char *childName;
00123
00124 parColl = (char *) xparColl->inOutStruct;
00125 childName = (char *) xchildName->inOutStruct;
00126
00127 if (reTestFlag > 0 ) {
00128 if (reTestFlag == COMMAND_TEST_1 || reTestFlag == HTML_TEST_1) {
00129 fprintf(stdout," NewCollection =%s/%s\n",
00130 parColl,childName);
00131 }
00132 else {
00133 rodsLog (LOG_NOTICE," Calling msiCreateCollByAdmin Coll: %s/%s\n",
00134 parColl,childName);
00135 }
00136 if (reLoopBackFlag > 0) {
00137 rodsLog (LOG_NOTICE,
00138 " Test mode, returning without performing normal operations (chlRegCollByAdmin)");
00139 return(0);
00140 }
00141 }
00142
00143 memset(&collInfo, 0, sizeof(collInfo_t));
00144 snprintf(collInfo.collName, sizeof(collInfo.collName),
00145 "%s/%s",parColl,childName);
00146 snprintf(collInfo.collOwnerName, sizeof(collInfo.collOwnerName),
00147 "%s",rei->uoio->userName);
00148 snprintf(collInfo.collOwnerZone, sizeof(collInfo.collOwnerZone),
00149 "%s",rei->uoio->rodsZone);
00150
00151
00152 #ifdef RODS_CAT
00153 i = chlRegCollByAdmin(rei->rsComm, &collInfo );
00154 #else
00155 i = SYS_NO_RCAT_SERVER_ERR;
00156 #endif
00157 return(i);
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
00194
00195 int msiDeleteCollByAdmin(msParam_t* xparColl, msParam_t* xchildName, ruleExecInfo_t *rei)
00196 {
00197 int i;
00198 collInfo_t collInfo;
00199 char *parColl;
00200 char *childName;
00201
00202 parColl = (char *) xparColl->inOutStruct;
00203 childName = (char *) xchildName->inOutStruct;
00204
00205 if (reTestFlag > 0 ) {
00206 if (reTestFlag == COMMAND_TEST_1 || reTestFlag == HTML_TEST_1) {
00207 fprintf(stdout," NewCollection =%s/%s\n",
00208 parColl,childName);
00209 }
00210 else {
00211 rodsLog (LOG_NOTICE," Calling msiDeleteCallByAdmin Coll: %s/%s\n",
00212 parColl,childName);
00213 }
00214 rodsLog (LOG_NOTICE,
00215 " Test mode, returning without performing normal operations (chlDelCollByAdmin)");
00216 return(0);
00217 }
00218
00219
00220 snprintf(collInfo.collName, sizeof(collInfo.collName),
00221 "%s/%s",parColl,childName);
00222 snprintf(collInfo.collOwnerName, sizeof(collInfo.collOwnerName),
00223 "%s",rei->uoio->userName);
00224 snprintf(collInfo.collOwnerZone, sizeof(collInfo.collOwnerZone),
00225 "%s",rei->uoio->rodsZone);
00226
00227 #ifdef RODS_CAT
00228 i = chlDelCollByAdmin(rei->rsComm, &collInfo );
00229 #else
00230 i = SYS_NO_RCAT_SERVER_ERR;
00231 #endif
00232 if (i == CAT_UNKNOWN_COLLECTION) {
00233
00234
00235
00236 freeRErrorContent(&rei->rsComm->rError);
00237 return(0);
00238 }
00239 return(i);
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
00274
00275 int
00276 msiDeleteUser(ruleExecInfo_t *rei)
00277 {
00278 int i;
00279
00280 if (reTestFlag > 0 ) {
00281 if (reTestFlag == COMMAND_TEST_1 || reTestFlag == HTML_TEST_1) {
00282 print_uoi(rei->uoio);
00283 }
00284 else {
00285 rodsLog (LOG_NOTICE," Calling chlDeleteUser For \n");
00286 print_uoi(rei->uoio);
00287 }
00288 rodsLog (LOG_NOTICE,
00289 " Test mode, returning without performing normal operations (chlDelUserRE)");
00290 return(0);
00291 }
00292
00293
00294 #ifdef RODS_CAT
00295 i = chlDelUserRE(rei->rsComm, rei->uoio);
00296 #else
00297 i = SYS_NO_RCAT_SERVER_ERR;
00298 #endif
00299 return(i);
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
00335
00336 int
00337 msiAddUserToGroup(msParam_t *msParam, ruleExecInfo_t *rei)
00338 {
00339 int i;
00340 #ifdef RODS_CAT
00341 char *groupName;
00342 #endif
00343 if (reTestFlag > 0 ) {
00344 if (reTestFlag == COMMAND_TEST_1 || reTestFlag == HTML_TEST_1) {
00345 print_uoi(rei->uoio);
00346 }
00347 else {
00348 rodsLog (LOG_NOTICE," Calling chlModGroup For \n");
00349 print_uoi(rei->uoio);
00350 }
00351 rodsLog (LOG_NOTICE,
00352 " Test mode, returning without performing normal operations (chlModGroup)");
00353 return(0);
00354 }
00355 #ifdef RODS_CAT
00356 if (strncmp(rei->uoio->userType,"rodsgroup",9)==0) {
00357 return(0);
00358 }
00359 groupName = (char *) msParam->inOutStruct;
00360 i = chlModGroup(rei->rsComm, groupName, "add", rei->uoio->userName,
00361 rei->uoio->rodsZone);
00362 #else
00363 i = SYS_NO_RCAT_SERVER_ERR;
00364 #endif
00365 return(i);
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
00402
00403 int
00404 msiRenameLocalZone(msParam_t* oldName, msParam_t* newName, ruleExecInfo_t *rei)
00405 {
00406 int status;
00407 char *oldNameStr;
00408 char *newNameStr;
00409
00410 oldNameStr = (char *) oldName->inOutStruct;
00411 newNameStr = (char *) newName->inOutStruct;
00412 #ifdef RODS_CAT
00413 status = chlRenameLocalZone(rei->rsComm, oldNameStr, newNameStr);
00414 #else
00415 status = SYS_NO_RCAT_SERVER_ERR;
00416 #endif
00417 return(status);
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
00454
00455 int
00456 msiRenameCollection(msParam_t* oldName, msParam_t* newName, ruleExecInfo_t *rei)
00457 {
00458 int status;
00459 char *oldNameStr;
00460 char *newNameStr;
00461
00462 oldNameStr = (char *) oldName->inOutStruct;
00463 newNameStr = (char *) newName->inOutStruct;
00464 #ifdef RODS_CAT
00465 status = chlRenameColl(rei->rsComm, oldNameStr, newNameStr);
00466 #else
00467 status = SYS_NO_RCAT_SERVER_ERR;
00468 #endif
00469 return(status);
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
00509
00510 int
00511 msiAclPolicy(msParam_t *msParam, ruleExecInfo_t *rei)
00512 {
00513 #if 0
00514 msParamArray_t *myMsParamArray;
00515 int flag=1;
00516 #endif
00517 char *inputArg;
00518
00519 inputArg = (char *) msParam->inOutStruct;
00520 if (inputArg != NULL) {
00521 if (strncmp(inputArg,"STRICT",6)==0) {
00522 #if 0
00523
00524
00525
00526
00527
00528
00529 myMsParamArray = mallocAndZero (sizeof (msParamArray_t));
00530 addMsParamToArray (myMsParamArray, "STRICT", INT_MS_T, &flag,
00531 NULL, 0);
00532 rei->inOutMsParamArray=*myMsParamArray;
00533 #endif
00534 #ifdef RODS_CAT
00535 chlGenQueryAccessControlSetup(NULL, NULL, 0, 2);
00536 #endif
00537 }
00538 }
00539 else {
00540 #ifdef RODS_CAT
00541 chlGenQueryAccessControlSetup(NULL, NULL, 0, 0);
00542 #endif
00543 }
00544 return (0);
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
00587
00588 int
00589 msiSetQuota(msParam_t *type, msParam_t *name, msParam_t *resource, msParam_t *value, ruleExecInfo_t *rei)
00590 {
00591 generalAdminInp_t generalAdminInp;
00592 char quota[21];
00593 int status;
00594
00595
00596
00597 RE_TEST_MACRO (" Calling msiSetQuota")
00598
00599
00600 if (rei == NULL || rei->rsComm == NULL)
00601 {
00602 rodsLog (LOG_ERROR, "msiSetQuota: input rei or rsComm is NULL.");
00603 return (SYS_INTERNAL_NULL_INPUT_ERR);
00604 }
00605
00606
00607
00608 if (rei->uoic->authInfo.authFlag < LOCAL_PRIV_USER_AUTH)
00609 {
00610 status = CAT_INSUFFICIENT_PRIVILEGE_LEVEL;
00611 rodsLog (LOG_ERROR, "msiSetQuota: User %s is not local admin. Status = %d",
00612 rei->uoic->userName, status);
00613 return(status);
00614 }
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629 memset (&generalAdminInp, 0, sizeof(generalAdminInp_t));
00630 generalAdminInp.arg0 = "set-quota";
00631
00632
00633 generalAdminInp.arg1 = parseMspForStr(type);
00634 if (strcmp(generalAdminInp.arg1, "user") && strcmp(generalAdminInp.arg1, "group"))
00635 {
00636 status = USER_BAD_KEYWORD_ERR;
00637 rodsLog (LOG_ERROR, "msiSetQuota: Invalid user type: %s. Valid types are \"user\" and \"group\"",
00638 generalAdminInp.arg1);
00639 return(status);
00640 }
00641
00642
00643 generalAdminInp.arg2 = parseMspForStr(name);
00644
00645
00646 if ((generalAdminInp.arg3 = parseMspForStr(resource)) == NULL)
00647 {
00648 generalAdminInp.arg3 = "total";
00649 }
00650
00651
00652 if (value->type && !strcmp(value->type, STR_MS_T))
00653 {
00654 generalAdminInp.arg4 = (char *)value->inOutStruct;
00655 }
00656 else if (value->type && !strcmp(value->type, INT_MS_T) )
00657 {
00658 snprintf(quota, 11,"%d", *(int *)value->inOutStruct);
00659 generalAdminInp.arg4 = quota;
00660 }
00661 else if (value->type && !strcmp(value->type, DOUBLE_MS_T))
00662 {
00663 snprintf(quota, 21,"%lld", *(rodsLong_t *)value->inOutStruct);
00664 generalAdminInp.arg4 = quota;
00665 }
00666 else
00667 {
00668 status = USER_PARAM_TYPE_ERR;
00669 rodsLog (LOG_ERROR, "msiSetQuota: Invalid type for param value. Status = %d", status);
00670 return(status);
00671 }
00672
00673
00674 generalAdminInp.arg5 = "";
00675 generalAdminInp.arg6 = "";
00676 generalAdminInp.arg7 = "";
00677 generalAdminInp.arg8 = "";
00678 generalAdminInp.arg9 = "";
00679
00680
00681
00682 status = rsGeneralAdmin (rei->rsComm, &generalAdminInp);
00683
00684
00685
00686 return status;
00687 }
00688