diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-04-02 12:57:30 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-04-02 19:34:30 +0200 |
commit | b4fdcebebecd8d8952211b78bce26d53fd29edb3 (patch) | |
tree | ce9c41857b2ea8ae6e17c5f9334e7b7f1f004b05 /scripts/build-command-op-templates | |
parent | 99440fc005d734d602fb9cd5b546e320c9b1e19b (diff) | |
download | vyos-1x-b4fdcebebecd8d8952211b78bce26d53fd29edb3.tar.gz vyos-1x-b4fdcebebecd8d8952211b78bce26d53fd29edb3.zip |
T3165: prevent override of populated node.def file with empty content
Diffstat (limited to 'scripts/build-command-op-templates')
-rwxr-xr-x | scripts/build-command-op-templates | 7 |
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("*") |