-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconnectivity
executable file
·110 lines (95 loc) · 2.06 KB
/
connectivity
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/dash
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
. /usr/lib/connectivity-common.sh
OCF=org.chromium.flimflam
MASKED_PROPERTIES="
Address
Cellular.ESN
Cellular.ICCID
Cellular.IMEI
Cellular.IMSI
Cellular.MDN
Cellular.MEID
Cellular.MIN
Cellular.UsageUrl
EAP.AnonymousIdentity
EAP.CACertID
EAP.CACertNSS
EAP.CertID
EAP.EAP
EAP.Identity
EAP.InnerEAP
EAP.KeyID
EAP.PIN
EAP.SubjectMatch
Name
WiFi.BSSID
WiFi.HexSSID
WiFi.SSID
"
MASKED_PROPERTIES_PATTERN=$(echo ${MASKED_PROPERTIES} | sed 's/ /|/g')
mask_properties() {
sed -E "s/\<(${MASKED_PROPERTIES_PATTERN}): (.+)/\1: *** MASKED ***/i"
}
# Returns a list of flimflam objects of the specified kind.
get_flimflam_objects() {
# NB: add s to pluralize kind
local kind="${1}s"
local filter="$2"
dbus_call "${OCF}" / "${OCF}.Manager.GetProperties" \
| extract_dbus_match "${kind}" \
| grep "${filter}"
}
print_properties() {
local kind="$1"
local object="$2"
dbus_call "${OCF}" "${object}" "${OCF}.${kind}.GetProperties" | stripindexes
}
normalize_kind() {
local kind="${1%s}" # Remove trailing s
case "${kind}" in
[Ss]ervice)
echo -n Service
;;
[Dd]evice)
echo -n Device
;;
*)
error_exit "Did not understand connection manager entity ${kind}."
;;
esac
}
show() {
$(needarg raw_kind)
$(arg_or_default filter .)
local kind=$(normalize_kind "${raw_kind}")
local objects="$(get_flimflam_objects ${kind} ${filter})"
for object in ${objects}; do
echo "${object}"
print_properties "${kind}" "${object}"
echo
done
}
usage() {
cat <<EOF
Usage: $0 <command> [args...]
show {Devices|Services} [-filter regex]
Show these objects and their properties: If a filter is supplied,
use it to filter object names.
EOF
exit
}
$(needarg cmd)
case "$cmd" in
show)
show "$@"
;;
show-feedback)
show "$@" | mask_properties
;;
*)
usage
;;
esac