PSARC 2007/045 I2O EOL and EOF 4863632 Hey Hey! Ho Ho! I2O Has Got to Go!
1 #!/bin/sh 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 # 23 # Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24 # Use is subject to license terms. 25 # 26 #ident "@(#)i.minorperm_i386 1.73 07/01/22 SMI" 27 # 28 29 # 30 # NOTE: When a change is made to the source file for 31 # /etc/minor_perm, a corresponding change must be made to 32 # this class-action script. 33 # 34 # - If an existing entry in minor_perm is having its 35 # attributes e.g. permissions, ownership changed, 36 # add it to the list produced by make_chattr_list below. 37 # 38 # - If an existing entry must be deleted, add it to 39 # the list produced by make_delete_list below. 40 # 41 # - If a new entry must be added to the file, add it to the 42 # list produced by make_add_list. 43 # 44 # - If a new entry is being added to minor_perm, but there 45 # may already be devices of that name on the system (e.g. 46 # we used the system default permissions in a previous release), 47 # and those old devices now need to have their attributes changed, 48 # add it to the make_chattr_list AND the make_add_list lists 49 # 50 51 # 52 # If an entry in /etc/minor_perm needs to have its attributes 53 # changed, identify the entry in the list copied to /etc/chattr.$$ 54 # by this function. The fields are: 55 # 56 # <device>:<minor> <old_attrs> <new_attrs> <optional list of logical 57 # devices whose attributes 58 # will need to be changed> 59 # 60 # where an <attribute list> := <perm> <user> <group> 61 # 62 # NOTE: this list should also contain entries for nodes that previously 63 # were not in /etc/minor_perm (which means the default mode of 600, 64 # owner/group == root/sys), but now have an entry 65 # 66 67 make_chattr_list() 68 { 69 cat > /tmp/chattr.$$ << EOF 70 vol:volctl 0600 root sys 0666 root sys /dev/volctl 71 clone:llc1 0600 root sys 0666 root sys /dev/llc1 72 clone:sound,sbpro 0666 root sys 0600 root sys /dev/sound/* 73 sbpro:* 0666 root sys 0600 root sys /dev/sound/* 74 log:conslog 0620 root sys 0666 root sys /dev/conslog 75 sy:tty 0666 root sys 0666 root tty /dev/tty 76 icmp:icmp 0600 root sys 0666 root sys /dev/rawip 77 icmp6:icmp6 0600 root sys 0666 root sys /dev/rawip6 78 ip:ip 0660 root sys 0666 root sys /dev/ip 79 ip6:ip6 0660 root sys 0666 root sys /dev/ip6 80 rts:rts 0660 root sys 0666 root sys /dev/rts 81 keysock:keysock 0600 root sys 0666 root sys /dev/keysock 82 ipsecah:ipsecah 0600 root sys 0666 root sys /dev/ipsecah 83 ipsecesp:ipsecesp 0600 root sys 0666 root sys /dev/ipsecesp 84 spdsock:spdsock 0600 root sys 0666 root sys /dev/spdsock 85 sad:admin 0600 root sys 0666 root sys /dev/sad/admin 86 fssnap:ctl 0600 root sys 0666 root sys /dev/fssnapctl 87 fssnap:* 0600 root sys 0640 root sys /dev/fssnap/* 88 clone:dnet 0600 root sys 0666 root sys /dev/dnet 89 dnet:* 0600 root sys 0666 root sys /dev/dnet* 90 clone:elxl 0600 root sys 0666 root sys /dev/elxl 91 elxl:* 0600 root sys 0666 root sys /dev/elxl* 92 clone:iprb 0600 root sys 0666 root sys /dev/iprb 93 iprb:* 0600 root sys 0666 root sys /dev/iprb* 94 clone:pcelx 0600 root sys 0666 root sys /dev/pcelx 95 pcelx:* 0600 root sys 0666 root sys /dev/pcelx* 96 clone:spwr 0600 root sys 0666 root sys /dev/spwr 97 spwr:* 0600 root sys 0666 root sys /dev/spwr* 98 cpc:* 0600 root sys 0666 root sys /devices/pseudo/cpc* 99 ipf:* 0600 root sys 0666 root sys /dev/ipf 100 pfil:* 0600 root sys 0666 root sys /dev/pfil 101 scsi_vhci:devctl 0600 root sys 0666 root sys /devices/scsi_vhci:devctl 102 fbt:fbt 0600 root sys 0644 root sys /dev/dtrace/provider/fbt 103 lockstat:* 0600 root sys 0644 root sys /dev/dtrace/provider/lockstat 104 profile:profile 0600 root sys 0644 root sys /dev/dtrace/provider/profile 105 sdt:sdt 0600 root sys 0644 root sys /dev/dtrace/provider/sdt 106 systrace:systrace 0600 root sys 0644 root sys /dev/dtrace/provider/systrace 107 clone:bge 0600 root sys 0666 root sys /dev/bge 108 clone:rge 0600 root sys 0666 root sys /dev/rge 109 clone:xge 0600 root sys 0666 root sys /dev/xge 110 clone:nge 0600 root sys 0666 root sys /dev/nge 111 clone:chxge 0600 root sys 0666 root sys /dev/chxge 112 clone:pcn 0600 root sys 0666 root sys /dev/pcn 113 clone:rtls 0600 root sys 0666 root sys /dev/rtls 114 clone:ath 0600 root sys 0666 root sys /dev/ath 115 bge:* 0600 root sys 0666 root sys /dev/bge* 116 rge:* 0600 root sys 0666 root sys /dev/rge* 117 xge:* 0600 root sys 0666 root sys /dev/xge* 118 nge:* 0600 root sys 0666 root sys /dev/nge* 119 e1000g:* 0666 root root 0666 root sys /dev/e1000g* 120 chxge:* 0600 root sys 0666 root sys /dev/chxge* 121 pcn:* 0600 root sys 0666 root sys /dev/pcn* 122 rtls:* 0600 root sys 0666 root sys /dev/rtls* 123 ath:* 0600 root sys 0666 root sys /dev/ath* 124 EOF 125 } 126 127 # 128 # If an entry in /etc/minor_perm needs to be deleted, identify 129 # the entry in the list copied to /etc/delete.$$ by this function. 130 # The fields are: 131 # 132 # <device>:<minor> <optional list of logical devices to be deleted> 133 # 134 135 make_delete_list() 136 { 137 cat > /tmp/delete.$$ << EOF 138 rip:rawip 139 consfb:consfb 140 clone:el 141 clone:elx 142 clone:sle 143 clone:sie 144 clone:sp 145 clone:ip 146 clone:icmp 147 clone:udp 148 clone:tcp 149 clone:rts 150 clone:arp 151 clone:ipsecah 152 clone:ipsecesp 153 clone:keysock 154 clone:smc 155 clone:tr 156 elx:* 157 win:* 158 cmtp:* 159 profile:profile 160 asy:[a-z] 161 asy:[a-z],cu 162 i2o_bs:* 163 EOF 164 } 165 166 # 167 # If an entry needs to be added to /etc/minor_perm, add the first 168 # field of the entry to the list created by this function. The 169 # remainder of the entry will be extracted from the /etc/minor_perm 170 # in the package being installed, so it is not necessary to supply 171 # it here. 172 # 173 174 make_add_list() 175 { 176 cat > /tmp/add.$$ << EOF 177 vol:volctl 178 clone:llc1 179 tnf:tnfctl 180 tnf:tnfmap 181 st:* 182 pm:* 183 devinfo:devinfo 184 openeepr:openprom 185 wc:* 186 ip:ip 187 ip6:ip6 188 icmp:icmp 189 icmp6:icmp6 190 udp:udp 191 udp6:udp6 192 tcp:tcp 193 tcp6:tcp6 194 rts:rts 195 arp:arp 196 poll:* 197 pool:pool 198 pool:poolctl 199 cpc:shared 200 sysmsg:msglog 201 sysmsg:sysmsg 202 ipsecah:ipsecah 203 ipsecesp:ipsecesp 204 keysock:keysock 205 spdsock:spdsock 206 devinfo:devinfo,ro 207 lofi:* 208 lofi:ctl 209 sgen:* 210 fssnap:* 211 fssnap:ctl 212 rsm:* 213 random:* 214 mm:allkmem 215 clone:dnet 216 dnet:* 217 clone:elxl 218 elxl:* 219 clone:ibd 220 ibd:* 221 clone:iprb 222 iprb:* 223 clone:pcelx 224 pcelx:* 225 clone:spwr 226 spwr:* 227 sysevent:* 228 ramdisk:* 229 ramdisk:ctl 230 cryptoadm:cryptoadm 231 crypto:crypto 232 dtrace:* 233 fasttrap:fasttrap 234 ipf:* 235 pfil:* 236 bl:* 237 sctp:* 238 sctp6:* 239 vni:* 240 cpuid:self 241 clone:bge 242 clone:rge 243 clone:xge 244 clone:nge 245 clone:e1000g 246 clone:chxge 247 clone:pcn 248 clone:rtls 249 clone:ath 250 bge:* 251 rge:* 252 xge:* 253 nge:* 254 e1000g:* 255 chxge:* 256 pcn:* 257 rtls:* 258 ath:* 259 bmc:bmc 260 dld:* 261 aggr:* 262 smbios:smbios 263 zfs:* 264 zfs:zfs 265 scsi_vhci:* 266 kssl:* 267 fbt:fbt 268 profile:profile 269 sdt:sdt 270 systrace:systrace 271 lx_ptm:lx_ptmajor 272 lx_systrace:* 273 physmem:* 274 asy:* 275 asy:*,cu 276 EOF 277 } 278 279 PATH="/sbin:/usr/sbin:/usr/bin:/usr/sadm/install/bin" 280 export PATH 281 282 # Internal routine to create a sed script which can be used to 283 # escape all shell globbing metacharacters in a path. 284 285 create_esc_sedscript() 286 { 287 cat > /tmp/esc.sed.$$ << EOF 288 s/\*/\\\\*/g 289 s/\?/\\\\?/g 290 s/\[/\\\\[/g 291 s/\]/\\\\]/g 292 EOF 293 } 294 295 # Internal routine to convert an entry in a /tmp/chwhatever.$$ file to 296 # an appropriately escaped pattern which can be used to grep into minor_perm. 297 298 entry2pattern() 299 { 300 # the first argument is the 'key' field from the change file. 301 # entries can contain shell globbing characters to match 302 # several devices - hence all the palaver below. 303 304 printf '%s' `echo "$1" | sed \ 305 -e 's/\*/\\\\*/g' -e 's/\?/\\\\?/g' \ 306 -e 's/\./\\\\./g' -e 's/\[/\\\\[/g' \ 307 -e 's/\]/\\\\]/g'` 308 shift 309 310 # the remaining optional arguments are tokens separated by white-space 311 312 if [ $# = 0 ] ; then 313 printf '[ \t]' 314 else 315 while [ -n "$1" ] 316 do 317 printf '[ \t][ \t]*%s' $1 318 shift 319 done 320 printf '[ \t]*$' 321 fi 322 } 323 324 while read src dest 325 do 326 if [ ! -f $dest ] ; then 327 cp $src $dest 328 else 329 rm -f /tmp/*.$$ 330 create_esc_sedscript 331 make_chattr_list 332 make_delete_list 333 make_add_list 334 335 # 336 # Process the list of devices whose attributes are to be 337 # changed. Find those that actually need to be 338 # applied to the file. For each change that needs 339 # to be applied, add an entry for it to the sed 340 # script that will eventually be applied to the 341 # currently-installed /etc/minor_perm file. Also, 342 # add an entry to the /tmp/chdevs.$$ file, which 343 # contains the list of logical names of devices 344 # whose permissions need to be changed. 345 # 346 347 cat /tmp/chattr.$$ | \ 348 while read key oldp oldu oldg newp newu newg chdevs 349 do 350 do_chdevs=no 351 352 # 353 # First determine whether the device entry 354 # is already in the file, but with the old 355 # permissions. If so, the entry needs to be 356 # modified and the devices in the chdevs list 357 # need to have their permissions and ownerships 358 # changed. 359 # 360 grepstr=`entry2pattern "${key}" $oldp $oldu $oldg` 361 if grep "$grepstr" $dest > /dev/null 2>&1; then 362 echo "s/${grepstr}/$key $newp $newu $newg/" \ 363 >> /tmp/sedscript.$$ 364 do_chdevs=yes 365 fi 366 367 # 368 # Now determine whether the device entry is 369 # in the file at all. If not, it is a new 370 # entry, but there may already be devices 371 # on the system whose permissions need to 372 # be changed. 373 # 374 grepstr=`entry2pattern "${key}"` 375 grep "${grepstr}" $dest > /dev/null 2>&1 376 if [ $? != 0 ] ; then 377 do_chdevs=yes 378 fi 379 380 if [ $do_chdevs = yes -a "$chdevs" != "" ] ; then 381 xchdevs=`echo "$chdevs" | \ 382 sed -f /tmp/esc.sed.$$` 383 for m in $xchdevs ; do 384 echo "$m" $oldp $oldu $oldg \ 385 $newp $newu $newg >> /tmp/chdevs.$$ 386 done 387 fi 388 done 389 390 # sort the "change attributes" list 391 if [ -s /tmp/chdevs.$$ ] ; then 392 sort -u /tmp/chdevs.$$ > /tmp/tmp.$$ 393 mv /tmp/tmp.$$ /tmp/chdevs.$$ 394 fi 395 396 # 397 # Process the list of devices to be deleted. 398 # Find those that actually need to be deleted 399 # from the file. For each entry to be deleted, 400 # add an entry for it to the sed script that will 401 # eventually be applied to the currently-installed 402 # /etc/minor_perm file. Also, add an entry to the 403 # /tmp/deldevs.$$ file, which contains the list of 404 # logical names of devices to be deleted. 405 # 406 407 cat /tmp/delete.$$ | while read key deldevs 408 do 409 grepstr=`entry2pattern "${key}"` 410 if grep "$grepstr" $dest > /dev/null 2>&1; then 411 echo "/${grepstr}/d" >> /tmp/sedscript.$$ 412 if [ "$deldevs" != "" ] ; then 413 xdeldevs=`echo "$deldevs" | \ 414 sed -f /tmp/esc.sed.$$` 415 for m in $xdeldevs ; do 416 echo "$m" >> /tmp/deldevs.$$ 417 done 418 fi 419 fi 420 done 421 if [ -s /tmp/deldevs.$$ ] ; then 422 sort -u /tmp/deldevs.$$ > /tmp/tmp.$$ 423 mv /tmp/tmp.$$ /tmp/deldevs.$$ 424 fi 425 426 # 427 # Apply the sed script possibly built above to the 428 # currently-installed /etc/minor_perm file. 429 # 430 431 if [ -s /tmp/sedscript.$$ ] ; then 432 sed -f /tmp/sedscript.$$ $dest > /tmp/tmp.$$ 433 cp /tmp/tmp.$$ $dest 434 fi 435 436 # For all entries in minor_perm whose attributes had 437 # to be corrected, correct the relevant attributes of the 438 # already-existing devices that correspond to those 439 # entries. 440 # 441 if [ -s /tmp/chdevs.$$ -a "$PKG_INSTALL_ROOT" != "" -a \ 442 "$PKG_INSTALL_ROOT" != "/" ] ; then 443 cat /tmp/chdevs.$$ |\ 444 while read device oldp oldu oldg newp newu newg 445 do 446 # 447 # Note that we take pains -only- to change 448 # the permission/ownership of devices that 449 # have kept their original permissions. 450 # 451 for dev in $PKG_INSTALL_ROOT/$device; do 452 find $dev -follow -perm $oldp -exec \ 453 chmod $newp $dev \; >/dev/null 2>&1 454 find $dev -follow -user $oldu -exec \ 455 chown $newu $dev \; >/dev/null 2>&1 456 find $dev -follow -group $oldg -exec \ 457 chgrp $newg $dev \; >/dev/null 2>&1 458 done 459 done 460 fi 461 462 # 463 # For all entries in minor_perm that were deleted, 464 # remove the /dev entries that point to device nodes 465 # that correspond to those entries. 466 # 467 if [ -s /tmp/deldevs.$$ -a "$PKG_INSTALL_ROOT" != "" -a \ 468 "$PKG_INSTALL_ROOT" != "/" ] ; then 469 cat /tmp/deldevs.$$ | while read device 470 do 471 rm -f $PKG_INSTALL_ROOT/$device 472 done 473 fi 474 475 cat /tmp/add.$$ | while read key 476 do 477 grepstr=`entry2pattern "${key}"` 478 grep "$grepstr" $dest > /dev/null 2>&1 479 if [ $? != 0 ] ; then 480 grep "$grepstr" $src >> $dest 481 fi 482 done 483 484 rm -f /tmp/*.$$ 485 fi 486 done 487 488 exit 0 --- EOF ---