1*1c7715ddSchristos /* $NetBSD: auth2-none.c,v 1.15 2024/07/08 22:33:43 christos Exp $ */
2*1c7715ddSchristos /* $OpenBSD: auth2-none.c,v 1.26 2024/05/17 00:30:23 djm Exp $ */
3*1c7715ddSchristos
4ca32bd8dSchristos /*
5ca32bd8dSchristos * Copyright (c) 2000 Markus Friedl. All rights reserved.
6ca32bd8dSchristos *
7ca32bd8dSchristos * Redistribution and use in source and binary forms, with or without
8ca32bd8dSchristos * modification, are permitted provided that the following conditions
9ca32bd8dSchristos * are met:
10ca32bd8dSchristos * 1. Redistributions of source code must retain the above copyright
11ca32bd8dSchristos * notice, this list of conditions and the following disclaimer.
12ca32bd8dSchristos * 2. Redistributions in binary form must reproduce the above copyright
13ca32bd8dSchristos * notice, this list of conditions and the following disclaimer in the
14ca32bd8dSchristos * documentation and/or other materials provided with the distribution.
15ca32bd8dSchristos *
16ca32bd8dSchristos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17ca32bd8dSchristos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18ca32bd8dSchristos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19ca32bd8dSchristos * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20ca32bd8dSchristos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21ca32bd8dSchristos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22ca32bd8dSchristos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23ca32bd8dSchristos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24ca32bd8dSchristos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25ca32bd8dSchristos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26ca32bd8dSchristos */
27ca32bd8dSchristos
28313c6c94Schristos #include "includes.h"
29*1c7715ddSchristos __RCSID("$NetBSD: auth2-none.c,v 1.15 2024/07/08 22:33:43 christos Exp $");
30ca32bd8dSchristos #include <sys/types.h>
318a4530f9Schristos #include <stdarg.h>
328a4530f9Schristos #include <stdio.h>
33ca32bd8dSchristos
34ca32bd8dSchristos #include "xmalloc.h"
357a183406Schristos #include "sshkey.h"
36ca32bd8dSchristos #include "hostfile.h"
37ca32bd8dSchristos #include "auth.h"
38ca32bd8dSchristos #include "packet.h"
39ca32bd8dSchristos #include "log.h"
408a4530f9Schristos #include "misc.h"
41ca32bd8dSchristos #include "servconf.h"
42ca32bd8dSchristos #include "ssh2.h"
437a183406Schristos #include "ssherr.h"
44ca32bd8dSchristos #ifdef GSSAPI
45ca32bd8dSchristos #include "ssh-gss.h"
46ca32bd8dSchristos #endif
47ca32bd8dSchristos #include "monitor_wrap.h"
48ca32bd8dSchristos
49ca32bd8dSchristos /* import */
50ca32bd8dSchristos extern ServerOptions options;
51*1c7715ddSchristos extern struct authmethod_cfg methodcfg_none;
52ca32bd8dSchristos
53*1c7715ddSchristos extern int none_enabled;
54ca32bd8dSchristos
55ca32bd8dSchristos static int
userauth_none(struct ssh * ssh,const char * method)56a03ec00cSchristos userauth_none(struct ssh *ssh, const char *method)
57ca32bd8dSchristos {
587a183406Schristos int r;
597a183406Schristos
60ca32bd8dSchristos none_enabled = 0;
617a183406Schristos if ((r = sshpkt_get_end(ssh)) != 0)
6217418e98Schristos fatal_fr(r, "parse packet");
6334b27b53Sadam if (options.permit_empty_passwd && options.password_authentication)
64*1c7715ddSchristos return mm_auth_password(ssh, "");
65ca32bd8dSchristos return (0);
66ca32bd8dSchristos }
67ca32bd8dSchristos
68ca32bd8dSchristos Authmethod method_none = {
69*1c7715ddSchristos &methodcfg_none,
70ca32bd8dSchristos userauth_none,
71ca32bd8dSchristos };
72