mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
Feature #1742: chgrp does not delete the user from the previous group
This allows users to use the chgrp to change their own primary group to one of the secondary ones
This commit is contained in:
parent
d0b28bc90a
commit
913a96f7e8
@ -317,6 +317,8 @@ void UserChown::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
int rc;
|
||||
|
||||
bool remove_old_group;
|
||||
|
||||
string ngname;
|
||||
string uname;
|
||||
|
||||
@ -399,8 +401,17 @@ void UserChown::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
user->set_group(ngid,ngname);
|
||||
|
||||
user->add_group(ngid);
|
||||
user->del_group(old_gid);
|
||||
// The user is removed from the old group only if the new group is not a
|
||||
// secondary one
|
||||
|
||||
rc = user->add_group(ngid);
|
||||
|
||||
remove_old_group = (rc == 0);
|
||||
|
||||
if (remove_old_group)
|
||||
{
|
||||
user->del_group(old_gid);
|
||||
}
|
||||
|
||||
upool->update(user);
|
||||
|
||||
@ -426,15 +437,18 @@ void UserChown::request_execute(xmlrpc_c::paramList const& paramList,
|
||||
|
||||
// ------------- Updates old group removing the user ---------------------
|
||||
|
||||
group = gpool->get(old_gid, true);
|
||||
|
||||
if( group != 0 )
|
||||
if (remove_old_group)
|
||||
{
|
||||
group->del_user(oid);
|
||||
group = gpool->get(old_gid, true);
|
||||
|
||||
gpool->update(group);
|
||||
if( group != 0 )
|
||||
{
|
||||
group->del_user(oid);
|
||||
|
||||
group->unlock();
|
||||
gpool->update(group);
|
||||
|
||||
group->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
success_response(oid, att);
|
||||
|
Loading…
Reference in New Issue
Block a user