diff --git a/src/group/Group.cc b/src/group/Group.cc
index e2010f42d5..a3ddb0033c 100644
--- a/src/group/Group.cc
+++ b/src/group/Group.cc
@@ -24,10 +24,12 @@
const char * Group::table = "group_pool";
-const char * Group::db_names = "oid, name, body";
+const char * Group::db_names =
+ "oid, name, body, uid, gid, owner_u, group_u, other_u";
const char * Group::db_bootstrap = "CREATE TABLE IF NOT EXISTS group_pool ("
- "oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, "
+ "oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, "
+ "gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, "
"UNIQUE(name))";
/* ************************************************************************ */
@@ -44,6 +46,12 @@ int Group::insert_replace(SqlDB *db, bool replace, string& error_str)
char * sql_name;
char * sql_xml;
+ // Set oneadmin as the owner
+ set_user(0,"");
+
+ // Set the Group ID as the group it belongs to
+ set_group(oid, name);
+
// Update the Group
sql_name = db->escape_str(name.c_str());
@@ -79,7 +87,13 @@ int Group::insert_replace(SqlDB *db, bool replace, string& error_str)
oss <<" INTO "<
exec(oss);
diff --git a/src/host/Host.cc b/src/host/Host.cc
index 630322f617..50c8da083d 100644
--- a/src/host/Host.cc
+++ b/src/host/Host.cc
@@ -60,11 +60,13 @@ Host::~Host()
const char * Host::table = "host_pool";
-const char * Host::db_names = "oid, name, body, state, last_mon_time";
+const char * Host::db_names =
+ "oid, name, body, state, last_mon_time, uid, gid, owner_u, group_u, other_u";
const char * Host::db_bootstrap = "CREATE TABLE IF NOT EXISTS host_pool ("
"oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, state INTEGER, "
- "last_mon_time INTEGER, UNIQUE(name))";
+ "last_mon_time INTEGER, uid INTEGER, gid INTEGER, owner_u INTEGER, "
+ "group_u INTEGER, other_u INTEGER, UNIQUE(name))";
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
@@ -79,6 +81,10 @@ int Host::insert_replace(SqlDB *db, bool replace, string& error_str)
char * sql_hostname;
char * sql_xml;
+ // Set the owner and group to oneadmin
+ set_user(0, "");
+ set_group(GroupPool::ONEADMIN_ID, GroupPool::ONEADMIN_NAME);
+
// Update the Host
sql_hostname = db->escape_str(name.c_str());
@@ -116,7 +122,12 @@ int Host::insert_replace(SqlDB *db, bool replace, string& error_str)
<< "'" << sql_hostname << "',"
<< "'" << sql_xml << "',"
<< state << ","
- << last_monitored << ")";
+ << last_monitored << ","
+ << uid << ","
+ << gid << ","
+ << owner_u << ","
+ << group_u << ","
+ << other_u << ")";
rc = db->exec(oss);
diff --git a/src/um/User.cc b/src/um/User.cc
index 303e37ae19..f971d2d335 100644
--- a/src/um/User.cc
+++ b/src/um/User.cc
@@ -36,10 +36,13 @@ const string User::INVALID_PASS_CHARS = " \t\n\v\f\r";
const char * User::table = "user_pool";
-const char * User::db_names = "oid,name,body";
+const char * User::db_names =
+ "oid, name, body, uid, gid, owner_u, group_u, other_u";
const char * User::db_bootstrap = "CREATE TABLE IF NOT EXISTS user_pool ("
- "oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, UNIQUE(name))";
+ "oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, "
+ "gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, "
+ "UNIQUE(name))";
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
@@ -54,6 +57,9 @@ int User::insert_replace(SqlDB *db, bool replace, string& error_str)
char * sql_username;
char * sql_xml;
+ // Set itself as the owner
+ set_user(oid, name);
+
// Update the User
sql_username = db->escape_str(name.c_str());
@@ -88,7 +94,13 @@ int User::insert_replace(SqlDB *db, bool replace, string& error_str)
oss << " INTO " << table << " ("<< db_names <<") VALUES ("
<< oid << ","
<< "'" << sql_username << "',"
- << "'" << sql_xml << "')";
+ << "'" << sql_xml << "',"
+ << uid << ","
+ << gid << ","
+ << owner_u << ","
+ << group_u << ","
+ << other_u << ")";
+
rc = db->exec(oss);