File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,22 @@ export PATH="${toplevel}${PATH:+:${PATH}}"
44
44
unset toplevel
45
45
46
46
function busctl {
47
+ # Short-circuit if we got "busctl status <...>". If TEST_BUSCTL_STATUS_RC is
48
+ # unset or empty, assume this is the call from the "main" function in
49
+ # update-systemd-resolved, rather than an automated test checking the
50
+ # behaviour of "busctl status <...>".
51
+ case " ${1:- } " in
52
+ status)
53
+ if [[ -n " ${TEST_BUSCTL_STATUS_RC:- } " ]]; then
54
+ busctl_called=1
55
+ _log " busctl status: returning ${TEST_BUSCTL_STATUS_RC} "
56
+ return " $TEST_BUSCTL_STATUS_RC "
57
+ else
58
+ return 0
59
+ fi
60
+ ;;
61
+ esac
62
+
47
63
shift 4
48
64
_log " busctl called with: ${@ } "
49
65
# Set that busctl has been called
@@ -216,6 +232,7 @@ evaltest() {
216
232
TEST_BUSCTL_DNS=" "
217
233
TEST_BUSCTL_DOMAINS=" "
218
234
TEST_BUSCTL_DNSSEC=" "
235
+ TEST_BUSCTL_STATUS_RC=" "
219
236
# Keep this random, as we will never know the ifindex up-front
220
237
ip_ifindex=$(( RANDOM%= 64 ))
221
238
# Clear foreign_option_*
Original file line number Diff line number Diff line change
1
+ script_type=" up"
2
+ dev=" tun23"
3
+
4
+ TEST_TITLE=' Error if "busctl status org.freedesktop.resolve1" fails'
5
+ TEST_BUSCTL_CALLED=1
6
+
7
+ # Mocked-up busctl function will return exit code 1 upon "busctl status <...>"
8
+ TEST_BUSCTL_STATUS_RC=1
9
+ EXPECT_FAILURE=1
Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ usage() {
44
44
err " ${1:? ${1} . } . Usage: ${SCRIPT_NAME} up|down|print-polkit-rules [<options>]."
45
45
}
46
46
47
+ busctl_status () {
48
+ busctl status " $DBUS_DEST "
49
+ }
50
+
47
51
busctl_call () {
48
52
# Preserve busctl's exit status
49
53
busctl call " $DBUS_DEST " " $DBUS_NODE " " ${DBUS_DEST} .Manager" " $@ " || {
@@ -252,6 +256,15 @@ with_openvpn_script_handling() {
252
256
return 1
253
257
fi
254
258
259
+ busctl_status & > /dev/null || {
260
+ local -i status=" $? "
261
+ err << ERR
262
+ systemd-resolved DBus interface (${DBUS_DEST} ) is not available.
263
+ $SCRIPT_NAME requires systemd version 229 or above.
264
+ ERR
265
+ return " $status "
266
+ }
267
+
255
268
if ! " $func " " $link " " $if_index " " $@ " ; then
256
269
err ' Unable to configure systemd-resolved.'
257
270
print_polkit_rules_command_for_current_user | err
You can’t perform that action at this time.
0 commit comments