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