1#!/bin/sh
2# Copyright (c) 2004-2013 Apple Inc.
3#
4# get-mobility-info
5#
6# Collect system & network configuration information.
7#
8
9PATH=/bin:/usr/bin:/sbin:/usr/sbin
10
11#
12# Disclaimer
13#
14cat <<_END_OF_DISCLAIMER
15
16This diagnostic tool generates files that allow Apple to investigate issues
17with your computer and help Apple to improve its products. The generated files
18may contain some of your personal information, which may include, but not be
19limited to, the serial number or similar unique number for your device, your
20user name, or your computer name. The information is used by Apple in
21accordance with its privacy policy (www.apple.com/privacy) and is not shared
22with any third party. By enabling this diagnostic tool and sending a copy of
23the generated files to Apple, you are consenting to Apple���s use of the content
24of such files.
25
26_END_OF_DISCLAIMER
27
28/bin/echo "Press 'Enter' to continue."
29read reply
30
31#
32# Setup
33#
34PRIV=""
35if [ ${EUID} -ne 0 ]; then
36	PRIV="sudo"
37fi
38
39if [ -x /usr/bin/tail ]; then
40	TAIL_2000="/usr/bin/tail -n 2000"
41	TAIL_25000="/usr/bin/tail -n 25000"
42else
43	TAIL_2000="/bin/cat"
44	TAIL_25000="/bin/cat"
45fi
46
47OUT="mobility-info-`date +'%m.%d.%Y.%H%M%S'`"
48OUTDIR="/var/tmp"
49if [ -d ~/Desktop ]; then
50	OUTDIR=~/Desktop
51elif [ "`readlink /tmp`" = "private/var/tmp" ]; then
52	OUTDIR=/Library/Logs/CrashReporter
53	mkdir -p ${OUTDIR}
54fi
55
56umask 077
57
58WORKDIR=`mktemp -d -q "/tmp/${OUT}"`
59if [ $? -ne 0 ]; then
60	echo "Could not create snapshot directory"
61	exit 1
62fi
63
64GZ_EXT=""
65GZ_OPT=""
66if [ -x /usr/bin/gzip ]; then
67	GZ_EXT=".gz"
68	GZ_OPT="-z"
69fi
70
71ARCHIVE=`mktemp -q "${OUTDIR}/${OUT}.tar${GZ_EXT}"`
72if [ $? -ne 0 ]; then
73	echo "Could not create snapshot archive"
74	rm -rf "${WORKDIR}"
75	exit 1
76fi
77
78cd "${WORKDIR}"
79
80echo ""
81echo "Please wait, collecting information and statistics"
82echo ""
83
84#
85# Execute network reachability/DNS commands early as "mDNSResponder" will block while
86# logging its "state" info.
87#
88scutil -d -v -r www.apple.com "" no-server		> reachability-info	2>&1
89if [ -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
91fi
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#
98if [ -x /usr/bin/killall ]; then
99	${PRIV} /usr/bin/killall -INFO networkd
100	${PRIV} /usr/bin/killall -INFO mDNSResponder
101	sleep 1
102fi
103
104#
105# processes
106#
107if [ -x /bin/ps ]; then
108	/bin/ps axlww					> ps			2>&1
109fi
110
111#
112# network interface configuration
113#
114if [ -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
119fi
120
121#
122# network route configuration
123#
124if [ -x /usr/sbin/netstat ]; then
125	/usr/sbin/netstat -n -r -a -l			> netstat		2>&1
126fi
127
128#
129# DHCP configuration
130#
131if [ -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
140fi
141
142#
143# AirPort info
144#
145if [ -x /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport ]; then
146	/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport --getinfo	\
147							> airport		2>&1
148fi
149
150#
151# collect wifi dump
152#
153if [ -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
164fi
165
166#
167# OS info
168#
169if [ -e /System/Library/CoreServices/SystemVersion.plist ]; then
170	cat /System/Library/CoreServices/SystemVersion.plist	\
171							> SystemVersion.plist	2>&1
172fi
173if [ -e /System/Library/CoreServices/ServerVersion.plist ]; then
174	cat /System/Library/CoreServices/ServerVersion.plist	\
175							> ServerVersion.plist	2>&1
176fi
177
178#
179# IOKit info
180#
181if [ -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
184fi
185
186#
187# Power Management info
188#
189if [ -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
194fi
195
196#
197# Host name
198#
199if [ -x /bin/hostname ]; then
200	/bin/hostname					> hostname		2>&1
201fi
202
203#
204# Host configuration
205#
206if [ -x /usr/bin/hostinfo ]; then
207	/usr/bin/hostinfo				> hostinfo		2>&1
208fi
209if [ -e /etc/hostconfig ]; then
210	cat /etc/hostconfig				> etc.hostconfig	2>&1
211fi
212
213#
214# DNS configuration
215#
216scutil --dns						> dns-configuration	2>&1
217if [ -e /etc/resolv.conf ]; then
218	cat /etc/resolv.conf				> etc.resolv.conf	2>&1
219fi
220if [ -e /var/run/resolv.conf ]; then
221	cat /var/run/resolv.conf			> var.run.resolv.conf	2>&1
222fi
223if [ -e /etc/resolver ]; then
224	tar -c -H /etc/resolver				> etc.resolver.tar	2>/dev/null
225fi
226
227#
228# Proxy configuration
229#
230scutil -d -v --proxy					> proxy-configuration	2>&1
231
232#
233# Network information
234#
235if [ -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
248fi
249
250#
251# System / network preferences
252#
253for 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
265do
266	if [ -e "${f}" ]; then
267		b="`basename ${f}`"
268		cat "${f}"				> "${b}"		2>&1
269	fi
270done
271
272#
273# System / network preferences (from other volumes)
274#
275mount											\
276| awk 'BEGIN { FS= "[/ \t]+" } /^\/dev\/disk.* on \/Volumes\// { print $6 }'		\
277| while read volume
278do
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
291done
292
293#
294# InternetSharing
295#
296if   [ -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
299elif [ -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
302fi
303
304#
305# configd's cache
306#
307${PRIV} scutil -p --snapshot
308if [ -f /var/tmp/configd-store.plist ]; then
309	cat /var/tmp/configd-store.plist		> configd-store.plist	2>&1
310fi
311if [ -f /var/tmp/configd-pattern.plist ]; then
312	cat /var/tmp/configd-pattern.plist		> configd-pattern.plist	2>&1
313fi
314if [ -f /var/tmp/configd-session.plist ]; then
315	cat /var/tmp/configd-session.plist		> configd-session.plist	2>&1
316fi
317if [ -f /var/tmp/configd-state ]; then
318	cat /var/tmp/configd-state			> configd-state		2>&1
319fi
320if [ -f /var/tmp/configd-reachability ]; then
321	cat /var/tmp/configd-reachability		> configd-reachability		2>&1
322fi
323
324#
325# mounted filesystems
326#
327mount							> mounted-filesystems	2>&1
328
329${PRIV} cat /etc/hosts 					> etc.hosts		2>/dev/null
330
331#
332# kernel extensions statistic
333#
334if   [ -x /usr/sbin/kextstat ]; then
335	/usr/sbin/kextstat				> kextstat		2>&1
336elif [ -x /usr/sbin/kmodstat ]; then
337	/usr/sbin/kmodstat				> kmodstat		2>&1
338fi
339
340#
341# network statistics
342#
343echo -n ""							>  network-statistics
344
345if   [ -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
350fi
351
352if [ -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
412fi
413
414if [ -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
439fi
440
441if [ -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
446fi
447
448if [ -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
453fi
454
455if [ -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
473fi
474
475if [ -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
480fi
481
482#
483# DirectoryService info
484#
485if [ -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
490elif [ -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
505fi
506
507#
508# IPsec configuration
509#
510if [ -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
548fi
549
550#
551# Kerberos configuration
552#
553if [ -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
568fi
569
570#
571# system profiler
572#
573if [ -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
583fi
584
585#
586# system usage statistics
587#
588echo -n ""						> system-statistics
589
590if [ -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
595fi
596
597if [ -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
602fi
603
604if [ -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
609fi
610
611#
612# collect executable and plugin info
613#
614report_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
632get_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
667get_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
738if [ -x /usr/bin/what -a -x /usr/bin/sum -a -x /bin/ls ]; then
739	get_binary_info
740	get_plugins_info
741fi
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#
751if [ -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
767else
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
774fi
775if [ -x /sbin/dmesg ]; then
776	${PRIV} /sbin/dmesg						> dmesg
777fi
778
779#
780# IPConfiguration log
781#
782if [ -f /var/log/com.apple.IPConfiguration.bootp ]; then
783	${PRIV} ${TAIL_2000} /var/log/com.apple.IPConfiguration.bootp	\
784							> com.apple.IPConfiguration.bootp
785fi
786
787#
788# ppp log file(s)
789#
790scutil <<_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
803open
804show Setup:/Network/Service/[^/]+/PPP pattern
805quit
806_END_OF_INPUT
807do
808	if [ -f "${logFile}" ]; then
809		b="`basename ${logFile}`"
810		cat "${logFile}"			> "${b}"		2>&1
811	fi
812done
813
814#
815# application firewall log
816#
817if [ -f /var/log/appfirewall.log ]; then
818	${PRIV} ${TAIL_2000} /var/log/appfirewall.log	> appfirewall.log
819fi
820
821if [ -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
865fi
866
867
868#
869# collect everything into a single archive
870#
871cd "${WORKDIR}/.."
872tar -c ${GZ_OPT} -f "${ARCHIVE}" "${OUT}"
873rm -rf "${WORKDIR}"
874
875if [ ${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
881fi
882
883echo "Network data collected to \"${ARCHIVE}\""
884
885