linux-um archives
 help / color / mirror / Atom feed
From: Karl Chen <quarl@cs.berkeley.edu>
To: Blaisorblade <blaisorblade@yahoo.it>
Cc: user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [uml-devel] hostfs permissions
Date: Fri, 10 Jun 2005 17:48:14 -0700	[thread overview]
Message-ID: <quack.20050610T1748.87psutn2gh@quack.cs.berkeley.edu> (raw)
In-Reply-To: <200506110026.24655.blaisorblade@yahoo.it> (blaisorblade@yahoo.it's message of "Sat, 11 Jun 2005 00:26:24 +0200")

>>>>> On 2005-06-10 15:26 PDT, Blaisorblade  writes:

    Blaisorblade> Ok, in this case there's probably a simpler
    Blaisorblade> road: simply use a 2.4.27-1bs kernel. The
    Blaisorblade> implemented behaviour is that all created files
    Blaisorblade> will have the ID they have on the host, i.e. the
    Blaisorblade> ID of the user running UML.

Thanks for the tip!  I will be running UML under different user
IDs but I'd rather it always be the same uid inside the UML.  I
used this micropatch to get exactly the behavior I want.  It's
obviously for this particular experiment only; I still think
uid,gid mount options would be better in general.  I guess that's
only 5 or 10 more lines of code...


diff -u /home/quarl/proj/uml/linux/linux-2.4.27/arch/um/fs/hostfs/.backup/hostfs_kern.c.\~1\~ /home/quarl/proj/uml/linux/linux-2.4.27/arch/um/fs/hostfs/hostfs_kern.c
--- /home/quarl/proj/uml/linux/linux-2.4.27/arch/um/fs/hostfs/.backup/hostfs_kern.c.~1~	2005-06-10 16:58:51.000000000 -0700
+++ /home/quarl/proj/uml/linux/linux-2.4.27/arch/um/fs/hostfs/hostfs_kern.c	2005-06-10 17:35:01.829485585 -0700
@@ -1,3 +1,6 @@
+#define KLUDGE_FS_UID 7777
+#define KLUDGE_FS_GID 7777
+
 /*
  * Copyright (C) 2000 - 2003 Jeff Dike (jdike@addtoit.com)
  * Licensed under the GPL
@@ -142,6 +145,10 @@
 	ino->i_blocks = i_blocks;
 	if(kdev_same(ino->i_sb->s_dev, ROOT_DEV) && (ino->i_uid == getuid()))
 		ino->i_uid = 0;
+        else if (ino->i_uid == getuid()) {          /* KC KLUDGE */
+                ino->i_uid = KLUDGE_FS_UID;         /* KC KLUDGE */
+                ino->i_gid = KLUDGE_FS_GID;         /* KC KLUDGE */
+        }                                           /* KC KLUDGE */
 	return(0);
 }
 
@@ -760,13 +767,17 @@
 		if(kdev_same(dentry->d_inode->i_sb->s_dev, ROOT_DEV) &&
 		   (attr->ia_uid == 0))
 			attr->ia_uid = getuid();
+                else if (attr->ia_uid == KLUDGE_FS_UID) { /* KC KLUDGE */
+                        attr->ia_uid = getuid();          /* KC KLUDGE */
+                        attr->ia_gid = getgid();          /* KC KLUDGE */
+                }                                         /* KC KLUDGE */
 		attrs.ia_valid |= HOSTFS_ATTR_UID;
 		attrs.ia_uid = attr->ia_uid;
 	}
 	if(attr->ia_valid & ATTR_GID){
 		if(kdev_same(dentry->d_inode->i_sb->s_dev, ROOT_DEV) &&
 		   (attr->ia_gid == 0))
-			attr->ia_gid = getuid();
+			attr->ia_gid = getgid();
 		attrs.ia_valid |= HOSTFS_ATTR_GID;
 		attrs.ia_gid = attr->ia_gid;
 	}


-- 
Karl 2005-06-10 17:44


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

  reply	other threads:[~2005-06-11  0:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-10  5:34 [uml-devel] hostfs permissions Karl Chen
2005-06-10 16:03 ` Blaisorblade
2005-06-10 20:14   ` Karl Chen
2005-06-10 22:26     ` Blaisorblade
2005-06-11  0:48       ` Karl Chen [this message]
2005-06-11  2:33         ` Blaisorblade

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=quack.20050610T1748.87psutn2gh@quack.cs.berkeley.edu \
    --to=quarl@cs.berkeley.edu \
    --cc=blaisorblade@yahoo.it \
    --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