From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vlad Dogaru Subject: [PATCH linux-next] configfs: set new file and directory owners Date: Thu, 7 May 2015 16:06:58 +0300 Message-ID: <1431004018-5682-1-git-send-email-vlad.dogaru@intel.com> Cc: octavian.purdila@intel.com, daniel.baluta@intel.com, adriana.reus@intel.com, Vlad Dogaru To: viro@zeniv.linux.org.uk, akpm@linux-foundation.org, hch@lst.de, linux-fsdevel@vger.kernel.org, jlbec@evilplan.org Return-path: Received: from mga14.intel.com ([192.55.52.115]:46560 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751021AbbEGNHw (ORCPT ); Thu, 7 May 2015 09:07:52 -0400 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: All new files and directories in configfs are owned by root, regardless of the process which creates them. Fix this by preserving filesystem semantics and assigning the uid and gid of the current process to all new items in configfs. Signed-off-by: Vlad Dogaru --- fs/configfs/dir.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index c81ce7f..f05dfa8 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include "configfs_internal.h" @@ -245,6 +247,9 @@ static void init_dir(struct inode * inode) inode->i_op = &configfs_dir_inode_operations; inode->i_fop = &configfs_dir_operations; + inode->i_uid = current_fsuid(); + inode->i_gid = current_fsgid(); + /* directory inodes start off with i_nlink == 2 (for "." entry) */ inc_nlink(inode); } @@ -253,6 +258,9 @@ static void configfs_init_file(struct inode * inode) { inode->i_size = PAGE_SIZE; inode->i_fop = &configfs_file_operations; + + inode->i_uid = current_fsuid(); + inode->i_gid = current_fsgid(); } static void init_symlink(struct inode * inode) -- 1.9.1