[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] Add subsystem support to mdev (firmware loading)
From: Bernhard Fischer <rep.nop () aon ! at>
Date: 2006-09-29 11:44:12
Message-ID: 20060929114412.GA24586 () aon ! at
[Download RAW message or body]
On Fri, Sep 29, 2006 at 01:34:06PM +0200, walter harms wrote:
>i am not a security expert but
>sprintf(temp, "/lib/mdev/%s", getenv("SUBSYSTEM"));
>would lead to a problem the subsystem is of freakish length (accidently of cause).
>perhaps snprintf() or asprint() (requires _GNU_SOURCE) would be
>better.
The proper thing to do there is to reuse concat_path_file, fwiw.
Also please make sure to adhere to the coding-style perused for busybox:
Bad style:
make_device(temp,0);
Proper:
make_device(temp, 0);
>
>just my two cents,
+=2;
thanks,
>
>re,
> wh
>
>Michael-Luke Jones wrote:
>> Hi there,
>>
>> I'm enclosing a patch that allows mdev to call external scripts to
>> deal with 'subsystem' hotplug requests. I also enclose a script to
>> handle firmware loading (via firmware_class) which has been tested
>> with the 2.6.18 kernel on an NSLU2.
>>
>> --- busybox-1.2.1.orig/util-linux/mdev.c 2006-07-01
>> 00:42:13.000000000 +0200
>> +++ busybox-1.2.1/util-linux/mdev.c 2006-09-26 17:42:38.414162744 +0200
>> @@ -255,7 +255,16 @@
>> bb_show_usage();
>> sprintf(temp, "/sys%s", env_path);
>> - if (!strcmp(action, "add")) make_device(temp,0);
>> + if (!strcmp(action, "add")) {
>> + struct stat st;
>> + make_device(temp,0);
>> + sprintf(temp, "/lib/mdev/%s", getenv("SUBSYSTEM"));
>> + if (stat(temp, &st) == 0) {
>> + if ((st.st_mode & S_IXUSR) && S_ISREG(st.st_mode)) {
>> + system(temp);
>> + }
>> + }
>> + }
>> else if (!strcmp(action, "remove")) make_device(temp,1);
>> }
>>
>> --Script should be dropped into /lib/mdev/firmware--
>> #!/bin/sh
>>
>> firmwaredir=/lib/firmware
>>
>> if test "$SUBSYSTEM" = "firmware" -a "$ACTION" = "add"; then
>> if test -f $firmwaredir/$FIRMWARE; then
>> echo 1 > /sys/$DEVPATH/loading
>> cat $firmwaredir/$FIRMWARE > /sys/$DEVPATH/data
>> echo 0 > /sys/$DEVPATH/loading
>> else
>> echo -1 > /sys/$DEVPATH/loading
>> fi
>> fi
>>
>> Firmware loading is vital for certain embedded systems such as all
>> IXP4xx boards when the GPL Ethernet driver is used. I hope that this
>> patch or a variation can be included in BusyBox 1.3.0. Christian
>> Hohnstaedt is the author of this patch and he is CCed on this email.
>> I've got his permission to send them to you.
>>
>> Michael-Luke Jones
>> _______________________________________________
>> busybox mailing list
>> busybox@busybox.net
>> http://busybox.net/cgi-bin/mailman/listinfo/busybox
>>
>>
>>
>_______________________________________________
>busybox mailing list
>busybox@busybox.net
>http://busybox.net/cgi-bin/mailman/listinfo/busybox
>
_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic