Skip to content

Commit

Permalink
Merge pull request #473 from zowe/users/jstruga/updatev3
Browse files Browse the repository at this point in the history
Sync v3 with new v2 changes
  • Loading branch information
1000TurquoisePogs authored Aug 9, 2024
2 parents eb8bd1e + 6c28859 commit 48c55b6
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-configmgr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ jobs:
- name: '[Dep 2] Quickjs'
uses: actions/checkout@v3
with:
repository: joenemo/quickjs-portable
repository: JoeNemo/quickjs-portable
path: deps/configmgr/quickjs
ref: 'main'

Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
# Zowe Common C Changelog


## `2.17.0`
- Fixed `xplatform.loadFileUTF8` when trying to open nonexistent file (#454)
- Bugfix: fix an incorrect check in the recovery router code which might lead to
the state cell-pool being released prematurely (#446)
- Allocating SLH for http server with configurable value 'httpRequestHeapMaxBlocks' in yaml (#447).
- Return error when last config file is non existent or has some error (#460).

## `2.16.0`
- No yaml value converted to null (#442)
- Added `zos.getZosVersion()` and `zos.getEsm()` calls for configmgr QJS (#429)
- For correct base64 encoding scheme the buffer size is made to be divisble by 3 (#431).
- Take into account leap seconds in xmem log messages' timestamps (#432, #433)
- Using a temporary buffer pointer to avoid pointer corruption during file write (#437).

## `2.15.0`
- Remove obsolete building script build_configmgr.sh (#410). (#423)
- Add flags to avoid linkage-stack queries in the recovery facility (#404, #412)

## `2.13.0`
- Added support for using "zowe.network" and "components.zss.zowe.network" to set TLS version properties. (#411)
Expand Down
112 changes: 0 additions & 112 deletions build/build_configmgr.sh

This file was deleted.

2 changes: 1 addition & 1 deletion build/configmgr.proj.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ VERSION=3.0.0
DEPS="QUICKJS LIBYAML"

QUICKJS="quickjs"
QUICKJS_SOURCE="[email protected]:joenemo/quickjs-portable.git"
QUICKJS_SOURCE="[email protected]:JoeNemo/quickjs-portable.git"
QUICKJS_BRANCH="main"

LIBYAML="libyaml"
Expand Down
5 changes: 4 additions & 1 deletion c/configmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ int cfgSetParmlibMemberName(ConfigManager *mgr, const char *configName, const ch
CFGConfig *config = getConfig(mgr,configName);
if (config){
int len = strlen(parmlibMemberName);
if (len < 3 || len > PARMLIB_MEMBER_MAX){
if (len < 1 || len > PARMLIB_MEMBER_MAX){
return ZCFG_BAD_PARMLIB_MEMBER_NAME;
} else {
config->parmlibMemberName = substring(mgr,(char*)parmlibMemberName,0,len);
Expand Down Expand Up @@ -827,6 +827,9 @@ static int overloadConfiguration(ConfigManager *mgr,
trace(mgr, DEBUG2, "at end of config path\n");
bool dontCare = false;
config->configData = readJson(mgr,config,pathElement,&dontCare);
if ((config->configData == NULL) && !dontCare){
return ZCFG_MISSING_CONFIG_SOURCE;
}
trace(mgr, DEBUG2, "mgr->config = 0x%p\n", config);
return 0; /* success */
} else {
Expand Down
10 changes: 9 additions & 1 deletion c/crossmemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,19 +510,27 @@ static void getSTCK(uint64 *stckValue) {
__asm(" STCK 0(%0)" : : "r"(stckValue));
}

int64 getLocalTimeOffset() {
static int64 getLocalTimeOffset(void) {
CVT * __ptr32 cvt = *(void * __ptr32 * __ptr32)0x10;
void * __ptr32 cvtext2 = cvt->cvtext2;
int64 *cvtldto = (int64 * __ptr32)(cvtext2 + 0x38);
return *cvtldto;
}

static int64 getLeapSecondsOffset(void) {
CVT * __ptr32 cvt = *(void * __ptr32 * __ptr32)0x10;
void * __ptr32 cvtext2 = cvt->cvtext2;
int64 *cvtlso = (int64 * __ptr32)(cvtext2 + 0x50);
return *cvtlso;
}

static void getCurrentLogTimestamp(LogTimestamp *timestamp) {

uint64 stck = 0;
getSTCK(&stck);

stck += getLocalTimeOffset();
stck -= getLeapSecondsOffset();

stckToLogTimestamp(stck, timestamp);

Expand Down
7 changes: 3 additions & 4 deletions c/embeddedjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,6 @@ uint8_t *js_load_file(JSContext *ctx, size_t *pbuf_len, const char *filename);
/* (filename, ccsid) ccsid -1 implies guess best for platform, 0 implies don't translate */
static JSValue xplatformLoadFileUTF8(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv){
size_t size;
size_t length;
char *buf;

Expand All @@ -626,7 +625,9 @@ static JSValue xplatformLoadFileUTF8(JSContext *ctx, JSValueConst this_val,
JS_ToInt32(ctx, &sourceCCSID, argv[1]);

buf = (char*)js_load_file(ctx, &length, filename);

if (!buf) {
return JS_EXCEPTION;
}
if (sourceCCSID < 0){
char *nativeBuffer = safeMalloc(length+1,"xplatformStringFromBytes");
memcpy(nativeBuffer,buf,length);
Expand Down Expand Up @@ -678,7 +679,6 @@ static int appendToFile(char *filename, const char *data, int length) {
/* (filename, ccsid) ccsid -1 implies guess best for platform, 0 implies don't translate */
static JSValue xplatformAppendFileUTF8(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv){
size_t size;
size_t length;

NATIVE_STR(filename,nativeFilename,0);
Expand Down Expand Up @@ -718,7 +718,6 @@ static JSValue xplatformAppendFileUTF8(JSContext *ctx, JSValueConst this_val,
/* (filename, ccsid) ccsid -1 implies guess best for platform, 0 implies don't translate */
static JSValue xplatformStoreFileUTF8(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv){
size_t size;
size_t length;

NATIVE_STR(filename,nativeFilename,0);
Expand Down
5 changes: 3 additions & 2 deletions c/httpfileservice.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,11 +935,12 @@ int writeAsciiDataFromBase64(UnixFile *file, char *fileContents, int contentLeng
&reasonCode);
if (status == 0) {
int writtenLength = 0;
char *currentBufferStart = dataToWrite;
while (dataSize != 0) {
writtenLength = fileWrite(file, dataToWrite, dataSize, &returnCode, &reasonCode);
writtenLength = fileWrite(file, currentBufferStart, dataSize, &returnCode, &reasonCode);
if (writtenLength >= 0) {
dataSize -= writtenLength;
dataToWrite -= writtenLength;
currentBufferStart += writtenLength;
}
else {
zowelog(NULL, LOG_COMP_RESTFILE, ZOWE_LOG_DEBUG, "Error writing to file: return: %d, rsn: %d.\n", returnCode, reasonCode);
Expand Down
19 changes: 13 additions & 6 deletions c/httpserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1564,6 +1564,7 @@ HttpServer *makeHttpServerInner(STCBase *base,
memcpy(&server->config->sessionTokenKey[0], &sessionTokenKey,
sizeof (sessionTokenKey));
server->config->authTokenType = SERVICE_AUTH_TOKEN_TYPE_LEGACY;
server->config->httpRequestHeapMaxBlocks = HTTP_REQUEST_HEAP_DEFAULT_BLOCKS;

return server;
}
Expand Down Expand Up @@ -1656,6 +1657,8 @@ static HttpServer *makeSecureHttpServerInner(STCBase *base, int port,
int64 now = getFineGrainedTime();
server->config->sessionTokenKeySize = sizeof (now);
memcpy(&server->config->sessionTokenKey[0], &now, sizeof (now));
server->config->httpRequestHeapMaxBlocks = HTTP_REQUEST_HEAP_DEFAULT_BLOCKS;

return server;
}
#endif
Expand Down Expand Up @@ -3210,10 +3213,10 @@ static int serviceAuthNativeWithSessionToken(HttpService *service, HttpRequest *
request->flags = HTTP_REQUEST_NO_PASSWORD;
authDataFound = TRUE;
} else {
zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_INFO, "No user was found for client certificate. (rc = 0x%x racfRC = 0x%x racfRSN = 0x%x)\n", safReturnCode, racfReturnCode, racfReasonCode);
zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG, "No user was found for client certificate. (rc = 0x%x racfRC = 0x%x racfRSN = 0x%x)\n", safReturnCode, racfReturnCode, racfReasonCode);
}
} else {
zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_INFO, "Client certificate was attached to request, but credentials are also attached. Server won't attempt to map the client certificate.\n");
zowelog(NULL, LOG_COMP_HTTPSERVER, ZOWE_LOG_DEBUG, "Client certificate was attached to request, but credentials are also attached. Server won't attempt to map the client certificate.\n");
}
}

Expand Down Expand Up @@ -4637,8 +4640,9 @@ static int streamBinaryForFile2(HttpResponse *response, Socket *socket, UnixFile
if (encoding == ENCODING_CHUNKED) {
stream = makeChunkedOutputStreamInternal(response);
}

int bufferSize = FILE_STREAM_BUFFER_SIZE;

// To make bufferSize divisble by 3 for correct base64 encoding.
int bufferSize = FILE_STREAM_BUFFER_SIZE - (FILE_STREAM_BUFFER_SIZE % 3);
char *buffer = safeMalloc(bufferSize+4, "streamBinaryBuffer");
int encodedLength;

Expand Down Expand Up @@ -4710,7 +4714,8 @@ static int streamTextForFile2(HttpResponse *response, Socket *socket, UnixFile *
stream = makeChunkedOutputStreamInternal(response);
/* fallthrough */
case ENCODING_SIMPLE: {
int bufferSize = FILE_STREAM_BUFFER_SIZE;
// To make bufferSize divisble by 3 for correct base64 encoding.
int bufferSize = FILE_STREAM_BUFFER_SIZE - (FILE_STREAM_BUFFER_SIZE % 3);
char *buffer = safeMalloc(bufferSize+4, "streamTextBuffer");
char *translation = safeMalloc((2*bufferSize)+4, "streamTextConvertBuffer"); /* UTF inflation tolerance */
int encodedLength;
Expand Down Expand Up @@ -5819,7 +5824,9 @@ static int httpHandleTCP(STCBase *base,
}
}
#endif // USE_ZOWE_TLS
ShortLivedHeap *slh = makeShortLivedHeap(READ_BUFFER_SIZE,100);
HttpServer *server = (HttpServer*) module->data;
unsigned int maxBlocks = server->config->httpRequestHeapMaxBlocks;
ShortLivedHeap *slh = makeShortLivedHeap(READ_BUFFER_SIZE, maxBlocks);
#ifndef __ZOWE_OS_WINDOWS
int writeBufferSize = 0x40000;
setSocketWriteBufferSize(peerSocket,0x40000, &returnCode, &reasonCode);
Expand Down
41 changes: 41 additions & 0 deletions c/qjszos.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,41 @@ static JSValue zosChangeStreamCCSID(JSContext *ctx, JSValueConst this_val,
return JS_NewInt64(ctx,(int64_t)status);
}

static JSValue getZosVersion(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv){

#ifdef __ZOWE_OS_ZOS
ECVT *ecvt = getECVT();
int version = ecvt->ecvtpseq;
#else
int version = -1;
#endif
return JS_NewInt64(ctx,(int64_t)version);
}


static JSValue getEsm(JSContext *ctx, JSValueConst this_val,
int argc, JSValueConst *argv){

#ifdef __ZOWE_OS_ZOS
switch(getExternalSecurityManager()) {
case ZOS_ESM_RTSS:
return newJSStringFromNative(ctx, "TSS", 3);
case ZOS_ESM_RACF:
return newJSStringFromNative(ctx, "RACF", 4);
case ZOS_ESM_ACF2:
return newJSStringFromNative(ctx, "ACF2", 4);
case ZOS_ESM_NONE:
return newJSStringFromNative(ctx, "NONE", 4);
default:
return JS_NewString(ctx, NULL);
}
#else
return JS_NewString(ctx, NULL);
#endif

}


/* return [obj, errcode] */
static JSValue zosStat(JSContext *ctx, JSValueConst this_val,
Expand Down Expand Up @@ -377,6 +412,10 @@ static const char changeStreamCCSIDASCII[18] ={ 0x63, 0x68, 0x61, 0x6e, 0x67, 0x
0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x43, 0x53, 0x49, 0x44, 0x00};
static const char zstatASCII[6] ={ 0x7A, 0x73, 0x74, 0x61, 0x74, 0};

static const char getZosVersionASCII[14] ={ 0x67, 0x65, 0x74, 0x5A, 0x6F, 0x73, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x00};

static const char getEsmASCII[7] = { 0x67, 0x65, 0x74, 0x45, 0x73, 0x6D, 0x00 };

static const char EXTATTR_SHARELIB_ASCII[17] = { 0x45, 0x58, 0x54, 0x41, 0x54, 0x54, 0x52, 0x5f,
0x53, 0x48, 0x41, 0x52, 0x45, 0x4c, 0x49, 0x42, 0x0};

Expand All @@ -398,6 +437,8 @@ static const JSCFunctionListEntry zosFunctions[] = {
JS_CFUNC_DEF(changeExtAttrASCII, 3, zosChangeExtAttr),
JS_CFUNC_DEF(changeStreamCCSIDASCII, 2, zosChangeStreamCCSID),
JS_CFUNC_DEF(zstatASCII, 1, zosStat),
JS_CFUNC_DEF(getZosVersionASCII, 0, getZosVersion),
JS_CFUNC_DEF(getEsmASCII, 0, getEsm),
JS_CFUNC_DEF(dslistASCII, 1, zosDatasetInfo),
JS_CFUNC_DEF(resolveSymbolASCII, 1, zosResolveSymbol),
JS_PROP_INT32_DEF(EXTATTR_SHARELIB_ASCII, EXTATTR_SHARELIB, JS_PROP_CONFIGURABLE ),
Expand Down
Loading

0 comments on commit 48c55b6

Please sign in to comment.