News
Abstract
Lock down BNDSRVPGM library settings using the Change Program Data (QBNCHGPD) API for IBM i 6.1 and later releases
Content
You are in: IBM i Technology Updates > General IBM i Operating System > Lock down BNDSRVPGM library settings using the Change Program Data (QBNCHGPD) API
This enhancement may be of particular interest to ISV developers. The Change Program Data (QBNCHGPD) API is being enhanced with a new key value which can be used to prevent changes to the Bound Service Program settings within programs.
Specifying a change record with a key value of 5 on the API call will request that the program or service program for which the API was called be changed to not allow changes to the bound service program library.
When an ISV develops an application, the install of the application can allow a user-specified library into which the programs and service programs are restored. QBNCHGPD API can be used to change the bound service program library for the application programs to the user-specified library, and then the new key 5 function can be used to 'lock down' the library value so that it cannot be changed again.
For more details, refer to the IBM i Knowledge Center topic QBNCHGPD API and the PTF coverletter for the following PTF:
IBM i 7.1 PTF: SI46130
Sample program demonstrating the new key:
/*-----------------------------------------------------------------------------
Example program to demonstrate usage of the QBNCHGPD "Change Program Data" API:
1. Change SRVPGM libraries
2. Change attribute "Allow bound *SRVPGM library name update" to *NO
Example CL usage:
CALL thisPgm PARM('OBJNAME LIBNAME ' '*PGM ' 'NEWSRVLIB ')
(parameters must be specified in upper case and be padded with blanks as shown)
Result:
*PGM LIBNAME/OBJNAME will have its non-IBM-supplied service program libraries
changed to NEWSRVLIB, then further changes to the libraries will be prohibited.
Header files included:
h/string.h - character manipulation routines
h/stdio.h - standard I/O functions
h/QBNCHGPD.H - Change Program Data API definitions
h/QUSEC.H - API Error Code parameter definitions
-----------------------------------------------------------------------------*/
#include <string.h>
#include <stdio.h>
#include <QBNCHGPD.H>
#include <QUSEC.H>
static void printUsage(char *thisPgm) {
printf("\nExample CL Usage:\n\n");
printf("CALL %s PARM('OBJNAME LIBNAME ' '*PGM ' 'NEWSRVLIB ')\n\n", thisPgm);
printf("Parameters:\n");
printf("\tchar20\tobject name and library name of program to change\n");
printf("\tchar10\tobject type *PGM or *SRVPGM\n");
printf("\tchar10\tnew SRVPGM library\n\n");
}
void main (int argc, char *argv[]) {
// local copies of input parameters
char *objectSpec;
char *objectType;
char *newSrvpgmLib;
// API error code parameter
Qus_EC_t errorCode;
// allocate change records for QBNCHGPD:
// 1. key 4: change srvpgm lib names
// 2. key 5: prohibit further changes to srvpgm lib names
// see Qbn_CHGPD_Change_Obj_Info in QBNCHGPD.H for layout
struct {
int count;
Qbn_CHGPD_Chg_Rec_t record[2];
} changeInfo;
if (argc < 4) {
printUsage(argv[0]);
return;
}
// get parameters
objectSpec = argv[1];
objectType = argv[2];
newSrvpgmLib = argv[3];
// initialize API error code parameter to signal exceptions (field Bytes_Provided = 0)
memset(&errorCode, 0, sizeof(errorCode));
changeInfo.count = 2;
// change library of each bound srvpgm (other than those in QSYS) --
// each srvpgm must reside in the new library for the change to succeed
changeInfo.record[0].Key = 4;
memcpy(&changeInfo.record[0].From_Library, "*ALL ", 10);
memcpy(&changeInfo.record[0].From_File, " ", 10);
memcpy(&changeInfo.record[0].From_Member, " ", 10);
memcpy(&changeInfo.record[0].To_Library, newSrvpgmLib, 10);
memcpy(&changeInfo.record[0].To_File, " ", 10);
memcpy(&changeInfo.record[0].To_Member, " ", 10);
// prohibit further changes to library of bound srvpgms --
// all 'From' and 'To' change record fields must be blank for key 5
changeInfo.record[1].Key = 5;
memcpy(&changeInfo.record[1].From_Library, " ", 10);
memcpy(&changeInfo.record[1].From_File, " ", 10);
memcpy(&changeInfo.record[1].From_Member, " ", 10);
memcpy(&changeInfo.record[1].To_Library, " ", 10);
memcpy(&changeInfo.record[1].To_File, " ", 10);
memcpy(&changeInfo.record[1].To_Member, " ", 10);
QBNCHGPD(
objectSpec,
objectType,
"CHGP0100", // char8 API format name
&changeInfo,
&errorCode,
"*NONE ", // char20 module name and lib to be changed
"*ALL *ALL " // char20 srvpgm name and lib to be changed
);
}
Was this topic helpful?
Document Information
Modified date:
10 January 2020
UID
ibm11127745