commit:     e6db37173cb70183ee983aa1aaa5224a2f8c49c3
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu Jan 19 04:47:54 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jan 19 18:49:22 2023 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=e6db3717

net/l2tp.sh: Don't try to evaluate l2tptunnel_${IFVAR} if unset

The "restructuring" commit went one step too far by combining the test for
whether l2tptunnel_${IFVAR} is defined with the test for whether the tunnel
exists, in a way that adversely affects the outer control flow. Fix it by
nesting the latter test.

Fixes: 0b8b9b13146c1eba04f2bd8d0b2b049c03891010
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 net/l2tp.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/l2tp.sh b/net/l2tp.sh
index aa8e3fd..dde86af 100644
--- a/net/l2tp.sh
+++ b/net/l2tp.sh
@@ -28,12 +28,14 @@ l2tp_pre_start() {
                eend 1 "${key} defines a \"name\" parameter, which is forbidden 
by netifrc"
        elif ! modprobe l2tp_eth; then
                eend 1 "Couldn't load the l2tp_eth module (perhaps the 
CONFIG_L2TP_ETH kernel option is disabled)"
-       elif key="l2tptunnel_${IFVAR}"; ! eval "[ \${${key}+set} ]" && ! 
_l2tp_has_tunnel "${tunnel_id}"; then
+       elif key="l2tptunnel_${IFVAR}"; ! eval "[ \${${key}+set} ]"; then
                # A tunnel may incorporate more than one session (link). This
                # module allows for the user not to define a tunnel for a given
                # session. In that case, it will be expected that the required
                # tunnel has already been created to satisfy some other session.
-               eend 1 "Tunnel #${tunnel_id} not found (defining ${key} may be 
required)"
+               if ! _l2tp_has_tunnel "${tunnel_id}"; then
+                       eend 1 "Tunnel #${tunnel_id} not found (defining ${key} 
may be required)"
+               fi
        elif eval "l2tptunnel=\$${key}"; _is_blank "${l2tptunnel}"; then
                eend 1 "${key} is defined but its value is blank"
        elif ! declared_tunnel=$(_l2tp_parse_opts "${l2tptunnel}" "local 
peer_tunnel_id remote tunnel_id" "encap"); then

Reply via email to