From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: network@lists.ipfire.org Subject: Re: [PATCH] Fix parsing of hids and ids Date: Tue, 06 Feb 2018 00:57:14 +0000 Message-ID: <1517878634.21272.70.camel@ipfire.org> In-Reply-To: <1517153148-6844-1-git-send-email-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6344376789918761101==" List-Id: --===============6344376789918761101== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi, I think this patch confuses a few things that we should not confuse. HID =3D Human IDs - readable by a human - that's it; and IDs which are readab= le by a machine and easier to handle - therefore faster code On Sun, 2018-01-28 at 15:25 +0000, Jonatan Schlag wrote: > If we get an id insted of a hid we failed beacuse > we passed the wrong variable. >=20 > I also added some more comments. >=20 > Fixes: #11453 >=20 > Signed-off-by: Jonatan Schlag > --- > src/functions/functions.zone | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) >=20 > diff --git a/src/functions/functions.zone b/src/functions/functions.zone > index f724f50..2d3d2c7 100644 > --- a/src/functions/functions.zone > +++ b/src/functions/functions.zone > @@ -527,7 +527,8 @@ zone_config() { > zone_config_list "${zone}" "$@" > ;; > *) > - # usually ${1} is a valid hid > + # usually ${cmd} is valid hid > + # We get ${hid} ${cmd} $@ from the cli > local hid=3D${cmd} > local cmd=3D${1} > shift 1 > @@ -538,11 +539,11 @@ zone_config() { > if isset id && [[ ${cmd} =3D=3D "edit" ]]; then > zone_config_edit "${zone}" "${id}" "$@" > =20 > - # If we didn't get a valid hid we check if we got a > valid id > + # If we didn't get a valid hid we check if we got a > valid id (saved in ${hid}) > else > - if zone_config_id_is_valid ${zone} ${id} && > [[ ${cmd} =3D=3D "edit" ]]; then > + if zone_config_id_is_valid ${zone} ${hid} && > [[ ${cmd} =3D=3D "edit" ]]; then The function zone_config_id_is_valid should never take a HID. If it does its name is wrong. > shift 1 > - zone_config_edit "${zone}" "${id}" > "$@" > + zone_config_edit "${zone}" "${hid}" > "$@" The internal functions should never handle HIDs. > else > # in ${hid} is saved the command > after network zone ${zone} config > error "Unrecognized argument: ${hid}" > @@ -1171,6 +1172,8 @@ zone_config_id_is_valid() { > local zone=3D${1} > local id=3D${2} > =20 > + log DEBUG "Checking if id: ${id} is valid for zone: ${zone}" > + > local zone_path=3D"${NETWORK_ZONES_DIR}/${zone}" > =20 > [ -f ${zone_path}/configs/*.${id} ]; -Michael --===============6344376789918761101== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSXpCQUFCQ2dBZEZpRUU1L3JXNWwzR0dl Mnlwa3R4Z0hudy8yK1FDUWNGQWxwNC9Xb0FDZ2tRZ0hudy8yK1EKQ1FmYmhnLytMNmVBckxmNU05 M3NkcllOQnpaMWwwellYYXlzRmJUNVpPOVRUdjUycStpN0UzUUN0SS9ROVk0UApMT1EwYmNmU0hJ VmVqTDd6VHU2K1lha0Q1OGFGZU5maTVYR1FNNWkzRFdrQkxIOVNXZCtVMC9BaHppMlZlZ1h0Ci9T d2hZdXU2Tjhhdm5ROW5TTVVHbjArNnRBc0pxTlRlTHRobmhSUkQ0ZjhpcUh4TDBUazRKK3FtTlM5 NUVOWXIKNEh1WUxKT2Z4bnNaMFNjSDBVQ1ZtM0hWZm5sbFh5dVVlUU0rV0dIREFtY3hqejlmQ2RU anZNRWQ4cGowb0trWQpYNXZXbDg2WklXL1RPTlg3aDltcW5seVh6VGwvSUZzRzVaQ3ZaRHRUZFpU bkEvUEJhVDNUTHM0SUxudHpaeFMzCnRrK3QvTVd2VFRlalIxS0pnZUZ6aEcwaU92TjlQQTU0NlZo amQwM0hKbGJiUUFKWFhYaHl1QjNmQ3M4Q3p4RFoKVk9sR2JIR3FrRE1XMG1lWHo3WGZqWlh2dDlZ YXZLTlRtZ2pGY3Vjby9EL2pZNWdwUTVjV2tVaG9aald2a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