1*0fdf8faeSEd Maste /* $OpenBSD: auth2-none.c,v 1.26 2024/05/17 00:30:23 djm Exp $ */
2545d5ecaSDag-Erling Smørgrav /*
3545d5ecaSDag-Erling Smørgrav * Copyright (c) 2000 Markus Friedl. All rights reserved.
4545d5ecaSDag-Erling Smørgrav *
5545d5ecaSDag-Erling Smørgrav * Redistribution and use in source and binary forms, with or without
6545d5ecaSDag-Erling Smørgrav * modification, are permitted provided that the following conditions
7545d5ecaSDag-Erling Smørgrav * are met:
8545d5ecaSDag-Erling Smørgrav * 1. Redistributions of source code must retain the above copyright
9545d5ecaSDag-Erling Smørgrav * notice, this list of conditions and the following disclaimer.
10545d5ecaSDag-Erling Smørgrav * 2. Redistributions in binary form must reproduce the above copyright
11545d5ecaSDag-Erling Smørgrav * notice, this list of conditions and the following disclaimer in the
12545d5ecaSDag-Erling Smørgrav * documentation and/or other materials provided with the distribution.
13545d5ecaSDag-Erling Smørgrav *
14545d5ecaSDag-Erling Smørgrav * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15545d5ecaSDag-Erling Smørgrav * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16545d5ecaSDag-Erling Smørgrav * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17545d5ecaSDag-Erling Smørgrav * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18545d5ecaSDag-Erling Smørgrav * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19545d5ecaSDag-Erling Smørgrav * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20545d5ecaSDag-Erling Smørgrav * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21545d5ecaSDag-Erling Smørgrav * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22545d5ecaSDag-Erling Smørgrav * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23545d5ecaSDag-Erling Smørgrav * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24545d5ecaSDag-Erling Smørgrav */
25545d5ecaSDag-Erling Smørgrav
26545d5ecaSDag-Erling Smørgrav #include "includes.h"
27545d5ecaSDag-Erling Smørgrav
28761efaa7SDag-Erling Smørgrav #include <sys/types.h>
29761efaa7SDag-Erling Smørgrav #include <sys/stat.h>
30761efaa7SDag-Erling Smørgrav #include <sys/uio.h>
31761efaa7SDag-Erling Smørgrav
32761efaa7SDag-Erling Smørgrav #include <fcntl.h>
33d4af9e69SDag-Erling Smørgrav #include <string.h>
34761efaa7SDag-Erling Smørgrav #include <unistd.h>
35a0ee8cc6SDag-Erling Smørgrav #include <stdarg.h>
36a0ee8cc6SDag-Erling Smørgrav #include <stdio.h>
37761efaa7SDag-Erling Smørgrav
38d4af9e69SDag-Erling Smørgrav #include "atomicio.h"
39545d5ecaSDag-Erling Smørgrav #include "xmalloc.h"
404f52dfbbSDag-Erling Smørgrav #include "sshkey.h"
41761efaa7SDag-Erling Smørgrav #include "hostfile.h"
42761efaa7SDag-Erling Smørgrav #include "auth.h"
43545d5ecaSDag-Erling Smørgrav #include "packet.h"
44545d5ecaSDag-Erling Smørgrav #include "log.h"
45a0ee8cc6SDag-Erling Smørgrav #include "misc.h"
46545d5ecaSDag-Erling Smørgrav #include "servconf.h"
47545d5ecaSDag-Erling Smørgrav #include "ssh2.h"
484f52dfbbSDag-Erling Smørgrav #include "ssherr.h"
49761efaa7SDag-Erling Smørgrav #ifdef GSSAPI
50761efaa7SDag-Erling Smørgrav #include "ssh-gss.h"
51761efaa7SDag-Erling Smørgrav #endif
52545d5ecaSDag-Erling Smørgrav #include "monitor_wrap.h"
53545d5ecaSDag-Erling Smørgrav
54545d5ecaSDag-Erling Smørgrav /* import */
55545d5ecaSDag-Erling Smørgrav extern ServerOptions options;
56*0fdf8faeSEd Maste extern struct authmethod_cfg methodcfg_none;
57545d5ecaSDag-Erling Smørgrav
58*0fdf8faeSEd Maste extern int none_enabled;
59545d5ecaSDag-Erling Smørgrav
60545d5ecaSDag-Erling Smørgrav static int
userauth_none(struct ssh * ssh,const char * method)611323ec57SEd Maste userauth_none(struct ssh *ssh, const char *method)
62545d5ecaSDag-Erling Smørgrav {
634f52dfbbSDag-Erling Smørgrav int r;
644f52dfbbSDag-Erling Smørgrav
65545d5ecaSDag-Erling Smørgrav none_enabled = 0;
664f52dfbbSDag-Erling Smørgrav if ((r = sshpkt_get_end(ssh)) != 0)
6719261079SEd Maste fatal_fr(r, "parse packet");
68e2f6069cSDag-Erling Smørgrav if (options.permit_empty_passwd && options.password_authentication)
69*0fdf8faeSEd Maste return mm_auth_password(ssh, "");
70d95e11bfSDag-Erling Smørgrav return (0);
71545d5ecaSDag-Erling Smørgrav }
72545d5ecaSDag-Erling Smørgrav
73545d5ecaSDag-Erling Smørgrav Authmethod method_none = {
74*0fdf8faeSEd Maste &methodcfg_none,
75545d5ecaSDag-Erling Smørgrav userauth_none,
76545d5ecaSDag-Erling Smørgrav };
77