Contents of /trunk/module-init-tools/patches/module-init-tools-3.2.2-handle-dupliate-aliases.patch
Parent Directory | Revision Log
Revision 153 -
(show annotations)
(download)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 2345 byte(s)
Tue May 8 20:52:56 2007 UTC (17 years, 4 months ago) by niro
File size: 2345 byte(s)
-import
1 | http://bugs.gentoo.org/149426 |
2 | |
3 | keep from blowing up when people have duplicate aliases ... the grep |
4 | ends up including new lines and with certain formed comments, hits an |
5 | infinite loop ... |
6 | |
7 | for example, the following inputs illustrates the problem: |
8 | ---------------------------------------------- |
9 | # Old nvidia support ... |
10 | alias char-major-195 NVdriver |
11 | alias /dev/nvidiactl char-major-195 |
12 | alias char-major-195 nvidia |
13 | alias /dev/nvidiactl char-major-195 |
14 | # To enable Side Band Adressing: NVreg_EnableAGPSBA=1 |
15 | #options nvidia NVreg_EnableAGPSBA=1 NVreg_EnableAGPFW=1 |
16 | #options nvidia NVreg_SoftEDIDs=0 NVreg_Mobile=3 |
17 | ---------------------------------------------- |
18 | alias a b |
19 | alias b a |
20 | ---------------------------------------------- |
21 | |
22 | fixes from Martin Väth |
23 | |
24 | --- generate-modprobe.conf |
25 | +++ generate-modprobe.conf |
26 | @@ -65,19 +65,29 @@ |
27 | # Resolve (possibly recursive) alias: args filename alias |
28 | resolve_alias() |
29 | { |
30 | - RA_RESOLVE=`grep "^alias[ ][ ]*$2[ ]" -- $1 | awk '{ print $3 }'` |
31 | + if [ 0$3 -gt 99 ]; then |
32 | + echo "Infinite recursion detected; aborting after $3 tries (alias '$2')" 1>&2 |
33 | + return 1 |
34 | + fi |
35 | + |
36 | + _RA_RESOLVE=`grep "^alias[ ][ ]*$2[ ]" -- $1 | awk '{ print $3 }'` |
37 | + RA_RESOLVE=`echo "$_RA_RESOLVE" | head -n 1` |
38 | + if [ x"$_RA_RESOLVE" != x"$RA_RESOLVE" ]; then |
39 | + echo "Invalid dupliate alias found for '$2' (results: `echo $_RA_RESOLVE`)" 1>&2 |
40 | + return 1 |
41 | + fi |
42 | if [ x"$RA_RESOLVE" = x ]; then |
43 | echo $2 |
44 | return |
45 | fi |
46 | # Recurse. |
47 | - (resolve_alias $1 "$RA_RESOLVE") |
48 | + (resolve_alias $1 "$RA_RESOLVE" $(($3 + 1))) |
49 | } |
50 | |
51 | # Parse alias: args filename modulename aliasto. |
52 | parse_alias() |
53 | { |
54 | - PA_ALIAS=`resolve_alias $1 $3` |
55 | + PA_ALIAS=`resolve_alias $1 $3` || exit 1 |
56 | NAME=`echo $2|sed -e 's/\(block\|char\)-major-\([0-9]\+\)$/\1-major-\2-*/'` |
57 | |
58 | echo "alias $NAME $PA_ALIAS" |
59 | @@ -180,7 +190,8 @@ |
60 | parse_options $MODULE `grab_noninstall_options $REST` |
61 | INSTALL_OPTIONS=`grab_install_options $REST` |
62 | INSTALL_COMMANDS="$INSTALL_COMMANDS $MODULE" |
63 | - eval install_$MODNAME=\"/sbin/modprobe $INSTALL_OPTIONS --ignore-install `resolve_alias $MODPROBECONF $MODULE`\" |
64 | + INSTALL_ALIAS=`resolve_alias $MODPROBECONF "$MODULE"` || exit 1 |
65 | + eval install_$MODNAME=\"/sbin/modprobe $INSTALL_OPTIONS --ignore-install $INSTALL_ALIAS\" |
66 | ;; |
67 | *) |
68 | parse_options $MODULE "$REST" |