[Pkg-owncloud-commits] [owncloud-client] 131/175: NSIS: Fix NSIS error handling

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Aug 8 10:36:35 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 3df26ef189e97201bd0ccf955cce7b5bfb97f592
Author: Daniel Molkentin <danimo at owncloud.com>
Date:   Fri Jun 5 08:43:16 2015 +0200

    NSIS: Fix NSIS error handling
---
 admin/win/nsi/l10n/English.nsh          |  1 +
 admin/win/nsi/l10n/declarations.nsh     |  1 +
 admin/win/nsi/l10n/pofiles/messages.pot |  4 ++
 cmake/modules/NSIS.template.in          | 78 +++++++++++++++++----------------
 4 files changed, 46 insertions(+), 38 deletions(-)

diff --git a/admin/win/nsi/l10n/English.nsh b/admin/win/nsi/l10n/English.nsh
index b6237a6..81900bb 100644
--- a/admin/win/nsi/l10n/English.nsh
+++ b/admin/win/nsi/l10n/English.nsh
@@ -42,5 +42,6 @@ StrCpy $UAC_ERROR_ELEVATE "Unable to elevate, error:"
 StrCpy $UAC_INSTALLER_REQUIRE_ADMIN "This installer requires admin access, try again"
 StrCpy $INIT_INSTALLER_RUNNING "The installer is already running."
 StrCpy $UAC_UNINSTALLER_REQUIRE_ADMIN "This uninstaller requires admin access, try again"
+StrCpy $UAC_ERROR_LOGON_SERVICE "Logon service is not running, aborting!"
 StrCpy $INIT_UNINSTALLER_RUNNING "The uninstaller is already running."
 StrCpy $SectionGroup_Shortcuts "Shortcuts"
diff --git a/admin/win/nsi/l10n/declarations.nsh b/admin/win/nsi/l10n/declarations.nsh
index b5eb598..b43a17d 100644
--- a/admin/win/nsi/l10n/declarations.nsh
+++ b/admin/win/nsi/l10n/declarations.nsh
@@ -42,5 +42,6 @@ Var UAC_ERROR_ELEVATE
 Var UAC_INSTALLER_REQUIRE_ADMIN
 Var INIT_INSTALLER_RUNNING
 Var UAC_UNINSTALLER_REQUIRE_ADMIN
+Var UAC_ERROR_LOGON_SERVICE
 Var INIT_UNINSTALLER_RUNNING
 Var SectionGroup_Shortcuts
diff --git a/admin/win/nsi/l10n/pofiles/messages.pot b/admin/win/nsi/l10n/pofiles/messages.pot
index 330723e..8cd8b18 100644
--- a/admin/win/nsi/l10n/pofiles/messages.pot
+++ b/admin/win/nsi/l10n/pofiles/messages.pot
@@ -198,6 +198,10 @@ msgstr "The installer is already running."
 msgid "This uninstaller requires admin access, try again"
 msgstr "This uninstaller requires admin access, try again"
 
+#. UAC_ERROR_LOGON_SERVICE
+msgid "Logon service is not running, aborting!"
+msgstr "Logon service is not running, aborting!"
+
 #. INIT_UNINSTALLER_RUNNING
 msgid "The uninstaller is already running."
 msgstr "The uninstaller is already running."
diff --git a/cmake/modules/NSIS.template.in b/cmake/modules/NSIS.template.in
index ec8fa1d..ae86cdb 100644
--- a/cmake/modules/NSIS.template.in
+++ b/cmake/modules/NSIS.template.in
@@ -756,25 +756,26 @@ Function .onInit
 
    ${MementoSectionRestore}
 
-   UAC_Elevate:
-      !insertmacro UAC_RunElevated
-      StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
-      StrCmp 0 $0 0 UAC_Err ; Error?
-      StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
-      Quit
-
-   UAC_Err:
-      MessageBox MB_ICONSTOP "$UAC_ERROR_ELEVATE $0"
-      Abort
-
-   UAC_ElevationAborted:
-      Abort
-
-   UAC_Success:
-      StrCmp 1 $3 +4 ;Admin?
-      StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
-      MessageBox MB_ICONSTOP $UAC_INSTALLER_REQUIRE_ADMIN
-      goto UAC_Elevate
+   UAC_TryAgain:
+      ${Switch} $0
+      ${Case} 0
+          ${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done
+          ${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on
+          ${If} $1 = 3 ;RunAs completed successfully, but with a non-admin user
+             MessageBox mb_YesNo|mb_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND $UAC_INSTALLER_REQUIRE_ADMIN /SD IDNO IDYES UAC_TryAgain IDNO 0
+          ${EndIf}
+          ;fall-through and die
+      ${Case} 1223
+         MessageBox MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND $UAC_INSTALLER_REQUIRE_ADMIN
+         Quit
+      ${Case} 1062
+         MessageBox MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND $UAC_ERROR_LOGON_SERVICE
+         Quit
+      ${Default}
+         MessageBox MB_ICONSTOP "$UAC_ERROR_ELEVATE $0"
+         Abort
+         Quit
+      ${EndSwitch}
 
    ;Prevent multiple instances.
    System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${APPLICATION_SHORTNAME}Installer") i .r1 ?e'
@@ -819,25 +820,26 @@ FunctionEnd
 Function un.onInit
    Call un.SetLang
 
-   UAC_Elevate:
-      !insertmacro UAC_RunElevated
-      StrCmp 1223 $0 UAC_ElevationAborted ; UAC dialog aborted by user?
-      StrCmp 0 $0 0 UAC_Err ; Error?
-      StrCmp 1 $1 0 UAC_Success ;Are we the real deal or just the wrapper?
-      Quit
-
-   UAC_Err:
-      MessageBox MB_ICONSTOP "$UAC_ERROR_ELEVATE $0"
-      Abort
-
-   UAC_ElevationAborted:
-      Abort
-
-   UAC_Success:
-      StrCmp 1 $3 +4 ;Admin?
-      StrCmp 3 $1 0 UAC_ElevationAborted ;Try again?
-      MessageBox MB_ICONSTOP $UAC_UNINSTALLER_REQUIRE_ADMIN
-      goto UAC_Elevate
+   UAC_TryAgain:
+      ${Switch} $0
+      ${Case} 0
+          ${IfThen} $1 = 1 ${|} Quit ${|} ;we are the outer process, the inner process has done its work, we are done
+          ${IfThen} $3 <> 0 ${|} ${Break} ${|} ;we are admin, let the show go on
+          ${If} $1 = 3 ;RunAs completed successfully, but with a non-admin user
+             MessageBox mb_YesNo|mb_ICONEXCLAMATION|MB_TOPMOST|MB_SETFOREGROUND $UAC_UNINSTALLER_REQUIRE_ADMIN /SD IDNO IDYES UAC_TryAgain IDNO 0
+          ${EndIf}
+          ;fall-through and die
+      ${Case} 1223
+         MessageBox MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND $UAC_UNINSTALLER_REQUIRE_ADMIN
+         Quit
+      ${Case} 1062
+         MessageBox MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND $UAC_ERROR_LOGON_SERVICE
+         Quit
+      ${Default}
+         MessageBox MB_ICONSTOP "$UAC_ERROR_ELEVATE $0"
+         Abort
+         Quit
+      ${EndSwitch}
 
    ;Prevent multiple instances.
    System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${APPLICATION_SHORTNAME}Uninstaller") i .r1 ?e'

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list