Skip to contentSkip to conversation

configfs: set new file and directory owners

PATCH New Vlad Dogaru 1 participant 1 message May 7, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configfs: set new file and directory owners

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.

---
 fs/configfs/dir.c | 8 ++++++++
 1 file changed, 8 insertions(+)
fs/configfs/dir.c +8 -0
index c81ce7f..f05dfa8 100644
@@ -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)
Signature · 1 line
1.9.1