Joachim Wiberg 5ea99680c8 bin: backport fixes to shell/cli copy command
This is a backport of the following commits from origin/main: 3b24fab
e6a04fb 92e80b4 ad96965 3e03ece 21256a8 b7d91e4 d26e311 0977ab4 f83fbc6

---

cli: fix 'copy FILE running-config' use-case

When copying to the running datastore we cannot use sr_copy_config(),
instead we must use sr_replace_config().  This fix covers both the case
of 'copy startup-config running-config' and 'copy FILE running-config'.

Fixes #1203

---

cli: add 'validate', or '-n', dry run to copy command

This commit adds config file validation to the copy command, discussed
in #373.  Allowing users to test their config files before restoring a
backup.  The feature could also be used for the automatic rollback when
downgrading to an earlier version of the OS.

Fixes #373

---

cli: fix copy to missing startup-config file

Fixes #981

---

cli: restrict copy and erase commands

This is a follow-up to PR #717 where path traversal protection was
discussed.  A year later and it's clear that having a user-friendly
copy tool in the shell is a good thing, but that we proably want to
restrict what it can do when called from the CLI.

A sanitize flag (-s) is added to control the behavior, when used in the
shell without -s, both commands act like traditional UNIX tools and do
assume . for relative paths, and allow ../, whereas when running from
the CLI only /media/ is allowed and otherwise files are assumed to be
in $HOME or /cfg

---

cli: sanitize regular file to file copy

The regular file-to-file copy, was missing calls to cfg_adjust(), this
commit fixes that and adds some helpful comments for each use-case.

Also, drop insecure mktemp() in favor of our own version which uses the
basename of the remote source file.

---

bin: add bash completion for copy command

Add bash completion for the common datastores, like we already do in the
CLI, and update the usage text accordingly.

Also, make sure to install to /usr/bin, not /bin since we've now merged
the hierarchies since a while back.

---

bin: copy: Refactor

copy() made some...creative...use of control flow that made it quite
difficult to follow.

Take a first priciples approach to simplify the logic.

---

bin: copy: Always get startup from sysrepo

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.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2025-12-18 14:12:00 +01:00
2022-12-05 21:09:05 +01:00
2025-09-01 12:25:54 +02:00

License Badge GitHub Status Coverity Status Discord

Infix - Linux <3 NETCONF

Turn any ARM or x86 device into a powerful, manageable network appliance in minutes. From $35 Raspberry Pi boards to enterprise switches — deploy routers, IoT gateways, edge devices, or custom network solutions that just work.

Our Values

🔒 Immutable
Your system never breaks. Read-only filesystem with atomic upgrades means no configuration drift, no corrupted updates, and instant rollback if something goes wrong. Deploy once, trust forever.

🤝 Friendly
Actually easy to use. Auto-generated CLI from standard YANG models comes with built-in help for every command — just hit ? or TAB for context-aware assistance. Familiar NETCONF/RESTCONF APIs and comprehensive documentation mean you're never stuck. Whether you're learning networking or managing enterprise infrastructure.

🛡️ Secure
Built with security as a foundation, not an afterthought. Minimal attack surface, separation between system and data, and container isolation. Sleep better knowing your infrastructure is protected.

Why Choose Infix

Hardware Flexibility: Start with a $35 Raspberry Pi, scale to enterprise switching hardware. Same OS, same tools, same reliability.

Standards-Based: Built around YANG models and IETF standards. Learn once, use everywhere - no vendor lock-in.

Container Ready: Run your applications alongside networking functions. GPIO access, dedicated Ethernet ports, custom protocols — your device, your rules.

Use Cases

  1. Home Labs & Hobbyists:
    Transform a Raspberry Pi into a full-featured router with WiFi
  2. IoT & Edge Computing:
    Bridge devices to the cloud with reliable, updatable gateways
  3. Small Business Networks:
    Enterprise-grade features without the complexity or cost
  4. Developers & Makers:
    Test networking concepts, prototype IoT solutions, or build custom appliances
  5. Network Professionals:
    Consistent tooling from development to production deployment.
    How about a digital twin using raw Qemu or GNS3!

See It In Action

Configure an interface in seconds - the CLI guides you with built-in help:

Click Here for an example CLI Session
admin@infix-12-34-56:/> configure
admin@infix-12-34-56:/config/> edit interface eth0
admin@infix-12-34-56:/config/interface/eth0/> set ipv4 <TAB>
      address     autoconf bind-ni-name      enabled
      forwarding  mtu      neighbor
admin@infix-12-34-56:/config/interface/eth0/> set ipv4 address 192.168.2.200 prefix-length 24
admin@infix-12-34-56:/config/interface/eth0/> show
type ethernet;
ipv4 {
  address 192.168.2.200 {
    prefix-length 24;
  }
}
admin@infix-12-34-56:/config/interface/eth0/> diff
interfaces {
  interface eth0 {
+    ipv4 {
+      address 192.168.2.200 {
+        prefix-length 24;
+      }
+    }
  }
}
admin@infix-12-34-56:/config/interface/eth0/> leave
admin@infix-12-34-56:/> show interfaces
INTERFACE       PROTOCOL   STATE       DATA
eth0            ethernet   UP          52:54:00:12:34:56
                ipv4                   192.168.2.200/24 (static)
                ipv6                   fe80::5054:ff:fe12:3456/64 (link-layer)
lo              ethernet   UP          00:00:00:00:00:00
                ipv4                   127.0.0.1/8 (static)
                ipv6                   ::1/128 (static)
admin@infix-12-34-56:/> copy running-config startup-config

Notice how TAB completion shows available options, show displays current config, and diff shows exactly what changed before you commit your changes with the leave command.

Full CLI documentation →

Get Started

Get pre-built images for your hardware. Use the CLI, web interface, or standard NETCONF/RESTCONF tools, e.g., curl. Add containers for any custom functionality you need.

Supported Platforms

  • Raspberry Pi 4B - Perfect for home labs, learning, and prototyping
  • NanoPi R2S - Compact dual-port router in a tiny package
  • x86_64 - Run in VMs or on mini PCs for development and testing
  • Marvell CN9130 CRB, EspressoBIN - High-performance ARM platforms
  • Microchip SparX-5i, NXP i.MX8MP EVK - Enterprise switching capabilities
  • StarFive VisionFive2 - RISC-V architecture support

Why start with Raspberry Pi? It's affordable, widely available, has built-in WiFi + Ethernet, and runs the exact same Infix OS you'd deploy in production. Perfect for learning, prototyping, or even small-scale deployments.

📖 Complete documentation💬 Join our Discord

Technical Details

Built on proven open-source foundations (Buildroot + sysrepo) for reliability you can trust:

  • Immutable OS: Read-only filesystem, atomic updates, instant rollback
  • YANG Configuration: Industry-standard models with auto-generated tooling
  • Hardware Acceleration: Linux switchdev support for wire-speed packet processing
  • Container Integration: Docker support with flexible network and hardware access
  • Memory Efficient: Runs comfortably on devices with as little as 256 MB RAM

Perfect for everything from resource-constrained edge devices to high-throughput network appliances.

Check the Latest Build for bleeding-edge features.



Infix development is sponsored by Wires
Languages
Python 36.9%
C 16.3%
Go 16.1%
HTML 13.5%
Shell 8.2%
Other 8.9%