Mac: In permissions error alert: show branded name and path to bad file or subdirectory

svn path=/trunk/boinc/; revision=25081
This commit is contained in:
Charlie Fenton 2012-01-17 09:38:32 +00:00
parent bd55ab5968
commit 52d06bce98
5 changed files with 88 additions and 48 deletions

View File

@ -617,3 +617,15 @@ Rom 16 Jan 2012
/
configure.ac
version.h
Charlie 17 Jan 2012
- Mac: In permissions error alert: show branded name, if permissions
error is in a subdirectory, show path to bad file or subdirectory.
client/
check_security.cpp
sandbox.h
clientgui/
BOINCGUIApp.cpp
mac_installer/
PosInstall.cpp

View File

@ -39,7 +39,10 @@
bool IsUserInGroupBM();
#endif
static int CheckNestedDirectories(char * basepath, int depth, int use_sandbox, int isManager);
static int CheckNestedDirectories(char * basepath, int depth,
int use_sandbox, int isManager,
char * path_to_error
);
#if (! defined(__WXMAC__) && ! defined(_MAC_INSTALLER))
static char * PersistentFGets(char *buf, size_t buflen, FILE *f);
@ -66,7 +69,7 @@ int check_security(
#ifdef _MAC_INSTALLER
char *bundlePath, char *dataPath,
#endif
int use_sandbox, int isManager
int use_sandbox, int isManager, char* path_to_error
) {
passwd *pw;
group *grp;
@ -358,7 +361,7 @@ saverName[2] = "Progress Thru Processors";
return -1026;
// Step through project directories
retval = CheckNestedDirectories(full_path, 1, use_sandbox, isManager);
retval = CheckNestedDirectories(full_path, 1, use_sandbox, isManager, path_to_error);
if (retval)
return retval;
}
@ -380,7 +383,7 @@ saverName[2] = "Progress Thru Processors";
return -1029;
// Step through slot directories
retval = CheckNestedDirectories(full_path, 1, use_sandbox, isManager);
retval = CheckNestedDirectories(full_path, 1, use_sandbox, isManager, path_to_error);
if (retval)
return retval;
}
@ -497,7 +500,10 @@ saverName[2] = "Progress Thru Processors";
}
static int CheckNestedDirectories(char * basepath, int depth, int use_sandbox, int isManager) {
static int CheckNestedDirectories(char * basepath, int depth,
int use_sandbox, int isManager,
char * path_to_error
) {
int isDirectory;
char full_path[MAXPATHLEN];
struct stat sbuf;
@ -583,7 +589,7 @@ static int CheckNestedDirectories(char * basepath, int depth, int use_sandbox, i
if ((! isManager) && (sbuf.st_uid != boinc_master_uid))
continue; // Client can't check subdirectories owned by boinc_project
}
retval = CheckNestedDirectories(full_path, depth + 1, use_sandbox, isManager);
retval = CheckNestedDirectories(full_path, depth + 1, use_sandbox, isManager, path_to_error);
if (retval)
break;
}
@ -594,6 +600,7 @@ static int CheckNestedDirectories(char * basepath, int depth, int use_sandbox, i
if (retval && !errShown) {
fprintf(stderr, "Permissions error %d at %s\n", retval, full_path);
if (path_to_error) strcpy(path_to_error, full_path);
errShown = 1;
}
return retval;

View File

@ -23,7 +23,7 @@ extern int client_clean_out_dir(const char*, const char* reason);
extern int delete_project_owned_file(const char* path, bool retry);
extern int remove_project_owned_dir(const char* name);
extern int remove_project_owned_file_or_dir(const char* path);
extern int check_security(int use_sandbox, int isManager);
extern int check_security(int use_sandbox, int isManager, char* path_to_error = NULL);
#define BOINC_PROJECT_GROUP_NAME "boinc_project"

View File

@ -294,46 +294,6 @@ bool CBOINCGUIApp::OnInit() {
wxHelpProvider::Set(new wxHelpControllerHelpProvider());
#ifdef SANDBOX
// Make sure owners, groups and permissions are correct for the current setting of g_use_sandbox
if (!iErrorCode) {
#if (defined(__WXMAC__) && defined(_DEBUG)) // TODO: implement this for other platforms
// GDB can't attach to applications which are running as a different user
// or group, so fix up data with current user and group during debugging
if (check_security(g_use_sandbox, true)) {
CreateBOINCUsersAndGroups();
SetBOINCDataOwnersGroupsAndPermissions();
SetBOINCAppOwnersGroupsAndPermissions(NULL);
}
#endif
iErrorCode = check_security(g_use_sandbox, true);
}
if (iErrorCode) {
ShowApplication(true);
if (iErrorCode == -1099) {
strDialogMessage =
_("You currently are not authorized to manage the client.\n\nTo run BOINC as this user, please:\n - reinstall BOINC answering \"Yes\" to the question about\n non-administrative users\n or\n - contact your administrator to add you to the 'boinc_master'\n user group.");
} else {
strDialogMessage.Printf(
_("BOINC ownership or permissions are not set properly; please reinstall BOINC.\n(Error code %d)"),
iErrorCode
);
}
wxMessageDialog* pDlg = new wxMessageDialog(NULL, strDialogMessage, wxT("BOINC Manager"), wxOK);
pDlg->ShowModal();
if (pDlg)
pDlg->Destroy();
return false;
}
#endif // SANDBOX
// Enable known image types
wxInitAllImageHandlers();
@ -351,6 +311,64 @@ bool CBOINCGUIApp::OnInit() {
m_pSkinManager->ReloadSkin(strDesiredSkinName);
#ifdef SANDBOX
// Make sure owners, groups and permissions are correct for the current setting of g_use_sandbox
char path_to_error[MAXPATHLEN];
path_to_error[0] = '\0';
if (!iErrorCode) {
#if (defined(__WXMAC__) && defined(_DEBUG)) // TODO: implement this for other platforms
// GDB can't attach to applications which are running as a different user
// or group, so fix up data with current user and group during debugging
if (check_security(g_use_sandbox, true)) {
CreateBOINCUsersAndGroups();
SetBOINCDataOwnersGroupsAndPermissions();
SetBOINCAppOwnersGroupsAndPermissions(NULL);
}
#endif
iErrorCode = check_security(g_use_sandbox, true, path_to_error);
}
if (iErrorCode) {
ShowApplication(true);
if (iErrorCode == -1099) {
strDialogMessage.Printf(
_("You currently are not authorized to manage the client.\n\nTo run %s as this user, please:\n - reinstall %s answering \"Yes\" to the question about\n non-administrative users\n or\n - contact your administrator to add you to the 'boinc_master'\n user group."),
m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str(),
m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str()
);
} else {
wxString strErrorPath = wxString::FromUTF8(path_to_error);
strDialogMessage.Printf(
_("%s ownership or permissions are not set properly; please reinstall %s.\n(Error code %d at %s)"),
m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str(),
m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str(),
iErrorCode , strErrorPath.c_str()
);
fprintf(stderr, "%ls ownership or permissions are not set properly; please reinstall %ls.\n(Error code %d at %s)",
m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str(),
m_pSkinManager->GetAdvanced()->GetApplicationShortName().c_str(),
iErrorCode, path_to_error
);
}
wxMessageDialog* pDlg = new wxMessageDialog(
NULL,
strDialogMessage,
m_pSkinManager->GetAdvanced()->GetApplicationName(),
wxOK
);
pDlg->ShowModal();
if (pDlg)
pDlg->Destroy();
return false;
}
#endif // SANDBOX
#ifdef __WXMSW__
// Perform any last minute checks that should keep the manager
// from starting up.

View File

@ -112,7 +112,10 @@ static OSErr QuitAppleEventHandler(const AppleEvent *appleEvt, AppleEvent* reply
void print_to_log_file(const char *format, ...);
void strip_cr(char *buf);
extern int check_security(char *bundlePath, char *dataPath, int use_sandbox, int isManager);
extern int check_security(char *bundlePath, char *dataPath,
int use_sandbox, int isManager,
char* path_to_error = NULL
);
#define NUMBRANDS 4