summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-07-15 14:14:16 +1000
committerDamien Miller <djm@mindrot.org>2000-07-15 14:14:16 +1000
commitbe484b5d9889ca636fecdf1f6b73ddfbe4cce3c9 (patch)
tree8b1023f666bebd274c08fe579a61c70a8a66f283
parent055dc369837e1bde0f84a7ecfe669e4e44f10db9 (diff)
- (djm) OpenBSD CVS updates
- provos@cvs.openbsd.org 2000/07/13 16:53:22 [aux.c readconf.c servconf.c ssh.h] allow multiple whitespace but only one '=' between tokens, bug report from Ralf S. Engelschall <rse@engelschall.com> but different fix. okay deraadt@ - provos@cvs.openbsd.org 2000/07/13 17:14:09 [clientloop.c] typo; todd@fries.net - provos@cvs.openbsd.org 2000/07/13 17:19:31 [scp.c] close can fail on AFS, report error; from Greg Hudson <ghudson@mit.edu> - markus@cvs.openbsd.org 2000/07/14 16:59:46 [readconf.c servconf.c] allow leading whitespace. ok niels - djm@cvs.openbsd.org 2000/07/14 22:01:38 [ssh-keygen.c ssh.c] Always create ~/.ssh with mode 700; ok Markus
-rw-r--r--ChangeLog171
-rw-r--r--aux.c32
-rw-r--r--clientloop.c4
-rw-r--r--readconf.c54
-rw-r--r--scp.c9
-rw-r--r--servconf.c49
-rw-r--r--ssh-keygen.c4
-rw-r--r--ssh.c4
-rw-r--r--ssh.h5
9 files changed, 193 insertions, 139 deletions
diff --git a/ChangeLog b/ChangeLog
index 54e80b71b..2b3cd0b6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
120000713
2 - (djm) OpenBSD CVS updates
3 - provos@cvs.openbsd.org 2000/07/13 16:53:22
4 [aux.c readconf.c servconf.c ssh.h]
5 allow multiple whitespace but only one '=' between tokens, bug report from
6 Ralf S. Engelschall <rse@engelschall.com> but different fix. okay deraadt@
7 - provos@cvs.openbsd.org 2000/07/13 17:14:09
8 [clientloop.c]
9 typo; todd@fries.net
10 - provos@cvs.openbsd.org 2000/07/13 17:19:31
11 [scp.c]
12 close can fail on AFS, report error; from Greg Hudson <ghudson@mit.edu>
13 - markus@cvs.openbsd.org 2000/07/14 16:59:46
14 [readconf.c servconf.c]
15 allow leading whitespace. ok niels
16 - djm@cvs.openbsd.org 2000/07/14 22:01:38
17 [ssh-keygen.c ssh.c]
18 Always create ~/.ssh with mode 700; ok Markus
19
120000712 2020000712
2 - (djm) Remove -lresolve for Reliant Unix 21 - (djm) Remove -lresolve for Reliant Unix
3 - (djm) OpenBSD CVS Updates: 22 - (djm) OpenBSD CVS Updates:
@@ -247,7 +266,7 @@
247 - Don't try to retrieve lastlog from wtmp/wtmpx if DISABLE_LASTLOG is 266 - Don't try to retrieve lastlog from wtmp/wtmpx if DISABLE_LASTLOG is
248 def'd 267 def'd
249 - Set AIX to use preformatted manpages 268 - Set AIX to use preformatted manpages
250 269
25120000610 27020000610
252 - (djm) Minor doc tweaks 271 - (djm) Minor doc tweaks
253 - (djm) Fix for configure on bash2 from Jim Knoble <jmknoble@jmknoble.cx> 272 - (djm) Fix for configure on bash2 from Jim Knoble <jmknoble@jmknoble.cx>
@@ -304,7 +323,7 @@
304 - (andre) New login code 323 - (andre) New login code
305 - Remove bsd-login.[ch] and all the OpenBSD-derived code in login.c 324 - Remove bsd-login.[ch] and all the OpenBSD-derived code in login.c
306 - Add loginrec.[ch], logintest.c and autoconf code 325 - Add loginrec.[ch], logintest.c and autoconf code
307 326
30820000531 32720000531
309 - Cleanup of auth.c, login.c and fake-* 328 - Cleanup of auth.c, login.c and fake-*
310 - Cleanup of auth-pam.c, save and print "account expired" error messages 329 - Cleanup of auth-pam.c, save and print "account expired" error messages
@@ -366,9 +385,9 @@
366 - Gives useful error message if PRNG initialisation fails 385 - Gives useful error message if PRNG initialisation fails
367 - Reduced ssh startup delay 386 - Reduced ssh startup delay
368 - Measures cumulative command time rather than the time between reads 387 - Measures cumulative command time rather than the time between reads
369 after select() 388 after select()
370 - 'fixprogs' perl script to eliminate non-working entropy commands, and 389 - 'fixprogs' perl script to eliminate non-working entropy commands, and
371 optionally run 'ent' to measure command entropy 390 optionally run 'ent' to measure command entropy
372 - Applied Tom Bertelson's <tbert@abac.com> AIX authentication fix 391 - Applied Tom Bertelson's <tbert@abac.com> AIX authentication fix
373 - Avoid WCOREDUMP complation errors for systems that lack it 392 - Avoid WCOREDUMP complation errors for systems that lack it
374 - Avoid SIGCHLD warnings from entropy commands 393 - Avoid SIGCHLD warnings from entropy commands
@@ -853,64 +872,64 @@
853 872
85420000309 87320000309
855 - OpenBSD CVS updates to v1.2.3 874 - OpenBSD CVS updates to v1.2.3
856 [ssh.h atomicio.c] 875 [ssh.h atomicio.c]
857 - int atomicio -> ssize_t (for alpha). ok deraadt@ 876 - int atomicio -> ssize_t (for alpha). ok deraadt@
858 [auth-rsa.c] 877 [auth-rsa.c]
859 - delay MD5 computation until client sends response, free() early, cleanup. 878 - delay MD5 computation until client sends response, free() early, cleanup.
860 [cipher.c] 879 [cipher.c]
861 - void* -> unsigned char*, ok niels@ 880 - void* -> unsigned char*, ok niels@
862 [hostfile.c] 881 [hostfile.c]
863 - remove unused variable 'len'. fix comments. 882 - remove unused variable 'len'. fix comments.
864 - remove unused variable 883 - remove unused variable
865 [log-client.c log-server.c] 884 [log-client.c log-server.c]
866 - rename a cpp symbol, to avoid param.h collision 885 - rename a cpp symbol, to avoid param.h collision
867 [packet.c] 886 [packet.c]
868 - missing xfree() 887 - missing xfree()
869 - getsockname() requires initialized tolen; andy@guildsoftware.com 888 - getsockname() requires initialized tolen; andy@guildsoftware.com
870 - use getpeername() in packet_connection_is_on_socket(), fixes sshd -i; 889 - use getpeername() in packet_connection_is_on_socket(), fixes sshd -i;
871 from Holger.Trapp@Informatik.TU-Chemnitz.DE 890 from Holger.Trapp@Informatik.TU-Chemnitz.DE
872 [pty.c pty.h] 891 [pty.c pty.h]
873 - register cleanup for pty earlier. move code for pty-owner handling to 892 - register cleanup for pty earlier. move code for pty-owner handling to
874 pty.c ok provos@, dugsong@
875 [readconf.c]
876 - turn off x11-fwd for the client, too.
877 [rsa.c]
878 - PKCS#1 padding
879 [scp.c]
880 - allow '.' in usernames; from jedgar@fxp.org
881 [servconf.c]
882 - typo: ignore_user_known_hosts int->flag; naddy@mips.rhein-neckar.de
883 - sync with sshd_config
884 [ssh-keygen.c]
885 - enable ssh-keygen -l -f ~/.ssh/known_hosts, ok deraadt@
886 [ssh.1]
887 - Change invalid 'CHAT' loglevel to 'VERBOSE'
888 [ssh.c]
889 - suppress AAAA query host when '-4' is used; from shin@nd.net.fujitsu.co.jp
890 - turn off x11-fwd for the client, too.
891 [sshconnect.c]
892 - missing xfree()
893 - retry rresvport_af(), too. from sumikawa@ebina.hitachi.co.jp.
894 - read error vs. "Connection closed by remote host"
895 [sshd.8]
896 - ie. -> i.e.,
897 - do not link to a commercial page..
898 - sync with sshd_config
899 [sshd.c]
900 - no need for poll.h; from bright@wintelcom.net
901 - log with level log() not fatal() if peer behaves badly.
902 - don't panic if client behaves strange. ok deraadt@
903 - make no-port-forwarding for RSA keys deny both -L and -R style fwding
904 - delay close() of pty until the pty has been chowned back to root
905 - oops, fix comment, too.
906 - missing xfree()
907 - move XAUTHORITY to subdir. ok dugsong@. fixes debian bug #57907, too.
908 (http://cgi.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=57907)
909 - register cleanup for pty earlier. move code for pty-owner handling to
910 pty.c ok provos@, dugsong@ 893 pty.c ok provos@, dugsong@
911 - create x11 cookie file 894 [readconf.c]
912 - fix pr 1113, fclose() -> pclose(), todo: remote popen() 895 - turn off x11-fwd for the client, too.
913 - version 1.2.3 896 [rsa.c]
897 - PKCS#1 padding
898 [scp.c]
899 - allow '.' in usernames; from jedgar@fxp.org
900 [servconf.c]
901 - typo: ignore_user_known_hosts int->flag; naddy@mips.rhein-neckar.de
902 - sync with sshd_config
903 [ssh-keygen.c]
904 - enable ssh-keygen -l -f ~/.ssh/known_hosts, ok deraadt@
905 [ssh.1]
906 - Change invalid 'CHAT' loglevel to 'VERBOSE'
907 [ssh.c]
908 - suppress AAAA query host when '-4' is used; from shin@nd.net.fujitsu.co.jp
909 - turn off x11-fwd for the client, too.
910 [sshconnect.c]
911 - missing xfree()
912 - retry rresvport_af(), too. from sumikawa@ebina.hitachi.co.jp.
913 - read error vs. "Connection closed by remote host"
914 [sshd.8]
915 - ie. -> i.e.,
916 - do not link to a commercial page..
917 - sync with sshd_config
918 [sshd.c]
919 - no need for poll.h; from bright@wintelcom.net
920 - log with level log() not fatal() if peer behaves badly.
921 - don't panic if client behaves strange. ok deraadt@
922 - make no-port-forwarding for RSA keys deny both -L and -R style fwding
923 - delay close() of pty until the pty has been chowned back to root
924 - oops, fix comment, too.
925 - missing xfree()
926 - move XAUTHORITY to subdir. ok dugsong@. fixes debian bug #57907, too.
927 (http://cgi.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=57907)
928 - register cleanup for pty earlier. move code for pty-owner handling to
929 pty.c ok provos@, dugsong@
930 - create x11 cookie file
931 - fix pr 1113, fclose() -> pclose(), todo: remote popen()
932 - version 1.2.3
914 - Cleaned up 933 - Cleaned up
915 - Removed warning workaround for Linux and devpts filesystems (no longer 934 - Removed warning workaround for Linux and devpts filesystems (no longer
916 required after OpenBSD updates) 935 required after OpenBSD updates)
@@ -1656,21 +1675,21 @@
1656 modular. 1675 modular.
1657 - Revised autoconf support for enabling/disabling askpass support. 1676 - Revised autoconf support for enabling/disabling askpass support.
1658 - Merged more OpenBSD CVS changes: 1677 - Merged more OpenBSD CVS changes:
1659 [auth-krb4.c] 1678 [auth-krb4.c]
1660 - disconnect if getpeername() fails 1679 - disconnect if getpeername() fails
1661 - missing xfree(*client) 1680 - missing xfree(*client)
1662 [canohost.c] 1681 [canohost.c]
1663 - disconnect if getpeername() fails 1682 - disconnect if getpeername() fails
1664 - fix comment: we _do_ disconnect if ip-options are set 1683 - fix comment: we _do_ disconnect if ip-options are set
1665 [sshd.c] 1684 [sshd.c]
1666 - disconnect if getpeername() fails 1685 - disconnect if getpeername() fails
1667 - move checking of remote port to central place 1686 - move checking of remote port to central place
1668 [auth-rhosts.c] move checking of remote port to central place 1687 [auth-rhosts.c] move checking of remote port to central place
1669 [log-server.c] avoid extra fd per sshd, from millert@ 1688 [log-server.c] avoid extra fd per sshd, from millert@
1670 [readconf.c] print _all_ bad config-options in ssh(1), too 1689 [readconf.c] print _all_ bad config-options in ssh(1), too
1671 [readconf.h] print _all_ bad config-options in ssh(1), too 1690 [readconf.h] print _all_ bad config-options in ssh(1), too
1672 [ssh.c] print _all_ bad config-options in ssh(1), too 1691 [ssh.c] print _all_ bad config-options in ssh(1), too
1673 [sshconnect.c] disconnect if getpeername() fails 1692 [sshconnect.c] disconnect if getpeername() fails
1674 - OpenBSD's changes to sshd.c broke the PAM stuff, re-merged it. 1693 - OpenBSD's changes to sshd.c broke the PAM stuff, re-merged it.
1675 - Various small cleanups to bring diff (against OpenBSD) size down. 1694 - Various small cleanups to bring diff (against OpenBSD) size down.
1676 - Merged more Solaris compability from Marc G. Fournier 1695 - Merged more Solaris compability from Marc G. Fournier
diff --git a/aux.c b/aux.c
index 63f7dd41a..709e2451b 100644
--- a/aux.c
+++ b/aux.c
@@ -1,5 +1,5 @@
1#include "includes.h" 1#include "includes.h"
2RCSID("$OpenBSD: aux.c,v 1.3 2000/06/18 17:13:41 markus Exp $"); 2RCSID("$OpenBSD: aux.c,v 1.4 2000/07/13 22:53:21 provos Exp $");
3 3
4#include "ssh.h" 4#include "ssh.h"
5 5
@@ -39,3 +39,33 @@ set_nonblock(int fd)
39 if (fcntl(fd, F_SETFL, val) == -1) 39 if (fcntl(fd, F_SETFL, val) == -1)
40 error("fcntl(%d, F_SETFL, O_NONBLOCK): %s", fd, strerror(errno)); 40 error("fcntl(%d, F_SETFL, O_NONBLOCK): %s", fd, strerror(errno));
41} 41}
42
43/* Characters considered whitespace in strsep calls. */
44#define WHITESPACE " \t\r\n"
45
46char *
47strdelim(char **s)
48{
49 char *old;
50 int wspace = 0;
51
52 if (*s == NULL)
53 return NULL;
54
55 old = *s;
56
57 *s = strpbrk(*s, WHITESPACE "=");
58 if (*s == NULL)
59 return (old);
60
61 /* Allow only one '=' to be skipped */
62 if (*s[0] == '=')
63 wspace = 1;
64 *s[0] = '\0';
65
66 *s += strspn(*s + 1, WHITESPACE) + 1;
67 if (*s[0] == '=' && !wspace)
68 *s += strspn(*s + 1, WHITESPACE) + 1;
69
70 return (old);
71}
diff --git a/clientloop.c b/clientloop.c
index 5df584ab2..f7ac7b3b0 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -16,7 +16,7 @@
16 */ 16 */
17 17
18#include "includes.h" 18#include "includes.h"
19RCSID("$OpenBSD: clientloop.c,v 1.27 2000/06/20 01:39:40 markus Exp $"); 19RCSID("$OpenBSD: clientloop.c,v 1.28 2000/07/13 23:14:08 provos Exp $");
20 20
21#include "xmalloc.h" 21#include "xmalloc.h"
22#include "ssh.h" 22#include "ssh.h"
@@ -778,7 +778,7 @@ client_loop(int have_pty, int escape_char_arg)
778 if (have_pty) 778 if (have_pty)
779 enter_raw_mode(); 779 enter_raw_mode();
780 780
781 /* Check if we should immediately send of on stdin. */ 781 /* Check if we should immediately send eof on stdin. */
782 if (!compat20) 782 if (!compat20)
783 client_check_initial_eof_on_stdin(); 783 client_check_initial_eof_on_stdin();
784 784
diff --git a/readconf.c b/readconf.c
index c514e9b59..06cfaa1a3 100644
--- a/readconf.c
+++ b/readconf.c
@@ -14,7 +14,7 @@
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$OpenBSD: readconf.c,v 1.41 2000/07/11 19:17:44 deraadt Exp $"); 17RCSID("$OpenBSD: readconf.c,v 1.43 2000/07/14 22:59:46 markus Exp $");
18 18
19#include "ssh.h" 19#include "ssh.h"
20#include "cipher.h" 20#include "cipher.h"
@@ -164,10 +164,6 @@ static struct {
164 { NULL, 0 } 164 { NULL, 0 }
165}; 165};
166 166
167/* Characters considered whitespace in strsep calls. */
168#define WHITESPACE " \t\r\n="
169
170
171/* 167/*
172 * Adds a local TCP/IP port forward to options. Never returns if there is an 168 * Adds a local TCP/IP port forward to options. Never returns if there is an
173 * error. 169 * error.
@@ -241,13 +237,15 @@ process_config_line(Options *options, const char *host,
241 int opcode, *intptr, value; 237 int opcode, *intptr, value;
242 u_short fwd_port, fwd_host_port; 238 u_short fwd_port, fwd_host_port;
243 239
244 /* Skip leading whitespace. */ 240 s = line;
245 s = line + strspn(line, WHITESPACE); 241 /* Get the keyword. (Each line is supposed to begin with a keyword). */
246 if (!*s || *s == '\n' || *s == '#') 242 keyword = strdelim(&s);
243 /* Ignore leading whitespace. */
244 if (*keyword == '\0')
245 keyword = strdelim(&s);
246 if (!*keyword || *keyword == '\n' || *keyword == '#')
247 return 0; 247 return 0;
248 248
249 /* Get the keyword. (Each line is supposed to begin with a keyword). */
250 keyword = strsep(&s, WHITESPACE);
251 opcode = parse_token(keyword, filename, linenum); 249 opcode = parse_token(keyword, filename, linenum);
252 250
253 switch (opcode) { 251 switch (opcode) {
@@ -258,7 +256,7 @@ process_config_line(Options *options, const char *host,
258 case oForwardAgent: 256 case oForwardAgent:
259 intptr = &options->forward_agent; 257 intptr = &options->forward_agent;
260parse_flag: 258parse_flag:
261 arg = strsep(&s, WHITESPACE); 259 arg = strdelim(&s);
262 if (!arg || *arg == '\0') 260 if (!arg || *arg == '\0')
263 fatal("%.200s line %d: Missing yes/no argument.", filename, linenum); 261 fatal("%.200s line %d: Missing yes/no argument.", filename, linenum);
264 value = 0; /* To avoid compiler warning... */ 262 value = 0; /* To avoid compiler warning... */
@@ -344,7 +342,7 @@ parse_flag:
344 342
345 case oStrictHostKeyChecking: 343 case oStrictHostKeyChecking:
346 intptr = &options->strict_host_key_checking; 344 intptr = &options->strict_host_key_checking;
347 arg = strsep(&s, WHITESPACE); 345 arg = strdelim(&s);
348 if (!arg || *arg == '\0') 346 if (!arg || *arg == '\0')
349 fatal("%.200s line %d: Missing yes/no argument.", 347 fatal("%.200s line %d: Missing yes/no argument.",
350 filename, linenum); 348 filename, linenum);
@@ -379,7 +377,7 @@ parse_flag:
379 377
380 case oIdentityFile: 378 case oIdentityFile:
381 case oIdentityFile2: 379 case oIdentityFile2:
382 arg = strsep(&s, WHITESPACE); 380 arg = strdelim(&s);
383 if (!arg || *arg == '\0') 381 if (!arg || *arg == '\0')
384 fatal("%.200s line %d: Missing argument.", filename, linenum); 382 fatal("%.200s line %d: Missing argument.", filename, linenum);
385 if (*activep) { 383 if (*activep) {
@@ -404,7 +402,7 @@ parse_flag:
404 case oUser: 402 case oUser:
405 charptr = &options->user; 403 charptr = &options->user;
406parse_string: 404parse_string:
407 arg = strsep(&s, WHITESPACE); 405 arg = strdelim(&s);
408 if (!arg || *arg == '\0') 406 if (!arg || *arg == '\0')
409 fatal("%.200s line %d: Missing argument.", filename, linenum); 407 fatal("%.200s line %d: Missing argument.", filename, linenum);
410 if (*activep && *charptr == NULL) 408 if (*activep && *charptr == NULL)
@@ -434,7 +432,7 @@ parse_string:
434 case oProxyCommand: 432 case oProxyCommand:
435 charptr = &options->proxy_command; 433 charptr = &options->proxy_command;
436 string = xstrdup(""); 434 string = xstrdup("");
437 while ((arg = strsep(&s, WHITESPACE)) != NULL && *arg != '\0') { 435 while ((arg = strdelim(&s)) != NULL && *arg != '\0') {
438 string = xrealloc(string, strlen(string) + strlen(arg) + 2); 436 string = xrealloc(string, strlen(string) + strlen(arg) + 2);
439 strcat(string, " "); 437 strcat(string, " ");
440 strcat(string, arg); 438 strcat(string, arg);
@@ -448,7 +446,7 @@ parse_string:
448 case oPort: 446 case oPort:
449 intptr = &options->port; 447 intptr = &options->port;
450parse_int: 448parse_int:
451 arg = strsep(&s, WHITESPACE); 449 arg = strdelim(&s);
452 if (!arg || *arg == '\0') 450 if (!arg || *arg == '\0')
453 fatal("%.200s line %d: Missing argument.", filename, linenum); 451 fatal("%.200s line %d: Missing argument.", filename, linenum);
454 if (arg[0] < '0' || arg[0] > '9') 452 if (arg[0] < '0' || arg[0] > '9')
@@ -468,7 +466,7 @@ parse_int:
468 466
469 case oCipher: 467 case oCipher:
470 intptr = &options->cipher; 468 intptr = &options->cipher;
471 arg = strsep(&s, WHITESPACE); 469 arg = strdelim(&s);
472 if (!arg || *arg == '\0') 470 if (!arg || *arg == '\0')
473 fatal("%.200s line %d: Missing argument.", filename, linenum); 471 fatal("%.200s line %d: Missing argument.", filename, linenum);
474 value = cipher_number(arg); 472 value = cipher_number(arg);
@@ -480,7 +478,7 @@ parse_int:
480 break; 478 break;
481 479
482 case oCiphers: 480 case oCiphers:
483 arg = strsep(&s, WHITESPACE); 481 arg = strdelim(&s);
484 if (!arg || *arg == '\0') 482 if (!arg || *arg == '\0')
485 fatal("%.200s line %d: Missing argument.", filename, linenum); 483 fatal("%.200s line %d: Missing argument.", filename, linenum);
486 if (!ciphers_valid(arg)) 484 if (!ciphers_valid(arg))
@@ -492,7 +490,7 @@ parse_int:
492 490
493 case oProtocol: 491 case oProtocol:
494 intptr = &options->protocol; 492 intptr = &options->protocol;
495 arg = strsep(&s, WHITESPACE); 493 arg = strdelim(&s);
496 if (!arg || *arg == '\0') 494 if (!arg || *arg == '\0')
497 fatal("%.200s line %d: Missing argument.", filename, linenum); 495 fatal("%.200s line %d: Missing argument.", filename, linenum);
498 value = proto_spec(arg); 496 value = proto_spec(arg);
@@ -505,7 +503,7 @@ parse_int:
505 503
506 case oLogLevel: 504 case oLogLevel:
507 intptr = (int *) &options->log_level; 505 intptr = (int *) &options->log_level;
508 arg = strsep(&s, WHITESPACE); 506 arg = strdelim(&s);
509 value = log_level_number(arg); 507 value = log_level_number(arg);
510 if (value == (LogLevel) - 1) 508 if (value == (LogLevel) - 1)
511 fatal("%.200s line %d: unsupported log level '%s'\n", 509 fatal("%.200s line %d: unsupported log level '%s'\n",
@@ -515,14 +513,14 @@ parse_int:
515 break; 513 break;
516 514
517 case oRemoteForward: 515 case oRemoteForward:
518 arg = strsep(&s, WHITESPACE); 516 arg = strdelim(&s);
519 if (!arg || *arg == '\0') 517 if (!arg || *arg == '\0')
520 fatal("%.200s line %d: Missing argument.", filename, linenum); 518 fatal("%.200s line %d: Missing argument.", filename, linenum);
521 if (arg[0] < '0' || arg[0] > '9') 519 if (arg[0] < '0' || arg[0] > '9')
522 fatal("%.200s line %d: Badly formatted port number.", 520 fatal("%.200s line %d: Badly formatted port number.",
523 filename, linenum); 521 filename, linenum);
524 fwd_port = atoi(arg); 522 fwd_port = atoi(arg);
525 arg = strsep(&s, WHITESPACE); 523 arg = strdelim(&s);
526 if (!arg || *arg == '\0') 524 if (!arg || *arg == '\0')
527 fatal("%.200s line %d: Missing second argument.", 525 fatal("%.200s line %d: Missing second argument.",
528 filename, linenum); 526 filename, linenum);
@@ -534,14 +532,14 @@ parse_int:
534 break; 532 break;
535 533
536 case oLocalForward: 534 case oLocalForward:
537 arg = strsep(&s, WHITESPACE); 535 arg = strdelim(&s);
538 if (!arg || *arg == '\0') 536 if (!arg || *arg == '\0')
539 fatal("%.200s line %d: Missing argument.", filename, linenum); 537 fatal("%.200s line %d: Missing argument.", filename, linenum);
540 if (arg[0] < '0' || arg[0] > '9') 538 if (arg[0] < '0' || arg[0] > '9')
541 fatal("%.200s line %d: Badly formatted port number.", 539 fatal("%.200s line %d: Badly formatted port number.",
542 filename, linenum); 540 filename, linenum);
543 fwd_port = atoi(arg); 541 fwd_port = atoi(arg);
544 arg = strsep(&s, WHITESPACE); 542 arg = strdelim(&s);
545 if (!arg || *arg == '\0') 543 if (!arg || *arg == '\0')
546 fatal("%.200s line %d: Missing second argument.", 544 fatal("%.200s line %d: Missing second argument.",
547 filename, linenum); 545 filename, linenum);
@@ -554,18 +552,18 @@ parse_int:
554 552
555 case oHost: 553 case oHost:
556 *activep = 0; 554 *activep = 0;
557 while ((arg = strsep(&s, WHITESPACE)) != NULL && *arg != '\0') 555 while ((arg = strdelim(&s)) != NULL && *arg != '\0')
558 if (match_pattern(host, arg)) { 556 if (match_pattern(host, arg)) {
559 debug("Applying options for %.100s", arg); 557 debug("Applying options for %.100s", arg);
560 *activep = 1; 558 *activep = 1;
561 break; 559 break;
562 } 560 }
563 /* Avoid garbage check below, as strsep is done. */ 561 /* Avoid garbage check below, as strdelim is done. */
564 return 0; 562 return 0;
565 563
566 case oEscapeChar: 564 case oEscapeChar:
567 intptr = &options->escape_char; 565 intptr = &options->escape_char;
568 arg = strsep(&s, WHITESPACE); 566 arg = strdelim(&s);
569 if (!arg || *arg == '\0') 567 if (!arg || *arg == '\0')
570 fatal("%.200s line %d: Missing argument.", filename, linenum); 568 fatal("%.200s line %d: Missing argument.", filename, linenum);
571 if (arg[0] == '^' && arg[2] == 0 && 569 if (arg[0] == '^' && arg[2] == 0 &&
@@ -590,7 +588,7 @@ parse_int:
590 } 588 }
591 589
592 /* Check that there is no garbage at end of line. */ 590 /* Check that there is no garbage at end of line. */
593 if ((arg = strsep(&s, WHITESPACE)) != NULL && *arg != '\0') 591 if ((arg = strdelim(&s)) != NULL && *arg != '\0')
594 { 592 {
595 fatal("%.200s line %d: garbage at end of line; \"%.200s\".", 593 fatal("%.200s line %d: garbage at end of line; \"%.200s\".",
596 filename, linenum, arg); 594 filename, linenum, arg);
diff --git a/scp.c b/scp.c
index 5f849cc13..02feba9c1 100644
--- a/scp.c
+++ b/scp.c
@@ -45,7 +45,7 @@
45 */ 45 */
46 46
47#include "includes.h" 47#include "includes.h"
48RCSID("$OpenBSD: scp.c,v 1.32 2000/06/20 01:39:44 markus Exp $"); 48RCSID("$OpenBSD: scp.c,v 1.33 2000/07/13 23:19:31 provos Exp $");
49 49
50#include "ssh.h" 50#include "ssh.h"
51#include "xmalloc.h" 51#include "xmalloc.h"
@@ -889,7 +889,10 @@ bad: run_err("%s: %s", np, strerror(errno));
889 run_err("%s: set mode: %s", 889 run_err("%s: set mode: %s",
890 np, strerror(errno)); 890 np, strerror(errno));
891 } 891 }
892 (void) close(ofd); 892 if (close(ofd) == -1) {
893 wrerr = YES;
894 wrerrno = errno;
895 }
893 (void) response(); 896 (void) response();
894 if (setimes && wrerr == NO) { 897 if (setimes && wrerr == NO) {
895 setimes = 0; 898 setimes = 0;
@@ -1015,7 +1018,7 @@ run_err(const char *fmt,...)
1015 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1018 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1016 * SUCH DAMAGE. 1019 * SUCH DAMAGE.
1017 * 1020 *
1018 * $OpenBSD: scp.c,v 1.32 2000/06/20 01:39:44 markus Exp $ 1021 * $OpenBSD: scp.c,v 1.33 2000/07/13 23:19:31 provos Exp $
1019 */ 1022 */
1020 1023
1021char * 1024char *
diff --git a/servconf.c b/servconf.c
index 77ac84527..477204cfd 100644
--- a/servconf.c
+++ b/servconf.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: servconf.c,v 1.47 2000/07/10 16:30:25 ho Exp $"); 15RCSID("$OpenBSD: servconf.c,v 1.49 2000/07/14 22:59:46 markus Exp $");
16 16
17#include "ssh.h" 17#include "ssh.h"
18#include "servconf.h" 18#include "servconf.h"
@@ -164,8 +164,6 @@ fill_default_server_options(ServerOptions *options)
164 options->max_startups = 10; 164 options->max_startups = 10;
165} 165}
166 166
167#define WHITESPACE " \t\r\n="
168
169/* Keyword tokens. */ 167/* Keyword tokens. */
170typedef enum { 168typedef enum {
171 sBadOption, /* == unknown option */ 169 sBadOption, /* == unknown option */
@@ -318,10 +316,13 @@ read_server_config(ServerOptions *options, const char *filename)
318 linenum = 0; 316 linenum = 0;
319 while (fgets(line, sizeof(line), f)) { 317 while (fgets(line, sizeof(line), f)) {
320 linenum++; 318 linenum++;
321 cp = line + strspn(line, WHITESPACE); 319 cp = line;
322 if (!*cp || *cp == '#') 320 arg = strdelim(&cp);
321 /* Ignore leading whitespace */
322 if (*arg == '\0')
323 arg = strdelim(&cp);
324 if (!*arg || *arg == '#')
323 continue; 325 continue;
324 arg = strsep(&cp, WHITESPACE);
325 opcode = parse_token(arg, filename, linenum); 326 opcode = parse_token(arg, filename, linenum);
326 switch (opcode) { 327 switch (opcode) {
327 case sBadOption: 328 case sBadOption:
@@ -337,7 +338,7 @@ read_server_config(ServerOptions *options, const char *filename)
337 if (options->num_ports >= MAX_PORTS) 338 if (options->num_ports >= MAX_PORTS)
338 fatal("%s line %d: too many ports.\n", 339 fatal("%s line %d: too many ports.\n",
339 filename, linenum); 340 filename, linenum);
340 arg = strsep(&cp, WHITESPACE); 341 arg = strdelim(&cp);
341 if (!arg || *arg == '\0') 342 if (!arg || *arg == '\0')
342 fatal("%s line %d: missing port number.\n", 343 fatal("%s line %d: missing port number.\n",
343 filename, linenum); 344 filename, linenum);
@@ -347,7 +348,7 @@ read_server_config(ServerOptions *options, const char *filename)
347 case sServerKeyBits: 348 case sServerKeyBits:
348 intptr = &options->server_key_bits; 349 intptr = &options->server_key_bits;
349parse_int: 350parse_int:
350 arg = strsep(&cp, WHITESPACE); 351 arg = strdelim(&cp);
351 if (!arg || *arg == '\0') { 352 if (!arg || *arg == '\0') {
352 fprintf(stderr, "%s line %d: missing integer value.\n", 353 fprintf(stderr, "%s line %d: missing integer value.\n",
353 filename, linenum); 354 filename, linenum);
@@ -367,7 +368,7 @@ parse_int:
367 goto parse_int; 368 goto parse_int;
368 369
369 case sListenAddress: 370 case sListenAddress:
370 arg = strsep(&cp, WHITESPACE); 371 arg = strdelim(&cp);
371 if (!arg || *arg == '\0') 372 if (!arg || *arg == '\0')
372 fatal("%s line %d: missing inet addr.\n", 373 fatal("%s line %d: missing inet addr.\n",
373 filename, linenum); 374 filename, linenum);
@@ -379,7 +380,7 @@ parse_int:
379 charptr = (opcode == sHostKeyFile ) ? 380 charptr = (opcode == sHostKeyFile ) ?
380 &options->host_key_file : &options->host_dsa_key_file; 381 &options->host_key_file : &options->host_dsa_key_file;
381parse_filename: 382parse_filename:
382 arg = strsep(&cp, WHITESPACE); 383 arg = strdelim(&cp);
383 if (!arg || *arg == '\0') { 384 if (!arg || *arg == '\0') {
384 fprintf(stderr, "%s line %d: missing file name.\n", 385 fprintf(stderr, "%s line %d: missing file name.\n",
385 filename, linenum); 386 filename, linenum);
@@ -396,12 +397,12 @@ parse_filename:
396 case sRandomSeedFile: 397 case sRandomSeedFile:
397 fprintf(stderr, "%s line %d: \"randomseed\" option is obsolete.\n", 398 fprintf(stderr, "%s line %d: \"randomseed\" option is obsolete.\n",
398 filename, linenum); 399 filename, linenum);
399 arg = strsep(&cp, WHITESPACE); 400 arg = strdelim(&cp);
400 break; 401 break;
401 402
402 case sPermitRootLogin: 403 case sPermitRootLogin:
403 intptr = &options->permit_root_login; 404 intptr = &options->permit_root_login;
404 arg = strsep(&cp, WHITESPACE); 405 arg = strdelim(&cp);
405 if (!arg || *arg == '\0') { 406 if (!arg || *arg == '\0') {
406 fprintf(stderr, "%s line %d: missing yes/without-password/no argument.\n", 407 fprintf(stderr, "%s line %d: missing yes/without-password/no argument.\n",
407 filename, linenum); 408 filename, linenum);
@@ -425,7 +426,7 @@ parse_filename:
425 case sIgnoreRhosts: 426 case sIgnoreRhosts:
426 intptr = &options->ignore_rhosts; 427 intptr = &options->ignore_rhosts;
427parse_flag: 428parse_flag:
428 arg = strsep(&cp, WHITESPACE); 429 arg = strdelim(&cp);
429 if (!arg || *arg == '\0') { 430 if (!arg || *arg == '\0') {
430 fprintf(stderr, "%s line %d: missing yes/no argument.\n", 431 fprintf(stderr, "%s line %d: missing yes/no argument.\n",
431 filename, linenum); 432 filename, linenum);
@@ -540,7 +541,7 @@ parse_flag:
540 541
541 case sLogFacility: 542 case sLogFacility:
542 intptr = (int *) &options->log_facility; 543 intptr = (int *) &options->log_facility;
543 arg = strsep(&cp, WHITESPACE); 544 arg = strdelim(&cp);
544 value = log_facility_number(arg); 545 value = log_facility_number(arg);
545 if (value == (SyslogFacility) - 1) 546 if (value == (SyslogFacility) - 1)
546 fatal("%.200s line %d: unsupported log facility '%s'\n", 547 fatal("%.200s line %d: unsupported log facility '%s'\n",
@@ -551,7 +552,7 @@ parse_flag:
551 552
552 case sLogLevel: 553 case sLogLevel:
553 intptr = (int *) &options->log_level; 554 intptr = (int *) &options->log_level;
554 arg = strsep(&cp, WHITESPACE); 555 arg = strdelim(&cp);
555 value = log_level_number(arg); 556 value = log_level_number(arg);
556 if (value == (LogLevel) - 1) 557 if (value == (LogLevel) - 1)
557 fatal("%.200s line %d: unsupported log level '%s'\n", 558 fatal("%.200s line %d: unsupported log level '%s'\n",
@@ -561,7 +562,7 @@ parse_flag:
561 break; 562 break;
562 563
563 case sAllowUsers: 564 case sAllowUsers:
564 while ((arg = strsep(&cp, WHITESPACE)) && *arg != '\0') { 565 while ((arg = strdelim(&cp)) && *arg != '\0') {
565 if (options->num_allow_users >= MAX_ALLOW_USERS) 566 if (options->num_allow_users >= MAX_ALLOW_USERS)
566 fatal("%s line %d: too many allow users.\n", 567 fatal("%s line %d: too many allow users.\n",
567 filename, linenum); 568 filename, linenum);
@@ -570,7 +571,7 @@ parse_flag:
570 break; 571 break;
571 572
572 case sDenyUsers: 573 case sDenyUsers:
573 while ((arg = strsep(&cp, WHITESPACE)) && *arg != '\0') { 574 while ((arg = strdelim(&cp)) && *arg != '\0') {
574 if (options->num_deny_users >= MAX_DENY_USERS) 575 if (options->num_deny_users >= MAX_DENY_USERS)
575 fatal( "%s line %d: too many deny users.\n", 576 fatal( "%s line %d: too many deny users.\n",
576 filename, linenum); 577 filename, linenum);
@@ -579,7 +580,7 @@ parse_flag:
579 break; 580 break;
580 581
581 case sAllowGroups: 582 case sAllowGroups:
582 while ((arg = strsep(&cp, WHITESPACE)) && *arg != '\0') { 583 while ((arg = strdelim(&cp)) && *arg != '\0') {
583 if (options->num_allow_groups >= MAX_ALLOW_GROUPS) 584 if (options->num_allow_groups >= MAX_ALLOW_GROUPS)
584 fatal("%s line %d: too many allow groups.\n", 585 fatal("%s line %d: too many allow groups.\n",
585 filename, linenum); 586 filename, linenum);
@@ -588,7 +589,7 @@ parse_flag:
588 break; 589 break;
589 590
590 case sDenyGroups: 591 case sDenyGroups:
591 while ((arg = strsep(&cp, WHITESPACE)) && *arg != '\0') { 592 while ((arg = strdelim(&cp)) && *arg != '\0') {
592 if (options->num_deny_groups >= MAX_DENY_GROUPS) 593 if (options->num_deny_groups >= MAX_DENY_GROUPS)
593 fatal("%s line %d: too many deny groups.\n", 594 fatal("%s line %d: too many deny groups.\n",
594 filename, linenum); 595 filename, linenum);
@@ -597,7 +598,7 @@ parse_flag:
597 break; 598 break;
598 599
599 case sCiphers: 600 case sCiphers:
600 arg = strsep(&cp, WHITESPACE); 601 arg = strdelim(&cp);
601 if (!arg || *arg == '\0') 602 if (!arg || *arg == '\0')
602 fatal("%s line %d: Missing argument.", filename, linenum); 603 fatal("%s line %d: Missing argument.", filename, linenum);
603 if (!ciphers_valid(arg)) 604 if (!ciphers_valid(arg))
@@ -609,7 +610,7 @@ parse_flag:
609 610
610 case sProtocol: 611 case sProtocol:
611 intptr = &options->protocol; 612 intptr = &options->protocol;
612 arg = strsep(&cp, WHITESPACE); 613 arg = strdelim(&cp);
613 if (!arg || *arg == '\0') 614 if (!arg || *arg == '\0')
614 fatal("%s line %d: Missing argument.", filename, linenum); 615 fatal("%s line %d: Missing argument.", filename, linenum);
615 value = proto_spec(arg); 616 value = proto_spec(arg);
@@ -625,7 +626,7 @@ parse_flag:
625 fatal("%s line %d: too many subsystems defined.", 626 fatal("%s line %d: too many subsystems defined.",
626 filename, linenum); 627 filename, linenum);
627 } 628 }
628 arg = strsep(&cp, WHITESPACE); 629 arg = strdelim(&cp);
629 if (!arg || *arg == '\0') 630 if (!arg || *arg == '\0')
630 fatal("%s line %d: Missing subsystem name.", 631 fatal("%s line %d: Missing subsystem name.",
631 filename, linenum); 632 filename, linenum);
@@ -634,7 +635,7 @@ parse_flag:
634 fatal("%s line %d: Subsystem '%s' already defined.", 635 fatal("%s line %d: Subsystem '%s' already defined.",
635 filename, linenum, arg); 636 filename, linenum, arg);
636 options->subsystem_name[options->num_subsystems] = xstrdup(arg); 637 options->subsystem_name[options->num_subsystems] = xstrdup(arg);
637 arg = strsep(&cp, WHITESPACE); 638 arg = strdelim(&cp);
638 if (!arg || *arg == '\0') 639 if (!arg || *arg == '\0')
639 fatal("%s line %d: Missing subsystem command.", 640 fatal("%s line %d: Missing subsystem command.",
640 filename, linenum); 641 filename, linenum);
@@ -651,7 +652,7 @@ parse_flag:
651 filename, linenum, arg, opcode); 652 filename, linenum, arg, opcode);
652 exit(1); 653 exit(1);
653 } 654 }
654 if ((arg = strsep(&cp, WHITESPACE)) != NULL && *arg != '\0') { 655 if ((arg = strdelim(&cp)) != NULL && *arg != '\0') {
655 fprintf(stderr, 656 fprintf(stderr,
656 "%s line %d: garbage at end of line; \"%.200s\".\n", 657 "%s line %d: garbage at end of line; \"%.200s\".\n",
657 filename, linenum, arg); 658 filename, linenum, arg);
diff --git a/ssh-keygen.c b/ssh-keygen.c
index b38ebfb91..8a03f0d8d 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -7,7 +7,7 @@
7 */ 7 */
8 8
9#include "includes.h" 9#include "includes.h"
10RCSID("$OpenBSD: ssh-keygen.c,v 1.28 2000/07/07 03:55:04 todd Exp $"); 10RCSID("$OpenBSD: ssh-keygen.c,v 1.29 2000/07/15 04:01:37 djm Exp $");
11 11
12#include <openssl/evp.h> 12#include <openssl/evp.h>
13#include <openssl/pem.h> 13#include <openssl/pem.h>
@@ -660,7 +660,7 @@ main(int ac, char **av)
660 snprintf(dotsshdir, sizeof dotsshdir, "%s/%s", pw->pw_dir, SSH_USER_DIR); 660 snprintf(dotsshdir, sizeof dotsshdir, "%s/%s", pw->pw_dir, SSH_USER_DIR);
661 if (strstr(identity_file, dotsshdir) != NULL && 661 if (strstr(identity_file, dotsshdir) != NULL &&
662 stat(dotsshdir, &st) < 0) { 662 stat(dotsshdir, &st) < 0) {
663 if (mkdir(dotsshdir, 0755) < 0) 663 if (mkdir(dotsshdir, 0700) < 0)
664 error("Could not create directory '%s'.", dotsshdir); 664 error("Could not create directory '%s'.", dotsshdir);
665 else if (!quiet) 665 else if (!quiet)
666 printf("Created directory '%s'.\n", dotsshdir); 666 printf("Created directory '%s'.\n", dotsshdir);
diff --git a/ssh.c b/ssh.c
index be2ba4469..c2faf3882 100644
--- a/ssh.c
+++ b/ssh.c
@@ -11,7 +11,7 @@
11 */ 11 */
12 12
13#include "includes.h" 13#include "includes.h"
14RCSID("$OpenBSD: ssh.c,v 1.56 2000/06/20 01:39:44 markus Exp $"); 14RCSID("$OpenBSD: ssh.c,v 1.57 2000/07/15 04:01:37 djm Exp $");
15 15
16#include <openssl/evp.h> 16#include <openssl/evp.h>
17#include <openssl/dsa.h> 17#include <openssl/dsa.h>
@@ -622,7 +622,7 @@ main(int ac, char **av)
622 */ 622 */
623 snprintf(buf, sizeof buf, "%.100s/%.100s", pw->pw_dir, SSH_USER_DIR); 623 snprintf(buf, sizeof buf, "%.100s/%.100s", pw->pw_dir, SSH_USER_DIR);
624 if (stat(buf, &st) < 0) 624 if (stat(buf, &st) < 0)
625 if (mkdir(buf, 0755) < 0) 625 if (mkdir(buf, 0700) < 0)
626 error("Could not create directory '%.200s'.", buf); 626 error("Could not create directory '%.200s'.", buf);
627 627
628 /* Check if the connection failed, and try "rsh" if appropriate. */ 628 /* Check if the connection failed, and try "rsh" if appropriate. */
diff --git a/ssh.h b/ssh.h
index 213f73def..f3f049fcc 100644
--- a/ssh.h
+++ b/ssh.h
@@ -13,7 +13,7 @@
13 * 13 *
14 */ 14 */
15 15
16/* RCSID("$OpenBSD: ssh.h,v 1.47 2000/06/20 01:39:45 markus Exp $"); */ 16/* RCSID("$OpenBSD: ssh.h,v 1.48 2000/07/13 22:53:21 provos Exp $"); */
17 17
18#ifndef SSH_H 18#ifndef SSH_H
19#define SSH_H 19#define SSH_H
@@ -489,6 +489,9 @@ char *tilde_expand_filename(const char *filename, uid_t my_uid);
489/* remove newline at end of string */ 489/* remove newline at end of string */
490char *chop(char *s); 490char *chop(char *s);
491 491
492/* return next token in configuration line */
493char *strdelim(char **s);
494
492/* set filedescriptor to non-blocking */ 495/* set filedescriptor to non-blocking */
493void set_nonblock(int fd); 496void set_nonblock(int fd);
494 497