feat: add --remote-dir flag and use ssh alias as mount label
Update PKGBUILD version / update-pkgver (push) Successful in 3s

- New `-r` / `--remote-dir` flag to mount a specific remote subdirectory;
  empty default preserves prior home-dir behaviour.
- Validate the flag value via a dedicated `rxRemoteDir` allowlist before it
  reaches the sshfs argv.
- Use the ssh_config alias (not the resolved HostName) as the local
  mountpoint name and as the sshfs source. File managers now show the
  human-readable label instead of the raw IP.
- Validate `args[0]` against `rxHostUser` since it now flows into argv.
- Rename `verify_mount_dir` parameter `hostname -> name` and `mount_sshfs`
  first parameter `hostname -> alias` for clarity.
This commit is contained in:
2026-04-28 15:39:17 +02:00
parent d01a358f35
commit afb51f1d61
4 changed files with 90 additions and 10 deletions
+13 -1
View File
@@ -92,12 +92,24 @@ func TestValidateSSHFieldRegexes(t *testing.T) {
{"identityfile leading dot rejected", ".ssh/id", "ifile", false},
{"identityfile leading colon rejected", ":weird", "ifile", false},
{"identityfile empty rejected", "", "ifile", false},
{"remote-dir absolute", "/var/www", "rdir", true},
{"remote-dir tilde", "~/work", "rdir", true},
{"remote-dir relative", "projects/foo", "rdir", true},
{"remote-dir leading dash rejected", "-rf", "rdir", false},
{"remote-dir leading dot rejected", "./x", "rdir", false},
{"remote-dir space rejected", "/var /www", "rdir", false},
{"remote-dir comma rejected", "/a,b", "rdir", false},
{"remote-dir empty rejected", "", "rdir", false},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var rx = rxHostUser
if tc.rx == "ifile" {
switch tc.rx {
case "ifile":
rx = rxIdentityFile
case "rdir":
rx = rxRemoteDir
}
err := validate_ssh_field("X", tc.value, rx)
if tc.ok && err != nil {