Commit d5f9873c authored by Olaf Dietsche's avatar Olaf Dietsche Committed by Linus Torvalds

[PATCH] 2.5.40: fix chmod/chown on procfs

This patch allows to change uid, gid and mode of files and directories
located in procfs.

Without this patch you can change uid, gid and mode as long as the
file is open. As soon as you close the file, it reverts back to its
default, which is root:root and readonly usually.
parent bbb7d857
...@@ -165,6 +165,24 @@ proc_file_lseek(struct file * file, loff_t offset, int orig) ...@@ -165,6 +165,24 @@ proc_file_lseek(struct file * file, loff_t offset, int orig)
return -EINVAL; return -EINVAL;
} }
static int proc_notify_change(struct dentry *dentry, struct iattr *iattr)
{
struct inode *inode = dentry->d_inode;
int error = inode_setattr(inode, iattr);
if (!error) {
struct proc_dir_entry *de = PDE(inode);
de->uid = inode->i_uid;
de->gid = inode->i_gid;
de->mode = inode->i_mode;
}
return error;
}
static struct inode_operations proc_file_inode_operations = {
.setattr = proc_notify_change,
};
/* /*
* This function parses a name such as "tty/driver/serial", and * This function parses a name such as "tty/driver/serial", and
* returns the struct proc_dir_entry for "/proc/tty/driver", and * returns the struct proc_dir_entry for "/proc/tty/driver", and
...@@ -368,6 +386,7 @@ static struct file_operations proc_dir_operations = { ...@@ -368,6 +386,7 @@ static struct file_operations proc_dir_operations = {
*/ */
static struct inode_operations proc_dir_inode_operations = { static struct inode_operations proc_dir_inode_operations = {
.lookup = proc_lookup, .lookup = proc_lookup,
.setattr = proc_notify_change,
}; };
static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp) static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp)
...@@ -393,6 +412,8 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp ...@@ -393,6 +412,8 @@ static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp
} else if (S_ISREG(dp->mode)) { } else if (S_ISREG(dp->mode)) {
if (dp->proc_fops == NULL) if (dp->proc_fops == NULL)
dp->proc_fops = &proc_file_operations; dp->proc_fops = &proc_file_operations;
if (dp->proc_iops == NULL)
dp->proc_iops = &proc_file_inode_operations;
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment