mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-14 16:53:12 +09:00
Feature #1681: Add new oned.conf att. for a default umask
This commit is contained in:
1 parent
3d3cc4fa9f
commit
d4245a6699
35 files changed
+257
-106
No files matched your search
@@ -17,6 +17,7 @@
|
||||
#include "PoolObjectSQL.h"
|
||||
#include "PoolObjectAuth.h"
|
||||
#include "SSLTools.h"
|
||||
#include "Nebula.h"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -305,3 +306,41 @@ error_value:
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void PoolObjectSQL::set_umask(int umask)
|
||||
{
|
||||
int perms;
|
||||
bool enable_other;
|
||||
|
||||
Nebula::instance().get_configuration_attribute(
|
||||
"ENABLE_OTHER_PERMISSIONS", enable_other);
|
||||
|
||||
if (uid == 0 || gid == 0)
|
||||
{
|
||||
perms = 0777;
|
||||
}
|
||||
else if (enable_other)
|
||||
{
|
||||
perms = 0666;
|
||||
}
|
||||
else
|
||||
{
|
||||
perms = 0660;
|
||||
}
|
||||
|
||||
perms = perms & ~umask;
|
||||
|
||||
owner_u = ( (perms & 0400) != 0 ) ? 1 : 0;
|
||||
owner_m = ( (perms & 0200) != 0 ) ? 1 : 0;
|
||||
owner_a = ( (perms & 0100) != 0 ) ? 1 : 0;
|
||||
group_u = ( (perms & 0040) != 0 ) ? 1 : 0;
|
||||
group_m = ( (perms & 0020) != 0 ) ? 1 : 0;
|
||||
group_a = ( (perms & 0010) != 0 ) ? 1 : 0;
|
||||
other_u = ( (perms & 0004) != 0 ) ? 1 : 0;
|
||||
other_m = ( (perms & 0002) != 0 ) ? 1 : 0;
|
||||
other_a = ( (perms & 0001) != 0 ) ? 1 : 0;
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
Reference in new issue
Block a user