From: Olaf Dietsche <olaf.dietsche#list.linux-kernel@t-online.de>
To: linux-kernel@vger.kernel.org
Cc: torvalds@transmeta.com, marcelo@conectiva.com.br
Subject: [PATCH] 2.5.40: fix chmod/chown on procfs
Date: Thu, 10 Oct 2002 18:45:03 +0200 [thread overview]
Message-ID: <87zntm8cq8.fsf@goat.bogus.local> (raw)
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.
This patch is tested with 2.5.40, but applies to 2.5.41 as well.
Comments?
Regards, Olaf.
--- a/fs/proc/generic.c Sat Oct 5 18:45:53 2002
+++ b/fs/proc/generic.c Thu Oct 10 17:48:10 2002
@@ -165,6 +165,24 @@
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
* returns the struct proc_dir_entry for "/proc/tty/driver", and
@@ -368,6 +386,7 @@
*/
static struct inode_operations proc_dir_inode_operations = {
.lookup = proc_lookup,
+ .setattr = proc_notify_change,
};
static int proc_register(struct proc_dir_entry * dir, struct proc_dir_entry * dp)
@@ -393,6 +412,8 @@
} else if (S_ISREG(dp->mode)) {
if (dp->proc_fops == NULL)
dp->proc_fops = &proc_file_operations;
+ if (dp->proc_iops == NULL)
+ dp->proc_iops = &proc_file_inode_operations;
}
return 0;
}
reply other threads:[~2002-10-10 16:39 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=87zntm8cq8.fsf@goat.bogus.local \
--to=olaf.dietsche#list.linux-kernel@t-online.de \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
--cc=torvalds@transmeta.com \
/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
all inboxes | Powered by JetHome®