Skip to content

Right some wrongs with copy#1213

Merged
troglobit merged 3 commits intomainfrom
copyright
Oct 31, 2025
Merged

Right some wrongs with copy#1213
troglobit merged 3 commits intomainfrom
copyright

Conversation

@wkz
Copy link
Contributor

@wkz wkz commented Oct 29, 2025

Description

Refactor copy to make it easier to follow. NACM should now also actually be applied, before this PR, sr_nacm_set_user() was called without first calling sr_nacm_init(), but this was not detected as the return code was not checked. Also plug some Bobby Droptables vectors by invoking curl without shell expansion.

I also added a small test script to test the most common use-cases. Its execution is not automated, but then again we do not muck about in this code that often. Please have a look if there are any glaring holes in that. I would also appreciate some free testing to make sure I have not missed anything major.

Checklist

  • Bugfix
    • Regression tests
    • ChangeLog updates (for next release)
  • Feature
    • YANG model change => revision updated?
    • Regression tests added?
    • ChangeLog updates (for next release)
    • Documentation added?
  • Test changes
    • Checked in changed Readme.adoc (make test-spec)
    • Added new test to group Readme.adoc and yaml file
  • Code style update (formatting, renaming)
  • Refactoring (please detail in commit messages)
  • Build related changes
  • Documentation content changes
    • ChangeLog updated (for major changes)
  • Other (please describe):

wkz added 3 commits October 29, 2025 16:35
Add a simple script that verifies all the common use-cases of copy.
copy() made some...creative...use of control flow that made it quite
difficult to follow.

Take a first priciples approach to simplify the logic.
This will make sure to apply NACM rules for all the data. It also
makes it possible for a luser access a subset of the data, even if
they to do not have read access to /cfg/startup-config.cfg.
@wkz wkz requested review from mattiaswal and troglobit October 29, 2025 15:44
Copy link
Contributor

@troglobit troglobit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work cleaning this up, and thank you for taking the time! 🙇

Only minor thing I found, that's a regression from my version, is this:

admin@ix-00-00-00:~$ copy operational-state fozza
admin@ix-00-00-00:~$ ll
total 20
drwxr-sr-x    3 admin    admin         4096 Oct 31 09:59 ./
drwxr-xr-x    1 root     root          4096 Oct 28 18:19 ../
-rw-r--r--    1 admin    admin          183 Oct 31 09:55 .klish_history
-rw-------    1 admin    admin           20 Oct 31 09:59 .lesshst
drwxr-s---    2 root     admin         4096 Oct 31 08:23 .ssh/
admin@ix-00-00-00:~$ copy operational-state fozza.cfg
Overwrite existing file /cfg//fozza.cfg (y/N)? 

But if I give an absolute path it works. This is not important enough to block this PR.

@troglobit troglobit merged commit eb829af into main Oct 31, 2025
6 of 7 checks passed
@troglobit troglobit deleted the copyright branch October 31, 2025 11:44
@troglobit troglobit mentioned this pull request Dec 18, 2025
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants