diff options
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | sftp-int.c | 62 |
2 files changed, 49 insertions, 29 deletions
@@ -9,6 +9,22 @@ | |||
9 | - stevesk@cvs.openbsd.org 2001/02/04 15:21:19 | 9 | - stevesk@cvs.openbsd.org 2001/02/04 15:21:19 |
10 | [sftp-server.c] | 10 | [sftp-server.c] |
11 | SSH2_FILEXFER_ATTR_UIDGID support; ok markus@ | 11 | SSH2_FILEXFER_ATTR_UIDGID support; ok markus@ |
12 | - deraadt@cvs.openbsd.org 2001/02/04 17:02:32 | ||
13 | [sftp-int.c] | ||
14 | ? == help | ||
15 | - deraadt@cvs.openbsd.org 2001/02/04 16:47:46 | ||
16 | [sftp-int.c] | ||
17 | sort commands, so that abbreviations work as expected | ||
18 | - stevesk@cvs.openbsd.org 2001/02/04 15:17:52 | ||
19 | [sftp-int.c] | ||
20 | debugging sftp: precedence and missing break. chmod, chown, chgrp | ||
21 | seem to be working now. | ||
22 | - markus@cvs.openbsd.org 2001/02/04 14:41:21 | ||
23 | [sftp-int.c] | ||
24 | use base 8 for umask/chmod | ||
25 | - markus@cvs.openbsd.org 2001/02/04 11:11:54 | ||
26 | [sftp-int.c] | ||
27 | fix LCD | ||
12 | 28 | ||
13 | 20010104 | 29 | 20010104 |
14 | - (bal) I think this is the last of the bsd-*.h that don't belong. | 30 | - (bal) I think this is the last of the bsd-*.h that don't belong. |
diff --git a/sftp-int.c b/sftp-int.c index 9ec5b9712..02e0d38c0 100644 --- a/sftp-int.c +++ b/sftp-int.c | |||
@@ -27,7 +27,7 @@ | |||
27 | /* XXX: recursive operations */ | 27 | /* XXX: recursive operations */ |
28 | 28 | ||
29 | #include "includes.h" | 29 | #include "includes.h" |
30 | RCSID("$OpenBSD: sftp-int.c,v 1.1 2001/02/04 11:11:54 djm Exp $"); | 30 | RCSID("$OpenBSD: sftp-int.c,v 1.7 2001/02/05 00:02:32 deraadt Exp $"); |
31 | 31 | ||
32 | #include "buffer.h" | 32 | #include "buffer.h" |
33 | #include "xmalloc.h" | 33 | #include "xmalloc.h" |
@@ -65,35 +65,36 @@ RCSID("$OpenBSD: sftp-int.c,v 1.1 2001/02/04 11:11:54 djm Exp $"); | |||
65 | #define I_SHELL 20 | 65 | #define I_SHELL 20 |
66 | 66 | ||
67 | struct CMD { | 67 | struct CMD { |
68 | const int n; | ||
69 | const char *c; | 68 | const char *c; |
69 | const int n; | ||
70 | }; | 70 | }; |
71 | 71 | ||
72 | const struct CMD cmds[] = { | 72 | const struct CMD cmds[] = { |
73 | { I_CHDIR, "CD" }, | 73 | { "CD", I_CHDIR }, |
74 | { I_CHDIR, "CHDIR" }, | 74 | { "CHDIR", I_CHDIR }, |
75 | { I_CHDIR, "LCD" }, | 75 | { "CHGRP", I_CHGRP }, |
76 | { I_CHGRP, "CHGRP" }, | 76 | { "CHMOD", I_CHMOD }, |
77 | { I_CHMOD, "CHMOD" }, | 77 | { "CHOWN", I_CHOWN }, |
78 | { I_CHOWN, "CHOWN" }, | 78 | { "EXIT", I_QUIT }, |
79 | { I_HELP, "HELP" }, | 79 | { "GET", I_GET }, |
80 | { I_GET, "GET" }, | 80 | { "HELP", I_HELP }, |
81 | { I_LCHDIR, "LCHDIR" }, | 81 | { "LCD", I_LCHDIR }, |
82 | { I_LLS, "LLS" }, | 82 | { "LCHDIR", I_LCHDIR }, |
83 | { I_LMKDIR, "LMKDIR" }, | 83 | { "LLS", I_LLS }, |
84 | { I_LPWD, "LPWD" }, | 84 | { "LMKDIR", I_LMKDIR }, |
85 | { I_LS, "LS" }, | 85 | { "LPWD", I_LPWD }, |
86 | { I_LUMASK, "LUMASK" }, | 86 | { "LS", I_LS }, |
87 | { I_MKDIR, "MKDIR" }, | 87 | { "LUMASK", I_LUMASK }, |
88 | { I_PUT, "PUT" }, | 88 | { "MKDIR", I_MKDIR }, |
89 | { I_PWD, "PWD" }, | 89 | { "PUT", I_PUT }, |
90 | { I_QUIT, "EXIT" }, | 90 | { "PWD", I_PWD }, |
91 | { I_QUIT, "QUIT" }, | 91 | { "QUIT", I_QUIT }, |
92 | { I_RENAME, "RENAME" }, | 92 | { "RENAME", I_RENAME }, |
93 | { I_RMDIR, "RMDIR" }, | 93 | { "RM", I_RM }, |
94 | { I_RM, "RM" }, | 94 | { "RMDIR", I_RMDIR }, |
95 | { I_SHELL, "!" }, | 95 | { "!", I_SHELL }, |
96 | { -1, NULL} | 96 | { "?", I_HELP }, |
97 | { NULL, -1} | ||
97 | }; | 98 | }; |
98 | 99 | ||
99 | void | 100 | void |
@@ -289,6 +290,7 @@ parse_args(const char **cpp, int *pflag, unsigned long *n_arg, | |||
289 | char **path1, char **path2) | 290 | char **path1, char **path2) |
290 | { | 291 | { |
291 | const char *cmd, *cp = *cpp; | 292 | const char *cmd, *cp = *cpp; |
293 | int base = 0; | ||
292 | int i, cmdnum; | 294 | int i, cmdnum; |
293 | 295 | ||
294 | /* Skip leading whitespace */ | 296 | /* Skip leading whitespace */ |
@@ -383,6 +385,7 @@ parse_args(const char **cpp, int *pflag, unsigned long *n_arg, | |||
383 | break; | 385 | break; |
384 | case I_LUMASK: | 386 | case I_LUMASK: |
385 | case I_CHMOD: | 387 | case I_CHMOD: |
388 | base = 8; | ||
386 | case I_CHOWN: | 389 | case I_CHOWN: |
387 | case I_CHGRP: | 390 | case I_CHGRP: |
388 | /* Get numeric arg (mandatory) */ | 391 | /* Get numeric arg (mandatory) */ |
@@ -391,7 +394,7 @@ parse_args(const char **cpp, int *pflag, unsigned long *n_arg, | |||
391 | "to the %s command.", cmd); | 394 | "to the %s command.", cmd); |
392 | return(-1); | 395 | return(-1); |
393 | } | 396 | } |
394 | *n_arg = strtoul(cp, (char**)&cp, 0); | 397 | *n_arg = strtoul(cp, (char**)&cp, base); |
395 | if (!*cp || !strchr(WHITESPACE, *cp)) { | 398 | if (!*cp || !strchr(WHITESPACE, *cp)) { |
396 | error("You must supply a numeric argument " | 399 | error("You must supply a numeric argument " |
397 | "to the %s command.", cmd); | 400 | "to the %s command.", cmd); |
@@ -500,10 +503,11 @@ parse_dispatch_command(int in, int out, const char *cmd, char **pwd) | |||
500 | a.flags |= SSH2_FILEXFER_ATTR_PERMISSIONS; | 503 | a.flags |= SSH2_FILEXFER_ATTR_PERMISSIONS; |
501 | a.perm = n_arg; | 504 | a.perm = n_arg; |
502 | do_setstat(in, out, path1, &a); | 505 | do_setstat(in, out, path1, &a); |
506 | break; | ||
503 | case I_CHOWN: | 507 | case I_CHOWN: |
504 | path1 = make_absolute(path1, *pwd); | 508 | path1 = make_absolute(path1, *pwd); |
505 | aa = do_stat(in, out, path1); | 509 | aa = do_stat(in, out, path1); |
506 | if (!aa->flags & SSH2_FILEXFER_ATTR_UIDGID) { | 510 | if (!(aa->flags & SSH2_FILEXFER_ATTR_UIDGID)) { |
507 | error("Can't get current ownership of " | 511 | error("Can't get current ownership of " |
508 | "remote file \"%s\"", path1); | 512 | "remote file \"%s\"", path1); |
509 | break; | 513 | break; |
@@ -514,7 +518,7 @@ parse_dispatch_command(int in, int out, const char *cmd, char **pwd) | |||
514 | case I_CHGRP: | 518 | case I_CHGRP: |
515 | path1 = make_absolute(path1, *pwd); | 519 | path1 = make_absolute(path1, *pwd); |
516 | aa = do_stat(in, out, path1); | 520 | aa = do_stat(in, out, path1); |
517 | if (!aa->flags & SSH2_FILEXFER_ATTR_UIDGID) { | 521 | if (!(aa->flags & SSH2_FILEXFER_ATTR_UIDGID)) { |
518 | error("Can't get current ownership of " | 522 | error("Can't get current ownership of " |
519 | "remote file \"%s\"", path1); | 523 | "remote file \"%s\"", path1); |
520 | break; | 524 | break; |