diff --git a/oam/install_scripts/post-install b/oam/install_scripts/post-install index 38e21cb8b..98a7e4a02 100755 --- a/oam/install_scripts/post-install +++ b/oam/install_scripts/post-install @@ -191,6 +191,12 @@ mkdir -p $hdfsDir >/dev/null 2>&1 #create mount directories mkdir /mnt/tmp > /dev/null 2>&1 +#create shared memory if non-root +if [ $user != "root" ]; then + mkdir -p ${installdir}/dev/shm + chmod 666 ${installdir}/dev/shm +fi + # remove mysql archive log test -d $installdir/mysql/db || mkdir -p $installdir/mysql/db rm -rf $installdir/mysql/db/columnstore_log_archive > /dev/null 2>&1 diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index 1c864c833..31239341f 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -852,7 +852,7 @@ int main(int argc, char* argv[]) if (temp == "1") { singleServerInstall = temp; - cout << endl << "Performing the Single Server Install." << endl; + cout << endl << "Performing the Single Server Install." << endl << endl; if ( reuseConfig == "n" ) { diff --git a/procmon/main.cpp b/procmon/main.cpp index 6047f2dfa..688424f1e 100644 --- a/procmon/main.cpp +++ b/procmon/main.cpp @@ -1886,6 +1886,11 @@ static void statusControlThread() // //Allocate Shared Memory for storing Process Status Data // + + string shmLocation = "/dev/shm/"; + if ( !rootUser) + shmLocation = startup::StartUp::installDir() + "/dev/shm/"; + PROCSTATshmsize = MAX_PROCESS * sizeof(shmProcessStatus); bool memInit = true; #if 0 @@ -1914,7 +1919,7 @@ static void statusControlThread() bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); #ifdef __linux__ { - string pname = "/dev/shm/" + keyName; + string pname = shmLocation + keyName; chmod(pname.c_str(), 0666); } #endif @@ -1992,7 +1997,7 @@ static void statusControlThread() bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); #ifdef __linux__ { - string pname = "/dev/shm/" + keyName; + string pname = shmLocation + keyName; chmod(pname.c_str(), 0666); } #endif @@ -2111,7 +2116,7 @@ static void statusControlThread() bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); #ifdef __linux__ { - string pname = "/dev/shm/" + keyName; + string pname = shmLocation + keyName; chmod(pname.c_str(), 0666); } #endif @@ -2209,7 +2214,7 @@ static void statusControlThread() bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); #ifdef __linux__ { - string pname = "/dev/shm/" + keyName; + string pname = shmLocation + keyName; chmod(pname.c_str(), 0666); } #endif @@ -2299,7 +2304,7 @@ static void statusControlThread() bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); #ifdef __linux__ { - string pname = "/dev/shm/" + keyName; + string pname = shmLocation + keyName; chmod(pname.c_str(), 0666); } #endif diff --git a/utils/rwlock/rwlock.cpp b/utils/rwlock/rwlock.cpp index 8d37b5124..4ffec938f 100644 --- a/utils/rwlock/rwlock.cpp +++ b/utils/rwlock/rwlock.cpp @@ -52,6 +52,8 @@ using namespace boost::posix_time; #include "shmkeys.h" +#include "installdir.h" + namespace { using namespace rwlock; @@ -141,13 +143,26 @@ RWLockShmImpl::RWLockShmImpl(int key, bool excl) string keyName = BRM::ShmKeys::keyToName(key); fKeyString = keyName; + bool rootUser = true; + + //check if root-user + int user; + user = getuid(); + + if (user != 0) + rootUser = false; + + string shmLocation = "/dev/shm/"; + if ( !rootUser) + shmLocation = startup::StartUp::installDir() + "/dev/shm/"; + try { #if BOOST_VERSION < 104500 bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); #ifdef __linux__ { - string pname = "/dev/shm/" + keyName; + string pname = shmLocation + keyName; chmod(pname.c_str(), 0666); } #endif diff --git a/versioning/BRM/brmshmimpl.cpp b/versioning/BRM/brmshmimpl.cpp index f5985fc8f..38584760e 100644 --- a/versioning/BRM/brmshmimpl.cpp +++ b/versioning/BRM/brmshmimpl.cpp @@ -36,6 +36,8 @@ namespace bi = boost::interprocess; #include "brmshmimpl.h" #include "brmtypes.h" +#include "installdir.h" + namespace BRM { @@ -44,6 +46,19 @@ BRMShmImpl::BRMShmImpl(unsigned key, off_t size, bool readOnly) : { string keyName = ShmKeys::keyToName(fKey); + bool rootUser = true; + + //check if root-user + int user; + user = getuid(); + + if (user != 0) + rootUser = false; + + string shmLocation = "/dev/shm/"; + if ( !rootUser) + shmLocation = startup::StartUp::installDir() + "/dev/shm/"; + if (fSize == 0) { unsigned tries = 0; @@ -89,7 +104,7 @@ again: bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); #ifdef __linux__ { - string pname = "/dev/shm/" + keyName; + string pname = "shmLocation + keyName; chmod(pname.c_str(), 0666); } #endif @@ -147,7 +162,7 @@ int BRMShmImpl::grow(unsigned newKey, off_t newSize) bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); #ifdef __linux__ { - string pname = "/dev/shm/" + keyName; + string pname = shmLocation + keyName; chmod(pname.c_str(), 0666); } #endif @@ -194,7 +209,7 @@ int BRMShmImpl::clear(unsigned newKey, off_t newSize) bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); #ifdef __linux__ { - string pname = "/dev/shm/" + keyName; + string pname = shmLocation + keyName; chmod(pname.c_str(), 0666); } #endif diff --git a/versioning/BRM/mastersegmenttable.cpp b/versioning/BRM/mastersegmenttable.cpp index 4d5816f41..0abf81c0c 100644 --- a/versioning/BRM/mastersegmenttable.cpp +++ b/versioning/BRM/mastersegmenttable.cpp @@ -41,6 +41,8 @@ using namespace rwlock; #include "mastersegmenttable.h" #undef MASTERSEGMENTTABLE_DLLEXPORT +#include "installdir.h" + namespace { using namespace BRM; @@ -73,13 +75,26 @@ MasterSegmentTableImpl::MasterSegmentTableImpl(int key, int size) { string keyName = ShmKeys::keyToName(key); + bool rootUser = true; + + //check if root-user + int user; + user = getuid(); + + if (user != 0) + rootUser = false; + + string shmLocation = "/dev/shm/"; + if ( !rootUser) + shmLocation = startup::StartUp::installDir() + "/dev/shm/"; + try { #if BOOST_VERSION < 104500 bi::shared_memory_object shm(bi::create_only, keyName.c_str(), bi::read_write); #ifdef __linux__ { - string pname = "/dev/shm/" + keyName; + string pname = shmLocation + keyName; chmod(pname.c_str(), 0666); } #endif @@ -96,7 +111,7 @@ MasterSegmentTableImpl::MasterSegmentTableImpl(int key, int size) bi::shared_memory_object shm(bi::open_only, keyName.c_str(), bi::read_write); #ifdef __linux__ { - string pname = "/dev/shm/" + keyName; + string pname = shmLocation + keyName; chmod(pname.c_str(), 0666); } #endif