summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-07-04 04:46:56 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-07-04 04:46:56 +0000
commit4cc240dabbd81a308f06f2717b1942041fe0e205 (patch)
tree07291c8c2c467fc2ecec9166ed0d8ec1e75631a3
parent5bf5d67d497ed91c19851db6b904d54003afe67e (diff)
- markus@cvs.openbsd.org 2001/06/26 17:27:25
[authfd.h authfile.h auth.h auth-options.h bufaux.h buffer.h canohost.h channels.h cipher.h clientloop.h compat.h compress.h crc32.h deattack.h dh.h dispatch.h groupaccess.c groupaccess.h hostfile.h kex.h key.h log.c log.h mac.h misc.c misc.h mpaux.h packet.h radix.h readconf.h readpass.h rsa.h servconf.h serverloop.h session.h sftp-common.c sftp-common.h sftp-glob.h sftp-int.h sshconnect.h ssh-dss.h sshlogin.h sshpty.h ssh-rsa.h sshtty.h tildexpand.h uidswap.h uuencode.h xmalloc.h] remove comments from .h, since they are cut&paste from the .c files and out of sync
-rw-r--r--ChangeLog15
-rw-r--r--auth-options.h11
-rw-r--r--auth.h60
-rw-r--r--authfd.h85
-rw-r--r--authfile.h21
-rw-r--r--bufaux.h26
-rw-r--r--buffer.h55
-rw-r--r--canohost.h33
-rw-r--r--channels.h123
-rw-r--r--cipher.h22
-rw-r--r--clientloop.h4
-rw-r--r--compat.h11
-rw-r--r--compress.h36
-rw-r--r--crc32.h8
-rw-r--r--deattack.h4
-rw-r--r--dh.h8
-rw-r--r--dispatch.h10
-rw-r--r--groupaccess.c13
-rw-r--r--groupaccess.h21
-rw-r--r--hostfile.h19
-rw-r--r--kex.h14
-rw-r--r--key.h23
-rw-r--r--log.c6
-rw-r--r--log.h40
-rw-r--r--mac.h6
-rw-r--r--misc.c40
-rw-r--r--misc.h58
-rw-r--r--mpaux.h10
-rw-r--r--packet.h232
-rw-r--r--radix.h6
-rw-r--r--readconf.h46
-rw-r--r--readpass.h3
-rw-r--r--rsa.h9
-rw-r--r--servconf.h18
-rw-r--r--serverloop.h7
-rw-r--r--session.h12
-rw-r--r--sftp-common.c8
-rw-r--r--sftp-common.h19
-rw-r--r--sftp-glob.h3
-rw-r--r--sftp-int.h4
-rw-r--r--ssh-dss.h7
-rw-r--r--ssh-rsa.h7
-rw-r--r--sshconnect.h14
-rw-r--r--sshlogin.h35
-rw-r--r--sshpty.h31
-rw-r--r--sshtty.h25
-rw-r--r--tildexpand.h8
-rw-r--r--uidswap.h22
-rw-r--r--uuencode.h8
-rw-r--r--xmalloc.h17
50 files changed, 412 insertions, 911 deletions
diff --git a/ChangeLog b/ChangeLog
index c27402b5f..9c8aca4fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -62,7 +62,18 @@
62 - markus@cvs.openbsd.org 2001/06/26 17:25:34 62 - markus@cvs.openbsd.org 2001/06/26 17:25:34
63 [ssh.1] 63 [ssh.1]
64 document SSH_ASKPASS; fubob@MIT.EDU 64 document SSH_ASKPASS; fubob@MIT.EDU
65 65 - markus@cvs.openbsd.org 2001/06/26 17:27:25
66 [authfd.h authfile.h auth.h auth-options.h bufaux.h buffer.h
67 canohost.h channels.h cipher.h clientloop.h compat.h compress.h
68 crc32.h deattack.h dh.h dispatch.h groupaccess.c groupaccess.h
69 hostfile.h kex.h key.h log.c log.h mac.h misc.c misc.h mpaux.h
70 packet.h radix.h readconf.h readpass.h rsa.h servconf.h serverloop.h
71 session.h sftp-common.c sftp-common.h sftp-glob.h sftp-int.h
72 sshconnect.h ssh-dss.h sshlogin.h sshpty.h ssh-rsa.h sshtty.h
73 tildexpand.h uidswap.h uuencode.h xmalloc.h]
74 remove comments from .h, since they are cut&paste from the .c files
75 and out of sync
76
6620010629 7720010629
67 - (bal) Removed net_aton() since we don't use it any more 78 - (bal) Removed net_aton() since we don't use it any more
68 - (bal) Fixed _DISABLE_VPOSIX in readpassphrase.c. 79 - (bal) Fixed _DISABLE_VPOSIX in readpassphrase.c.
@@ -5889,4 +5900,4 @@
5889 - Wrote replacements for strlcpy and mkdtemp 5900 - Wrote replacements for strlcpy and mkdtemp
5890 - Released 1.0pre1 5901 - Released 1.0pre1
5891 5902
5892$Id: ChangeLog,v 1.1359 2001/07/04 04:31:38 mouring Exp $ 5903$Id: ChangeLog,v 1.1360 2001/07/04 04:46:56 mouring Exp $
diff --git a/auth-options.h b/auth-options.h
index db0e6e8fb..3b2ce344b 100644
--- a/auth-options.h
+++ b/auth-options.h
@@ -11,7 +11,7 @@
11 * called by a name other than "ssh" or "Secure Shell". 11 * called by a name other than "ssh" or "Secure Shell".
12 */ 12 */
13 13
14/* $OpenBSD: auth-options.h,v 1.9 2001/06/26 06:32:47 itojun Exp $ */ 14/* $OpenBSD: auth-options.h,v 1.10 2001/06/26 17:27:22 markus Exp $ */
15 15
16#ifndef AUTH_OPTIONS_H 16#ifndef AUTH_OPTIONS_H
17#define AUTH_OPTIONS_H 17#define AUTH_OPTIONS_H
@@ -30,14 +30,7 @@ extern int no_pty_flag;
30extern char *forced_command; 30extern char *forced_command;
31extern struct envstring *custom_environment; 31extern struct envstring *custom_environment;
32 32
33/* 33int auth_parse_options(struct passwd *, char *, char *, u_long);
34 * return 1 if access is granted, 0 if not.
35 * side effect: sets key option flags
36 */
37int
38auth_parse_options(struct passwd *, char *, char *, u_long);
39
40/* reset options flags */
41void auth_clear_options(void); 34void auth_clear_options(void);
42 35
43#endif 36#endif
diff --git a/auth.h b/auth.h
index 1c72dffa3..edfc9fb55 100644
--- a/auth.h
+++ b/auth.h
@@ -21,7 +21,7 @@
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
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 * $OpenBSD: auth.h,v 1.21 2001/06/26 16:15:23 dugsong Exp $ 24 * $OpenBSD: auth.h,v 1.22 2001/06/26 17:27:22 markus Exp $
25 */ 25 */
26#ifndef AUTH_H 26#ifndef AUTH_H
27#define AUTH_H 27#define AUTH_H
@@ -87,70 +87,29 @@ struct KbdintDevice
87 void (*free_ctx) __P((void *ctx)); 87 void (*free_ctx) __P((void *ctx));
88}; 88};
89 89
90/*
91 * Tries to authenticate the user using the .rhosts file. Returns true if
92 * authentication succeeds. If ignore_rhosts is non-zero, this will not
93 * consider .rhosts and .shosts (/etc/hosts.equiv will still be used).
94 */
95int auth_rhosts(struct passwd *, const char *); 90int auth_rhosts(struct passwd *, const char *);
96
97/* extended interface similar to auth_rhosts() */
98int 91int
99auth_rhosts2(struct passwd *, const char *, const char *, const char *); 92auth_rhosts2(struct passwd *, const char *, const char *, const char *);
100 93
101/* 94int auth_rhosts_rsa(struct passwd *, const char *, RSA *);
102 * Tries to authenticate the user using the .rhosts file and the host using 95int auth_password(Authctxt *, const char *);
103 * its host key. Returns true if authentication succeeds. 96int auth_rsa(struct passwd *, BIGNUM *);
104 */ 97int auth_rsa_read_key(char **, u_int *, BIGNUM *, BIGNUM *);
105int 98int auth_rsa_challenge_dialog(RSA *);
106auth_rhosts_rsa(struct passwd *, const char *, RSA *);
107
108/*
109 * Tries to authenticate the user using password. Returns true if
110 * authentication succeeds.
111 */
112int auth_password(Authctxt *, const char *);
113
114/*
115 * Performs the RSA authentication dialog with the client. This returns 0 if
116 * the client could not be authenticated, and 1 if authentication was
117 * successful. This may exit if there is a serious protocol violation.
118 */
119int auth_rsa(struct passwd *, BIGNUM *);
120
121/*
122 * Parses an RSA key (number of bits, e, n) from a string. Moves the pointer
123 * over the key. Skips any whitespace at the beginning and at end.
124 */
125int auth_rsa_read_key(char **, u_int *, BIGNUM *, BIGNUM *);
126
127/*
128 * Performs the RSA authentication challenge-response dialog with the client,
129 * and returns true (non-zero) if the client gave the correct answer to our
130 * challenge; returns zero if the client gives a wrong answer.
131 */
132int auth_rsa_challenge_dialog(RSA *);
133 99
134#ifdef KRB4 100#ifdef KRB4
135#include <krb.h> 101#include <krb.h>
136/*
137 * Performs Kerberos v4 mutual authentication with the client. This returns 0
138 * if the client could not be authenticated, and 1 if authentication was
139 * successful. This may exit if there is a serious protocol violation.
140 */
141int auth_krb4(Authctxt *, KTEXT, char **); 102int auth_krb4(Authctxt *, KTEXT, char **);
142int auth_krb4_password(Authctxt *, const char *); 103int auth_krb4_password(Authctxt *, const char *);
143void krb4_cleanup_proc(void *); 104void krb4_cleanup_proc(void *);
144 105
145#ifdef AFS 106#ifdef AFS
146#include <kafs.h> 107#include <kafs.h>
147
148/* Accept passed Kerberos v4 ticket-granting ticket and AFS tokens. */
149int auth_krb4_tgt(Authctxt *, const char *); 108int auth_krb4_tgt(Authctxt *, const char *);
150int auth_afs_token(Authctxt *, const char *); 109int auth_afs_token(Authctxt *, const char *);
151#endif /* AFS */ 110#endif /* AFS */
152 111
153#endif /* KRB4 */ 112#endif /* KRB4 */
154 113
155#ifdef KRB5 114#ifdef KRB5
156int auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client); 115int auth_krb5(Authctxt *authctxt, krb5_data *auth, char **client);
@@ -179,16 +138,13 @@ int verify_response(Authctxt *, const char *);
179 138
180struct passwd * auth_get_user(void); 139struct passwd * auth_get_user(void);
181 140
182/* expand a filename - return buffer is allocated by xmalloc */
183char *expand_filename(const char *, struct passwd *); 141char *expand_filename(const char *, struct passwd *);
184char *authorized_keys_file(struct passwd *); 142char *authorized_keys_file(struct passwd *);
185char *authorized_keys_file2(struct passwd *); 143char *authorized_keys_file2(struct passwd *);
186 144
187/* check a file and the path to it */
188int 145int
189secure_filename(FILE *, const char *, struct passwd *, char *, size_t); 146secure_filename(FILE *, const char *, struct passwd *, char *, size_t);
190 147
191/* helper for hostbased auth */
192HostStatus 148HostStatus
193check_key_in_hostfiles(struct passwd *, Key *, const char *, 149check_key_in_hostfiles(struct passwd *, Key *, const char *,
194 const char *, const char *); 150 const char *, const char *);
diff --git a/authfd.h b/authfd.h
index 4fe35aff8..5aac78bda 100644
--- a/authfd.h
+++ b/authfd.h
@@ -11,7 +11,7 @@
11 * called by a name other than "ssh" or "Secure Shell". 11 * called by a name other than "ssh" or "Secure Shell".
12 */ 12 */
13 13
14/* RCSID("$OpenBSD: authfd.h,v 1.18 2001/06/26 06:32:47 itojun Exp $"); */ 14/* RCSID("$OpenBSD: authfd.h,v 1.19 2001/06/26 17:27:22 markus Exp $"); */
15 15
16#ifndef AUTHFD_H 16#ifndef AUTHFD_H
17#define AUTHFD_H 17#define AUTHFD_H
@@ -43,96 +43,35 @@
43#define SSH_AGENTC_REMOVE_SMARTCARD_KEY 21 43#define SSH_AGENTC_REMOVE_SMARTCARD_KEY 21
44 44
45/* additional error code for ssh.com's ssh-agent2 */ 45/* additional error code for ssh.com's ssh-agent2 */
46#define SSH_COM_AGENT2_FAILURE 102 46#define SSH_COM_AGENT2_FAILURE 102
47 47
48#define SSH_AGENT_OLD_SIGNATURE 0x01 48#define SSH_AGENT_OLD_SIGNATURE 0x01
49 49
50
51typedef struct { 50typedef struct {
52 int fd; 51 int fd;
53 Buffer identities; 52 Buffer identities;
54 int howmany; 53 int howmany;
55} AuthenticationConnection; 54} AuthenticationConnection;
56 55
57/* Returns the number of the authentication fd, or -1 if there is none. */ 56int ssh_get_authentication_socket(void);
58int ssh_get_authentication_socket(void); 57void ssh_close_authentication_socket(int);
59
60/*
61 * This should be called for any descriptor returned by
62 * ssh_get_authentication_socket(). Depending on the way the descriptor was
63 * obtained, this may close the descriptor.
64 */
65void ssh_close_authentication_socket(int);
66 58
67/*
68 * Opens and connects a private socket for communication with the
69 * authentication agent. Returns NULL if an error occurred and the
70 * connection could not be opened. The connection should be closed by the
71 * caller by calling ssh_close_authentication_connection().
72 */
73AuthenticationConnection *ssh_get_authentication_connection(void); 59AuthenticationConnection *ssh_get_authentication_connection(void);
74 60void ssh_close_authentication_connection(AuthenticationConnection *);
75/* 61int ssh_get_num_identities(AuthenticationConnection *, int);
76 * Closes the connection to the authentication agent and frees any associated
77 * memory.
78 */
79void ssh_close_authentication_connection(AuthenticationConnection *);
80
81/*
82 * Returns the number authentication identity held by the agent.
83 */
84int ssh_get_num_identities(AuthenticationConnection *, int);
85
86/*
87 * Returns the first authentication identity held by the agent or NULL if
88 * no identies are available. Caller must free comment and key.
89 * Note that you cannot mix calls with different versions.
90 */
91Key *ssh_get_first_identity(AuthenticationConnection *, char **, int); 62Key *ssh_get_first_identity(AuthenticationConnection *, char **, int);
92
93/*
94 * Returns the next authentication identity for the agent. Other functions
95 * can be called between this and ssh_get_first_identity or two calls of this
96 * function. This returns NULL if there are no more identities. The caller
97 * must free key and comment after a successful return.
98 */
99Key *ssh_get_next_identity(AuthenticationConnection *, char **, int); 63Key *ssh_get_next_identity(AuthenticationConnection *, char **, int);
64int ssh_add_identity(AuthenticationConnection *, Key *, const char *);
65int ssh_remove_identity(AuthenticationConnection *, Key *);
66int ssh_remove_all_identities(AuthenticationConnection *, int);
67int ssh_update_card(AuthenticationConnection *, int, int);
100 68
101/*
102 * Requests the agent to decrypt the given challenge. Returns true if the
103 * agent claims it was able to decrypt it.
104 */
105int 69int
106ssh_decrypt_challenge(AuthenticationConnection *, Key *, BIGNUM *, u_char[16], 70ssh_decrypt_challenge(AuthenticationConnection *, Key *, BIGNUM *, u_char[16],
107 u_int, u_char[16]); 71 u_int, u_char[16]);
108 72
109/* Requests the agent to sign data using key */
110int
111ssh_agent_sign(AuthenticationConnection *, Key *, u_char **, int *,
112 u_char *, int);
113
114/*
115 * Adds an identity to the authentication server. This call is not meant to
116 * be used by normal applications. This returns true if the identity was
117 * successfully added.
118 */
119int 73int
120ssh_add_identity(AuthenticationConnection *, Key *, const char *); 74ssh_agent_sign(AuthenticationConnection *, Key *, u_char **, int *, u_char *,
121 75 int);
122/*
123 * Removes the identity from the authentication server. This call is not
124 * meant to be used by normal applications. This returns true if the
125 * identity was successfully added.
126 */
127int ssh_remove_identity(AuthenticationConnection *, Key *);
128
129/*
130 * Removes all identities from the authentication agent. This call is not
131 * meant to be used by normal applications. This returns true if the
132 * operation was successful.
133 */
134int ssh_remove_all_identities(AuthenticationConnection *, int);
135
136int ssh_update_card(AuthenticationConnection *, int, int);
137 76
138#endif /* AUTHFD_H */ 77#endif /* AUTHFD_H */
diff --git a/authfile.h b/authfile.h
index 982645d50..c8b31fbe6 100644
--- a/authfile.h
+++ b/authfile.h
@@ -10,24 +10,15 @@
10 * called by a name other than "ssh" or "Secure Shell". 10 * called by a name other than "ssh" or "Secure Shell".
11 */ 11 */
12 12
13/* $OpenBSD: authfile.h,v 1.7 2001/06/26 06:32:48 itojun Exp $ */ 13/* $OpenBSD: authfile.h,v 1.8 2001/06/26 17:27:22 markus Exp $ */
14 14
15#ifndef AUTHFILE_H 15#ifndef AUTHFILE_H
16#define AUTHFILE_H 16#define AUTHFILE_H
17 17
18int 18int key_save_private(Key *, const char *, const char *, const char *);
19key_save_private(Key *, const char *, const char *, const char *); 19Key *key_load_public(const char *, char **);
20 20Key *key_load_public_type(int, const char *, char **);
21Key * 21Key *key_load_private(const char *, const char *, char **);
22key_load_public(const char *, char **); 22Key *key_load_private_type(int, const char *, const char *, char **);
23
24Key *
25key_load_public_type(int, const char *, char **);
26
27Key *
28key_load_private(const char *, const char *, char **);
29
30Key *
31key_load_private_type(int, const char *, const char *, char **);
32 23
33#endif 24#endif
diff --git a/bufaux.h b/bufaux.h
index 765ee5e79..d1af09881 100644
--- a/bufaux.h
+++ b/bufaux.h
@@ -10,7 +10,7 @@
10 * called by a name other than "ssh" or "Secure Shell". 10 * called by a name other than "ssh" or "Secure Shell".
11 */ 11 */
12 12
13/* RCSID("$OpenBSD: bufaux.h,v 1.12 2001/06/26 06:32:48 itojun Exp $"); */ 13/* RCSID("$OpenBSD: bufaux.h,v 1.13 2001/06/26 17:27:22 markus Exp $"); */
14 14
15#ifndef BUFAUX_H 15#ifndef BUFAUX_H
16#define BUFAUX_H 16#define BUFAUX_H
@@ -18,46 +18,26 @@
18#include "buffer.h" 18#include "buffer.h"
19#include <openssl/bn.h> 19#include <openssl/bn.h>
20 20
21/*
22 * Stores an BIGNUM in the buffer with a 2-byte msb first bit count, followed
23 * by (bits+7)/8 bytes of binary data, msb first.
24 */
25void buffer_put_bignum(Buffer *, BIGNUM *); 21void buffer_put_bignum(Buffer *, BIGNUM *);
26void buffer_put_bignum2(Buffer *, BIGNUM *); 22void buffer_put_bignum2(Buffer *, BIGNUM *);
27 23
28/* Retrieves an BIGNUM from the buffer. */
29int buffer_get_bignum(Buffer *, BIGNUM *); 24int buffer_get_bignum(Buffer *, BIGNUM *);
30int buffer_get_bignum2(Buffer *, BIGNUM *); 25int buffer_get_bignum2(Buffer *, BIGNUM *);
31 26
32/* Returns an integer from the buffer (4 bytes, msb first). */
33u_int buffer_get_int(Buffer *); 27u_int buffer_get_int(Buffer *);
34#ifdef HAVE_U_INT64_T
35u_int64_t buffer_get_int64(Buffer *);
36#endif
37
38/* Stores an integer in the buffer in 4 bytes, msb first. */
39void buffer_put_int(Buffer *, u_int); 28void buffer_put_int(Buffer *, u_int);
29
40#ifdef HAVE_U_INT64_T 30#ifdef HAVE_U_INT64_T
31u_int64_t buffer_get_int64(Buffer *);
41void buffer_put_int64(Buffer *, u_int64_t); 32void buffer_put_int64(Buffer *, u_int64_t);
42#endif 33#endif
43 34
44/* Returns a character from the buffer (0 - 255). */
45int buffer_get_char(Buffer *); 35int buffer_get_char(Buffer *);
46 36
47/* Stores a character in the buffer. */
48void buffer_put_char(Buffer *, int); 37void buffer_put_char(Buffer *, int);
49 38
50/*
51 * Returns an arbitrary binary string from the buffer. The string cannot be
52 * longer than 256k. The returned value points to memory allocated with
53 * xmalloc; it is the responsibility of the calling function to free the
54 * data. If length_ptr is non-NULL, the length of the returned data will be
55 * stored there. A null character will be automatically appended to the
56 * returned string, and is not counted in length.
57 */
58char *buffer_get_string(Buffer *, u_int *); 39char *buffer_get_string(Buffer *, u_int *);
59 40
60/* Stores and arbitrary binary string in the buffer. */
61void buffer_put_string(Buffer *, const void *, u_int); 41void buffer_put_string(Buffer *, const void *, u_int);
62void buffer_put_cstring(Buffer *, const char *); 42void buffer_put_cstring(Buffer *, const char *);
63 43
diff --git a/buffer.h b/buffer.h
index 5e9fc278d..845bfb697 100644
--- a/buffer.h
+++ b/buffer.h
@@ -11,56 +11,33 @@
11 * called by a name other than "ssh" or "Secure Shell". 11 * called by a name other than "ssh" or "Secure Shell".
12 */ 12 */
13 13
14/* RCSID("$OpenBSD: buffer.h,v 1.8 2001/06/26 06:32:48 itojun Exp $"); */ 14/* RCSID("$OpenBSD: buffer.h,v 1.9 2001/06/26 17:27:23 markus Exp $"); */
15 15
16#ifndef BUFFER_H 16#ifndef BUFFER_H
17#define BUFFER_H 17#define BUFFER_H
18 18
19typedef struct { 19typedef struct {
20 char *buf; /* Buffer for data. */ 20 char *buf; /* Buffer for data. */
21 u_int alloc; /* Number of bytes allocated for data. */ 21 u_int alloc; /* Number of bytes allocated for data. */
22 u_int offset; /* Offset of first byte containing data. */ 22 u_int offset; /* Offset of first byte containing data. */
23 u_int end; /* Offset of last byte containing data. */ 23 u_int end; /* Offset of last byte containing data. */
24} Buffer; 24} Buffer;
25/* Initializes the buffer structure. */
26void buffer_init(Buffer *);
27 25
28/* Frees any memory used for the buffer. */ 26void buffer_init(Buffer *);
29void buffer_free(Buffer *); 27void buffer_clear(Buffer *);
28void buffer_free(Buffer *);
30 29
31/* Clears any data from the buffer, making it empty. This does not actually 30u_int buffer_len(Buffer *);
32 zero the memory. */ 31char *buffer_ptr(Buffer *);
33void buffer_clear(Buffer *);
34 32
35/* Appends data to the buffer, expanding it if necessary. */ 33void buffer_append(Buffer *, const char *, u_int);
36void buffer_append(Buffer *, const char *, u_int); 34void buffer_append_space(Buffer *, char **, u_int);
37 35
38/* 36void buffer_get(Buffer *, char *, u_int);
39 * Appends space to the buffer, expanding the buffer if necessary. This does
40 * not actually copy the data into the buffer, but instead returns a pointer
41 * to the allocated region.
42 */
43void buffer_append_space(Buffer *, char **, u_int);
44
45/* Returns the number of bytes of data in the buffer. */
46u_int buffer_len(Buffer *);
47
48/* Gets data from the beginning of the buffer. */
49void buffer_get(Buffer *, char *, u_int);
50 37
51/* Consumes the given number of bytes from the beginning of the buffer. */ 38void buffer_consume(Buffer *, u_int);
52void buffer_consume(Buffer *, u_int); 39void buffer_consume_end(Buffer *, u_int);
53 40
54/* Consumes the given number of bytes from the end of the buffer. */ 41void buffer_dump(Buffer *);
55void buffer_consume_end(Buffer *, u_int);
56
57/* Returns a pointer to the first used byte in the buffer. */
58char *buffer_ptr(Buffer *);
59
60/*
61 * Dumps the contents of the buffer to stderr in hex. This intended for
62 * debugging purposes only.
63 */
64void buffer_dump(Buffer *);
65 42
66#endif /* BUFFER_H */ 43#endif /* BUFFER_H */
diff --git a/canohost.h b/canohost.h
index 66e64d506..4347b488a 100644
--- a/canohost.h
+++ b/canohost.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: canohost.h,v 1.7 2001/06/26 06:32:49 itojun Exp $ */ 1/* $OpenBSD: canohost.h,v 1.8 2001/06/26 17:27:23 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -12,27 +12,14 @@
12 * called by a name other than "ssh" or "Secure Shell". 12 * called by a name other than "ssh" or "Secure Shell".
13 */ 13 */
14 14
15/* 15const char *get_canonical_hostname(int);
16 * Return the canonical name of the host in the other side of the current 16const char *get_remote_ipaddr(void);
17 * connection (as returned by packet_get_connection). The host name is 17const char *get_remote_name_or_ip(u_int, int);
18 * cached, so it is efficient to call this several times.
19 */
20const char *get_canonical_hostname(int);
21
22/*
23 * Returns the IP-address of the remote host as a string. The returned
24 * string is cached and must not be freed.
25 */
26const char *get_remote_ipaddr(void);
27
28const char *get_remote_name_or_ip(u_int, int);
29 18
30/* Returns the ipaddr/port number of the peer of the socket. */ 19char *get_peer_ipaddr(int);
31char * get_peer_ipaddr(int); 20int get_peer_port(int);
32int get_peer_port(int); 21char *get_local_ipaddr(int);
33char * get_local_ipaddr(int); 22char *get_local_name(int);
34char * get_local_name(int);
35 23
36/* Returns the port number of the remote/local host. */ 24int get_remote_port(void);
37int get_remote_port(void); 25int get_local_port(void);
38int get_local_port(void);
diff --git a/channels.h b/channels.h
index 3a114e070..98bba1aed 100644
--- a/channels.h
+++ b/channels.h
@@ -32,7 +32,7 @@
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */ 34 */
35/* RCSID("$OpenBSD: channels.h,v 1.41 2001/06/26 06:32:49 itojun Exp $"); */ 35/* RCSID("$OpenBSD: channels.h,v 1.42 2001/06/26 17:27:23 markus Exp $"); */
36 36
37#ifndef CHANNEL_H 37#ifndef CHANNEL_H
38#define CHANNEL_H 38#define CHANNEL_H
@@ -58,10 +58,6 @@
58 58
59#define SSH_CHANNEL_PATH_LEN 30 59#define SSH_CHANNEL_PATH_LEN 30
60 60
61/*
62 * Data structure for channel data. This is initialized in channel_new
63 * and cleared in channel_free.
64 */
65struct Channel; 61struct Channel;
66typedef struct Channel Channel; 62typedef struct Channel Channel;
67 63
@@ -139,87 +135,87 @@ struct Channel {
139#define CHAN_CLOSE_SENT 0x01 135#define CHAN_CLOSE_SENT 0x01
140#define CHAN_CLOSE_RCVD 0x02 136#define CHAN_CLOSE_RCVD 0x02
141 137
142
143/* channel management */ 138/* channel management */
144 139
145Channel *channel_lookup(int); 140Channel *channel_lookup(int);
146Channel *channel_new(char *, int, int, int, int, int, int, int, char *, int); 141Channel *channel_new(char *, int, int, int, int, int, int, int, char *, int);
147void channel_set_fds(int, int, int, int, int, int); 142void channel_set_fds(int, int, int, int, int, int);
148void channel_free(Channel *); 143void channel_free(Channel *);
149void channel_free_all(void); 144void channel_free_all(void);
150 145
151void channel_send_open(int); 146void channel_send_open(int);
152void channel_request(int, char *, int); 147void channel_request(int, char *, int);
153void channel_request_start(int, char *, int); 148void channel_request_start(int, char *, int);
154void channel_register_callback(int, int mtype, channel_callback_fn *, void *); 149void channel_register_callback(int, int mtype, channel_callback_fn *, void *);
155void channel_register_cleanup(int, channel_callback_fn *); 150void channel_register_cleanup(int, channel_callback_fn *);
156void channel_register_filter(int, channel_filter_fn *); 151void channel_register_filter(int, channel_filter_fn *);
157void channel_cancel_cleanup(int); 152void channel_cancel_cleanup(int);
158 153
159/* protocol handler */ 154/* protocol handler */
160 155
161void channel_input_channel_request(int, int, void *); 156void channel_input_channel_request(int, int, void *);
162void channel_input_close(int, int, void *); 157void channel_input_close(int, int, void *);
163void channel_input_close_confirmation(int, int, void *); 158void channel_input_close_confirmation(int, int, void *);
164void channel_input_data(int, int, void *); 159void channel_input_data(int, int, void *);
165void channel_input_extended_data(int, int, void *); 160void channel_input_extended_data(int, int, void *);
166void channel_input_ieof(int, int, void *); 161void channel_input_ieof(int, int, void *);
167void channel_input_oclose(int, int, void *); 162void channel_input_oclose(int, int, void *);
168void channel_input_open_confirmation(int, int, void *); 163void channel_input_open_confirmation(int, int, void *);
169void channel_input_open_failure(int, int, void *); 164void channel_input_open_failure(int, int, void *);
170void channel_input_port_open(int, int, void *); 165void channel_input_port_open(int, int, void *);
171void channel_input_window_adjust(int, int, void *); 166void channel_input_window_adjust(int, int, void *);
172 167
173/* file descriptor handling (read/write) */ 168/* file descriptor handling (read/write) */
174 169
175void 170void channel_prepare_select(fd_set **, fd_set **, int *, int);
176channel_prepare_select(fd_set **, fd_set **, int *, int); 171void channel_after_select(fd_set *, fd_set *);
177void channel_after_select(fd_set *, fd_set *); 172void channel_output_poll(void);
178void channel_output_poll(void);
179 173
180int channel_not_very_much_buffered_data(void); 174int channel_not_very_much_buffered_data(void);
181void channel_close_all(void); 175void channel_close_all(void);
182void channel_free_all(void); 176void channel_free_all(void);
183int channel_still_open(void); 177int channel_still_open(void);
184char *channel_open_message(void); 178char *channel_open_message(void);
185int channel_find_open(void); 179int channel_find_open(void);
186 180
187/* channel_tcpfwd.c */ 181/* channel_tcpfwd.c */
188int 182void channel_permit_all_opens(void);
189channel_request_local_forwarding(u_short, const char *, u_short, int); 183void channel_add_permitted_opens(char *, int);
184void channel_clear_permitted_opens(void);
185void channel_input_port_forward_request(int, int);
186int channel_connect_to(const char *, u_short);
187int channel_connect_by_listen_adress(u_short);
188void channel_request_remote_forwarding(u_short, const char *, u_short);
189int channel_request_local_forwarding(u_short, const char *, u_short, int);
190int 190int
191channel_request_forwarding(const char *, u_short, const char *, u_short, int, 191channel_request_forwarding(const char *, u_short, const char *, u_short, int,
192 int); 192 int);
193void
194channel_request_remote_forwarding(u_short, const char *, u_short);
195void channel_permit_all_opens(void);
196void channel_add_permitted_opens(char *, int);
197void channel_clear_permitted_opens(void);
198void channel_input_port_forward_request(int, int);
199int channel_connect_to(const char *, u_short);
200int channel_connect_by_listen_adress(u_short);
201 193
202/* x11 forwarding */ 194/* x11 forwarding */
203 195
204int x11_connect_display(void); 196int x11_connect_display(void);
205char *x11_create_display(int); 197char *x11_create_display(int);
206char *x11_create_display_inet(int, int); 198char *x11_create_display_inet(int, int);
207void x11_input_open(int, int, void *); 199void x11_input_open(int, int, void *);
208void x11_request_forwarding(void); 200void x11_request_forwarding(void);
209void 201void x11_request_forwarding_with_spoofing(int, const char *, const char *);
210x11_request_forwarding_with_spoofing(int, const char *, const char *); 202void deny_input_open(int, int, void *);
211void deny_input_open(int, int, void *);
212 203
213/* agent forwarding */ 204/* agent forwarding */
214 205
215void auth_request_forwarding(void); 206void auth_request_forwarding(void);
216char *auth_get_socket_name(void); 207char *auth_get_socket_name(void);
217void auth_sock_cleanup_proc(void *); 208void auth_sock_cleanup_proc(void *);
218int auth_input_request_forwarding(struct passwd *); 209int auth_input_request_forwarding(struct passwd *);
219void auth_input_open_request(int, int, void *); 210void auth_input_open_request(int, int, void *);
220 211
221/* channel close */ 212/* channel close */
222 213
214int chan_is_dead(Channel *);
215void chan_mark_dead(Channel *);
216void chan_init_iostates(Channel *);
217void chan_init(void);
218
223typedef void chan_event_fn(Channel *); 219typedef void chan_event_fn(Channel *);
224 220
225/* for the input state */ 221/* for the input state */
@@ -232,9 +228,4 @@ extern chan_event_fn *chan_rcvd_ieof;
232extern chan_event_fn *chan_write_failed; 228extern chan_event_fn *chan_write_failed;
233extern chan_event_fn *chan_obuf_empty; 229extern chan_event_fn *chan_obuf_empty;
234 230
235int chan_is_dead(Channel *);
236void chan_mark_dead(Channel *);
237void chan_init_iostates(Channel *);
238void chan_init(void);
239
240#endif 231#endif
diff --git a/cipher.h b/cipher.h
index 16dd06230..1b79d4d69 100644
--- a/cipher.h
+++ b/cipher.h
@@ -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 34
35/* RCSID("$OpenBSD: cipher.h,v 1.27 2001/06/26 06:32:49 itojun Exp $"); */ 35/* RCSID("$OpenBSD: cipher.h,v 1.28 2001/06/26 17:27:23 markus Exp $"); */
36 36
37#ifndef CIPHER_H 37#ifndef CIPHER_H
38#define CIPHER_H 38#define CIPHER_H
@@ -104,16 +104,16 @@ struct Cipher {
104 void (*decrypt)(CipherContext *, u_char *, const u_char *, u_int); 104 void (*decrypt)(CipherContext *, u_char *, const u_char *, u_int);
105}; 105};
106 106
107u_int cipher_mask_ssh1(int); 107u_int cipher_mask_ssh1(int);
108Cipher *cipher_by_name(const char *); 108Cipher *cipher_by_name(const char *);
109Cipher *cipher_by_number(int); 109Cipher *cipher_by_number(int);
110int cipher_number(const char *); 110int cipher_number(const char *);
111char *cipher_name(int); 111char *cipher_name(int);
112int ciphers_valid(const char *); 112int ciphers_valid(const char *);
113void cipher_init(CipherContext *, Cipher *, const u_char *, u_int, 113void cipher_init(CipherContext *, Cipher *, const u_char *, u_int,
114 const u_char *, u_int); 114 const u_char *, u_int);
115void cipher_encrypt(CipherContext *, u_char *, const u_char *, u_int); 115void cipher_encrypt(CipherContext *, u_char *, const u_char *, u_int);
116void cipher_decrypt(CipherContext *, u_char *, const u_char *, u_int); 116void cipher_decrypt(CipherContext *, u_char *, const u_char *, u_int);
117void cipher_set_key_string(CipherContext *, Cipher *, const char *); 117void cipher_set_key_string(CipherContext *, Cipher *, const char *);
118 118
119#endif /* CIPHER_H */ 119#endif /* CIPHER_H */
diff --git a/clientloop.h b/clientloop.h
index b7f48aa86..1bc9a9523 100644
--- a/clientloop.h
+++ b/clientloop.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: clientloop.h,v 1.5 2001/06/26 06:32:50 itojun Exp $ */ 1/* $OpenBSD: clientloop.h,v 1.6 2001/06/26 17:27:23 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -36,4 +36,4 @@
36 */ 36 */
37 37
38/* Client side main loop for the interactive session. */ 38/* Client side main loop for the interactive session. */
39int client_loop(int, int, int); 39int client_loop(int, int, int);
diff --git a/compat.h b/compat.h
index a44f321ce..7d688cc9e 100644
--- a/compat.h
+++ b/compat.h
@@ -21,7 +21,7 @@
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
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/* RCSID("$OpenBSD: compat.h,v 1.27 2001/06/26 06:32:50 itojun Exp $"); */ 24/* RCSID("$OpenBSD: compat.h,v 1.28 2001/06/26 17:27:23 markus Exp $"); */
25 25
26#ifndef COMPAT_H 26#ifndef COMPAT_H
27#define COMPAT_H 27#define COMPAT_H
@@ -51,11 +51,12 @@
51#define SSH_BUG_OPENFAILURE 0x00020000 51#define SSH_BUG_OPENFAILURE 0x00020000
52#define SSH_BUG_DERIVEKEY 0x00040000 52#define SSH_BUG_DERIVEKEY 0x00040000
53 53
54void enable_compat13(void); 54void enable_compat13(void);
55void enable_compat20(void); 55void enable_compat20(void);
56void compat_datafellows(const char *); 56void compat_datafellows(const char *);
57int proto_spec(const char *); 57int proto_spec(const char *);
58char *compat_cipher_proposal(char *); 58char *compat_cipher_proposal(char *);
59
59extern int compat13; 60extern int compat13;
60extern int compat20; 61extern int compat20;
61extern int datafellows; 62extern int datafellows;
diff --git a/compress.h b/compress.h
index a9d06fc05..2721d450c 100644
--- a/compress.h
+++ b/compress.h
@@ -11,39 +11,15 @@
11 * called by a name other than "ssh" or "Secure Shell". 11 * called by a name other than "ssh" or "Secure Shell".
12 */ 12 */
13 13
14/* RCSID("$OpenBSD: compress.h,v 1.9 2001/06/26 06:32:50 itojun Exp $"); */ 14/* RCSID("$OpenBSD: compress.h,v 1.10 2001/06/26 17:27:23 markus Exp $"); */
15 15
16#ifndef COMPRESS_H 16#ifndef COMPRESS_H
17#define COMPRESS_H 17#define COMPRESS_H
18 18
19/* 19void buffer_compress_init_send(int);
20 * Initializes compression; level is compression level from 1 to 9 (as in 20void buffer_compress_init_recv(void);
21 * gzip). 21void buffer_compress_uninit(void);
22 */ 22void buffer_compress(Buffer *, Buffer *);
23void buffer_compress_init_send(int); 23void buffer_uncompress(Buffer *, Buffer *);
24void buffer_compress_init_recv(void);
25
26/* Frees any data structures allocated by buffer_compress_init. */
27void buffer_compress_uninit(void);
28
29/*
30 * Compresses the contents of input_buffer into output_buffer. All packets
31 * compressed using this function will form a single compressed data stream;
32 * however, data will be flushed at the end of every call so that each
33 * output_buffer can be decompressed independently (but in the appropriate
34 * order since they together form a single compression stream) by the
35 * receiver. This appends the compressed data to the output buffer.
36 */
37void buffer_compress(Buffer *, Buffer *);
38
39/*
40 * Uncompresses the contents of input_buffer into output_buffer. All packets
41 * uncompressed using this function will form a single compressed data
42 * stream; however, data will be flushed at the end of every call so that
43 * each output_buffer. This must be called for the same size units that the
44 * buffer_compress was called, and in the same order that buffers compressed
45 * with that. This appends the uncompressed data to the output buffer.
46 */
47void buffer_uncompress(Buffer *, Buffer *);
48 24
49#endif /* COMPRESS_H */ 25#endif /* COMPRESS_H */
diff --git a/crc32.h b/crc32.h
index 4cd933390..bdabc1b09 100644
--- a/crc32.h
+++ b/crc32.h
@@ -11,15 +11,11 @@
11 * called by a name other than "ssh" or "Secure Shell". 11 * called by a name other than "ssh" or "Secure Shell".
12 */ 12 */
13 13
14/* RCSID("$OpenBSD: crc32.h,v 1.11 2001/06/26 06:32:51 itojun Exp $"); */ 14/* RCSID("$OpenBSD: crc32.h,v 1.12 2001/06/26 17:27:23 markus Exp $"); */
15 15
16#ifndef CRC32_H 16#ifndef CRC32_H
17#define CRC32_H 17#define CRC32_H
18 18
19/* 19u_int ssh_crc32(const u_char *, u_int);
20 * This computes a 32 bit CRC of the data in the buffer, and returns the CRC.
21 * The polynomial used is 0xedb88320.
22 */
23u_int ssh_crc32(const u_char *, u_int);
24 20
25#endif /* CRC32_H */ 21#endif /* CRC32_H */
diff --git a/deattack.h b/deattack.h
index 24d3957a6..ddccdea50 100644
--- a/deattack.h
+++ b/deattack.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: deattack.h,v 1.6 2001/06/26 06:32:51 itojun Exp $ */ 1/* $OpenBSD: deattack.h,v 1.7 2001/06/26 17:27:23 markus Exp $ */
2 2
3/* 3/*
4 * Cryptographic attack detector for ssh - Header file 4 * Cryptographic attack detector for ssh - Header file
@@ -26,5 +26,5 @@
26#define DEATTACK_OK 0 26#define DEATTACK_OK 0
27#define DEATTACK_DETECTED 1 27#define DEATTACK_DETECTED 1
28 28
29int detect_attack(u_char *, u_int32_t, u_char[8]); 29int detect_attack(u_char *, u_int32_t, u_char[8]);
30#endif 30#endif
diff --git a/dh.h b/dh.h
index fd90fab5a..a0c97b2ff 100644
--- a/dh.h
+++ b/dh.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: dh.h,v 1.6 2001/06/26 06:32:52 itojun Exp $ */ 1/* $OpenBSD: dh.h,v 1.7 2001/06/26 17:27:23 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Niels Provos. All rights reserved. 4 * Copyright (c) 2000 Niels Provos. All rights reserved.
@@ -37,10 +37,10 @@ DH *dh_new_group_asc(const char *, const char *);
37DH *dh_new_group(BIGNUM *, BIGNUM *); 37DH *dh_new_group(BIGNUM *, BIGNUM *);
38DH *dh_new_group1(void); 38DH *dh_new_group1(void);
39 39
40void dh_gen_key(DH *, int); 40void dh_gen_key(DH *, int);
41int dh_pub_is_valid(DH *, BIGNUM *); 41int dh_pub_is_valid(DH *, BIGNUM *);
42 42
43int dh_estimate(int); 43int dh_estimate(int);
44 44
45#define DH_GRP_MIN 1024 45#define DH_GRP_MIN 1024
46#define DH_GRP_MAX 8192 46#define DH_GRP_MAX 8192
diff --git a/dispatch.h b/dispatch.h
index f796705a2..7b94032af 100644
--- a/dispatch.h
+++ b/dispatch.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: dispatch.h,v 1.5 2001/06/26 06:32:52 itojun Exp $ */ 1/* $OpenBSD: dispatch.h,v 1.6 2001/06/26 17:27:23 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -30,7 +30,7 @@ enum {
30 30
31typedef void dispatch_fn(int, int, void *); 31typedef void dispatch_fn(int, int, void *);
32 32
33void dispatch_init(dispatch_fn *); 33void dispatch_init(dispatch_fn *);
34void dispatch_set(int, dispatch_fn *); 34void dispatch_set(int, dispatch_fn *);
35void dispatch_run(int, int *, void *); 35void dispatch_run(int, int *, void *);
36void dispatch_protocol_error(int, int, void *); 36void dispatch_protocol_error(int, int, void *);
diff --git a/groupaccess.c b/groupaccess.c
index ac9e00aca..cbfe72035 100644
--- a/groupaccess.c
+++ b/groupaccess.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: groupaccess.c,v 1.3 2001/01/29 01:58:15 niklas Exp $ */ 1/* $OpenBSD: groupaccess.c,v 1.4 2001/06/26 17:27:23 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 Kevin Steves. All rights reserved. 4 * Copyright (c) 2001 Kevin Steves. All rights reserved.
@@ -34,6 +34,10 @@
34static int ngroups; 34static int ngroups;
35static char *groups_byname[NGROUPS_MAX + 1]; /* +1 for base/primary group */ 35static char *groups_byname[NGROUPS_MAX + 1]; /* +1 for base/primary group */
36 36
37/*
38 * Initialize group access list for user with primary (base) and
39 * supplementary groups. Return the number of groups in the list.
40 */
37int 41int
38ga_init(const char *user, gid_t base) 42ga_init(const char *user, gid_t base)
39{ 43{
@@ -53,6 +57,10 @@ ga_init(const char *user, gid_t base)
53 return (ngroups = j); 57 return (ngroups = j);
54} 58}
55 59
60/*
61 * Return 1 if one of user's groups is contained in groups.
62 * Return 0 otherwise. Use match_pattern() for string comparison.
63 */
56int 64int
57ga_match(char * const *groups, int n) 65ga_match(char * const *groups, int n)
58{ 66{
@@ -65,6 +73,9 @@ ga_match(char * const *groups, int n)
65 return 0; 73 return 0;
66} 74}
67 75
76/*
77 * Free memory allocated for group access list.
78 */
68void 79void
69ga_free(void) 80ga_free(void)
70{ 81{
diff --git a/groupaccess.h b/groupaccess.h
index 01e394f69..ede4805c2 100644
--- a/groupaccess.h
+++ b/groupaccess.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: groupaccess.h,v 1.3 2001/06/26 06:32:52 itojun Exp $ */ 1/* $OpenBSD: groupaccess.h,v 1.4 2001/06/26 17:27:23 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 Kevin Steves. All rights reserved. 4 * Copyright (c) 2001 Kevin Steves. All rights reserved.
@@ -29,21 +29,8 @@
29 29
30#include <grp.h> 30#include <grp.h>
31 31
32/* 32int ga_init(const char *, gid_t);
33 * Initialize group access list for user with primary (base) and 33int ga_match(char * const *, int);
34 * supplementary groups. Return the number of groups in the list. 34void ga_free(void);
35 */
36int ga_init(const char *, gid_t);
37
38/*
39 * Return 1 if one of user's groups is contained in groups.
40 * Return 0 otherwise. Use match_pattern() for string comparison.
41 */
42int ga_match(char * const *, int);
43
44/*
45 * Free memory allocated for group access list.
46 */
47void ga_free(void);
48 35
49#endif 36#endif
diff --git a/hostfile.h b/hostfile.h
index b83b77008..05ef69174 100644
--- a/hostfile.h
+++ b/hostfile.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: hostfile.h,v 1.8 2001/06/26 06:32:53 itojun Exp $ */ 1/* $OpenBSD: hostfile.h,v 1.9 2001/06/26 17:27:23 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -14,26 +14,13 @@
14#ifndef HOSTFILE_H 14#ifndef HOSTFILE_H
15#define HOSTFILE_H 15#define HOSTFILE_H
16 16
17int
18auth_rsa_read_key(char **, u_int *, BIGNUM *, BIGNUM *);
19
20/*
21 * Checks whether the given host is already in the list of our known hosts.
22 * Returns HOST_OK if the host is known and has the specified key, HOST_NEW
23 * if the host is not known, and HOST_CHANGED if the host is known but used
24 * to have a different host key. The host must be in all lowercase.
25 */
26typedef enum { 17typedef enum {
27 HOST_OK, HOST_NEW, HOST_CHANGED 18 HOST_OK, HOST_NEW, HOST_CHANGED
28} HostStatus; 19} HostStatus;
29 20
30HostStatus 21HostStatus
31check_host_in_hostfile(const char *, const char *, Key *, Key *, int *); 22check_host_in_hostfile(const char *, const char *, Key *, Key *, int *);
32 23int add_host_to_hostfile(const char *, const char *, Key *);
33/* 24int auth_rsa_read_key(char **, u_int *, BIGNUM *, BIGNUM *);
34 * Appends an entry to the host file. Returns false if the entry could not
35 * be appended.
36 */
37int add_host_to_hostfile(const char *, const char *, Key *);
38 25
39#endif 26#endif
diff --git a/kex.h b/kex.h
index 80ce31cef..fe339211a 100644
--- a/kex.h
+++ b/kex.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: kex.h,v 1.25 2001/06/26 06:32:53 itojun Exp $ */ 1/* $OpenBSD: kex.h,v 1.26 2001/06/26 17:27:23 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@@ -112,14 +112,14 @@ struct Kex {
112}; 112};
113 113
114Kex *kex_setup(char *[PROPOSAL_MAX]); 114Kex *kex_setup(char *[PROPOSAL_MAX]);
115void kex_finish(Kex *); 115void kex_finish(Kex *);
116 116
117void kex_send_kexinit(Kex *); 117void kex_send_kexinit(Kex *);
118void kex_input_kexinit(int, int, void *); 118void kex_input_kexinit(int, int, void *);
119void kex_derive_keys(Kex *, u_char *, BIGNUM *); 119void kex_derive_keys(Kex *, u_char *, BIGNUM *);
120 120
121void kexdh(Kex *); 121void kexdh(Kex *);
122void kexgex(Kex *); 122void kexgex(Kex *);
123 123
124Newkeys *kex_get_newkeys(int); 124Newkeys *kex_get_newkeys(int);
125 125
diff --git a/key.h b/key.h
index db2dd324c..562834c98 100644
--- a/key.h
+++ b/key.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: key.h,v 1.14 2001/06/26 06:32:54 itojun Exp $ */ 1/* $OpenBSD: key.h,v 1.15 2001/06/26 17:27:23 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@@ -52,25 +52,24 @@ struct Key {
52 52
53Key *key_new(int); 53Key *key_new(int);
54Key *key_new_private(int); 54Key *key_new_private(int);
55void key_free(Key *); 55void key_free(Key *);
56int key_equal(Key *, Key *); 56int key_equal(Key *, Key *);
57char *key_fingerprint(Key *, enum fp_type, enum fp_rep); 57char *key_fingerprint(Key *, enum fp_type, enum fp_rep);
58char *key_type(Key *); 58char *key_type(Key *);
59int key_write(Key *, FILE *); 59int key_write(Key *, FILE *);
60int key_read(Key *, char **); 60int key_read(Key *, char **);
61u_int key_size(Key *); 61u_int key_size(Key *);
62 62
63Key *key_generate(int, u_int); 63Key *key_generate(int, u_int);
64Key *key_from_private(Key *); 64Key *key_from_private(Key *);
65int key_type_from_name(char *); 65int key_type_from_name(char *);
66 66
67Key *key_from_blob(char *, int); 67Key *key_from_blob(char *, int);
68int key_to_blob(Key *, u_char **, u_int *); 68int key_to_blob(Key *, u_char **, u_int *);
69char *key_ssh_name(Key *); 69char *key_ssh_name(Key *);
70int key_names_valid2(const char *); 70int key_names_valid2(const char *);
71 71
72int key_sign(Key *, u_char **, int *, u_char *, int); 72int key_sign(Key *, u_char **, int *, u_char *, int);
73 73int key_verify(Key *, u_char *, int, u_char *, int);
74int key_verify(Key *, u_char *, int, u_char *, int);
75 74
76#endif 75#endif
diff --git a/log.c b/log.c
index f8f6c1c4a..39bc8b5d7 100644
--- a/log.c
+++ b/log.c
@@ -34,7 +34,7 @@
34 */ 34 */
35 35
36#include "includes.h" 36#include "includes.h"
37RCSID("$OpenBSD: log.c,v 1.17 2001/03/04 17:42:28 millert Exp $"); 37RCSID("$OpenBSD: log.c,v 1.18 2001/06/26 17:27:23 markus Exp $");
38 38
39#include "log.h" 39#include "log.h"
40#include "xmalloc.h" 40#include "xmalloc.h"
@@ -88,6 +88,8 @@ static struct {
88 { NULL, 0 } 88 { NULL, 0 }
89}; 89};
90 90
91static void do_log(LogLevel level, const char *fmt, va_list args);
92
91SyslogFacility 93SyslogFacility
92log_facility_number(char *name) 94log_facility_number(char *name)
93{ 95{
@@ -326,7 +328,7 @@ log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr)
326 328
327#define MSGBUFSIZ 1024 329#define MSGBUFSIZ 1024
328 330
329void 331static void
330do_log(LogLevel level, const char *fmt, va_list args) 332do_log(LogLevel level, const char *fmt, va_list args)
331{ 333{
332 char msgbuf[MSGBUFSIZ]; 334 char msgbuf[MSGBUFSIZ];
diff --git a/log.h b/log.h
index 95ec864f3..23451f74f 100644
--- a/log.h
+++ b/log.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: log.h,v 1.3 2001/06/26 06:32:55 itojun Exp $ */ 1/* $OpenBSD: log.h,v 1.4 2001/06/26 17:27:24 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -45,36 +45,22 @@ typedef enum {
45 SYSLOG_LEVEL_DEBUG2, 45 SYSLOG_LEVEL_DEBUG2,
46 SYSLOG_LEVEL_DEBUG3 46 SYSLOG_LEVEL_DEBUG3
47} LogLevel; 47} LogLevel;
48/* Initializes logging. */
49void log_init(char *, LogLevel, SyslogFacility, int);
50 48
51/* Logging implementation, depending on server or client */ 49void log_init(char *, LogLevel, SyslogFacility, int);
52void do_log(LogLevel, const char *, va_list);
53 50
54/* name to facility/level */ 51SyslogFacility log_facility_number(char *);
55SyslogFacility log_facility_number(char *);
56LogLevel log_level_number(char *); 52LogLevel log_level_number(char *);
57 53
58/* Output a message to syslog or stderr */ 54void fatal(const char *, ...) __attribute__((format(printf, 1, 2)));
59void fatal(const char *, ...) __attribute__((format(printf, 1, 2))); 55void error(const char *, ...) __attribute__((format(printf, 1, 2)));
60void error(const char *, ...) __attribute__((format(printf, 1, 2))); 56void log(const char *, ...) __attribute__((format(printf, 1, 2)));
61void log(const char *, ...) __attribute__((format(printf, 1, 2))); 57void verbose(const char *, ...) __attribute__((format(printf, 1, 2)));
62void verbose(const char *, ...) __attribute__((format(printf, 1, 2))); 58void debug(const char *, ...) __attribute__((format(printf, 1, 2)));
63void debug(const char *, ...) __attribute__((format(printf, 1, 2))); 59void debug2(const char *, ...) __attribute__((format(printf, 1, 2)));
64void debug2(const char *, ...) __attribute__((format(printf, 1, 2))); 60void debug3(const char *, ...) __attribute__((format(printf, 1, 2)));
65void debug3(const char *, ...) __attribute__((format(printf, 1, 2)));
66 61
67/* same as fatal() but w/o logging */ 62void fatal_cleanup(void);
68void fatal_cleanup(void); 63void fatal_add_cleanup(void (*) (void *), void *);
69 64void fatal_remove_cleanup(void (*) (void *), void *);
70/*
71 * Registers a cleanup function to be called by fatal()/fatal_cleanup()
72 * before exiting. It is permissible to call fatal_remove_cleanup for the
73 * function itself from the function.
74 */
75void fatal_add_cleanup(void (*) (void *), void *);
76
77/* Removes a cleanup function to be called at fatal(). */
78void fatal_remove_cleanup(void (*) (void *), void *);
79 65
80#endif 66#endif
diff --git a/mac.h b/mac.h
index 67df3b605..43b485dd9 100644
--- a/mac.h
+++ b/mac.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: mac.h,v 1.2 2001/06/26 06:32:55 itojun Exp $ */ 1/* $OpenBSD: mac.h,v 1.3 2001/06/26 17:27:24 markus Exp $ */
2/* 2/*
3 * Copyright (c) 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2001 Markus Friedl. All rights reserved.
4 * 4 *
@@ -23,6 +23,6 @@
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 25
26int mac_valid(const char *); 26int mac_valid(const char *);
27int mac_init(Mac *, char *); 27int mac_init(Mac *, char *);
28u_char *mac_compute(Mac *, u_int32_t, u_char *, int); 28u_char *mac_compute(Mac *, u_int32_t, u_char *, int);
diff --git a/misc.c b/misc.c
index db9c2e481..620121fdc 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.c,v 1.11 2001/06/16 08:58:34 markus Exp $ */ 1/* $OpenBSD: misc.c,v 1.12 2001/06/26 17:27:24 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -25,12 +25,13 @@
25 */ 25 */
26 26
27#include "includes.h" 27#include "includes.h"
28RCSID("$OpenBSD: misc.c,v 1.11 2001/06/16 08:58:34 markus Exp $"); 28RCSID("$OpenBSD: misc.c,v 1.12 2001/06/26 17:27:24 markus Exp $");
29 29
30#include "misc.h" 30#include "misc.h"
31#include "log.h" 31#include "log.h"
32#include "xmalloc.h" 32#include "xmalloc.h"
33 33
34/* remove newline at end of string */
34char * 35char *
35chop(char *s) 36chop(char *s)
36{ 37{
@@ -46,6 +47,7 @@ chop(char *s)
46 47
47} 48}
48 49
50/* set/unset filedescriptor to non-blocking */
49void 51void
50set_nonblock(int fd) 52set_nonblock(int fd)
51{ 53{
@@ -93,6 +95,7 @@ unset_nonblock(int fd)
93/* Characters considered whitespace in strsep calls. */ 95/* Characters considered whitespace in strsep calls. */
94#define WHITESPACE " \t\r\n" 96#define WHITESPACE " \t\r\n"
95 97
98/* return next token in configuration line */
96char * 99char *
97strdelim(char **s) 100strdelim(char **s)
98{ 101{
@@ -145,7 +148,13 @@ pwcopy(struct passwd *pw)
145 return copy; 148 return copy;
146} 149}
147 150
148int a2port(const char *s) 151/*
152 * Convert ASCII string to TCP/IP port number.
153 * Port must be >0 and <=65535.
154 * Return 0 if invalid.
155 */
156int
157a2port(const char *s)
149{ 158{
150 long port; 159 long port;
151 char *endp; 160 char *endp;
@@ -166,7 +175,29 @@ int a2port(const char *s)
166#define DAYS (HOURS * 24) 175#define DAYS (HOURS * 24)
167#define WEEKS (DAYS * 7) 176#define WEEKS (DAYS * 7)
168 177
169long convtime(const char *s) 178/*
179 * Convert a time string into seconds; format is
180 * a sequence of:
181 * time[qualifier]
182 *
183 * Valid time qualifiers are:
184 * <none> seconds
185 * s|S seconds
186 * m|M minutes
187 * h|H hours
188 * d|D days
189 * w|W weeks
190 *
191 * Examples:
192 * 90m 90 minutes
193 * 1h30m 90 minutes
194 * 2d 2 days
195 * 1w 1 week
196 *
197 * Return -1 if time string is invalid.
198 */
199long
200convtime(const char *s)
170{ 201{
171 long total, secs; 202 long total, secs;
172 const char *p; 203 const char *p;
@@ -253,6 +284,7 @@ colon(char *cp)
253 return (0); 284 return (0);
254} 285}
255 286
287/* function to assist building execv() arguments */
256void 288void
257addargs(arglist *args, char *fmt, ...) 289addargs(arglist *args, char *fmt, ...)
258{ 290{
diff --git a/misc.h b/misc.h
index 829208d29..5f0b0aa4f 100644
--- a/misc.h
+++ b/misc.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.h,v 1.9 2001/06/26 06:32:56 itojun Exp $ */ 1/* $OpenBSD: misc.h,v 1.10 2001/06/26 17:27:24 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -11,54 +11,16 @@
11 * incompatible with the protocol description in the RFC file, it must be 11 * incompatible with the protocol description in the RFC file, it must be
12 * called by a name other than "ssh" or "Secure Shell". 12 * called by a name other than "ssh" or "Secure Shell".
13 */ 13 */
14/* remove newline at end of string */
15char *chop(char *);
16 14
17/* return next token in configuration line */ 15char *chop(char *);
18char *strdelim(char **); 16char *strdelim(char **);
17void set_nonblock(int);
18void unset_nonblock(int);
19int a2port(const char *);
20char *cleanhostname(char *);
21char *colon(char *);
22long convtime(const char *);
19 23
20/* set/unset filedescriptor to non-blocking */
21void set_nonblock(int);
22void unset_nonblock(int);
23
24struct passwd * pwcopy(struct passwd *);
25
26/*
27 * Convert ASCII string to TCP/IP port number.
28 * Port must be >0 and <=65535.
29 * Return 0 if invalid.
30 */
31int a2port(const char *);
32
33/* code from scp.c/rcp.c */
34char *cleanhostname(char *);
35char *colon(char *);
36
37/*
38 * Convert a time string into seconds; format is
39 * a sequence of:
40 * time[qualifier]
41 *
42 * Valid time qualifiers are:
43 * <none> seconds
44 * s|S seconds
45 * m|M minutes
46 * h|H hours
47 * d|D days
48 * w|W weeks
49 *
50 * Examples:
51 * 90m 90 minutes
52 * 1h30m 90 minutes
53 * 2d 2 days
54 * 1w 1 week
55 *
56 * Return -1 if time string is invalid.
57 */
58
59long convtime(const char *);
60
61/* function to assist building execv() arguments */
62typedef struct arglist arglist; 24typedef struct arglist arglist;
63struct arglist { 25struct arglist {
64 char **list; 26 char **list;
@@ -66,7 +28,7 @@ struct arglist {
66 int nalloc; 28 int nalloc;
67}; 29};
68 30
69void addargs(arglist *, char *, ...) __attribute__((format(printf, 2, 3))); 31void addargs(arglist *, char *, ...) __attribute__((format(printf, 2, 3)));
70 32
71/* wrapper for signal interface */ 33/* wrapper for signal interface */
72typedef void (*mysig_t)(int); 34typedef void (*mysig_t)(int);
diff --git a/mpaux.h b/mpaux.h
index a4d324fca..082b7fd47 100644
--- a/mpaux.h
+++ b/mpaux.h
@@ -12,17 +12,11 @@
12 * called by a name other than "ssh" or "Secure Shell". 12 * called by a name other than "ssh" or "Secure Shell".
13 */ 13 */
14 14
15/* RCSID("$OpenBSD: mpaux.h,v 1.10 2001/06/26 06:32:57 itojun Exp $"); */ 15/* RCSID("$OpenBSD: mpaux.h,v 1.11 2001/06/26 17:27:24 markus Exp $"); */
16 16
17#ifndef MPAUX_H 17#ifndef MPAUX_H
18#define MPAUX_H 18#define MPAUX_H
19 19
20/* 20void compute_session_id(u_char[16], u_char[8], BIGNUM *, BIGNUM *);
21 * Computes a 16-byte session id in the global variable session_id. The
22 * session id is computed by concatenating the linearized, msb first
23 * representations of host_key_n, session_key_n, and the cookie.
24 */
25void
26compute_session_id(u_char[16], u_char[8], BIGNUM *, BIGNUM *);
27 21
28#endif /* MPAUX_H */ 22#endif /* MPAUX_H */
diff --git a/packet.h b/packet.h
index 97afbdf60..ffae736d6 100644
--- a/packet.h
+++ b/packet.h
@@ -11,186 +11,75 @@
11 * called by a name other than "ssh" or "Secure Shell". 11 * called by a name other than "ssh" or "Secure Shell".
12 */ 12 */
13 13
14/* RCSID("$OpenBSD: packet.h,v 1.24 2001/06/26 06:32:57 itojun Exp $"); */ 14/* RCSID("$OpenBSD: packet.h,v 1.25 2001/06/26 17:27:24 markus Exp $"); */
15 15
16#ifndef PACKET_H 16#ifndef PACKET_H
17#define PACKET_H 17#define PACKET_H
18 18
19#include <openssl/bn.h> 19#include <openssl/bn.h>
20 20
21/* 21void packet_set_connection(int, int);
22 * Sets the socket used for communication. Disables encryption until 22void packet_set_nonblocking(void);
23 * packet_set_encryption_key is called. It is permissible that fd_in and 23int packet_get_connection_in(void);
24 * fd_out are the same descriptor; in that case it is assumed to be a socket. 24int packet_get_connection_out(void);
25 */ 25void packet_close(void);
26void packet_set_connection(int, int); 26void packet_set_encryption_key(const u_char *, u_int, int);
27 27void packet_set_protocol_flags(u_int);
28/* Puts the connection file descriptors into non-blocking mode. */ 28u_int packet_get_protocol_flags(void);
29void packet_set_nonblocking(void); 29void packet_start_compression(int);
30 30void packet_set_interactive(int);
31/* Returns the file descriptor used for input. */ 31int packet_is_interactive(void);
32int packet_get_connection_in(void); 32
33 33void packet_start(u_char);
34/* Returns the file descriptor used for output. */ 34void packet_put_char(int ch);
35int packet_get_connection_out(void); 35void packet_put_int(u_int value);
36 36void packet_put_bignum(BIGNUM * value);
37/* 37void packet_put_bignum2(BIGNUM * value);
38 * Closes the connection (both descriptors) and clears and frees internal 38void packet_put_string(const char *buf, u_int len);
39 * data structures. 39void packet_put_cstring(const char *str);
40 */ 40void packet_put_raw(const char *buf, u_int len);
41void packet_close(void); 41void packet_send(void);
42 42
43/* 43int packet_read(int *payload_len_ptr);
44 * Causes any further packets to be encrypted using the given key. The same 44void packet_read_expect(int *payload_len_ptr, int type);
45 * key is used for both sending and reception. However, both directions are 45int packet_read_poll(int *packet_len_ptr);
46 * encrypted independently of each other. Cipher types are defined in ssh.h. 46void packet_process_incoming(const char *buf, u_int len);
47 */ 47
48void 48u_int packet_get_char(void);
49packet_set_encryption_key(const u_char *, u_int, int); 49u_int packet_get_int(void);
50 50void packet_get_bignum(BIGNUM * value, int *length_ptr);
51/* 51void packet_get_bignum2(BIGNUM * value, int *length_ptr);
52 * Sets remote side protocol flags for the current connection. This can be
53 * called at any time.
54 */
55void packet_set_protocol_flags(u_int);
56
57/* Returns the remote protocol flags set earlier by the above function. */
58u_int packet_get_protocol_flags(void);
59
60/* Enables compression in both directions starting from the next packet. */
61void packet_start_compression(int);
62
63/*
64 * Informs that the current session is interactive. Sets IP flags for
65 * optimal performance in interactive use.
66 */
67void packet_set_interactive(int);
68
69/* Returns true if the current connection is interactive. */
70int packet_is_interactive(void);
71
72/* Starts constructing a packet to send. */
73void packet_start(u_char);
74
75/* Appends a character to the packet data. */
76void packet_put_char(int ch);
77
78/* Appends an integer to the packet data. */
79void packet_put_int(u_int value);
80
81/* Appends an arbitrary precision integer to packet data. */
82void packet_put_bignum(BIGNUM * value);
83void packet_put_bignum2(BIGNUM * value);
84
85/* Appends a string to packet data. */
86void packet_put_string(const char *buf, u_int len);
87void packet_put_cstring(const char *str);
88void packet_put_raw(const char *buf, u_int len);
89
90/*
91 * Finalizes and sends the packet. If the encryption key has been set,
92 * encrypts the packet before sending.
93 */
94void packet_send(void);
95
96/* Waits until a packet has been received, and returns its type. */
97int packet_read(int *payload_len_ptr);
98
99/*
100 * Waits until a packet has been received, verifies that its type matches
101 * that given, and gives a fatal error and exits if there is a mismatch.
102 */
103void packet_read_expect(int *payload_len_ptr, int type);
104
105/*
106 * Checks if a full packet is available in the data received so far via
107 * packet_process_incoming. If so, reads the packet; otherwise returns
108 * SSH_MSG_NONE. This does not wait for data from the connection.
109 * SSH_MSG_DISCONNECT is handled specially here. Also, SSH_MSG_IGNORE
110 * messages are skipped by this function and are never returned to higher
111 * levels.
112 */
113int packet_read_poll(int *packet_len_ptr);
114
115/*
116 * Buffers the given amount of input characters. This is intended to be used
117 * together with packet_read_poll.
118 */
119void packet_process_incoming(const char *buf, u_int len);
120
121/* Returns a character (0-255) from the packet data. */
122u_int packet_get_char(void);
123
124/* Returns an integer from the packet data. */
125u_int packet_get_int(void);
126
127/*
128 * Returns an arbitrary precision integer from the packet data. The integer
129 * must have been initialized before this call.
130 */
131void packet_get_bignum(BIGNUM * value, int *length_ptr);
132void packet_get_bignum2(BIGNUM * value, int *length_ptr);
133char *packet_get_raw(int *length_ptr); 52char *packet_get_raw(int *length_ptr);
53char *packet_get_string(u_int *length_ptr);
54void packet_disconnect(const char *fmt,...) __attribute__((format(printf, 1, 2)));
55void packet_send_debug(const char *fmt,...) __attribute__((format(printf, 1, 2)));
134 56
135/* 57void packet_write_poll(void);
136 * Returns a string from the packet data. The string is allocated using 58void packet_write_wait(void);
137 * xmalloc; it is the responsibility of the calling program to free it when 59int packet_have_data_to_write(void);
138 * no longer needed. The length_ptr argument may be NULL, or point to an 60int packet_not_very_much_data_to_write(void);
139 * integer into which the length of the string is stored.
140 */
141char *packet_get_string(u_int *length_ptr);
142
143/*
144 * Logs the error in syslog using LOG_INFO, constructs and sends a disconnect
145 * packet, closes the connection, and exits. This function never returns.
146 * The error message should not contain a newline. The total length of the
147 * message must not exceed 1024 bytes.
148 */
149void packet_disconnect(const char *fmt,...) __attribute__((format(printf, 1, 2)));
150
151/*
152 * Sends a diagnostic message to the other side. This message can be sent at
153 * any time (but not while constructing another message). The message is
154 * printed immediately, but only if the client is being executed in verbose
155 * mode. These messages are primarily intended to ease debugging
156 * authentication problems. The total length of the message must not exceed
157 * 1024 bytes. This will automatically call packet_write_wait. If the
158 * remote side protocol flags do not indicate that it supports SSH_MSG_DEBUG,
159 * this will do nothing.
160 */
161void packet_send_debug(const char *fmt,...) __attribute__((format(printf, 1, 2)));
162
163/* Checks if there is any buffered output, and tries to write some of the output. */
164void packet_write_poll(void);
165
166/* Waits until all pending output data has been written. */
167void packet_write_wait(void);
168 61
169/* Returns true if there is buffered data to write to the connection. */ 62int packet_connection_is_on_socket(void);
170int packet_have_data_to_write(void); 63int packet_connection_is_ipv4(void);
64int packet_remaining(void);
65void packet_send_ignore(int);
66void packet_inject_ignore(int);
171 67
172/* Returns true if there is not too much data to write to the connection. */ 68void tty_make_modes(int, struct termios *);
173int packet_not_very_much_data_to_write(void); 69void tty_parse_modes(int, int *);
174 70
175/* maximum packet size, requested by client with SSH_CMSG_MAX_PACKET_SIZE */
176extern int max_packet_size; 71extern int max_packet_size;
177int packet_set_maxsize(int); 72int packet_set_maxsize(int);
178#define packet_get_maxsize() max_packet_size 73#define packet_get_maxsize() max_packet_size
179
180/* Stores tty modes from the fd or tiop into current packet. */
181void tty_make_modes(int, struct termios *);
182
183/* Parses tty modes for the fd from the current packet. */
184void tty_parse_modes(int, int *);
185 74
186#define packet_integrity_check(payload_len, expected_len, type) \ 75#define packet_integrity_check(payload_len, expected_len, type) \
187do { \ 76do { \
188 int _p = (payload_len), _e = (expected_len); \ 77 int _p = (payload_len), _e = (expected_len); \
189 if (_p != _e) { \ 78 if (_p != _e) { \
190 log("Packet integrity error (%d != %d) at %s:%d", \ 79 log("Packet integrity error (%d != %d) at %s:%d", \
191 _p, _e, __FILE__, __LINE__); \ 80 _p, _e, __FILE__, __LINE__); \
192 packet_disconnect("Packet integrity error. (%d)", (type)); \ 81 packet_disconnect("Packet integrity error. (%d)", (type)); \
193 } \ 82 } \
194} while (0) 83} while (0)
195 84
196#define packet_done() \ 85#define packet_done() \
@@ -203,17 +92,4 @@ do { \
203 } \ 92 } \
204} while (0) 93} while (0)
205 94
206/* remote host is connected via a socket/ipv4 */
207int packet_connection_is_on_socket(void);
208int packet_connection_is_ipv4(void);
209
210/* returns remaining payload bytes */
211int packet_remaining(void);
212
213/* append an ignore message */
214void packet_send_ignore(int);
215
216/* add an ignore message and make sure size (current+ignore) = n*sumlen */
217void packet_inject_ignore(int);
218
219#endif /* PACKET_H */ 95#endif /* PACKET_H */
diff --git a/radix.h b/radix.h
index 6f3428cd3..e94e4acc6 100644
--- a/radix.h
+++ b/radix.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: radix.h,v 1.3 2001/06/26 06:32:57 itojun Exp $ */ 1/* $OpenBSD: radix.h,v 1.4 2001/06/26 17:27:24 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999 Dug Song. All rights reserved. 4 * Copyright (c) 1999 Dug Song. All rights reserved.
@@ -24,5 +24,5 @@
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27int creds_to_radix(CREDENTIALS *, u_char *, size_t); 27int creds_to_radix(CREDENTIALS *, u_char *, size_t);
28int radix_to_creds(const char *, CREDENTIALS *); 28int radix_to_creds(const char *, CREDENTIALS *);
diff --git a/readconf.h b/readconf.h
index 2f784e6e2..f91dc3899 100644
--- a/readconf.h
+++ b/readconf.h
@@ -11,7 +11,7 @@
11 * called by a name other than "ssh" or "Secure Shell". 11 * called by a name other than "ssh" or "Secure Shell".
12 */ 12 */
13 13
14/* RCSID("$OpenBSD: readconf.h,v 1.34 2001/06/26 16:15:24 dugsong Exp $"); */ 14/* RCSID("$OpenBSD: readconf.h,v 1.35 2001/06/26 17:27:24 markus Exp $"); */
15 15
16#ifndef READCONF_H 16#ifndef READCONF_H
17#define READCONF_H 17#define READCONF_H
@@ -102,48 +102,14 @@ typedef struct {
102} Options; 102} Options;
103 103
104 104
105/* 105void initialize_options(Options *);
106 * Initializes options to special values that indicate that they have not yet 106void fill_default_options(Options *);
107 * been set. Read_config_file will only set options with this value. Options 107void read_config_file(const char *, const char *, Options *);
108 * are processed in the following order: command line, user config file,
109 * system config file. Last, fill_default_options is called.
110 */
111void initialize_options(Options *);
112
113/*
114 * Called after processing other sources of option data, this fills those
115 * options for which no value has been specified with their default values.
116 */
117void fill_default_options(Options *);
118 108
119/*
120 * Processes a single option line as used in the configuration files. This
121 * only sets those values that have not already been set. Returns 0 for legal
122 * options
123 */
124int 109int
125process_config_line(Options *, const char *, char *, const char *, int, int *); 110process_config_line(Options *, const char *, char *, const char *, int, int *);
126 111
127/* 112void add_local_forward(Options *, u_short, const char *, u_short);
128 * Reads the config file and modifies the options accordingly. Options 113void add_remote_forward(Options *, u_short, const char *, u_short);
129 * should already be initialized before this call. This never returns if
130 * there is an error. If the file does not exist, this returns immediately.
131 */
132void
133read_config_file(const char *, const char *, Options *);
134
135/*
136 * Adds a local TCP/IP port forward to options. Never returns if there is an
137 * error.
138 */
139void
140add_local_forward(Options *, u_short, const char *, u_short);
141
142/*
143 * Adds a remote TCP/IP port forward to options. Never returns if there is
144 * an error.
145 */
146void
147add_remote_forward(Options *, u_short, const char *, u_short);
148 114
149#endif /* READCONF_H */ 115#endif /* READCONF_H */
diff --git a/readpass.h b/readpass.h
index da362ab41..229973c68 100644
--- a/readpass.h
+++ b/readpass.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: readpass.h,v 1.5 2001/06/26 06:32:58 itojun Exp $ */ 1/* $OpenBSD: readpass.h,v 1.6 2001/06/26 17:27:24 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -14,4 +14,5 @@
14 14
15#define RP_ECHO 0x0001 15#define RP_ECHO 0x0001
16#define RP_ALLOW_STDIN 0x0002 16#define RP_ALLOW_STDIN 0x0002
17
17char *read_passphrase(const char *, int); 18char *read_passphrase(const char *, int);
diff --git a/rsa.h b/rsa.h
index b803b3ad3..70756f83c 100644
--- a/rsa.h
+++ b/rsa.h
@@ -11,7 +11,7 @@
11 * called by a name other than "ssh" or "Secure Shell". 11 * called by a name other than "ssh" or "Secure Shell".
12 */ 12 */
13 13
14/* RCSID("$OpenBSD: rsa.h,v 1.12 2001/06/26 06:32:58 itojun Exp $"); */ 14/* RCSID("$OpenBSD: rsa.h,v 1.13 2001/06/26 17:27:24 markus Exp $"); */
15 15
16#ifndef RSA_H 16#ifndef RSA_H
17#define RSA_H 17#define RSA_H
@@ -19,9 +19,8 @@
19#include <openssl/bn.h> 19#include <openssl/bn.h>
20#include <openssl/rsa.h> 20#include <openssl/rsa.h>
21 21
22void rsa_public_encrypt __P((BIGNUM *, BIGNUM *, RSA *)); 22void rsa_public_encrypt(BIGNUM *, BIGNUM *, RSA *);
23int rsa_private_decrypt __P((BIGNUM *, BIGNUM *, RSA *)); 23int rsa_private_decrypt(BIGNUM *, BIGNUM *, RSA *);
24 24void generate_additional_parameters(RSA *);
25void generate_additional_parameters __P((RSA *));
26 25
27#endif /* RSA_H */ 26#endif /* RSA_H */
diff --git a/servconf.h b/servconf.h
index 1b0220283..3552bb11a 100644
--- a/servconf.h
+++ b/servconf.h
@@ -11,7 +11,7 @@
11 * called by a name other than "ssh" or "Secure Shell". 11 * called by a name other than "ssh" or "Secure Shell".
12 */ 12 */
13 13
14/* RCSID("$OpenBSD: servconf.h,v 1.46 2001/06/26 16:15:24 dugsong Exp $"); */ 14/* RCSID("$OpenBSD: servconf.h,v 1.47 2001/06/26 17:27:24 markus Exp $"); */
15 15
16#ifndef SERVCONF_H 16#ifndef SERVCONF_H
17#define SERVCONF_H 17#define SERVCONF_H
@@ -130,19 +130,9 @@ typedef struct {
130 char *authorized_keys_file2; /* File containing public SSH2 keys */ 130 char *authorized_keys_file2; /* File containing public SSH2 keys */
131 int pam_authentication_via_kbd_int; 131 int pam_authentication_via_kbd_int;
132} ServerOptions; 132} ServerOptions;
133/*
134 * Initializes the server options to special values that indicate that they
135 * have not yet been set.
136 */
137void initialize_server_options(ServerOptions *);
138
139/*
140 * Reads the server configuration file. This only sets the values for those
141 * options that have the special value indicating they have not been set.
142 */
143void read_server_config(ServerOptions *, const char *);
144 133
145/* Sets values for those values that have not yet been set. */ 134void initialize_server_options(ServerOptions *);
146void fill_default_server_options(ServerOptions *); 135void read_server_config(ServerOptions *, const char *);
136void fill_default_server_options(ServerOptions *);
147 137
148#endif /* SERVCONF_H */ 138#endif /* SERVCONF_H */
diff --git a/serverloop.h b/serverloop.h
index 9c2c2ccb9..9ea2b38d4 100644
--- a/serverloop.h
+++ b/serverloop.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: serverloop.h,v 1.3 2001/06/26 06:33:00 itojun Exp $ */ 1/* $OpenBSD: serverloop.h,v 1.4 2001/06/26 17:27:24 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -18,5 +18,10 @@
18 * (of the child program), and reads from stdout and stderr (of the child 18 * (of the child program), and reads from stdout and stderr (of the child
19 * program). 19 * program).
20 */ 20 */
21#ifndef SERVERLOOP_H
22#define SERVERLOOP_H
23
21void server_loop(pid_t, int, int, int); 24void server_loop(pid_t, int, int, int);
22void server_loop2(void); 25void server_loop2(void);
26
27#endif
diff --git a/session.h b/session.h
index 9ed83585c..39ab7d0e6 100644
--- a/session.h
+++ b/session.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: session.h,v 1.8 2001/06/26 06:33:01 itojun Exp $ */ 1/* $OpenBSD: session.h,v 1.9 2001/06/26 17:27:24 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@@ -26,11 +26,11 @@
26#ifndef SESSION_H 26#ifndef SESSION_H
27#define SESSION_H 27#define SESSION_H
28 28
29void do_authenticated(Authctxt *); 29void do_authenticated(Authctxt *);
30 30
31int session_open(int); 31int session_open(int);
32void session_input_channel_req(int, void *); 32void session_input_channel_req(int, void *);
33void session_close_by_pid(pid_t, int); 33void session_close_by_pid(pid_t, int);
34void session_close_by_channel(int, void *); 34void session_close_by_channel(int, void *);
35 35
36#endif 36#endif
diff --git a/sftp-common.c b/sftp-common.c
index 3310eabab..aed95f2f0 100644
--- a/sftp-common.c
+++ b/sftp-common.c
@@ -24,7 +24,7 @@
24 */ 24 */
25 25
26#include "includes.h" 26#include "includes.h"
27RCSID("$OpenBSD: sftp-common.c,v 1.2 2001/02/06 23:50:10 markus Exp $"); 27RCSID("$OpenBSD: sftp-common.c,v 1.3 2001/06/26 17:27:24 markus Exp $");
28 28
29#include "buffer.h" 29#include "buffer.h"
30#include "bufaux.h" 30#include "bufaux.h"
@@ -35,6 +35,7 @@ RCSID("$OpenBSD: sftp-common.c,v 1.2 2001/02/06 23:50:10 markus Exp $");
35#include "sftp.h" 35#include "sftp.h"
36#include "sftp-common.h" 36#include "sftp-common.h"
37 37
38/* Clear contents of attributes structure */
38void 39void
39attrib_clear(Attrib *a) 40attrib_clear(Attrib *a)
40{ 41{
@@ -47,6 +48,7 @@ attrib_clear(Attrib *a)
47 a->mtime = 0; 48 a->mtime = 0;
48} 49}
49 50
51/* Convert from struct stat to filexfer attribs */
50void 52void
51stat_to_attrib(struct stat *st, Attrib *a) 53stat_to_attrib(struct stat *st, Attrib *a)
52{ 54{
@@ -64,6 +66,7 @@ stat_to_attrib(struct stat *st, Attrib *a)
64 a->mtime = st->st_mtime; 66 a->mtime = st->st_mtime;
65} 67}
66 68
69/* Decode attributes in buffer */
67Attrib * 70Attrib *
68decode_attrib(Buffer *b) 71decode_attrib(Buffer *b)
69{ 72{
@@ -98,6 +101,7 @@ decode_attrib(Buffer *b)
98 return &a; 101 return &a;
99} 102}
100 103
104/* Encode attributes to buffer */
101void 105void
102encode_attrib(Buffer *b, Attrib *a) 106encode_attrib(Buffer *b, Attrib *a)
103{ 107{
@@ -116,6 +120,7 @@ encode_attrib(Buffer *b, Attrib *a)
116 } 120 }
117} 121}
118 122
123/* Convert from SSH2_FX_ status to text error message */
119const char * 124const char *
120fx2txt(int status) 125fx2txt(int status)
121{ 126{
@@ -143,4 +148,3 @@ fx2txt(int status)
143 }; 148 };
144 /* NOTREACHED */ 149 /* NOTREACHED */
145} 150}
146
diff --git a/sftp-common.h b/sftp-common.h
index 3e4f502b0..4c126bf10 100644
--- a/sftp-common.h
+++ b/sftp-common.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-common.h,v 1.2 2001/06/26 06:33:01 itojun Exp $ */ 1/* $OpenBSD: sftp-common.h,v 1.3 2001/06/26 17:27:24 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2001 Markus Friedl. All rights reserved.
@@ -38,18 +38,9 @@ struct Attrib {
38 u_int32_t mtime; 38 u_int32_t mtime;
39}; 39};
40 40
41/* Clear contents of attributes structure */ 41void attrib_clear(Attrib *);
42void attrib_clear(Attrib *); 42void stat_to_attrib(struct stat *, Attrib *);
43Attrib *decode_attrib(Buffer *);
44void encode_attrib(Buffer *, Attrib *);
43 45
44/* Convert from struct stat to filexfer attribs */
45void stat_to_attrib(struct stat *, Attrib *);
46
47/* Decode attributes in buffer */
48Attrib *decode_attrib(Buffer *);
49
50/* Encode attributes to buffer */
51void encode_attrib(Buffer *, Attrib *);
52
53/* Convert from SSH2_FX_ status to text error message */
54const char *fx2txt(int); 46const char *fx2txt(int);
55
diff --git a/sftp-glob.h b/sftp-glob.h
index 37bd5d2da..2885044ae 100644
--- a/sftp-glob.h
+++ b/sftp-glob.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-glob.h,v 1.4 2001/06/26 06:33:01 itojun Exp $ */ 1/* $OpenBSD: sftp-glob.h,v 1.5 2001/06/26 17:27:24 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 Damien Miller. All rights reserved. 4 * Copyright (c) 2001 Damien Miller. All rights reserved.
@@ -28,4 +28,3 @@
28 28
29int 29int
30remote_glob(int, int, const char *, int, int (*)(const char *, int), glob_t *); 30remote_glob(int, int, const char *, int, int (*)(const char *, int), glob_t *);
31
diff --git a/sftp-int.h b/sftp-int.h
index bbb138a6b..699e758b1 100644
--- a/sftp-int.h
+++ b/sftp-int.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: sftp-int.h,v 1.3 2001/06/26 06:33:02 itojun Exp $ */ 1/* $OpenBSD: sftp-int.h,v 1.4 2001/06/26 17:27:25 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 Damien Miller. All rights reserved. 4 * Copyright (c) 2001 Damien Miller. All rights reserved.
@@ -24,4 +24,4 @@
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27void interactive_loop(int, int, char *, char *); 27void interactive_loop(int, int, char *, char *);
diff --git a/ssh-dss.h b/ssh-dss.h
index fe7e3207c..0613acba3 100644
--- a/ssh-dss.h
+++ b/ssh-dss.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-dss.h,v 1.4 2001/06/26 06:33:02 itojun Exp $ */ 1/* $OpenBSD: ssh-dss.h,v 1.5 2001/06/26 17:27:25 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -26,8 +26,7 @@
26#ifndef DSA_H 26#ifndef DSA_H
27#define DSA_H 27#define DSA_H
28 28
29int ssh_dss_sign(Key *, u_char **, int *, u_char *, int); 29int ssh_dss_sign(Key *, u_char **, int *, u_char *, int);
30 30int ssh_dss_verify(Key *, u_char *, int, u_char *, int);
31int ssh_dss_verify(Key *, u_char *, int, u_char *, int);
32 31
33#endif 32#endif
diff --git a/ssh-rsa.h b/ssh-rsa.h
index 1e94c8b3c..11d355d58 100644
--- a/ssh-rsa.h
+++ b/ssh-rsa.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-rsa.h,v 1.4 2001/06/26 06:33:03 itojun Exp $ */ 1/* $OpenBSD: ssh-rsa.h,v 1.5 2001/06/26 17:27:25 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -26,8 +26,7 @@
26#ifndef SSH_RSA_H 26#ifndef SSH_RSA_H
27#define SSH_RSA_H 27#define SSH_RSA_H
28 28
29int ssh_rsa_sign(Key *, u_char **, int *, u_char *, int); 29int ssh_rsa_sign(Key *, u_char **, int *, u_char *, int);
30 30int ssh_rsa_verify(Key *, u_char *, int, u_char *, int);
31int ssh_rsa_verify(Key *, u_char *, int, u_char *, int);
32 31
33#endif 32#endif
diff --git a/sshconnect.h b/sshconnect.h
index c15ed4bc4..27ed2b745 100644
--- a/sshconnect.h
+++ b/sshconnect.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshconnect.h,v 1.11 2001/06/26 06:33:03 itojun Exp $ */ 1/* $OpenBSD: sshconnect.h,v 1.12 2001/06/26 17:27:25 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -33,14 +33,14 @@ ssh_connect(const char *, struct sockaddr_storage *, u_short, int,
33void 33void
34ssh_login(Key **, int, const char *, struct sockaddr *, struct passwd *); 34ssh_login(Key **, int, const char *, struct sockaddr *, struct passwd *);
35 35
36int verify_host_key(char *, struct sockaddr *, Key *); 36int verify_host_key(char *, struct sockaddr *, Key *);
37 37
38void ssh_kex(char *, struct sockaddr *); 38void ssh_kex(char *, struct sockaddr *);
39void ssh_kex2(char *, struct sockaddr *); 39void ssh_kex2(char *, struct sockaddr *);
40 40
41void ssh_userauth1(const char *, const char *, char *, Key **, int); 41void ssh_userauth1(const char *, const char *, char *, Key **, int);
42void ssh_userauth2(const char *, const char *, char *, Key **, int); 42void ssh_userauth2(const char *, const char *, char *, Key **, int);
43 43
44void ssh_put_password(char *); 44void ssh_put_password(char *);
45 45
46#endif 46#endif
diff --git a/sshlogin.h b/sshlogin.h
index 05840c291..79d42a982 100644
--- a/sshlogin.h
+++ b/sshlogin.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshlogin.h,v 1.2 2001/06/26 06:33:04 itojun Exp $ */ 1/* $OpenBSD: sshlogin.h,v 1.3 2001/06/26 17:27:25 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -14,35 +14,10 @@
14#ifndef SSHLOGIN_H 14#ifndef SSHLOGIN_H
15#define SSHLOGIN_H 15#define SSHLOGIN_H
16 16
17/*
18 * Returns the time when the user last logged in. Returns 0 if the
19 * information is not available. This must be called before record_login.
20 * The host from which the user logged in is stored in buf.
21 */
22u_long
23get_last_login_time(uid_t, const char *, char *, u_int);
24
25/*
26 * Records that the user has logged in. This does many things normally done
27 * by login(1).
28 */
29void 17void
30record_login(pid_t, const char *, const char *, uid_t, const char *, 18record_login(pid_t, const char *, const char *, uid_t,
31 struct sockaddr *); 19 const char *, struct sockaddr *);
32 20void record_logout(pid_t, const char *);
33#ifdef LOGIN_NEEDS_UTMPX 21u_long get_last_login_time(uid_t, const char *, char *, u_int);
34/*
35 * Record just the utmp info for /bin/login.
36 */
37void
38record_utmp_only(pid_t, const char *, const char *, const char *,
39 struct sockaddr *);
40#endif
41
42/*
43 * Records that the user has logged out. This does many thigs normally done
44 * by login(1) or init.
45 */
46void record_logout(pid_t, const char *);
47 22
48#endif 23#endif
diff --git a/sshpty.h b/sshpty.h
index d962924f8..4eb479f76 100644
--- a/sshpty.h
+++ b/sshpty.h
@@ -12,34 +12,15 @@
12 * called by a name other than "ssh" or "Secure Shell". 12 * called by a name other than "ssh" or "Secure Shell".
13 */ 13 */
14 14
15/* RCSID("$OpenBSD: sshpty.h,v 1.2 2001/06/26 06:33:04 itojun Exp $"); */ 15/* RCSID("$OpenBSD: sshpty.h,v 1.3 2001/06/26 17:27:25 markus Exp $"); */
16 16
17#ifndef SSHPTY_H 17#ifndef SSHPTY_H
18#define SSHPTY_H 18#define SSHPTY_H
19 19
20/* 20int pty_allocate(int *, int *, char *, int);
21 * Allocates and opens a pty. Returns 0 if no pty could be allocated, or 21void pty_release(const char *);
22 * nonzero if a pty was successfully allocated. On success, open file 22void pty_make_controlling_tty(int *, const char *);
23 * descriptors for the pty and tty sides and the name of the tty side are 23void pty_change_window_size(int, int, int, int, int);
24 * returned (the buffer must be able to hold at least 64 characters). 24void pty_setowner(struct passwd *, const char *);
25 */
26int pty_allocate(int *, int *, char *, int);
27
28/*
29 * Releases the tty. Its ownership is returned to root, and permissions to
30 * 0666.
31 */
32void pty_release(const char *);
33
34/*
35 * Makes the tty the processes controlling tty and sets it to sane modes.
36 * This may need to reopen the tty to get rid of possible eavesdroppers.
37 */
38void pty_make_controlling_tty(int *, const char *);
39
40/* Changes the window size associated with the pty. */
41void pty_change_window_size(int, int, int, int, int);
42
43void pty_setowner(struct passwd *, const char *);
44 25
45#endif /* SSHPTY_H */ 26#endif /* SSHPTY_H */
diff --git a/sshtty.h b/sshtty.h
index e29385e35..7ba4a2627 100644
--- a/sshtty.h
+++ b/sshtty.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshtty.h,v 1.1 2001/04/14 16:33:20 stevesk Exp $ */ 1/* $OpenBSD: sshtty.h,v 1.2 2001/06/26 17:27:25 markus Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -40,26 +40,9 @@
40 40
41#include <termios.h> 41#include <termios.h>
42 42
43/* 43int in_raw_mode(void);
44 * Accessor function indicating whether we are in raw mode. Set by
45 * enter_raw_mode() and leave_raw_mode().
46 */
47int in_raw_mode(void);
48
49/*
50 * Return terminal modes, as saved by enter_raw_mode().
51 */
52struct termios get_saved_tio(void); 44struct termios get_saved_tio(void);
53 45void leave_raw_mode(void);
54/* 46void enter_raw_mode(void);
55 * Returns the user's terminal to normal mode if it had been
56 * put in raw mode.
57 */
58void leave_raw_mode(void);
59
60/*
61 * Puts the user's terminal in raw mode.
62 */
63void enter_raw_mode(void);
64 47
65#endif 48#endif
diff --git a/tildexpand.h b/tildexpand.h
index a30f0db30..f5e7e40bc 100644
--- a/tildexpand.h
+++ b/tildexpand.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: tildexpand.h,v 1.3 2001/06/26 06:33:06 itojun Exp $ */ 1/* $OpenBSD: tildexpand.h,v 1.4 2001/06/26 17:27:25 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -12,8 +12,4 @@
12 * called by a name other than "ssh" or "Secure Shell". 12 * called by a name other than "ssh" or "Secure Shell".
13 */ 13 */
14 14
15/* 15char *tilde_expand_filename(const char *, uid_t);
16 * Expands tildes in the file name. Returns data allocated by xmalloc.
17 * Warning: this calls getpw*.
18 */
19char *tilde_expand_filename(const char *, uid_t);
diff --git a/uidswap.h b/uidswap.h
index 9aea88367..0726980d0 100644
--- a/uidswap.h
+++ b/uidswap.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: uidswap.h,v 1.8 2001/06/26 06:33:06 itojun Exp $ */ 1/* $OpenBSD: uidswap.h,v 1.9 2001/06/26 17:27:25 markus Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -15,22 +15,8 @@
15#ifndef UIDSWAP_H 15#ifndef UIDSWAP_H
16#define UIDSWAP_H 16#define UIDSWAP_H
17 17
18/* 18void temporarily_use_uid(struct passwd *);
19 * Temporarily changes to the given uid. If the effective user id is not 19void restore_uid(void);
20 * root, this does nothing. This call cannot be nested. 20void permanently_set_uid(struct passwd *);
21 */
22void temporarily_use_uid(struct passwd *);
23
24/*
25 * Restores the original effective user id after temporarily_use_uid().
26 * This should only be called while temporarily_use_uid is effective.
27 */
28void restore_uid(void);
29
30/*
31 * Permanently sets all uids to the given uid. This cannot be called while
32 * temporarily_use_uid is effective. This must also clear any saved uids.
33 */
34void permanently_set_uid(struct passwd *);
35 21
36#endif /* UIDSWAP_H */ 22#endif /* UIDSWAP_H */
diff --git a/uuencode.h b/uuencode.h
index fd8f3dbda..0067635b6 100644
--- a/uuencode.h
+++ b/uuencode.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: uuencode.h,v 1.7 2001/06/26 06:33:06 itojun Exp $ */ 1/* $OpenBSD: uuencode.h,v 1.8 2001/06/26 17:27:25 markus Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000 Markus Friedl. All rights reserved.
@@ -26,7 +26,7 @@
26 26
27#ifndef UUENCODE_H 27#ifndef UUENCODE_H
28#define UUENCODE_H 28#define UUENCODE_H
29int uuencode(u_char *, u_int, char *, size_t); 29int uuencode(u_char *, u_int, char *, size_t);
30int uudecode(const char *, u_char *, size_t); 30int uudecode(const char *, u_char *, size_t);
31void dump_base64(FILE *, u_char *, int); 31void dump_base64(FILE *, u_char *, int);
32#endif 32#endif
diff --git a/xmalloc.h b/xmalloc.h
index d04f10293..e14d0141d 100644
--- a/xmalloc.h
+++ b/xmalloc.h
@@ -14,21 +14,14 @@
14 * called by a name other than "ssh" or "Secure Shell". 14 * called by a name other than "ssh" or "Secure Shell".
15 */ 15 */
16 16
17/* RCSID("$OpenBSD: xmalloc.h,v 1.6 2001/06/26 06:33:07 itojun Exp $"); */ 17/* RCSID("$OpenBSD: xmalloc.h,v 1.7 2001/06/26 17:27:25 markus Exp $"); */
18 18
19#ifndef XMALLOC_H 19#ifndef XMALLOC_H
20#define XMALLOC_H 20#define XMALLOC_H
21 21
22/* Like malloc, but calls fatal() if out of memory. */ 22void *xmalloc(size_t);
23void *xmalloc(size_t); 23void *xrealloc(void *, size_t);
24 24void xfree(void *);
25/* Like realloc, but calls fatal() if out of memory. */ 25char *xstrdup(const char *);
26void *xrealloc(void *, size_t);
27
28/* Frees memory allocated using xmalloc or xrealloc. */
29void xfree(void *);
30
31/* Allocates memory using xmalloc, and copies the string into that memory. */
32char *xstrdup(const char *);
33 26
34#endif /* XMALLOC_H */ 27#endif /* XMALLOC_H */