Skip to content

Commit

Permalink
meta: indicate writability of tunables in file mode
Browse files Browse the repository at this point in the history
All files under .meta (synthetic subtree facilitating
reflection for glusterfs clients, implemented by meta
xlator) were shown as writable, but the vast majority of
them are usable only for querying parameters or stats, not
for setting them. (The exceptions are loglevel and
measure_latency.)

However, one could only find out about this only by trial
and error, or reading the code.

With this change we align file permissions with
tunability, stripping the writable bits for those nodes
which are only for querying.

Also strip writable bits from directory permissions.

updates: gluster#1000
Change-Id: I82954e165ffc31cdf7307f4d990ef60b8154a2e2
Signed-off-by: Csaba Henk <csaba@redhat.com>
  • Loading branch information
csabahenk authored and gluster-ant committed Apr 21, 2020
1 parent f8bae59 commit 2554080
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions xlators/meta/src/meta-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,22 +182,23 @@ meta_uuid_copy(uuid_t dst, uuid_t src)
}

static void
default_meta_iatt_fill(struct iatt *iatt, inode_t *inode, ia_type_t type)
default_meta_iatt_fill(struct iatt *iatt, inode_t *inode, ia_type_t type,
gf_boolean_t is_tunable)
{
struct timeval tv = {};

iatt->ia_type = type;
switch (type) {
case IA_IFDIR:
iatt->ia_prot = ia_prot_from_st_mode(0755);
iatt->ia_prot = ia_prot_from_st_mode(0555);
iatt->ia_nlink = 2;
break;
case IA_IFLNK:
iatt->ia_prot = ia_prot_from_st_mode(0777);
iatt->ia_nlink = 1;
break;
default:
iatt->ia_prot = ia_prot_from_st_mode(0644);
iatt->ia_prot = ia_prot_from_st_mode(is_tunable ? 0644 : 0444);
iatt->ia_nlink = 1;
break;
}
Expand Down Expand Up @@ -225,7 +226,7 @@ meta_iatt_fill(struct iatt *iatt, inode_t *inode, ia_type_t type)
return;

if (!ops->iatt_fill)
default_meta_iatt_fill(iatt, inode, type);
default_meta_iatt_fill(iatt, inode, type, !!ops->file_write);
else
ops->iatt_fill(THIS, inode, iatt);
return;
Expand Down

0 comments on commit 2554080

Please sign in to comment.