Skip to contentSkip to conversation

udev - flag for preserving the ownership

DISCUSSION Harald Hoyer 2 participants 7 messages Jun 1, 2004 – Jun 3, 2004

lore
Share & tools
lore
#0 lore raw

How about a config flag, which means that udev preserves the ownership of an already existing device node (with the correct major, minor numbers)?

Btw, we only check if the file we want to create is block or char, not e.g. that we want block and it is char.

if (((stats.st_mode & S_IFMT) == S_IFBLK || (stats.st_mode & S_IFMT) == S_IFCHR) && (stats.st_rdev == makedev(major, minor)))

should look like:

if (((stats.st_mode & S_IFMT) == mode) && (stats.st_rdev == makedev(major, minor)))

#1 lore raw
Quoted 9 lines · Harald Hoyer

How about a config flag, which means that udev preserves the ownership of an already existing device node (with the correct major, minor numbers)?

Btw, we only check if the file we want to create is block or char, not e.g. that we want block and it is char.

if (((stats.st_mode & S_IFMT) == S_IFBLK || (stats.st_mode & S_IFMT) == S_IFCHR) && (stats.st_rdev == makedev(major, minor)))

should look like:

if (((stats.st_mode & S_IFMT) == mode) && (stats.st_rdev == makedev(major, minor)))

how about this (see attachement)?

udev-add.c renamed from udev-add.c.keep +2 -2
@@ -114,10 +114,10 @@
 		goto create;
 
 	/* preserve node with already correct numbers, to not change the inode number */
-	if (((stats.st_mode & S_IFMT) == S_IFBLK || (stats.st_mode & S_IFMT) == S_IFCHR) &&
+	if (((stats.st_mode & S_IFMT) == (mode & S_IFMT)) &&
 	    (stats.st_rdev == makedev(major, minor))) {
 		dbg("preserve file '%s', cause it has correct dev_t", file);
-		goto perms;
+		goto exit;
 	}
 
 	if (unlink(file) != 0)
#2 lore raw
In reply to Harald Hoyer
Quoted 10 lines · Harald Hoyer
Quoted 9 lines · Harald Hoyer

How about a config flag, which means that udev preserves the ownership of an already existing device node (with the correct major, minor numbers)?

Btw, we only check if the file we want to create is block or char, not e.g. that we want block and it is char.

if (((stats.st_mode & S_IFMT) = S_IFBLK || (stats.st_mode & S_IFMT) = S_IFCHR) && (stats.st_rdev = makedev(major, minor)))

Quoted 6 lines
Quoted 4 lines

should look like:

if (((stats.st_mode & S_IFMT) = mode) && (stats.st_rdev = makedev(major, minor)))

how about this (see attachement)?

I havent looked at the larger context, but I believe this changes behaviour of udev. Currently udevstart can fix up your system for sure, but with this change, a bogus file will not be removed if it happens to have the same permissions.
Or will stats.st_rdev = makedev(major, minor) take care of that?

Quoted 15 lines
udev-add.c renamed from udev-add.c.keep +2 -2
@@ -114,10 +114,10 @@
 		goto create;
 
 	/* preserve node with already correct numbers, to not change the inode number */
-	if (((stats.st_mode & S_IFMT) = S_IFBLK || (stats.st_mode & S_IFMT) = S_IFCHR) &&
+	if (((stats.st_mode & S_IFMT) = (mode & S_IFMT)) &&
 	    (stats.st_rdev = makedev(major, minor))) {
 		dbg("preserve file '%s', cause it has correct dev_t", file);
-		goto perms;
+		goto exit;
 	}
 
 	if (unlink(file) != 0)
Signature · 14 lines
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG


-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#3 lore raw
In reply to Harald Hoyer
Quoted 5 lines · Olaf Hering

I havent looked at the larger context, but I believe this changes behaviour of udev. Currently udevstart can fix up your system for sure, but with this change, a bogus file will not be removed if it happens to have the same permissions.
Or will stats.st_rdev == makedev(major, minor) take care of that?

yep, it will not change file permissions and ownership, if it already exists and is the correct node... we can also create a config flag, which changes the goto. You may look at the whole code.

What I also wish is a flag for the DB, which indicates that the file already existed and should not be removed with the "remove" ACTION.

Quoted 22 lines
Quoted 17 lines
udev-add.c renamed from udev-add.c.keep +2 -2
@@ -114,10 +114,10 @@
 		goto create;
 
 	/* preserve node with already correct numbers, to not change the inode number */
-	if (((stats.st_mode & S_IFMT) == S_IFBLK || (stats.st_mode & S_IFMT) == S_IFCHR) &&
+	if (((stats.st_mode & S_IFMT) == (mode & S_IFMT)) &&
 	    (stats.st_rdev == makedev(major, minor))) {
 		dbg("preserve file '%s', cause it has correct dev_t", file);
-		goto perms;
+		goto exit;
 	}
 
 	if (unlink(file) != 0)
#4 lore raw
In reply to Harald Hoyer
Quoted 10 lines · Harald Hoyer
Quoted 5 lines · Olaf Hering

I havent looked at the larger context, but I believe this changes behaviour of udev. Currently udevstart can fix up your system for sure, but with this change, a bogus file will not be removed if it happens to have the same permissions.
Or will stats.st_rdev = makedev(major, minor) take care of that?

yep, it will not change file permissions and ownership, if it already exists and is the correct node... we can also create a config flag, which changes the goto. You may look at the whole code.

ok in this case.

Quoted 2 lines

What I also wish is a flag for the DB, which indicates that the file already existed and should not be removed with the "remove" ACTION.

That cant be the job of udev. If the device is not there, then noone will need the device node. We can certainly argue about broken things like md0 and similar chicken/egg problems.

Signature · 14 lines
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG


-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#5 lore raw
In reply to Harald Hoyer
Quoted 8 lines · Olaf Hering
Quoted 1 line · Harald Hoyer

What I also wish is a flag for the DB, which indicates that the file already existed and should not be removed with the "remove" ACTION.

That cant be the job of udev. If the device is not there, then noone will need the device node. We can certainly argue about broken things like md0 and similar chicken/egg problems.

Think of the administrator manually changing the ownership of device nodes. You cannot/will not want to teach them to edit the udev permissions file. Thus you have to preserve the node, if it was there before udev stepped in. With the old ownerships and permissions.

#6 lore raw
In reply to Harald Hoyer
Quoted 11 lines · Harald Hoyer
Quoted 9 lines · Olaf Hering
Quoted 2 lines · Harald Hoyer

What I also wish is a flag for the DB, which indicates that the file already existed and should not be removed with the "remove" ACTION.

That cant be the job of udev. If the device is not there, then noone will need the device node. We can certainly argue about broken things like md0 and similar chicken/egg problems.

Quoted 4 lines

Think of the administrator manually changing the ownership of device nodes. You cannot/will not want to teach them to edit the udev permissions file. Thus you have to preserve the node, if it was there before udev stepped in. With the old ownerships and permissions.

That would fail as well if one updates the devs.rpm. Either use udev and its permissions config file, or dont use udev.

Signature · 14 lines
USB is for mice, FireWire is for men!

sUse lINUX ag, nÜRNBERG


-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel