diff --git a/oam/oamcpp/liboamcpp.cpp b/oam/oamcpp/liboamcpp.cpp index f85df737a..341b37340 100644 --- a/oam/oamcpp/liboamcpp.cpp +++ b/oam/oamcpp/liboamcpp.cpp @@ -8194,8 +8194,10 @@ namespace oam int Oam::glusterctl(GLUSTER_COMMANDS command, std::string argument1, std::string& argument2, std::string& errmsg) { #ifndef _MSC_VER - int user; + int user,group; user = getuid(); + group = getgid(); + string glustercmd = "gluster "; if (user!=0) @@ -8424,6 +8426,23 @@ namespace oam writeLog("ERROR: command failed: " + command,LOG_TYPE_DEBUG); exceptionControl("GLUSTER_ADD", API_FAILURE); } + if (user != 0) + { + command = "sudo gluster volume set dbroot" + itoa(newDbrootID) + " storage.owner-uid " + itoa(user) + " >> /tmp/glusterCommands.txt 2>&1";; + status = system(command.c_str()); + if (WEXITSTATUS(status) != 0 ) + { + writeLog("ERROR: command failed: ",LOG_TYPE_DEBUG); + exceptionControl("GLUSTER_ADD", API_FAILURE); + } + command = "sudo gluster volume set dbroot" + itoa(newDbrootID) + " storage.owner-gid " + itoa(group) + " >> /tmp/glusterCommands.txt 2>&1";; + status = system(command.c_str()); + if (WEXITSTATUS(status) != 0 ) + { + writeLog("ERROR: command failed: ",LOG_TYPE_DEBUG); + exceptionControl("GLUSTER_ADD", API_FAILURE); + } + } command = glustercmd + "volume start dbroot" + itoa(newDbrootID) + " >> /tmp/glusterCommands.txt 2>&1"; status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index f92372549..195a849ea 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -254,7 +254,9 @@ int main(int argc, char *argv[]) //check if root-user int user; + int usergroup; user = getuid(); + usergroup = getgid(); if (user != 0) rootUser = false; @@ -5971,16 +5973,38 @@ bool glusterSetup(string password) { if (rootUser) { command = "gluster volume start dbroot" + oam.itoa(dbrootID) + " >> /tmp/glusterCommands.txt 2>&1"; + status = system(command.c_str()); + if (WEXITSTATUS(status) != 0 ) + { + cout << "ERROR: Failed to start dbroot" << oam.itoa(dbrootID) << endl; + exit(1); + } } else { + int user = getuid(); + int group = getgid(); + command = "sudo gluster volume set dbroot" + oam.itoa(dbrootID) + " storage.owner-uid " + oam.itoa(user) + " >> /tmp/glusterCommands.txt 2>&1";; + status = system(command.c_str()); + if (WEXITSTATUS(status) != 0 ) + { + cout << "ERROR: Failed to start dbroot" << oam.itoa(dbrootID) << endl; + exit(1); + } + command = "sudo gluster volume set dbroot" + oam.itoa(dbrootID) + " storage.owner-gid " + oam.itoa(group) + " >> /tmp/glusterCommands.txt 2>&1";; + status = system(command.c_str()); + if (WEXITSTATUS(status) != 0 ) + { + cout << "ERROR: Failed to start dbroot" << oam.itoa(dbrootID) << endl; + exit(1); + } command = "sudo gluster volume start dbroot" + oam.itoa(dbrootID) + " >> /tmp/glusterCommands.txt 2>&1"; - } - status = system(command.c_str()); - if (WEXITSTATUS(status) != 0 ) - { - cout << "ERROR: Failed to start dbroot" << oam.itoa(dbrootID) << endl; - exit(1); + status = system(command.c_str()); + if (WEXITSTATUS(status) != 0 ) + { + cout << "ERROR: Failed to start dbroot" << oam.itoa(dbrootID) << endl; + exit(1); + } } cout << "DONE" << endl; }