Loading init/devices.c +11 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include <errno.h> #include <fnmatch.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> Loading Loading @@ -77,6 +78,7 @@ struct perms_ { unsigned int uid; unsigned int gid; unsigned short prefix; unsigned short wildcard; }; struct perm_node { Loading @@ -97,7 +99,8 @@ static list_declare(platform_names); int add_dev_perms(const char *name, const char *attr, mode_t perm, unsigned int uid, unsigned int gid, unsigned short prefix) { unsigned short prefix, unsigned short wildcard) { struct perm_node *node = calloc(1, sizeof(*node)); if (!node) return -ENOMEM; Loading @@ -116,6 +119,7 @@ int add_dev_perms(const char *name, const char *attr, node->dp.uid = uid; node->dp.gid = gid; node->dp.prefix = prefix; node->dp.wildcard = wildcard; if (attr) list_add_tail(&sys_perms, &node->plist); Loading @@ -140,6 +144,9 @@ void fixup_sys_perms(const char *upath) if (dp->prefix) { if (strncmp(upath, dp->name + 4, strlen(dp->name + 4))) continue; } else if (dp->wildcard) { if (fnmatch(dp->name + 4, upath, FNM_PATHNAME) != 0) continue; } else { if (strcmp(upath, dp->name + 4)) continue; Loading Loading @@ -180,6 +187,9 @@ static mode_t get_device_perm(const char *path, unsigned *uid, unsigned *gid) if (dp->prefix) { if (strncmp(path, dp->name, strlen(dp->name))) continue; } else if (dp->wildcard) { if (fnmatch(dp->name, path, FNM_PATHNAME) != 0) continue; } else { if (strcmp(path, dp->name)) continue; Loading init/devices.h +2 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ extern void handle_device_fd(); extern void device_init(void); extern int add_dev_perms(const char *name, const char *attr, mode_t perm, unsigned int uid, unsigned int gid, unsigned short prefix); unsigned int gid, unsigned short prefix, unsigned short wildcard); int get_device_fd(); #endif /* _INIT_DEVICES_H */ init/ueventd.c +7 −2 Original line number Diff line number Diff line Loading @@ -122,6 +122,7 @@ void set_device_permission(int nargs, char **args) uid_t uid; gid_t gid; int prefix = 0; int wildcard = 0; char *endptr; int ret; char *tmp = 0; Loading Loading @@ -154,9 +155,13 @@ void set_device_permission(int nargs, char **args) name = tmp; } else { int len = strlen(name); if (name[len - 1] == '*') { char *wildcard_chr = strchr(name, '*'); if ((name[len - 1] == '*') && (wildcard_chr == (name + len - 1))) { prefix = 1; name[len - 1] = '\0'; } else if (wildcard_chr) { wildcard = 1; } } Loading @@ -183,6 +188,6 @@ void set_device_permission(int nargs, char **args) } gid = ret; add_dev_perms(name, attr, perm, uid, gid, prefix); add_dev_perms(name, attr, perm, uid, gid, prefix, wildcard); free(tmp); } Loading
init/devices.c +11 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ #include <errno.h> #include <fnmatch.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> Loading Loading @@ -77,6 +78,7 @@ struct perms_ { unsigned int uid; unsigned int gid; unsigned short prefix; unsigned short wildcard; }; struct perm_node { Loading @@ -97,7 +99,8 @@ static list_declare(platform_names); int add_dev_perms(const char *name, const char *attr, mode_t perm, unsigned int uid, unsigned int gid, unsigned short prefix) { unsigned short prefix, unsigned short wildcard) { struct perm_node *node = calloc(1, sizeof(*node)); if (!node) return -ENOMEM; Loading @@ -116,6 +119,7 @@ int add_dev_perms(const char *name, const char *attr, node->dp.uid = uid; node->dp.gid = gid; node->dp.prefix = prefix; node->dp.wildcard = wildcard; if (attr) list_add_tail(&sys_perms, &node->plist); Loading @@ -140,6 +144,9 @@ void fixup_sys_perms(const char *upath) if (dp->prefix) { if (strncmp(upath, dp->name + 4, strlen(dp->name + 4))) continue; } else if (dp->wildcard) { if (fnmatch(dp->name + 4, upath, FNM_PATHNAME) != 0) continue; } else { if (strcmp(upath, dp->name + 4)) continue; Loading Loading @@ -180,6 +187,9 @@ static mode_t get_device_perm(const char *path, unsigned *uid, unsigned *gid) if (dp->prefix) { if (strncmp(path, dp->name, strlen(dp->name))) continue; } else if (dp->wildcard) { if (fnmatch(dp->name, path, FNM_PATHNAME) != 0) continue; } else { if (strcmp(path, dp->name)) continue; Loading
init/devices.h +2 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ extern void handle_device_fd(); extern void device_init(void); extern int add_dev_perms(const char *name, const char *attr, mode_t perm, unsigned int uid, unsigned int gid, unsigned short prefix); unsigned int gid, unsigned short prefix, unsigned short wildcard); int get_device_fd(); #endif /* _INIT_DEVICES_H */
init/ueventd.c +7 −2 Original line number Diff line number Diff line Loading @@ -122,6 +122,7 @@ void set_device_permission(int nargs, char **args) uid_t uid; gid_t gid; int prefix = 0; int wildcard = 0; char *endptr; int ret; char *tmp = 0; Loading Loading @@ -154,9 +155,13 @@ void set_device_permission(int nargs, char **args) name = tmp; } else { int len = strlen(name); if (name[len - 1] == '*') { char *wildcard_chr = strchr(name, '*'); if ((name[len - 1] == '*') && (wildcard_chr == (name + len - 1))) { prefix = 1; name[len - 1] = '\0'; } else if (wildcard_chr) { wildcard = 1; } } Loading @@ -183,6 +188,6 @@ void set_device_permission(int nargs, char **args) } gid = ret; add_dev_perms(name, attr, perm, uid, gid, prefix); add_dev_perms(name, attr, perm, uid, gid, prefix, wildcard); free(tmp); }