From: Hannes Schulz <schulz@schwaar.com>
To: user-mode-linux-devel@lists.sourceforge.net
Cc: jdike@addtoit.com
Subject: [uml-devel] [PATCH] hostfs as root (when lauched by root)
Date: Tue, 23 Sep 2003 20:24:16 +0200 [thread overview]
Message-ID: <p05111b03bb963eec0fa9@[10.96.96.13]> (raw)
If um is launched by root hostfs works as rootfs; it just creates
files & directories with the wrong (=root's) uid and gid. This patch
tries to chown+chgid newly created files and directories.
Regards
Hannes
--- uml-2.4.22um5-orig/arch/um/fs/hostfs/hostfs_kern.c 2003-09-23
15:21:33.000000000 +0200
+++ uml-2.4.22um5-hwh1/arch/um/fs/hostfs/hostfs_kern.c 2003-09-23
19:34:40.000000000 +0200
@@ -557,7 +557,18 @@
mode & S_IROTH, mode & S_IWOTH, mode & S_IXOTH);
if(fd < 0)
error = fd;
- else error = read_name(inode, name);
+ else {
+ int ign;
+ struct hostfs_iattr uidgid;
+
+ uidgid.ia_valid = HOSTFS_ATTR_UID | HOSTFS_ATTR_GID;
+ uidgid.ia_uid = current->fsuid;
+ uidgid.ia_gid = current->fsgid;
+ /* the file was successfully created; the only reasonable
+ * error is ENOPERM - which is ignored */
+ ign = set_attr(name, &uidgid);
+ error = read_name(inode, name);
+ }
kfree(name);
if(error){
@@ -660,6 +671,17 @@
file = inode_dentry_name(ino, dentry);
if(file == NULL) return(-ENOMEM);
err = do_mkdir(file, mode);
+ if(!err){
+ int ign;
+ struct hostfs_iattr uidgid;
+
+ uidgid.ia_valid = HOSTFS_ATTR_UID | HOSTFS_ATTR_GID;
+ uidgid.ia_uid = current->fsuid;
+ uidgid.ia_gid = current->fsgid;
+ /* the directory was successfully created. Errors in
+ * set_attr are ignored */
+ ign = set_attr(file, &uidgid);
+ }
kfree(file);
return(err);
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next reply other threads:[~2003-09-23 18:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-23 18:24 Hannes Schulz [this message]
2003-09-23 19:41 ` [uml-devel] [PATCH] hostfs as root (when lauched by root) Adam Heath
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='p05111b03bb963eec0fa9@[10.96.96.13]' \
--to=schulz@schwaar.com \
--cc=jdike@addtoit.com \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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