From e9ddf9f268794c781ef2673118a54d641c642a6e Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Fri, 9 Jun 2006 23:57:41 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=10292 --- checkin_notes | 12 ++++++++++++ client/app_start.C | 2 +- client/client_state.C | 4 +++- client/client_state.h | 2 +- client/client_types.C | 2 +- lib/shmem.C | 22 ++++++++++++++++++++-- lib/shmem.h | 2 +- 7 files changed, 39 insertions(+), 7 deletions(-) diff --git a/checkin_notes b/checkin_notes index dc93edfc87..675d40abe9 100755 --- a/checkin_notes +++ b/checkin_notes @@ -5749,3 +5749,15 @@ David 9 June 2006 validate_util.C,h validate_util2.C,h (new) validator_placeholder.C + +Charlie 9 June 2006 + - Changes for sandbox: + Renamed global variable boinc_project_gid to g_boinc_project_gid. + Change shared memory segment group to g_boinc_project_gid. + + client/ + app_start.C + client_state.C,h + client_types.C + lib/ + shmem.C,h diff --git a/client/app_start.C b/client/app_start.C index e7e0709c2c..ce13616fa1 100644 --- a/client/app_start.C +++ b/client/app_start.C @@ -489,7 +489,7 @@ int ACTIVE_TASK::start(bool first_time) { // if (!app_client_shm.shm) { retval = create_shmem( - shmem_seg_name, sizeof(SHARED_MEM), (void**)&app_client_shm.shm + shmem_seg_name, sizeof(SHARED_MEM), g_boinc_project_gid, (void**)&app_client_shm.shm ); if (retval) { msg_printf( diff --git a/client/client_state.C b/client/client_state.C index 21dcfca6e5..3348da50f8 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -52,6 +52,8 @@ using std::max; CLIENT_STATE gstate; +gid_t g_boinc_project_gid; + CLIENT_STATE::CLIENT_STATE() { net_xfers = new NET_XFER_SET; http_ops = new HTTP_OP_SET(net_xfers); @@ -301,7 +303,7 @@ int CLIENT_STATE::init() { } #ifdef SANDBOX - retval = lookup_group(BOINC_PROJECT_GROUP_NAME, boinc_project_gid); + retval = lookup_group(BOINC_PROJECT_GROUP_NAME, g_boinc_project_gid); if (retval) return retval; #endif diff --git a/client/client_state.h b/client/client_state.h index 7e7ccd02eb..583f8a85a1 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -472,7 +472,7 @@ extern CLIENT_STATE gstate; #ifdef SANDBOX #define BOINC_PROJECT_GROUP_NAME "boinc_project" -extern gid_t boinc_project_gid; +extern gid_t g_boinc_project_gid; #endif // return a random double in the range [MIN,min(e^n,MAX)) diff --git a/client/client_types.C b/client/client_types.C index 016eb002dd..7ca9fc4045 100644 --- a/client/client_types.C +++ b/client/client_types.C @@ -556,7 +556,7 @@ int FILE_INFO::set_permissions() { // in case someone runs BOINC from different user #ifdef SANDBOX - retval = chown(pathname, -1, boinc_project_gid); + retval = chown(pathname, (uid_t)-1, g_boinc_project_gid); if (retval) return retval; if (executable) { retval = chmod(pathname, diff --git a/lib/shmem.C b/lib/shmem.C index d803b03426..4d01ebc872 100755 --- a/lib/shmem.C +++ b/lib/shmem.C @@ -159,10 +159,29 @@ int detach_shmem(void* p) { #else -int create_shmem(key_t key, int size, void** pp) { +int create_shmem(key_t key, int size, gid_t gid, void** pp) { int id; +#ifdef SANDBOX + int retval; + struct shmid_ds buf; +#endif + id = shmget(key, size, IPC_CREAT|0660); if (id < 0) { +#ifdef SANDBOX + // Set the shmem segment's group ID + retval = shmctl(id, IPC_STAT, &buf); + if (retval) { + perror("shmget: shmctl STAT"); + return ERR_SHMGET; + } + buf.shm_perm.gid = gid; + retval = shmctl(id, IPC_SET, &buf); + if (retval) { + perror("shmget: shmctl IPC_SET"); + return ERR_SHMGET; + } +#endif id = shmget(key, size, IPC_CREAT|SHM_R|SHM_W); } if (id < 0) { @@ -170,7 +189,6 @@ int create_shmem(key_t key, int size, void** pp) { return ERR_SHMGET; } return attach_shmem(key, pp); - } int destroy_shmem(key_t key){ diff --git a/lib/shmem.h b/lib/shmem.h index 19b3cbbd0f..a1ebbece83 100755 --- a/lib/shmem.h +++ b/lib/shmem.h @@ -47,7 +47,7 @@ int detach_shmem(HANDLE hSharedMem, void* p); // create a shared-memory segment of the given size. // -extern int create_shmem(key_t, int size, void**); +extern int create_shmem(key_t, int size, gid_t gid, void**); // Destroy a shared-memory segment. // If there are attachments to it,