diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2009-09-18 17:01:12 -0400 |
---|---|---|
committer | Live-CD User <linux@linux.site> | 2009-09-19 15:50:38 -0400 |
commit | e454cea20bdcff10ee698d11b8882662a0153a47 (patch) | |
tree | f44581fe57787aef0a4f4dc00993a90ea8e688f6 /drivers/base/core.c | |
parent | 78f28b7c555359c67c2a0d23f7436e915329421e (diff) |
Driver-Core: extend devnode callbacks to provide permissions
This allows subsytems to provide devtmpfs with non-default permissions
for the device node. Instead of the default mode of 0600, null, zero,
random, urandom, full, tty, ptmx now have a mode of 0666, which allows
non-privileged processes to access standard device nodes in case no
other userspace process applies the expected permissions.
This also fixes a wrong assignment in pktcdvd and a checkpatch.pl complain.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r-- | drivers/base/core.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index 390e664ec1c7..6bee6af8d8e1 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -166,13 +166,16 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj, | |||
166 | if (MAJOR(dev->devt)) { | 166 | if (MAJOR(dev->devt)) { |
167 | const char *tmp; | 167 | const char *tmp; |
168 | const char *name; | 168 | const char *name; |
169 | mode_t mode = 0; | ||
169 | 170 | ||
170 | add_uevent_var(env, "MAJOR=%u", MAJOR(dev->devt)); | 171 | add_uevent_var(env, "MAJOR=%u", MAJOR(dev->devt)); |
171 | add_uevent_var(env, "MINOR=%u", MINOR(dev->devt)); | 172 | add_uevent_var(env, "MINOR=%u", MINOR(dev->devt)); |
172 | name = device_get_nodename(dev, &tmp); | 173 | name = device_get_devnode(dev, &mode, &tmp); |
173 | if (name) { | 174 | if (name) { |
174 | add_uevent_var(env, "DEVNAME=%s", name); | 175 | add_uevent_var(env, "DEVNAME=%s", name); |
175 | kfree(tmp); | 176 | kfree(tmp); |
177 | if (mode) | ||
178 | add_uevent_var(env, "DEVMODE=%#o", mode & 0777); | ||
176 | } | 179 | } |
177 | } | 180 | } |
178 | 181 | ||
@@ -1148,8 +1151,9 @@ static struct device *next_device(struct klist_iter *i) | |||
1148 | } | 1151 | } |
1149 | 1152 | ||
1150 | /** | 1153 | /** |
1151 | * device_get_nodename - path of device node file | 1154 | * device_get_devnode - path of device node file |
1152 | * @dev: device | 1155 | * @dev: device |
1156 | * @mode: returned file access mode | ||
1153 | * @tmp: possibly allocated string | 1157 | * @tmp: possibly allocated string |
1154 | * | 1158 | * |
1155 | * Return the relative path of a possible device node. | 1159 | * Return the relative path of a possible device node. |
@@ -1157,21 +1161,22 @@ static struct device *next_device(struct klist_iter *i) | |||
1157 | * a name. This memory is returned in tmp and needs to be | 1161 | * a name. This memory is returned in tmp and needs to be |
1158 | * freed by the caller. | 1162 | * freed by the caller. |
1159 | */ | 1163 | */ |
1160 | const char *device_get_nodename(struct device *dev, const char **tmp) | 1164 | const char *device_get_devnode(struct device *dev, |
1165 | mode_t *mode, const char **tmp) | ||
1161 | { | 1166 | { |
1162 | char *s; | 1167 | char *s; |
1163 | 1168 | ||
1164 | *tmp = NULL; | 1169 | *tmp = NULL; |
1165 | 1170 | ||
1166 | /* the device type may provide a specific name */ | 1171 | /* the device type may provide a specific name */ |
1167 | if (dev->type && dev->type->nodename) | 1172 | if (dev->type && dev->type->devnode) |
1168 | *tmp = dev->type->nodename(dev); | 1173 | *tmp = dev->type->devnode(dev, mode); |
1169 | if (*tmp) | 1174 | if (*tmp) |
1170 | return *tmp; | 1175 | return *tmp; |
1171 | 1176 | ||
1172 | /* the class may provide a specific name */ | 1177 | /* the class may provide a specific name */ |
1173 | if (dev->class && dev->class->nodename) | 1178 | if (dev->class && dev->class->devnode) |
1174 | *tmp = dev->class->nodename(dev); | 1179 | *tmp = dev->class->devnode(dev, mode); |
1175 | if (*tmp) | 1180 | if (*tmp) |
1176 | return *tmp; | 1181 | return *tmp; |
1177 | 1182 | ||