jcs's openbsd hax
openbsd
1/* $OpenBSD: auth.c,v 1.164 2026/02/11 22:57:16 djm Exp $ */
2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include <sys/types.h>
27#include <sys/stat.h>
28#include <sys/socket.h>
29#include <sys/wait.h>
30
31#include <stdlib.h>
32#include <errno.h>
33#include <fcntl.h>
34#include <login_cap.h>
35#include <paths.h>
36#include <pwd.h>
37#include <stdarg.h>
38#include <stdio.h>
39#include <string.h>
40#include <unistd.h>
41#include <limits.h>
42#include <netdb.h>
43#include <time.h>
44
45#include "xmalloc.h"
46#include "match.h"
47#include "groupaccess.h"
48#include "log.h"
49#include "sshbuf.h"
50#include "misc.h"
51#include "servconf.h"
52#include "sshkey.h"
53#include "hostfile.h"
54#include "auth.h"
55#include "auth-options.h"
56#include "canohost.h"
57#include "uidswap.h"
58#include "packet.h"
59#ifdef GSSAPI
60#include "ssh-gss.h"
61#endif
62#include "authfile.h"
63#include "monitor_wrap.h"
64#include "ssherr.h"
65#include "channels.h"
66
67/* import */
68extern ServerOptions options;
69extern struct include_list includes;
70extern struct sshauthopt *auth_opts;
71
72/* Debugging messages */
73static struct sshbuf *auth_debug;
74
75/*
76 * Check if the user is allowed to log in via ssh. If user is listed
77 * in DenyUsers or one of user's groups is listed in DenyGroups, false
78 * will be returned. If AllowUsers isn't empty and user isn't listed
79 * there, or if AllowGroups isn't empty and one of user's groups isn't
80 * listed there, false will be returned.
81 * If the user's shell is not executable, false will be returned.
82 * Otherwise true is returned.
83 */
84int
85allowed_user(struct ssh *ssh, struct passwd * pw)
86{
87 struct stat st;
88 const char *hostname = NULL, *ipaddr = NULL;
89 int r;
90 u_int i;
91
92 /* Shouldn't be called if pw is NULL, but better safe than sorry... */
93 if (!pw || !pw->pw_name)
94 return 0;
95
96 /*
97 * Deny if shell does not exist or is not executable unless we
98 * are chrooting.
99 */
100 if (options.chroot_directory == NULL ||
101 strcasecmp(options.chroot_directory, "none") == 0) {
102 char *shell = xstrdup((pw->pw_shell[0] == '\0') ?
103 _PATH_BSHELL : pw->pw_shell); /* empty = /bin/sh */
104
105 if (stat(shell, &st) == -1) {
106 logit("User %.100s not allowed because shell %.100s "
107 "does not exist", pw->pw_name, shell);
108 free(shell);
109 return 0;
110 }
111 if (S_ISREG(st.st_mode) == 0 ||
112 (st.st_mode & (S_IXOTH|S_IXUSR|S_IXGRP)) == 0) {
113 logit("User %.100s not allowed because shell %.100s "
114 "is not executable", pw->pw_name, shell);
115 free(shell);
116 return 0;
117 }
118 free(shell);
119 }
120
121 if (options.num_deny_users > 0 || options.num_allow_users > 0 ||
122 options.num_deny_groups > 0 || options.num_allow_groups > 0) {
123 hostname = auth_get_canonical_hostname(ssh, options.use_dns);
124 ipaddr = ssh_remote_ipaddr(ssh);
125 }
126
127 /* Return false if user is listed in DenyUsers */
128 if (options.num_deny_users > 0) {
129 for (i = 0; i < options.num_deny_users; i++) {
130 r = match_user(pw->pw_name, hostname, ipaddr,
131 options.deny_users[i]);
132 if (r < 0) {
133 fatal("Invalid DenyUsers pattern \"%.100s\"",
134 options.deny_users[i]);
135 } else if (r != 0) {
136 logit("User %.100s from %.100s not allowed "
137 "because listed in DenyUsers",
138 pw->pw_name, hostname);
139 return 0;
140 }
141 }
142 }
143 /* Return false if AllowUsers isn't empty and user isn't listed there */
144 if (options.num_allow_users > 0) {
145 for (i = 0; i < options.num_allow_users; i++) {
146 r = match_user(pw->pw_name, hostname, ipaddr,
147 options.allow_users[i]);
148 if (r < 0) {
149 fatal("Invalid AllowUsers pattern \"%.100s\"",
150 options.allow_users[i]);
151 } else if (r == 1)
152 break;
153 }
154 /* i < options.num_allow_users iff we break for loop */
155 if (i >= options.num_allow_users) {
156 logit("User %.100s from %.100s not allowed because "
157 "not listed in AllowUsers", pw->pw_name, hostname);
158 return 0;
159 }
160 }
161 if (options.num_deny_groups > 0 || options.num_allow_groups > 0) {
162 /* Get the user's group access list (primary and supplementary) */
163 if (ga_init(pw->pw_name, pw->pw_gid) == 0) {
164 logit("User %.100s from %.100s not allowed because "
165 "not in any group", pw->pw_name, hostname);
166 return 0;
167 }
168
169 /* Return false if one of user's groups is listed in DenyGroups */
170 if (options.num_deny_groups > 0)
171 if (ga_match(options.deny_groups,
172 options.num_deny_groups)) {
173 ga_free();
174 logit("User %.100s from %.100s not allowed "
175 "because a group is listed in DenyGroups",
176 pw->pw_name, hostname);
177 return 0;
178 }
179 /*
180 * Return false if AllowGroups isn't empty and one of user's groups
181 * isn't listed there
182 */
183 if (options.num_allow_groups > 0)
184 if (!ga_match(options.allow_groups,
185 options.num_allow_groups)) {
186 ga_free();
187 logit("User %.100s from %.100s not allowed "
188 "because none of user's groups are listed "
189 "in AllowGroups", pw->pw_name, hostname);
190 return 0;
191 }
192 ga_free();
193 }
194 /* We found no reason not to let this user try to log on... */
195 return 1;
196}
197
198/*
199 * Formats any key left in authctxt->auth_method_key for inclusion in
200 * auth_log()'s message. Also includes authxtct->auth_method_info if present.
201 */
202static char *
203format_method_key(Authctxt *authctxt)
204{
205 const struct sshkey *key = authctxt->auth_method_key;
206 const char *methinfo = authctxt->auth_method_info;
207 char *fp, *cafp, *ret = NULL;
208
209 if (key == NULL)
210 return NULL;
211
212 if (sshkey_is_cert(key)) {
213 fp = sshkey_fingerprint(key,
214 options.fingerprint_hash, SSH_FP_DEFAULT);
215 cafp = sshkey_fingerprint(key->cert->signature_key,
216 options.fingerprint_hash, SSH_FP_DEFAULT);
217 xasprintf(&ret, "%s %s ID %s (serial %llu) CA %s %s%s%s",
218 sshkey_type(key), fp == NULL ? "(null)" : fp,
219 key->cert->key_id,
220 (unsigned long long)key->cert->serial,
221 sshkey_type(key->cert->signature_key),
222 cafp == NULL ? "(null)" : cafp,
223 methinfo == NULL ? "" : ", ",
224 methinfo == NULL ? "" : methinfo);
225 free(fp);
226 free(cafp);
227 } else {
228 fp = sshkey_fingerprint(key, options.fingerprint_hash,
229 SSH_FP_DEFAULT);
230 xasprintf(&ret, "%s %s%s%s", sshkey_type(key),
231 fp == NULL ? "(null)" : fp,
232 methinfo == NULL ? "" : ", ",
233 methinfo == NULL ? "" : methinfo);
234 free(fp);
235 }
236 return ret;
237}
238
239void
240auth_log(struct ssh *ssh, int authenticated, int partial,
241 const char *method, const char *submethod)
242{
243 Authctxt *authctxt = (Authctxt *)ssh->authctxt;
244 int level = SYSLOG_LEVEL_VERBOSE;
245 const char *authmsg;
246 char *extra = NULL;
247
248 if (!mm_is_monitor() && !authctxt->postponed)
249 return;
250
251 /* Raise logging level */
252 if (authenticated == 1 ||
253 !authctxt->valid ||
254 authctxt->failures >= options.max_authtries / 2 ||
255 strcmp(method, "password") == 0)
256 level = SYSLOG_LEVEL_INFO;
257
258 if (authctxt->postponed)
259 authmsg = "Postponed";
260 else if (partial)
261 authmsg = "Partial";
262 else
263 authmsg = authenticated ? "Accepted" : "Failed";
264
265 if ((extra = format_method_key(authctxt)) == NULL) {
266 if (authctxt->auth_method_info != NULL)
267 extra = xstrdup(authctxt->auth_method_info);
268 }
269
270 do_log2(level, "%s %s%s%s for %s%.100s from %.200s port %d ssh2%s%s",
271 authmsg,
272 method,
273 submethod != NULL ? "/" : "", submethod == NULL ? "" : submethod,
274 authctxt->valid ? "" : "invalid user ",
275 authctxt->user,
276 ssh_remote_ipaddr(ssh),
277 ssh_remote_port(ssh),
278 extra != NULL ? ": " : "",
279 extra != NULL ? extra : "");
280
281 free(extra);
282}
283
284void
285auth_maxtries_exceeded(struct ssh *ssh)
286{
287 Authctxt *authctxt = (Authctxt *)ssh->authctxt;
288
289 error("maximum authentication attempts exceeded for "
290 "%s%.100s from %.200s port %d ssh2",
291 authctxt->valid ? "" : "invalid user ",
292 authctxt->user,
293 ssh_remote_ipaddr(ssh),
294 ssh_remote_port(ssh));
295 ssh_packet_disconnect(ssh, "Too many authentication failures");
296 /* NOTREACHED */
297}
298
299/*
300 * Check whether root logins are disallowed.
301 */
302int
303auth_root_allowed(struct ssh *ssh, const char *method)
304{
305 switch (options.permit_root_login) {
306 case PERMIT_YES:
307 return 1;
308 case PERMIT_NO_PASSWD:
309 if (strcmp(method, "publickey") == 0 ||
310 strcmp(method, "hostbased") == 0 ||
311 strcmp(method, "gssapi-with-mic") == 0)
312 return 1;
313 break;
314 case PERMIT_FORCED_ONLY:
315 if (auth_opts->force_command != NULL) {
316 logit("Root login accepted for forced command.");
317 return 1;
318 }
319 break;
320 }
321 logit("ROOT LOGIN REFUSED FROM %.200s port %d",
322 ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));
323 return 0;
324}
325
326
327/*
328 * Given a template and a passwd structure, build a filename
329 * by substituting % tokenised options. Currently, %% becomes '%',
330 * %h becomes the home directory and %u the username.
331 *
332 * This returns a buffer allocated by xmalloc.
333 */
334char *
335expand_authorized_keys(const char *filename, struct passwd *pw)
336{
337 char *file, uidstr[32], ret[PATH_MAX];
338 int i;
339
340 snprintf(uidstr, sizeof(uidstr), "%llu",
341 (unsigned long long)pw->pw_uid);
342 file = percent_expand(filename, "h", pw->pw_dir,
343 "u", pw->pw_name, "U", uidstr, (char *)NULL);
344
345 /*
346 * Ensure that filename starts anchored. If not, be backward
347 * compatible and prepend the '%h/'
348 */
349 if (path_absolute(file))
350 return (file);
351
352 i = snprintf(ret, sizeof(ret), "%s/%s", pw->pw_dir, file);
353 if (i < 0 || (size_t)i >= sizeof(ret))
354 fatal("expand_authorized_keys: path too long");
355 free(file);
356 return (xstrdup(ret));
357}
358
359char *
360authorized_principals_file(struct passwd *pw)
361{
362 if (options.authorized_principals_file == NULL)
363 return NULL;
364 return expand_authorized_keys(options.authorized_principals_file, pw);
365}
366
367/* return ok if key exists in sysfile or userfile */
368HostStatus
369check_key_in_hostfiles(struct passwd *pw, struct sshkey *key, const char *host,
370 const char *sysfile, const char *userfile)
371{
372 char *user_hostfile;
373 struct stat st;
374 HostStatus host_status;
375 struct hostkeys *hostkeys;
376 const struct hostkey_entry *found;
377
378 hostkeys = init_hostkeys();
379 load_hostkeys(hostkeys, host, sysfile, 0);
380 if (userfile != NULL) {
381 user_hostfile = tilde_expand_filename(userfile, pw->pw_uid);
382 if (options.strict_modes &&
383 (stat(user_hostfile, &st) == 0) &&
384 ((st.st_uid != 0 && st.st_uid != pw->pw_uid) ||
385 (st.st_mode & 022) != 0)) {
386 logit("Authentication refused for %.100s: "
387 "bad owner or modes for %.200s",
388 pw->pw_name, user_hostfile);
389 auth_debug_add("Ignored %.200s: bad ownership or modes",
390 user_hostfile);
391 } else {
392 temporarily_use_uid(pw);
393 load_hostkeys(hostkeys, host, user_hostfile, 0);
394 restore_uid();
395 }
396 free(user_hostfile);
397 }
398 host_status = check_key_in_hostkeys(hostkeys, key, &found);
399 if (host_status == HOST_REVOKED)
400 error("WARNING: revoked key for %s attempted authentication",
401 host);
402 else if (host_status == HOST_OK)
403 debug_f("key for %s found at %s:%ld",
404 found->host, found->file, found->line);
405 else
406 debug_f("key for host %s not found", host);
407
408 free_hostkeys(hostkeys);
409
410 return host_status;
411}
412
413struct passwd *
414getpwnamallow(struct ssh *ssh, const char *user)
415{
416 extern login_cap_t *lc;
417 auth_session_t *as;
418 struct passwd *pw;
419 struct connection_info *ci;
420 u_int i;
421
422 ci = server_get_connection_info(ssh, 1, options.use_dns);
423 ci->user = user;
424 ci->user_invalid = getpwnam(user) == NULL;
425 parse_server_match_config(&options, &includes, ci);
426 log_change_level(options.log_level);
427 log_verbose_reset();
428 for (i = 0; i < options.num_log_verbose; i++)
429 log_verbose_add(options.log_verbose[i]);
430 server_process_permitopen(ssh);
431
432 pw = getpwnam(user);
433 if (pw == NULL) {
434 logit("Invalid user %.100s from %.100s port %d",
435 user, ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));
436 return (NULL);
437 }
438 if (!allowed_user(ssh, pw))
439 return (NULL);
440 if ((lc = login_getclass(pw->pw_class)) == NULL) {
441 debug("unable to get login class: %s", user);
442 return (NULL);
443 }
444 if ((as = auth_open()) == NULL || auth_setpwd(as, pw) != 0 ||
445 auth_approval(as, lc, pw->pw_name, "ssh") <= 0) {
446 debug("Approval failure for %s", user);
447 pw = NULL;
448 }
449 if (as != NULL)
450 auth_close(as);
451 if (pw != NULL)
452 return (pwcopy(pw));
453 return (NULL);
454}
455
456/* Returns 1 if key is revoked by revoked_keys_file, 0 otherwise */
457int
458auth_key_is_revoked(struct sshkey *key)
459{
460 char *fp = NULL;
461 u_int i;
462 int r;
463
464 if (options.num_revoked_keys_files == 0)
465 return 0;
466 if ((fp = sshkey_fingerprint(key, options.fingerprint_hash,
467 SSH_FP_DEFAULT)) == NULL) {
468 r = SSH_ERR_ALLOC_FAIL;
469 error_fr(r, "fingerprint key");
470 goto out;
471 }
472
473 for (i = 0; i < options.num_revoked_keys_files; i++) {
474 r = sshkey_check_revoked(key, options.revoked_keys_files[i]);
475 switch (r) {
476 case 0:
477 break; /* not revoked */
478 case SSH_ERR_KEY_REVOKED:
479 error("Authentication key %s %s revoked by file %s",
480 sshkey_type(key), fp,
481 options.revoked_keys_files[i]);
482 goto out;
483 default:
484 error_r(r, "Error checking authentication key %s %s in "
485 "revoked keys file %s", sshkey_type(key), fp,
486 options.revoked_keys_files[i]);
487 goto out;
488 }
489 }
490
491 /* Success */
492 r = 0;
493
494 out:
495 free(fp);
496 return r == 0 ? 0 : 1;
497}
498
499void
500auth_debug_add(const char *fmt,...)
501{
502 char buf[1024];
503 va_list args;
504 int r;
505
506 va_start(args, fmt);
507 vsnprintf(buf, sizeof(buf), fmt, args);
508 va_end(args);
509 debug3("%s", buf);
510 if (auth_debug != NULL)
511 if ((r = sshbuf_put_cstring(auth_debug, buf)) != 0)
512 fatal_fr(r, "sshbuf_put_cstring");
513}
514
515void
516auth_debug_send(struct ssh *ssh)
517{
518 char *msg;
519 int r;
520
521 if (auth_debug == NULL)
522 return;
523 while (sshbuf_len(auth_debug) != 0) {
524 if ((r = sshbuf_get_cstring(auth_debug, &msg, NULL)) != 0)
525 fatal_fr(r, "sshbuf_get_cstring");
526 ssh_packet_send_debug(ssh, "%s", msg);
527 free(msg);
528 }
529}
530
531void
532auth_debug_reset(void)
533{
534 if (auth_debug != NULL)
535 sshbuf_reset(auth_debug);
536 else if ((auth_debug = sshbuf_new()) == NULL)
537 fatal_f("sshbuf_new failed");
538}
539
540struct passwd *
541fakepw(void)
542{
543 static int done = 0;
544 static struct passwd fake;
545 const char hashchars[] = "./ABCDEFGHIJKLMNOPQRSTUVWXYZ"
546 "abcdefghijklmnopqrstuvwxyz0123456789"; /* from bcrypt.c */
547 char *cp;
548
549 if (done)
550 return (&fake);
551
552 memset(&fake, 0, sizeof(fake));
553 fake.pw_name = "NOUSER";
554 fake.pw_passwd = xstrdup("$2a$10$"
555 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
556 for (cp = fake.pw_passwd + 7; *cp != '\0'; cp++)
557 *cp = hashchars[arc4random_uniform(sizeof(hashchars) - 1)];
558 fake.pw_gecos = "NOUSER";
559 fake.pw_uid = (uid_t)-1;
560 fake.pw_gid = (gid_t)-1;
561 fake.pw_class = "";
562 fake.pw_dir = "/nonexist";
563 fake.pw_shell = "/nonexist";
564 done = 1;
565
566 return (&fake);
567}
568
569/*
570 * Return the canonical name of the host in the other side of the current
571 * connection. The host name is cached, so it is efficient to call this
572 * several times.
573 */
574
575const char *
576auth_get_canonical_hostname(struct ssh *ssh, int use_dns)
577{
578 static char *dnsname;
579
580 if (!use_dns)
581 return ssh_remote_ipaddr(ssh);
582 if (dnsname != NULL)
583 return dnsname;
584 dnsname = ssh_remote_hostname(ssh);
585 return dnsname;
586}
587
588/* These functions link key/cert options to the auth framework */
589
590/* Log sshauthopt options locally and (optionally) for remote transmission */
591void
592auth_log_authopts(const char *loc, const struct sshauthopt *opts, int do_remote)
593{
594 int do_env = options.permit_user_env && opts->nenv > 0;
595 int do_permitopen = opts->npermitopen > 0 &&
596 (options.allow_tcp_forwarding & FORWARD_LOCAL) != 0;
597 int do_permitlisten = opts->npermitlisten > 0 &&
598 (options.allow_tcp_forwarding & FORWARD_REMOTE) != 0;
599 size_t i;
600 char msg[1024], buf[64];
601
602 snprintf(buf, sizeof(buf), "%d", opts->force_tun_device);
603 /* Try to keep this alphabetically sorted */
604 snprintf(msg, sizeof(msg), "key options:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
605 opts->permit_agent_forwarding_flag ? " agent-forwarding" : "",
606 opts->force_command == NULL ? "" : " command",
607 do_env ? " environment" : "",
608 opts->valid_before == 0 ? "" : "expires",
609 opts->no_require_user_presence ? " no-touch-required" : "",
610 do_permitopen ? " permitopen" : "",
611 do_permitlisten ? " permitlisten" : "",
612 opts->permit_port_forwarding_flag ? " port-forwarding" : "",
613 opts->cert_principals == NULL ? "" : " principals",
614 opts->permit_pty_flag ? " pty" : "",
615 opts->require_verify ? " uv" : "",
616 opts->force_tun_device == -1 ? "" : " tun=",
617 opts->force_tun_device == -1 ? "" : buf,
618 opts->permit_user_rc ? " user-rc" : "",
619 opts->permit_x11_forwarding_flag ? " x11-forwarding" : "");
620
621 debug("%s: %s", loc, msg);
622 if (do_remote)
623 auth_debug_add("%s: %s", loc, msg);
624
625 if (options.permit_user_env) {
626 for (i = 0; i < opts->nenv; i++) {
627 debug("%s: environment: %s", loc, opts->env[i]);
628 if (do_remote) {
629 auth_debug_add("%s: environment: %s",
630 loc, opts->env[i]);
631 }
632 }
633 }
634
635 /* Go into a little more details for the local logs. */
636 if (opts->valid_before != 0) {
637 format_absolute_time(opts->valid_before, buf, sizeof(buf));
638 debug("%s: expires at %s", loc, buf);
639 }
640 if (opts->cert_principals != NULL) {
641 debug("%s: authorized principals: \"%s\"",
642 loc, opts->cert_principals);
643 }
644 if (opts->force_command != NULL)
645 debug("%s: forced command: \"%s\"", loc, opts->force_command);
646 if (do_permitopen) {
647 for (i = 0; i < opts->npermitopen; i++) {
648 debug("%s: permitted open: %s",
649 loc, opts->permitopen[i]);
650 }
651 }
652 if (do_permitlisten) {
653 for (i = 0; i < opts->npermitlisten; i++) {
654 debug("%s: permitted listen: %s",
655 loc, opts->permitlisten[i]);
656 }
657 }
658}
659
660/* Activate a new set of key/cert options; merging with what is there. */
661int
662auth_activate_options(struct ssh *ssh, struct sshauthopt *opts)
663{
664 struct sshauthopt *old = auth_opts;
665 const char *emsg = NULL;
666
667 debug_f("setting new authentication options");
668 if ((auth_opts = sshauthopt_merge(old, opts, &emsg)) == NULL) {
669 error("Inconsistent authentication options: %s", emsg);
670 return -1;
671 }
672 sshauthopt_free(old);
673 return 0;
674}
675
676/* Disable forwarding, etc for the session */
677void
678auth_restrict_session(struct ssh *ssh)
679{
680 struct sshauthopt *restricted;
681
682 debug_f("restricting session");
683
684 /* A blank sshauthopt defaults to permitting nothing */
685 if ((restricted = sshauthopt_new()) == NULL)
686 fatal_f("sshauthopt_new failed");
687 restricted->permit_pty_flag = 1;
688 restricted->restricted = 1;
689
690 if (auth_activate_options(ssh, restricted) != 0)
691 fatal_f("failed to restrict session");
692 sshauthopt_free(restricted);
693}