mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Feature #862: Add uid,gid and USE permissions columns to Group, Host and User tables
This commit is contained in:
parent
c19345db50
commit
a5005f5533
@ -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 "<<table <<" ("<< db_names <<") VALUES ("
|
||||
<< oid << ","
|
||||
<< "'" << sql_name << "',"
|
||||
<< "'" << sql_xml << "')";
|
||||
<< "'" << sql_xml << "',"
|
||||
<< uid << ","
|
||||
<< gid << ","
|
||||
<< owner_u << ","
|
||||
<< group_u << ","
|
||||
<< other_u << ")";
|
||||
|
||||
|
||||
rc = db->exec(oss);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user