void interp(void) { char line[256]; char *p; while(1) { putchar('>'); putchar(' '); fflush(stdin); fflush(stdout); fflush(stderr); gets(line); /* p points to next word after verb on command line */ p = line; while (*p && *p!=' ') p++; if (!*p) p = 0; else { while(*p && *p==' ') p++; } switch(toupper(line[0])) { case 'N': vCreate(p); break; case 'A': error("VR_SetRegDirectory", VR_SetRegDirectory(p)); break; case 'C': error("VR_Close", VR_Close()); break; case 'I': vInstall(p); break; case 'R': error("VR_Remove", VR_Remove(p)); break; case 'X': error("VR_InRegistry", VR_InRegistry(p)); break; case 'T': error("VR_ValidateComponent", VR_ValidateComponent(p)); break; #if LATER case 'E': vEnum(p); break; case 'V': vVersion(p); break; case 'P': vPath(p); break; case 'F': vGetRefCount(p); break; case 'D': vGetDir(p); break; case 'S': puts("--Unsupported--"); #endif case 'H': default: vHelp(line); break; case 'Q': return; } /* switch */ } /* while */ assert(0); return; /* shouldn't get here */ } /* interp */
/* Complete * Completes the install: * - move the downloaded file to the final location * - updates the registry */ char* nsInstallFile::Complete() { int err; int refCount; int rc; if (softUpdate == NULL) { return SU_GetErrorMsg3("nsSoftwareUpdate object is null", SUERR_INVALID_ARGUMENTS); } if (vrName == NULL) { return SU_GetErrorMsg3("version registry name is null", SUERR_INVALID_ARGUMENTS); } if (finalFile == NULL) { return SU_GetErrorMsg3("folderSpec's full path (finalFile) is null", SUERR_INVALID_ARGUMENTS); } /* Check the security for our target */ // XXX: Make the following security code into a function. /* Request impersonation privileges */ nsTarget* impersonation = nsTarget::findTarget(IMPERSONATOR); nsPrivilegeManager* privMgr = nsPrivilegeManager::getPrivilegeManager(); nsTarget* install_target = NULL; if ((privMgr != NULL) && (impersonation != NULL)) { privMgr->enablePrivilege(impersonation, 1); /* check the security permissions */ install_target = nsTarget::findTarget(INSTALL_PRIV); if (install_target != NULL) { if (!privMgr->enablePrivilege(install_target, softUpdate->GetPrincipal(), 1)) { return SU_GetErrorMsg3("Permssion was denied", SUERR_ACCESS_DENIED); } } } err = NativeComplete(); if ((privMgr != NULL) && (install_target != NULL)) { privMgr->revertPrivilege(install_target, 1); } char *vr_name = vrName->ToNewCString(); char *final_file = finalFile->ToNewCString(); // Add java archives to the classpath. Don't add if we're // replacing an existing file -- it'll already be there. if ( bJavaDir && !replace ) { PRBool found_zip = endsWith(finalFile, ".zip"); PRBool found_jar = endsWith(finalFile, ".jar");; if (found_zip || found_jar) { AddToClasspath( finalFile ); } } // Register file and log for Uninstall if ( 0 == err || SU_REBOOT_NEEDED == err ) { // we ignore all registry errors because they're not // important enough to abort an otherwise OK install. if (!bChild) { int found; if (regPackageName) { char *reg_package_name = regPackageName->ToNewCString(); found = VR_UninstallFileExistsInList( reg_package_name, vr_name ); delete reg_package_name; } else { found = VR_UninstallFileExistsInList( "", vr_name ); } if (found != REGERR_OK) bUpgrade = PR_FALSE; else bUpgrade = PR_TRUE; } else if (REGERR_OK == VR_InRegistry(vr_name)) { bUpgrade = PR_TRUE; } else { bUpgrade = PR_FALSE; } err = VR_GetRefCount( vr_name, &refCount ); if ( err != REGERR_OK ) { refCount = 0; } if (!bUpgrade) { if (refCount != 0) { rc = 1 + refCount; VR_Install( vr_name, final_file, versionInfo->toString(), PR_FALSE ); VR_SetRefCount( vr_name, rc ); } else { if (replace) { VR_Install( vr_name, final_file, versionInfo->toString(), PR_FALSE); VR_SetRefCount( vr_name, 2 ); } else { VR_Install( vr_name, final_file, versionInfo->toString(), PR_FALSE ); VR_SetRefCount( vr_name, 1 ); } } } else if (bUpgrade) { if (refCount == 0) { VR_Install( vr_name, final_file, versionInfo->toString(), PR_FALSE ); VR_SetRefCount( vr_name, 1 ); } else { VR_Install( vr_name, final_file, versionInfo->toString(), PR_FALSE ); VR_SetRefCount( vr_name, 0 ); } } if ( !bChild && !bUpgrade ) { if (regPackageName) { char *reg_package_name = regPackageName->ToNewCString(); VR_UninstallAddFileToList( reg_package_name, vr_name ); delete reg_package_name; } else { VR_UninstallAddFileToList( "", vr_name ); } } } delete vr_name; delete final_file; if ( err != 0 ) { return SU_GetErrorMsg2(SU_ERROR_INSTALL_FILE_UNEXPECTED, finalFile, err); } return NULL; }