From e393a46a8b53b0f6c2663f13b733c43153f25ebc Mon Sep 17 00:00:00 2001 From: "syd%netscape.com" Date: Thu, 7 Feb 2002 03:44:26 +0000 Subject: [PATCH] Miscellanous fixes for Linux installer, including 53244, 107803, 122916, 122918. r=sgehani, sr=dveditz --- xpinstall/wizard/unix/src2/XIDefines.h | 2 - xpinstall/wizard/unix/src2/mozilla-installer | 5 +- xpinstall/wizard/unix/src2/nsSetupTypeDlg.cpp | 23 +++++++- xpinstall/wizard/unix/src2/nsXIEngine.cpp | 55 +++++++++++-------- 4 files changed, 57 insertions(+), 28 deletions(-) diff --git a/xpinstall/wizard/unix/src2/XIDefines.h b/xpinstall/wizard/unix/src2/XIDefines.h index 5f502ee12215..290db9728cb7 100644 --- a/xpinstall/wizard/unix/src2/XIDefines.h +++ b/xpinstall/wizard/unix/src2/XIDefines.h @@ -37,7 +37,6 @@ #define MAX_URLS 32 #define MAX_URL_LEN 1024 #define MAX_DEPENDEE_KEY_LEN 16 -#define MAX_TMP_DIRS 1024 #define MAX_LEGACY_CHECKS 32 @@ -104,7 +103,6 @@ /*--------------------------------------------------------------------* * Macros *--------------------------------------------------------------------*/ -#define TMP_DIR_TEMPLATE "/tmp/.tmp.xi.%d" #define TMP_EXTRACT_SUBDIR "bin" #define XPI_DIR "./xpi" diff --git a/xpinstall/wizard/unix/src2/mozilla-installer b/xpinstall/wizard/unix/src2/mozilla-installer index f4ed8d01f987..9ce182f22943 100755 --- a/xpinstall/wizard/unix/src2/mozilla-installer +++ b/xpinstall/wizard/unix/src2/mozilla-installer @@ -48,10 +48,9 @@ export MOZILLA_FIVE_HOME BASEDIR=`dirname $0` if [ "$BASEDIR" = "" ]; then echo "dirname is not in your PATH" - ./mozilla-installer-bin --sync $@ + ./mozilla-installer-bin $@ else cd ${BASEDIR:-.} - ./mozilla-installer-bin --sync $@ + ./mozilla-installer-bin $@ fi -rm -rf /tmp/.tmp.xi.* diff --git a/xpinstall/wizard/unix/src2/nsSetupTypeDlg.cpp b/xpinstall/wizard/unix/src2/nsSetupTypeDlg.cpp index f1397a6ea554..cd8ef5b1d2d6 100644 --- a/xpinstall/wizard/unix/src2/nsSetupTypeDlg.cpp +++ b/xpinstall/wizard/unix/src2/nsSetupTypeDlg.cpp @@ -786,9 +786,30 @@ nsSetupTypeDlg::CreateDestYes(GtkWidget *aWidget, gpointer aData) { DUMP("CreateDestYes"); int err = 0; + char path[PATH_MAX + 1]; + int pathLen = strlen(gCtx->opt->mDestination); + if (pathLen > PATH_MAX) + pathLen = PATH_MAX; + memcpy(path, gCtx->opt->mDestination, pathLen); + path[pathLen] = '/'; // for uniform handling + + struct stat buf; mode_t oldPerms = umask(022); - err = mkdir(gCtx->opt->mDestination, (0777 & ~oldPerms)); + + for (int i = 1; !err && i <= pathLen; i++) + { + if (path[i] == '/') + { + path[i] = '\0'; + if (stat(path, &buf) != 0) + { + err = mkdir(path, (0777 & ~oldPerms)); + } + path[i] = '/'; + } + } + umask(oldPerms); // restore original umask gtk_widget_destroy(sCreateDestDlg); diff --git a/xpinstall/wizard/unix/src2/nsXIEngine.cpp b/xpinstall/wizard/unix/src2/nsXIEngine.cpp index 16a854240da0..1296243b6e5e 100644 --- a/xpinstall/wizard/unix/src2/nsXIEngine.cpp +++ b/xpinstall/wizard/unix/src2/nsXIEngine.cpp @@ -43,6 +43,8 @@ nsXIEngine::nsXIEngine() : { } +#define RM_PREFIX "rm -rf " + nsXIEngine::~nsXIEngine() { DUMP("~nsXIEngine"); @@ -50,7 +52,20 @@ nsXIEngine::~nsXIEngine() // reset back to original directory chdir(mOriginalDir); - XI_IF_FREE(mTmp); + if ( mTmp != (char *) NULL ) { + + // blow away the temp dir + + char *buf; + buf = (char *) malloc( strlen(RM_PREFIX) + strlen( mTmp ) + 1 ); + if ( buf != (char *) NULL ) { + strcpy( buf, RM_PREFIX ); + strcat( buf, mTmp ); + system( buf ); + XI_IF_FREE(mTmp); + free( buf ); + } + } XI_IF_FREE(mOriginalDir); } @@ -406,7 +421,7 @@ nsXIEngine::CheckConn( char *URL, int type, CONN *myConn, PRBool force ) if ( myConn->type == TYPE_UNDEF ) retval = PR_TRUE; // first time - else if ( ( myConn->type != type || strcmp( URL, myConn->URL ) || force == PR_TRUE ) /* && gControls->state != ePaused */) { + else if ( ( myConn->type != type || myConn->URL == (char *) NULL || strcmp( URL, myConn->URL ) || force == PR_TRUE ) /* && gControls->state != ePaused */) { retval = PR_TRUE; switch ( myConn->type ) { case TYPE_HTTP: @@ -416,14 +431,19 @@ nsXIEngine::CheckConn( char *URL, int type, CONN *myConn, PRBool force ) break; case TYPE_FTP: fconn = (nsFTPConn *) myConn->conn; - fconn->Close(); - XI_IF_DELETE(fconn); + if ( fconn != (nsFTPConn *) NULL ) { + fconn->Close(); + XI_IF_DELETE(fconn); + myConn->conn = NULL; + } break; } } - if ( retval == PR_TRUE && myConn->URL != (char *) NULL ) + if ( retval == PR_TRUE && myConn->URL != (char *) NULL ) { free( myConn->URL ); + myConn->URL = (char *) NULL; + } return retval; } @@ -528,25 +548,16 @@ nsXIEngine::Install(int aCustom, nsComponentList *aComps, char *aDestination) int nsXIEngine::MakeUniqueTmpDir() { - int err = OK; - int i; - char buf[MAXPATHLEN]; - struct stat dummy; - mTmp = NULL; + int err = E_DIR_CREATE; - for (i = 0; i < MAX_TMP_DIRS; i++) - { - sprintf(buf, TMP_DIR_TEMPLATE, i); - if (-1 == stat(buf, &dummy)) - break; + mTmp = tempnam( (const char *) NULL, "xpi" ); + + if ( mTmp != (char *) NULL ) { + int tmperr; + tmperr = mkdir(mTmp, 0755); + if ( tmperr != -1 ) + err = OK; } - - mTmp = (char *) malloc( (strlen(buf) * sizeof(char)) + 1 ); - if (!mTmp) return E_MEM; - - sprintf(mTmp, "%s", buf); - mkdir(mTmp, 0755); - return err; }