summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--auth-rhosts.c4
-rw-r--r--auth1.c6
-rw-r--r--auth2-chall.c16
-rw-r--r--auth2.c56
-rw-r--r--authfd.c8
-rw-r--r--authfile.c16
-rw-r--r--canohost.c14
-rw-r--r--channels.c74
-rw-r--r--cipher.c63
-rw-r--r--clientloop.c60
-rw-r--r--deattack.c7
-rw-r--r--dh.c4
-rw-r--r--hostfile.c6
-rw-r--r--kex.c33
-rw-r--r--kexdh.c8
-rw-r--r--kexgex.c8
-rw-r--r--key.c16
-rw-r--r--nchan.c14
-rw-r--r--packet.c16
-rw-r--r--radix.c4
-rw-r--r--readpass.c4
-rw-r--r--scp.c9
-rw-r--r--servconf.c10
-rw-r--r--serverloop.c46
-rw-r--r--session.c69
-rw-r--r--sftp-client.c18
-rw-r--r--sftp-glob.c20
-rw-r--r--sftp-int.c30
-rw-r--r--sftp-server.c90
-rw-r--r--sftp.c6
-rw-r--r--ssh-add.c12
-rw-r--r--ssh-agent.c42
-rw-r--r--ssh-keygen.c24
-rw-r--r--ssh-keyscan.c44
-rw-r--r--ssh.c30
-rw-r--r--sshconnect.c12
-rw-r--r--sshconnect1.c20
-rw-r--r--sshconnect2.c38
-rw-r--r--sshd.c37
40 files changed, 510 insertions, 497 deletions
diff --git a/ChangeLog b/ChangeLog
index a663e1210..a7497b581 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -67,6 +67,17 @@
67 [ssh-keygen.c] 67 [ssh-keygen.c]
68 try to decode ssh-3.0.0 private rsa keys 68 try to decode ssh-3.0.0 private rsa keys
69 (allow migration to openssh, not vice versa), #910 69 (allow migration to openssh, not vice versa), #910
70 - itojun@cvs.openbsd.org 2001/06/23 15:12:20
71 [auth1.c auth2.c auth2-chall.c authfd.c authfile.c auth-rhosts.c
72 canohost.c channels.c cipher.c clientloop.c deattack.c dh.c
73 hostfile.c kex.c kexdh.c kexgex.c key.c nchan.c packet.c radix.c
74 readpass.c scp.c servconf.c serverloop.c session.c sftp.c
75 sftp-client.c sftp-glob.c sftp-int.c sftp-server.c ssh-add.c
76 ssh-agent.c ssh.c sshconnect1.c sshconnect2.c sshconnect.c sshd.c
77 ssh-keygen.c ssh-keyscan.c]
78 more strict prototypes. raise warning level in Makefile.inc.
79 markus ok'ed
80 TODO; cleanup headers
70 81
7120010622 8220010622
72 - (stevesk) handle systems without pw_expire and pw_change. 83 - (stevesk) handle systems without pw_expire and pw_change.
@@ -5751,4 +5762,4 @@
5751 - Wrote replacements for strlcpy and mkdtemp 5762 - Wrote replacements for strlcpy and mkdtemp
5752 - Released 1.0pre1 5763 - Released 1.0pre1
5753 5764
5754$Id: ChangeLog,v 1.1314 2001/06/25 04:47:54 mouring Exp $ 5765$Id: ChangeLog,v 1.1315 2001/06/25 05:01:22 mouring Exp $
diff --git a/auth-rhosts.c b/auth-rhosts.c
index 324a0f925..9ba64dbc3 100644
--- a/auth-rhosts.c
+++ b/auth-rhosts.c
@@ -14,7 +14,7 @@
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$OpenBSD: auth-rhosts.c,v 1.23 2001/04/12 19:15:24 markus Exp $"); 17RCSID("$OpenBSD: auth-rhosts.c,v 1.24 2001/06/23 15:12:17 itojun Exp $");
18 18
19#include "packet.h" 19#include "packet.h"
20#include "xmalloc.h" 20#include "xmalloc.h"
@@ -34,7 +34,7 @@ extern ServerOptions options;
34 * based on the file, and returns zero otherwise. 34 * based on the file, and returns zero otherwise.
35 */ 35 */
36 36
37int 37static int
38check_rhosts_file(const char *filename, const char *hostname, 38check_rhosts_file(const char *filename, const char *hostname,
39 const char *ipaddr, const char *client_user, 39 const char *ipaddr, const char *client_user,
40 const char *server_user) 40 const char *server_user)
diff --git a/auth1.c b/auth1.c
index 5ab6b06f1..d5b7fa7c8 100644
--- a/auth1.c
+++ b/auth1.c
@@ -10,7 +10,7 @@
10 */ 10 */
11 11
12#include "includes.h" 12#include "includes.h"
13RCSID("$OpenBSD: auth1.c,v 1.23 2001/05/18 14:13:28 markus Exp $"); 13RCSID("$OpenBSD: auth1.c,v 1.24 2001/06/23 15:12:17 itojun Exp $");
14 14
15#include "xmalloc.h" 15#include "xmalloc.h"
16#include "rsa.h" 16#include "rsa.h"
@@ -35,7 +35,7 @@ extern char *aixloginmsg;
35/* 35/*
36 * convert ssh auth msg type into description 36 * convert ssh auth msg type into description
37 */ 37 */
38char * 38static char *
39get_authname(int type) 39get_authname(int type)
40{ 40{
41 static char buf[1024]; 41 static char buf[1024];
@@ -64,7 +64,7 @@ get_authname(int type)
64 * read packets, try to authenticate the user and 64 * read packets, try to authenticate the user and
65 * return only if authentication is successful 65 * return only if authentication is successful
66 */ 66 */
67void 67static void
68do_authloop(Authctxt *authctxt) 68do_authloop(Authctxt *authctxt)
69{ 69{
70 int authenticated = 0; 70 int authenticated = 0;
diff --git a/auth2-chall.c b/auth2-chall.c
index be741010e..5afd7d769 100644
--- a/auth2-chall.c
+++ b/auth2-chall.c
@@ -23,7 +23,7 @@
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: auth2-chall.c,v 1.6 2001/06/03 20:06:11 markus Exp $"); 26RCSID("$OpenBSD: auth2-chall.c,v 1.7 2001/06/23 15:12:17 itojun Exp $");
27 27
28#include "ssh2.h" 28#include "ssh2.h"
29#include "auth.h" 29#include "auth.h"
@@ -33,9 +33,9 @@ RCSID("$OpenBSD: auth2-chall.c,v 1.6 2001/06/03 20:06:11 markus Exp $");
33#include "auth.h" 33#include "auth.h"
34#include "log.h" 34#include "log.h"
35 35
36static int auth2_challenge_start(Authctxt *authctxt); 36static int auth2_challenge_start(Authctxt *);
37static int send_userauth_info_request(Authctxt *authctxt); 37static int send_userauth_info_request(Authctxt *);
38static void input_userauth_info_response(int type, int plen, void *ctxt); 38static void input_userauth_info_response(int, int, void *);
39 39
40#ifdef BSD_AUTH 40#ifdef BSD_AUTH
41extern KbdintDevice bsdauth_device; 41extern KbdintDevice bsdauth_device;
@@ -64,7 +64,7 @@ struct KbdintAuthctxt
64 KbdintDevice *device; 64 KbdintDevice *device;
65}; 65};
66 66
67KbdintAuthctxt * 67static KbdintAuthctxt *
68kbdint_alloc(const char *devs) 68kbdint_alloc(const char *devs)
69{ 69{
70 KbdintAuthctxt *kbdintctxt; 70 KbdintAuthctxt *kbdintctxt;
@@ -89,7 +89,7 @@ kbdint_alloc(const char *devs)
89 89
90 return kbdintctxt; 90 return kbdintctxt;
91} 91}
92void 92static void
93kbdint_reset_device(KbdintAuthctxt *kbdintctxt) 93kbdint_reset_device(KbdintAuthctxt *kbdintctxt)
94{ 94{
95 if (kbdintctxt->ctxt) { 95 if (kbdintctxt->ctxt) {
@@ -98,7 +98,7 @@ kbdint_reset_device(KbdintAuthctxt *kbdintctxt)
98 } 98 }
99 kbdintctxt->device = NULL; 99 kbdintctxt->device = NULL;
100} 100}
101void 101static void
102kbdint_free(KbdintAuthctxt *kbdintctxt) 102kbdint_free(KbdintAuthctxt *kbdintctxt)
103{ 103{
104 if (kbdintctxt->device) 104 if (kbdintctxt->device)
@@ -110,7 +110,7 @@ kbdint_free(KbdintAuthctxt *kbdintctxt)
110 xfree(kbdintctxt); 110 xfree(kbdintctxt);
111} 111}
112/* get next device */ 112/* get next device */
113int 113static int
114kbdint_next_device(KbdintAuthctxt *kbdintctxt) 114kbdint_next_device(KbdintAuthctxt *kbdintctxt)
115{ 115{
116 size_t len; 116 size_t len;
diff --git a/auth2.c b/auth2.c
index 272683bb2..ca0526649 100644
--- a/auth2.c
+++ b/auth2.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: auth2.c,v 1.65 2001/06/23 03:04:43 markus Exp $"); 26RCSID("$OpenBSD: auth2.c,v 1.66 2001/06/23 15:12:17 itojun Exp $");
27 27
28#include <openssl/evp.h> 28#include <openssl/evp.h>
29 29
@@ -74,25 +74,23 @@ struct Authmethod {
74 74
75/* protocol */ 75/* protocol */
76 76
77void input_service_request(int type, int plen, void *ctxt); 77static void input_service_request(int, int, void *);
78void input_userauth_request(int type, int plen, void *ctxt); 78static void input_userauth_request(int, int, void *);
79void protocol_error(int type, int plen, void *ctxt); 79static void protocol_error(int, int, void *);
80 80
81/* helper */ 81/* helper */
82Authmethod *authmethod_lookup(const char *name); 82static Authmethod *authmethod_lookup(const char *);
83char *authmethods_get(void); 83char *authmethods_get(void);
84int user_key_allowed(struct passwd *pw, Key *key); 84static int user_key_allowed(struct passwd *, Key *);
85int 85static int hostbased_key_allowed(struct passwd *, const char *, char *, Key *);
86hostbased_key_allowed(struct passwd *pw, const char *cuser, char *chost,
87 Key *key);
88 86
89/* auth */ 87/* auth */
90void userauth_banner(void); 88static void userauth_banner(void);
91int userauth_none(Authctxt *authctxt); 89static int userauth_none(Authctxt *);
92int userauth_passwd(Authctxt *authctxt); 90static int userauth_passwd(Authctxt *);
93int userauth_pubkey(Authctxt *authctxt); 91static int userauth_pubkey(Authctxt *);
94int userauth_hostbased(Authctxt *authctxt); 92static int userauth_hostbased(Authctxt *);
95int userauth_kbdint(Authctxt *authctxt); 93static int userauth_kbdint(Authctxt *);
96 94
97Authmethod authmethods[] = { 95Authmethod authmethods[] = {
98 {"none", 96 {"none",
@@ -136,7 +134,7 @@ do_authentication2()
136 do_authenticated(authctxt); 134 do_authenticated(authctxt);
137} 135}
138 136
139void 137static void
140protocol_error(int type, int plen, void *ctxt) 138protocol_error(int type, int plen, void *ctxt)
141{ 139{
142 log("auth: protocol error: type %d plen %d", type, plen); 140 log("auth: protocol error: type %d plen %d", type, plen);
@@ -146,7 +144,7 @@ protocol_error(int type, int plen, void *ctxt)
146 packet_write_wait(); 144 packet_write_wait();
147} 145}
148 146
149void 147static void
150input_service_request(int type, int plen, void *ctxt) 148input_service_request(int type, int plen, void *ctxt)
151{ 149{
152 Authctxt *authctxt = ctxt; 150 Authctxt *authctxt = ctxt;
@@ -179,7 +177,7 @@ input_service_request(int type, int plen, void *ctxt)
179 xfree(service); 177 xfree(service);
180} 178}
181 179
182void 180static void
183input_userauth_request(int type, int plen, void *ctxt) 181input_userauth_request(int type, int plen, void *ctxt)
184{ 182{
185 Authctxt *authctxt = ctxt; 183 Authctxt *authctxt = ctxt;
@@ -297,7 +295,7 @@ userauth_finish(Authctxt *authctxt, int authenticated, char *method)
297 } 295 }
298} 296}
299 297
300void 298static void
301userauth_banner(void) 299userauth_banner(void)
302{ 300{
303 struct stat st; 301 struct stat st;
@@ -328,7 +326,7 @@ done:
328 return; 326 return;
329} 327}
330 328
331int 329static int
332userauth_none(Authctxt *authctxt) 330userauth_none(Authctxt *authctxt)
333{ 331{
334 /* disable method "none", only allowed one time */ 332 /* disable method "none", only allowed one time */
@@ -354,7 +352,7 @@ userauth_none(Authctxt *authctxt)
354#endif /* USE_PAM */ 352#endif /* USE_PAM */
355} 353}
356 354
357int 355static int
358userauth_passwd(Authctxt *authctxt) 356userauth_passwd(Authctxt *authctxt)
359{ 357{
360 char *password; 358 char *password;
@@ -383,7 +381,7 @@ userauth_passwd(Authctxt *authctxt)
383 return authenticated; 381 return authenticated;
384} 382}
385 383
386int 384static int
387userauth_kbdint(Authctxt *authctxt) 385userauth_kbdint(Authctxt *authctxt)
388{ 386{
389 int authenticated = 0; 387 int authenticated = 0;
@@ -411,7 +409,7 @@ userauth_kbdint(Authctxt *authctxt)
411 return authenticated; 409 return authenticated;
412} 410}
413 411
414int 412static int
415userauth_pubkey(Authctxt *authctxt) 413userauth_pubkey(Authctxt *authctxt)
416{ 414{
417 Buffer b; 415 Buffer b;
@@ -517,7 +515,7 @@ userauth_pubkey(Authctxt *authctxt)
517 return authenticated; 515 return authenticated;
518} 516}
519 517
520int 518static int
521userauth_hostbased(Authctxt *authctxt) 519userauth_hostbased(Authctxt *authctxt)
522{ 520{
523 Buffer b; 521 Buffer b;
@@ -634,7 +632,7 @@ authmethods_get(void)
634 return list; 632 return list;
635} 633}
636 634
637Authmethod * 635static Authmethod *
638authmethod_lookup(const char *name) 636authmethod_lookup(const char *name)
639{ 637{
640 Authmethod *method = NULL; 638 Authmethod *method = NULL;
@@ -649,7 +647,7 @@ authmethod_lookup(const char *name)
649} 647}
650 648
651/* return 1 if user allows given key */ 649/* return 1 if user allows given key */
652int 650static int
653user_key_allowed2(struct passwd *pw, Key *key, char *file) 651user_key_allowed2(struct passwd *pw, Key *key, char *file)
654{ 652{
655 char line[8192]; 653 char line[8192];
@@ -737,7 +735,7 @@ user_key_allowed2(struct passwd *pw, Key *key, char *file)
737} 735}
738 736
739/* check whether given key is in .ssh/authorized_keys* */ 737/* check whether given key is in .ssh/authorized_keys* */
740int 738static int
741user_key_allowed(struct passwd *pw, Key *key) 739user_key_allowed(struct passwd *pw, Key *key)
742{ 740{
743 int success; 741 int success;
@@ -757,7 +755,7 @@ user_key_allowed(struct passwd *pw, Key *key)
757} 755}
758 756
759/* return 1 if given hostkey is allowed */ 757/* return 1 if given hostkey is allowed */
760int 758static int
761hostbased_key_allowed(struct passwd *pw, const char *cuser, char *chost, 759hostbased_key_allowed(struct passwd *pw, const char *cuser, char *chost,
762 Key *key) 760 Key *key)
763{ 761{
diff --git a/authfd.c b/authfd.c
index 9f47b0ae8..dfa33a978 100644
--- a/authfd.c
+++ b/authfd.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: authfd.c,v 1.40 2001/06/07 20:23:03 markus Exp $"); 38RCSID("$OpenBSD: authfd.c,v 1.41 2001/06/23 15:12:17 itojun Exp $");
39 39
40#include <openssl/evp.h> 40#include <openssl/evp.h>
41 41
@@ -96,7 +96,7 @@ ssh_get_authentication_socket(void)
96 return sock; 96 return sock;
97} 97}
98 98
99int 99static int
100ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply) 100ssh_request_reply(AuthenticationConnection *auth, Buffer *request, Buffer *reply)
101{ 101{
102 int l, len; 102 int l, len;
@@ -419,7 +419,7 @@ ssh_agent_sign(AuthenticationConnection *auth,
419 419
420/* Encode key for a message to the agent. */ 420/* Encode key for a message to the agent. */
421 421
422void 422static void
423ssh_encode_identity_rsa1(Buffer *b, RSA *key, const char *comment) 423ssh_encode_identity_rsa1(Buffer *b, RSA *key, const char *comment)
424{ 424{
425 buffer_clear(b); 425 buffer_clear(b);
@@ -435,7 +435,7 @@ ssh_encode_identity_rsa1(Buffer *b, RSA *key, const char *comment)
435 buffer_put_cstring(b, comment); 435 buffer_put_cstring(b, comment);
436} 436}
437 437
438void 438static void
439ssh_encode_identity_ssh2(Buffer *b, Key *key, const char *comment) 439ssh_encode_identity_ssh2(Buffer *b, Key *key, const char *comment)
440{ 440{
441 buffer_clear(b); 441 buffer_clear(b);
diff --git a/authfile.c b/authfile.c
index c4da9aad3..b4b985c95 100644
--- a/authfile.c
+++ b/authfile.c
@@ -36,7 +36,7 @@
36 */ 36 */
37 37
38#include "includes.h" 38#include "includes.h"
39RCSID("$OpenBSD: authfile.c,v 1.36 2001/06/07 20:23:03 markus Exp $"); 39RCSID("$OpenBSD: authfile.c,v 1.37 2001/06/23 15:12:17 itojun Exp $");
40 40
41#include <openssl/err.h> 41#include <openssl/err.h>
42#include <openssl/evp.h> 42#include <openssl/evp.h>
@@ -62,7 +62,7 @@ static const char authfile_id_string[] =
62 * passphrase. 62 * passphrase.
63 */ 63 */
64 64
65int 65static int
66key_save_private_rsa1(Key *key, const char *filename, const char *passphrase, 66key_save_private_rsa1(Key *key, const char *filename, const char *passphrase,
67 const char *comment) 67 const char *comment)
68{ 68{
@@ -159,7 +159,7 @@ key_save_private_rsa1(Key *key, const char *filename, const char *passphrase,
159} 159}
160 160
161/* save SSH v2 key in OpenSSL PEM format */ 161/* save SSH v2 key in OpenSSL PEM format */
162int 162static int
163key_save_private_pem(Key *key, const char *filename, const char *_passphrase, 163key_save_private_pem(Key *key, const char *filename, const char *_passphrase,
164 const char *comment) 164 const char *comment)
165{ 165{
@@ -226,7 +226,7 @@ key_save_private(Key *key, const char *filename, const char *passphrase,
226 * otherwise. 226 * otherwise.
227 */ 227 */
228 228
229Key * 229static Key *
230key_load_public_rsa1(int fd, const char *filename, char **commentp) 230key_load_public_rsa1(int fd, const char *filename, char **commentp)
231{ 231{
232 Buffer buffer; 232 Buffer buffer;
@@ -306,7 +306,7 @@ key_load_public_type(int type, const char *filename, char **commentp)
306 * Assumes we are called under uid of the owner of the file. 306 * Assumes we are called under uid of the owner of the file.
307 */ 307 */
308 308
309Key * 309static Key *
310key_load_private_rsa1(int fd, const char *filename, const char *passphrase, 310key_load_private_rsa1(int fd, const char *filename, const char *passphrase,
311 char **commentp) 311 char **commentp)
312{ 312{
@@ -430,7 +430,7 @@ fail:
430 return NULL; 430 return NULL;
431} 431}
432 432
433Key * 433static Key *
434key_load_private_pem(int fd, int type, const char *passphrase, 434key_load_private_pem(int fd, int type, const char *passphrase,
435 char **commentp) 435 char **commentp)
436{ 436{
@@ -481,7 +481,7 @@ key_load_private_pem(int fd, int type, const char *passphrase,
481 return prv; 481 return prv;
482} 482}
483 483
484int 484static int
485key_perm_ok(int fd, const char *filename) 485key_perm_ok(int fd, const char *filename)
486{ 486{
487 struct stat st; 487 struct stat st;
@@ -571,7 +571,7 @@ key_load_private(const char *filename, const char *passphrase,
571 return prv; 571 return prv;
572} 572}
573 573
574int 574static int
575key_try_load_public(Key *k, const char *filename, char **commentp) 575key_try_load_public(Key *k, const char *filename, char **commentp)
576{ 576{
577 FILE *f; 577 FILE *f;
diff --git a/canohost.c b/canohost.c
index 5d345eb27..6e6a04505 100644
--- a/canohost.c
+++ b/canohost.c
@@ -12,21 +12,21 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: canohost.c,v 1.26 2001/04/18 14:15:00 markus Exp $"); 15RCSID("$OpenBSD: canohost.c,v 1.27 2001/06/23 15:12:17 itojun Exp $");
16 16
17#include "packet.h" 17#include "packet.h"
18#include "xmalloc.h" 18#include "xmalloc.h"
19#include "log.h" 19#include "log.h"
20#include "canohost.h" 20#include "canohost.h"
21 21
22void check_ip_options(int socket, char *ipaddr); 22static void check_ip_options(int, char *);
23 23
24/* 24/*
25 * Return the canonical name of the host at the other end of the socket. The 25 * Return the canonical name of the host at the other end of the socket. The
26 * caller should free the returned string with xfree. 26 * caller should free the returned string with xfree.
27 */ 27 */
28 28
29char * 29static char *
30get_remote_hostname(int socket, int reverse_mapping_check) 30get_remote_hostname(int socket, int reverse_mapping_check)
31{ 31{
32 struct sockaddr_storage from; 32 struct sockaddr_storage from;
@@ -140,7 +140,7 @@ get_remote_hostname(int socket, int reverse_mapping_check)
140 * exit here if we detect any IP options. 140 * exit here if we detect any IP options.
141 */ 141 */
142/* IPv4 only */ 142/* IPv4 only */
143void 143static void
144check_ip_options(int socket, char *ipaddr) 144check_ip_options(int socket, char *ipaddr)
145{ 145{
146 u_char options[200]; 146 u_char options[200];
@@ -202,7 +202,7 @@ get_canonical_hostname(int reverse_mapping_check)
202 * Returns the remote IP-address of socket as a string. The returned 202 * Returns the remote IP-address of socket as a string. The returned
203 * string must be freed. 203 * string must be freed.
204 */ 204 */
205char * 205static char *
206get_socket_address(int socket, int remote, int flags) 206get_socket_address(int socket, int remote, int flags)
207{ 207{
208 struct sockaddr_storage addr; 208 struct sockaddr_storage addr;
@@ -293,7 +293,7 @@ get_remote_name_or_ip(u_int utmp_len, int reverse_mapping_check)
293 293
294/* Returns the local/remote port for the socket. */ 294/* Returns the local/remote port for the socket. */
295 295
296int 296static int
297get_sock_port(int sock, int local) 297get_sock_port(int sock, int local)
298{ 298{
299 struct sockaddr_storage from; 299 struct sockaddr_storage from;
@@ -323,7 +323,7 @@ get_sock_port(int sock, int local)
323 323
324/* Returns remote/local port number for the current connection. */ 324/* Returns remote/local port number for the current connection. */
325 325
326int 326static int
327get_port(int local) 327get_port(int local)
328{ 328{
329 /* 329 /*
diff --git a/channels.c b/channels.c
index d9513fada..ce4c5952d 100644
--- a/channels.c
+++ b/channels.c
@@ -40,7 +40,7 @@
40 */ 40 */
41 41
42#include "includes.h" 42#include "includes.h"
43RCSID("$OpenBSD: channels.c,v 1.126 2001/06/20 13:56:39 markus Exp $"); 43RCSID("$OpenBSD: channels.c,v 1.127 2001/06/23 15:12:17 itojun Exp $");
44 44
45#include "ssh.h" 45#include "ssh.h"
46#include "ssh1.h" 46#include "ssh1.h"
@@ -133,12 +133,11 @@ static u_int x11_fake_data_len;
133static char *auth_sock_name = NULL; 133static char *auth_sock_name = NULL;
134static char *auth_sock_dir = NULL; 134static char *auth_sock_dir = NULL;
135 135
136
137/* AF_UNSPEC or AF_INET or AF_INET6 */ 136/* AF_UNSPEC or AF_INET or AF_INET6 */
138extern int IPv4or6; 137extern int IPv4or6;
139 138
140/* helper */ 139/* helper */
141void port_open_helper(Channel *c, char *rtype); 140static void port_open_helper(Channel *c, char *rtype);
142 141
143/* -- channel core */ 142/* -- channel core */
144 143
@@ -164,7 +163,7 @@ channel_lookup(int id)
164 * when the channel consumer/producer is ready, e.g. shell exec'd 163 * when the channel consumer/producer is ready, e.g. shell exec'd
165 */ 164 */
166 165
167void 166static void
168channel_register_fds(Channel *c, int rfd, int wfd, int efd, 167channel_register_fds(Channel *c, int rfd, int wfd, int efd,
169 int extusage, int nonblock) 168 int extusage, int nonblock)
170{ 169{
@@ -270,7 +269,7 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
270 269
271/* Close all channel fd/socket. */ 270/* Close all channel fd/socket. */
272 271
273void 272static void
274channel_close_fds(Channel *c) 273channel_close_fds(Channel *c)
275{ 274{
276 debug3("channel_close_fds: channel %d: r %d w %d e %d", 275 debug3("channel_close_fds: channel %d: r %d w %d e %d",
@@ -633,20 +632,20 @@ typedef void chan_fn(Channel *c, fd_set * readset, fd_set * writeset);
633chan_fn *channel_pre[SSH_CHANNEL_MAX_TYPE]; 632chan_fn *channel_pre[SSH_CHANNEL_MAX_TYPE];
634chan_fn *channel_post[SSH_CHANNEL_MAX_TYPE]; 633chan_fn *channel_post[SSH_CHANNEL_MAX_TYPE];
635 634
636void 635static void
637channel_pre_listener(Channel *c, fd_set * readset, fd_set * writeset) 636channel_pre_listener(Channel *c, fd_set * readset, fd_set * writeset)
638{ 637{
639 FD_SET(c->sock, readset); 638 FD_SET(c->sock, readset);
640} 639}
641 640
642void 641static void
643channel_pre_connecting(Channel *c, fd_set * readset, fd_set * writeset) 642channel_pre_connecting(Channel *c, fd_set * readset, fd_set * writeset)
644{ 643{
645 debug3("channel %d: waiting for connection", c->self); 644 debug3("channel %d: waiting for connection", c->self);
646 FD_SET(c->sock, writeset); 645 FD_SET(c->sock, writeset);
647} 646}
648 647
649void 648static void
650channel_pre_open_13(Channel *c, fd_set * readset, fd_set * writeset) 649channel_pre_open_13(Channel *c, fd_set * readset, fd_set * writeset)
651{ 650{
652 if (buffer_len(&c->input) < packet_get_maxsize()) 651 if (buffer_len(&c->input) < packet_get_maxsize())
@@ -655,7 +654,7 @@ channel_pre_open_13(Channel *c, fd_set * readset, fd_set * writeset)
655 FD_SET(c->sock, writeset); 654 FD_SET(c->sock, writeset);
656} 655}
657 656
658void 657static void
659channel_pre_open_15(Channel *c, fd_set * readset, fd_set * writeset) 658channel_pre_open_15(Channel *c, fd_set * readset, fd_set * writeset)
660{ 659{
661 /* test whether sockets are 'alive' for read/write */ 660 /* test whether sockets are 'alive' for read/write */
@@ -672,7 +671,7 @@ channel_pre_open_15(Channel *c, fd_set * readset, fd_set * writeset)
672 } 671 }
673} 672}
674 673
675void 674static void
676channel_pre_open_20(Channel *c, fd_set * readset, fd_set * writeset) 675channel_pre_open_20(Channel *c, fd_set * readset, fd_set * writeset)
677{ 676{
678 if (c->istate == CHAN_INPUT_OPEN && 677 if (c->istate == CHAN_INPUT_OPEN &&
@@ -698,7 +697,7 @@ channel_pre_open_20(Channel *c, fd_set * readset, fd_set * writeset)
698 } 697 }
699} 698}
700 699
701void 700static void
702channel_pre_input_draining(Channel *c, fd_set * readset, fd_set * writeset) 701channel_pre_input_draining(Channel *c, fd_set * readset, fd_set * writeset)
703{ 702{
704 if (buffer_len(&c->input) == 0) { 703 if (buffer_len(&c->input) == 0) {
@@ -710,7 +709,7 @@ channel_pre_input_draining(Channel *c, fd_set * readset, fd_set * writeset)
710 } 709 }
711} 710}
712 711
713void 712static void
714channel_pre_output_draining(Channel *c, fd_set * readset, fd_set * writeset) 713channel_pre_output_draining(Channel *c, fd_set * readset, fd_set * writeset)
715{ 714{
716 if (buffer_len(&c->output) == 0) 715 if (buffer_len(&c->output) == 0)
@@ -728,7 +727,7 @@ channel_pre_output_draining(Channel *c, fd_set * readset, fd_set * writeset)
728 * XXX All this happens at the client side. 727 * XXX All this happens at the client side.
729 * Returns: 0 = need more data, -1 = wrong cookie, 1 = ok 728 * Returns: 0 = need more data, -1 = wrong cookie, 1 = ok
730 */ 729 */
731int 730static int
732x11_open_helper(Buffer *b) 731x11_open_helper(Buffer *b)
733{ 732{
734 u_char *ucp; 733 u_char *ucp;
@@ -786,7 +785,7 @@ x11_open_helper(Buffer *b)
786 return 1; 785 return 1;
787} 786}
788 787
789void 788static void
790channel_pre_x11_open_13(Channel *c, fd_set * readset, fd_set * writeset) 789channel_pre_x11_open_13(Channel *c, fd_set * readset, fd_set * writeset)
791{ 790{
792 int ret = x11_open_helper(&c->output); 791 int ret = x11_open_helper(&c->output);
@@ -811,7 +810,7 @@ channel_pre_x11_open_13(Channel *c, fd_set * readset, fd_set * writeset)
811 } 810 }
812} 811}
813 812
814void 813static void
815channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset) 814channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset)
816{ 815{
817 int ret = x11_open_helper(&c->output); 816 int ret = x11_open_helper(&c->output);
@@ -830,7 +829,7 @@ channel_pre_x11_open(Channel *c, fd_set * readset, fd_set * writeset)
830} 829}
831 830
832/* try to decode a socks4 header */ 831/* try to decode a socks4 header */
833int 832static int
834channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset) 833channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset)
835{ 834{
836 u_char *p, *host; 835 u_char *p, *host;
@@ -900,7 +899,7 @@ channel_decode_socks4(Channel *c, fd_set * readset, fd_set * writeset)
900} 899}
901 900
902/* dynamic port forwarding */ 901/* dynamic port forwarding */
903void 902static void
904channel_pre_dynamic(Channel *c, fd_set * readset, fd_set * writeset) 903channel_pre_dynamic(Channel *c, fd_set * readset, fd_set * writeset)
905{ 904{
906 u_char *p; 905 u_char *p;
@@ -940,7 +939,7 @@ channel_pre_dynamic(Channel *c, fd_set * readset, fd_set * writeset)
940} 939}
941 940
942/* This is our fake X11 server socket. */ 941/* This is our fake X11 server socket. */
943void 942static void
944channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset) 943channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset)
945{ 944{
946 Channel *nc; 945 Channel *nc;
@@ -998,7 +997,7 @@ channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset)
998 } 997 }
999} 998}
1000 999
1001void 1000static void
1002port_open_helper(Channel *c, char *rtype) 1001port_open_helper(Channel *c, char *rtype)
1003{ 1002{
1004 int direct; 1003 int direct;
@@ -1052,7 +1051,7 @@ port_open_helper(Channel *c, char *rtype)
1052/* 1051/*
1053 * This socket is listening for connections to a forwarded TCP/IP port. 1052 * This socket is listening for connections to a forwarded TCP/IP port.
1054 */ 1053 */
1055void 1054static void
1056channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset) 1055channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset)
1057{ 1056{
1058 Channel *nc; 1057 Channel *nc;
@@ -1100,7 +1099,7 @@ channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset)
1100 * This is the authentication agent socket listening for connections from 1099 * This is the authentication agent socket listening for connections from
1101 * clients. 1100 * clients.
1102 */ 1101 */
1103void 1102static void
1104channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset) 1103channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset)
1105{ 1104{
1106 Channel *nc; 1105 Channel *nc;
@@ -1140,7 +1139,7 @@ channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset)
1140 } 1139 }
1141} 1140}
1142 1141
1143void 1142static void
1144channel_post_connecting(Channel *c, fd_set * readset, fd_set * writeset) 1143channel_post_connecting(Channel *c, fd_set * readset, fd_set * writeset)
1145{ 1144{
1146 int err = 0; 1145 int err = 0;
@@ -1187,7 +1186,7 @@ channel_post_connecting(Channel *c, fd_set * readset, fd_set * writeset)
1187 } 1186 }
1188} 1187}
1189 1188
1190int 1189static int
1191channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset) 1190channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset)
1192{ 1191{
1193 char buf[16*1024]; 1192 char buf[16*1024];
@@ -1225,7 +1224,7 @@ channel_handle_rfd(Channel *c, fd_set * readset, fd_set * writeset)
1225 } 1224 }
1226 return 1; 1225 return 1;
1227} 1226}
1228int 1227static int
1229channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset) 1228channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset)
1230{ 1229{
1231 struct termios tio; 1230 struct termios tio;
@@ -1273,7 +1272,7 @@ channel_handle_wfd(Channel *c, fd_set * readset, fd_set * writeset)
1273 } 1272 }
1274 return 1; 1273 return 1;
1275} 1274}
1276int 1275static int
1277channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset) 1276channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset)
1278{ 1277{
1279 char buf[16*1024]; 1278 char buf[16*1024];
@@ -1318,7 +1317,7 @@ channel_handle_efd(Channel *c, fd_set * readset, fd_set * writeset)
1318 } 1317 }
1319 return 1; 1318 return 1;
1320} 1319}
1321int 1320static int
1322channel_check_window(Channel *c) 1321channel_check_window(Channel *c)
1323{ 1322{
1324 if (c->type == SSH_CHANNEL_OPEN && 1323 if (c->type == SSH_CHANNEL_OPEN &&
@@ -1338,14 +1337,14 @@ channel_check_window(Channel *c)
1338 return 1; 1337 return 1;
1339} 1338}
1340 1339
1341void 1340static void
1342channel_post_open_1(Channel *c, fd_set * readset, fd_set * writeset) 1341channel_post_open_1(Channel *c, fd_set * readset, fd_set * writeset)
1343{ 1342{
1344 channel_handle_rfd(c, readset, writeset); 1343 channel_handle_rfd(c, readset, writeset);
1345 channel_handle_wfd(c, readset, writeset); 1344 channel_handle_wfd(c, readset, writeset);
1346} 1345}
1347 1346
1348void 1347static void
1349channel_post_open_2(Channel *c, fd_set * readset, fd_set * writeset) 1348channel_post_open_2(Channel *c, fd_set * readset, fd_set * writeset)
1350{ 1349{
1351 channel_handle_rfd(c, readset, writeset); 1350 channel_handle_rfd(c, readset, writeset);
@@ -1355,7 +1354,7 @@ channel_post_open_2(Channel *c, fd_set * readset, fd_set * writeset)
1355 channel_check_window(c); 1354 channel_check_window(c);
1356} 1355}
1357 1356
1358void 1357static void
1359channel_post_output_drain_13(Channel *c, fd_set * readset, fd_set * writeset) 1358channel_post_output_drain_13(Channel *c, fd_set * readset, fd_set * writeset)
1360{ 1359{
1361 int len; 1360 int len;
@@ -1370,7 +1369,7 @@ channel_post_output_drain_13(Channel *c, fd_set * readset, fd_set * writeset)
1370 } 1369 }
1371} 1370}
1372 1371
1373void 1372static void
1374channel_handler_init_20(void) 1373channel_handler_init_20(void)
1375{ 1374{
1376 channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open_20; 1375 channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open_20;
@@ -1391,7 +1390,7 @@ channel_handler_init_20(void)
1391 channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_2; 1390 channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_2;
1392} 1391}
1393 1392
1394void 1393static void
1395channel_handler_init_13(void) 1394channel_handler_init_13(void)
1396{ 1395{
1397 channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open_13; 1396 channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open_13;
@@ -1413,7 +1412,7 @@ channel_handler_init_13(void)
1413 channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_1; 1412 channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_1;
1414} 1413}
1415 1414
1416void 1415static void
1417channel_handler_init_15(void) 1416channel_handler_init_15(void)
1418{ 1417{
1419 channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open_15; 1418 channel_pre[SSH_CHANNEL_OPEN] = &channel_pre_open_15;
@@ -1432,7 +1431,7 @@ channel_handler_init_15(void)
1432 channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_1; 1431 channel_post[SSH_CHANNEL_DYNAMIC] = &channel_post_open_1;
1433} 1432}
1434 1433
1435void 1434static void
1436channel_handler_init(void) 1435channel_handler_init(void)
1437{ 1436{
1438 int i; 1437 int i;
@@ -1448,7 +1447,7 @@ channel_handler_init(void)
1448 channel_handler_init_15(); 1447 channel_handler_init_15();
1449} 1448}
1450 1449
1451void 1450static void
1452channel_handler(chan_fn *ftab[], fd_set * readset, fd_set * writeset) 1451channel_handler(chan_fn *ftab[], fd_set * readset, fd_set * writeset)
1453{ 1452{
1454 static int did_init = 0; 1453 static int did_init = 0;
@@ -1828,7 +1827,7 @@ channel_input_open_confirmation(int type, int plen, void *ctxt)
1828 } 1827 }
1829} 1828}
1830 1829
1831char * 1830static char *
1832reason2txt(int reason) 1831reason2txt(int reason)
1833{ 1832{
1834 switch(reason) { 1833 switch(reason) {
@@ -2220,7 +2219,7 @@ channel_clear_permitted_opens(void)
2220 2219
2221 2220
2222/* return socket to remote host, port */ 2221/* return socket to remote host, port */
2223int 2222static int
2224connect_to(const char *host, u_short port) 2223connect_to(const char *host, u_short port)
2225{ 2224{
2226 struct addrinfo hints, *ai, *aitop; 2225 struct addrinfo hints, *ai, *aitop;
@@ -2455,8 +2454,7 @@ x11_create_display_inet(int screen_number, int x11_display_offset)
2455#define X_UNIX_PATH "/tmp/.X11-unix/X" 2454#define X_UNIX_PATH "/tmp/.X11-unix/X"
2456#endif 2455#endif
2457 2456
2458static 2457static int
2459int
2460connect_local_xsocket(u_int dnr) 2458connect_local_xsocket(u_int dnr)
2461{ 2459{
2462 static const char *const x_sockets[] = { 2460 static const char *const x_sockets[] = {
diff --git a/cipher.c b/cipher.c
index fd93299ed..a7aacf284 100644
--- a/cipher.c
+++ b/cipher.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: cipher.c,v 1.44 2001/05/28 22:51:10 markus Exp $"); 38RCSID("$OpenBSD: cipher.c,v 1.45 2001/06/23 15:12:18 itojun Exp $");
39 39
40#include "xmalloc.h" 40#include "xmalloc.h"
41#include "log.h" 41#include "log.h"
@@ -43,24 +43,23 @@ RCSID("$OpenBSD: cipher.c,v 1.44 2001/05/28 22:51:10 markus Exp $");
43 43
44#include <openssl/md5.h> 44#include <openssl/md5.h>
45 45
46
47/* no encryption */ 46/* no encryption */
48void 47static void
49none_setkey(CipherContext *cc, const u_char *key, u_int keylen) 48none_setkey(CipherContext *cc, const u_char *key, u_int keylen)
50{ 49{
51} 50}
52void 51static void
53none_setiv(CipherContext *cc, const u_char *iv, u_int ivlen) 52none_setiv(CipherContext *cc, const u_char *iv, u_int ivlen)
54{ 53{
55} 54}
56void 55static void
57none_crypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len) 56none_crypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len)
58{ 57{
59 memcpy(dest, src, len); 58 memcpy(dest, src, len);
60} 59}
61 60
62/* DES */ 61/* DES */
63void 62static void
64des_ssh1_setkey(CipherContext *cc, const u_char *key, u_int keylen) 63des_ssh1_setkey(CipherContext *cc, const u_char *key, u_int keylen)
65{ 64{
66 static int dowarn = 1; 65 static int dowarn = 1;
@@ -71,18 +70,18 @@ des_ssh1_setkey(CipherContext *cc, const u_char *key, u_int keylen)
71 } 70 }
72 des_set_key((void *)key, cc->u.des.key); 71 des_set_key((void *)key, cc->u.des.key);
73} 72}
74void 73static void
75des_ssh1_setiv(CipherContext *cc, const u_char *iv, u_int ivlen) 74des_ssh1_setiv(CipherContext *cc, const u_char *iv, u_int ivlen)
76{ 75{
77 memset(cc->u.des.iv, 0, sizeof(cc->u.des.iv)); 76 memset(cc->u.des.iv, 0, sizeof(cc->u.des.iv));
78} 77}
79void 78static void
80des_ssh1_encrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len) 79des_ssh1_encrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len)
81{ 80{
82 des_ncbc_encrypt(src, dest, len, cc->u.des.key, &cc->u.des.iv, 81 des_ncbc_encrypt(src, dest, len, cc->u.des.key, &cc->u.des.iv,
83 DES_ENCRYPT); 82 DES_ENCRYPT);
84} 83}
85void 84static void
86des_ssh1_decrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len) 85des_ssh1_decrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len)
87{ 86{
88 des_ncbc_encrypt(src, dest, len, cc->u.des.key, &cc->u.des.iv, 87 des_ncbc_encrypt(src, dest, len, cc->u.des.key, &cc->u.des.iv,
@@ -90,14 +89,14 @@ des_ssh1_decrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len)
90} 89}
91 90
92/* 3DES */ 91/* 3DES */
93void 92static void
94des3_setkey(CipherContext *cc, const u_char *key, u_int keylen) 93des3_setkey(CipherContext *cc, const u_char *key, u_int keylen)
95{ 94{
96 des_set_key((void *) key, cc->u.des3.key1); 95 des_set_key((void *) key, cc->u.des3.key1);
97 des_set_key((void *) (key+8), cc->u.des3.key2); 96 des_set_key((void *) (key+8), cc->u.des3.key2);
98 des_set_key((void *) (key+16), cc->u.des3.key3); 97 des_set_key((void *) (key+16), cc->u.des3.key3);
99} 98}
100void 99static void
101des3_setiv(CipherContext *cc, const u_char *iv, u_int ivlen) 100des3_setiv(CipherContext *cc, const u_char *iv, u_int ivlen)
102{ 101{
103 memset(cc->u.des3.iv1, 0, sizeof(cc->u.des3.iv1)); 102 memset(cc->u.des3.iv1, 0, sizeof(cc->u.des3.iv1));
@@ -107,14 +106,14 @@ des3_setiv(CipherContext *cc, const u_char *iv, u_int ivlen)
107 return; 106 return;
108 memcpy(cc->u.des3.iv3, (char *)iv, 8); 107 memcpy(cc->u.des3.iv3, (char *)iv, 8);
109} 108}
110void 109static void
111des3_cbc_encrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len) 110des3_cbc_encrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len)
112{ 111{
113 des_ede3_cbc_encrypt(src, dest, len, 112 des_ede3_cbc_encrypt(src, dest, len,
114 cc->u.des3.key1, cc->u.des3.key2, cc->u.des3.key3, 113 cc->u.des3.key1, cc->u.des3.key2, cc->u.des3.key3,
115 &cc->u.des3.iv3, DES_ENCRYPT); 114 &cc->u.des3.iv3, DES_ENCRYPT);
116} 115}
117void 116static void
118des3_cbc_decrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len) 117des3_cbc_decrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len)
119{ 118{
120 des_ede3_cbc_encrypt(src, dest, len, 119 des_ede3_cbc_encrypt(src, dest, len,
@@ -136,7 +135,7 @@ des3_cbc_decrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len)
136 * result of that there is no longer any known iv1 to use when 135 * result of that there is no longer any known iv1 to use when
137 * choosing the X block. 136 * choosing the X block.
138 */ 137 */
139void 138static void
140des3_ssh1_setkey(CipherContext *cc, const u_char *key, u_int keylen) 139des3_ssh1_setkey(CipherContext *cc, const u_char *key, u_int keylen)
141{ 140{
142 des_set_key((void *) key, cc->u.des3.key1); 141 des_set_key((void *) key, cc->u.des3.key1);
@@ -146,7 +145,7 @@ des3_ssh1_setkey(CipherContext *cc, const u_char *key, u_int keylen)
146 else 145 else
147 des_set_key((void *) (key+16), cc->u.des3.key3); 146 des_set_key((void *) (key+16), cc->u.des3.key3);
148} 147}
149void 148static void
150des3_ssh1_encrypt(CipherContext *cc, u_char *dest, const u_char *src, 149des3_ssh1_encrypt(CipherContext *cc, u_char *dest, const u_char *src,
151 u_int len) 150 u_int len)
152{ 151{
@@ -157,7 +156,7 @@ des3_ssh1_encrypt(CipherContext *cc, u_char *dest, const u_char *src,
157 des_ncbc_encrypt(dest, dest, len, cc->u.des3.key3, &cc->u.des3.iv3, 156 des_ncbc_encrypt(dest, dest, len, cc->u.des3.key3, &cc->u.des3.iv3,
158 DES_ENCRYPT); 157 DES_ENCRYPT);
159} 158}
160void 159static void
161des3_ssh1_decrypt(CipherContext *cc, u_char *dest, const u_char *src, 160des3_ssh1_decrypt(CipherContext *cc, u_char *dest, const u_char *src,
162 u_int len) 161 u_int len)
163{ 162{
@@ -170,12 +169,12 @@ des3_ssh1_decrypt(CipherContext *cc, u_char *dest, const u_char *src,
170} 169}
171 170
172/* Blowfish */ 171/* Blowfish */
173void 172static void
174blowfish_setkey(CipherContext *cc, const u_char *key, u_int keylen) 173blowfish_setkey(CipherContext *cc, const u_char *key, u_int keylen)
175{ 174{
176 BF_set_key(&cc->u.bf.key, keylen, (u_char *)key); 175 BF_set_key(&cc->u.bf.key, keylen, (u_char *)key);
177} 176}
178void 177static void
179blowfish_setiv(CipherContext *cc, const u_char *iv, u_int ivlen) 178blowfish_setiv(CipherContext *cc, const u_char *iv, u_int ivlen)
180{ 179{
181 if (iv == NULL) 180 if (iv == NULL)
@@ -183,14 +182,14 @@ blowfish_setiv(CipherContext *cc, const u_char *iv, u_int ivlen)
183 else 182 else
184 memcpy(cc->u.bf.iv, (char *)iv, 8); 183 memcpy(cc->u.bf.iv, (char *)iv, 8);
185} 184}
186void 185static void
187blowfish_cbc_encrypt(CipherContext *cc, u_char *dest, const u_char *src, 186blowfish_cbc_encrypt(CipherContext *cc, u_char *dest, const u_char *src,
188 u_int len) 187 u_int len)
189{ 188{
190 BF_cbc_encrypt((void *)src, dest, len, &cc->u.bf.key, cc->u.bf.iv, 189 BF_cbc_encrypt((void *)src, dest, len, &cc->u.bf.key, cc->u.bf.iv,
191 BF_ENCRYPT); 190 BF_ENCRYPT);
192} 191}
193void 192static void
194blowfish_cbc_decrypt(CipherContext *cc, u_char *dest, const u_char *src, 193blowfish_cbc_decrypt(CipherContext *cc, u_char *dest, const u_char *src,
195 u_int len) 194 u_int len)
196{ 195{
@@ -221,7 +220,7 @@ swap_bytes(const u_char *src, u_char *dst, int n)
221 } 220 }
222} 221}
223 222
224void 223static void
225blowfish_ssh1_encrypt(CipherContext *cc, u_char *dest, const u_char *src, 224blowfish_ssh1_encrypt(CipherContext *cc, u_char *dest, const u_char *src,
226 u_int len) 225 u_int len)
227{ 226{
@@ -230,7 +229,7 @@ blowfish_ssh1_encrypt(CipherContext *cc, u_char *dest, const u_char *src,
230 BF_ENCRYPT); 229 BF_ENCRYPT);
231 swap_bytes(dest, dest, len); 230 swap_bytes(dest, dest, len);
232} 231}
233void 232static void
234blowfish_ssh1_decrypt(CipherContext *cc, u_char *dest, const u_char *src, 233blowfish_ssh1_decrypt(CipherContext *cc, u_char *dest, const u_char *src,
235 u_int len) 234 u_int len)
236{ 235{
@@ -241,37 +240,37 @@ blowfish_ssh1_decrypt(CipherContext *cc, u_char *dest, const u_char *src,
241} 240}
242 241
243/* alleged rc4 */ 242/* alleged rc4 */
244void 243static void
245arcfour_setkey(CipherContext *cc, const u_char *key, u_int keylen) 244arcfour_setkey(CipherContext *cc, const u_char *key, u_int keylen)
246{ 245{
247 RC4_set_key(&cc->u.rc4, keylen, (u_char *)key); 246 RC4_set_key(&cc->u.rc4, keylen, (u_char *)key);
248} 247}
249void 248static void
250arcfour_crypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len) 249arcfour_crypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len)
251{ 250{
252 RC4(&cc->u.rc4, len, (u_char *)src, dest); 251 RC4(&cc->u.rc4, len, (u_char *)src, dest);
253} 252}
254 253
255/* CAST */ 254/* CAST */
256void 255static void
257cast_setkey(CipherContext *cc, const u_char *key, u_int keylen) 256cast_setkey(CipherContext *cc, const u_char *key, u_int keylen)
258{ 257{
259 CAST_set_key(&cc->u.cast.key, keylen, (u_char *) key); 258 CAST_set_key(&cc->u.cast.key, keylen, (u_char *) key);
260} 259}
261void 260static void
262cast_setiv(CipherContext *cc, const u_char *iv, u_int ivlen) 261cast_setiv(CipherContext *cc, const u_char *iv, u_int ivlen)
263{ 262{
264 if (iv == NULL) 263 if (iv == NULL)
265 fatal("no IV for %s.", cc->cipher->name); 264 fatal("no IV for %s.", cc->cipher->name);
266 memcpy(cc->u.cast.iv, (char *)iv, 8); 265 memcpy(cc->u.cast.iv, (char *)iv, 8);
267} 266}
268void 267static void
269cast_cbc_encrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len) 268cast_cbc_encrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len)
270{ 269{
271 CAST_cbc_encrypt(src, dest, len, &cc->u.cast.key, cc->u.cast.iv, 270 CAST_cbc_encrypt(src, dest, len, &cc->u.cast.key, cc->u.cast.iv,
272 CAST_ENCRYPT); 271 CAST_ENCRYPT);
273} 272}
274void 273static void
275cast_cbc_decrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len) 274cast_cbc_decrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len)
276{ 275{
277 CAST_cbc_encrypt(src, dest, len, &cc->u.cast.key, cc->u.cast.iv, 276 CAST_cbc_encrypt(src, dest, len, &cc->u.cast.key, cc->u.cast.iv,
@@ -281,20 +280,20 @@ cast_cbc_decrypt(CipherContext *cc, u_char *dest, const u_char *src, u_int len)
281/* RIJNDAEL */ 280/* RIJNDAEL */
282 281
283#define RIJNDAEL_BLOCKSIZE 16 282#define RIJNDAEL_BLOCKSIZE 16
284void 283static void
285rijndael_setkey(CipherContext *cc, const u_char *key, u_int keylen) 284rijndael_setkey(CipherContext *cc, const u_char *key, u_int keylen)
286{ 285{
287 rijndael_set_key(&cc->u.rijndael.enc, (u4byte *)key, 8*keylen, 1); 286 rijndael_set_key(&cc->u.rijndael.enc, (u4byte *)key, 8*keylen, 1);
288 rijndael_set_key(&cc->u.rijndael.dec, (u4byte *)key, 8*keylen, 0); 287 rijndael_set_key(&cc->u.rijndael.dec, (u4byte *)key, 8*keylen, 0);
289} 288}
290void 289static void
291rijndael_setiv(CipherContext *cc, const u_char *iv, u_int ivlen) 290rijndael_setiv(CipherContext *cc, const u_char *iv, u_int ivlen)
292{ 291{
293 if (iv == NULL) 292 if (iv == NULL)
294 fatal("no IV for %s.", cc->cipher->name); 293 fatal("no IV for %s.", cc->cipher->name);
295 memcpy((u_char *)cc->u.rijndael.iv, iv, RIJNDAEL_BLOCKSIZE); 294 memcpy((u_char *)cc->u.rijndael.iv, iv, RIJNDAEL_BLOCKSIZE);
296} 295}
297void 296static void
298rijndael_cbc_encrypt(CipherContext *cc, u_char *dest, const u_char *src, 297rijndael_cbc_encrypt(CipherContext *cc, u_char *dest, const u_char *src,
299 u_int len) 298 u_int len)
300{ 299{
@@ -321,7 +320,7 @@ rijndael_cbc_encrypt(CipherContext *cc, u_char *dest, const u_char *src,
321 memcpy(iv, cprev, RIJNDAEL_BLOCKSIZE); 320 memcpy(iv, cprev, RIJNDAEL_BLOCKSIZE);
322} 321}
323 322
324void 323static void
325rijndael_cbc_decrypt(CipherContext *cc, u_char *dest, const u_char *src, 324rijndael_cbc_decrypt(CipherContext *cc, u_char *dest, const u_char *src,
326 u_int len) 325 u_int len)
327{ 326{
diff --git a/clientloop.c b/clientloop.c
index a62a71131..c96aea56f 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
59 */ 59 */
60 60
61#include "includes.h" 61#include "includes.h"
62RCSID("$OpenBSD: clientloop.c,v 1.76 2001/06/20 13:56:39 markus Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.77 2001/06/23 15:12:18 itojun Exp $");
63 63
64#include "ssh.h" 64#include "ssh.h"
65#include "ssh1.h" 65#include "ssh1.h"
@@ -124,7 +124,7 @@ static int connection_out; /* Connection to server (output). */
124static int need_rekeying; /* Set to non-zero if rekeying is requested. */ 124static int need_rekeying; /* Set to non-zero if rekeying is requested. */
125static int session_closed = 0; /* In SSH2: login session closed. */ 125static int session_closed = 0; /* In SSH2: login session closed. */
126 126
127void client_init_dispatch(void); 127static void client_init_dispatch(void);
128int session_ident = -1; 128int session_ident = -1;
129 129
130/*XXX*/ 130/*XXX*/
@@ -132,7 +132,7 @@ extern Kex *xxx_kex;
132 132
133/* Restores stdin to blocking mode. */ 133/* Restores stdin to blocking mode. */
134 134
135void 135static void
136leave_non_blocking(void) 136leave_non_blocking(void)
137{ 137{
138 if (in_non_blocking_mode) { 138 if (in_non_blocking_mode) {
@@ -144,7 +144,7 @@ leave_non_blocking(void)
144 144
145/* Puts stdin terminal in non-blocking mode. */ 145/* Puts stdin terminal in non-blocking mode. */
146 146
147void 147static void
148enter_non_blocking(void) 148enter_non_blocking(void)
149{ 149{
150 in_non_blocking_mode = 1; 150 in_non_blocking_mode = 1;
@@ -157,7 +157,7 @@ enter_non_blocking(void)
157 * flag indicating that the window has changed. 157 * flag indicating that the window has changed.
158 */ 158 */
159 159
160void 160static void
161window_change_handler(int sig) 161window_change_handler(int sig)
162{ 162{
163 received_window_change_signal = 1; 163 received_window_change_signal = 1;
@@ -169,7 +169,7 @@ window_change_handler(int sig)
169 * signals must be trapped to restore terminal modes. 169 * signals must be trapped to restore terminal modes.
170 */ 170 */
171 171
172void 172static void
173signal_handler(int sig) 173signal_handler(int sig)
174{ 174{
175 received_signal = sig; 175 received_signal = sig;
@@ -181,7 +181,7 @@ signal_handler(int sig)
181 * available resolution. 181 * available resolution.
182 */ 182 */
183 183
184double 184static double
185get_current_time(void) 185get_current_time(void)
186{ 186{
187 struct timeval tv; 187 struct timeval tv;
@@ -195,7 +195,7 @@ get_current_time(void)
195 * not appear to wake up when redirecting from /dev/null. 195 * not appear to wake up when redirecting from /dev/null.
196 */ 196 */
197 197
198void 198static void
199client_check_initial_eof_on_stdin(void) 199client_check_initial_eof_on_stdin(void)
200{ 200{
201 int len; 201 int len;
@@ -247,7 +247,7 @@ client_check_initial_eof_on_stdin(void)
247 * connection. 247 * connection.
248 */ 248 */
249 249
250void 250static void
251client_make_packets_from_stdin_data(void) 251client_make_packets_from_stdin_data(void)
252{ 252{
253 u_int len; 253 u_int len;
@@ -279,7 +279,7 @@ client_make_packets_from_stdin_data(void)
279 * appropriate. 279 * appropriate.
280 */ 280 */
281 281
282void 282static void
283client_check_window_change(void) 283client_check_window_change(void)
284{ 284{
285 struct winsize ws; 285 struct winsize ws;
@@ -316,7 +316,7 @@ client_check_window_change(void)
316 * one of the file descriptors). 316 * one of the file descriptors).
317 */ 317 */
318 318
319void 319static void
320client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, 320client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
321 int *maxfdp, int rekeying) 321 int *maxfdp, int rekeying)
322{ 322{
@@ -384,7 +384,7 @@ client_wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp,
384 } 384 }
385} 385}
386 386
387void 387static void
388client_suspend_self(Buffer *bin, Buffer *bout, Buffer *berr) 388client_suspend_self(Buffer *bin, Buffer *bout, Buffer *berr)
389{ 389{
390 struct winsize oldws, newws; 390 struct winsize oldws, newws;
@@ -427,7 +427,7 @@ client_suspend_self(Buffer *bin, Buffer *bout, Buffer *berr)
427 enter_raw_mode(); 427 enter_raw_mode();
428} 428}
429 429
430void 430static void
431client_process_net_input(fd_set * readset) 431client_process_net_input(fd_set * readset)
432{ 432{
433 int len; 433 int len;
@@ -468,7 +468,7 @@ client_process_net_input(fd_set * readset)
468} 468}
469 469
470/* process the characters one by one */ 470/* process the characters one by one */
471int 471static int
472process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len) 472process_escapes(Buffer *bin, Buffer *bout, Buffer *berr, char *buf, int len)
473{ 473{
474 char string[1024]; 474 char string[1024];
@@ -618,7 +618,7 @@ Supported escape sequences:\r\n\
618 return bytes; 618 return bytes;
619} 619}
620 620
621void 621static void
622client_process_input(fd_set * readset) 622client_process_input(fd_set * readset)
623{ 623{
624 int len; 624 int len;
@@ -671,7 +671,7 @@ client_process_input(fd_set * readset)
671 } 671 }
672} 672}
673 673
674void 674static void
675client_process_output(fd_set * writeset) 675client_process_output(fd_set * writeset)
676{ 676{
677 int len; 677 int len;
@@ -732,7 +732,7 @@ client_process_output(fd_set * writeset)
732 * preparatory phase. 732 * preparatory phase.
733 */ 733 */
734 734
735void 735static void
736client_process_buffered_input_packets(void) 736client_process_buffered_input_packets(void)
737{ 737{
738 dispatch_run(DISPATCH_NONBLOCK, &quit_pending, compat20 ? xxx_kex : NULL); 738 dispatch_run(DISPATCH_NONBLOCK, &quit_pending, compat20 ? xxx_kex : NULL);
@@ -740,14 +740,14 @@ client_process_buffered_input_packets(void)
740 740
741/* scan buf[] for '~' before sending data to the peer */ 741/* scan buf[] for '~' before sending data to the peer */
742 742
743int 743static int
744simple_escape_filter(Channel *c, char *buf, int len) 744simple_escape_filter(Channel *c, char *buf, int len)
745{ 745{
746 /* XXX we assume c->extended is writeable */ 746 /* XXX we assume c->extended is writeable */
747 return process_escapes(&c->input, &c->output, &c->extended, buf, len); 747 return process_escapes(&c->input, &c->output, &c->extended, buf, len);
748} 748}
749 749
750void 750static void
751client_channel_closed(int id, void *arg) 751client_channel_closed(int id, void *arg)
752{ 752{
753 if (id != session_ident) 753 if (id != session_ident)
@@ -1000,7 +1000,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
1000 1000
1001/*********/ 1001/*********/
1002 1002
1003void 1003static void
1004client_input_stdout_data(int type, int plen, void *ctxt) 1004client_input_stdout_data(int type, int plen, void *ctxt)
1005{ 1005{
1006 u_int data_len; 1006 u_int data_len;
@@ -1010,7 +1010,7 @@ client_input_stdout_data(int type, int plen, void *ctxt)
1010 memset(data, 0, data_len); 1010 memset(data, 0, data_len);
1011 xfree(data); 1011 xfree(data);
1012} 1012}
1013void 1013static void
1014client_input_stderr_data(int type, int plen, void *ctxt) 1014client_input_stderr_data(int type, int plen, void *ctxt)
1015{ 1015{
1016 u_int data_len; 1016 u_int data_len;
@@ -1020,7 +1020,7 @@ client_input_stderr_data(int type, int plen, void *ctxt)
1020 memset(data, 0, data_len); 1020 memset(data, 0, data_len);
1021 xfree(data); 1021 xfree(data);
1022} 1022}
1023void 1023static void
1024client_input_exit_status(int type, int plen, void *ctxt) 1024client_input_exit_status(int type, int plen, void *ctxt)
1025{ 1025{
1026 packet_integrity_check(plen, 4, type); 1026 packet_integrity_check(plen, 4, type);
@@ -1037,7 +1037,7 @@ client_input_exit_status(int type, int plen, void *ctxt)
1037 quit_pending = 1; 1037 quit_pending = 1;
1038} 1038}
1039 1039
1040Channel * 1040static Channel *
1041client_request_forwarded_tcpip(const char *request_type, int rchan) 1041client_request_forwarded_tcpip(const char *request_type, int rchan)
1042{ 1042{
1043 Channel* c = NULL; 1043 Channel* c = NULL;
@@ -1074,7 +1074,7 @@ client_request_forwarded_tcpip(const char *request_type, int rchan)
1074 return c; 1074 return c;
1075} 1075}
1076 1076
1077Channel* 1077static Channel*
1078client_request_x11(const char *request_type, int rchan) 1078client_request_x11(const char *request_type, int rchan)
1079{ 1079{
1080 Channel *c = NULL; 1080 Channel *c = NULL;
@@ -1113,7 +1113,7 @@ client_request_x11(const char *request_type, int rchan)
1113 return c; 1113 return c;
1114} 1114}
1115 1115
1116Channel* 1116static Channel*
1117client_request_agent(const char *request_type, int rchan) 1117client_request_agent(const char *request_type, int rchan)
1118{ 1118{
1119 Channel *c = NULL; 1119 Channel *c = NULL;
@@ -1139,7 +1139,7 @@ client_request_agent(const char *request_type, int rchan)
1139} 1139}
1140 1140
1141/* XXXX move to generic input handler */ 1141/* XXXX move to generic input handler */
1142void 1142static void
1143client_input_channel_open(int type, int plen, void *ctxt) 1143client_input_channel_open(int type, int plen, void *ctxt)
1144{ 1144{
1145 Channel *c = NULL; 1145 Channel *c = NULL;
@@ -1191,7 +1191,7 @@ client_input_channel_open(int type, int plen, void *ctxt)
1191 } 1191 }
1192 xfree(ctype); 1192 xfree(ctype);
1193} 1193}
1194void 1194static void
1195client_input_channel_req(int type, int plen, void *ctxt) 1195client_input_channel_req(int type, int plen, void *ctxt)
1196{ 1196{
1197 Channel *c = NULL; 1197 Channel *c = NULL;
@@ -1228,7 +1228,7 @@ client_input_channel_req(int type, int plen, void *ctxt)
1228 xfree(rtype); 1228 xfree(rtype);
1229} 1229}
1230 1230
1231void 1231static void
1232client_init_dispatch_20(void) 1232client_init_dispatch_20(void)
1233{ 1233{
1234 dispatch_init(&dispatch_protocol_error); 1234 dispatch_init(&dispatch_protocol_error);
@@ -1245,7 +1245,7 @@ client_init_dispatch_20(void)
1245 /* rekeying */ 1245 /* rekeying */
1246 dispatch_set(SSH2_MSG_KEXINIT, &kex_input_kexinit); 1246 dispatch_set(SSH2_MSG_KEXINIT, &kex_input_kexinit);
1247} 1247}
1248void 1248static void
1249client_init_dispatch_13(void) 1249client_init_dispatch_13(void)
1250{ 1250{
1251 dispatch_init(NULL); 1251 dispatch_init(NULL);
@@ -1264,7 +1264,7 @@ client_init_dispatch_13(void)
1264 dispatch_set(SSH_SMSG_X11_OPEN, options.forward_x11 ? 1264 dispatch_set(SSH_SMSG_X11_OPEN, options.forward_x11 ?
1265 &x11_input_open : &deny_input_open); 1265 &x11_input_open : &deny_input_open);
1266} 1266}
1267void 1267static void
1268client_init_dispatch_15(void) 1268client_init_dispatch_15(void)
1269{ 1269{
1270 client_init_dispatch_13(); 1270 client_init_dispatch_13();
diff --git a/deattack.c b/deattack.c
index 36023e0d3..1a89be4b8 100644
--- a/deattack.c
+++ b/deattack.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: deattack.c,v 1.13 2001/03/01 02:45:10 deraadt Exp $ */ 1/* $OpenBSD: deattack.c,v 1.14 2001/06/23 15:12:18 itojun Exp $ */
2 2
3/* 3/*
4 * Cryptographic attack detector for ssh - source code 4 * Cryptographic attack detector for ssh - source code
@@ -46,8 +46,7 @@
46 46
47#define CMP(a, b) (memcmp(a, b, SSH_BLOCKSIZE)) 47#define CMP(a, b) (memcmp(a, b, SSH_BLOCKSIZE))
48 48
49 49static void
50void
51crc_update(u_int32_t *a, u_int32_t b) 50crc_update(u_int32_t *a, u_int32_t b)
52{ 51{
53 b ^= *a; 52 b ^= *a;
@@ -55,7 +54,7 @@ crc_update(u_int32_t *a, u_int32_t b)
55} 54}
56 55
57/* detect if a block is used in a particular pattern */ 56/* detect if a block is used in a particular pattern */
58int 57static int
59check_crc(u_char *S, u_char *buf, u_int32_t len, 58check_crc(u_char *S, u_char *buf, u_int32_t len,
60 u_char *IV) 59 u_char *IV)
61{ 60{
diff --git a/dh.c b/dh.c
index 66eb95545..fa2508af7 100644
--- a/dh.c
+++ b/dh.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: dh.c,v 1.16 2001/06/22 21:57:59 provos Exp $"); 26RCSID("$OpenBSD: dh.c,v 1.17 2001/06/23 15:12:18 itojun Exp $");
27 27
28#include "xmalloc.h" 28#include "xmalloc.h"
29 29
@@ -39,7 +39,7 @@ RCSID("$OpenBSD: dh.c,v 1.16 2001/06/22 21:57:59 provos Exp $");
39#include "log.h" 39#include "log.h"
40#include "misc.h" 40#include "misc.h"
41 41
42int 42static int
43parse_prime(int linenum, char *line, struct dhgroup *dhg) 43parse_prime(int linenum, char *line, struct dhgroup *dhg)
44{ 44{
45 char *cp, *arg; 45 char *cp, *arg;
diff --git a/hostfile.c b/hostfile.c
index d532bd6ad..39a1a8313 100644
--- a/hostfile.c
+++ b/hostfile.c
@@ -36,7 +36,7 @@
36 */ 36 */
37 37
38#include "includes.h" 38#include "includes.h"
39RCSID("$OpenBSD: hostfile.c,v 1.26 2001/04/12 19:15:24 markus Exp $"); 39RCSID("$OpenBSD: hostfile.c,v 1.27 2001/06/23 15:12:18 itojun Exp $");
40 40
41#include "packet.h" 41#include "packet.h"
42#include "match.h" 42#include "match.h"
@@ -49,7 +49,7 @@ RCSID("$OpenBSD: hostfile.c,v 1.26 2001/04/12 19:15:24 markus Exp $");
49 * pointer over the key. Skips any whitespace at the beginning and at end. 49 * pointer over the key. Skips any whitespace at the beginning and at end.
50 */ 50 */
51 51
52int 52static int
53hostfile_read_key(char **cpp, u_int *bitsp, Key *ret) 53hostfile_read_key(char **cpp, u_int *bitsp, Key *ret)
54{ 54{
55 char *cp; 55 char *cp;
@@ -82,7 +82,7 @@ auth_rsa_read_key(char **cpp, u_int *bitsp, BIGNUM * e, BIGNUM * n)
82 return ret; 82 return ret;
83} 83}
84 84
85int 85static int
86hostfile_check_key(int bits, Key *key, const char *host, const char *filename, int linenum) 86hostfile_check_key(int bits, Key *key, const char *host, const char *filename, int linenum)
87{ 87{
88 if (key == NULL || key->type != KEY_RSA1 || key->rsa == NULL) 88 if (key == NULL || key->type != KEY_RSA1 || key->rsa == NULL)
diff --git a/kex.c b/kex.c
index 6b68ba504..25b3b8f8a 100644
--- a/kex.c
+++ b/kex.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: kex.c,v 1.34 2001/04/30 15:50:46 markus Exp $"); 26RCSID("$OpenBSD: kex.c,v 1.35 2001/06/23 15:12:18 itojun Exp $");
27 27
28#include <openssl/crypto.h> 28#include <openssl/crypto.h>
29 29
@@ -43,11 +43,12 @@ RCSID("$OpenBSD: kex.c,v 1.34 2001/04/30 15:50:46 markus Exp $");
43 43
44#define KEX_COOKIE_LEN 16 44#define KEX_COOKIE_LEN 16
45 45
46void kex_kexinit_finish(Kex *kex); 46/* prototype */
47void kex_choose_conf(Kex *k); 47static void kex_kexinit_finish(Kex *);
48static void kex_choose_conf(Kex *);
48 49
49/* put algorithm proposal into buffer */ 50/* put algorithm proposal into buffer */
50void 51static void
51kex_prop2buf(Buffer *b, char *proposal[PROPOSAL_MAX]) 52kex_prop2buf(Buffer *b, char *proposal[PROPOSAL_MAX])
52{ 53{
53 u_int32_t rand = 0; 54 u_int32_t rand = 0;
@@ -67,7 +68,7 @@ kex_prop2buf(Buffer *b, char *proposal[PROPOSAL_MAX])
67} 68}
68 69
69/* parse buffer and return algorithm proposal */ 70/* parse buffer and return algorithm proposal */
70char ** 71static char **
71kex_buf2prop(Buffer *raw) 72kex_buf2prop(Buffer *raw)
72{ 73{
73 Buffer b; 74 Buffer b;
@@ -95,7 +96,7 @@ kex_buf2prop(Buffer *raw)
95 return proposal; 96 return proposal;
96} 97}
97 98
98void 99static void
99kex_prop_free(char **proposal) 100kex_prop_free(char **proposal)
100{ 101{
101 int i; 102 int i;
@@ -105,13 +106,13 @@ kex_prop_free(char **proposal)
105 xfree(proposal); 106 xfree(proposal);
106} 107}
107 108
108void 109static void
109kex_protocol_error(int type, int plen, void *ctxt) 110kex_protocol_error(int type, int plen, void *ctxt)
110{ 111{
111 error("Hm, kex protocol error: type %d plen %d", type, plen); 112 error("Hm, kex protocol error: type %d plen %d", type, plen);
112} 113}
113 114
114void 115static void
115kex_clear_dispatch(void) 116kex_clear_dispatch(void)
116{ 117{
117 int i; 118 int i;
@@ -210,7 +211,7 @@ kex_setup(char *proposal[PROPOSAL_MAX])
210 return kex; 211 return kex;
211} 212}
212 213
213void 214static void
214kex_kexinit_finish(Kex *kex) 215kex_kexinit_finish(Kex *kex)
215{ 216{
216 if (!(kex->flags & KEX_INIT_SENT)) 217 if (!(kex->flags & KEX_INIT_SENT))
@@ -230,7 +231,7 @@ kex_kexinit_finish(Kex *kex)
230 } 231 }
231} 232}
232 233
233void 234static void
234choose_enc(Enc *enc, char *client, char *server) 235choose_enc(Enc *enc, char *client, char *server)
235{ 236{
236 char *name = match_list(client, server, NULL); 237 char *name = match_list(client, server, NULL);
@@ -244,7 +245,7 @@ choose_enc(Enc *enc, char *client, char *server)
244 enc->iv = NULL; 245 enc->iv = NULL;
245 enc->key = NULL; 246 enc->key = NULL;
246} 247}
247void 248static void
248choose_mac(Mac *mac, char *client, char *server) 249choose_mac(Mac *mac, char *client, char *server)
249{ 250{
250 char *name = match_list(client, server, NULL); 251 char *name = match_list(client, server, NULL);
@@ -259,7 +260,7 @@ choose_mac(Mac *mac, char *client, char *server)
259 mac->key = NULL; 260 mac->key = NULL;
260 mac->enabled = 0; 261 mac->enabled = 0;
261} 262}
262void 263static void
263choose_comp(Comp *comp, char *client, char *server) 264choose_comp(Comp *comp, char *client, char *server)
264{ 265{
265 char *name = match_list(client, server, NULL); 266 char *name = match_list(client, server, NULL);
@@ -274,7 +275,7 @@ choose_comp(Comp *comp, char *client, char *server)
274 } 275 }
275 comp->name = name; 276 comp->name = name;
276} 277}
277void 278static void
278choose_kex(Kex *k, char *client, char *server) 279choose_kex(Kex *k, char *client, char *server)
279{ 280{
280 k->name = match_list(client, server, NULL); 281 k->name = match_list(client, server, NULL);
@@ -287,7 +288,7 @@ choose_kex(Kex *k, char *client, char *server)
287 } else 288 } else
288 fatal("bad kex alg %s", k->name); 289 fatal("bad kex alg %s", k->name);
289} 290}
290void 291static void
291choose_hostkeyalg(Kex *k, char *client, char *server) 292choose_hostkeyalg(Kex *k, char *client, char *server)
292{ 293{
293 char *hostkeyalg = match_list(client, server, NULL); 294 char *hostkeyalg = match_list(client, server, NULL);
@@ -299,7 +300,7 @@ choose_hostkeyalg(Kex *k, char *client, char *server)
299 xfree(hostkeyalg); 300 xfree(hostkeyalg);
300} 301}
301 302
302void 303static void
303kex_choose_conf(Kex *kex) 304kex_choose_conf(Kex *kex)
304{ 305{
305 Newkeys *newkeys; 306 Newkeys *newkeys;
@@ -359,7 +360,7 @@ kex_choose_conf(Kex *kex)
359 kex_prop_free(peer); 360 kex_prop_free(peer);
360} 361}
361 362
362u_char * 363static u_char *
363derive_key(Kex *kex, int id, int need, u_char *hash, BIGNUM *shared_secret) 364derive_key(Kex *kex, int id, int need, u_char *hash, BIGNUM *shared_secret)
364{ 365{
365 Buffer b; 366 Buffer b;
diff --git a/kexdh.c b/kexdh.c
index d7f90b756..3e96a1ab3 100644
--- a/kexdh.c
+++ b/kexdh.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: kexdh.c,v 1.5 2001/06/23 02:34:29 markus Exp $"); 26RCSID("$OpenBSD: kexdh.c,v 1.6 2001/06/23 15:12:18 itojun Exp $");
27 27
28#include <openssl/crypto.h> 28#include <openssl/crypto.h>
29#include <openssl/bn.h> 29#include <openssl/bn.h>
@@ -38,7 +38,7 @@ RCSID("$OpenBSD: kexdh.c,v 1.5 2001/06/23 02:34:29 markus Exp $");
38#include "dh.h" 38#include "dh.h"
39#include "ssh2.h" 39#include "ssh2.h"
40 40
41u_char * 41static u_char *
42kex_dh_hash( 42kex_dh_hash(
43 char *client_version_string, 43 char *client_version_string,
44 char *server_version_string, 44 char *server_version_string,
@@ -88,7 +88,7 @@ kex_dh_hash(
88 88
89/* client */ 89/* client */
90 90
91void 91static void
92kexdh_client(Kex *kex) 92kexdh_client(Kex *kex)
93{ 93{
94 BIGNUM *dh_server_pub = NULL, *shared_secret = NULL; 94 BIGNUM *dh_server_pub = NULL, *shared_secret = NULL;
@@ -193,7 +193,7 @@ kexdh_client(Kex *kex)
193 193
194/* server */ 194/* server */
195 195
196void 196static void
197kexdh_server(Kex *kex) 197kexdh_server(Kex *kex)
198{ 198{
199 BIGNUM *shared_secret = NULL, *dh_client_pub = NULL; 199 BIGNUM *shared_secret = NULL, *dh_client_pub = NULL;
diff --git a/kexgex.c b/kexgex.c
index 01b86d903..1bc6b7e15 100644
--- a/kexgex.c
+++ b/kexgex.c
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26#include "includes.h" 26#include "includes.h"
27RCSID("$OpenBSD: kexgex.c,v 1.7 2001/06/23 02:34:29 markus Exp $"); 27RCSID("$OpenBSD: kexgex.c,v 1.8 2001/06/23 15:12:19 itojun Exp $");
28 28
29#include <openssl/bn.h> 29#include <openssl/bn.h>
30 30
@@ -39,7 +39,7 @@ RCSID("$OpenBSD: kexgex.c,v 1.7 2001/06/23 02:34:29 markus Exp $");
39#include "ssh2.h" 39#include "ssh2.h"
40#include "compat.h" 40#include "compat.h"
41 41
42u_char * 42static u_char *
43kexgex_hash( 43kexgex_hash(
44 char *client_version_string, 44 char *client_version_string,
45 char *server_version_string, 45 char *server_version_string,
@@ -99,7 +99,7 @@ kexgex_hash(
99 99
100/* client */ 100/* client */
101 101
102void 102static void
103kexgex_client(Kex *kex) 103kexgex_client(Kex *kex)
104{ 104{
105 BIGNUM *dh_server_pub = NULL, *shared_secret = NULL; 105 BIGNUM *dh_server_pub = NULL, *shared_secret = NULL;
@@ -253,7 +253,7 @@ kexgex_client(Kex *kex)
253 253
254/* server */ 254/* server */
255 255
256void 256static void
257kexgex_server(Kex *kex) 257kexgex_server(Kex *kex)
258{ 258{
259 BIGNUM *shared_secret = NULL, *dh_client_pub = NULL; 259 BIGNUM *shared_secret = NULL, *dh_client_pub = NULL;
diff --git a/key.c b/key.c
index 84306a9b0..cbe08a4c1 100644
--- a/key.c
+++ b/key.c
@@ -32,7 +32,7 @@
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34#include "includes.h" 34#include "includes.h"
35RCSID("$OpenBSD: key.c,v 1.26 2001/06/23 05:26:02 markus Exp $"); 35RCSID("$OpenBSD: key.c,v 1.27 2001/06/23 15:12:19 itojun Exp $");
36 36
37#include <openssl/evp.h> 37#include <openssl/evp.h>
38 38
@@ -153,7 +153,7 @@ key_equal(Key *a, Key *b)
153 return 0; 153 return 0;
154} 154}
155 155
156u_char* 156static u_char*
157key_fingerprint_raw(Key *k, enum fp_type dgst_type, size_t *dgst_raw_length) 157key_fingerprint_raw(Key *k, enum fp_type dgst_type, size_t *dgst_raw_length)
158{ 158{
159 EVP_MD *md = NULL; 159 EVP_MD *md = NULL;
@@ -210,7 +210,7 @@ key_fingerprint_raw(Key *k, enum fp_type dgst_type, size_t *dgst_raw_length)
210 return retval; 210 return retval;
211} 211}
212 212
213char* 213static char*
214key_fingerprint_hex(u_char* dgst_raw, size_t dgst_raw_len) 214key_fingerprint_hex(u_char* dgst_raw, size_t dgst_raw_len)
215{ 215{
216 char *retval; 216 char *retval;
@@ -227,7 +227,7 @@ key_fingerprint_hex(u_char* dgst_raw, size_t dgst_raw_len)
227 return retval; 227 return retval;
228} 228}
229 229
230char* 230static char*
231key_fingerprint_bubblebabble(u_char* dgst_raw, size_t dgst_raw_len) 231key_fingerprint_bubblebabble(u_char* dgst_raw, size_t dgst_raw_len)
232{ 232{
233 char vowels[] = { 'a', 'e', 'i', 'o', 'u', 'y' }; 233 char vowels[] = { 'a', 'e', 'i', 'o', 'u', 'y' };
@@ -308,7 +308,7 @@ key_fingerprint(Key *k, enum fp_type dgst_type, enum fp_rep dgst_rep)
308 * last processed (and maybe modified) character. Note that this may modify 308 * last processed (and maybe modified) character. Note that this may modify
309 * the buffer containing the number. 309 * the buffer containing the number.
310 */ 310 */
311int 311static int
312read_bignum(char **cpp, BIGNUM * value) 312read_bignum(char **cpp, BIGNUM * value)
313{ 313{
314 char *cp = *cpp; 314 char *cp = *cpp;
@@ -344,7 +344,7 @@ read_bignum(char **cpp, BIGNUM * value)
344 *cpp = cp; 344 *cpp = cp;
345 return 1; 345 return 1;
346} 346}
347int 347static int
348write_bignum(FILE *f, BIGNUM *num) 348write_bignum(FILE *f, BIGNUM *num)
349{ 349{
350 char *buf = BN_bn2dec(num); 350 char *buf = BN_bn2dec(num);
@@ -544,7 +544,7 @@ key_size(Key *k){
544 return 0; 544 return 0;
545} 545}
546 546
547RSA * 547static RSA *
548rsa_generate_private_key(u_int bits) 548rsa_generate_private_key(u_int bits)
549{ 549{
550 RSA *private; 550 RSA *private;
@@ -554,7 +554,7 @@ rsa_generate_private_key(u_int bits)
554 return private; 554 return private;
555} 555}
556 556
557DSA* 557static DSA*
558dsa_generate_private_key(u_int bits) 558dsa_generate_private_key(u_int bits)
559{ 559{
560 DSA *private = DSA_generate_parameters(bits, NULL, 0, NULL, NULL, NULL, NULL); 560 DSA *private = DSA_generate_parameters(bits, NULL, 0, NULL, NULL, NULL, NULL);
diff --git a/nchan.c b/nchan.c
index 6871cd86b..8916c13f4 100644
--- a/nchan.c
+++ b/nchan.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: nchan.c,v 1.28 2001/05/31 10:30:16 markus Exp $"); 26RCSID("$OpenBSD: nchan.c,v 1.29 2001/06/23 15:12:19 itojun Exp $");
27 27
28#include "ssh1.h" 28#include "ssh1.h"
29#include "ssh2.h" 29#include "ssh2.h"
@@ -74,14 +74,14 @@ chan_event_fn *chan_obuf_empty = NULL;
74/* 74/*
75 * ACTIONS: should never update the channel states 75 * ACTIONS: should never update the channel states
76 */ 76 */
77static void chan_send_ieof1(Channel *c); 77static void chan_send_ieof1(Channel *);
78static void chan_send_oclose1(Channel *c); 78static void chan_send_oclose1(Channel *);
79static void chan_send_close2(Channel *c); 79static void chan_send_close2(Channel *);
80static void chan_send_eof2(Channel *c); 80static void chan_send_eof2(Channel *);
81 81
82/* helper */ 82/* helper */
83static void chan_shutdown_write(Channel *c); 83static void chan_shutdown_write(Channel *);
84static void chan_shutdown_read(Channel *c); 84static void chan_shutdown_read(Channel *);
85 85
86/* 86/*
87 * SSH1 specific implementation of event functions 87 * SSH1 specific implementation of event functions
diff --git a/packet.c b/packet.c
index 64aabb3b0..5365abaec 100644
--- a/packet.c
+++ b/packet.c
@@ -37,7 +37,7 @@
37 */ 37 */
38 38
39#include "includes.h" 39#include "includes.h"
40RCSID("$OpenBSD: packet.c,v 1.67 2001/06/20 13:56:39 markus Exp $"); 40RCSID("$OpenBSD: packet.c,v 1.68 2001/06/23 15:12:19 itojun Exp $");
41 41
42#include "xmalloc.h" 42#include "xmalloc.h"
43#include "buffer.h" 43#include "buffer.h"
@@ -260,8 +260,8 @@ packet_get_protocol_flags()
260 * Level is compression level 1 (fastest) - 9 (slow, best) as in gzip. 260 * Level is compression level 1 (fastest) - 9 (slow, best) as in gzip.
261 */ 261 */
262 262
263void 263static void
264packet_init_compression() 264packet_init_compression(void)
265{ 265{
266 if (compression_buffer_ready == 1) 266 if (compression_buffer_ready == 1)
267 return; 267 return;
@@ -356,7 +356,7 @@ packet_put_bignum2(BIGNUM * value)
356 * encrypts the packet before sending. 356 * encrypts the packet before sending.
357 */ 357 */
358 358
359void 359static void
360packet_send1(void) 360packet_send1(void)
361{ 361{
362 char buf[8], *cp; 362 char buf[8], *cp;
@@ -427,7 +427,7 @@ packet_send1(void)
427 */ 427 */
428} 428}
429 429
430void 430static void
431set_newkeys(int mode) 431set_newkeys(int mode)
432{ 432{
433 Enc *enc; 433 Enc *enc;
@@ -480,7 +480,7 @@ set_newkeys(int mode)
480/* 480/*
481 * Finalize packet in SSH2 format (compress, mac, encrypt, enqueue) 481 * Finalize packet in SSH2 format (compress, mac, encrypt, enqueue)
482 */ 482 */
483void 483static void
484packet_send2(void) 484packet_send2(void)
485{ 485{
486 static u_int32_t seqnr = 0; 486 static u_int32_t seqnr = 0;
@@ -683,7 +683,7 @@ packet_read_expect(int *payload_len_ptr, int expected_type)
683 * Check bytes 683 * Check bytes
684 */ 684 */
685 685
686int 686static int
687packet_read_poll1(int *payload_len_ptr) 687packet_read_poll1(int *payload_len_ptr)
688{ 688{
689 u_int len, padded_len; 689 u_int len, padded_len;
@@ -761,7 +761,7 @@ packet_read_poll1(int *payload_len_ptr)
761 return type; 761 return type;
762} 762}
763 763
764int 764static int
765packet_read_poll2(int *payload_len_ptr) 765packet_read_poll2(int *payload_len_ptr)
766{ 766{
767 static u_int32_t seqnr = 0; 767 static u_int32_t seqnr = 0;
diff --git a/radix.c b/radix.c
index 3b149a82b..26b1ebe52 100644
--- a/radix.c
+++ b/radix.c
@@ -25,11 +25,13 @@
25#include "includes.h" 25#include "includes.h"
26#include "uuencode.h" 26#include "uuencode.h"
27 27
28RCSID("$OpenBSD: radix.c,v 1.15 2001/01/16 23:58:09 deraadt Exp $"); 28RCSID("$OpenBSD: radix.c,v 1.16 2001/06/23 15:12:19 itojun Exp $");
29 29
30#ifdef AFS 30#ifdef AFS
31#include <krb.h> 31#include <krb.h>
32 32
33#include <radix.h>
34
33typedef u_char my_u_char; 35typedef u_char my_u_char;
34typedef u_int my_u_int32_t; 36typedef u_int my_u_int32_t;
35typedef u_short my_u_short; 37typedef u_short my_u_short;
diff --git a/readpass.c b/readpass.c
index d059272e7..05883dfcd 100644
--- a/readpass.c
+++ b/readpass.c
@@ -32,7 +32,7 @@
32 */ 32 */
33 33
34#include "includes.h" 34#include "includes.h"
35RCSID("$OpenBSD: readpass.c,v 1.17 2001/05/06 17:52:07 mouring Exp $"); 35RCSID("$OpenBSD: readpass.c,v 1.18 2001/06/23 15:12:19 itojun Exp $");
36 36
37#include "xmalloc.h" 37#include "xmalloc.h"
38#include "cli.h" 38#include "cli.h"
@@ -42,7 +42,7 @@ RCSID("$OpenBSD: readpass.c,v 1.17 2001/05/06 17:52:07 mouring Exp $");
42#include "atomicio.h" 42#include "atomicio.h"
43#include "ssh.h" 43#include "ssh.h"
44 44
45char * 45static char *
46ssh_askpass(char *askpass, const char *msg) 46ssh_askpass(char *askpass, const char *msg)
47{ 47{
48 pid_t pid; 48 pid_t pid;
diff --git a/scp.c b/scp.c
index 1a83a298f..e5e3a97b8 100644
--- a/scp.c
+++ b/scp.c
@@ -75,7 +75,7 @@
75 */ 75 */
76 76
77#include "includes.h" 77#include "includes.h"
78RCSID("$OpenBSD: scp.c,v 1.75 2001/06/23 00:16:16 deraadt Exp $"); 78RCSID("$OpenBSD: scp.c,v 1.76 2001/06/23 15:12:19 itojun Exp $");
79 79
80#include "xmalloc.h" 80#include "xmalloc.h"
81#include "atomicio.h" 81#include "atomicio.h"
@@ -210,6 +210,7 @@ int pflag, iamremote, iamrecursive, targetshouldbedirectory;
210#define CMDNEEDS 64 210#define CMDNEEDS 64
211char cmd[CMDNEEDS]; /* must hold "rcp -r -p -d\0" */ 211char cmd[CMDNEEDS]; /* must hold "rcp -r -p -d\0" */
212 212
213int main(int, char *[]);
213int response(void); 214int response(void);
214void rsource(char *, struct stat *); 215void rsource(char *, struct stat *);
215void sink(int, char *[]); 216void sink(int, char *[]);
@@ -1060,7 +1061,7 @@ lostconn(signo)
1060} 1061}
1061 1062
1062 1063
1063void 1064static void
1064alarmtimer(int wait) 1065alarmtimer(int wait)
1065{ 1066{
1066 struct itimerval itv; 1067 struct itimerval itv;
@@ -1071,7 +1072,7 @@ alarmtimer(int wait)
1071 setitimer(ITIMER_REAL, &itv, NULL); 1072 setitimer(ITIMER_REAL, &itv, NULL);
1072} 1073}
1073 1074
1074void 1075static void
1075updateprogressmeter(int ignore) 1076updateprogressmeter(int ignore)
1076{ 1077{
1077 int save_errno = errno; 1078 int save_errno = errno;
@@ -1080,7 +1081,7 @@ updateprogressmeter(int ignore)
1080 errno = save_errno; 1081 errno = save_errno;
1081} 1082}
1082 1083
1083int 1084static int
1084foregroundproc(void) 1085foregroundproc(void)
1085{ 1086{
1086 static pid_t pgrp = -1; 1087 static pid_t pgrp = -1;
diff --git a/servconf.c b/servconf.c
index d1205a81f..55b0b0039 100644
--- a/servconf.c
+++ b/servconf.c
@@ -10,7 +10,7 @@
10 */ 10 */
11 11
12#include "includes.h" 12#include "includes.h"
13RCSID("$OpenBSD: servconf.c,v 1.83 2001/06/08 15:25:40 markus Exp $"); 13RCSID("$OpenBSD: servconf.c,v 1.84 2001/06/23 15:12:19 itojun Exp $");
14 14
15#ifdef KRB4 15#ifdef KRB4
16#include <krb.h> 16#include <krb.h>
@@ -31,8 +31,8 @@ RCSID("$OpenBSD: servconf.c,v 1.83 2001/06/08 15:25:40 markus Exp $");
31#include "kex.h" 31#include "kex.h"
32#include "mac.h" 32#include "mac.h"
33 33
34void add_listen_addr(ServerOptions *options, char *addr, u_short port); 34static void add_listen_addr(ServerOptions *, char *, u_short);
35void add_one_listen_addr(ServerOptions *options, char *addr, u_short port); 35static void add_one_listen_addr(ServerOptions *, char *, u_short);
36 36
37/* AF_UNSPEC or AF_INET or AF_INET6 */ 37/* AF_UNSPEC or AF_INET or AF_INET6 */
38extern int IPv4or6; 38extern int IPv4or6;
@@ -333,7 +333,7 @@ parse_token(const char *cp, const char *filename,
333 return sBadOption; 333 return sBadOption;
334} 334}
335 335
336void 336static void
337add_listen_addr(ServerOptions *options, char *addr, u_short port) 337add_listen_addr(ServerOptions *options, char *addr, u_short port)
338{ 338{
339 int i; 339 int i;
@@ -347,7 +347,7 @@ add_listen_addr(ServerOptions *options, char *addr, u_short port)
347 add_one_listen_addr(options, addr, port); 347 add_one_listen_addr(options, addr, port);
348} 348}
349 349
350void 350static void
351add_one_listen_addr(ServerOptions *options, char *addr, u_short port) 351add_one_listen_addr(ServerOptions *options, char *addr, u_short port)
352{ 352{
353 struct addrinfo hints, *ai, *aitop; 353 struct addrinfo hints, *ai, *aitop;
diff --git a/serverloop.c b/serverloop.c
index 1ce6c9106..1ffa4dbfb 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: serverloop.c,v 1.69 2001/06/20 13:56:39 markus Exp $"); 38RCSID("$OpenBSD: serverloop.c,v 1.70 2001/06/23 15:12:19 itojun Exp $");
39 39
40#include "xmalloc.h" 40#include "xmalloc.h"
41#include "packet.h" 41#include "packet.h"
@@ -84,13 +84,15 @@ static u_int buffer_high; /* "Soft" max buffer size. */
84 * This SIGCHLD kludge is used to detect when the child exits. The server 84 * This SIGCHLD kludge is used to detect when the child exits. The server
85 * will exit after that, as soon as forwarded connections have terminated. 85 * will exit after that, as soon as forwarded connections have terminated.
86 */ 86 */
87
87static volatile int child_terminated; /* The child has terminated. */ 88static volatile int child_terminated; /* The child has terminated. */
88 89
89void server_init_dispatch(void); 90/* prototypes */
91static void server_init_dispatch(void);
90 92
91int client_alive_timeouts = 0; 93int client_alive_timeouts = 0;
92 94
93void 95static void
94sigchld_handler(int sig) 96sigchld_handler(int sig)
95{ 97{
96 int save_errno = errno; 98 int save_errno = errno;
@@ -104,7 +106,7 @@ sigchld_handler(int sig)
104 * Make packets from buffered stderr data, and buffer it for sending 106 * Make packets from buffered stderr data, and buffer it for sending
105 * to the client. 107 * to the client.
106 */ 108 */
107void 109static void
108make_packets_from_stderr_data(void) 110make_packets_from_stderr_data(void)
109{ 111{
110 int len; 112 int len;
@@ -133,7 +135,7 @@ make_packets_from_stderr_data(void)
133 * Make packets from buffered stdout data, and buffer it for sending to the 135 * Make packets from buffered stdout data, and buffer it for sending to the
134 * client. 136 * client.
135 */ 137 */
136void 138static void
137make_packets_from_stdout_data(void) 139make_packets_from_stdout_data(void)
138{ 140{
139 int len; 141 int len;
@@ -164,7 +166,7 @@ make_packets_from_stdout_data(void)
164 * have data or can accept data. Optionally, a maximum time can be specified 166 * have data or can accept data. Optionally, a maximum time can be specified
165 * for the duration of the wait (0 = infinite). 167 * for the duration of the wait (0 = infinite).
166 */ 168 */
167void 169static void
168wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp, 170wait_until_can_do_something(fd_set **readsetp, fd_set **writesetp, int *maxfdp,
169 u_int max_time_milliseconds) 171 u_int max_time_milliseconds)
170{ 172{
@@ -286,7 +288,7 @@ retry_select:
286 * Processes input from the client and the program. Input data is stored 288 * Processes input from the client and the program. Input data is stored
287 * in buffers and processed later. 289 * in buffers and processed later.
288 */ 290 */
289void 291static void
290process_input(fd_set * readset) 292process_input(fd_set * readset)
291{ 293{
292 int len; 294 int len;
@@ -342,7 +344,7 @@ process_input(fd_set * readset)
342/* 344/*
343 * Sends data from internal buffers to client program stdin. 345 * Sends data from internal buffers to client program stdin.
344 */ 346 */
345void 347static void
346process_output(fd_set * writeset) 348process_output(fd_set * writeset)
347{ 349{
348 struct termios tio; 350 struct termios tio;
@@ -390,7 +392,7 @@ process_output(fd_set * writeset)
390 * Wait until all buffered output has been sent to the client. 392 * Wait until all buffered output has been sent to the client.
391 * This is used when the program terminates. 393 * This is used when the program terminates.
392 */ 394 */
393void 395static void
394drain_output(void) 396drain_output(void)
395{ 397{
396 /* Send any buffered stdout data to the client. */ 398 /* Send any buffered stdout data to the client. */
@@ -415,7 +417,7 @@ drain_output(void)
415 packet_write_wait(); 417 packet_write_wait();
416} 418}
417 419
418void 420static void
419process_buffered_input_packets(void) 421process_buffered_input_packets(void)
420{ 422{
421 dispatch_run(DISPATCH_NONBLOCK, NULL, compat20 ? xxx_kex : NULL); 423 dispatch_run(DISPATCH_NONBLOCK, NULL, compat20 ? xxx_kex : NULL);
@@ -706,7 +708,7 @@ server_loop2(void)
706 session_close_by_pid(pid, status); 708 session_close_by_pid(pid, status);
707} 709}
708 710
709void 711static void
710server_input_channel_failure(int type, int plen, void *ctxt) 712server_input_channel_failure(int type, int plen, void *ctxt)
711{ 713{
712 debug("Got CHANNEL_FAILURE for keepalive"); 714 debug("Got CHANNEL_FAILURE for keepalive");
@@ -719,7 +721,7 @@ server_input_channel_failure(int type, int plen, void *ctxt)
719} 721}
720 722
721 723
722void 724static void
723server_input_stdin_data(int type, int plen, void *ctxt) 725server_input_stdin_data(int type, int plen, void *ctxt)
724{ 726{
725 char *data; 727 char *data;
@@ -736,7 +738,7 @@ server_input_stdin_data(int type, int plen, void *ctxt)
736 xfree(data); 738 xfree(data);
737} 739}
738 740
739void 741static void
740server_input_eof(int type, int plen, void *ctxt) 742server_input_eof(int type, int plen, void *ctxt)
741{ 743{
742 /* 744 /*
@@ -749,7 +751,7 @@ server_input_eof(int type, int plen, void *ctxt)
749 stdin_eof = 1; 751 stdin_eof = 1;
750} 752}
751 753
752void 754static void
753server_input_window_size(int type, int plen, void *ctxt) 755server_input_window_size(int type, int plen, void *ctxt)
754{ 756{
755 int row = packet_get_int(); 757 int row = packet_get_int();
@@ -763,7 +765,7 @@ server_input_window_size(int type, int plen, void *ctxt)
763 pty_change_window_size(fdin, row, col, xpixel, ypixel); 765 pty_change_window_size(fdin, row, col, xpixel, ypixel);
764} 766}
765 767
766Channel * 768static Channel *
767server_request_direct_tcpip(char *ctype) 769server_request_direct_tcpip(char *ctype)
768{ 770{
769 Channel *c; 771 Channel *c;
@@ -796,7 +798,7 @@ server_request_direct_tcpip(char *ctype)
796 return c; 798 return c;
797} 799}
798 800
799Channel * 801static Channel *
800server_request_session(char *ctype) 802server_request_session(char *ctype)
801{ 803{
802 Channel *c; 804 Channel *c;
@@ -827,7 +829,7 @@ server_request_session(char *ctype)
827 return c; 829 return c;
828} 830}
829 831
830void 832static void
831server_input_channel_open(int type, int plen, void *ctxt) 833server_input_channel_open(int type, int plen, void *ctxt)
832{ 834{
833 Channel *c = NULL; 835 Channel *c = NULL;
@@ -877,7 +879,7 @@ server_input_channel_open(int type, int plen, void *ctxt)
877 xfree(ctype); 879 xfree(ctype);
878} 880}
879 881
880void 882static void
881server_input_global_request(int type, int plen, void *ctxt) 883server_input_global_request(int type, int plen, void *ctxt)
882{ 884{
883 char *rtype; 885 char *rtype;
@@ -927,7 +929,7 @@ server_input_global_request(int type, int plen, void *ctxt)
927 xfree(rtype); 929 xfree(rtype);
928} 930}
929 931
930void 932static void
931server_init_dispatch_20(void) 933server_init_dispatch_20(void)
932{ 934{
933 debug("server_init_dispatch_20"); 935 debug("server_init_dispatch_20");
@@ -947,7 +949,7 @@ server_init_dispatch_20(void)
947 /* rekeying */ 949 /* rekeying */
948 dispatch_set(SSH2_MSG_KEXINIT, &kex_input_kexinit); 950 dispatch_set(SSH2_MSG_KEXINIT, &kex_input_kexinit);
949} 951}
950void 952static void
951server_init_dispatch_13(void) 953server_init_dispatch_13(void)
952{ 954{
953 debug("server_init_dispatch_13"); 955 debug("server_init_dispatch_13");
@@ -962,7 +964,7 @@ server_init_dispatch_13(void)
962 dispatch_set(SSH_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure); 964 dispatch_set(SSH_MSG_CHANNEL_OPEN_FAILURE, &channel_input_open_failure);
963 dispatch_set(SSH_MSG_PORT_OPEN, &channel_input_port_open); 965 dispatch_set(SSH_MSG_PORT_OPEN, &channel_input_port_open);
964} 966}
965void 967static void
966server_init_dispatch_15(void) 968server_init_dispatch_15(void)
967{ 969{
968 server_init_dispatch_13(); 970 server_init_dispatch_13();
@@ -970,7 +972,7 @@ server_init_dispatch_15(void)
970 dispatch_set(SSH_MSG_CHANNEL_CLOSE, &channel_input_ieof); 972 dispatch_set(SSH_MSG_CHANNEL_CLOSE, &channel_input_ieof);
971 dispatch_set(SSH_MSG_CHANNEL_CLOSE_CONFIRMATION, &channel_input_oclose); 973 dispatch_set(SSH_MSG_CHANNEL_CLOSE_CONFIRMATION, &channel_input_oclose);
972} 974}
973void 975static void
974server_init_dispatch(void) 976server_init_dispatch(void)
975{ 977{
976 if (compat20) 978 if (compat20)
diff --git a/session.c b/session.c
index 0c723ef1a..92870a111 100644
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
33 */ 33 */
34 34
35#include "includes.h" 35#include "includes.h"
36RCSID("$OpenBSD: session.c,v 1.93 2001/06/21 21:08:25 markus Exp $"); 36RCSID("$OpenBSD: session.c,v 1.94 2001/06/23 15:12:20 itojun Exp $");
37 37
38#include "ssh.h" 38#include "ssh.h"
39#include "ssh1.h" 39#include "ssh1.h"
@@ -120,25 +120,22 @@ struct Session {
120/* func */ 120/* func */
121 121
122Session *session_new(void); 122Session *session_new(void);
123void session_set_fds(Session *s, int fdin, int fdout, int fderr); 123void session_set_fds(Session *, int, int, int);
124void session_pty_cleanup(void *session); 124static void session_pty_cleanup(void *);
125int session_pty_req(Session *s); 125void session_proctitle(Session *);
126void session_proctitle(Session *s); 126int session_setup_x11fwd(Session *);
127int session_setup_x11fwd(Session *s); 127void do_exec_pty(Session *, const char *);
128void session_close(Session *s); 128void do_exec_no_pty(Session *, const char *);
129void do_exec_pty(Session *s, const char *command); 129void do_exec(Session *, const char *);
130void do_exec_no_pty(Session *s, const char *command); 130void do_login(Session *, const char *);
131void do_exec(Session *s, const char *command); 131void do_child(Session *, const char *);
132void do_login(Session *s, const char *command);
133#ifdef LOGIN_NEEDS_UTMPX
134void do_pre_login(Session *s);
135#endif
136void do_child(Session *s, const char *command);
137void do_motd(void); 132void do_motd(void);
138int check_quietlogin(Session *s, const char *command);
139 133
140void do_authenticated1(Authctxt *authctxt); 134static void do_authenticated1(Authctxt *);
141void do_authenticated2(Authctxt *authctxt); 135static void do_authenticated2(Authctxt *);
136
137static void session_close(Session *);
138static int session_pty_req(Session *);
142 139
143/* import */ 140/* import */
144extern ServerOptions options; 141extern ServerOptions options;
@@ -209,7 +206,7 @@ do_authenticated(Authctxt *authctxt)
209 * terminals are allocated, X11, TCP/IP, and authentication agent forwardings 206 * terminals are allocated, X11, TCP/IP, and authentication agent forwardings
210 * are requested, etc. 207 * are requested, etc.
211 */ 208 */
212void 209static void
213do_authenticated1(Authctxt *authctxt) 210do_authenticated1(Authctxt *authctxt)
214{ 211{
215 Session *s; 212 Session *s;
@@ -738,7 +735,7 @@ check_quietlogin(Session *s, const char *command)
738 * Sets the value of the given variable in the environment. If the variable 735 * Sets the value of the given variable in the environment. If the variable
739 * already exists, its value is overriden. 736 * already exists, its value is overriden.
740 */ 737 */
741void 738static void
742child_set_env(char ***envp, u_int *envsizep, const char *name, 739child_set_env(char ***envp, u_int *envsizep, const char *name,
743 const char *value) 740 const char *value)
744{ 741{
@@ -779,7 +776,7 @@ child_set_env(char ***envp, u_int *envsizep, const char *name,
779 * Otherwise, it must consist of empty lines, comments (line starts with '#') 776 * Otherwise, it must consist of empty lines, comments (line starts with '#')
780 * and assignments of the form name=value. No other forms are allowed. 777 * and assignments of the form name=value. No other forms are allowed.
781 */ 778 */
782void 779static void
783read_environment_file(char ***env, u_int *envsize, 780read_environment_file(char ***env, u_int *envsize,
784 const char *filename) 781 const char *filename)
785{ 782{
@@ -1488,7 +1485,7 @@ session_new(void)
1488 return NULL; 1485 return NULL;
1489} 1486}
1490 1487
1491void 1488static void
1492session_dump(void) 1489session_dump(void)
1493{ 1490{
1494 int i; 1491 int i;
@@ -1520,7 +1517,7 @@ session_open(int chanid)
1520 return 1; 1517 return 1;
1521} 1518}
1522 1519
1523Session * 1520static Session *
1524session_by_channel(int id) 1521session_by_channel(int id)
1525{ 1522{
1526 int i; 1523 int i;
@@ -1536,7 +1533,7 @@ session_by_channel(int id)
1536 return NULL; 1533 return NULL;
1537} 1534}
1538 1535
1539Session * 1536static Session *
1540session_by_pid(pid_t pid) 1537session_by_pid(pid_t pid)
1541{ 1538{
1542 int i; 1539 int i;
@@ -1551,7 +1548,7 @@ session_by_pid(pid_t pid)
1551 return NULL; 1548 return NULL;
1552} 1549}
1553 1550
1554int 1551static int
1555session_window_change_req(Session *s) 1552session_window_change_req(Session *s)
1556{ 1553{
1557 s->col = packet_get_int(); 1554 s->col = packet_get_int();
@@ -1563,7 +1560,7 @@ session_window_change_req(Session *s)
1563 return 1; 1560 return 1;
1564} 1561}
1565 1562
1566int 1563static int
1567session_pty_req(Session *s) 1564session_pty_req(Session *s)
1568{ 1565{
1569 u_int len; 1566 u_int len;
@@ -1628,7 +1625,7 @@ session_pty_req(Session *s)
1628 return 1; 1625 return 1;
1629} 1626}
1630 1627
1631int 1628static int
1632session_subsystem_req(Session *s) 1629session_subsystem_req(Session *s)
1633{ 1630{
1634 u_int len; 1631 u_int len;
@@ -1655,7 +1652,7 @@ session_subsystem_req(Session *s)
1655 return success; 1652 return success;
1656} 1653}
1657 1654
1658int 1655static int
1659session_x11_req(Session *s) 1656session_x11_req(Session *s)
1660{ 1657{
1661 int success; 1658 int success;
@@ -1676,7 +1673,7 @@ session_x11_req(Session *s)
1676 return success; 1673 return success;
1677} 1674}
1678 1675
1679int 1676static int
1680session_shell_req(Session *s) 1677session_shell_req(Session *s)
1681{ 1678{
1682 packet_done(); 1679 packet_done();
@@ -1684,7 +1681,7 @@ session_shell_req(Session *s)
1684 return 1; 1681 return 1;
1685} 1682}
1686 1683
1687int 1684static int
1688session_exec_req(Session *s) 1685session_exec_req(Session *s)
1689{ 1686{
1690 u_int len; 1687 u_int len;
@@ -1695,7 +1692,7 @@ session_exec_req(Session *s)
1695 return 1; 1692 return 1;
1696} 1693}
1697 1694
1698int 1695static int
1699session_auth_agent_req(Session *s) 1696session_auth_agent_req(Session *s)
1700{ 1697{
1701 static int called = 0; 1698 static int called = 0;
@@ -1788,7 +1785,7 @@ session_set_fds(Session *s, int fdin, int fdout, int fderr)
1788 * Function to perform pty cleanup. Also called if we get aborted abnormally 1785 * Function to perform pty cleanup. Also called if we get aborted abnormally
1789 * (e.g., due to a dropped connection). 1786 * (e.g., due to a dropped connection).
1790 */ 1787 */
1791void 1788static void
1792session_pty_cleanup(void *session) 1789session_pty_cleanup(void *session)
1793{ 1790{
1794 Session *s = session; 1791 Session *s = session;
@@ -1818,7 +1815,7 @@ session_pty_cleanup(void *session)
1818 error("close(s->ptymaster): %s", strerror(errno)); 1815 error("close(s->ptymaster): %s", strerror(errno));
1819} 1816}
1820 1817
1821void 1818static void
1822session_exit_message(Session *s, int status) 1819session_exit_message(Session *s, int status)
1823{ 1820{
1824 Channel *c; 1821 Channel *c;
@@ -1867,7 +1864,7 @@ session_exit_message(Session *s, int status)
1867 s->chanid = -1; 1864 s->chanid = -1;
1868} 1865}
1869 1866
1870void 1867static void
1871session_close(Session *s) 1868session_close(Session *s)
1872{ 1869{
1873 debug("session_close: session %d pid %d", s->self, s->pid); 1870 debug("session_close: session %d pid %d", s->self, s->pid);
@@ -1928,7 +1925,7 @@ session_close_by_channel(int id, void *arg)
1928 } 1925 }
1929} 1926}
1930 1927
1931char * 1928static char *
1932session_tty_list(void) 1929session_tty_list(void)
1933{ 1930{
1934 static char buf[1024]; 1931 static char buf[1024];
@@ -1991,7 +1988,7 @@ session_setup_x11fwd(Session *s)
1991 return 1; 1988 return 1;
1992} 1989}
1993 1990
1994void 1991static void
1995do_authenticated2(Authctxt *authctxt) 1992do_authenticated2(Authctxt *authctxt)
1996{ 1993{
1997 server_loop2(); 1994 server_loop2();
diff --git a/sftp-client.c b/sftp-client.c
index cf672e70d..9670a7660 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -29,7 +29,7 @@
29/* XXX: copy between two remote sites */ 29/* XXX: copy between two remote sites */
30 30
31#include "includes.h" 31#include "includes.h"
32RCSID("$OpenBSD: sftp-client.c,v 1.16 2001/04/05 10:42:52 markus Exp $"); 32RCSID("$OpenBSD: sftp-client.c,v 1.17 2001/06/23 15:12:20 itojun Exp $");
33 33
34#include "ssh.h" 34#include "ssh.h"
35#include "buffer.h" 35#include "buffer.h"
@@ -51,7 +51,7 @@ RCSID("$OpenBSD: sftp-client.c,v 1.16 2001/04/05 10:42:52 markus Exp $");
51/* Message ID */ 51/* Message ID */
52static u_int msg_id = 1; 52static u_int msg_id = 1;
53 53
54void 54static void
55send_msg(int fd, Buffer *m) 55send_msg(int fd, Buffer *m)
56{ 56{
57 int mlen = buffer_len(m); 57 int mlen = buffer_len(m);
@@ -70,7 +70,7 @@ send_msg(int fd, Buffer *m)
70 buffer_free(&oqueue); 70 buffer_free(&oqueue);
71} 71}
72 72
73void 73static void
74get_msg(int fd, Buffer *m) 74get_msg(int fd, Buffer *m)
75{ 75{
76 u_int len, msg_len; 76 u_int len, msg_len;
@@ -98,7 +98,7 @@ get_msg(int fd, Buffer *m)
98 } 98 }
99} 99}
100 100
101void 101static void
102send_string_request(int fd, u_int id, u_int code, char *s, 102send_string_request(int fd, u_int id, u_int code, char *s,
103 u_int len) 103 u_int len)
104{ 104{
@@ -113,7 +113,7 @@ send_string_request(int fd, u_int id, u_int code, char *s,
113 buffer_free(&msg); 113 buffer_free(&msg);
114} 114}
115 115
116void 116static void
117send_string_attrs_request(int fd, u_int id, u_int code, char *s, 117send_string_attrs_request(int fd, u_int id, u_int code, char *s,
118 u_int len, Attrib *a) 118 u_int len, Attrib *a)
119{ 119{
@@ -129,7 +129,7 @@ send_string_attrs_request(int fd, u_int id, u_int code, char *s,
129 buffer_free(&msg); 129 buffer_free(&msg);
130} 130}
131 131
132u_int 132static u_int
133get_status(int fd, int expected_id) 133get_status(int fd, int expected_id)
134{ 134{
135 Buffer msg; 135 Buffer msg;
@@ -154,7 +154,7 @@ get_status(int fd, int expected_id)
154 return(status); 154 return(status);
155} 155}
156 156
157char * 157static char *
158get_handle(int fd, u_int expected_id, u_int *len) 158get_handle(int fd, u_int expected_id, u_int *len)
159{ 159{
160 Buffer msg; 160 Buffer msg;
@@ -183,7 +183,7 @@ get_handle(int fd, u_int expected_id, u_int *len)
183 return(handle); 183 return(handle);
184} 184}
185 185
186Attrib * 186static Attrib *
187get_decode_stat(int fd, u_int expected_id, int quiet) 187get_decode_stat(int fd, u_int expected_id, int quiet)
188{ 188{
189 Buffer msg; 189 Buffer msg;
@@ -283,7 +283,7 @@ do_close(int fd_in, int fd_out, char *handle, u_int handle_len)
283} 283}
284 284
285 285
286int 286static int
287do_lsreaddir(int fd_in, int fd_out, char *path, int printflag, 287do_lsreaddir(int fd_in, int fd_out, char *path, int printflag,
288 SFTP_DIRENT ***dir) 288 SFTP_DIRENT ***dir)
289{ 289{
diff --git a/sftp-glob.c b/sftp-glob.c
index aee5e91ac..18b44f82e 100644
--- a/sftp-glob.c
+++ b/sftp-glob.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: sftp-glob.c,v 1.5 2001/04/15 08:43:46 markus Exp $"); 26RCSID("$OpenBSD: sftp-glob.c,v 1.6 2001/06/23 15:12:20 itojun Exp $");
27 27
28#include "ssh.h" 28#include "ssh.h"
29#include "buffer.h" 29#include "buffer.h"
@@ -49,7 +49,8 @@ static struct {
49 int fd_out; 49 int fd_out;
50} cur; 50} cur;
51 51
52void *fudge_opendir(const char *path) 52static void *
53fudge_opendir(const char *path)
53{ 54{
54 struct SFTP_OPENDIR *r; 55 struct SFTP_OPENDIR *r;
55 56
@@ -63,7 +64,8 @@ void *fudge_opendir(const char *path)
63 return((void*)r); 64 return((void*)r);
64} 65}
65 66
66struct dirent *fudge_readdir(struct SFTP_OPENDIR *od) 67static struct dirent *
68fudge_readdir(struct SFTP_OPENDIR *od)
67{ 69{
68 /* Solaris needs sizeof(dirent) + path length (see below) */ 70 /* Solaris needs sizeof(dirent) + path length (see below) */
69 static char buf[sizeof(struct dirent) + MAXPATHLEN]; 71 static char buf[sizeof(struct dirent) + MAXPATHLEN];
@@ -101,13 +103,15 @@ struct dirent *fudge_readdir(struct SFTP_OPENDIR *od)
101 return(ret); 103 return(ret);
102} 104}
103 105
104void fudge_closedir(struct SFTP_OPENDIR *od) 106static void
107fudge_closedir(struct SFTP_OPENDIR *od)
105{ 108{
106 free_sftp_dirents(od->dir); 109 free_sftp_dirents(od->dir);
107 xfree(od); 110 xfree(od);
108} 111}
109 112
110void attrib_to_stat(Attrib *a, struct stat *st) 113static void
114attrib_to_stat(Attrib *a, struct stat *st)
111{ 115{
112 memset(st, 0, sizeof(*st)); 116 memset(st, 0, sizeof(*st));
113 117
@@ -125,7 +129,8 @@ void attrib_to_stat(Attrib *a, struct stat *st)
125 } 129 }
126} 130}
127 131
128int fudge_lstat(const char *path, struct stat *st) 132static int
133fudge_lstat(const char *path, struct stat *st)
129{ 134{
130 Attrib *a; 135 Attrib *a;
131 136
@@ -137,7 +142,8 @@ int fudge_lstat(const char *path, struct stat *st)
137 return(0); 142 return(0);
138} 143}
139 144
140int fudge_stat(const char *path, struct stat *st) 145static int
146fudge_stat(const char *path, struct stat *st)
141{ 147{
142 Attrib *a; 148 Attrib *a;
143 149
diff --git a/sftp-int.c b/sftp-int.c
index 03b229999..aa3a8a02f 100644
--- a/sftp-int.c
+++ b/sftp-int.c
@@ -26,7 +26,7 @@
26/* XXX: recursive operations */ 26/* XXX: recursive operations */
27 27
28#include "includes.h" 28#include "includes.h"
29RCSID("$OpenBSD: sftp-int.c,v 1.36 2001/04/15 08:43:46 markus Exp $"); 29RCSID("$OpenBSD: sftp-int.c,v 1.37 2001/06/23 15:12:20 itojun Exp $");
30 30
31#include "buffer.h" 31#include "buffer.h"
32#include "xmalloc.h" 32#include "xmalloc.h"
@@ -111,7 +111,7 @@ const struct CMD cmds[] = {
111 { NULL, -1} 111 { NULL, -1}
112}; 112};
113 113
114void 114static void
115help(void) 115help(void)
116{ 116{
117 printf("Available commands:\n"); 117 printf("Available commands:\n");
@@ -143,7 +143,7 @@ help(void)
143 printf("? Synonym for help\n"); 143 printf("? Synonym for help\n");
144} 144}
145 145
146void 146static void
147local_do_shell(const char *args) 147local_do_shell(const char *args)
148{ 148{
149 int status; 149 int status;
@@ -180,7 +180,7 @@ local_do_shell(const char *args)
180 error("Shell exited with status %d", WEXITSTATUS(status)); 180 error("Shell exited with status %d", WEXITSTATUS(status));
181} 181}
182 182
183void 183static void
184local_do_ls(const char *args) 184local_do_ls(const char *args)
185{ 185{
186 if (!args || !*args) 186 if (!args || !*args)
@@ -196,7 +196,7 @@ local_do_ls(const char *args)
196 } 196 }
197} 197}
198 198
199char * 199static char *
200path_append(char *p1, char *p2) 200path_append(char *p1, char *p2)
201{ 201{
202 char *ret; 202 char *ret;
@@ -210,7 +210,7 @@ path_append(char *p1, char *p2)
210 return(ret); 210 return(ret);
211} 211}
212 212
213char * 213static char *
214make_absolute(char *p, char *pwd) 214make_absolute(char *p, char *pwd)
215{ 215{
216 char *abs; 216 char *abs;
@@ -224,7 +224,7 @@ make_absolute(char *p, char *pwd)
224 return(p); 224 return(p);
225} 225}
226 226
227int 227static int
228infer_path(const char *p, char **ifp) 228infer_path(const char *p, char **ifp)
229{ 229{
230 char *cp; 230 char *cp;
@@ -244,7 +244,7 @@ infer_path(const char *p, char **ifp)
244 return(0); 244 return(0);
245} 245}
246 246
247int 247static int
248parse_getput_flags(const char **cpp, int *pflag) 248parse_getput_flags(const char **cpp, int *pflag)
249{ 249{
250 const char *cp = *cpp; 250 const char *cp = *cpp;
@@ -267,7 +267,7 @@ parse_getput_flags(const char **cpp, int *pflag)
267 return(0); 267 return(0);
268} 268}
269 269
270int 270static int
271get_pathname(const char **cpp, char **path) 271get_pathname(const char **cpp, char **path)
272{ 272{
273 const char *cp = *cpp, *end; 273 const char *cp = *cpp, *end;
@@ -315,7 +315,7 @@ get_pathname(const char **cpp, char **path)
315 return (-1); 315 return (-1);
316} 316}
317 317
318int 318static int
319is_dir(char *path) 319is_dir(char *path)
320{ 320{
321 struct stat sb; 321 struct stat sb;
@@ -327,7 +327,7 @@ is_dir(char *path)
327 return(sb.st_mode & S_IFDIR); 327 return(sb.st_mode & S_IFDIR);
328} 328}
329 329
330int 330static int
331remote_is_dir(int in, int out, char *path) 331remote_is_dir(int in, int out, char *path)
332{ 332{
333 Attrib *a; 333 Attrib *a;
@@ -340,7 +340,7 @@ remote_is_dir(int in, int out, char *path)
340 return(a->perm & S_IFDIR); 340 return(a->perm & S_IFDIR);
341} 341}
342 342
343int 343static int
344process_get(int in, int out, char *src, char *dst, char *pwd, int pflag) 344process_get(int in, int out, char *src, char *dst, char *pwd, int pflag)
345{ 345{
346 char *abs_src = NULL; 346 char *abs_src = NULL;
@@ -417,7 +417,7 @@ out:
417 return(err); 417 return(err);
418} 418}
419 419
420int 420static int
421process_put(int in, int out, char *src, char *dst, char *pwd, int pflag) 421process_put(int in, int out, char *src, char *dst, char *pwd, int pflag)
422{ 422{
423 char *tmp_dst = NULL; 423 char *tmp_dst = NULL;
@@ -497,7 +497,7 @@ out:
497 return(err); 497 return(err);
498} 498}
499 499
500int 500static int
501parse_args(const char **cpp, int *pflag, unsigned long *n_arg, 501parse_args(const char **cpp, int *pflag, unsigned long *n_arg,
502 char **path1, char **path2) 502 char **path1, char **path2)
503{ 503{
@@ -642,7 +642,7 @@ parse_args(const char **cpp, int *pflag, unsigned long *n_arg,
642 return(cmdnum); 642 return(cmdnum);
643} 643}
644 644
645int 645static int
646parse_dispatch_command(int in, int out, const char *cmd, char **pwd) 646parse_dispatch_command(int in, int out, const char *cmd, char **pwd)
647{ 647{
648 char *path1, *path2, *tmp; 648 char *path1, *path2, *tmp;
diff --git a/sftp-server.c b/sftp-server.c
index ab6291e61..e6353bceb 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -22,7 +22,7 @@
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24#include "includes.h" 24#include "includes.h"
25RCSID("$OpenBSD: sftp-server.c,v 1.27 2001/06/22 22:21:20 markus Exp $"); 25RCSID("$OpenBSD: sftp-server.c,v 1.28 2001/06/23 15:12:20 itojun Exp $");
26 26
27#include "buffer.h" 27#include "buffer.h"
28#include "bufaux.h" 28#include "bufaux.h"
@@ -62,7 +62,7 @@ struct Stat {
62 Attrib attrib; 62 Attrib attrib;
63}; 63};
64 64
65int 65static int
66errno_to_portable(int unixerrno) 66errno_to_portable(int unixerrno)
67{ 67{
68 int ret = 0; 68 int ret = 0;
@@ -93,7 +93,7 @@ errno_to_portable(int unixerrno)
93 return ret; 93 return ret;
94} 94}
95 95
96int 96static int
97flags_from_portable(int pflags) 97flags_from_portable(int pflags)
98{ 98{
99 int flags = 0; 99 int flags = 0;
@@ -115,7 +115,7 @@ flags_from_portable(int pflags)
115 return flags; 115 return flags;
116} 116}
117 117
118Attrib * 118static Attrib *
119get_attrib(void) 119get_attrib(void)
120{ 120{
121 return decode_attrib(&iqueue); 121 return decode_attrib(&iqueue);
@@ -139,7 +139,7 @@ enum {
139 139
140Handle handles[100]; 140Handle handles[100];
141 141
142void 142static void
143handle_init(void) 143handle_init(void)
144{ 144{
145 int i; 145 int i;
@@ -148,7 +148,7 @@ handle_init(void)
148 handles[i].use = HANDLE_UNUSED; 148 handles[i].use = HANDLE_UNUSED;
149} 149}
150 150
151int 151static int
152handle_new(int use, char *name, int fd, DIR *dirp) 152handle_new(int use, char *name, int fd, DIR *dirp)
153{ 153{
154 int i; 154 int i;
@@ -165,14 +165,14 @@ handle_new(int use, char *name, int fd, DIR *dirp)
165 return -1; 165 return -1;
166} 166}
167 167
168int 168static int
169handle_is_ok(int i, int type) 169handle_is_ok(int i, int type)
170{ 170{
171 return i >= 0 && i < sizeof(handles)/sizeof(Handle) && 171 return i >= 0 && i < sizeof(handles)/sizeof(Handle) &&
172 handles[i].use == type; 172 handles[i].use == type;
173} 173}
174 174
175int 175static int
176handle_to_string(int handle, char **stringp, int *hlenp) 176handle_to_string(int handle, char **stringp, int *hlenp)
177{ 177{
178 if (stringp == NULL || hlenp == NULL) 178 if (stringp == NULL || hlenp == NULL)
@@ -183,7 +183,7 @@ handle_to_string(int handle, char **stringp, int *hlenp)
183 return 0; 183 return 0;
184} 184}
185 185
186int 186static int
187handle_from_string(char *handle, u_int hlen) 187handle_from_string(char *handle, u_int hlen)
188{ 188{
189 int val; 189 int val;
@@ -197,7 +197,7 @@ handle_from_string(char *handle, u_int hlen)
197 return -1; 197 return -1;
198} 198}
199 199
200char * 200static char *
201handle_to_name(int handle) 201handle_to_name(int handle)
202{ 202{
203 if (handle_is_ok(handle, HANDLE_DIR)|| 203 if (handle_is_ok(handle, HANDLE_DIR)||
@@ -206,7 +206,7 @@ handle_to_name(int handle)
206 return NULL; 206 return NULL;
207} 207}
208 208
209DIR * 209static DIR *
210handle_to_dir(int handle) 210handle_to_dir(int handle)
211{ 211{
212 if (handle_is_ok(handle, HANDLE_DIR)) 212 if (handle_is_ok(handle, HANDLE_DIR))
@@ -214,7 +214,7 @@ handle_to_dir(int handle)
214 return NULL; 214 return NULL;
215} 215}
216 216
217int 217static int
218handle_to_fd(int handle) 218handle_to_fd(int handle)
219{ 219{
220 if (handle_is_ok(handle, HANDLE_FILE)) 220 if (handle_is_ok(handle, HANDLE_FILE))
@@ -222,7 +222,7 @@ handle_to_fd(int handle)
222 return -1; 222 return -1;
223} 223}
224 224
225int 225static int
226handle_close(int handle) 226handle_close(int handle)
227{ 227{
228 int ret = -1; 228 int ret = -1;
@@ -239,7 +239,7 @@ handle_close(int handle)
239 return ret; 239 return ret;
240} 240}
241 241
242int 242static int
243get_handle(void) 243get_handle(void)
244{ 244{
245 char *handle; 245 char *handle;
@@ -255,7 +255,7 @@ get_handle(void)
255 255
256/* send replies */ 256/* send replies */
257 257
258void 258static void
259send_msg(Buffer *m) 259send_msg(Buffer *m)
260{ 260{
261 int mlen = buffer_len(m); 261 int mlen = buffer_len(m);
@@ -265,7 +265,7 @@ send_msg(Buffer *m)
265 buffer_consume(m, mlen); 265 buffer_consume(m, mlen);
266} 266}
267 267
268void 268static void
269send_status(u_int32_t id, u_int32_t error) 269send_status(u_int32_t id, u_int32_t error)
270{ 270{
271 Buffer msg; 271 Buffer msg;
@@ -295,7 +295,7 @@ send_status(u_int32_t id, u_int32_t error)
295 send_msg(&msg); 295 send_msg(&msg);
296 buffer_free(&msg); 296 buffer_free(&msg);
297} 297}
298void 298static void
299send_data_or_handle(char type, u_int32_t id, char *data, int dlen) 299send_data_or_handle(char type, u_int32_t id, char *data, int dlen)
300{ 300{
301 Buffer msg; 301 Buffer msg;
@@ -308,14 +308,14 @@ send_data_or_handle(char type, u_int32_t id, char *data, int dlen)
308 buffer_free(&msg); 308 buffer_free(&msg);
309} 309}
310 310
311void 311static void
312send_data(u_int32_t id, char *data, int dlen) 312send_data(u_int32_t id, char *data, int dlen)
313{ 313{
314 TRACE("sent data id %d len %d", id, dlen); 314 TRACE("sent data id %d len %d", id, dlen);
315 send_data_or_handle(SSH2_FXP_DATA, id, data, dlen); 315 send_data_or_handle(SSH2_FXP_DATA, id, data, dlen);
316} 316}
317 317
318void 318static void
319send_handle(u_int32_t id, int handle) 319send_handle(u_int32_t id, int handle)
320{ 320{
321 char *string; 321 char *string;
@@ -327,7 +327,7 @@ send_handle(u_int32_t id, int handle)
327 xfree(string); 327 xfree(string);
328} 328}
329 329
330void 330static void
331send_names(u_int32_t id, int count, Stat *stats) 331send_names(u_int32_t id, int count, Stat *stats)
332{ 332{
333 Buffer msg; 333 Buffer msg;
@@ -347,7 +347,7 @@ send_names(u_int32_t id, int count, Stat *stats)
347 buffer_free(&msg); 347 buffer_free(&msg);
348} 348}
349 349
350void 350static void
351send_attrib(u_int32_t id, Attrib *a) 351send_attrib(u_int32_t id, Attrib *a)
352{ 352{
353 Buffer msg; 353 Buffer msg;
@@ -363,7 +363,7 @@ send_attrib(u_int32_t id, Attrib *a)
363 363
364/* parse incoming */ 364/* parse incoming */
365 365
366void 366static void
367process_init(void) 367process_init(void)
368{ 368{
369 Buffer msg; 369 Buffer msg;
@@ -377,7 +377,7 @@ process_init(void)
377 buffer_free(&msg); 377 buffer_free(&msg);
378} 378}
379 379
380void 380static void
381process_open(void) 381process_open(void)
382{ 382{
383 u_int32_t id, pflags; 383 u_int32_t id, pflags;
@@ -409,7 +409,7 @@ process_open(void)
409 xfree(name); 409 xfree(name);
410} 410}
411 411
412void 412static void
413process_close(void) 413process_close(void)
414{ 414{
415 u_int32_t id; 415 u_int32_t id;
@@ -423,7 +423,7 @@ process_close(void)
423 send_status(id, status); 423 send_status(id, status);
424} 424}
425 425
426void 426static void
427process_read(void) 427process_read(void)
428{ 428{
429 char buf[64*1024]; 429 char buf[64*1024];
@@ -463,7 +463,7 @@ process_read(void)
463 send_status(id, status); 463 send_status(id, status);
464} 464}
465 465
466void 466static void
467process_write(void) 467process_write(void)
468{ 468{
469 u_int32_t id; 469 u_int32_t id;
@@ -501,7 +501,7 @@ process_write(void)
501 xfree(data); 501 xfree(data);
502} 502}
503 503
504void 504static void
505process_do_stat(int do_lstat) 505process_do_stat(int do_lstat)
506{ 506{
507 Attrib a; 507 Attrib a;
@@ -526,19 +526,19 @@ process_do_stat(int do_lstat)
526 xfree(name); 526 xfree(name);
527} 527}
528 528
529void 529static void
530process_stat(void) 530process_stat(void)
531{ 531{
532 process_do_stat(0); 532 process_do_stat(0);
533} 533}
534 534
535void 535static void
536process_lstat(void) 536process_lstat(void)
537{ 537{
538 process_do_stat(1); 538 process_do_stat(1);
539} 539}
540 540
541void 541static void
542process_fstat(void) 542process_fstat(void)
543{ 543{
544 Attrib a; 544 Attrib a;
@@ -564,7 +564,7 @@ process_fstat(void)
564 send_status(id, status); 564 send_status(id, status);
565} 565}
566 566
567struct timeval * 567static struct timeval *
568attrib_to_tv(Attrib *a) 568attrib_to_tv(Attrib *a)
569{ 569{
570 static struct timeval tv[2]; 570 static struct timeval tv[2];
@@ -576,7 +576,7 @@ attrib_to_tv(Attrib *a)
576 return tv; 576 return tv;
577} 577}
578 578
579void 579static void
580process_setstat(void) 580process_setstat(void)
581{ 581{
582 Attrib *a; 582 Attrib *a;
@@ -608,7 +608,7 @@ process_setstat(void)
608 xfree(name); 608 xfree(name);
609} 609}
610 610
611void 611static void
612process_fsetstat(void) 612process_fsetstat(void)
613{ 613{
614 Attrib *a; 614 Attrib *a;
@@ -657,7 +657,7 @@ process_fsetstat(void)
657 send_status(id, status); 657 send_status(id, status);
658} 658}
659 659
660void 660static void
661process_opendir(void) 661process_opendir(void)
662{ 662{
663 DIR *dirp = NULL; 663 DIR *dirp = NULL;
@@ -689,7 +689,7 @@ process_opendir(void)
689/* 689/*
690 * drwxr-xr-x 5 markus markus 1024 Jan 13 18:39 .ssh 690 * drwxr-xr-x 5 markus markus 1024 Jan 13 18:39 .ssh
691 */ 691 */
692char * 692static char *
693ls_file(char *name, struct stat *st) 693ls_file(char *name, struct stat *st)
694{ 694{
695 int ulen, glen, sz = 0; 695 int ulen, glen, sz = 0;
@@ -728,7 +728,7 @@ ls_file(char *name, struct stat *st)
728 return xstrdup(buf); 728 return xstrdup(buf);
729} 729}
730 730
731void 731static void
732process_readdir(void) 732process_readdir(void)
733{ 733{
734 DIR *dirp; 734 DIR *dirp;
@@ -782,7 +782,7 @@ process_readdir(void)
782 } 782 }
783} 783}
784 784
785void 785static void
786process_remove(void) 786process_remove(void)
787{ 787{
788 char *name; 788 char *name;
@@ -799,7 +799,7 @@ process_remove(void)
799 xfree(name); 799 xfree(name);
800} 800}
801 801
802void 802static void
803process_mkdir(void) 803process_mkdir(void)
804{ 804{
805 Attrib *a; 805 Attrib *a;
@@ -819,7 +819,7 @@ process_mkdir(void)
819 xfree(name); 819 xfree(name);
820} 820}
821 821
822void 822static void
823process_rmdir(void) 823process_rmdir(void)
824{ 824{
825 u_int32_t id; 825 u_int32_t id;
@@ -835,7 +835,7 @@ process_rmdir(void)
835 xfree(name); 835 xfree(name);
836} 836}
837 837
838void 838static void
839process_realpath(void) 839process_realpath(void)
840{ 840{
841 char resolvedname[MAXPATHLEN]; 841 char resolvedname[MAXPATHLEN];
@@ -860,7 +860,7 @@ process_realpath(void)
860 xfree(path); 860 xfree(path);
861} 861}
862 862
863void 863static void
864process_rename(void) 864process_rename(void)
865{ 865{
866 u_int32_t id; 866 u_int32_t id;
@@ -882,7 +882,7 @@ process_rename(void)
882 xfree(newpath); 882 xfree(newpath);
883} 883}
884 884
885void 885static void
886process_readlink(void) 886process_readlink(void)
887{ 887{
888 u_int32_t id; 888 u_int32_t id;
@@ -906,7 +906,7 @@ process_readlink(void)
906 xfree(path); 906 xfree(path);
907} 907}
908 908
909void 909static void
910process_symlink(void) 910process_symlink(void)
911{ 911{
912 u_int32_t id; 912 u_int32_t id;
@@ -928,7 +928,7 @@ process_symlink(void)
928 xfree(newpath); 928 xfree(newpath);
929} 929}
930 930
931void 931static void
932process_extended(void) 932process_extended(void)
933{ 933{
934 u_int32_t id; 934 u_int32_t id;
@@ -942,7 +942,7 @@ process_extended(void)
942 942
943/* stolen from ssh-agent */ 943/* stolen from ssh-agent */
944 944
945void 945static void
946process(void) 946process(void)
947{ 947{
948 u_int msg_len; 948 u_int msg_len;
diff --git a/sftp.c b/sftp.c
index dd8c08b13..98294ab09 100644
--- a/sftp.c
+++ b/sftp.c
@@ -24,7 +24,7 @@
24 24
25#include "includes.h" 25#include "includes.h"
26 26
27RCSID("$OpenBSD: sftp.c,v 1.17 2001/05/08 19:45:25 mouring Exp $"); 27RCSID("$OpenBSD: sftp.c,v 1.18 2001/06/23 15:12:20 itojun Exp $");
28 28
29/* XXX: commandline mode */ 29/* XXX: commandline mode */
30/* XXX: short-form remote directory listings (like 'ls -C') */ 30/* XXX: short-form remote directory listings (like 'ls -C') */
@@ -49,7 +49,7 @@ char *__progname;
49char *ssh_program = _PATH_SSH_PROGRAM; 49char *ssh_program = _PATH_SSH_PROGRAM;
50FILE* infile; 50FILE* infile;
51 51
52void 52static void
53connect_to_server(char **args, int *in, int *out, pid_t *sshpid) 53connect_to_server(char **args, int *in, int *out, pid_t *sshpid)
54{ 54{
55 int c_in, c_out; 55 int c_in, c_out;
@@ -90,7 +90,7 @@ connect_to_server(char **args, int *in, int *out, pid_t *sshpid)
90 close(c_out); 90 close(c_out);
91} 91}
92 92
93void 93static void
94usage(void) 94usage(void)
95{ 95{
96 fprintf(stderr, "usage: sftp [-1vC] [-b batchfile] [-osshopt=value] [user@]host[:file [file]]\n"); 96 fprintf(stderr, "usage: sftp [-1vC] [-b batchfile] [-osshopt=value] [user@]host[:file [file]]\n");
diff --git a/ssh-add.c b/ssh-add.c
index 9240b0d1e..f03ce029e 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: ssh-add.c,v 1.38 2001/06/06 23:19:35 markus Exp $"); 38RCSID("$OpenBSD: ssh-add.c,v 1.39 2001/06/23 15:12:20 itojun Exp $");
39 39
40#include <openssl/evp.h> 40#include <openssl/evp.h>
41 41
@@ -57,7 +57,7 @@ char *__progname;
57 57
58/* we keep a cache of one passphrases */ 58/* we keep a cache of one passphrases */
59static char *pass = NULL; 59static char *pass = NULL;
60void 60static void
61clear_pass(void) 61clear_pass(void)
62{ 62{
63 if (pass) { 63 if (pass) {
@@ -67,7 +67,7 @@ clear_pass(void)
67 } 67 }
68} 68}
69 69
70void 70static void
71delete_file(AuthenticationConnection *ac, const char *filename) 71delete_file(AuthenticationConnection *ac, const char *filename)
72{ 72{
73 Key *public; 73 Key *public;
@@ -87,7 +87,7 @@ delete_file(AuthenticationConnection *ac, const char *filename)
87} 87}
88 88
89/* Send a request to remove all identities. */ 89/* Send a request to remove all identities. */
90void 90static void
91delete_all(AuthenticationConnection *ac) 91delete_all(AuthenticationConnection *ac)
92{ 92{
93 int success = 1; 93 int success = 1;
@@ -103,7 +103,7 @@ delete_all(AuthenticationConnection *ac)
103 fprintf(stderr, "Failed to remove all identities.\n"); 103 fprintf(stderr, "Failed to remove all identities.\n");
104} 104}
105 105
106void 106static void
107add_file(AuthenticationConnection *ac, const char *filename) 107add_file(AuthenticationConnection *ac, const char *filename)
108{ 108{
109 struct stat st; 109 struct stat st;
@@ -149,7 +149,7 @@ add_file(AuthenticationConnection *ac, const char *filename)
149 key_free(private); 149 key_free(private);
150} 150}
151 151
152void 152static void
153list_identities(AuthenticationConnection *ac, int do_fp) 153list_identities(AuthenticationConnection *ac, int do_fp)
154{ 154{
155 Key *key; 155 Key *key;
diff --git a/ssh-agent.c b/ssh-agent.c
index 07dafaa57..6d94c6c29 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-agent.c,v 1.54 2001/04/03 13:56:11 stevesk Exp $ */ 1/* $OpenBSD: ssh-agent.c,v 1.55 2001/06/23 15:12:20 itojun Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -37,7 +37,7 @@
37 */ 37 */
38 38
39#include "includes.h" 39#include "includes.h"
40RCSID("$OpenBSD: ssh-agent.c,v 1.54 2001/04/03 13:56:11 stevesk Exp $"); 40RCSID("$OpenBSD: ssh-agent.c,v 1.55 2001/06/23 15:12:20 itojun Exp $");
41 41
42#include <openssl/evp.h> 42#include <openssl/evp.h>
43#include <openssl/md5.h> 43#include <openssl/md5.h>
@@ -97,9 +97,7 @@ extern char *__progname;
97char *__progname; 97char *__progname;
98#endif 98#endif
99 99
100int prepare_select(fd_set **, fd_set **, int *); 100static void
101
102void
103idtab_init(void) 101idtab_init(void)
104{ 102{
105 int i; 103 int i;
@@ -110,7 +108,7 @@ idtab_init(void)
110} 108}
111 109
112/* return private key table for requested protocol version */ 110/* return private key table for requested protocol version */
113Idtab * 111static Idtab *
114idtab_lookup(int version) 112idtab_lookup(int version)
115{ 113{
116 if (version < 1 || version > 2) 114 if (version < 1 || version > 2)
@@ -119,7 +117,7 @@ idtab_lookup(int version)
119} 117}
120 118
121/* return matching private key for given public key */ 119/* return matching private key for given public key */
122Key * 120static Key *
123lookup_private_key(Key *key, int *idx, int version) 121lookup_private_key(Key *key, int *idx, int version)
124{ 122{
125 int i; 123 int i;
@@ -135,7 +133,7 @@ lookup_private_key(Key *key, int *idx, int version)
135} 133}
136 134
137/* send list of supported public keys to 'client' */ 135/* send list of supported public keys to 'client' */
138void 136static void
139process_request_identities(SocketEntry *e, int version) 137process_request_identities(SocketEntry *e, int version)
140{ 138{
141 Idtab *tab = idtab_lookup(version); 139 Idtab *tab = idtab_lookup(version);
@@ -167,7 +165,7 @@ process_request_identities(SocketEntry *e, int version)
167} 165}
168 166
169/* ssh1 only */ 167/* ssh1 only */
170void 168static void
171process_authentication_challenge1(SocketEntry *e) 169process_authentication_challenge1(SocketEntry *e)
172{ 170{
173 Key *key, *private; 171 Key *key, *private;
@@ -233,7 +231,7 @@ send:
233} 231}
234 232
235/* ssh2 only */ 233/* ssh2 only */
236void 234static void
237process_sign_request2(SocketEntry *e) 235process_sign_request2(SocketEntry *e)
238{ 236{
239 extern int datafellows; 237 extern int datafellows;
@@ -278,7 +276,7 @@ process_sign_request2(SocketEntry *e)
278} 276}
279 277
280/* shared */ 278/* shared */
281void 279static void
282process_remove_identity(SocketEntry *e, int version) 280process_remove_identity(SocketEntry *e, int version)
283{ 281{
284 Key *key = NULL, *private; 282 Key *key = NULL, *private;
@@ -339,7 +337,7 @@ process_remove_identity(SocketEntry *e, int version)
339 success ? SSH_AGENT_SUCCESS : SSH_AGENT_FAILURE); 337 success ? SSH_AGENT_SUCCESS : SSH_AGENT_FAILURE);
340} 338}
341 339
342void 340static void
343process_remove_all_identities(SocketEntry *e, int version) 341process_remove_all_identities(SocketEntry *e, int version)
344{ 342{
345 u_int i; 343 u_int i;
@@ -360,7 +358,7 @@ process_remove_all_identities(SocketEntry *e, int version)
360 return; 358 return;
361} 359}
362 360
363void 361static void
364process_add_identity(SocketEntry *e, int version) 362process_add_identity(SocketEntry *e, int version)
365{ 363{
366 Key *k = NULL; 364 Key *k = NULL;
@@ -444,7 +442,7 @@ send:
444 442
445/* dispatch incoming messages */ 443/* dispatch incoming messages */
446 444
447void 445static void
448process_message(SocketEntry *e) 446process_message(SocketEntry *e)
449{ 447{
450 u_int msg_len; 448 u_int msg_len;
@@ -508,7 +506,7 @@ process_message(SocketEntry *e)
508 } 506 }
509} 507}
510 508
511void 509static void
512new_socket(int type, int fd) 510new_socket(int type, int fd)
513{ 511{
514 u_int i, old_alloc; 512 u_int i, old_alloc;
@@ -540,7 +538,7 @@ new_socket(int type, int fd)
540 buffer_init(&sockets[old_alloc].output); 538 buffer_init(&sockets[old_alloc].output);
541} 539}
542 540
543int 541static int
544prepare_select(fd_set **fdrp, fd_set **fdwp, int *fdl) 542prepare_select(fd_set **fdrp, fd_set **fdwp, int *fdl)
545{ 543{
546 u_int i, sz; 544 u_int i, sz;
@@ -588,7 +586,7 @@ prepare_select(fd_set **fdrp, fd_set **fdwp, int *fdl)
588 return (1); 586 return (1);
589} 587}
590 588
591void 589static void
592after_select(fd_set *readset, fd_set *writeset) 590after_select(fd_set *readset, fd_set *writeset)
593{ 591{
594 u_int i; 592 u_int i;
@@ -660,7 +658,7 @@ after_select(fd_set *readset, fd_set *writeset)
660 } 658 }
661} 659}
662 660
663void 661static void
664check_parent_exists(int sig) 662check_parent_exists(int sig)
665{ 663{
666 int save_errno = errno; 664 int save_errno = errno;
@@ -674,7 +672,7 @@ check_parent_exists(int sig)
674 errno = save_errno; 672 errno = save_errno;
675} 673}
676 674
677void 675static void
678cleanup_socket(void) 676cleanup_socket(void)
679{ 677{
680 if (socket_name[0]) 678 if (socket_name[0])
@@ -683,21 +681,21 @@ cleanup_socket(void)
683 rmdir(socket_dir); 681 rmdir(socket_dir);
684} 682}
685 683
686void 684static void
687cleanup_exit(int i) 685cleanup_exit(int i)
688{ 686{
689 cleanup_socket(); 687 cleanup_socket();
690 exit(i); 688 exit(i);
691} 689}
692 690
693void 691static void
694cleanup_handler(int sig) 692cleanup_handler(int sig)
695{ 693{
696 cleanup_socket(); 694 cleanup_socket();
697 _exit(2); 695 _exit(2);
698} 696}
699 697
700void 698static void
701usage(void) 699usage(void)
702{ 700{
703 fprintf(stderr, "ssh-agent version %s\n", SSH_VERSION); 701 fprintf(stderr, "ssh-agent version %s\n", SSH_VERSION);
diff --git a/ssh-keygen.c b/ssh-keygen.c
index bd7eea9af..22946587f 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: ssh-keygen.c,v 1.62 2001/06/23 06:41:10 markus Exp $"); 15RCSID("$OpenBSD: ssh-keygen.c,v 1.63 2001/06/23 15:12:20 itojun Exp $");
16 16
17#include <openssl/evp.h> 17#include <openssl/evp.h>
18#include <openssl/pem.h> 18#include <openssl/pem.h>
@@ -79,7 +79,7 @@ char *__progname;
79 79
80char hostname[MAXHOSTNAMELEN]; 80char hostname[MAXHOSTNAMELEN];
81 81
82void 82static void
83ask_filename(struct passwd *pw, const char *prompt) 83ask_filename(struct passwd *pw, const char *prompt)
84{ 84{
85 char buf[1024]; 85 char buf[1024];
@@ -112,7 +112,7 @@ ask_filename(struct passwd *pw, const char *prompt)
112 have_identity = 1; 112 have_identity = 1;
113} 113}
114 114
115Key * 115static Key *
116load_identity(char *filename) 116load_identity(char *filename)
117{ 117{
118 char *pass; 118 char *pass;
@@ -136,7 +136,7 @@ load_identity(char *filename)
136#define SSH_COM_PRIVATE_BEGIN "---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ----" 136#define SSH_COM_PRIVATE_BEGIN "---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ----"
137#define SSH_COM_PRIVATE_KEY_MAGIC 0x3f6ff9eb 137#define SSH_COM_PRIVATE_KEY_MAGIC 0x3f6ff9eb
138 138
139void 139static void
140do_convert_to_ssh2(struct passwd *pw) 140do_convert_to_ssh2(struct passwd *pw)
141{ 141{
142 Key *k; 142 Key *k;
@@ -169,7 +169,7 @@ do_convert_to_ssh2(struct passwd *pw)
169 exit(0); 169 exit(0);
170} 170}
171 171
172void 172static void
173buffer_get_bignum_bits(Buffer *b, BIGNUM *value) 173buffer_get_bignum_bits(Buffer *b, BIGNUM *value)
174{ 174{
175 int bits = buffer_get_int(b); 175 int bits = buffer_get_int(b);
@@ -182,7 +182,7 @@ buffer_get_bignum_bits(Buffer *b, BIGNUM *value)
182 buffer_consume(b, bytes); 182 buffer_consume(b, bytes);
183} 183}
184 184
185Key * 185static Key *
186do_convert_private_ssh2_from_blob(char *blob, int blen) 186do_convert_private_ssh2_from_blob(char *blob, int blen)
187{ 187{
188 Buffer b; 188 Buffer b;
@@ -277,7 +277,7 @@ do_convert_private_ssh2_from_blob(char *blob, int blen)
277 return key; 277 return key;
278} 278}
279 279
280void 280static void
281do_convert_from_ssh2(struct passwd *pw) 281do_convert_from_ssh2(struct passwd *pw)
282{ 282{
283 Key *k; 283 Key *k;
@@ -350,7 +350,7 @@ do_convert_from_ssh2(struct passwd *pw)
350 exit(0); 350 exit(0);
351} 351}
352 352
353void 353static void
354do_print_public(struct passwd *pw) 354do_print_public(struct passwd *pw)
355{ 355{
356 Key *prv; 356 Key *prv;
@@ -374,7 +374,7 @@ do_print_public(struct passwd *pw)
374 exit(0); 374 exit(0);
375} 375}
376 376
377void 377static void
378do_fingerprint(struct passwd *pw) 378do_fingerprint(struct passwd *pw)
379{ 379{
380 FILE *f; 380 FILE *f;
@@ -471,7 +471,7 @@ do_fingerprint(struct passwd *pw)
471 * Perform changing a passphrase. The argument is the passwd structure 471 * Perform changing a passphrase. The argument is the passwd structure
472 * for the current user. 472 * for the current user.
473 */ 473 */
474void 474static void
475do_change_passphrase(struct passwd *pw) 475do_change_passphrase(struct passwd *pw)
476{ 476{
477 char *comment; 477 char *comment;
@@ -547,7 +547,7 @@ do_change_passphrase(struct passwd *pw)
547/* 547/*
548 * Change the comment of a private key file. 548 * Change the comment of a private key file.
549 */ 549 */
550void 550static void
551do_change_comment(struct passwd *pw) 551do_change_comment(struct passwd *pw)
552{ 552{
553 char new_comment[1024], *comment, *passphrase; 553 char new_comment[1024], *comment, *passphrase;
@@ -640,7 +640,7 @@ do_change_comment(struct passwd *pw)
640 exit(0); 640 exit(0);
641} 641}
642 642
643void 643static void
644usage(void) 644usage(void)
645{ 645{
646 printf("Usage: %s [-ceilpqyB] [-t type] [-b bits] [-f file] [-C comment] " 646 printf("Usage: %s [-ceilpqyB] [-t type] [-b bits] [-f file] [-C comment] "
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index da34f7c63..9f7aa94aa 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -7,7 +7,7 @@
7 */ 7 */
8 8
9#include "includes.h" 9#include "includes.h"
10RCSID("$OpenBSD: ssh-keyscan.c,v 1.23 2001/06/05 05:05:39 pvalchev Exp $"); 10RCSID("$OpenBSD: ssh-keyscan.c,v 1.24 2001/06/23 15:12:20 itojun Exp $");
11 11
12#if defined(HAVE_SYS_QUEUE_H) && !defined(HAVE_BOGUS_SYS_QUEUE_H) 12#if defined(HAVE_SYS_QUEUE_H) && !defined(HAVE_BOGUS_SYS_QUEUE_H)
13#include <sys/queue.h> 13#include <sys/queue.h>
@@ -90,7 +90,7 @@ typedef struct {
90 void (*errfun) (const char *,...); 90 void (*errfun) (const char *,...);
91} Linebuf; 91} Linebuf;
92 92
93Linebuf * 93static Linebuf *
94Linebuf_alloc(const char *filename, void (*errfun) (const char *,...)) 94Linebuf_alloc(const char *filename, void (*errfun) (const char *,...))
95{ 95{
96 Linebuf *lb; 96 Linebuf *lb;
@@ -124,7 +124,7 @@ Linebuf_alloc(const char *filename, void (*errfun) (const char *,...))
124 return (lb); 124 return (lb);
125} 125}
126 126
127void 127static void
128Linebuf_free(Linebuf * lb) 128Linebuf_free(Linebuf * lb)
129{ 129{
130 fclose(lb->stream); 130 fclose(lb->stream);
@@ -132,7 +132,8 @@ Linebuf_free(Linebuf * lb)
132 xfree(lb); 132 xfree(lb);
133} 133}
134 134
135void 135#if 0
136static void
136Linebuf_restart(Linebuf * lb) 137Linebuf_restart(Linebuf * lb)
137{ 138{
138 clearerr(lb->stream); 139 clearerr(lb->stream);
@@ -140,13 +141,14 @@ Linebuf_restart(Linebuf * lb)
140 lb->lineno = 0; 141 lb->lineno = 0;
141} 142}
142 143
143int 144static int
144Linebuf_lineno(Linebuf * lb) 145Linebuf_lineno(Linebuf * lb)
145{ 146{
146 return (lb->lineno); 147 return (lb->lineno);
147} 148}
149#endif
148 150
149char * 151static char *
150Linebuf_getline(Linebuf * lb) 152Linebuf_getline(Linebuf * lb)
151{ 153{
152 int n = 0; 154 int n = 0;
@@ -183,7 +185,7 @@ Linebuf_getline(Linebuf * lb)
183 } 185 }
184} 186}
185 187
186int 188static int
187fdlim_get(int hard) 189fdlim_get(int hard)
188{ 190{
189#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE) 191#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
@@ -202,7 +204,7 @@ fdlim_get(int hard)
202#endif 204#endif
203} 205}
204 206
205int 207static int
206fdlim_set(int lim) 208fdlim_set(int lim)
207{ 209{
208#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE) 210#if defined(HAVE_SETRLIMIT) && defined(RLIMIT_NOFILE)
@@ -227,7 +229,7 @@ fdlim_set(int lim)
227 * separators. This is the same as the 4.4BSD strsep, but different from the 229 * separators. This is the same as the 4.4BSD strsep, but different from the
228 * one in the GNU libc. 230 * one in the GNU libc.
229 */ 231 */
230char * 232static char *
231xstrsep(char **str, const char *delim) 233xstrsep(char **str, const char *delim)
232{ 234{
233 char *s, *e; 235 char *s, *e;
@@ -249,7 +251,7 @@ xstrsep(char **str, const char *delim)
249 * Get the next non-null token (like GNU strsep). Strsep() will return a 251 * Get the next non-null token (like GNU strsep). Strsep() will return a
250 * null token for two adjacent separators, so we may have to loop. 252 * null token for two adjacent separators, so we may have to loop.
251 */ 253 */
252char * 254static char *
253strnnsep(char **stringp, char *delim) 255strnnsep(char **stringp, char *delim)
254{ 256{
255 char *tok; 257 char *tok;
@@ -260,7 +262,7 @@ strnnsep(char **stringp, char *delim)
260 return (tok); 262 return (tok);
261} 263}
262 264
263void 265static void
264keyprint(char *host, char *output_name, char *kd, int len) 266keyprint(char *host, char *output_name, char *kd, int len)
265{ 267{
266 static Key *rsa; 268 static Key *rsa;
@@ -295,7 +297,7 @@ keyprint(char *host, char *output_name, char *kd, int len)
295 fputs("\n", stdout); 297 fputs("\n", stdout);
296} 298}
297 299
298int 300static int
299tcpconnect(char *host) 301tcpconnect(char *host)
300{ 302{
301 struct addrinfo hints, *ai, *aitop; 303 struct addrinfo hints, *ai, *aitop;
@@ -328,7 +330,7 @@ tcpconnect(char *host)
328 return s; 330 return s;
329} 331}
330 332
331int 333static int
332conalloc(char *iname, char *oname) 334conalloc(char *iname, char *oname)
333{ 335{
334 int s; 336 int s;
@@ -366,7 +368,7 @@ conalloc(char *iname, char *oname)
366 return (s); 368 return (s);
367} 369}
368 370
369void 371static void
370confree(int s) 372confree(int s)
371{ 373{
372 if (s >= maxfd || fdcon[s].c_status == CS_UNUSED) 374 if (s >= maxfd || fdcon[s].c_status == CS_UNUSED)
@@ -382,7 +384,7 @@ confree(int s)
382 ncon--; 384 ncon--;
383} 385}
384 386
385void 387static void
386contouch(int s) 388contouch(int s)
387{ 389{
388 TAILQ_REMOVE(&tq, &fdcon[s], c_link); 390 TAILQ_REMOVE(&tq, &fdcon[s], c_link);
@@ -391,7 +393,7 @@ contouch(int s)
391 TAILQ_INSERT_TAIL(&tq, &fdcon[s], c_link); 393 TAILQ_INSERT_TAIL(&tq, &fdcon[s], c_link);
392} 394}
393 395
394int 396static int
395conrecycle(int s) 397conrecycle(int s)
396{ 398{
397 int ret; 399 int ret;
@@ -407,7 +409,7 @@ conrecycle(int s)
407 return (ret); 409 return (ret);
408} 410}
409 411
410void 412static void
411congreet(int s) 413congreet(int s)
412{ 414{
413 char buf[80], *cp; 415 char buf[80], *cp;
@@ -442,7 +444,7 @@ congreet(int s)
442 contouch(s); 444 contouch(s);
443} 445}
444 446
445void 447static void
446conread(int s) 448conread(int s)
447{ 449{
448 int n; 450 int n;
@@ -482,7 +484,7 @@ conread(int s)
482 contouch(s); 484 contouch(s);
483} 485}
484 486
485void 487static void
486conloop(void) 488conloop(void)
487{ 489{
488 fd_set *r, *e; 490 fd_set *r, *e;
@@ -534,7 +536,7 @@ conloop(void)
534 } 536 }
535} 537}
536 538
537char * 539static char *
538nexthost(int argc, char **argv) 540nexthost(int argc, char **argv)
539{ 541{
540 static Linebuf *lb; 542 static Linebuf *lb;
@@ -577,7 +579,7 @@ nexthost(int argc, char **argv)
577 } 579 }
578} 580}
579 581
580void 582static void
581usage(void) 583usage(void)
582{ 584{
583 fatal("usage: %s [-t timeout] { [--] host | -f file } ...", __progname); 585 fatal("usage: %s [-t timeout] { [--] host | -f file } ...", __progname);
diff --git a/ssh.c b/ssh.c
index e0e141fe1..484e5de46 100644
--- a/ssh.c
+++ b/ssh.c
@@ -39,7 +39,7 @@
39 */ 39 */
40 40
41#include "includes.h" 41#include "includes.h"
42RCSID("$OpenBSD: ssh.c,v 1.125 2001/06/22 23:35:21 markus Exp $"); 42RCSID("$OpenBSD: ssh.c,v 1.126 2001/06/23 15:12:21 itojun Exp $");
43 43
44#include <openssl/evp.h> 44#include <openssl/evp.h>
45#include <openssl/err.h> 45#include <openssl/err.h>
@@ -148,7 +148,7 @@ int subsystem_flag = 0;
148 148
149/* Prints a help message to the user. This function never returns. */ 149/* Prints a help message to the user. This function never returns. */
150 150
151void 151static void
152usage(void) 152usage(void)
153{ 153{
154 fprintf(stderr, "Usage: %s [options] host [command]\n", __progname); 154 fprintf(stderr, "Usage: %s [options] host [command]\n", __progname);
@@ -198,7 +198,7 @@ usage(void)
198 * Connects to the given host using rsh (or prints an error message and exits 198 * Connects to the given host using rsh (or prints an error message and exits
199 * if rsh is not available). This function never returns. 199 * if rsh is not available). This function never returns.
200 */ 200 */
201void 201static void
202rsh_connect(char *host, char *user, Buffer * command) 202rsh_connect(char *host, char *user, Buffer * command)
203{ 203{
204 char *args[10]; 204 char *args[10];
@@ -232,9 +232,9 @@ rsh_connect(char *host, char *user, Buffer * command)
232 exit(1); 232 exit(1);
233} 233}
234 234
235int ssh_session(void); 235static int ssh_session(void);
236int ssh_session2(void); 236static int ssh_session2(void);
237void load_public_identity_files(void); 237static void load_public_identity_files(void);
238 238
239/* 239/*
240 * Main program for the ssh client. 240 * Main program for the ssh client.
@@ -742,7 +742,7 @@ main(int ac, char **av)
742 return exit_status; 742 return exit_status;
743} 743}
744 744
745void 745static void
746x11_get_proto(char *proto, int proto_len, char *data, int data_len) 746x11_get_proto(char *proto, int proto_len, char *data, int data_len)
747{ 747{
748 char line[512]; 748 char line[512];
@@ -781,7 +781,7 @@ x11_get_proto(char *proto, int proto_len, char *data, int data_len)
781 } 781 }
782} 782}
783 783
784void 784static void
785ssh_init_forwarding(void) 785ssh_init_forwarding(void)
786{ 786{
787 int success = 0; 787 int success = 0;
@@ -815,7 +815,7 @@ ssh_init_forwarding(void)
815 } 815 }
816} 816}
817 817
818void 818static void
819check_agent_present(void) 819check_agent_present(void)
820{ 820{
821 if (options.forward_agent) { 821 if (options.forward_agent) {
@@ -828,7 +828,7 @@ check_agent_present(void)
828 } 828 }
829} 829}
830 830
831int 831static int
832ssh_session(void) 832ssh_session(void)
833{ 833{
834 int type; 834 int type;
@@ -966,7 +966,7 @@ ssh_session(void)
966 options.escape_char : SSH_ESCAPECHAR_NONE, 0); 966 options.escape_char : SSH_ESCAPECHAR_NONE, 0);
967} 967}
968 968
969void 969static void
970client_subsystem_reply(int type, int plen, void *ctxt) 970client_subsystem_reply(int type, int plen, void *ctxt)
971{ 971{
972 int id, len; 972 int id, len;
@@ -981,7 +981,7 @@ client_subsystem_reply(int type, int plen, void *ctxt)
981 len, buffer_ptr(&command), id); 981 len, buffer_ptr(&command), id);
982} 982}
983 983
984void 984static void
985ssh_session2_callback(int id, void *arg) 985ssh_session2_callback(int id, void *arg)
986{ 986{
987 int len; 987 int len;
@@ -1057,7 +1057,7 @@ ssh_session2_callback(int id, void *arg)
1057 packet_set_interactive(interactive); 1057 packet_set_interactive(interactive);
1058} 1058}
1059 1059
1060int 1060static int
1061ssh_session2_command(void) 1061ssh_session2_command(void)
1062{ 1062{
1063 Channel *c; 1063 Channel *c;
@@ -1104,7 +1104,7 @@ ssh_session2_command(void)
1104 return c->self; 1104 return c->self;
1105} 1105}
1106 1106
1107int 1107static int
1108ssh_session2(void) 1108ssh_session2(void)
1109{ 1109{
1110 int id; 1110 int id;
@@ -1123,7 +1123,7 @@ ssh_session2(void)
1123 options.escape_char : SSH_ESCAPECHAR_NONE, id); 1123 options.escape_char : SSH_ESCAPECHAR_NONE, id);
1124} 1124}
1125 1125
1126void 1126static void
1127load_public_identity_files(void) 1127load_public_identity_files(void)
1128{ 1128{
1129 char *filename; 1129 char *filename;
diff --git a/sshconnect.c b/sshconnect.c
index 1766de0c3..745eeb5c3 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -13,7 +13,7 @@
13 */ 13 */
14 14
15#include "includes.h" 15#include "includes.h"
16RCSID("$OpenBSD: sshconnect.c,v 1.108 2001/06/23 02:34:31 markus Exp $"); 16RCSID("$OpenBSD: sshconnect.c,v 1.109 2001/06/23 15:12:21 itojun Exp $");
17 17
18#include <openssl/bn.h> 18#include <openssl/bn.h>
19 19
@@ -44,7 +44,7 @@ extern int IPv4or6;
44/* 44/*
45 * Connect to the given ssh server using a proxy command. 45 * Connect to the given ssh server using a proxy command.
46 */ 46 */
47int 47static int
48ssh_proxy_connect(const char *host, u_short port, struct passwd *pw, 48ssh_proxy_connect(const char *host, u_short port, struct passwd *pw,
49 const char *proxy_command) 49 const char *proxy_command)
50{ 50{
@@ -144,7 +144,7 @@ ssh_proxy_connect(const char *host, u_short port, struct passwd *pw,
144/* 144/*
145 * Creates a (possibly privileged) socket for use as the ssh connection. 145 * Creates a (possibly privileged) socket for use as the ssh connection.
146 */ 146 */
147int 147static int
148ssh_create_socket(struct passwd *pw, int privileged, int family) 148ssh_create_socket(struct passwd *pw, int privileged, int family)
149{ 149{
150 int sock, gaierr; 150 int sock, gaierr;
@@ -345,7 +345,7 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
345 * Waits for the server identification string, and sends our own 345 * Waits for the server identification string, and sends our own
346 * identification string. 346 * identification string.
347 */ 347 */
348void 348static void
349ssh_exchange_identification(void) 349ssh_exchange_identification(void)
350{ 350{
351 char buf[256], remote_version[256]; /* must be same size! */ 351 char buf[256], remote_version[256]; /* must be same size! */
@@ -444,7 +444,7 @@ ssh_exchange_identification(void)
444} 444}
445 445
446/* defaults to 'no' */ 446/* defaults to 'no' */
447int 447static int
448read_yes_or_no(const char *prompt, int defval) 448read_yes_or_no(const char *prompt, int defval)
449{ 449{
450 char buf[1024]; 450 char buf[1024];
@@ -500,7 +500,7 @@ read_yes_or_no(const char *prompt, int defval)
500 * is not valid. the user_hostfile will not be updated if 'readonly' is true. 500 * is not valid. the user_hostfile will not be updated if 'readonly' is true.
501 */ 501 */
502 502
503int 503static int
504check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key, 504check_host_key(char *host, struct sockaddr *hostaddr, Key *host_key,
505 int readonly, const char *user_hostfile, const char *system_hostfile) 505 int readonly, const char *user_hostfile, const char *system_hostfile)
506{ 506{
diff --git a/sshconnect1.c b/sshconnect1.c
index 4c469c20d..a03233f28 100644
--- a/sshconnect1.c
+++ b/sshconnect1.c
@@ -13,7 +13,7 @@
13 */ 13 */
14 14
15#include "includes.h" 15#include "includes.h"
16RCSID("$OpenBSD: sshconnect1.c,v 1.34 2001/06/23 02:34:32 markus Exp $"); 16RCSID("$OpenBSD: sshconnect1.c,v 1.35 2001/06/23 15:12:21 itojun Exp $");
17 17
18#include <openssl/bn.h> 18#include <openssl/bn.h>
19#include <openssl/evp.h> 19#include <openssl/evp.h>
@@ -55,7 +55,7 @@ extern char *__progname;
55 * Checks if the user has an authentication agent, and if so, tries to 55 * Checks if the user has an authentication agent, and if so, tries to
56 * authenticate using the agent. 56 * authenticate using the agent.
57 */ 57 */
58int 58static int
59try_agent_authentication(void) 59try_agent_authentication(void)
60{ 60{
61 int type; 61 int type;
@@ -155,7 +155,7 @@ try_agent_authentication(void)
155 * Computes the proper response to a RSA challenge, and sends the response to 155 * Computes the proper response to a RSA challenge, and sends the response to
156 * the server. 156 * the server.
157 */ 157 */
158void 158static void
159respond_to_rsa_challenge(BIGNUM * challenge, RSA * prv) 159respond_to_rsa_challenge(BIGNUM * challenge, RSA * prv)
160{ 160{
161 u_char buf[32], response[16]; 161 u_char buf[32], response[16];
@@ -200,7 +200,7 @@ respond_to_rsa_challenge(BIGNUM * challenge, RSA * prv)
200 * Checks if the user has authentication file, and if so, tries to authenticate 200 * Checks if the user has authentication file, and if so, tries to authenticate
201 * the user using it. 201 * the user using it.
202 */ 202 */
203int 203static int
204try_rsa_authentication(const char *authfile) 204try_rsa_authentication(const char *authfile)
205{ 205{
206 BIGNUM *challenge; 206 BIGNUM *challenge;
@@ -321,7 +321,7 @@ try_rsa_authentication(const char *authfile)
321 * Tries to authenticate the user using combined rhosts or /etc/hosts.equiv 321 * Tries to authenticate the user using combined rhosts or /etc/hosts.equiv
322 * authentication and RSA host authentication. 322 * authentication and RSA host authentication.
323 */ 323 */
324int 324static int
325try_rhosts_rsa_authentication(const char *local_user, Key * host_key) 325try_rhosts_rsa_authentication(const char *local_user, Key * host_key)
326{ 326{
327 int type; 327 int type;
@@ -379,7 +379,7 @@ try_rhosts_rsa_authentication(const char *local_user, Key * host_key)
379} 379}
380 380
381#ifdef KRB4 381#ifdef KRB4
382int 382static int
383try_kerberos_authentication(void) 383try_kerberos_authentication(void)
384{ 384{
385 KTEXT_ST auth; /* Kerberos data */ 385 KTEXT_ST auth; /* Kerberos data */
@@ -496,7 +496,7 @@ try_kerberos_authentication(void)
496#endif /* KRB4 */ 496#endif /* KRB4 */
497 497
498#ifdef AFS 498#ifdef AFS
499int 499static int
500send_kerberos_tgt(void) 500send_kerberos_tgt(void)
501{ 501{
502 CREDENTIALS *creds; 502 CREDENTIALS *creds;
@@ -541,7 +541,7 @@ send_kerberos_tgt(void)
541 return 1; 541 return 1;
542} 542}
543 543
544void 544static void
545send_afs_tokens(void) 545send_afs_tokens(void)
546{ 546{
547 CREDENTIALS creds; 547 CREDENTIALS creds;
@@ -615,7 +615,7 @@ send_afs_tokens(void)
615 * Tries to authenticate with any string-based challenge/response system. 615 * Tries to authenticate with any string-based challenge/response system.
616 * Note that the client code is not tied to s/key or TIS. 616 * Note that the client code is not tied to s/key or TIS.
617 */ 617 */
618int 618static int
619try_challenge_response_authentication(void) 619try_challenge_response_authentication(void)
620{ 620{
621 int type, i; 621 int type, i;
@@ -677,7 +677,7 @@ try_challenge_response_authentication(void)
677/* 677/*
678 * Tries to authenticate with plain passwd authentication. 678 * Tries to authenticate with plain passwd authentication.
679 */ 679 */
680int 680static int
681try_password_authentication(char *prompt) 681try_password_authentication(char *prompt)
682{ 682{
683 int type, i, payload_len; 683 int type, i, payload_len;
diff --git a/sshconnect2.c b/sshconnect2.c
index e2d64d7b1..1f57c3a9f 100644
--- a/sshconnect2.c
+++ b/sshconnect2.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: sshconnect2.c,v 1.75 2001/06/23 02:34:33 markus Exp $"); 26RCSID("$OpenBSD: sshconnect2.c,v 1.76 2001/06/23 15:12:21 itojun Exp $");
27 27
28#include <openssl/bn.h> 28#include <openssl/bn.h>
29#include <openssl/md5.h> 29#include <openssl/md5.h>
@@ -72,7 +72,7 @@ struct sockaddr *xxx_hostaddr;
72 72
73Kex *xxx_kex = NULL; 73Kex *xxx_kex = NULL;
74 74
75int 75static int
76verify_host_key_callback(Key *hostkey) 76verify_host_key_callback(Key *hostkey)
77{ 77{
78 if (verify_host_key(xxx_host, xxx_hostaddr, hostkey) == -1) 78 if (verify_host_key(xxx_host, xxx_hostaddr, hostkey) == -1)
@@ -188,14 +188,12 @@ int userauth_hostbased(Authctxt *authctxt);
188 188
189void userauth(Authctxt *authctxt, char *authlist); 189void userauth(Authctxt *authctxt, char *authlist);
190 190
191int 191static int sign_and_send_pubkey(Authctxt *, Key *, sign_cb_fn *);
192sign_and_send_pubkey(Authctxt *authctxt, Key *k, 192static void clear_auth_state(Authctxt *);
193 sign_cb_fn *sign_callback);
194void clear_auth_state(Authctxt *authctxt);
195 193
196Authmethod *authmethod_get(char *authlist); 194static Authmethod *authmethod_get(char *authlist);
197Authmethod *authmethod_lookup(const char *name); 195static Authmethod *authmethod_lookup(const char *name);
198char *authmethods_get(void); 196static char *authmethods_get(void);
199 197
200Authmethod authmethods[] = { 198Authmethod authmethods[] = {
201 {"publickey", 199 {"publickey",
@@ -477,7 +475,7 @@ clear_auth_state(Authctxt *authctxt)
477 authctxt->last_key_sign = NULL; 475 authctxt->last_key_sign = NULL;
478} 476}
479 477
480int 478static int
481sign_and_send_pubkey(Authctxt *authctxt, Key *k, sign_cb_fn *sign_callback) 479sign_and_send_pubkey(Authctxt *authctxt, Key *k, sign_cb_fn *sign_callback)
482{ 480{
483 Buffer b; 481 Buffer b;
@@ -562,7 +560,7 @@ sign_and_send_pubkey(Authctxt *authctxt, Key *k, sign_cb_fn *sign_callback)
562 return 1; 560 return 1;
563} 561}
564 562
565int 563static int
566send_pubkey_test(Authctxt *authctxt, Key *k, sign_cb_fn *sign_callback, 564send_pubkey_test(Authctxt *authctxt, Key *k, sign_cb_fn *sign_callback,
567 int hint) 565 int hint)
568{ 566{
@@ -595,7 +593,7 @@ send_pubkey_test(Authctxt *authctxt, Key *k, sign_cb_fn *sign_callback,
595 return 1; 593 return 1;
596} 594}
597 595
598Key * 596static Key *
599load_identity_file(char *filename) 597load_identity_file(char *filename)
600{ 598{
601 Key *private; 599 Key *private;
@@ -633,7 +631,7 @@ load_identity_file(char *filename)
633 return private; 631 return private;
634} 632}
635 633
636int 634static int
637identity_sign_cb(Authctxt *authctxt, Key *key, u_char **sigp, int *lenp, 635identity_sign_cb(Authctxt *authctxt, Key *key, u_char **sigp, int *lenp,
638 u_char *data, int datalen) 636 u_char *data, int datalen)
639{ 637{
@@ -651,19 +649,21 @@ identity_sign_cb(Authctxt *authctxt, Key *key, u_char **sigp, int *lenp,
651 return ret; 649 return ret;
652} 650}
653 651
654int agent_sign_cb(Authctxt *authctxt, Key *key, u_char **sigp, int *lenp, 652static int
653agent_sign_cb(Authctxt *authctxt, Key *key, u_char **sigp, int *lenp,
655 u_char *data, int datalen) 654 u_char *data, int datalen)
656{ 655{
657 return ssh_agent_sign(authctxt->agent, key, sigp, lenp, data, datalen); 656 return ssh_agent_sign(authctxt->agent, key, sigp, lenp, data, datalen);
658} 657}
659 658
660int key_sign_cb(Authctxt *authctxt, Key *key, u_char **sigp, int *lenp, 659static int
660key_sign_cb(Authctxt *authctxt, Key *key, u_char **sigp, int *lenp,
661 u_char *data, int datalen) 661 u_char *data, int datalen)
662{ 662{
663 return key_sign(key, sigp, lenp, data, datalen); 663 return key_sign(key, sigp, lenp, data, datalen);
664} 664}
665 665
666int 666static int
667userauth_pubkey_agent(Authctxt *authctxt) 667userauth_pubkey_agent(Authctxt *authctxt)
668{ 668{
669 static int called = 0; 669 static int called = 0;
@@ -900,7 +900,7 @@ userauth_hostbased(Authctxt *authctxt)
900 * given auth method name, if configurable options permit this method fill 900 * given auth method name, if configurable options permit this method fill
901 * in auth_ident field and return true, otherwise return false. 901 * in auth_ident field and return true, otherwise return false.
902 */ 902 */
903int 903static int
904authmethod_is_enabled(Authmethod *method) 904authmethod_is_enabled(Authmethod *method)
905{ 905{
906 if (method == NULL) 906 if (method == NULL)
@@ -914,7 +914,7 @@ authmethod_is_enabled(Authmethod *method)
914 return 1; 914 return 1;
915} 915}
916 916
917Authmethod * 917static Authmethod *
918authmethod_lookup(const char *name) 918authmethod_lookup(const char *name)
919{ 919{
920 Authmethod *method = NULL; 920 Authmethod *method = NULL;
@@ -935,7 +935,7 @@ static char *preferred = NULL;
935 * next method we should try. If the server initially sends a nil list, 935 * next method we should try. If the server initially sends a nil list,
936 * use a built-in default list. 936 * use a built-in default list.
937 */ 937 */
938Authmethod * 938static Authmethod *
939authmethod_get(char *authlist) 939authmethod_get(char *authlist)
940{ 940{
941 941
diff --git a/sshd.c b/sshd.c
index 1dfcac0d7..431f4e2ac 100644
--- a/sshd.c
+++ b/sshd.c
@@ -40,7 +40,7 @@
40 */ 40 */
41 41
42#include "includes.h" 42#include "includes.h"
43RCSID("$OpenBSD: sshd.c,v 1.199 2001/06/04 23:07:21 markus Exp $"); 43RCSID("$OpenBSD: sshd.c,v 1.200 2001/06/23 15:12:21 itojun Exp $");
44 44
45#include <openssl/dh.h> 45#include <openssl/dh.h>
46#include <openssl/bn.h> 46#include <openssl/bn.h>
@@ -182,16 +182,15 @@ int session_id2_len = 0;
182u_int utmp_len = MAXHOSTNAMELEN; 182u_int utmp_len = MAXHOSTNAMELEN;
183 183
184/* Prototypes for various functions defined later in this file. */ 184/* Prototypes for various functions defined later in this file. */
185void do_ssh1_kex(void); 185void destroy_sensitive_data(void);
186void do_ssh2_kex(void);
187 186
188void ssh_dh1_server(Kex *, Buffer *_kexinit, Buffer *); 187static void do_ssh1_kex(void);
189void ssh_dhgex_server(Kex *, Buffer *_kexinit, Buffer *); 188static void do_ssh2_kex(void);
190 189
191/* 190/*
192 * Close all listening sockets 191 * Close all listening sockets
193 */ 192 */
194void 193static void
195close_listen_socks(void) 194close_listen_socks(void)
196{ 195{
197 int i; 196 int i;
@@ -205,7 +204,7 @@ close_listen_socks(void)
205 * the effect is to reread the configuration file (and to regenerate 204 * the effect is to reread the configuration file (and to regenerate
206 * the server key). 205 * the server key).
207 */ 206 */
208void 207static void
209sighup_handler(int sig) 208sighup_handler(int sig)
210{ 209{
211 received_sighup = 1; 210 received_sighup = 1;
@@ -216,7 +215,7 @@ sighup_handler(int sig)
216 * Called from the main program after receiving SIGHUP. 215 * Called from the main program after receiving SIGHUP.
217 * Restarts the server. 216 * Restarts the server.
218 */ 217 */
219void 218static void
220sighup_restart(void) 219sighup_restart(void)
221{ 220{
222 log("Received SIGHUP; restarting."); 221 log("Received SIGHUP; restarting.");
@@ -229,7 +228,7 @@ sighup_restart(void)
229/* 228/*
230 * Generic signal handler for terminating signals in the master daemon. 229 * Generic signal handler for terminating signals in the master daemon.
231 */ 230 */
232void 231static void
233sigterm_handler(int sig) 232sigterm_handler(int sig)
234{ 233{
235 received_sigterm = sig; 234 received_sigterm = sig;
@@ -239,7 +238,7 @@ sigterm_handler(int sig)
239 * SIGCHLD handler. This is called whenever a child dies. This will then 238 * SIGCHLD handler. This is called whenever a child dies. This will then
240 * reap any zombies left by exited children. 239 * reap any zombies left by exited children.
241 */ 240 */
242void 241static void
243main_sigchld_handler(int sig) 242main_sigchld_handler(int sig)
244{ 243{
245 int save_errno = errno; 244 int save_errno = errno;
@@ -255,7 +254,7 @@ main_sigchld_handler(int sig)
255/* 254/*
256 * Signal handler for the alarm after the login grace period has expired. 255 * Signal handler for the alarm after the login grace period has expired.
257 */ 256 */
258void 257static void
259grace_alarm_handler(int sig) 258grace_alarm_handler(int sig)
260{ 259{
261 /* XXX no idea how fix this signal handler */ 260 /* XXX no idea how fix this signal handler */
@@ -274,7 +273,7 @@ grace_alarm_handler(int sig)
274 * Thus there should be no concurrency control/asynchronous execution 273 * Thus there should be no concurrency control/asynchronous execution
275 * problems. 274 * problems.
276 */ 275 */
277void 276static void
278generate_ephemeral_server_key(void) 277generate_ephemeral_server_key(void)
279{ 278{
280 u_int32_t rand = 0; 279 u_int32_t rand = 0;
@@ -297,7 +296,7 @@ generate_ephemeral_server_key(void)
297 arc4random_stir(); 296 arc4random_stir();
298} 297}
299 298
300void 299static void
301key_regeneration_alarm(int sig) 300key_regeneration_alarm(int sig)
302{ 301{
303 int save_errno = errno; 302 int save_errno = errno;
@@ -306,7 +305,7 @@ key_regeneration_alarm(int sig)
306 key_do_regen = 1; 305 key_do_regen = 1;
307} 306}
308 307
309void 308static void
310sshd_exchange_identification(int sock_in, int sock_out) 309sshd_exchange_identification(int sock_in, int sock_out)
311{ 310{
312 int i, mismatch; 311 int i, mismatch;
@@ -456,7 +455,7 @@ destroy_sensitive_data(void)
456 memset(sensitive_data.ssh1_cookie, 0, SSH_SESSION_KEY_LENGTH); 455 memset(sensitive_data.ssh1_cookie, 0, SSH_SESSION_KEY_LENGTH);
457} 456}
458 457
459char * 458static char *
460list_hostkey_types(void) 459list_hostkey_types(void)
461{ 460{
462 static char buf[1024]; 461 static char buf[1024];
@@ -481,7 +480,7 @@ list_hostkey_types(void)
481 return buf; 480 return buf;
482} 481}
483 482
484Key * 483static Key *
485get_hostkey_by_type(int type) 484get_hostkey_by_type(int type)
486{ 485{
487 int i; 486 int i;
@@ -499,7 +498,7 @@ get_hostkey_by_type(int type)
499 * of (max_startups_rate/100). the probability increases linearly until 498 * of (max_startups_rate/100). the probability increases linearly until
500 * all connections are dropped for startups > max_startups 499 * all connections are dropped for startups > max_startups
501 */ 500 */
502int 501static int
503drop_connection(int startups) 502drop_connection(int startups)
504{ 503{
505 double p, r; 504 double p, r;
@@ -1203,7 +1202,7 @@ main(int ac, char **av)
1203/* 1202/*
1204 * SSH1 key exchange 1203 * SSH1 key exchange
1205 */ 1204 */
1206void 1205static void
1207do_ssh1_kex(void) 1206do_ssh1_kex(void)
1208{ 1207{
1209 int i, len; 1208 int i, len;
@@ -1424,7 +1423,7 @@ do_ssh1_kex(void)
1424/* 1423/*
1425 * SSH2 key exchange: diffie-hellman-group1-sha1 1424 * SSH2 key exchange: diffie-hellman-group1-sha1
1426 */ 1425 */
1427void 1426static void
1428do_ssh2_kex(void) 1427do_ssh2_kex(void)
1429{ 1428{
1430 Kex *kex; 1429 Kex *kex;