version 1.214, 2022/03/31 03:07:03 |
version 1.215, 2022/05/08 22:32:36 |
|
|
return optind; |
return optind; |
} |
} |
|
|
|
static char * |
|
escape_glob(const char *s) |
|
{ |
|
size_t i, o, len; |
|
char *ret; |
|
|
|
len = strlen(s); |
|
ret = xcalloc(2, len + 1); |
|
for (i = o = 0; i < len; i++) { |
|
if (strchr("[]?*\\", s[i]) != NULL) |
|
ret[o++] = '\\'; |
|
ret[o++] = s[i]; |
|
} |
|
ret[o++] = '\0'; |
|
return ret; |
|
} |
|
|
|
static char * |
|
make_absolute_pwd_glob(const char *p, const char *pwd) |
|
{ |
|
char *ret, *escpwd; |
|
|
|
escpwd = escape_glob(pwd); |
|
if (p == NULL) |
|
return escpwd; |
|
ret = make_absolute(xstrdup(p), escpwd); |
|
free(escpwd); |
|
return ret; |
|
} |
|
|
static int |
static int |
process_get(struct sftp_conn *conn, const char *src, const char *dst, |
process_get(struct sftp_conn *conn, const char *src, const char *dst, |
const char *pwd, int pflag, int rflag, int resume, int fflag) |
const char *pwd, int pflag, int rflag, int resume, int fflag) |
{ |
{ |
char *abs_src = NULL; |
char *filename, *abs_src = NULL, *abs_dst = NULL, *tmp = NULL; |
char *abs_dst = NULL; |
|
glob_t g; |
glob_t g; |
char *filename, *tmp=NULL; |
|
int i, r, err = 0; |
int i, r, err = 0; |
|
|
abs_src = xstrdup(src); |
abs_src = make_absolute_pwd_glob(src, pwd); |
abs_src = make_absolute(abs_src, pwd); |
|
memset(&g, 0, sizeof(g)); |
memset(&g, 0, sizeof(g)); |
|
|
debug3("Looking up %s", abs_src); |
debug3("Looking up %s", abs_src); |
|
|
err = (sflag ? do_symlink : do_hardlink)(conn, path1, path2); |
err = (sflag ? do_symlink : do_hardlink)(conn, path1, path2); |
break; |
break; |
case I_RM: |
case I_RM: |
path1 = make_absolute(path1, *pwd); |
path1 = make_absolute_pwd_glob(path1, *pwd); |
remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g); |
remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g); |
for (i = 0; g.gl_pathv[i] && !interrupted; i++) { |
for (i = 0; g.gl_pathv[i] && !interrupted; i++) { |
if (!quiet) |
if (!quiet) |
|
|
if (!path_absolute(path1)) |
if (!path_absolute(path1)) |
tmp = *pwd; |
tmp = *pwd; |
|
|
path1 = make_absolute(path1, *pwd); |
path1 = make_absolute_pwd_glob(path1, *pwd); |
err = do_globbed_ls(conn, path1, tmp, lflag); |
err = do_globbed_ls(conn, path1, tmp, lflag); |
break; |
break; |
case I_DF: |
case I_DF: |
|
|
printf("Local umask: %03lo\n", n_arg); |
printf("Local umask: %03lo\n", n_arg); |
break; |
break; |
case I_CHMOD: |
case I_CHMOD: |
path1 = make_absolute(path1, *pwd); |
path1 = make_absolute_pwd_glob(path1, *pwd); |
attrib_clear(&a); |
attrib_clear(&a); |
a.flags |= SSH2_FILEXFER_ATTR_PERMISSIONS; |
a.flags |= SSH2_FILEXFER_ATTR_PERMISSIONS; |
a.perm = n_arg; |
a.perm = n_arg; |
|
|
break; |
break; |
case I_CHOWN: |
case I_CHOWN: |
case I_CHGRP: |
case I_CHGRP: |
path1 = make_absolute(path1, *pwd); |
path1 = make_absolute_pwd_glob(path1, *pwd); |
remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g); |
remote_glob(conn, path1, GLOB_NOCHECK, NULL, &g); |
for (i = 0; g.gl_pathv[i] && !interrupted; i++) { |
for (i = 0; g.gl_pathv[i] && !interrupted; i++) { |
if (!(aa = (hflag ? do_lstat : do_stat)(conn, |
if (!(aa = (hflag ? do_lstat : do_stat)(conn, |
|
|
|
|
memset(&g, 0, sizeof(g)); |
memset(&g, 0, sizeof(g)); |
if (remote != LOCAL) { |
if (remote != LOCAL) { |
tmp = make_absolute(tmp, remote_path); |
tmp = make_absolute_pwd_glob(tmp, remote_path); |
remote_glob(conn, tmp, GLOB_DOOFFS|GLOB_MARK, NULL, &g); |
remote_glob(conn, tmp, GLOB_DOOFFS|GLOB_MARK, NULL, &g); |
} else |
} else |
glob(tmp, GLOB_DOOFFS|GLOB_MARK, NULL, &g); |
glob(tmp, GLOB_DOOFFS|GLOB_MARK, NULL, &g); |