diff --git a/include/Request.h b/include/Request.h index faea23d7e0..c51ce85968 100644 --- a/include/Request.h +++ b/include/Request.h @@ -73,11 +73,13 @@ protected: string uname; /**< name of the user */ string gname; /**< name of the user's group */ - set group_ids; /**< set of user's group ids */ + set group_ids; /**< set of user's group ids */ string session; /**< Session from ONE XML-RPC API */ int req_id; /**< Request ID for log messages */ + int umask; /**< User umask for new objects */ + xmlrpc_c::value * retval; /**< Return value from libxmlrpc-c */ RequestAttributes(){}; @@ -92,6 +94,8 @@ protected: session = ra.session; retval = ra.retval; + + umask = ra.umask; }; RequestAttributes(int _uid, int _gid, const RequestAttributes& ra) @@ -102,6 +106,8 @@ protected: uname = ""; gname = ""; + umask = 0; + session = ra.session; retval = ra.retval; }; diff --git a/include/RequestManagerAllocate.h b/include/RequestManagerAllocate.h index bd6d91878a..223dadc306 100644 --- a/include/RequestManagerAllocate.h +++ b/include/RequestManagerAllocate.h @@ -61,12 +61,11 @@ protected: virtual Template * get_object_template() { return 0; }; - virtual int pool_allocate(xmlrpc_c::paramList const& _paramList, + virtual int pool_allocate(xmlrpc_c::paramList const& _paramList, Template * tmpl, - int& id, + int& id, string& error_str, - RequestAttributes& att, - int umask) + RequestAttributes& att) { return -1; }; @@ -77,10 +76,9 @@ protected: string& error_str, RequestAttributes& att, int cluster_id, - const string& cluster_name, - int umask) + const string& cluster_name) { - return pool_allocate(_paramList, tmpl, id, error_str, att, umask); + return pool_allocate(_paramList, tmpl, id, error_str, att); }; virtual int get_cluster_id(xmlrpc_c::paramList const& paramList) @@ -122,7 +120,7 @@ public: "Allocates a new virtual machine", "A:ssb", true) - { + { Nebula& nd = Nebula::instance(); pool = nd.get_vmpool(); auth_object = PoolObjectSQL::VM; @@ -132,17 +130,16 @@ public: /* --------------------------------------------------------------------- */ - Template * get_object_template() - { - return new VirtualMachineTemplate; + Template * get_object_template() + { + return new VirtualMachineTemplate; }; - int pool_allocate(xmlrpc_c::paramList const& _paramList, + int pool_allocate(xmlrpc_c::paramList const& _paramList, Template * tmpl, - int& id, + int& id, string& error_str, - RequestAttributes& att, - int umask); + RequestAttributes& att); bool allocate_authorization(Template * obj_template, RequestAttributes& att, @@ -160,7 +157,7 @@ public: "Allocates a new virtual network", "A:ssi", true) - { + { Nebula& nd = Nebula::instance(); pool = nd.get_vnpool(); auth_object = PoolObjectSQL::NET; @@ -170,9 +167,9 @@ public: /* --------------------------------------------------------------------- */ - Template * get_object_template() - { - return new VirtualNetworkTemplate; + Template * get_object_template() + { + return new VirtualNetworkTemplate; }; int pool_allocate(xmlrpc_c::paramList const& _paramList, @@ -181,8 +178,7 @@ public: string& error_str, RequestAttributes& att, int cluster_id, - const string& cluster_name, - int umask); + const string& cluster_name); int get_cluster_id(xmlrpc_c::paramList const& paramList) { @@ -235,7 +231,7 @@ public: "Allocates a new virtual machine template", "A:ss", true) - { + { Nebula& nd = Nebula::instance(); pool = nd.get_tpool(); auth_object = PoolObjectSQL::TEMPLATE; @@ -245,17 +241,16 @@ public: /* --------------------------------------------------------------------- */ - Template * get_object_template() - { - return new VirtualMachineTemplate; + Template * get_object_template() + { + return new VirtualMachineTemplate; }; - int pool_allocate(xmlrpc_c::paramList const& _paramList, + int pool_allocate(xmlrpc_c::paramList const& _paramList, Template * tmpl, - int& id, + int& id, string& error_str, - RequestAttributes& att, - int umask); + RequestAttributes& att); }; /* ------------------------------------------------------------------------- */ @@ -269,7 +264,7 @@ public: "Allocates a new host", "A:sssssi", false) - { + { Nebula& nd = Nebula::instance(); pool = nd.get_hpool(); auth_object = PoolObjectSQL::HOST; @@ -285,8 +280,7 @@ public: string& error_str, RequestAttributes& att, int cluster_id, - const string& cluster_name, - int umask); + const string& cluster_name); int get_cluster_id(xmlrpc_c::paramList const& paramList) { @@ -314,7 +308,7 @@ public: "Returns user information", "A:ssss", false) - { + { Nebula& nd = Nebula::instance(); pool = nd.get_upool(); auth_object = PoolObjectSQL::USER; @@ -322,12 +316,11 @@ public: ~UserAllocate(){}; - int pool_allocate(xmlrpc_c::paramList const& _paramList, + int pool_allocate(xmlrpc_c::paramList const& _paramList, Template * tmpl, - int& id, + int& id, string& error_str, - RequestAttributes& att, - int umask); + RequestAttributes& att); void log_xmlrpc_param( const xmlrpc_c::value& v, @@ -346,7 +339,7 @@ public: "Allocates a new group", "A:ss", false) - { + { Nebula& nd = Nebula::instance(); pool = nd.get_gpool(); auth_object = PoolObjectSQL::GROUP; @@ -354,12 +347,11 @@ public: ~GroupAllocate(){}; - int pool_allocate(xmlrpc_c::paramList const& _paramList, + int pool_allocate(xmlrpc_c::paramList const& _paramList, Template * tmpl, - int& id, + int& id, string& error_str, - RequestAttributes& att, - int umask); + RequestAttributes& att); }; /* ------------------------------------------------------------------------- */ @@ -394,8 +386,7 @@ public: string& error_str, RequestAttributes& att, int cluster_id, - const string& cluster_name, - int umask); + const string& cluster_name); int get_cluster_id(xmlrpc_c::paramList const& paramList) { @@ -449,8 +440,7 @@ public: Template * tmpl, int& id, string& error_str, - RequestAttributes& att, - int umask); + RequestAttributes& att); }; /* ------------------------------------------------------------------------- */ @@ -483,8 +473,7 @@ public: Template * tmpl, int& id, string& error_str, - RequestAttributes& att, - int umask); + RequestAttributes& att); }; /* ------------------------------------------------------------------------- */ @@ -520,8 +509,7 @@ public: Template * tmpl, int& id, string& error_str, - RequestAttributes& att, - int umask); + RequestAttributes& att); }; /* -------------------------------------------------------------------------- */ diff --git a/include/RequestManagerClone.h b/include/RequestManagerClone.h index 0cad867228..5107f65db0 100644 --- a/include/RequestManagerClone.h +++ b/include/RequestManagerClone.h @@ -49,8 +49,7 @@ protected: Template * tmpl, int& id, string& error_str, - RequestAttributes& att, - int umask) = 0; + RequestAttributes& att) = 0; }; /* ------------------------------------------------------------------------- */ @@ -84,15 +83,14 @@ public: Template * tmpl, int& id, string& error_str, - RequestAttributes& att, - int umask) + RequestAttributes& att) { VMTemplatePool * tpool = static_cast(pool); VirtualMachineTemplate * ttmpl = static_cast(tmpl); - return tpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, + return tpool->allocate(att.uid, att.gid, att.uname, att.gname, att.umask, ttmpl, &id, error_str); }; }; @@ -129,14 +127,13 @@ public: Template * tmpl, int& id, string& error_str, - RequestAttributes& att, - int umask) + RequestAttributes& att) { DocumentPool * docpool = static_cast(pool); Document * doc = docpool->get(source_id, true); - return docpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, - doc->get_document_type(), tmpl, &id, error_str); + return docpool->allocate(att.uid, att.gid, att.uname, att.gname, + att.umask, doc->get_document_type(), tmpl, &id, error_str); }; }; diff --git a/include/User.h b/include/User.h index 0d40bf23c0..6e7a1520a9 100644 --- a/include/User.h +++ b/include/User.h @@ -168,6 +168,13 @@ public: */ int get_umask() const; + /** + * Returns the default UMASK attribute (octal) from oned.conf + * + * @return the UMASK to create new objects + */ + static int get_default_umask(); + /** * Returns a copy of the groups for the user */ diff --git a/include/UserPool.h b/include/UserPool.h index 38a8fc5117..5f9cdde3ce 100644 --- a/include/UserPool.h +++ b/include/UserPool.h @@ -140,6 +140,7 @@ public: * @param uname of the user if authN succeeded "" otherwise * @param gname of the group if authN succeeded "" otherwise * @param group_ids the user groups if authN succeeded, is empty otherwise + * @param umask of the user, 0 otherwise * * @return false if authn failed, true otherwise */ @@ -148,7 +149,8 @@ public: int& gid, string& uname, string& gname, - set& group_ids); + set& group_ids, + int& umask); /** * Returns whether the operations described in a authorization request are * authorized ot not. @@ -223,7 +225,8 @@ private: int& group_id, string& uname, string& gname, - set& group_ids); + set& group_ids, + int& umask); /** * Function to authenticate internal users using a server driver @@ -234,7 +237,8 @@ private: int& group_id, string& uname, string& gname, - set& group_ids); + set& group_ids, + int& umask); /** @@ -246,7 +250,8 @@ private: int& group_id, string& uname, string& gname, - set& group_ids); + set& group_ids, + int& umask); /** * Factory method to produce User objects * @return a pointer to the new User diff --git a/src/rm/Request.cc b/src/rm/Request.cc index 40ce02572a..f0f5d4c0f8 100644 --- a/src/rm/Request.cc +++ b/src/rm/Request.cc @@ -36,12 +36,13 @@ void Request::execute( Nebula& nd = Nebula::instance(); UserPool* upool = nd.get_upool(); - bool authenticated = upool->authenticate( att.session, - att.uid, - att.gid, - att.uname, - att.gname, - att.group_ids); + bool authenticated = upool->authenticate(att.session, + att.uid, + att.gid, + att.uname, + att.gname, + att.group_ids, + att.umask); log_method_invoked(att, _paramList); diff --git a/src/rm/RequestManagerAllocate.cc b/src/rm/RequestManagerAllocate.cc index f4188c8aa0..7178ca0c9d 100644 --- a/src/rm/RequestManagerAllocate.cc +++ b/src/rm/RequestManagerAllocate.cc @@ -131,31 +131,13 @@ void RequestManagerAllocate::request_execute(xmlrpc_c::paramList const& params, Template * tmpl = 0; string error_str; - int rc, id, umask; + int rc, id; Cluster * cluster = 0; int cluster_id = ClusterPool::NONE_CLUSTER_ID; string cluster_name = ClusterPool::NONE_CLUSTER_NAME; PoolObjectAuth cluster_perms; - User * user; - UserPool * upool = Nebula::instance().get_upool(); - - user = upool->get(att.uid, true); - - if ( user == 0 ) - { - failure_response(NO_EXISTS, - get_error(object_name(PoolObjectSQL::USER), att.uid), - att); - - return; - } - - umask = user->get_umask(); - - user->unlock(); - if ( do_template == true ) { string str_tmpl = xmlrpc_c::value_string(params.getString(1)); @@ -197,7 +179,7 @@ void RequestManagerAllocate::request_execute(xmlrpc_c::paramList const& params, return; } - rc = pool_allocate(params, tmpl, id, error_str, att, cluster_id, cluster_name, umask); + rc = pool_allocate(params, tmpl, id, error_str,att,cluster_id,cluster_name); if ( rc < 0 ) { @@ -257,8 +239,7 @@ int VirtualMachineAllocate::pool_allocate( Template * tmpl, int& id, string& error_str, - RequestAttributes& att, - int umask) + RequestAttributes& att) { bool on_hold = false; @@ -272,7 +253,7 @@ int VirtualMachineAllocate::pool_allocate( Template tmpl_back(*tmpl); - int rc = vmpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, + int rc = vmpool->allocate(att.uid, att.gid, att.uname, att.gname, att.umask, ttmpl, &id, error_str, on_hold); if ( rc < 0 ) @@ -294,13 +275,12 @@ int VirtualNetworkAllocate::pool_allocate( string& error_str, RequestAttributes& att, int cluster_id, - const string& cluster_name, - int umask) + const string& cluster_name) { VirtualNetworkPool * vpool = static_cast(pool); VirtualNetworkTemplate * vtmpl=static_cast(tmpl); - return vpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, + return vpool->allocate(att.uid, att.gid, att.uname, att.gname, att.umask, vtmpl, &id, cluster_id, cluster_name, error_str); } @@ -330,7 +310,6 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params, Nebula& nd = Nebula::instance(); - UserPool * upool = nd.get_upool(); DatastorePool * dspool = nd.get_dspool(); ImagePool * ipool = static_cast(pool); ImageManager * imagem = nd.get_imagem(); @@ -338,32 +317,13 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params, ImageTemplate * tmpl; Template img_usage; - User * user; Datastore * ds; Image::DiskType ds_disk_type; long long avail; - int umask; bool ds_check; - // ------------------------- Get user's umask ------------------------------ - - user = upool->get(att.uid, true); - - if ( user == 0 ) - { - failure_response(NO_EXISTS, - get_error(object_name(PoolObjectSQL::USER), att.uid), - att); - - return; - } - - umask = user->get_umask(); - - user->unlock(); - // ------------------------- Parse image template -------------------------- tmpl = new ImageTemplate; @@ -512,7 +472,7 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params, att.gid, att.uname, att.gname, - umask, + att.umask, tmpl, ds_id, ds_name, @@ -552,15 +512,14 @@ int TemplateAllocate::pool_allocate( Template * tmpl, int& id, string& error_str, - RequestAttributes& att, - int umask) + RequestAttributes& att) { VMTemplatePool * tpool = static_cast(pool); VirtualMachineTemplate * ttmpl=static_cast(tmpl); - return tpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, ttmpl, - &id, error_str); + return tpool->allocate(att.uid, att.gid, att.uname, att.gname, att.umask, + ttmpl, &id, error_str); } /* -------------------------------------------------------------------------- */ @@ -573,8 +532,7 @@ int HostAllocate::pool_allocate( string& error_str, RequestAttributes& att, int cluster_id, - const string& cluster_name, - int umask) + const string& cluster_name) { string host = xmlrpc_c::value_string(paramList.getString(1)); string im_mad = xmlrpc_c::value_string(paramList.getString(2)); @@ -596,8 +554,7 @@ int UserAllocate::pool_allocate( Template * tmpl, int& id, string& error_str, - RequestAttributes& att, - int umask) + RequestAttributes& att) { string uname = xmlrpc_c::value_string(paramList.getString(1)); string passwd = xmlrpc_c::value_string(paramList.getString(2)); @@ -647,8 +604,7 @@ int GroupAllocate::pool_allocate( Template * tmpl, int& id, string& error_str, - RequestAttributes& att, - int umask) + RequestAttributes& att) { string gname = xmlrpc_c::value_string(paramList.getString(1)); @@ -667,13 +623,12 @@ int DatastoreAllocate::pool_allocate( string& error_str, RequestAttributes& att, int cluster_id, - const string& cluster_name, - int umask) + const string& cluster_name) { DatastorePool * dspool = static_cast(pool); DatastoreTemplate * ds_tmpl = static_cast(tmpl); - return dspool->allocate(att.uid, att.gid, att.uname, att.gname, umask, + return dspool->allocate(att.uid, att.gid, att.uname, att.gname, att.umask, ds_tmpl, &id, cluster_id, cluster_name, error_str); } @@ -685,8 +640,7 @@ int ClusterAllocate::pool_allocate( Template * tmpl, int& id, string& error_str, - RequestAttributes& att, - int umask) + RequestAttributes& att) { string name = xmlrpc_c::value_string(paramList.getString(1)); @@ -703,14 +657,13 @@ int DocumentAllocate::pool_allocate( Template * tmpl, int& id, string& error_str, - RequestAttributes& att, - int umask) + RequestAttributes& att) { int type = xmlrpc_c::value_int(paramList.getInt(2)); DocumentPool * docpool = static_cast(pool); - return docpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, + return docpool->allocate(att.uid, att.gid, att.uname, att.gname, att.umask, type, tmpl, &id, error_str); } @@ -739,8 +692,7 @@ int ZoneAllocate::pool_allocate( Template * tmpl, int& id, string& error_str, - RequestAttributes& att, - int umask) + RequestAttributes& att) { string name = xmlrpc_c::value_string(paramList.getString(1)); diff --git a/src/rm/RequestManagerClone.cc b/src/rm/RequestManagerClone.cc index 20d1ea6747..2de7c4d24e 100644 --- a/src/rm/RequestManagerClone.cc +++ b/src/rm/RequestManagerClone.cc @@ -28,33 +28,15 @@ void RequestManagerClone::request_execute( int source_id = xmlrpc_c::value_int(paramList.getInt(1)); string name = xmlrpc_c::value_string(paramList.getString(2)); - int rc, new_id, umask; + int rc, new_id; PoolObjectAuth perms; Template * tmpl; PoolObjectSQL * source_obj; - User * user; - - UserPool * upool = Nebula::instance().get_upool(); string error_str; - user = upool->get(att.uid, true); - - if ( user == 0 ) - { - failure_response(NO_EXISTS, - get_error(object_name(PoolObjectSQL::USER), att.uid), - att); - - return; - } - - umask = user->get_umask(); - - user->unlock(); - source_obj = pool->get(source_id, true); if ( source_obj == 0 ) @@ -98,7 +80,7 @@ void RequestManagerClone::request_execute( } } - rc = pool_allocate(source_id, tmpl, new_id, error_str, att, umask); + rc = pool_allocate(source_id, tmpl, new_id, error_str, att); if ( rc < 0 ) { diff --git a/src/rm/RequestManagerImage.cc b/src/rm/RequestManagerImage.cc index 69467d987f..5cd8076015 100644 --- a/src/rm/RequestManagerImage.cc +++ b/src/rm/RequestManagerImage.cc @@ -230,7 +230,7 @@ void ImageClone::request_execute( string name = xmlrpc_c::value_string(paramList.getString(2)); long long avail, size; - int rc, new_id, ds_id, umask; + int rc, new_id, ds_id; string error_str, ds_name, ds_data; bool ds_check; @@ -241,30 +241,11 @@ void ImageClone::request_execute( Template img_usage; Image * img; Datastore * ds; - User * user; Nebula& nd = Nebula::instance(); DatastorePool * dspool = nd.get_dspool(); ImagePool * ipool = static_cast(pool); - UserPool * upool = nd.get_upool(); - - // ------------------------- Get user's umask ------------------------------ - - user = upool->get(att.uid, true); - - if ( user == 0 ) - { - failure_response(NO_EXISTS, - get_error(object_name(PoolObjectSQL::USER), att.uid), - att); - - return; - } - - umask = user->get_umask(); - - user->unlock(); // ------------------------- Get source Image info ------------------------- @@ -391,7 +372,7 @@ void ImageClone::request_execute( att.gid, att.uname, att.gname, - umask, + att.umask, tmpl, ds_id, ds_name, diff --git a/src/rm/RequestManagerVMTemplate.cc b/src/rm/RequestManagerVMTemplate.cc index ce22fbebcc..8569c487c5 100644 --- a/src/rm/RequestManagerVMTemplate.cc +++ b/src/rm/RequestManagerVMTemplate.cc @@ -31,7 +31,6 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList int rc; int vid; - int umask; ostringstream sid; @@ -41,12 +40,10 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList VirtualMachinePool* vmpool = nd.get_vmpool(); VMTemplatePool * tpool = static_cast(pool); - UserPool * upool = nd.get_upool(); VirtualMachineTemplate * tmpl; VirtualMachineTemplate uattrs; VMTemplate * rtmpl; - User * user; string error_str; string aname; @@ -60,25 +57,6 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList str_uattrs = xmlrpc_c::value_string(paramList.getString(4)); } - /* ---------------------------------------------------------------------- */ - /* Get user's umask */ - /* ---------------------------------------------------------------------- */ - - user = upool->get(att.uid, true); - - if ( user == 0 ) - { - failure_response(NO_EXISTS, - get_error(object_name(PoolObjectSQL::USER), att.uid), - att); - - return; - } - - umask = user->get_umask(); - - user->unlock(); - /* ---------------------------------------------------------------------- */ /* Get, check and clone the template */ /* ---------------------------------------------------------------------- */ @@ -212,7 +190,7 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList Template tmpl_back(*tmpl); - rc = vmpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, + rc = vmpool->allocate(att.uid, att.gid, att.uname, att.gname, att.umask, tmpl, &vid, error_str, on_hold); if ( rc < 0 ) diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index 36bbdaddad..191303e817 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -1025,7 +1025,6 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis ImagePool * ipool = nd.get_ipool(); DatastorePool * dspool = nd.get_dspool(); - UserPool * upool = nd.get_upool(); VMTemplatePool* tpool = nd.get_tpool(); int id = xmlrpc_c::value_int(paramList.getInt(1)); @@ -1057,24 +1056,6 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis string target; string dev_prefix; - // ------------------------------------------------------------------------- - // Get user's umask - // ------------------------------------------------------------------------- - User * user = upool->get(att.uid, true); - - if ( user == 0 ) - { - failure_response(NO_EXISTS, - get_error(object_name(PoolObjectSQL::USER), att.uid), - att); - - return; - } - - int umask = user->get_umask(); - - user->unlock(); - // ------------------------------------------------------------------------- // Prepare and check the VM/DISK to be saved_as // ------------------------------------------------------------------------- @@ -1306,7 +1287,7 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis att.gid, att.uname, att.gname, - umask, + att.umask, itemplate, ds_id, ds_name, @@ -1419,7 +1400,7 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis //Allocate the template - rc = tpool->allocate(att.uid, att.gid, att.uname, att.gname, umask, + rc = tpool->allocate(att.uid, att.gid, att.uname, att.gname, att.umask, tmpl, &ntid, error_str); if (rc < 0) diff --git a/src/um/User.cc b/src/um/User.cc index 2677be0b15..30a4196e9c 100644 --- a/src/um/User.cc +++ b/src/um/User.cc @@ -413,5 +413,21 @@ int User::get_umask() const return (umask & 0777); } +int User::get_default_umask() +{ + string umask_st; + int umask; + + istringstream iss; + + Nebula::instance().get_configuration_attribute("DEFAULT_UMASK",umask_st); + + iss.str(umask_st); + + iss >> oct >> umask; + + return (umask & 0777); +} + /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ diff --git a/src/um/UserPool.cc b/src/um/UserPool.cc index 923b2b3b3d..8375f7d143 100644 --- a/src/um/UserPool.cc +++ b/src/um/UserPool.cc @@ -419,7 +419,8 @@ bool UserPool::authenticate_internal(User * user, int& group_id, string& uname, string& gname, - set& group_ids) + set& group_ids, + int& umask) { bool result = false; @@ -440,13 +441,15 @@ bool UserPool::authenticate_internal(User * user, group_ids = user->get_groups(); - uname = user->name; - gname = user->gname; + uname = user->name; + gname = user->gname; auth_driver = user->auth_driver; result = user->valid_session(token); + umask = user->get_umask(); + user->unlock(); if (result) @@ -523,6 +526,8 @@ auth_failure: uname = ""; gname = ""; + umask = 0; + return false; } @@ -535,7 +540,8 @@ bool UserPool::authenticate_server(User * user, int& group_id, string& uname, string& gname, - set& group_ids) + set& group_ids, + int& umask) { bool result = false; @@ -585,6 +591,8 @@ bool UserPool::authenticate_server(User * user, result = user->valid_session(second_token); + umask = user->get_umask(); + user->unlock(); if (result) @@ -654,6 +662,8 @@ auth_failure: uname = ""; gname = ""; + umask = 0; + return false; } @@ -666,7 +676,8 @@ bool UserPool::authenticate_external(const string& username, int& group_id, string& uname, string& gname, - set& group_ids) + set& group_ids, + int& umask) { ostringstream oss; istringstream is; @@ -741,6 +752,8 @@ bool UserPool::authenticate_external(const string& username, uname = mad_name; gname = GroupPool::USERS_NAME; + umask = User::get_default_umask(); + return true; auth_failure_user: @@ -770,6 +783,8 @@ auth_failure: uname = ""; gname = ""; + umask = 0; + return false; } @@ -781,7 +796,8 @@ bool UserPool::authenticate(const string& session, int& group_id, string& uname, string& gname, - set& group_ids) + set& group_ids, + int& umask) { User * user = 0; string username; @@ -805,16 +821,19 @@ bool UserPool::authenticate(const string& session, if ( fnmatch(UserPool::SERVER_AUTH, driver.c_str(), 0) == 0 ) { - ar = authenticate_server(user,token,user_id,group_id,uname,gname,group_ids); + ar = authenticate_server(user, token, user_id, group_id, uname, + gname, group_ids, umask); } else { - ar = authenticate_internal(user,token,user_id,group_id,uname,gname,group_ids); + ar = authenticate_internal(user, token, user_id, group_id, uname, + gname, group_ids, umask); } } else { - ar = authenticate_external(username,token,user_id,group_id,uname,gname,group_ids); + ar = authenticate_external(username, token, user_id, group_id, uname, + gname, group_ids, umask); } return ar;