linux-um archives
 help / color / mirror / Atom feed
* [uml-devel] [PATCH] hostfs as root (when lauched by root)
@ 2003-09-23 18:24 Hannes Schulz
  2003-09-23 19:41 ` Adam Heath
  0 siblings, 1 reply; 2+ messages in thread
From: Hannes Schulz @ 2003-09-23 18:24 UTC (permalink / raw)
  To: user-mode-linux-devel; +Cc: jdike

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

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

* Re: [uml-devel] [PATCH] hostfs as root (when lauched by root)
  2003-09-23 18:24 [uml-devel] [PATCH] hostfs as root (when lauched by root) Hannes Schulz
@ 2003-09-23 19:41 ` Adam Heath
  0 siblings, 0 replies; 2+ messages in thread
From: Adam Heath @ 2003-09-23 19:41 UTC (permalink / raw)
  To: Hannes Schulz; +Cc: user-mode-linux-devel, jdike

On Tue, 23 Sep 2003, Hannes Schulz wrote:

> 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.

I verified that before this patch was applied, normal use in  uml would see
new files owned by root.  After applying the patch, it works as expected.



-------------------------------------------------------
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

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

end of thread, other threads:[~2003-09-23 19:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-23 18:24 [uml-devel] [PATCH] hostfs as root (when lauched by root) Hannes Schulz
2003-09-23 19:41 ` Adam Heath

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox