/*{ ** Name: II_PrecheckInstallation - Pre-check installation environment ** ** Description: ** Verify that a machine environment will support the current release of ** Ingres. The following checks are made: **(E ** a. A minimum operating system version ** b. Other required software (currently none) ** c. Check the install path ** - exists ** - that user can write to it ** - does not have any disallowed characters (Windows only). **)E ** ** Inputs: ** response_file path to the Embedded Ingres response file. ** For more information concerning response file options ** please see the Ingres Embedded Edition User Guide. ** ** Outputs: ** error_msg Message text for status. If the message text exceeds ** MAX_IIERR_LEN then the message is truncated to ** MAX_IIERR_LEN. ** Unchanged if II_SUCCESSFUL is returned. ** ** Returns: ** II_SUCCESSFUL The environment test completed successfully ** II_NULL_PARAM The parameters passed are invalid ** II_NO_INSTALL_PATH Error reading response file or no II_SYSTEM entry ** II_CHARMAP_ERROR Error processing character mapping file ** II_GET_COMPUTER_FAIL Attempt to retrieve computer name failed ** II_INVALID_HOST Computer name contains illegal characters ** II_GET_HOST_FAILED Attempt to retrieve the network name failed ** II_INVALID_USER The username contains illegal characters ** II_UNMATCHED_NAME Computer name does not match network name ** II_OS_NOT_MIN_VERSION OS version does not meet the minimum requirement ** II_BAD_PATH The II_SYSTEM path is incorrectly formed ** II_INVAL_CHARS_IN_PATH The II_SYSTEM path contains illegal characters ** II_PATH_NOT_DIR The II_SYSTEM path is not a directory ** II_PATH_CANNOT_WRITE No write permission in the II_SYSTEM directory ** II_PATH_EXCEEDED Length of the path exceeds permitted maximum ** ** Example: ** # include "tngapi.h" ** ** # if defined(UNIX) ** II_CHAR reponsefile[] = {"./ingres.rsp"}; ** # else ** II_CHAR reponsefile[] = {".\\ingres.rsp"}; ** # endif ** II_INT4 status; ** II_CHAR error_msg[MAX_IIERR_LEN + 1] = { '\0' }; ** ** if ((status = II_PrecheckInstallation( responsefile, error_msg )) != ** II_SUCCESSFUL) ** { ** printf( "II_PrecheckInstallation failed - %s\n", error_msg ); ** } ** ** Side Effects: ** none ** ** History: ** 16-apr-2002 (abbjo03) ** Written. ** 11-Jul-2005 (fanra01) ** Add more specific status code from check_path_chars. */ int II_PrecheckInstallation( char *response_file, char *error_msg) { LOCATION loc; char buf[MAX_LOC]; char charmap[MAX_LOC+1]; LOINFORMATION loinfo; i4 flags; int result; CL_ERR_DESC clerr; if (!response_file || !error_msg) { result = II_NULL_PARAM; if (error_msg) II_GetErrorMessage(error_msgs[result], error_msg); return result; } if (!GetPrivateProfileString("Ingres Configuration", "II_SYSTEM", "", buf, sizeof(buf), response_file)) { result = II_NO_INSTALL_PATH; II_GetErrorMessage(error_msgs[result], error_msg); return result; } /* ** Get the charmap field from the response file. */ if (!GetPrivateProfileString("Ingres Configuration", II_CHARMAP, "", charmap, sizeof(charmap), response_file)) { result = II_NO_CHAR_MAP; II_GetErrorMessage(error_msgs[result], error_msg); return result; } /* ** Open and read the character map specified in the response file. ** This is a special installation character description file. */ #if defined(UNIX) if ((result = CMset_attr( charmap, &clerr )) != 0) #else if ((result = CMread_attr( II_CHARSET, charmap, &clerr )) != 0) #endif { result = II_CHARMAP_ERROR; II_GetErrorMessage( error_msgs[result], error_msg ); return(result); } if ((result = check_user()) != II_SUCCESSFUL) { II_GetErrorMessage( error_msgs[result], error_msg ); return(result); } if ((result = check_host()) != II_SUCCESSFUL) { II_GetErrorMessage( error_msgs[result], error_msg ); return(result); } if (check_platform( II_DEFARCH ) != OK) { result = II_OS_NOT_MIN_VERSION; II_GetErrorMessage(error_msgs[result], error_msg); return result; } if (LOfroms(PATH & FILENAME, buf, &loc) != OK) { result = II_BAD_PATH; II_GetErrorMessage(error_msgs[result], error_msg); return result; } flags = LO_I_TYPE | LO_I_PERMS; if (LOinfo(&loc, &flags, &loinfo) != OK) { result = II_BAD_PATH; II_GetErrorMessage(error_msgs[result], error_msg); return result; } if ((flags & LO_I_TYPE) == 0 || loinfo.li_type != LO_IS_DIR) { result = II_PATH_NOT_DIR; II_GetErrorMessage(error_msgs[result], error_msg); return result; } if ((flags & LO_I_PERMS) == 0 || (loinfo.li_perms & LO_P_WRITE) == 0) { result = II_PATH_CANNOT_WRITE; II_GetErrorMessage(error_msgs[result], error_msg); return result; } if (check_path_chars(&loc, &result)) { switch(result) { case LO_BAD_DEVICE: result = II_BAD_PATH; break; case LO_NOT_PATH: case LO_NOT_FILE: default: result = II_INVAL_CHARS_IN_PATH; break; } II_GetErrorMessage(error_msgs[result], error_msg); return result; } result = II_SUCCESSFUL; II_GetErrorMessage(error_msgs[result], error_msg); return result; }
/*{ ** Name: II_PrecheckInstallationEx - Extended installation environment pre-check ** ** Description: ** Verify that a machine environment will support the current release of ** Ingres. ** The following checks may be made by specifying the required set of flags: **(E ** ** a. Test for invalid characters in the machine hostname ** b. Test for invalid characters in the username ** c. A minimum operating system version ** d. Test that the path value supplied for II_SYSTEM ** i) does not contain disallowed characters (Windows only) ** ii) consists of an existing parent directory ** e. Test that the operating system user of the running process is granted ** permission to write in d.ii). ** f. The value of the instancecode field in the response file is tested ** for valid characters and character sequences. **)E ** ** The path check flags II_CHK_PATHDIR and II_CHK_PATHPERM may be combined ** (bit wise); they include an implicit II_CHK_PATHCHAR. All path checks ** implicitly include an II_CHK_PATHLEN flag. ** Use the II_CHK_ALL flag as a convenient shorthand to perform each of the ** tests together. ** Specifying a flag of zero will check for the existence of the ** II_SYSTEM entry in the response file. ** ** Inputs: ** eflags Specifies the pre-installation checks to be performed. ** Can be a combination of the following ** 0 Test for existence of II_SYSTEM entry ** in response file ** II_CHK_HOSTNAME Verify characters in machine name ** II_CHK_OSVERSION Verify minimum OS version ** II_CHK_PATHCHAR Check characters used in II_SYSTEM ** II_CHK_PATHDIR Check II_SYSTEM path for a valid ** existing directory ** II_CHK_PATHPERM Check path write permissions ** II_CHK_PATHLEN Check length of path not exceeded ** II_CHK_USERNAME Verify characters in user name ** II_CHK_INSTCODE Verify characters of the configured ** instance code ** II_CHK_ALL Equivalent to II_PrecheckInstallation ** call. ** architecture The value of architecture is used only if the ** II_CHK_VERSION flag is set in the eflags field. ** If the II_CHK_VERSION flag is set ** Let the value of architecture be set as follows: ** Case: ** - II_DEFVER determines if the suitability of ** the internal Ingres platform architecture ** is appropriate for the operating architecture. ** - Determines if the suitability of the defined ** value of architecture is appropriate for the ** operating architecture. ** If the II_CHK_VERSION flag is not set ** Let the value of architecture be set to II_DEFVER. ** ** response_file Path to the Embedded Ingres response file ** For more information concerning response file options ** please see the Ingres Embedded Edition User Guide. ** This function requires valid values for the II_SYSTEM and ** charmap entries. ** ** Outputs: ** error_msg Message text for status. If the message text exceeds ** MAX_IIERR_LEN then the message is truncated to ** MAX_IIERR_LEN. ** Unchanged if II_SUCCESSFUL is returned. ** ** Returns: ** II_SUCCESSFUL The environment test completed successfully ** II_NULL_PARAM The parameters passed are invalid ** II_NO_INSTALL_PATH Error reading response file or no II_SYSTEM entry ** II_NO_CHAR_MAP Error reading response file or no II_CHARMAP entry ** II_CHARMAP_ERROR Error processing character mapping file ** II_GET_COMPUTER_FAIL Attempt to retrieve computer name failed ** II_INVALID_HOST Computer name contains illegal characters ** II_GET_HOST_FAILED Attempt to retrieve the network name failed ** II_INVALID_USER The username contains illegal characters ** II_UNMATCHED_NAME Computer name does not match network name ** II_OS_NOT_MIN_VERSION OS version does not meet the minimum requirement ** II_BAD_PATH The II_SYSTEM path is incorrectly formed ** II_INVAL_CHARS_IN_PATH The II_SYSTEM path contains illegal characters ** II_PATH_NOT_DIR The II_SYSTEM path does not contain a valid ** directory ** II_PATH_CANNOT_WRITE No write permission in the II_SYSTEM directory or ** a parent directory. ** II_PATH_EXCEEDED Length of the path exceeds permitted maximum ** II_INVALID_INSTANCECODE Instance code contains illegal characters ** II_INSTANCE_ERROR Error reading instance code or no instancecode ** entry. ** ** Example: ** # include "tngapi.h" ** ** # if defined(UNIX) ** II_CHAR reponsefile[] = {"./ingres.rsp"}; ** # else ** II_CHAR reponsefile[] = {".\\ingres.rsp"}; ** # endif ** II_INT4 status; ** II_INT4 eflags = (II_CHK_HOSTNAME | II_CHK_OSVERSION | \ ** II_CHK_PATHCHAR | II_CHK_PATHDIR | II_CHK_PATHPERM | II_CHK_PATHLEN \ ** II_CHK_INSTCODE); ** II_CHAR error_msg[MAX_IIERR_LEN + 1] = { '\0' }; ** ** if ((status = II_PrecheckInstallationEx( eflags, II_DEFARCH, responsefile, ** error_msg )) != II_SUCCESSFUL) ** { ** printf( "II_PrecheckInstallationEx failed - %s\n", error_msg ); ** } ** ** if ((status = II_PrecheckInstallationEx( II_CHK_OSVERSION, II_IA64, ** responsefile, error_msg )) != II_SUCCESSFUL) ** { ** printf( "II_PrecheckInstallationEx failed - %s\n", error_msg ); ** if (status == II_OS_NOT_MIN_VERSION) ** { ** printf( "Target environment is unsuitable for IA64 binaries\n"); ** } ** } ** ** Side Effects: ** none ** ** History: ** 07-Sep-2004 (fanra01) ** Created based on II_PrecheckInstallation. ** 30-Jun-2005 (fanra01) ** Moved and extended path validation into check_path function. ** 18-Aug-2005 (fanra01) ** Include path length check on character map file. }*/ int II_PrecheckInstallationEx( int eflags, int architecture, char* response_file, char* error_msg ) { i4 status = II_SUCCESSFUL; i4 flags; i4 pathlen; LOCATION loc; LOINFORMATION loinfo; char buf[MAX_LOC + 3]; /* over size buffer to detect overrun */ char charmap[MAX_LOC + 3]; char ii_install[MAX_LOC + 3]; CL_ERR_DESC clerr; i4 pathchk = 0; while(TRUE) { if (!response_file || !error_msg) { status = II_NULL_PARAM; break; } if ((pathlen = GetPrivateProfileString( ERx("Ingres Configuration"), ERx("II_SYSTEM"), "", buf, sizeof(buf), response_file )) == 0) { status = II_NO_INSTALL_PATH; break; } else { if ((pathchk = (eflags & (II_CHK_PATHCHAR | II_CHK_PATHDIR | II_CHK_PATHPERM | II_CHK_PATHLEN))) && (pathlen > MAX_LOC)) { status = II_PATH_EXCEEDED; break; } } if (eflags & II_CHK_INSTCODE) { if ((pathlen = GetPrivateProfileString("Ingres Configuration", II_INSTCODE, "", ii_install, sizeof(ii_install), response_file)) == 0) { status = II_INSTANCE_ERROR; break; } else { if ((status = check_instcode( ii_install )) != II_SUCCESSFUL) { break; } } } if ((eflags & (II_CHK_HOSTNAME | II_CHK_USERNAME | pathchk)) && ((pathlen = GetPrivateProfileString("Ingres Configuration", II_CHARMAP, "", charmap, sizeof(charmap), response_file)) == 0)) { status = II_NO_CHAR_MAP; break; } else { if (eflags & (II_CHK_HOSTNAME | II_CHK_USERNAME | pathchk)) { if (pathlen > MAX_LOC) { status = II_PATH_EXCEEDED; break; } else { #if defined(UNIX) if ((status = CMset_attr( charmap, &clerr )) != 0) #else if ((status = CMread_attr( II_CHARSET, charmap, &clerr )) != 0) #endif { status = II_CHARMAP_ERROR; break; } } } } if ((eflags & II_CHK_HOSTNAME) && ((status = check_host()) != II_SUCCESSFUL)) { break; } if ((eflags & II_CHK_USERNAME) && ((status = check_user()) != II_SUCCESSFUL)) { break; } if ((eflags & II_CHK_OSVERSION) && (check_platform( architecture ) != OK)) { status = II_OS_NOT_MIN_VERSION; break; } /* ** Perform path validation test. */ if (eflags & (II_CHK_PATHCHAR | II_CHK_PATHDIR | II_CHK_PATHPERM)) { status = check_path( buf, eflags ); break; } break; } if ((status != II_SUCCESSFUL) && (error_msg != NULL)) { II_GetErrorMessage( error_msgs[status], error_msg ); } return(status); }
static STATUS initialize( i4 argc, char **argv ) { CL_ERR_DESC cl_err; char *instance = ERx("*"); char *env; char name[ 16 ]; i4 i; GCD_global.language = 1; MHsrand( TMsecs() ); for( i = 1; i < argc; i++ ) if ( ! STbcompare( argv[i], 0, ERx("-instance"), 9, TRUE ) ) { if ( argv[i][9] == ERx('=') && argv[i][10] != EOS ) instance = &argv[i][10]; else if ( argv[i][9] == EOS && (i + 1) < argc ) instance = argv[++i]; break; } NMgtAt( ERx("II_INSTALLATION"), &env ); STprintf( name, ERx("II_CHARSET%s"), (env && *env) ? env : "" ); NMgtAt( name, &env ); if ( ! env || ! *env || STlength(env) > CM_MAXATTRNAME) { switch( CMgetDefCS() ) { #if ( !defined(UNIX) && !defined(VMS) ) case CM_IBM : env = "IBMPC850"; break; #endif case CM_DECMULTI : env = "DECMULTI"; break; default : env = "ISO88591"; break; } } GCD_global.charset = STalloc( env ); CVupper( GCD_global.charset ); gcu_read_cset( gcd_cset_id ); if ( CMset_attr( GCD_global.charset, &cl_err) != OK ) { gcu_erlog( 0, GCD_global.language, E_GC0105_GCN_CHAR_INIT, NULL, 0, NULL ); return( E_GC0105_GCN_CHAR_INIT ); } PMinit(); switch( PMload( (LOCATION *)NULL, (PM_ERR_FUNC *)NULL ) ) { case OK: break; case PM_FILE_BAD: gcu_erlog( 0, GCD_global.language, E_GC003D_BAD_PMFILE, NULL, 0, NULL ); return( E_GC003D_BAD_PMFILE ); break; default: gcu_erlog( 0, GCD_global.language, E_GC003E_PMLOAD_ERR, NULL, 0, NULL ); return( E_GC003E_PMLOAD_ERR ); break; } PMsetDefault( 0, SystemCfgPrefix ); PMsetDefault( 1, PMhost() ); PMsetDefault( 2, ERx("gcd") ); PMsetDefault( 3, instance ); gcd_tl_services[0] = &gcd_dmtl_service; gcd_tl_services[1] = &gcd_jctl_service; GCD_global.tl_services = gcd_tl_services; GCD_global.tl_srvc_cnt = ARR_SIZE( gcd_tl_services ); QUinit( &GCD_global.pib_q ); QUinit( &GCD_global.rcb_q ); QUinit( &GCD_global.ccb_q ); QUinit( &GCD_global.ccb_free ); for( i = 0; i < ARR_SIZE( GCD_global.cib_free ); i++ ) QUinit( &GCD_global.cib_free[ i ] ); env = NULL; gcu_get_tracesym( NULL, ERx("!.client_max"), &env ); if ( env && *env ) { i4 count; if ( CVal( env, &count ) == OK && count > 0 ) GCD_global.client_max = count; } env = NULL; gcu_get_tracesym( NULL, ERx("!.client_timeout"), &env ); if ( env && *env ) { i4 timeout; if ( CVal( env, &timeout ) == OK && timeout > 0 ) GCD_global.client_idle_limit = timeout * 60; /* Cnvt to seconds */ } env = NULL; gcu_get_tracesym( NULL, ERx("!.connect_pool_status"), &env ); if ( env && *env ) { if ( ! STbcompare( env, 0, "optional", 0, TRUE ) ) GCD_global.client_pooling = TRUE; if ( GCD_global.client_pooling || ! STbcompare( env, 0, "on", 0, TRUE ) ) { env = NULL; gcu_get_tracesym( NULL, ERx("!.connect_pool_size"), &env ); if ( env && *env ) CVal( env, &GCD_global.pool_max ); env = NULL; gcu_get_tracesym( NULL, ERx("!.connect_pool_expire"), &env ); if ( env && *env ) { i4 limit; if ( CVal( env, &limit ) == OK && limit > 0 ) GCD_global.pool_idle_limit = limit * 60; /* Seconds */ } } } env = NULL; gcu_get_tracesym( "II_GCD_TRACE", ERx("!.gcd_trace_level"), &env ); if ( env && *env ) CVal( env, &GCD_global.gcd_trace_level ); env = NULL; gcu_get_tracesym( "II_GCD_LOG", ERx("!.gcd_trace_log"), &env ); if ( env && *env ) TRset_file( TR_F_OPEN, env, (i4)STlength( env ), &cl_err ); return( OK ); }