Damien Miller | e4340be | 2000-09-16 13:29:08 +1100 | [diff] [blame] | 1 | /* |
| 2 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
| 3 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
| 4 | * All rights reserved |
Damien Miller | e4340be | 2000-09-16 13:29:08 +1100 | [diff] [blame] | 5 | * As far as I am concerned, the code I have written for this software |
| 6 | * can be used freely for any purpose. Any derived versions of this |
| 7 | * software must be clearly marked as such, and if the derived work is |
| 8 | * incompatible with the protocol description in the RFC file, it must be |
| 9 | * called by a name other than "ssh" or "Secure Shell". |
| 10 | */ |
| 11 | |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 12 | #include "includes.h" |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 13 | RCSID("$OpenBSD: auth-options.c,v 1.24 2002/05/13 20:44:58 markus Exp $"); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 14 | |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 15 | #include "packet.h" |
| 16 | #include "xmalloc.h" |
| 17 | #include "match.h" |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 18 | #include "log.h" |
| 19 | #include "canohost.h" |
Ben Lindstrom | c763767 | 2001-06-09 00:36:26 +0000 | [diff] [blame] | 20 | #include "channels.h" |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 21 | #include "auth-options.h" |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 22 | #include "servconf.h" |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 23 | #include "bufaux.h" |
Ben Lindstrom | d71ba57 | 2001-09-12 18:03:31 +0000 | [diff] [blame] | 24 | #include "misc.h" |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 25 | #include "monitor_wrap.h" |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 26 | #include "auth.h" |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 27 | |
| 28 | /* Flags set authorized_keys flags */ |
| 29 | int no_port_forwarding_flag = 0; |
| 30 | int no_agent_forwarding_flag = 0; |
| 31 | int no_x11_forwarding_flag = 0; |
| 32 | int no_pty_flag = 0; |
| 33 | |
| 34 | /* "command=" option. */ |
| 35 | char *forced_command = NULL; |
| 36 | |
| 37 | /* "environment=" options. */ |
| 38 | struct envstring *custom_environment = NULL; |
| 39 | |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 40 | extern ServerOptions options; |
| 41 | |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 42 | void |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 43 | auth_clear_options(void) |
| 44 | { |
| 45 | no_agent_forwarding_flag = 0; |
| 46 | no_port_forwarding_flag = 0; |
| 47 | no_pty_flag = 0; |
| 48 | no_x11_forwarding_flag = 0; |
| 49 | while (custom_environment) { |
| 50 | struct envstring *ce = custom_environment; |
| 51 | custom_environment = ce->next; |
| 52 | xfree(ce->s); |
| 53 | xfree(ce); |
| 54 | } |
| 55 | if (forced_command) { |
| 56 | xfree(forced_command); |
| 57 | forced_command = NULL; |
| 58 | } |
Ben Lindstrom | 7bb8b49 | 2001-03-17 00:47:54 +0000 | [diff] [blame] | 59 | channel_clear_permitted_opens(); |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 60 | auth_debug_reset(); |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 61 | } |
| 62 | |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 63 | /* |
| 64 | * return 1 if access is granted, 0 if not. |
| 65 | * side effect: sets key option flags |
| 66 | */ |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 67 | int |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 68 | auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum) |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 69 | { |
| 70 | const char *cp; |
Ben Lindstrom | 7bb8b49 | 2001-03-17 00:47:54 +0000 | [diff] [blame] | 71 | int i; |
Damien Miller | 874d77b | 2000-10-14 16:23:11 +1100 | [diff] [blame] | 72 | |
| 73 | /* reset options */ |
| 74 | auth_clear_options(); |
| 75 | |
Ben Lindstrom | 36d7bd0 | 2001-02-10 22:27:19 +0000 | [diff] [blame] | 76 | if (!opts) |
| 77 | return 1; |
| 78 | |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 79 | while (*opts && *opts != ' ' && *opts != '\t') { |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 80 | cp = "no-port-forwarding"; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 81 | if (strncasecmp(opts, cp, strlen(cp)) == 0) { |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 82 | auth_debug_add("Port forwarding disabled."); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 83 | no_port_forwarding_flag = 1; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 84 | opts += strlen(cp); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 85 | goto next_option; |
| 86 | } |
| 87 | cp = "no-agent-forwarding"; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 88 | if (strncasecmp(opts, cp, strlen(cp)) == 0) { |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 89 | auth_debug_add("Agent forwarding disabled."); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 90 | no_agent_forwarding_flag = 1; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 91 | opts += strlen(cp); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 92 | goto next_option; |
| 93 | } |
| 94 | cp = "no-X11-forwarding"; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 95 | if (strncasecmp(opts, cp, strlen(cp)) == 0) { |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 96 | auth_debug_add("X11 forwarding disabled."); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 97 | no_x11_forwarding_flag = 1; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 98 | opts += strlen(cp); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 99 | goto next_option; |
| 100 | } |
| 101 | cp = "no-pty"; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 102 | if (strncasecmp(opts, cp, strlen(cp)) == 0) { |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 103 | auth_debug_add("Pty allocation disabled."); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 104 | no_pty_flag = 1; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 105 | opts += strlen(cp); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 106 | goto next_option; |
| 107 | } |
| 108 | cp = "command=\""; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 109 | if (strncasecmp(opts, cp, strlen(cp)) == 0) { |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 110 | opts += strlen(cp); |
| 111 | forced_command = xmalloc(strlen(opts) + 1); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 112 | i = 0; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 113 | while (*opts) { |
| 114 | if (*opts == '"') |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 115 | break; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 116 | if (*opts == '\\' && opts[1] == '"') { |
| 117 | opts += 2; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 118 | forced_command[i++] = '"'; |
| 119 | continue; |
| 120 | } |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 121 | forced_command[i++] = *opts++; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 122 | } |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 123 | if (!*opts) { |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 124 | debug("%.100s, line %lu: missing end quote", |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 125 | file, linenum); |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 126 | auth_debug_add("%.100s, line %lu: missing end quote", |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 127 | file, linenum); |
Damien Miller | 056ddf7 | 2001-03-14 10:15:20 +1100 | [diff] [blame] | 128 | xfree(forced_command); |
| 129 | forced_command = NULL; |
| 130 | goto bad_option; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 131 | } |
| 132 | forced_command[i] = 0; |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 133 | auth_debug_add("Forced command: %.900s", forced_command); |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 134 | opts++; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 135 | goto next_option; |
| 136 | } |
| 137 | cp = "environment=\""; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 138 | if (strncasecmp(opts, cp, strlen(cp)) == 0) { |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 139 | char *s; |
| 140 | struct envstring *new_envstring; |
Ben Lindstrom | 7bb8b49 | 2001-03-17 00:47:54 +0000 | [diff] [blame] | 141 | |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 142 | opts += strlen(cp); |
| 143 | s = xmalloc(strlen(opts) + 1); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 144 | i = 0; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 145 | while (*opts) { |
| 146 | if (*opts == '"') |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 147 | break; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 148 | if (*opts == '\\' && opts[1] == '"') { |
| 149 | opts += 2; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 150 | s[i++] = '"'; |
| 151 | continue; |
| 152 | } |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 153 | s[i++] = *opts++; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 154 | } |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 155 | if (!*opts) { |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 156 | debug("%.100s, line %lu: missing end quote", |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 157 | file, linenum); |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 158 | auth_debug_add("%.100s, line %lu: missing end quote", |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 159 | file, linenum); |
Damien Miller | 056ddf7 | 2001-03-14 10:15:20 +1100 | [diff] [blame] | 160 | xfree(s); |
| 161 | goto bad_option; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 162 | } |
| 163 | s[i] = 0; |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 164 | auth_debug_add("Adding to environment: %.900s", s); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 165 | debug("Adding to environment: %.900s", s); |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 166 | opts++; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 167 | new_envstring = xmalloc(sizeof(struct envstring)); |
| 168 | new_envstring->s = s; |
| 169 | new_envstring->next = custom_environment; |
| 170 | custom_environment = new_envstring; |
| 171 | goto next_option; |
| 172 | } |
| 173 | cp = "from=\""; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 174 | if (strncasecmp(opts, cp, strlen(cp)) == 0) { |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 175 | const char *remote_ip = get_remote_ipaddr(); |
| 176 | const char *remote_host = get_canonical_hostname( |
Damien Miller | c5d8635 | 2002-02-05 12:13:41 +1100 | [diff] [blame] | 177 | options.verify_reverse_mapping); |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 178 | char *patterns = xmalloc(strlen(opts) + 1); |
Ben Lindstrom | 7bb8b49 | 2001-03-17 00:47:54 +0000 | [diff] [blame] | 179 | |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 180 | opts += strlen(cp); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 181 | i = 0; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 182 | while (*opts) { |
| 183 | if (*opts == '"') |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 184 | break; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 185 | if (*opts == '\\' && opts[1] == '"') { |
| 186 | opts += 2; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 187 | patterns[i++] = '"'; |
| 188 | continue; |
| 189 | } |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 190 | patterns[i++] = *opts++; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 191 | } |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 192 | if (!*opts) { |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 193 | debug("%.100s, line %lu: missing end quote", |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 194 | file, linenum); |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 195 | auth_debug_add("%.100s, line %lu: missing end quote", |
Ben Lindstrom | 226cfa0 | 2001-01-22 05:34:40 +0000 | [diff] [blame] | 196 | file, linenum); |
Damien Miller | 056ddf7 | 2001-03-14 10:15:20 +1100 | [diff] [blame] | 197 | xfree(patterns); |
| 198 | goto bad_option; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 199 | } |
| 200 | patterns[i] = 0; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 201 | opts++; |
Ben Lindstrom | f0c5029 | 2001-06-25 05:17:53 +0000 | [diff] [blame] | 202 | if (match_host_and_ip(remote_host, remote_ip, |
| 203 | patterns) != 1) { |
| 204 | xfree(patterns); |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 205 | log("Authentication tried for %.100s with " |
| 206 | "correct key but not from a permitted " |
| 207 | "host (host=%.200s, ip=%.200s).", |
| 208 | pw->pw_name, remote_host, remote_ip); |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 209 | auth_debug_add("Your host '%.200s' is not " |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 210 | "permitted to use this key for login.", |
| 211 | remote_host); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 212 | /* deny access */ |
| 213 | return 0; |
| 214 | } |
Ben Lindstrom | f0c5029 | 2001-06-25 05:17:53 +0000 | [diff] [blame] | 215 | xfree(patterns); |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 216 | /* Host name matches. */ |
| 217 | goto next_option; |
| 218 | } |
Ben Lindstrom | 7bb8b49 | 2001-03-17 00:47:54 +0000 | [diff] [blame] | 219 | cp = "permitopen=\""; |
| 220 | if (strncasecmp(opts, cp, strlen(cp)) == 0) { |
Ben Lindstrom | d71ba57 | 2001-09-12 18:03:31 +0000 | [diff] [blame] | 221 | char host[256], sport[6]; |
Ben Lindstrom | 7bb8b49 | 2001-03-17 00:47:54 +0000 | [diff] [blame] | 222 | u_short port; |
Ben Lindstrom | 7bb8b49 | 2001-03-17 00:47:54 +0000 | [diff] [blame] | 223 | char *patterns = xmalloc(strlen(opts) + 1); |
| 224 | |
| 225 | opts += strlen(cp); |
| 226 | i = 0; |
| 227 | while (*opts) { |
| 228 | if (*opts == '"') |
| 229 | break; |
| 230 | if (*opts == '\\' && opts[1] == '"') { |
| 231 | opts += 2; |
| 232 | patterns[i++] = '"'; |
| 233 | continue; |
| 234 | } |
| 235 | patterns[i++] = *opts++; |
| 236 | } |
| 237 | if (!*opts) { |
| 238 | debug("%.100s, line %lu: missing end quote", |
| 239 | file, linenum); |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 240 | auth_debug_add("%.100s, line %lu: missing end quote", |
Ben Lindstrom | 7bb8b49 | 2001-03-17 00:47:54 +0000 | [diff] [blame] | 241 | file, linenum); |
| 242 | xfree(patterns); |
| 243 | goto bad_option; |
| 244 | } |
| 245 | patterns[i] = 0; |
| 246 | opts++; |
Ben Lindstrom | d71ba57 | 2001-09-12 18:03:31 +0000 | [diff] [blame] | 247 | if (sscanf(patterns, "%255[^:]:%5[0-9]", host, sport) != 2 && |
| 248 | sscanf(patterns, "%255[^/]/%5[0-9]", host, sport) != 2) { |
| 249 | debug("%.100s, line %lu: Bad permitopen specification " |
| 250 | "<%.100s>", file, linenum, patterns); |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 251 | auth_debug_add("%.100s, line %lu: " |
Ben Lindstrom | d71ba57 | 2001-09-12 18:03:31 +0000 | [diff] [blame] | 252 | "Bad permitopen specification", file, linenum); |
Ben Lindstrom | 7bb8b49 | 2001-03-17 00:47:54 +0000 | [diff] [blame] | 253 | xfree(patterns); |
| 254 | goto bad_option; |
| 255 | } |
Ben Lindstrom | d71ba57 | 2001-09-12 18:03:31 +0000 | [diff] [blame] | 256 | if ((port = a2port(sport)) == 0) { |
| 257 | debug("%.100s, line %lu: Bad permitopen port <%.100s>", |
| 258 | file, linenum, sport); |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 259 | auth_debug_add("%.100s, line %lu: " |
Ben Lindstrom | d71ba57 | 2001-09-12 18:03:31 +0000 | [diff] [blame] | 260 | "Bad permitopen port", file, linenum); |
Ben Lindstrom | 7bb8b49 | 2001-03-17 00:47:54 +0000 | [diff] [blame] | 261 | xfree(patterns); |
| 262 | goto bad_option; |
| 263 | } |
Ben Lindstrom | 2d70f98 | 2001-03-19 00:13:46 +0000 | [diff] [blame] | 264 | if (options.allow_tcp_forwarding) |
Ben Lindstrom | d71ba57 | 2001-09-12 18:03:31 +0000 | [diff] [blame] | 265 | channel_add_permitted_opens(host, port); |
Ben Lindstrom | 7bb8b49 | 2001-03-17 00:47:54 +0000 | [diff] [blame] | 266 | xfree(patterns); |
| 267 | goto next_option; |
| 268 | } |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 269 | next_option: |
| 270 | /* |
| 271 | * Skip the comma, and move to the next option |
| 272 | * (or break out if there are no more). |
| 273 | */ |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 274 | if (!*opts) |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 275 | fatal("Bugs in auth-options.c option processing."); |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 276 | if (*opts == ' ' || *opts == '\t') |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 277 | break; /* End of options. */ |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 278 | if (*opts != ',') |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 279 | goto bad_option; |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 280 | opts++; |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 281 | /* Process the next option. */ |
| 282 | } |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 283 | |
| 284 | if (!use_privsep) |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 285 | auth_debug_send(); |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 286 | |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 287 | /* grant access */ |
| 288 | return 1; |
| 289 | |
| 290 | bad_option: |
| 291 | log("Bad options in %.100s file, line %lu: %.50s", |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 292 | file, linenum, opts); |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 293 | auth_debug_add("Bad options in %.100s file, line %lu: %.50s", |
Damien Miller | 3380426 | 2001-02-04 23:20:18 +1100 | [diff] [blame] | 294 | file, linenum, opts); |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 295 | |
| 296 | if (!use_privsep) |
Ben Lindstrom | a574cda | 2002-05-15 16:16:14 +0000 | [diff] [blame] | 297 | auth_debug_send(); |
Ben Lindstrom | 7a2073c | 2002-03-22 02:30:41 +0000 | [diff] [blame] | 298 | |
Damien Miller | f6d9e22 | 2000-06-18 14:50:44 +1000 | [diff] [blame] | 299 | /* deny access */ |
| 300 | return 0; |
| 301 | } |