linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vlad Dogaru <vlad.dogaru@intel.com>
To: viro@zeniv.linux.org.uk, akpm@linux-foundation.org, hch@lst.de,
	linux-fsdevel@vger.kernel.org, jlbec@evilplan.org
Cc: octavian.purdila@intel.com, daniel.baluta@intel.com,
	adriana.reus@intel.com, Vlad Dogaru <vlad.dogaru@intel.com>
Subject: [PATCH linux-next] configfs: set new file and directory owners
Date: Thu,  7 May 2015 16:06:58 +0300	[thread overview]
Message-ID: <1431004018-5682-1-git-send-email-vlad.dogaru@intel.com> (raw)

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 <vlad.dogaru@intel.com>
---
 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 <linux/module.h>
 #include <linux/slab.h>
 #include <linux/err.h>
+#include <linux/sched.h>
+#include <linux/cred.h>
 
 #include <linux/configfs.h>
 #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


                 reply	other threads:[~2015-05-07 13:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1431004018-5682-1-git-send-email-vlad.dogaru@intel.com \
    --to=vlad.dogaru@intel.com \
    --cc=adriana.reus@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=daniel.baluta@intel.com \
    --cc=hch@lst.de \
    --cc=jlbec@evilplan.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=octavian.purdila@intel.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).