All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hfsplus: honor setgid flag on directories
@ 2017-12-04 19:27 Ernesto A. Fernández
  2017-12-05 18:03 ` Viacheslav Dubeyko
  0 siblings, 1 reply; 2+ messages in thread
From: Ernesto A. Fernández @ 2017-12-04 19:27 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Ernesto A. Fernández, Al Viro, Andrew Morton

When creating a file inside a directory that has the setgid flag set,
give the new file the group ID of the parent, and also the setgid flag
if it is a directory itself.

Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
---
 fs/hfsplus/dir.c        | 4 ++--
 fs/hfsplus/hfsplus_fs.h | 3 ++-
 fs/hfsplus/inode.c      | 7 +++----
 fs/hfsplus/super.c      | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 92a28da..db827e0 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -443,7 +443,7 @@ static int hfsplus_symlink(struct inode *dir, struct dentry *dentry,
 	int res = -ENOMEM;
 
 	mutex_lock(&sbi->vh_mutex);
-	inode = hfsplus_new_inode(dir->i_sb, S_IFLNK | S_IRWXUGO);
+	inode = hfsplus_new_inode(dir->i_sb, dir, S_IFLNK | S_IRWXUGO);
 	if (!inode)
 		goto out;
 
@@ -485,7 +485,7 @@ static int hfsplus_mknod(struct inode *dir, struct dentry *dentry,
 	int res = -ENOMEM;
 
 	mutex_lock(&sbi->vh_mutex);
-	inode = hfsplus_new_inode(dir->i_sb, mode);
+	inode = hfsplus_new_inode(dir->i_sb, dir, mode);
 	if (!inode)
 		goto out;
 
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index 36ca6e17..8e03943 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -477,7 +477,8 @@ extern const struct address_space_operations hfsplus_aops;
 extern const struct address_space_operations hfsplus_btree_aops;
 extern const struct dentry_operations hfsplus_dentry_operations;
 
-struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode);
+struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir,
+				umode_t mode);
 void hfsplus_delete_inode(struct inode *inode);
 void hfsplus_inode_read_fork(struct inode *inode,
 			     struct hfsplus_fork_raw *fork);
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 72801ca..671357e 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -343,7 +343,8 @@ static const struct file_operations hfsplus_file_operations = {
 	.unlocked_ioctl = hfsplus_ioctl,
 };
 
-struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode)
+struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir,
+				umode_t mode)
 {
 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
 	struct inode *inode = new_inode(sb);
@@ -353,9 +354,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, umode_t mode)
 		return NULL;
 
 	inode->i_ino = sbi->next_cnid++;
-	inode->i_mode = mode;
-	inode->i_uid = current_fsuid();
-	inode->i_gid = current_fsgid();
+	inode_init_owner(inode, dir, mode);
 	set_nlink(inode, 1);
 	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
 
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
index d5e6a71..8fc4327 100644
--- a/fs/hfsplus/super.c
+++ b/fs/hfsplus/super.c
@@ -549,7 +549,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
 
 		if (!sbi->hidden_dir) {
 			mutex_lock(&sbi->vh_mutex);
-			sbi->hidden_dir = hfsplus_new_inode(sb, S_IFDIR);
+			sbi->hidden_dir = hfsplus_new_inode(sb, root, S_IFDIR);
 			if (!sbi->hidden_dir) {
 				mutex_unlock(&sbi->vh_mutex);
 				err = -ENOMEM;
-- 
2.1.4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] hfsplus: honor setgid flag on directories
  2017-12-04 19:27 [PATCH] hfsplus: honor setgid flag on directories Ernesto A. Fernández
@ 2017-12-05 18:03 ` Viacheslav Dubeyko
  0 siblings, 0 replies; 2+ messages in thread
From: Viacheslav Dubeyko @ 2017-12-05 18:03 UTC (permalink / raw)
  To: Ernesto A. Fernández, linux-fsdevel; +Cc: Al Viro, Andrew Morton

On Mon, 2017-12-04 at 16:27 -0300, Ernesto A. Fernández wrote:
> When creating a file inside a directory that has the setgid flag set,
> give the new file the group ID of the parent, and also the setgid
> flag
> if it is a directory itself.
> 


Looks really good. I have no remarks.

Reviewed-by: Vyacheslav Dubeyko <slava@dubeyko.com>

