/* $OpenBSD: auth2-kbdint.c,v 1.15 2024/05/17 00:30:23 djm Exp $ */1/*2* Copyright (c) 2000 Markus Friedl. All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR14* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES15* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.16* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,17* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT18* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,19* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY20* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT21* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF22* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.23*/2425#include "includes.h"2627#include <sys/types.h>2829#include <stdlib.h>30#include <stdio.h>31#include <stdarg.h>3233#include "xmalloc.h"34#include "packet.h"35#include "hostfile.h"36#include "auth.h"37#include "log.h"38#include "misc.h"39#include "servconf.h"40#include "ssherr.h"4142/* import */43extern ServerOptions options;44extern struct authmethod_cfg methodcfg_kbdint;4546static int47userauth_kbdint(struct ssh *ssh, const char *method)48{49int r, authenticated = 0;50char *lang, *devs;5152if ((r = sshpkt_get_cstring(ssh, &lang, NULL)) != 0 ||53(r = sshpkt_get_cstring(ssh, &devs, NULL)) != 0 ||54(r = sshpkt_get_end(ssh)) != 0)55fatal_fr(r, "parse packet");5657debug("keyboard-interactive devs %s", devs);5859if (options.kbd_interactive_authentication)60authenticated = auth2_challenge(ssh, devs);6162free(devs);63free(lang);64return authenticated;65}6667Authmethod method_kbdint = {68&methodcfg_kbdint,69userauth_kbdint,70};717273