]> git.saurik.com Git - apple/configd.git/blob - get-mobility-info
configd-699.30.1.tar.gz
[apple/configd.git] / get-mobility-info
1 #!/bin/sh
2 # Copyright (c) 2004-2015 Apple Inc.
3 #
4 # get-mobility-info
5 #
6 # Collect system & network configuration information.
7 #
8
9 PATH=/bin:/usr/bin:/sbin:/usr/sbin
10
11 #
12 # Disclaimer
13 #
14 cat <<_END_OF_DISCLAIMER
15
16 This diagnostic tool generates files that allow Apple to investigate issues
17 with your computer and help Apple to improve its products. The generated files
18 may contain some of your personal information, which may include, but not be
19 limited to, the serial number or similar unique number for your device, your
20 user name, or your computer name. The information is used by Apple in
21 accordance with its privacy policy (www.apple.com/privacy) and is not shared
22 with any third party. By enabling this diagnostic tool and sending a copy of
23 the generated files to Apple, you are consenting to Apple's use of the content
24 of such files.
25
26 _END_OF_DISCLAIMER
27
28 /bin/echo "Press 'Enter' to continue."
29 read reply
30
31 #
32 # Setup
33 #
34 PRIV=""
35 if [ ${EUID} -ne 0 ]; then
36 PRIV="sudo"
37 fi
38
39 if [ -x /usr/bin/tail ]; then
40 TAIL_2000="/usr/bin/tail -n 2000"
41 TAIL_25000="/usr/bin/tail -n 25000"
42 else
43 TAIL_2000="/bin/cat"
44 TAIL_25000="/bin/cat"
45 fi
46
47 OUT="mobility-info-`date +'%m.%d.%Y.%H%M%S'`"
48 OUTDIR="/var/tmp"
49 if [ -d ~/Desktop ]; then
50 OUTDIR=~/Desktop
51 elif [ "`readlink /tmp`" = "private/var/tmp" ]; then
52 OUTDIR=/Library/Logs/CrashReporter
53 mkdir -p ${OUTDIR}
54 fi
55
56 umask 077
57
58 WORKDIR=`mktemp -d -q "/tmp/${OUT}"`
59 if [ $? -ne 0 ]; then
60 echo "Could not create snapshot directory"
61 exit 1
62 fi
63
64 GZ_EXT=""
65 GZ_OPT=""
66 if [ -x /usr/bin/gzip ]; then
67 GZ_EXT=".gz"
68 GZ_OPT="-z"
69 fi
70
71 ARCHIVE=`mktemp -q "${OUTDIR}/${OUT}.tar${GZ_EXT}"`
72 if [ $? -ne 0 ]; then
73 echo "Could not create snapshot archive"
74 rm -rf "${WORKDIR}"
75 exit 1
76 fi
77
78 cd "${WORKDIR}"
79
80 echo ""
81 echo "Please wait, collecting information and statistics"
82 echo ""
83
84 #
85 # Execute network reachability/DNS commands early
86 #
87 echo "#" > reachability-info
88 echo '# scutil -d -v -r www.apple.com "" no-server' >> reachability-info
89 echo "#" >> reachability-info
90 scutil -d -v -r www.apple.com "" no-server >> reachability-info 2>&1
91
92 echo "#" >> reachability-info
93 echo '# scutil -d -v -r 0.0.0.0 no-server' >> reachability-info
94 echo "#" >> reachability-info
95 scutil -d -v -r 0.0.0.0 no-server >> reachability-info 2>&1
96
97 if [ -x /usr/bin/dig -a -f /etc/resolv.conf ]; then
98 /usr/bin/dig -t any -c any www.apple.com > dig-results 2>/dev/null
99 fi
100
101 #
102 # Signal "networkd" and "mDNSResponder" early to log their "state" info. This
103 # logging will continue while we execute a few other commands and should be
104 # complete by the time we collect the log content.
105 #
106 if [ -x /usr/bin/killall ]; then
107 #
108 # request networkd state
109 #
110 ${PRIV} /usr/bin/killall -INFO networkd 2>/dev/null
111
112 #
113 # request mDNSResponder state
114 #
115 ${PRIV} /usr/bin/killall -INFO mDNSResponder 2>/dev/null
116
117 sleep 1
118 fi
119
120 #
121 # processes
122 #
123 if [ -x /bin/ps ]; then
124 /bin/ps axlww > ps 2>&1
125 fi
126
127 #
128 # network interface configuration
129 #
130 if [ -x /sbin/ifconfig ]; then
131 /sbin/ifconfig -a -L -b -m -r -v -v > ifconfig 2>&1
132 if [ $? -ne 0 ]; then
133 /sbin/ifconfig -a > ifconfig 2>&1
134 fi
135 fi
136
137 #
138 # network route configuration
139 #
140 if [ -x /usr/sbin/netstat ]; then
141 /usr/sbin/netstat -n -r -a -l > netstat 2>&1
142 fi
143
144 #
145 # DHCP configuration
146 #
147 if [ -x /sbin/ifconfig ]; then
148 for if in `/sbin/ifconfig -l`
149 do
150 case ${if} in
151 lo* ) ;;
152 en* ) ipconfig getpacket ${if} > ipconfig-${if} 2>&1
153 ;;
154 esac
155 done
156 fi
157
158 #
159 # AirPort info
160 #
161 if [ -x /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport ]; then
162 /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport --getinfo \
163 > airport 2>&1
164 fi
165
166 #
167 # collect wifi dump
168 #
169 if [ -x /usr/bin/wdutil -a -x /bin/ls ]; then
170 ${PRIV} /usr/bin/wdutil dump
171 mkdir -p "wifi_dump"
172 /bin/ls -1 /private/tmp/wifi-* 2>/dev/null \
173 | while read log
174 do
175 if [ -f "${log}" ]; then
176 b="`basename ${log}`"
177 ${PRIV} cat "${log}" > "wifi_dump/${b}" 2>&1
178 fi
179 done
180 fi
181
182 #
183 # OS info
184 #
185 if [ -e /System/Library/CoreServices/SystemVersion.plist ]; then
186 cat /System/Library/CoreServices/SystemVersion.plist \
187 > SystemVersion.plist 2>&1
188 fi
189
190 #
191 # IOKit info
192 #
193 if [ -x /usr/sbin/ioreg ]; then
194 /usr/sbin/ioreg -i -l -w 0 > ioreg 2>&1
195 /usr/sbin/ioreg -i -l -p IODeviceTree -w 0 >> ioreg 2>&1
196 fi
197
198 #
199 # Power Management info
200 #
201 if [ -x /usr/bin/pmset ]; then
202 echo "#" > pmset
203 echo "# pmset -g everything" >> pmset
204 echo "#" >> pmset
205 /usr/bin/pmset -g everything 2>/dev/null | ${TAIL_25000} >> pmset
206 fi
207
208 #
209 # Host name
210 #
211 if [ -x /bin/hostname ]; then
212 /bin/hostname > hostname 2>&1
213 fi
214
215 #
216 # Host configuration
217 #
218 if [ -x /usr/bin/hostinfo ]; then
219 /usr/bin/hostinfo > hostinfo 2>&1
220 fi
221 if [ -e /etc/hostconfig ]; then
222 cat /etc/hostconfig > etc.hostconfig 2>&1
223 fi
224
225 #
226 # DNS configuration
227 #
228 scutil --dns > dns-configuration 2>&1
229 if [ -e /etc/resolv.conf ]; then
230 cat /etc/resolv.conf > etc.resolv.conf 2>&1
231 fi
232 if [ -e /var/run/resolv.conf ]; then
233 cat /var/run/resolv.conf > var.run.resolv.conf 2>&1
234 fi
235 if [ -e /etc/resolver ]; then
236 tar -c -H /etc/resolver > etc.resolver.tar 2>/dev/null
237 fi
238
239 #
240 # Proxy configuration
241 #
242 scutil -d -v --proxy > proxy-configuration 2>&1
243
244 #
245 # Network information
246 #
247 if [ -x /sbin/ifconfig ]; then
248 echo "#" > network-information
249 echo "# scutil --nwi" >> network-information
250 echo "#" >> network-information
251 scutil --nwi >> network-information 2>&1
252 for if in `/sbin/ifconfig -l`
253 do
254 echo "" >> network-information
255 echo "#" >> network-information
256 echo "# scutil --nwi ${if}" >> network-information
257 echo "#" >> network-information
258 scutil --nwi ${if} >> network-information 2>&1
259 done
260 fi
261
262 #
263 # System / network preferences
264 #
265 for f in \
266 /Library/Preferences/SystemConfiguration/NetworkInterfaces.plist \
267 /Library/Preferences/SystemConfiguration/com.apple.PowerManagement.plist \
268 /Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist \
269 /Library/Preferences/SystemConfiguration/com.apple.nat.plist \
270 /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist \
271 /Library/Preferences/SystemConfiguration/com.apple.wifi.plist \
272 /Library/Preferences/SystemConfiguration/preferences.plist \
273 /Library/Preferences/com.apple.alf.plist \
274 /Library/Preferences/com.apple.sharing.firewall.plist \
275 /Library/Preferences/com.apple.networkextension.plist \
276 /Library/Preferences/com.apple.networkextension.control.plist \
277 /Library/Preferences/com.apple.networkextension.necp.plist \
278 /Library/Preferences/com.apple.wwand.plist \
279
280 do
281 if [ -e "${f}" ]; then
282 b="`basename ${f}`"
283 cat "${f}" > "${b}" 2>&1
284 fi
285 done
286
287 #
288 # System / network preferences (from other volumes)
289 #
290 /bin/ls /Volumes 2>/dev/null \
291 | while read volume
292 do
293 V_PATH="/Volumes/${volume}"
294 if [ -h "${V_PATH}" ]; then
295 # if the path is a symlink
296 continue
297 fi
298 for f in \
299 /Library/Preferences/SystemConfiguration/Networkinterfaces.plist \
300 /Library/Preferences/SystemConfiguration/preferences.plist \
301
302 do
303 if [ -f "${V_PATH}/${f}" ]; then
304 mkdir -p "OtherPreferences/${volume}"
305 b="`basename ${f}`"
306 cat "${V_PATH}/${f}" > "OtherPreferences/${volume}/${b}" 2>&1
307 fi
308 done
309 done
310
311 #
312 # InternetSharing
313 #
314 if [ -e /etc/bootpd.plist ]; then
315 cat /etc/bootpd.plist > bootpd.plist 2>&1
316 cat /etc/com.apple.named.proxy.conf > com.apple.named.proxy.conf 2>/dev/null
317 elif [ -e /Library/Preferences/SystemConfiguration/bootpd.plist ]; then
318 cat /Library/Preferences/SystemConfiguration/bootpd.plist > bootpd.plist 2>&1
319 cat /Library/Preferences/SystemConfiguration/com.apple.named.proxy.conf > com.apple.named.proxy.conf 2>/dev/null
320 fi
321
322 #
323 # configd's cache
324 #
325 ${PRIV} scutil -p --snapshot
326 if [ -f /var/tmp/configd-store.plist ]; then
327 cat /var/tmp/configd-store.plist > configd-store.plist 2>&1
328 fi
329 if [ -f /var/tmp/configd-pattern.plist ]; then
330 cat /var/tmp/configd-pattern.plist > configd-pattern.plist 2>&1
331 fi
332 if [ -f /var/tmp/configd-session.plist ]; then
333 cat /var/tmp/configd-session.plist > configd-session.plist 2>&1
334 fi
335 if [ -f /var/tmp/configd-state ]; then
336 cat /var/tmp/configd-state > configd-state 2>&1
337 fi
338 if [ -f /var/tmp/configd-reachability ]; then
339 cat /var/tmp/configd-reachability > configd-reachability 2>&1
340 fi
341
342 #
343 # mounted filesystems
344 #
345 mount > mounted-filesystems 2>&1
346
347 ${PRIV} cat /etc/hosts > etc.hosts 2>/dev/null
348
349 #
350 # kernel extensions statistic
351 #
352 if [ -x /usr/sbin/kextstat ]; then
353 /usr/sbin/kextstat > kextstat 2>&1
354 fi
355
356 #
357 # network statistics
358 #
359 /bin/echo -n "" > network-statistics
360
361 if [ -x /usr/sbin/arp ]; then
362 echo "#" >> network-statistics
363 echo "# arp -n -a" >> network-statistics
364 echo "#" >> network-statistics
365 /usr/sbin/arp -n -a >> network-statistics 2>&1
366 fi
367
368 if [ -x /usr/sbin/netstat ]; then
369 echo "#" >> network-statistics
370 echo "# netstat -A -a -l -n" >> network-statistics
371 echo "#" >> network-statistics
372 /usr/sbin/netstat -A -a -l -n >> network-statistics 2>&1
373
374 echo "#" >> network-statistics
375 echo "# netstat -s" >> network-statistics
376 echo "#" >> network-statistics
377 /usr/sbin/netstat -s >> network-statistics 2>&1
378
379 echo "#" >> network-statistics
380 echo "# netstat -mmm" >> network-statistics
381 echo "#" >> network-statistics
382 /usr/sbin/netstat -mmm >> network-statistics 2>&1
383
384 echo "#" >> network-statistics
385 echo "# netstat -i -n -d" >> network-statistics
386 echo "#" >> network-statistics
387 /usr/sbin/netstat -i -n -d >> network-statistics 2>&1
388
389 echo "#" >> network-statistics
390 echo "# netstat -g -n -s" >> network-statistics
391 echo "#" >> network-statistics
392 /usr/sbin/netstat -g -n -s >> network-statistics 2>&1
393
394 echo "#" >> network-statistics
395 echo "# netstat -i -x R" >> network-statistics
396 echo "#" >> network-statistics
397 /usr/sbin/netstat -i -x R >> network-statistics 2>&1
398 echo "#" >> network-statistics
399
400 echo "# netstat -a -n -p mptcp" >> network-statistics
401 echo "#" >> network-statistics
402 /usr/sbin/netstat -a -n -p mptcp >> network-statistics 2>/dev/null
403
404 echo "#" >> network-statistics
405 echo "# netstat -s -p mptcp" >> network-statistics
406 echo "#" >> network-statistics
407 /usr/sbin/netstat -s -p mptcp >> network-statistics 2>/dev/null
408
409 if [ -x /sbin/ifconfig ]; then
410 for if in `/sbin/ifconfig -l`
411 do
412 `/sbin/ifconfig -v ${if} | grep -q TXSTART`
413 if [ $? -eq 0 ]; then
414 echo "#" >> network-statistics
415 echo "# netstat -qq -I ${if}" >> network-statistics
416 echo "#" >> network-statistics
417 /usr/sbin/netstat -qq -I ${if} >> network-statistics 2>&1
418 fi
419 `/sbin/ifconfig -v ${if} | grep -q RXPOLL`
420 if [ $? -eq 0 ]; then
421 echo "#" >> network-statistics
422 echo "# netstat -Q -I ${if}" >> network-statistics
423 echo "#" >> network-statistics
424 /usr/sbin/netstat -Q -I ${if} >> network-statistics 2>&1
425 fi
426 done
427 fi
428 fi
429
430 if [ -x /usr/sbin/ndp ]; then
431 echo "#" >> network-statistics
432 echo "# ndp -n -a" >> network-statistics
433 echo "#" >> network-statistics
434 /usr/sbin/ndp -n -a >> network-statistics 2>&1
435
436 echo "#" >> network-statistics
437 echo "# ndp -n -p" >> network-statistics
438 echo "#" >> network-statistics
439 /usr/sbin/ndp -n -p >> network-statistics 2>&1
440
441 echo "#" >> network-statistics
442 echo "# ndp -n -r" >> network-statistics
443 echo "#" >> network-statistics
444 /usr/sbin/ndp -n -r >> network-statistics 2>&1
445
446 if [ -x /sbin/ifconfig ]; then
447 for if in `/sbin/ifconfig -l`
448 do
449 echo "#" >> network-statistics
450 echo "# ndp -i ${if}" >> network-statistics
451 echo "#" >> network-statistics
452 /usr/sbin/ndp -i ${if} >> network-statistics 2>&1
453 done
454 fi
455 fi
456
457 if [ -x /sbin/pfctl ]; then
458 echo "#" > pf
459 echo "# pfctl -s all" >> pf
460 echo "#" >> pf
461 ${PRIV} /sbin/pfctl -s all >> pf 2>&1
462 echo "==============================" >> pf
463 echo "#" >> pf
464 echo "# pfctl -s References" >> pf
465 echo "#" >> pf
466 ${PRIV} /sbin/pfctl -s References >> pf 2>&1
467 for ANCHOR in `${PRIV} pfctl -s Anchors -v 2>/dev/null`
468 do
469 echo "==============================" >> pf
470 echo "#" >> pf
471 echo "# pfctl -a ${ANCHOR} -s all" >> pf
472 echo "#" >> pf
473 ${PRIV} /sbin/pfctl -a ${ANCHOR} -s all >> pf 2>&1
474 done
475 fi
476
477 #
478 # mach port info
479 #
480 if [ -x /usr/local/bin/lsmp ]; then
481 ${PRIV} /usr/local/bin/lsmp -a -v > lsmp 2>&1
482 fi
483
484 #
485 # open files
486 #
487 if [ -x /usr/sbin/lsof ]; then
488 ${PRIV} /usr/sbin/lsof -n -P -T q > lsof 2>&1
489 fi
490
491 #
492 # [lib]dispatch info
493 #
494 if [ -x /usr/local/bin/ddt ]; then
495 /bin/echo -n "" > dispatch-info
496 for BIN in \
497 configd \
498 mDNSResponder \
499
500 do
501 echo "#" >> dispatch-info
502 echo "# ddt -vkp ${BIN}" >> dispatch-info
503 echo "#" >> dispatch-info
504 ${PRIV} /usr/local/bin/ddt -vkp ${BIN} >> dispatch-info 2>&1
505 done
506 fi
507
508 #
509 # OpenDirectory info
510 #
511 if [ -x /usr/bin/odutil ]; then
512 echo "#" > od-info
513 echo "# odutil show all" >> od-info
514 echo "#" >> od-info
515 ${PRIV} /usr/bin/odutil show all >> od-info 2>&1
516 fi
517
518 #
519 # IPsec configuration
520 #
521 if [ -x /usr/sbin/setkey -a -x /usr/bin/perl ]; then
522 echo "#" > ipsec
523 echo "# setkey -D" >> ipsec
524 echo "#" >> ipsec
525 ${PRIV} /usr/sbin/setkey -D \
526 | /usr/bin/perl -M'Digest::MD5 qw(md5_hex)' -l -n -e '
527 if (/^(\s+[AE]:\s+\S+\s+)"?(.*)"?\s*$/) {
528 printf "%s[MD5:%s]%s\n", $1, md5_hex($2 . "\n"), $3;
529 } else {
530 printf "%s\n", $_;
531 }
532 ' >> ipsec
533
534 echo "" >> ipsec
535 echo "#" >> ipsec
536 echo "# setkey -Pp -D" >> ipsec
537 echo "#" >> ipsec
538 ${PRIV} /usr/sbin/setkey -Pp -D >> ipsec
539
540 for CF in /var/run/racoon/*.conf
541 do
542 if [ ! -r "${CF}" ]; then
543 continue
544 fi
545
546 echo "" >> ipsec
547 echo "#" >> ipsec
548 echo "# ${CF}" >> ipsec
549 echo "#" >> ipsec
550 ${PRIV} cat ${CF} \
551 | /usr/bin/perl -M'Digest::MD5 qw(md5_hex)' -l -n -e '
552 if (/^(\s+shared_secret\s+use\s+)"?([^\s;"]+)"?(.*)/) {
553 printf "%s[MD5:%s]%s\n", $1, md5_hex($2 . "\n"), $3;
554 } else {
555 printf "%s\n", $_;
556 }
557 ' >> ipsec
558 done
559 fi
560
561 #
562 # Kerberos configuration
563 #
564 if [ -x /usr/bin/klist ]; then
565 echo "#" > kerberos
566 echo "# klist --verbose --all-content" >> kerberos
567 echo "#" >> kerberos
568 klist --verbose --all-content >> kerberos 2>&1
569
570 echo "#" >> kerberos
571 echo "# ktutil list" >> kerberos
572 echo "#" >> kerberos
573 ${PRIV} /usr/sbin/ktutil --verbose list >> kerberos 2>&1
574
575 echo "#" >> kerberos
576 echo "# gsstool list --verbose" >> kerberos
577 echo "#" >> kerberos
578 /System/Library/PrivateFrameworks/Heimdal.framework/Helpers/gsstool list --verbose >> kerberos 2>&1
579 fi
580
581 #
582 # system profiler
583 #
584 if [ -x /usr/sbin/system_profiler ]; then
585 system_profiler -xml SPEthernetDataType \
586 SPFibreChannelDataType \
587 SPFireWireDataType \
588 SPFirewallDataType \
589 SPModemDataType \
590 SPNetworkDataType \
591 SPThunderboltDataType \
592 SPWWANDataType \
593 SPAirPortDataType > system_profiler.spx 2>/dev/null
594 fi
595
596 #
597 # system usage statistics
598 #
599 /bin/echo -n "" > system-statistics
600
601 if [ -x /usr/bin/uptime ]; then
602 echo "#" >> system-statistics
603 echo "# uptime" >> system-statistics
604 echo "#" >> system-statistics
605 /usr/bin/uptime >> system-statistics 2>&1
606 fi
607
608 if [ -x /usr/sbin/sysctl ]; then
609 echo "#" >> system-statistics
610 echo "# sysctl kern hw net debug" >> system-statistics
611 echo "#" >> system-statistics
612 /usr/sbin/sysctl kern hw net debug >> system-statistics 2>&1
613 fi
614
615 if [ -x /usr/bin/zprint ]; then
616 echo "#" >> system-statistics
617 echo "# zprint" >> system-statistics
618 echo "#" >> system-statistics
619 ${PRIV} /usr/bin/zprint >> system-statistics 2>&1
620 fi
621
622 if [ -x /usr/sbin/lsof -a -x /bin/ls ]; then
623 N=0
624 /bin/ls -1 /Library/Preferences/SystemConfiguration/*-lock \
625 2>/dev/null \
626 | while read lock
627 do
628 if [ ${N} -eq 0 ]; then
629 echo "#" >> system-statistics
630 echo "# lsof [SCPreferences lock files]" >> system-statistics
631 fi
632 N=`expr ${N} + 1`
633
634 echo "#" >> system-statistics
635 ${PRIV} /usr/sbin/lsof -- ${lock} >> system-statistics 2>&1
636 done
637 fi
638
639 #
640 # collect executable and plugin info
641 #
642 report_binary_info()
643 {
644 if [ ! -f "${1}" ]; then
645 return
646 fi
647
648 VERSION=`what "${1}"`
649 echo "${VERSION}" >> versions 2>&1
650
651 SUM=`sum "${1}"`
652 echo "\tsum: ${SUM}" >> versions 2>&1
653
654 LSINFO=`ls -lu "${1}"`
655 echo "\tadditional info: ${LSINFO}" >> versions 2>&1
656
657 echo "" >> versions 2>&1
658 }
659
660 get_binary_info()
661 {
662 for BIN in \
663 /usr/libexec/InternetSharing \
664 /usr/libexec/bootpd \
665 /usr/libexec/configd \
666 /usr/libexec/misd \
667 /usr/sbin/awacsd \
668 /usr/sbin/mDNSResponder \
669 /usr/sbin/pppd \
670 /usr/sbin/racoon \
671 /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \
672
673 do
674 report_binary_info "${BIN}"
675 done
676
677 if [ -x /usr/bin/xcode-select -a -x /usr/bin/xcodebuild -a -x /usr/bin/xcrun ]; then
678 SDKPATH="`xcode-select --print-path 2>/dev/null`"
679 if [ $? -eq 0 -a -n "${SDKPATH}" ]; then
680 /usr/bin/xcodebuild -showsdks 2>/dev/null \
681 | grep iphone \
682 | awk '{ print $NF }' \
683 | while read SDK
684 do
685 SDKPATH="`xcrun --sdk $SDK --show-sdk-path`"
686 for BIN in \
687 /usr/libexec/configd_sim \
688 /System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration \
689
690 do
691 report_binary_info "${SDKPATH}${BIN}"
692 done
693 done
694 else
695 echo "*** NO SDKs ***" >> versions
696 echo "" >> versions
697 fi
698 fi
699 }
700
701 get_plugins_info()
702 {
703 num=0
704 cd /System/Library/SystemConfiguration
705 for PLUGIN in *.bundle
706 do
707 plugins[$num]="${PLUGIN}"
708 num=$(( $num + 1 ))
709 done
710
711 cd "${WORKDIR}"
712
713 for PLUGIN in "${plugins[@]}"
714 do
715 PLUGIN_DIR="/System/Library/SystemConfiguration/${PLUGIN}"
716 PLUGIN_INF="${PLUGIN_DIR}/Contents/Info.plist"
717 if [ ! -f "${PLUGIN_INF}" ]; then
718 PLUGIN_INF="${PLUGIN_DIR}/Info.plist"
719 if [ ! -f "${PLUGIN_INF}" ]; then
720 echo "${PLUGIN_INF}: No Info.plist" >> versions 2>&1
721 fi
722 fi
723
724 echo "${PLUGIN}" >> versions 2>&1
725
726 ENABLED="Enabled"
727 BOOL=`scutil --get "${PLUGIN_INF}" / Enabled 2>/dev/null`
728 if [ $? -eq 0 ]; then
729 if [ ${BOOL} = "TRUE" ]; then
730 ENABLED="Enabled*"
731 else
732 ENABLED="Disabled"
733 fi
734 fi
735 echo "\t${ENABLED}" >> versions 2>&1
736
737 VERBOSE=""
738 BOOL=`scutil --get "${PLUGIN_INF}" / Verbose 2>/dev/null`
739 if [ $? -eq 0 ]; then
740 if [ ${BOOL} = "TRUE" ]; then
741 VERBOSE="Verbose"
742 fi
743 fi
744 if [ -n "${VERBOSE}" ]; then
745 echo "\t${VERBOSE}" >> versions 2>&1
746 fi
747
748 VERSION=`scutil --get "${PLUGIN_INF}" / CFBundleVersion 2>/dev/null`
749 if [ $? -eq 1 ]; then
750 VERSION=`scutil --get "${PLUGIN_INF}" / CFBundleShortVersionString 2>/dev/null`
751 fi
752 echo "\tVersion: ${VERSION}" >> versions 2>&1
753
754 if [ -f "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}" ]; then
755 SUM=`sum "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}"`
756 echo "\tsum: ${SUM}" >> versions 2>&1
757
758 LSINFO=`ls -lu "${PLUGIN_DIR}/Contents/MacOS/${PLUGIN%.*}"`
759 echo "\tadditional info: ${LSINFO}" >> versions 2>&1
760 elif [ -f "${PLUGIN_DIR}/${PLUGIN%.*}" ]; then
761 SUM=`sum "${PLUGIN_DIR}/${PLUGIN%.*}"`
762 echo "\tsum: ${SUM}" >> versions 2>&1
763
764 LSINFO=`ls -lu "${PLUGIN_DIR}/${PLUGIN%.*}"`
765 echo "\tadditional info: ${LSINFO}" >> versions 2>&1
766 fi
767
768 echo "" >> versions 2>&1
769 done
770 }
771
772 if [ -x /usr/bin/what -a -x /usr/bin/sum -a -x /bin/ls ]; then
773 get_binary_info
774 get_plugins_info
775 fi
776
777 #
778 # to give a chance for "networkd" and "mDNSResponder" to finish dumping their
779 # state, the last thing we do is collect the logs
780 #
781
782 #
783 # system log, kernel.log, early boot log messages
784 #
785 if [ -x /usr/bin/syslog ]; then
786 #
787 # save the recent activity
788 #
789 ${PRIV} /usr/bin/syslog -T local.3 \
790 | ${TAIL_25000} > syslog
791
792 #
793 # save just the "kernel" activity (in case some of the
794 # interesting/relevant message are before the messages
795 # captured above.
796 #
797 ${PRIV} /usr/bin/syslog -T local.3 -k Facility kern \
798 | ${TAIL_25000} > kernel
799
800 if [ -d /var/log/DiagnosticMessages ]; then
801 # save any MessageTracer activity
802 ${PRIV} /usr/bin/syslog -d /var/log/DiagnosticMessages \
803 -F raw \
804 -T local.3 \
805 | ${TAIL_25000} > DiagnosticMessages
806 fi
807 else
808 if [ -f /var/log/system.log ]; then
809 ${PRIV} ${TAIL_25000} /var/log/system.log > system.log
810 fi
811 if [ -f /var/log/kernel.log ]; then
812 ${PRIV} ${TAIL_25000} /var/log/kernel.log > kernel.log
813 fi
814 fi
815 if [ -x /sbin/dmesg ]; then
816 ${PRIV} /sbin/dmesg > dmesg
817 fi
818
819 #
820 # IPConfiguration log
821 #
822 if [ -f /var/log/com.apple.IPConfiguration.bootp ]; then
823 ${PRIV} ${TAIL_2000} /var/log/com.apple.IPConfiguration.bootp \
824 > com.apple.IPConfiguration.bootp
825 fi
826
827 #
828 # ppp log file(s)
829 #
830 scutil <<_END_OF_INPUT \
831 | awk -F' *: *' \
832 ' \
833 /Logfile : / { \
834 if (index($2, "/") == 1) { print $2 } \
835 else { print "/var/log/ppp/" $2 } \
836 } \
837 END { \
838 print "/tmp/pppotcp.log" \
839 } \
840 ' \
841 | sort -u \
842 | while read logFile
843 open
844 show Setup:/Network/Service/[^/]+/PPP pattern
845 quit
846 _END_OF_INPUT
847 do
848 if [ -f "${logFile}" ]; then
849 b="`basename ${logFile}`"
850 cat "${logFile}" > "${b}" 2>&1
851 fi
852 done
853
854 #
855 # application firewall log
856 #
857 if [ -f /var/log/appfirewall.log ]; then
858 ${PRIV} ${TAIL_2000} /var/log/appfirewall.log > appfirewall.log
859 fi
860
861 if [ -x /bin/ls ]; then
862 #
863 # collect crash reports
864 #
865 for daemon in \
866 InternetSharing \
867 SCHelper \
868 SCMonitor \
869 awacsd \
870 bootpd \
871 configd \
872 eapolclient \
873 mDNSResponder \
874 mDNSResponderHelper \
875 pppd \
876 racoon \
877 socketfilterfw \
878
879 do
880 /bin/ls -1 /Library/Logs/DiagnosticReports/${daemon}_*.crash \
881 /Library/Logs/DiagnosticReports/${daemon}_*.ips \
882 /Library/Logs/CrashReporter/${daemon}_*.crash \
883 /Library/Logs/CrashReporter/${daemon}_*.ips \
884 /Library/Logs/CrashReporter/${daemon}_*.plist \
885 2>/dev/null \
886 | while read log
887 do
888 if [ -f "${log}" ]; then
889 b="`basename ${log}`"
890 ${PRIV} cat "${log}" > "${b}" 2>&1
891 fi
892 done
893 done
894
895 #
896 # collect any verbose logging output
897 #
898 /bin/ls -1 /Library/Logs/CrashReporter/com.apple.networking.*.log* \
899 2>/dev/null \
900 | while read log
901 do
902 if [ -f "${log}" ]; then
903 b="`basename ${log}`"
904 ${PRIV} cat "${log}" > "${b}" 2>&1
905 fi
906 done
907 fi
908
909 #
910 # stackshot
911 #
912 if [ -x /usr/local/bin/crstackshot ]; then
913 /usr/local/bin/crstackshot 2>/dev/null
914 fi
915
916 #
917 # collect everything into a single archive
918 #
919 cd "${WORKDIR}/.."
920 tar -c ${GZ_OPT} -f "${ARCHIVE}" "${OUT}"
921 rm -rf "${WORKDIR}"
922
923 if [ ${UID} -eq 0 ]; then
924 if [ -n "${SUDO_UID}" -a -n "${SUDO_GID}" ]; then
925 if [ ${UID} -ne ${SUDO_UID} ]; then
926 chown ${SUDO_UID}:${SUDO_GID} "${ARCHIVE}"
927 fi
928 fi
929 fi
930
931 echo "Network data collected to \"${ARCHIVE}\""
932