mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-01 13:23:01 +02:00
bin: allow 'copy <src> foo' for shell users
With guard rails in CLI, without in shell. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
+11
-6
@@ -129,14 +129,19 @@ char *cfg_adjust(const char *path, const char *template, bool sanitize)
|
||||
if (!path_allowed(path))
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* CLI users save to /cfg by default, unless abs. path */
|
||||
if (asprintf(&expanded, "%s%.*s/%s%s",
|
||||
path[0] == '/' ? "" : "/cfg/",
|
||||
dlen, path,
|
||||
basename,
|
||||
strchr(basename, '.') ? "" : ".cfg") < 0)
|
||||
goto err;
|
||||
} else {
|
||||
/* Shell users expect copy to behave more like cp */
|
||||
expanded = strdup(path);
|
||||
}
|
||||
|
||||
if (asprintf(&expanded, "%s%.*s/%s%s",
|
||||
path[0] == '/' ? "" : "/cfg/",
|
||||
dlen, path,
|
||||
basename,
|
||||
strchr(basename, '.') ? "" : ".cfg") < 0)
|
||||
goto err;
|
||||
|
||||
if (sanitize) {
|
||||
resolved = realpath(expanded, NULL);
|
||||
|
||||
Reference in New Issue
Block a user