Merge lp:~crimsun/udev/ubuntu into lp:~ubuntu-core-dev/udev/ubuntu

Proposed by Daniel T Chen on 2009-08-08
Status: Needs review
Proposed branch: lp:~crimsun/udev/ubuntu
Merge into: lp:~ubuntu-core-dev/udev/ubuntu
Diff against target: None lines
To merge this branch: bzr merge lp:~crimsun/udev/ubuntu
Reviewer Review Type Date Requested Status
Scott James Remnant (Canonical) (community) 2009-08-08 Disapprove on 2009-08-10
Review via email: mp+9883@code.launchpad.net
To post a comment you must log in.
Daniel T Chen (crimsun) wrote :

According to https://tango.0pointer.de/pipermail/pulseaudio-discuss/2009-August/004674.html, Lennart strongly recommends that we merge his patch (merged into udev.git upstream, changeset 3bf768245b98479a14190e1e1d32ef5fae3ddf8a) to fix an ACL race affecting profile creation.

If this is an important issue, we should just get a new version of udev released upstream and update to that.

review: Disapprove

Unmerged revisions

2500. By Daniel T Chen <crimsun@errno> on 2009-08-08

Update changelog

2499. By Daniel T Chen <crimsun@errno> on 2009-08-08

Apply 3bf768245b98479a14190e1e1d32ef5fae3ddf8a from upstream upon Lennart's recommendation

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2009-07-18 13:43:22 +0000
3+++ debian/changelog 2009-08-08 18:51:09 +0000
4@@ -3,6 +3,10 @@
5 [ Scott James Remnant ]
6 *
7
8+ [ Daniel T Chen ]
9+ * Apply 3bf768245b98479a14190e1e1d32ef5fae3ddf8a from upstream
10+ to fix an ACL race
11+
12 [ Martin Pitt ]
13 * debian/control: Add missing Breaks: casper (<< 1.174) to avoid breaking
14 upgrades from jaunty in wubi installations. (LP: #400138)
15
16=== modified file 'libudev/libudev-enumerate.c'
17--- libudev/libudev-enumerate.c 2009-07-08 00:04:49 +0000
18+++ libudev/libudev-enumerate.c 2009-08-08 18:48:37 +0000
19@@ -187,7 +187,8 @@
20 return ret;
21 }
22
23-static int devices_delay(struct udev *udev, const char *syspath)
24+/* For devices that should be moved to the absolute end of the list */
25+static int devices_delay_end(struct udev *udev, const char *syspath)
26 {
27 static const char *delay_device_list[] = {
28 "/block/md",
29@@ -207,6 +208,32 @@
30 return 0;
31 }
32
33+/* For devices that should just be moved a little bit later, just
34+ * before the point where some common path prefix changes. Returns the
35+ * number of characters that make up that common prefix */
36+static size_t devices_delay_later(struct udev *udev, const char *syspath)
37+{
38+ const char *c;
39+
40+ /* For sound cards the control device must be enumerated last
41+ * to make sure it's the final device node that gets ACLs
42+ * applied. Applications rely on this fact and use ACL changes
43+ * on the control node as an indicator that the ACL change of
44+ * the entire sound card completed. The kernel makes this
45+ * guarantee when creating those devices, and hence we should
46+ * too when enumerating them. */
47+
48+ if ((c = strstr(syspath, "/sound/card"))) {
49+ c += 11;
50+ c += strcspn(c, "/");
51+
52+ if (strncmp(c, "/controlC", 9) == 0)
53+ return c - syspath + 1;
54+ }
55+
56+ return 0;
57+}
58+
59 /**
60 * udev_enumerate_get_list_entry:
61 * @udev_enumerate: context
62@@ -220,7 +247,8 @@
63 if (!udev_enumerate->devices_uptodate) {
64 unsigned int i;
65 unsigned int max;
66- struct syspath *prev = NULL;
67+ struct syspath *prev = NULL, *move_later = NULL;
68+ size_t move_later_prefix;
69
70 udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->devices_list);
71 qsort(udev_enumerate->devices, udev_enumerate->devices_cur, sizeof(struct syspath), syspath_cmp);
72@@ -237,14 +265,39 @@
73 prev = entry;
74
75 /* skip to be delayed devices, and add them to the end of the list */
76- if (devices_delay(udev_enumerate->udev, entry->syspath)) {
77+ if (devices_delay_end(udev_enumerate->udev, entry->syspath)) {
78 syspath_add(udev_enumerate, entry->syspath);
79 continue;
80 }
81
82+ /* skip to be delayed devices, and move the to
83+ * the point where the prefix changes. We can
84+ * only move one item at a time. */
85+ if (!move_later) {
86+ move_later_prefix = devices_delay_later(udev_enumerate->udev, entry->syspath);
87+
88+ if (move_later_prefix > 0) {
89+ move_later = entry;
90+ continue;
91+ }
92+ }
93+
94+ if (move_later &&
95+ strncmp(entry->syspath, move_later->syspath, move_later_prefix) != 0) {
96+
97+ udev_list_entry_add(udev_enumerate->udev, &udev_enumerate->devices_list,
98+ move_later->syspath, NULL, 0, 0);
99+ move_later = NULL;
100+ }
101+
102 udev_list_entry_add(udev_enumerate->udev, &udev_enumerate->devices_list,
103 entry->syspath, NULL, 0, 0);
104 }
105+
106+ if (move_later)
107+ udev_list_entry_add(udev_enumerate->udev, &udev_enumerate->devices_list,
108+ move_later->syspath, NULL, 0, 0);
109+
110 /* add and cleanup delayed devices from end of list */
111 for (i = max; i < udev_enumerate->devices_cur; i++) {
112 struct syspath *entry = &udev_enumerate->devices[i];

Subscribers

People subscribed via source and target branches