* udev change event
@ 2008-07-03 12:01 Harald Hoyer
2008-07-03 12:16 ` Marco d'Itri
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: Harald Hoyer @ 2008-07-03 12:01 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 197 bytes --]
With recent changes, udev processes "change" events for removable devices and
resets the permissions, if it has changed since creation. Is this intended? Or
do we just want a new vol_id symlink?
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/x-pkcs7-signature, Size: 3636 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: udev change event
2008-07-03 12:01 udev change event Harald Hoyer
@ 2008-07-03 12:16 ` Marco d'Itri
2008-07-03 19:48 ` Bill Nottingham
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Marco d'Itri @ 2008-07-03 12:16 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 387 bytes --]
On Jul 03, Harald Hoyer <harald@redhat.com> wrote:
> With recent changes, udev processes "change" events for removable devices
> and resets the permissions, if it has changed since creation. Is this
> intended? Or do we just want a new vol_id symlink?
I think this is intended: manually changing the permissions of dynamic
devices is not supposed to work.
--
ciao,
Marco
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: udev change event
2008-07-03 12:01 udev change event Harald Hoyer
2008-07-03 12:16 ` Marco d'Itri
@ 2008-07-03 19:48 ` Bill Nottingham
2008-07-03 21:50 ` Kay Sievers
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bill Nottingham @ 2008-07-03 19:48 UTC (permalink / raw)
To: linux-hotplug
Marco d'Itri (md@Linux.IT) said:
> On Jul 03, Harald Hoyer <harald@redhat.com> wrote:
>
> > With recent changes, udev processes "change" events for removable devices
> > and resets the permissions, if it has changed since creation. Is this
> > intended? Or do we just want a new vol_id symlink?
> I think this is intended: manually changing the permissions of dynamic
> devices is not supposed to work.
....? How do you handle ACLs for local users, then?
Bill
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: udev change event
2008-07-03 12:01 udev change event Harald Hoyer
2008-07-03 12:16 ` Marco d'Itri
2008-07-03 19:48 ` Bill Nottingham
@ 2008-07-03 21:50 ` Kay Sievers
2008-07-03 21:57 ` Marco d'Itri
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Kay Sievers @ 2008-07-03 21:50 UTC (permalink / raw)
To: linux-hotplug
On Thu, Jul 3, 2008 at 21:48, Bill Nottingham <notting@redhat.com> wrote:
> Marco d'Itri (md@Linux.IT) said:
>> On Jul 03, Harald Hoyer <harald@redhat.com> wrote:
>>
>> > With recent changes, udev processes "change" events for removable devices
>> > and resets the permissions, if it has changed since creation. Is this
>> > intended? Or do we just want a new vol_id symlink?
>> I think this is intended: manually changing the permissions of dynamic
>> devices is not supposed to work.
>
> ....? How do you handle ACLs for local users, then?
Re-apply them, with the same logic that did it in the first place?
Kay
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: udev change event
2008-07-03 12:01 udev change event Harald Hoyer
` (2 preceding siblings ...)
2008-07-03 21:50 ` Kay Sievers
@ 2008-07-03 21:57 ` Marco d'Itri
2008-07-04 9:47 ` Harald Hoyer
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Marco d'Itri @ 2008-07-03 21:57 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 352 bytes --]
On Jul 03, Bill Nottingham <notting@redhat.com> wrote:
> > I think this is intended: manually changing the permissions of dynamic
> > devices is not supposed to work.
> ....? How do you handle ACLs for local users, then?
I don't (not my package), but if I had to I would dynamically maintain
rules in /dev/.udev/rules.d/ .
--
ciao,
Marco
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: udev change event
2008-07-03 12:01 udev change event Harald Hoyer
` (3 preceding siblings ...)
2008-07-03 21:57 ` Marco d'Itri
@ 2008-07-04 9:47 ` Harald Hoyer
2008-07-07 14:55 ` Bill Nottingham
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Harald Hoyer @ 2008-07-04 9:47 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 295 bytes --]
Harald Hoyer wrote:
> With recent changes, udev processes "change" events for removable
> devices and resets the permissions, if it has changed since creation. Is
> this intended? Or do we just want a new vol_id symlink?
https://bugzilla.redhat.com/show_bug.cgi?id=451320
for the reference
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/x-pkcs7-signature, Size: 3636 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: udev change event
2008-07-03 12:01 udev change event Harald Hoyer
` (4 preceding siblings ...)
2008-07-04 9:47 ` Harald Hoyer
@ 2008-07-07 14:55 ` Bill Nottingham
2008-07-07 15:05 ` Marco d'Itri
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bill Nottingham @ 2008-07-07 14:55 UTC (permalink / raw)
To: linux-hotplug
Marco d'Itri (md@Linux.IT) said:
> On Jul 03, Bill Nottingham <notting@redhat.com> wrote:
>
> > > I think this is intended: manually changing the permissions of dynamic
> > > devices is not supposed to work.
> > ....? How do you handle ACLs for local users, then?
> I don't (not my package), but if I had to I would dynamically maintain
> rules in /dev/.udev/rules.d/ .
So, instead of just calling setfacl() when a user logs in, it's
better to write udev syntax and kill the daemon (oh, and then
generate an event to apply them?)
That's just nuts. Far better to change all the distributed rules
to only have MODE= on 'add' events, not change ones.
Bill
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: udev change event
2008-07-03 12:01 udev change event Harald Hoyer
` (5 preceding siblings ...)
2008-07-07 14:55 ` Bill Nottingham
@ 2008-07-07 15:05 ` Marco d'Itri
2008-07-07 15:25 ` Bill Nottingham
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Marco d'Itri @ 2008-07-07 15:05 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 384 bytes --]
On Jul 07, Bill Nottingham <notting@redhat.com> wrote:
> So, instead of just calling setfacl() when a user logs in, it's
> better to write udev syntax and kill the daemon (oh, and then
> generate an event to apply them?)
You do not need to kill the daemon, and if no event is received to apply
it then I suppose that there is no need to access the drive.
--
ciao,
Marco
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: udev change event
2008-07-03 12:01 udev change event Harald Hoyer
` (6 preceding siblings ...)
2008-07-07 15:05 ` Marco d'Itri
@ 2008-07-07 15:25 ` Bill Nottingham
2008-07-07 15:28 ` Marco d'Itri
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bill Nottingham @ 2008-07-07 15:25 UTC (permalink / raw)
To: linux-hotplug
Marco d'Itri (md@Linux.IT) said:
> > So, instead of just calling setfacl() when a user logs in, it's
> > better to write udev syntax and kill the daemon (oh, and then
> > generate an event to apply them?)
>
> You do not need to kill the daemon, and if no event is received to apply
> it then I suppose that there is no need to access the drive.
I'm not following you here. Here's the scenario you're proposing I implement:
- CD w/blank media exists, is 0640 root/disk (or whatever)
- I log in
- Rather than set the ACLs, the system daemon writes a udev rule
- ... how does this not work without an event, and what would theoretically
provide it?
Bill
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: udev change event
2008-07-03 12:01 udev change event Harald Hoyer
` (7 preceding siblings ...)
2008-07-07 15:25 ` Bill Nottingham
@ 2008-07-07 15:28 ` Marco d'Itri
2008-07-07 15:34 ` Bill Nottingham
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Marco d'Itri @ 2008-07-07 15:28 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 426 bytes --]
On Jul 07, Bill Nottingham <notting@redhat.com> wrote:
> - CD w/blank media exists, is 0640 root/disk (or whatever)
> - I log in
> - Rather than set the ACLs, the system daemon writes a udev rule
> - ... how does this not work without an event, and what would theoretically
> provide it?
Inserting the CD. If it was inserted by a precedent user, do you really
want to change the device owner?
--
ciao,
Marco
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: udev change event
2008-07-03 12:01 udev change event Harald Hoyer
` (8 preceding siblings ...)
2008-07-07 15:28 ` Marco d'Itri
@ 2008-07-07 15:34 ` Bill Nottingham
2008-07-10 14:21 ` David Zeuthen
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Bill Nottingham @ 2008-07-07 15:34 UTC (permalink / raw)
To: linux-hotplug
Marco d'Itri (md@Linux.IT) said:
> On Jul 07, Bill Nottingham <notting@redhat.com> wrote:
>
> > - CD w/blank media exists, is 0640 root/disk (or whatever)
> > - I log in
> > - Rather than set the ACLs, the system daemon writes a udev rule
> > - ... how does this not work without an event, and what would theoretically
> > provide it?
> Inserting the CD. If it was inserted by a precedent user, do you really
> want to change the device owner?
Substitute 'precedent user' with 'no user', and yes, why not?
Doing this all as udev rules seems very wrong.
Bill
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: udev change event
2008-07-03 12:01 udev change event Harald Hoyer
` (9 preceding siblings ...)
2008-07-07 15:34 ` Bill Nottingham
@ 2008-07-10 14:21 ` David Zeuthen
2008-07-10 18:44 ` Kay Sievers
2008-07-10 23:00 ` Kay Sievers
12 siblings, 0 replies; 14+ messages in thread
From: David Zeuthen @ 2008-07-10 14:21 UTC (permalink / raw)
To: linux-hotplug
On Thu, 2008-07-03 at 23:50 +0200, Kay Sievers wrote:
> On Thu, Jul 3, 2008 at 21:48, Bill Nottingham <notting@redhat.com> wrote:
> > Marco d'Itri (md@Linux.IT) said:
> >> On Jul 03, Harald Hoyer <harald@redhat.com> wrote:
> >>
> >> > With recent changes, udev processes "change" events for removable devices
> >> > and resets the permissions, if it has changed since creation. Is this
> >> > intended? Or do we just want a new vol_id symlink?
> >> I think this is intended: manually changing the permissions of dynamic
> >> devices is not supposed to work.
> >
> > ....? How do you handle ACLs for local users, then?
>
> Re-apply them, with the same logic that did it in the first place?
Racy. The ACL's are applied long after udev stopped processing rules.
Better to fix udev to only apply permissions on "add" events.
David
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: udev change event
2008-07-03 12:01 udev change event Harald Hoyer
` (10 preceding siblings ...)
2008-07-10 14:21 ` David Zeuthen
@ 2008-07-10 18:44 ` Kay Sievers
2008-07-10 23:00 ` Kay Sievers
12 siblings, 0 replies; 14+ messages in thread
From: Kay Sievers @ 2008-07-10 18:44 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 1195 bytes --]
On Thu, 2008-07-10 at 10:21 -0400, David Zeuthen wrote:
> On Thu, 2008-07-03 at 23:50 +0200, Kay Sievers wrote:
> > On Thu, Jul 3, 2008 at 21:48, Bill Nottingham <notting@redhat.com> wrote:
> > > Marco d'Itri (md@Linux.IT) said:
> > >> On Jul 03, Harald Hoyer <harald@redhat.com> wrote:
> > >>
> > >> > With recent changes, udev processes "change" events for removable devices
> > >> > and resets the permissions, if it has changed since creation. Is this
> > >> > intended? Or do we just want a new vol_id symlink?
> > >> I think this is intended: manually changing the permissions of dynamic
> > >> devices is not supposed to work.
> > >
> > > ....? How do you handle ACLs for local users, then?
> >
> > Re-apply them, with the same logic that did it in the first place?
>
> Racy. The ACL's are applied long after udev stopped processing rules.
> Better to fix udev to only apply permissions on "add" events.
We should just leave the perms and ownership as they are, if they
already match the udev values, in the same way we preserve the inode.
That way all ACL's are preserved, and hooking into "change" to set
permissions will still work.
Does the following work for you?
Thanks,
Kay
[-- Attachment #2: change-event-perms-fix.patch --]
[-- Type: text/x-patch, Size: 3458 bytes --]
diff --git a/udev_node.c b/udev_node.c
index 0e59e2d..732cce4 100644
--- a/udev_node.c
+++ b/udev_node.c
@@ -39,7 +39,8 @@ int udev_node_mknod(struct udevice *udev, const char *file, dev_t devt, mode_t m
{
char file_tmp[PATH_SIZE + sizeof(TMP_FILE_EXT)];
struct stat stats;
- int retval = 0;
+ int preserve = 0;
+ int err = 0;
if (major(devt) != 0 && strcmp(udev->dev->subsystem, "block") == 0)
mode |= S_IFBLK;
@@ -47,56 +48,56 @@ int udev_node_mknod(struct udevice *udev, const char *file, dev_t devt, mode_t m
mode |= S_IFCHR;
if (lstat(file, &stats) == 0) {
- if ((stats.st_mode & S_IFMT) == (mode & S_IFMT) && (stats.st_rdev == devt)) {
+ if (((stats.st_mode & S_IFMT) == (mode & S_IFMT)) && (stats.st_rdev == devt)) {
info("preserve file '%s', because it has correct dev_t\n", file);
- selinux_setfilecon(file, udev->dev->kernel, stats.st_mode);
- goto perms;
+ preserve = 1;
+ selinux_setfilecon(file, udev->dev->kernel, mode);
+ } else {
+ info("atomically replace existing file '%s'\n", file);
+ strlcpy(file_tmp, file, sizeof(file_tmp));
+ strlcat(file_tmp, TMP_FILE_EXT, sizeof(file_tmp));
+ unlink(file_tmp);
+ selinux_setfscreatecon(file_tmp, udev->dev->kernel, mode);
+ err = mknod(file_tmp, mode, devt);
+ selinux_resetfscreatecon();
+ if (err != 0) {
+ err("mknod(%s, %#o, %u, %u) failed: %s\n",
+ file_tmp, mode, major(devt), minor(devt), strerror(errno));
+ goto exit;
+ }
+ err = rename(file_tmp, file);
+ if (err != 0) {
+ err("rename(%s, %s) failed: %s\n",
+ file_tmp, file, strerror(errno));
+ unlink(file_tmp);
+ }
}
} else {
+ info("mknod(%s, %#o, (%u,%u))\n", file, mode, major(devt), minor(devt));
selinux_setfscreatecon(file, udev->dev->kernel, mode);
- retval = mknod(file, mode, devt);
+ err = mknod(file, mode, devt);
selinux_resetfscreatecon();
- if (retval == 0)
- goto perms;
- }
-
- info("atomically replace '%s'\n", file);
- strlcpy(file_tmp, file, sizeof(file_tmp));
- strlcat(file_tmp, TMP_FILE_EXT, sizeof(file_tmp));
- unlink(file_tmp);
- selinux_setfscreatecon(file_tmp, udev->dev->kernel, mode);
- retval = mknod(file_tmp, mode, devt);
- selinux_resetfscreatecon();
- if (retval != 0) {
- err("mknod(%s, %#o, %u, %u) failed: %s\n",
- file_tmp, mode, major(devt), minor(devt), strerror(errno));
- goto exit;
- }
- retval = rename(file_tmp, file);
- if (retval != 0) {
- err("rename(%s, %s) failed: %s\n",
- file_tmp, file, strerror(errno));
- unlink(file_tmp);
- goto exit;
+ if (err != 0)
+ goto exit;
}
-perms:
- dbg("chmod(%s, %#o)\n", file, mode);
- if (chmod(file, mode) != 0) {
- err("chmod(%s, %#o) failed: %s\n", file, mode, strerror(errno));
- goto exit;
+ if (!preserve || stats.st_mode != mode) {
+ info("chmod(%s, %#o)\n", file, mode);
+ if (chmod(file, mode) != 0) {
+ err("chmod(%s, %#o) failed: %s\n", file, mode, strerror(errno));
+ goto exit;
+ }
}
- if (uid != 0 || gid != 0) {
- dbg("chown(%s, %u, %u)\n", file, uid, gid);
+ if (!preserve || stats.st_uid != uid || stats.st_gid != gid) {
+ info("chown(%s, %u, %u)\n", file, uid, gid);
if (chown(file, uid, gid) != 0) {
- err("chown(%s, %u, %u) failed: %s\n",
- file, uid, gid, strerror(errno));
+ err("chown(%s, %u, %u) failed: %s\n", file, uid, gid, strerror(errno));
goto exit;
}
}
exit:
- return retval;
+ return err;
}
static int node_symlink(const char *node, const char *slink)
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: udev change event
2008-07-03 12:01 udev change event Harald Hoyer
` (11 preceding siblings ...)
2008-07-10 18:44 ` Kay Sievers
@ 2008-07-10 23:00 ` Kay Sievers
12 siblings, 0 replies; 14+ messages in thread
From: Kay Sievers @ 2008-07-10 23:00 UTC (permalink / raw)
To: linux-hotplug
On Thu, Jul 10, 2008 at 20:44, Kay Sievers <kay.sievers@vrfy.org> wrote:
> On Thu, 2008-07-10 at 10:21 -0400, David Zeuthen wrote:
>> On Thu, 2008-07-03 at 23:50 +0200, Kay Sievers wrote:
>> > On Thu, Jul 3, 2008 at 21:48, Bill Nottingham <notting@redhat.com> wrote:
>> > > Marco d'Itri (md@Linux.IT) said:
>> > >> On Jul 03, Harald Hoyer <harald@redhat.com> wrote:
>> > >>
>> > >> > With recent changes, udev processes "change" events for removable devices
>> > >> > and resets the permissions, if it has changed since creation. Is this
>> > >> > intended? Or do we just want a new vol_id symlink?
>> > >> I think this is intended: manually changing the permissions of dynamic
>> > >> devices is not supposed to work.
>> > >
>> > > ....? How do you handle ACLs for local users, then?
>> >
>> > Re-apply them, with the same logic that did it in the first place?
>>
>> Racy. The ACL's are applied long after udev stopped processing rules.
>> Better to fix udev to only apply permissions on "add" events.
>
> We should just leave the perms and ownership as they are, if they
> already match the udev values, in the same way we preserve the inode.
>
> That way all ACL's are preserved, and hooking into "change" to set
> permissions will still work.
>
> Does the following work for you?
Care to check the changes in the udev git tree?
Thanks,
Kay
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2008-07-10 23:00 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-03 12:01 udev change event Harald Hoyer
2008-07-03 12:16 ` Marco d'Itri
2008-07-03 19:48 ` Bill Nottingham
2008-07-03 21:50 ` Kay Sievers
2008-07-03 21:57 ` Marco d'Itri
2008-07-04 9:47 ` Harald Hoyer
2008-07-07 14:55 ` Bill Nottingham
2008-07-07 15:05 ` Marco d'Itri
2008-07-07 15:25 ` Bill Nottingham
2008-07-07 15:28 ` Marco d'Itri
2008-07-07 15:34 ` Bill Nottingham
2008-07-10 14:21 ` David Zeuthen
2008-07-10 18:44 ` Kay Sievers
2008-07-10 23:00 ` Kay Sievers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).