xref: /dflybsd-src/crypto/openssh/auth2-none.c (revision ce74baca94b6dd2a80af6a625aba2cf14ab7fec8)
1*ce74bacaSMatthew Dillon /* $OpenBSD: auth2-none.c,v 1.20 2017/05/30 14:29:59 markus Exp $ */
218de8d7fSPeter Avalos /*
318de8d7fSPeter Avalos  * Copyright (c) 2000 Markus Friedl.  All rights reserved.
418de8d7fSPeter Avalos  *
518de8d7fSPeter Avalos  * Redistribution and use in source and binary forms, with or without
618de8d7fSPeter Avalos  * modification, are permitted provided that the following conditions
718de8d7fSPeter Avalos  * are met:
818de8d7fSPeter Avalos  * 1. Redistributions of source code must retain the above copyright
918de8d7fSPeter Avalos  *    notice, this list of conditions and the following disclaimer.
1018de8d7fSPeter Avalos  * 2. Redistributions in binary form must reproduce the above copyright
1118de8d7fSPeter Avalos  *    notice, this list of conditions and the following disclaimer in the
1218de8d7fSPeter Avalos  *    documentation and/or other materials provided with the distribution.
1318de8d7fSPeter Avalos  *
1418de8d7fSPeter Avalos  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1518de8d7fSPeter Avalos  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1618de8d7fSPeter Avalos  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1718de8d7fSPeter Avalos  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1818de8d7fSPeter Avalos  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1918de8d7fSPeter Avalos  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2018de8d7fSPeter Avalos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2118de8d7fSPeter Avalos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2218de8d7fSPeter Avalos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2318de8d7fSPeter Avalos  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2418de8d7fSPeter Avalos  */
2518de8d7fSPeter Avalos 
2618de8d7fSPeter Avalos #include "includes.h"
2718de8d7fSPeter Avalos 
2818de8d7fSPeter Avalos #include <sys/types.h>
2918de8d7fSPeter Avalos #include <sys/stat.h>
3018de8d7fSPeter Avalos #include <sys/uio.h>
3118de8d7fSPeter Avalos 
3218de8d7fSPeter Avalos #include <fcntl.h>
3318de8d7fSPeter Avalos #include <string.h>
3418de8d7fSPeter Avalos #include <unistd.h>
3536e94dc5SPeter Avalos #include <stdarg.h>
3636e94dc5SPeter Avalos #include <stdio.h>
3718de8d7fSPeter Avalos 
3818de8d7fSPeter Avalos #include "atomicio.h"
3918de8d7fSPeter Avalos #include "xmalloc.h"
40*ce74bacaSMatthew Dillon #include "sshkey.h"
4118de8d7fSPeter Avalos #include "hostfile.h"
4218de8d7fSPeter Avalos #include "auth.h"
4318de8d7fSPeter Avalos #include "packet.h"
4418de8d7fSPeter Avalos #include "log.h"
4518de8d7fSPeter Avalos #include "buffer.h"
4636e94dc5SPeter Avalos #include "misc.h"
4718de8d7fSPeter Avalos #include "servconf.h"
4818de8d7fSPeter Avalos #include "compat.h"
4918de8d7fSPeter Avalos #include "ssh2.h"
50*ce74bacaSMatthew Dillon #include "ssherr.h"
5118de8d7fSPeter Avalos #ifdef GSSAPI
5218de8d7fSPeter Avalos #include "ssh-gss.h"
5318de8d7fSPeter Avalos #endif
5418de8d7fSPeter Avalos #include "monitor_wrap.h"
5518de8d7fSPeter Avalos 
5618de8d7fSPeter Avalos /* import */
5718de8d7fSPeter Avalos extern ServerOptions options;
5818de8d7fSPeter Avalos 
5918de8d7fSPeter Avalos /* "none" is allowed only one time */
6018de8d7fSPeter Avalos static int none_enabled = 1;
6118de8d7fSPeter Avalos 
6218de8d7fSPeter Avalos static int
63*ce74bacaSMatthew Dillon userauth_none(struct ssh *ssh)
6418de8d7fSPeter Avalos {
65*ce74bacaSMatthew Dillon 	int r;
66*ce74bacaSMatthew Dillon 
6718de8d7fSPeter Avalos 	none_enabled = 0;
68*ce74bacaSMatthew Dillon 	if ((r = sshpkt_get_end(ssh)) != 0)
69*ce74bacaSMatthew Dillon 		fatal("%s: %s", __func__, ssh_err(r));
70856ea928SPeter Avalos 	if (options.permit_empty_passwd && options.password_authentication)
71*ce74bacaSMatthew Dillon 		return (PRIVSEP(auth_password(ssh->authctxt, "")));
7218de8d7fSPeter Avalos 	return (0);
7318de8d7fSPeter Avalos }
7418de8d7fSPeter Avalos 
7518de8d7fSPeter Avalos Authmethod method_none = {
7618de8d7fSPeter Avalos 	"none",
7718de8d7fSPeter Avalos 	userauth_none,
7818de8d7fSPeter Avalos 	&none_enabled
7918de8d7fSPeter Avalos };
80