Uploaded image for project: 'OpenShift Bugs'
  1. OpenShift Bugs
  2. OCPBUGS-10235

[OVN] baremetal 30-static-dhcpv6 shell quoting error: binary operator expected

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done-Errata
    • Icon: Normal Normal
    • 4.14
    • 4.10, 4.14
    • None
    • Low
    • No
    • SDN Sprint 235, SDN Sprint 236, SDN Sprint 237, SDN Sprint 238
    • 4
    • Rejected
    • False
    • Hide

      None

      Show
      None

      Description of problem:

      I found an old shell error while checking logs. We don't quote a variable with [ -z ].

          if [ -z $DHCP6_IP6_ADDRESS ]
          then
              >&2 echo "Not a DHCP6 address. Ignoring."
              exit 0
          fi
      

      https://github.com/openshift/machine-config-operator/blob/master/templates/common/baremetal/files/NetworkManager-static-dhcpv6.yaml#L8

      
      Dec 05 12:05:02 master-0-2 nm-dispatcher[1365]: time="2022-12-05T12:05:02Z" level=debug msg="Ignoring filtered route {Ifindex: 10 Dst: fd2e:6f44:5dd8::59/128 Src: <nil> Gw: <nil> Flags: [] Table: 254}"
      Dec 05 12:05:02 master-0-2 nm-dispatcher[1365]: time="2022-12-05T12:05:02Z" level=debug msg="Ignoring filtered route {Ifindex: 10 Dst: fd2e:6f44:5dd8::5a/128 Src: <nil> Gw: <nil> Flags: [] Table: 254}"
      
      Dec 05 12:05:27 master-0-2 nm-dispatcher[1365]: req:19 'up' [br-ex], "/etc/NetworkManager/dispatcher.d/30-static-dhcpv6": run script
      Dec 05 12:05:27 master-0-2 nm-dispatcher[1365]: + '[' -z fd2e:6f44:5dd8::5a fd2e:6f44:5dd8::59 ']'
      Dec 05 12:05:27 master-0-2 nm-dispatcher[1365]: /etc/NetworkManager/dispatcher.d/30-static-dhcpv6: line 4: [: fd2e:6f44:5dd8::5a: binary operator expected
      Dec 05 12:05:27 master-0-2 nm-dispatcher[1365]: ++ ip -j -6 a show br-ex
      Dec 05 12:05:27 master-0-2 nm-dispatcher[1365]: ++ jq -r '.[].addr_info[] | select(.scope=="global") | select(.deprecated!=true) | select(.local=="fd2e:6f44:5dd8::5a fd2e:6f44:5dd8::59") | .preferred_life_time'
      Dec 05 12:05:27 master-0-2 nm-dispatcher[1365]: + LEASE_TIME=
      Dec 05 12:05:27 master-0-2 nm-dispatcher[1365]: ++ ip -j -6 a show br-ex
      Dec 05 12:05:27 master-0-2 nm-dispatcher[1365]: ++ jq -r '.[].addr_info[] | select(.scope=="global") | select(.deprecated!=true) | select(.local=="fd2e:6f44:5dd8::5a fd2e:6f44:5dd8::59") | .prefixlen'
      Dec 05 12:05:27 master-0-2 nm-dispatcher[1365]: + PREFIX_LEN=
      Dec 05 12:05:27 master-0-2 nm-dispatcher[1365]: + '[' 0 -lt 4294967295 ']'
      Dec 05 12:05:27 master-0-2 nm-dispatcher[1365]: + echo 'Not an infinite DHCP6 lease. Ignoring.'
      Dec 05 12:05:27 master-0-2 nm-dispatcher[1365]: Not an infinite DHCP6 lease. Ignoring.
      Dec 05 12:05:27 master-0-2 nm-dispatcher[1365]: + exit 0
      Dec 05 12:05:27 master-0-2 nm-dispatcher[1365]: req:19 'up' [
      
      
      
      
      

      Version-Release number of selected component (if applicable):

      4.10.0-0.nightly-2022-11-30-111136
      

      How reproducible:

      Twice

      Steps to Reproduce:

      1. Somehow DHCPv6 provides two IPv6 leases
      2. NetworkManager sets $DHCP6_IP6_ADDRESS to be all IPv6 address with spaces in-between
      3. Bash error
      

      Actual results:

      
      /etc/NetworkManager/dispatcher.d/30-static-dhcpv6: line 4: [: fd2e:6f44:5dd8::5a: binary operator expected
      

      Expected results:

      shell inputs are sanitized or properly quoted.

      Additional info:

              bpickard@redhat.com Ben Pickard
              rbrattai@redhat.com Ross Brattain
              Ross Brattain Ross Brattain
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: