Skip to content

Commit

Permalink
Merge pull request #259 from zowe/staging
Browse files Browse the repository at this point in the history
merge staging into rc
  • Loading branch information
1000TurquoisePogs authored Nov 30, 2021
2 parents e67f025 + 135cec3 commit cf7a77b
Show file tree
Hide file tree
Showing 24 changed files with 1,336 additions and 411 deletions.
247 changes: 217 additions & 30 deletions c/crossmemory.c

Large diffs are not rendered by default.

34 changes: 18 additions & 16 deletions c/datasetjson.c
Original file line number Diff line number Diff line change
Expand Up @@ -1317,7 +1317,7 @@ static int getVolserForDataset(const DatasetName *dataset, Volser *volser) {
if (lParenIndex > -1 || asterixIndex > -1 || dollarIndex > -1){
return -1;
}
csi_parmblock *returnParms = (csi_parmblock*)safeMalloc(sizeof(csi_parmblock),"CSI ParmBlock");
csi_parmblock * __ptr32 returnParms = (csi_parmblock* __ptr32)safeMalloc31(sizeof(csi_parmblock),"CSI ParmBlock");
EntryDataSet *entrySet = returnEntries(dsnNullTerm, defaultDatasetTypesAllowed,3, 0, defaultCSIFields, defaultCSIFieldCount, NULL, NULL, returnParms);

EntryData *entry = entrySet->entries ? entrySet->entries[0] : NULL;
Expand All @@ -1343,11 +1343,11 @@ static int getVolserForDataset(const DatasetName *dataset, Volser *volser) {
safeFree((char*)(currentEntry),entrySize);
}
if (entrySet->entries != NULL) {
safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->length);
safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->size);
entrySet->entries = NULL;
}
safeFree((char*)entrySet,sizeof(EntryDataSet));
safeFree((char*)returnParms,sizeof(csi_parmblock));
safeFree31((char*)returnParms,sizeof(csi_parmblock));
return rc;
}

