summaryrefslogtreecommitdiff
path: root/scripts/build-command-op-templates
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-04-02 12:57:30 +0200
committerChristian Poessinger <christian@poessinger.com>2021-06-08 07:54:32 +0200
commitbca6af49ffe39d6c01b3925c7b93b39cecaa2d25 (patch)
treeb401c5959530ae10341abd7985b5320b3f7f7b41 /scripts/build-command-op-templates
parent6289ee5ac3e7c2392cdefe5df4b7b4b1c69e93d7 (diff)
downloadvyos-1x-bca6af49ffe39d6c01b3925c7b93b39cecaa2d25.tar.gz
vyos-1x-bca6af49ffe39d6c01b3925c7b93b39cecaa2d25.zip
T3165: prevent override of populated node.def file with empty content
(cherry picked from commit b4fdcebebecd8d8952211b78bce26d53fd29edb3)
Diffstat (limited to 'scripts/build-command-op-templates')
-rwxr-xr-xscripts/build-command-op-templates7
1 files changed, 3 insertions, 4 deletions
diff --git a/scripts/build-command-op-templates b/scripts/build-command-op-templates
index c60b32a1e..c285ee594 100755
--- a/scripts/build-command-op-templates
+++ b/scripts/build-command-op-templates
@@ -170,12 +170,11 @@ def process_node(n, tmpl_dir):
print("Processing node {}".format(name))
nodedef_path = os.path.join(make_path(my_tmpl_dir), "node.def")
- if not os.path.exists(nodedef_path):
+ # Only create the "node.def" file if it exists but is empty, or if it
+ # does not exist at all.
+ if not os.path.exists(nodedef_path) or os.path.getsize(nodedef_path) == 0:
with open(nodedef_path, "w") as f:
f.write(make_node_def(props, command))
- else:
- # Something has already generated this file
- pass
if children is not None:
inner_nodes = children.iterfind("*")