Thanks,
Vyacheslav Dubeyko.


> Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
> ---
>  fs/hfsplus/dir.c        | 4 ++--
>  fs/hfsplus/hfsplus_fs.h | 3 ++-
>  fs/hfsplus/inode.c      | 7 +++----
>  fs/hfsplus/super.c      | 2 +-
>  4 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
> index 92a28da..db827e0 100644
> --- a/fs/hfsplus/dir.c
> +++ b/fs/hfsplus/dir.c
> @@ -443,7 +443,7 @@ static int hfsplus_symlink(struct inode *dir,
> struct dentry *dentry,
>  	int res = -ENOMEM;
>  
>  	mutex_lock(&sbi->vh_mutex);
> -	inode = hfsplus_new_inode(dir->i_sb, S_IFLNK | S_IRWXUGO);
> +	inode = hfsplus_new_inode(dir->i_sb, dir, S_IFLNK |
> S_IRWXUGO);
>  	if (!inode)
>  		goto out;
>  
> @@ -485,7 +485,7 @@ static int hfsplus_mknod(struct inode *dir,
> struct dentry *dentry,
>  	int res = -ENOMEM;
>  
>  	mutex_lock(&sbi->vh_mutex);
> -	inode = hfsplus_new_inode(dir->i_sb, mode);
> +	inode = hfsplus_new_inode(dir->i_sb, dir, mode);
>  	if (!inode)
>  		goto out;
>  
> diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
> index 36ca6e17..8e03943 100644
> --- a/fs/hfsplus/hfsplus_fs.h
> +++ b/fs/hfsplus/hfsplus_fs.h
> @@ -477,7 +477,8 @@ extern const struct address_space_operations
> hfsplus_aops;
>  extern const struct address_space_operations hfsplus_btree_aops;
>  extern const struct dentry_operations hfsplus_dentry_operations;
>  
> -struct inode *hfsplus_new_inode(struct super_block *sb, umode_t
> mode);
> +struct inode *hfsplus_new_inode(struct super_block *sb, struct inode
> *dir,
> +				umode_t mode);
>  void hfsplus_delete_inode(struct inode *inode);
>  void hfsplus_inode_read_fork(struct inode *inode,
>  			     struct hfsplus_fork_raw *fork);
> diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
> index 72801ca..671357e 100644
> --- a/fs/hfsplus/inode.c
> +++ b/fs/hfsplus/inode.c
> @@ -343,7 +343,8 @@ static const struct file_operations
> hfsplus_file_operations = {
>  	.unlocked_ioctl = hfsplus_ioctl,
>  };
>  
> -struct inode *hfsplus_new_inode(struct super_block *sb, umode_t
> mode)
> +struct inode *hfsplus_new_inode(struct super_block *sb, struct inode
> *dir,
> +				umode_t mode)
>  {
>  	struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
>  	struct inode *inode = new_inode(sb);
> @@ -353,9 +354,7 @@ struct inode *hfsplus_new_inode(struct
> super_block *sb, umode_t mode)
>  		return NULL;
>  
>  	inode->i_ino = sbi->next_cnid++;
> -	inode->i_mode = mode;
> -	inode->i_uid = current_fsuid();
> -	inode->i_gid = current_fsgid();
> +	inode_init_owner(inode, dir, mode);
>  	set_nlink(inode, 1);
>  	inode->i_mtime = inode->i_atime = inode->i_ctime =
> current_time(inode);
>  
> diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c
> index d5e6a71..8fc4327 100644
> --- a/fs/hfsplus/super.c
> +++ b/fs/hfsplus/super.c
> @@ -549,7 +549,7 @@ static int hfsplus_fill_super(struct super_block
> *sb, void *data, int silent)
>  
>  		if (!sbi->hidden_dir) {
>  			mutex_lock(&sbi->vh_mutex);
> -			sbi->hidden_dir = hfsplus_new_inode(sb,
> S_IFDIR);
> +			sbi->hidden_dir = hfsplus_new_inode(sb,
> root, S_IFDIR);
>  			if (!sbi->hidden_dir) {
>  				mutex_unlock(&sbi->vh_mutex);
>  				err = -ENOMEM;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-05 18:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-04 19:27 [PATCH] hfsplus: honor setgid flag on directories Ernesto A. Fernández
2017-12-05 18:03 ` Viacheslav Dubeyko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.