Skip to content

Commit

Permalink
Modified the Stackbuilder to raise a UAC in case non-administrative u…
Browse files Browse the repository at this point in the history
…ser launches the application
  • Loading branch information
sachin committed Jun 29, 2011
1 parent b0c212e commit b055df2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ ENDIF(WIN32)
ADD_EXECUTABLE(stackbuilder WIN32 MACOSX_BUNDLE ${_srcs})
TARGET_LINK_LIBRARIES(stackbuilder ${WX_LIBRARIES})

IF(WIN32)
SET_TARGET_PROPERTIES(stackbuilder PROPERTIES LINK_FLAGS "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\"")
ENDIF(WIN32)

IF(APPLE)
CONFIGURE_FILE(${stackbuilder_SOURCE_DIR}/include/images/StackBuilder.icns ${stackbuilder_BINARY_DIR}/stackbuilder.app/Contents/Resources/StackBuilder.icns COPYONLY)
ENDIF(APPLE)
Expand Down
30 changes: 28 additions & 2 deletions StackBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Purpose: PostgreSQL/EnterpriseDB Application Stack Builder
// Author: Dave Page
// Created: 2007-02-13
// RCS-ID: $Id: StackBuilder.cpp,v 1.15 2010/06/03 19:43:35 sachin Exp $
// RCS-ID: $Id: StackBuilder.cpp,v 1.16 2011/06/29 09:05:20 sachin Exp $
// Copyright: (c) EnterpriseDB
// Licence: BSD Licence
/////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -86,10 +86,36 @@ bool StackBuilder::OnInit()
#ifdef __WXGTK__
if(geteuid() != 0)
{
wxLogError(_("This application must be run as the superuser."));
wxLogError(_("StackBuilder requires superuser privileges.Please become superuser before executing StackBuilder"));
return false;
}
#endif
#ifdef __WXMSW__
BOOL isAdmin;
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup;
isAdmin = AllocateAndInitializeSid(
&NtAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&AdministratorsGroup);
if(isAdmin)
{
if (!CheckTokenMembership( NULL, AdministratorsGroup, &isAdmin))
{
isAdmin = FALSE;
}
FreeSid(AdministratorsGroup);
}

if(!isAdmin)
{
wxLogError(_("StackBuilder requires superuser privileges.Please become superuser before executing StackBuilder"));
return false;
}
#endif

// Create and run the wizard
wxBitmap bitmap = wxBitmap(background_xpm);
Expand Down

0 comments on commit b055df2

Please sign in to comment.