summaryrefslogtreecommitdiffstats
path: root/source3/client
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2013-07-09 14:27:55 +0200
committerAndreas Schneider <asn@samba.org>2014-02-19 18:22:26 +0100
commitb753900b09e6b5001042e45388b72ad36e8a0093 (patch)
treea01823b4f18cabde95522221355f6d9df0a7bdd9 /source3/client
parent3a8e3264d0da83817629def666c483b558d8d49d (diff)
downloadsamba-b753900b09e6b5001042e45388b72ad36e8a0093.tar.gz
samba-b753900b09e6b5001042e45388b72ad36e8a0093.tar.xz
samba-b753900b09e6b5001042e45388b72ad36e8a0093.zip
clitar.c: fix path name when adding them
Signed-off-by: Aurélien Aptel <aurelien.aptel@gmail.com> Reviewed-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/client')
-rw-r--r--source3/client/clitar.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index 47b4036ce3c..6c3bbd7d4fc 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -87,6 +87,43 @@ struct tar tar_ctx = {
.mode.dry = false,
};
+static char *fix_unix_path (char *path, bool removeprefix)
+{
+ char *from = path, *to = path;
+
+ if (!path || !*path)
+ return path;
+
+ /* remove prefix:
+ * ./path => path
+ * /path => path
+ */
+ if (removeprefix) {
+ /* /path */
+ if (path[0] == '/' || path[0] == '\\') {
+ from += 1;
+ }
+
+ /* ./path */
+ if (path[1] && path[0] == '.' && (path[1] == '/' || path[1] == '\\')) {
+ from += 2;
+ }
+ }
+
+ /* replace \ with / */
+ while (*from) {
+ if (*from == '\\') {
+ *to = '/';
+ } else {
+ *to = *from;
+ }
+ from++; to++;
+ }
+ *to = 0;
+
+ return path;
+}
+
#define XSET(v) [v] = #v
#define XTABLE(v, t) DEBUG(2, ("DUMP:%-20.20s = %s\n", #v, t[v]))
#define XBOOL(v) DEBUG(2, ("DUMP:%-20.20s = %d\n", #v, v ? 1 : 0))
@@ -173,7 +210,7 @@ static bool tar_read_inclusion_file (struct tar *t, const char* filename)
list = str_list_make_empty(ctx);
while ((line = afdgets(fd, ctx, 0))) {
- list = str_list_add((const char **)list, line);
+ list = str_list_add((const char **)list, fix_unix_path(line, true));
}
close(fd);
@@ -568,6 +605,7 @@ int tar_parse_args(struct tar* t, const char *flag, const char **val, int valsiz
int i;
for (i = ival; i < valsize; i++) {
t->path_list = str_list_add((const char**)t->path_list, val[i]);
+ fix_unix_path(t->path_list[i-ival], true);
}
}