From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kay Sievers Date: Fri, 24 Oct 2003 13:42:26 +0000 Subject: Re: [ANNOUNCE] udev 004 release MIME-Version: 1 Content-Type: multipart/mixed; boundary="bg08WKrSYDhXBjb5" Message-Id: List-Id: References: In-Reply-To: To: linux-hotplug@vger.kernel.org --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Oct 22, 2003 at 04:52:10PM -0700, Greg KH wrote: > On Wed, Oct 22, 2003 at 05:24:24AM +0200, Kay Sievers wrote: > > > > attached is a patch for udev-add.c to set file permissions. > > Nice. > > > The problem is that the resolving of owner/group name to its numeric id > > needs shared libc libs. What does this mean for klibc? > > Hm, not good. udev has to be able to be linked statically. I just got > the klibc build working properly, and it makes a world of difference in > size compared to glibc. > > Could we convert the permissions file to numbers at build time? That > way the /etc/* file parsing would not be needed. Yeah, it's not the > nicest solution. Anyone know of any other way we can do this properly? Hi, here is the patch for ownership setting on the ceated device node, supporting only numeric id's given in udev.permissions. For now, it may be better than nothing. o set ownership of device node for now, we only accept numeric id's in udev.permissions cause we are unable to resolve it with klibc and/or before real /etc is even mounted and for the man page: o present the tiny udev in bold font :) o make CALLOUT example look less fictious thanks, Kay --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="udev-add.c.diff" --- udev-add.c.orig 2003-10-23 02:30:51.000000000 +0200 +++ udev-add.c 2003-10-24 15:37:07.000000000 +0200 @@ -67,7 +67,8 @@ } /* - * We also want to add some permissions here, and possibly some symlinks + * we possibly want to add some symlinks here + * only numeric owner/group id's are supported */ static int create_node(struct udevice *dev) { @@ -106,7 +107,35 @@ dbg("mknod(%s, %#o, %u, %u) failed with error '%s'", filename, dev->mode, dev->major, dev->minor, strerror(errno)); - // FIXME set the ownership of the node + uid_t uid = 0; + gid_t gid = 0; + + if (*dev->owner) { + char *endptr; + unsigned long id = strtoul(dev->owner, &endptr, 10); + if (*endptr == 0x00) + uid = (uid_t) id; + else + dbg("only numeric owner id supported: %s", dev->owner); + } + + if (*dev->group) { + char *endptr; + unsigned long id = strtoul(dev->group, &endptr, 10); + if (*endptr == 0x00) + gid = (gid_t) id; + else + dbg("only numeric group id supported: %s", dev->group); + } + + if (uid || gid) { + dbg("chown(%s, %u, %u)", filename, uid, gid); + retval = chown(filename, uid, gid); + if (retval) + dbg("chown(%s, %u, %u) failed with error '%s'", filename, + uid, gid, strerror(errno)); + } + return retval; } --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="udev.8.diff" --- udev.8 2003-10-22 01:09:41.000000000 +0200 +++ /home/kay/udev/udev.8 2003-10-24 15:06:41.000000000 +0200 @@ -20,13 +20,15 @@ like label, serial number or bus device number. These attributes are treated as a key to determine a unique name for device file creation. -udev maintains a database for devices present on the system. +.B udev +maintains a database for devices present on the system. .br On device removal, .B udev queries the internal database for the name of the device file to be deleted. .SH "CONFIGURATION" -udev expects its configuration at +.B udev +expects its configuration at .I /etc/udev/udev.config. The file consists of a set of lines. All empty lines and lines beginning with a '#' will be ignored. @@ -85,8 +87,8 @@ # ttyUSB1 should always be called pda REPLACE, KERNEL="ttyUSB1", NAME="pda" -# if /sbin/dev_id returns "V0815" device will be called dev0815 -CALLOUT, PROGRAM="/sbin/dev_id", BUS="pci", ID="V0815", NAME="dev0815" +# if /sbin/scsi_id returns "OEM 0815" device will be called disk1 +CALLOUT, PROGRAM="/sbin/scsi_id" BUS="scsi", ID="OEM 0815" NAME="disk1" .fi .P Permissions and ownership for the created device files may specified at @@ -120,5 +122,6 @@ .I http://linux-hotplug.sourceforge.net/ web site. .SH AUTHORS -udev was developed by Greg Kroah-Hartman with much help from +.B udev +was developed by Greg Kroah-Hartman with much help from Dan Stekloff and many others. --bg08WKrSYDhXBjb5-- ------------------------------------------------------- This SF.net email is sponsored by: The SF.net Donation Program. Do you like what SourceForge.net is doing for the Open Source Community? Make a contribution, and help us add new features and functionality. Click here: http://sourceforge.net/donate/ _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel