lxd icon indicating copy to clipboard operation
lxd copied to clipboard

Enhancement: extend "lxc file" command-set with symlinks manipulation

Open tregubovav-dev opened this issue 2 years ago • 2 comments

LXC supports file and directory manipulation via REST API and command line "lxc file ..". However there are a few discrepancies between REST API and command-line interfaces:

  1. lxc command-line interfaces does not support manipulation with symlinks in container filesystem. There is no way to create and/or modify symlink(s) via command-line interface.
  2. lxc command-line interface support for directory manipulation confusing is a bit. There is no way to create an empty directory in container file-system in one shot. The only pushing local directory to container is supported.

I would suggest to extend command-line interfaces with:

  • flag type which can be file, symlink or directory as defined in REST API.
  • command create with optional flag content (applicable for type file or symlink only).
  • it would be good if it possible to add command rename in command-line and REST API

These changes may also introduce some changes in push, pull and edit sub-commands.

tregubovav-dev avatar Oct 21 '23 00:10 tregubovav-dev

While looking into this, I noticed an inconsistent behavior regarding symlinks. As it turns out, symlinks are handled differently depending on whether you're pushing recursively or non-recursively. When pushing recursively, they are created as symlinks in the instance. When pushing non-recursively, symlinks are followed and will create regular files in the instance. This inconsistency might be bug.

We could add a --follow-symlinks or --dereference flag to lxc file push to ensure the behavior is the same for recursive push and non-recursive push. But this will break one of the two, unless the new flag's default is false for recursive push, and true for non-recursive push. That might be confusing though.

@tomponline @simondeziel what are your thoughts on this?

monstermunchkin avatar Nov 08 '23 15:11 monstermunchkin

To avoid the possible issues we can introduce additional command to create (or even modify) symlink file. for example lxc file symlink create <name> <target> with option --force to override exiting symlink.

tregubovav-dev avatar Nov 08 '23 18:11 tregubovav-dev

After review, we have decided not to move forward with this request.

escabo avatar Dec 01 '25 16:12 escabo