Expand Down Expand Up @@ -1649,7 +1649,7 @@ char getCSIType(char* absolutePath) {
int fieldCount = defaultCSIFieldCount;
char **csiFields = defaultCSIFields;

csi_parmblock *returnParms = (csi_parmblock*)safeMalloc(sizeof(csi_parmblock),"CSI ParmBlock");
csi_parmblock * __ptr32 returnParms = (csi_parmblock* __ptr32)safeMalloc31(sizeof(csi_parmblock),"CSI ParmBlock");

DatasetName datasetName;
DatasetMemberName memberName;
Expand Down Expand Up @@ -1941,7 +1941,7 @@ void respondWithVSAMDataset(HttpResponse* response, char* absolutePath, hashtabl

/* TODO: We should not need to do this on every call - only if the ACB needs to be opened */
/* TODO: How to access the CSI in cases where the entry is archived? Is this possible? */
csi_parmblock *returnParms = (csi_parmblock*)safeMalloc(sizeof(csi_parmblock),"CSI ParmBlock");
csi_parmblock * __ptr32 returnParms = (csi_parmblock* __ptr32)safeMalloc31(sizeof(csi_parmblock),"CSI ParmBlock");
EntryDataSet *entrySet = returnEntries(dsn, clusterTypesAllowed, clusterTypesCount, 0, defaultVSAMCSIFields, defaultVSAMCSIFieldCount, NULL, NULL, returnParms);
EntryData *entry = entrySet->entries[0];
if (entry){
Expand Down Expand Up @@ -1969,14 +1969,14 @@ void respondWithVSAMDataset(HttpResponse* response, char* absolutePath, hashtabl
safeFree((char*)(currentEntry),entrySize);
}
memset((char*)(entrySet->entries),0,sizeof(EntryData*)*entrySet->length);
safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->length);
safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->size);
memset((char*)entrySet,0,sizeof(EntryDataSet));
safeFree((char*)entrySet,sizeof(EntryDataSet));

EntryDataSet *entrySet = returnEntries(dsnData, clusterTypesAllowed, clusterTypesCount, 0, defaultVSAMCSIFields, defaultVSAMCSIFieldCount, NULL, NULL, returnParms);
entry = entrySet->entries[0];
} else if (entry->type != 'D') {
safeFree((char*)returnParms,sizeof(csi_parmblock));
safeFree31((char*)returnParms,sizeof(csi_parmblock));
for (int i = 0; i < entrySet->length; i++){
EntryData *currentEntry = entrySet->entries[i];
if (!(entrySet->entries)) break;
Expand Down Expand Up @@ -2026,7 +2026,7 @@ void respondWithVSAMDataset(HttpResponse* response, char* absolutePath, hashtabl
} /* end Catalog Search */
zowelog(NULL, LOG_COMP_RESTDATASET, ZOWE_LOG_DEBUG, "vsamType = 0x%0x, ciSize = %d, maxlrecl = %d, keyLoc = %d, keyLen = %d\n", vsamType, ciSize, maxlrecl, keyLoc, keyLen);

safeFree((char*)returnParms,sizeof(csi_parmblock));
safeFree31((char*)returnParms,sizeof(csi_parmblock));
for (int i = 0; i < entrySet->length; i++){
EntryData *currentEntry = entrySet->entries[i];
if (!(entrySet->entries)) break;
Expand All @@ -2038,7 +2038,7 @@ void respondWithVSAMDataset(HttpResponse* response, char* absolutePath, hashtabl
int entrySize = sizeof(EntryData)+fieldDataLength-4;
safeFree((char*)(currentEntry),entrySize);
}
safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->length);
safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->size);
safeFree((char*)entrySet,sizeof(EntryDataSet));

char *dsnUidPair = safeMalloc(44+8+1, "DSN,UID Pair Entry"); /* TODO: plug this leak for each time it is htPut below. */
Expand Down Expand Up @@ -2316,9 +2316,11 @@ void respondWithDatasetMetadata(HttpResponse *response) {

int fieldCount = defaultCSIFieldCount;
char **csiFields = defaultCSIFields;

csi_parmblock *returnParms = (csi_parmblock*)safeMalloc(sizeof(csi_parmblock),"CSI ParmBlock");
EntryDataSet *entrySet = returnEntries(dsnName.value, typesArg,datasetTypeCount, workAreaSizeArg, csiFields, fieldCount, resumeNameArg, resumeCatalogNameArg, returnParms);
char dsnNameNullTerm[45] = {0};
memcpy(dsnNameNullTerm, dsnName.value, sizeof(dsnName.value));
nullTerminate(dsnNameNullTerm, sizeof(dsnNameNullTerm) - 1);
csi_parmblock * __ptr32 returnParms = (csi_parmblock* __ptr32)safeMalloc31(sizeof(csi_parmblock),"CSI ParmBlock");
EntryDataSet *entrySet = returnEntries(dsnNameNullTerm, typesArg,datasetTypeCount, workAreaSizeArg, csiFields, fieldCount, resumeNameArg, resumeCatalogNameArg, returnParms);
char *resumeName = returnParms->resume_name;
char *catalogName = returnParms->catalog_name;
int isResume = (returnParms->is_resume == 'Y');
Expand Down Expand Up @@ -2402,8 +2404,8 @@ void respondWithDatasetMetadata(HttpResponse *response) {
}
jsonEnd(jPrinter);
finishResponse(response);
safeFree((char*)returnParms,sizeof(csi_parmblock));
safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->length);
safeFree31((char*)returnParms,sizeof(csi_parmblock));
safeFree((char*)(entrySet->entries),sizeof(EntryData*)*entrySet->size);
safeFree((char*)entrySet,sizeof(EntryDataSet));
#endif /* __ZOWE_OS_ZOS */
}
Expand All @@ -2419,7 +2421,7 @@ void respondWithHLQNames(HttpResponse *response, MetadataQueryCache *metadataQue
jsonPrinter *jPrinter = respondWithJsonPrinter(response);
writeHeader(response);
EntryDataSet *hlqSet;
csi_parmblock **returnParmsArray;
csi_parmblock * __ptr32 * __ptr32 returnParmsArray;
char **csiFields = defaultCSIFields;
int fieldCount = defaultCSIFieldCount;

Expand Down Expand Up @@ -2452,7 +2454,7 @@ void respondWithHLQNames(HttpResponse *response, MetadataQueryCache *metadataQue
HttpRequestParam *workAreaSizeParam = getCheckedParam(request,"workAreaSize");
int workAreaSizeArg = (workAreaSizeParam ? workAreaSizeParam->intValue : 0);

returnParmsArray = (csi_parmblock**)safeMalloc(29*sizeof(csi_parmblock*),"CSI Parm Results");
returnParmsArray = (csi_parmblock* __ptr32 * __ptr32)safeMalloc31(29*sizeof(csi_parmblock* __ptr32),"CSI Parm Results");
hlqSet = getHLQs(typesArg, datasetTypeCount, workAreaSizeArg, csiFields, fieldCount, returnParmsArray);
}
jsonStart(jPrinter);
Expand Down
25 changes: 25 additions & 0 deletions c/discovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ DiscoveryContext *makeDiscoveryContext(ShortLivedHeap *outerSLH, ZOSModel *model
context->slh = slh;

context->model = model;
zowelog(NULL, LOG_COMP_DISCOVERY, ZOWE_LOG_DEBUG,
"mDCntxt() model=%p pSN=\'%.16s\'\n", model,
model ? model->privilegedServerName.nameSpacePadded : "");
if (model != NULL) {
context->privilegedServerName = model->privilegedServerName;
} else {
Expand Down Expand Up @@ -315,6 +318,25 @@ static int walkTCBs1(DiscoveryContext *context,
return 0;
}


int walkTCBs(DiscoveryContext *context,
ASCB *ascb,
TCB *tcb,
void (*visitor)(DiscoveryContext *discoveryContext,
void *visitorContext,
int depth,
ASCB *ascb,
TCB *tcb,
char *mustBeNull),
void *visitorContext){
if (ascb){
ASXB *asxb = (ASXB*)ascb->ascbasxb;
TCB *firstTCB = (TCB*)getStructCopy(context,ascb,0,asxb->asxbftcb,sizeof(TCB));
walkTCBs1(context,ascb,firstTCB,(TCB*)ANY_TCB,0,visitor,visitorContext,NULL);
}
}


static void visitSSCTEntry(DiscoveryContext *context,
SSCT *ssctChain, GDA *gda, int subsystemTypeMask,
char *specificBestName){
Expand Down Expand Up @@ -900,7 +922,10 @@ ZOSModel *makeZOSModel2(CrossMemoryServerName *privilegedServerName,

model->slowScanExpiry = DEFAULT_SSCT_INTERVAL;
if (privilegedServerName != NULL) {
zowelog(NULL, LOG_COMP_DISCOVERY, ZOWE_LOG_DEBUG,
"makeZOSModel case 1 %p\n", privilegedServerName);
model->privilegedServerName = *privilegedServerName;
dumpbuffer((char*)&(model->privilegedServerName),16);
} else {
model->privilegedServerName = zisGetDefaultServerName();
}
Expand Down
37 changes: 23 additions & 14 deletions c/httpserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2440,9 +2440,16 @@ static int proxyServe(HttpService *service,
static char *getCookieValue(HttpRequest *request, char *cookieName){
HttpHeader *cookieHeader = getHeader(request,"Cookie");
ShortLivedHeap *slh = request->slh;
char *cookieText = cookieHeader->nativeValue;
int cookieTextLength = strlen(cookieText);
int cookieNameLength = strlen(cookieName);
int cookieTextLength = 0;
int cookieNameLength = 0;
char *cookieText = NULL;
if (cookieHeader != NULL){
cookieText = cookieHeader->nativeValue;
cookieTextLength = strlen(cookieText);
cookieNameLength = strlen(cookieName);
} else{
return NULL;
}
int pos = 0;
while (pos<cookieTextLength){
if (isspace(cookieText[pos])) {
Expand Down Expand Up @@ -2499,7 +2506,7 @@ static int safAuthenticate(HttpService *service, HttpRequest *request, AuthRespo
}
}
if (traceAuth){
printf("safAuthenticate\n");
printf("safAutheniticate: authDataFound=%d\n",authDataFound);
}
if (authDataFound) {
ACEE *acee = NULL;
Expand Down Expand Up @@ -2532,7 +2539,6 @@ static int safAuthenticate(HttpService *service, HttpRequest *request, AuthRespo
int pwdCheckRC = 0, pwdCheckRSN = 0;
pwdCheckRC = zisCheckUsernameAndPassword(privilegedServerName,
request->username, request->password, &status);

authResponse->type = AUTH_TYPE_RACF;
authResponse->responseDetails.safStatus = status.safStatus;

Expand Down Expand Up @@ -2566,7 +2572,8 @@ static int safAuthenticate(HttpService *service, HttpRequest *request, AuthRespo

static int nativeAuth(HttpService *service, HttpRequest *request, AuthResponse *authResponse){
#ifdef __ZOWE_OS_ZOS
return safAuthenticate(service, request, authResponse);
int retValue = safAuthenticate(service, request, authResponse);
return retValue;
#else
#ifdef DEBUG_AUTH
printf("*** ERROR *** native auth not implemented for this platform\n");
Expand Down Expand Up @@ -2796,11 +2803,11 @@ static int64 getFineGrainedTime(){
#define SESSION_VALIDITY_IN_SECONDS 3600

//validitySec 0=not found, -1=no expiration, positive int=session in seconds
static int getGroupSessionValidity(int *groupId, const HttpServerConfig *config,
static int getGroupSessionValidity(int groupId, const HttpServerConfig *config,
int *validitySec, int *returnCode, int *reasonCode) {
int retVal = 0;
if (config->groupTimeouts) {
*validitySec = (int)htGet(config->groupTimeouts, (void*)groupId);
*validitySec = INT_FROM_POINTER(htGet(config->groupTimeouts, POINTER_FROM_INT(groupId)));
AUTH_TRACE("exp=%d for gid=%d\n",*validitySec, groupId);
if (*validitySec){
return 0;
Expand All @@ -2817,7 +2824,7 @@ static int getUserSessionValidity(char *username, const HttpServerConfig *config
int *validitySec, int *returnCode, int *reasonCode) {
strupcase(username); /* upfold username */
if (config->userTimeouts) {
*validitySec = (int)htGet(config->userTimeouts, (void*)username);
*validitySec = INT_FROM_POINTER(htGet(config->userTimeouts, (void*)username));
AUTH_TRACE("user validitySec found=%d\n",*validitySec);
if (*validitySec){
return 0;
Expand All @@ -2834,8 +2841,7 @@ static int getUserSessionValidity(char *username, const HttpServerConfig *config
if (!retVal) {
int currentValiditySec = 0;
for (int i = 0; i < groupCount; i++) {
retVal = getGroupSessionValidity(POINTER_FROM_INT(groups[i]), config, &currentValiditySec, returnCode, reasonCode);

retVal = getGroupSessionValidity(groups[i], config, &currentValiditySec, returnCode, reasonCode);
if (!retVal) {
if (currentValiditySec && *validitySec != -1 && ((currentValiditySec == -1) || (currentValiditySec > *validitySec))) {
*validitySec = currentValiditySec;
Expand Down Expand Up @@ -3291,6 +3297,10 @@ static void serveRequest(HttpService* service, HttpResponse* response,
serveSimpleTemplate(service, response);
// Response is finished on return
} else {
/*
bills
try normal login and trace with Sean
*/
service->serviceFunction(service, response);
}
}
Expand Down Expand Up @@ -3354,7 +3364,6 @@ static int handleHttpService(HttpServer *server,
HttpService *service,
HttpRequest *request,
HttpResponse *response){

#ifdef __ZOWE_OS_ZOS
HttpConversation *conversation = response->conversation;

Expand Down Expand Up @@ -3395,11 +3404,9 @@ static int handleHttpService(HttpServer *server,
service->server = server;

int clearSessionToken = FALSE;

AuthResponse authResponse;

switch (service->authType){

case SERVICE_AUTH_NONE:
request->authenticated = TRUE;
break;
Expand Down Expand Up @@ -3883,6 +3890,8 @@ static MimeType MIME_TYPES[] = {
{"md", "text/markdown", FALSE},
{"sh", "application/x-sh", FALSE},
{"bin", "application/octet-stream", TRUE},
{"o", "application/octet-stream", TRUE},
{"dbg", "application/octet-stream", TRUE},
{"gz", "application/gzip", TRUE},
{"jar", "application/java-archive", TRUE},
{"tar", "application/x-tar", TRUE},
Expand Down
Loading

0 comments on commit cf7a77b

Please sign in to comment.