[systemd-devel] [PATCHv3 2/2] logind: apply ACL's to "dead" device nodes

Tom Gundersen teg at jklm.no
Tue Jul 16 14:11:21 PDT 2013


On Tue, Jul 16, 2013 at 8:39 PM, Lennart Poettering
<lennart at poettering.net> wrote:
> On Tue, 16.07.13 19:38, Tom Gundersen (teg at jklm.no) wrote:
>
>> -                udev_enumerate_unref(e);
>> +        /* udev exports "dead" device nodes to allow module on-demand loading,
>> +         * these devices are not known to the kernel at this moment */
>> +        dir = opendir("/run/udev/static_node-tags/uaccess");
>> +        if (dir) {
>> +                for (dent = readdir(dir); dent != NULL; dent =
>> readdir(dir)) {
>
> Please use FOREACH_DIRENT here!
>
>> +                        _cleanup_free_ char *unescaped_devname = NULL;
>>
>> +                        if (dent->d_name[0] == '.')
>> +                                continue;
>
> This is unnecessary if you use FOREACH_DIRENT.
>
>> +
>> +                        unescaped_devname = cunescape(dent->d_name);
>> +                        if (unescaped_devname == NULL) {
>> +                                r = -ENOMEM;
>> +                                closedir(dir);
>
> Looks like you want to use _cleanup_closedir_ for this?

Thanks for the suggestions. Will push fix after testing.

>> +                                goto finish;
>> +                        }
>> +
>> +                        n = strappend("/dev/", unescaped_devname);
>
> Good candidate for strappenda?

Except for this one.

-t


More information about the systemd-devel mailing list