summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstevesk <stevesk@openbsd.org>2001-02-12 20:53:33 +0000
committerstevesk <stevesk@openbsd.org>2001-02-12 20:53:33 +0000
commitbc3b0dc177f85e843c7fed2e1c89c2822714790b (patch)
treec7de86ea79eaaaf9d36c9a3a7252d26778dbfcbb
parentDefine MAX_UNAME in terms of _PW_NAME_LEN. Potential problem found by (diff)
downloadwireguard-openbsd-bc3b0dc177f85e843c7fed2e1c89c2822714790b.tar.xz
wireguard-openbsd-bc3b0dc177f85e843c7fed2e1c89c2822714790b.zip
lumask now works with 1 numeric arg; ok markus@, djm@
-rw-r--r--usr.bin/ssh/sftp-int.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/usr.bin/ssh/sftp-int.c b/usr.bin/ssh/sftp-int.c
index 9c3ebe5bf9c..c236f6dac20 100644
--- a/usr.bin/ssh/sftp-int.c
+++ b/usr.bin/ssh/sftp-int.c
@@ -28,7 +28,7 @@
/* XXX: recursive operations */
#include "includes.h"
-RCSID("$OpenBSD: sftp-int.c,v 1.20 2001/02/10 00:45:26 djm Exp $");
+RCSID("$OpenBSD: sftp-int.c,v 1.21 2001/02/12 20:53:33 stevesk Exp $");
#include "buffer.h"
#include "xmalloc.h"
@@ -293,7 +293,9 @@ parse_args(const char **cpp, int *pflag, unsigned long *n_arg,
char **path1, char **path2)
{
const char *cmd, *cp = *cpp;
+ char *cp2;
int base = 0;
+ long l;
int i, cmdnum;
/* Skip leading whitespace */
@@ -387,18 +389,24 @@ parse_args(const char **cpp, int *pflag, unsigned long *n_arg,
/* Uses the rest of the line */
break;
case I_LUMASK:
+ base = 8;
case I_CHMOD:
base = 8;
case I_CHOWN:
case I_CHGRP:
/* Get numeric arg (mandatory) */
- if (*cp < '0' && *cp > '9') {
+ l = strtol(cp, &cp2, base);
+ if (cp2 == cp || ((l == LONG_MIN || l == LONG_MAX) &&
+ errno == ERANGE) || l < 0) {
error("You must supply a numeric argument "
"to the %s command.", cmd);
return(-1);
}
- *n_arg = strtoul(cp, (char**)&cp, base);
- if (!*cp || !strchr(WHITESPACE, *cp)) {
+ cp = cp2;
+ *n_arg = l;
+ if (cmdnum == I_LUMASK && strchr(WHITESPACE, *cp))
+ break;
+ if (cmdnum == I_LUMASK || !strchr(WHITESPACE, *cp)) {
error("You must supply a numeric argument "
"to the %s command.", cmd);
return(-1);
@@ -530,6 +538,7 @@ parse_dispatch_command(int in, int out, const char *cmd, char **pwd)
break;
case I_LUMASK:
umask(n_arg);
+ printf("Local umask: %03lo\n", n_arg);
break;
case I_CHMOD:
path1 = make_absolute(path1, *pwd);