summaryrefslogtreecommitdiff
path: root/auth-options.c
diff options
context:
space:
mode:
Diffstat (limited to 'auth-options.c')
-rw-r--r--auth-options.c48
1 files changed, 28 insertions, 20 deletions
diff --git a/auth-options.c b/auth-options.c
index da6965266..c9c149d69 100644
--- a/auth-options.c
+++ b/auth-options.c
@@ -14,7 +14,7 @@
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$OpenBSD: auth-options.c,v 1.4 2000/09/07 21:13:36 markus Exp $"); 17RCSID("$OpenBSD: auth-options.c,v 1.5 2000/10/09 21:32:34 markus Exp $");
18 18
19#include "ssh.h" 19#include "ssh.h"
20#include "packet.h" 20#include "packet.h"
@@ -33,6 +33,25 @@ char *forced_command = NULL;
33/* "environment=" options. */ 33/* "environment=" options. */
34struct envstring *custom_environment = NULL; 34struct envstring *custom_environment = NULL;
35 35
36void
37auth_clear_options(void)
38{
39 no_agent_forwarding_flag = 0;
40 no_port_forwarding_flag = 0;
41 no_pty_flag = 0;
42 no_x11_forwarding_flag = 0;
43 while (custom_environment) {
44 struct envstring *ce = custom_environment;
45 custom_environment = ce->next;
46 xfree(ce->s);
47 xfree(ce);
48 }
49 if (forced_command) {
50 xfree(forced_command);
51 forced_command = NULL;
52 }
53}
54
36/* return 1 if access is granted, 0 if not. side effect: sets key option flags */ 55/* return 1 if access is granted, 0 if not. side effect: sets key option flags */
37int 56int
38auth_parse_options(struct passwd *pw, char *options, unsigned long linenum) 57auth_parse_options(struct passwd *pw, char *options, unsigned long linenum)
@@ -40,6 +59,10 @@ auth_parse_options(struct passwd *pw, char *options, unsigned long linenum)
40 const char *cp; 59 const char *cp;
41 if (!options) 60 if (!options)
42 return 1; 61 return 1;
62
63 /* reset options */
64 auth_clear_options();
65
43 while (*options && *options != ' ' && *options != '\t') { 66 while (*options && *options != ' ' && *options != '\t') {
44 cp = "no-port-forwarding"; 67 cp = "no-port-forwarding";
45 if (strncmp(options, cp, strlen(cp)) == 0) { 68 if (strncmp(options, cp, strlen(cp)) == 0) {
@@ -87,9 +110,9 @@ auth_parse_options(struct passwd *pw, char *options, unsigned long linenum)
87 } 110 }
88 if (!*options) { 111 if (!*options) {
89 debug("%.100s, line %lu: missing end quote", 112 debug("%.100s, line %lu: missing end quote",
90 SSH_USER_PERMITTED_KEYS, linenum); 113 SSH_USER_PERMITTED_KEYS, linenum);
91 packet_send_debug("%.100s, line %lu: missing end quote", 114 packet_send_debug("%.100s, line %lu: missing end quote",
92 SSH_USER_PERMITTED_KEYS, linenum); 115 SSH_USER_PERMITTED_KEYS, linenum);
93 continue; 116 continue;
94 } 117 }
95 forced_command[i] = 0; 118 forced_command[i] = 0;
@@ -117,9 +140,9 @@ auth_parse_options(struct passwd *pw, char *options, unsigned long linenum)
117 } 140 }
118 if (!*options) { 141 if (!*options) {
119 debug("%.100s, line %lu: missing end quote", 142 debug("%.100s, line %lu: missing end quote",
120 SSH_USER_PERMITTED_KEYS, linenum); 143 SSH_USER_PERMITTED_KEYS, linenum);
121 packet_send_debug("%.100s, line %lu: missing end quote", 144 packet_send_debug("%.100s, line %lu: missing end quote",
122 SSH_USER_PERMITTED_KEYS, linenum); 145 SSH_USER_PERMITTED_KEYS, linenum);
123 continue; 146 continue;
124 } 147 }
125 s[i] = 0; 148 s[i] = 0;
@@ -175,21 +198,6 @@ auth_parse_options(struct passwd *pw, char *options, unsigned long linenum)
175 get_remote_ipaddr()); 198 get_remote_ipaddr());
176 packet_send_debug("Your host '%.200s' is not permitted to use this key for login.", 199 packet_send_debug("Your host '%.200s' is not permitted to use this key for login.",
177 get_canonical_hostname()); 200 get_canonical_hostname());
178 /* key invalid for this host, reset flags */
179 no_agent_forwarding_flag = 0;
180 no_port_forwarding_flag = 0;
181 no_pty_flag = 0;
182 no_x11_forwarding_flag = 0;
183 while (custom_environment) {
184 struct envstring *ce = custom_environment;
185 custom_environment = ce->next;
186 xfree(ce->s);
187 xfree(ce);
188 }
189 if (forced_command) {
190 xfree(forced_command);
191 forced_command = NULL;
192 }
193 /* deny access */ 201 /* deny access */
194 return 0; 202 return 0;
195 } 203 }