From 5a0d617af0ce7f43ae502b16d2099b3b9c0d0f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 7 Jun 2011 17:00:14 +0200 Subject: [PATCH] Feature #662: Add a user to the default USERS group when it is allocated. This needs to be done when the user creation is done outside the RM. --- src/rm/RequestManagerAllocate.cc | 14 +++++++++++++- src/um/UserPool.cc | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/rm/RequestManagerAllocate.cc b/src/rm/RequestManagerAllocate.cc index 35dbeae9e5..ed942e06de 100644 --- a/src/rm/RequestManagerAllocate.cc +++ b/src/rm/RequestManagerAllocate.cc @@ -212,6 +212,7 @@ int UserAllocate::pool_allocate(xmlrpc_c::paramList const& paramList, string passwd = xmlrpc_c::value_string(paramList.getString(2)); UserPool * upool = static_cast(pool); + User * user; int rc = upool->allocate(&id,GroupPool::USERS_ID,uname,passwd,true,error_str); @@ -220,9 +221,20 @@ int UserAllocate::pool_allocate(xmlrpc_c::paramList const& paramList, return rc; } + user = static_cast(pool->get(id,true)); + + if( user == 0 ) + { + return -1; + } + + user->add_group(GroupPool::USERS_ID); + pool->update(user); + user->unlock(); + Nebula& nd = Nebula::instance(); GroupPool * gpool = nd.get_gpool(); - Group * group = gpool->get(gid, true); + Group * group = gpool->get(GroupPool::USERS_ID, true); if( group == 0 ) { diff --git a/src/um/UserPool.cc b/src/um/UserPool.cc index 9d79ded225..0766d9ba87 100644 --- a/src/um/UserPool.cc +++ b/src/um/UserPool.cc @@ -88,6 +88,7 @@ UserPool::UserPool(SqlDB * db):PoolSQL(db,User::table) string error_str; string sha1_pass = SSLTools::sha1_digest(one_pass); + // TODO: Add oneadmin to ONEADMIN Group allocate(&one_uid,GroupPool::ONEADMIN_ID,one_name,sha1_pass, true, error_str); } @@ -256,6 +257,7 @@ bool UserPool::authenticate(const string& session, int& user_id, int& group_id) if ( !is.fail() ) { + // TODO: Add new user to USERS Group allocate(&user_id, GroupPool::USERS_ID, mad_name,