Main Page | Namespace List | Class List | Directories | File List | Class Members | File Members

auth2-none.c File Reference

#include "includes.h"
#include "auth.h"
#include "xmalloc.h"
#include "packet.h"
#include "log.h"
#include "servconf.h"
#include "atomicio.h"
#include "compat.h"
#include "ssh2.h"
#include "monitor_wrap.h"

Go to the source code of this file.

Functions

 RCSID ("$OpenBSD: auth2-none.c,v 1.7 2004/05/11 19:01:43 deraadt Exp $")
charauth2_read_banner (void)
void userauth_send_banner (const char *msg)
static void userauth_banner (void)
static int userauth_none (Authctxt *authctxt)

Variables

ServerOptions options
static int none_enabled = 1
Authmethod method_none


Function Documentation

char* auth2_read_banner void   ) 
 

Definition at line 45 of file auth2-none.c.

References atomicio(), ServerOptions::banner, xfree(), and xmalloc().

Referenced by mm_answer_auth2_read_banner(), and userauth_banner().

00046 {
00047         struct stat st;
00048         char *banner = NULL;
00049         size_t len, n;
00050         int fd;
00051 
00052         if ((fd = open(options.banner, O_RDONLY)) == -1)
00053                 return (NULL);
00054         if (fstat(fd, &st) == -1) {
00055                 close(fd);
00056                 return (NULL);
00057         }
00058         if (st.st_size > 1*1024*1024) {
00059                 close(fd);
00060                 return (NULL);
00061         }
00062 
00063         len = (size_t)st.st_size;               /* truncate */
00064         banner = xmalloc(len + 1);
00065         n = atomicio(read, fd, banner, len);
00066         close(fd);
00067 
00068         if (n != len) {
00069                 xfree(banner);
00070                 return (NULL);
00071         }
00072         banner[n] = '\0';
00073 
00074         return (banner);
00075 }

RCSID "$OpenBSD: auth2-none.  c,
v 1.7 2004/05/11 19:01:43 deraadt Exp $" 
 

static void userauth_banner void   )  [static]
 

Definition at line 91 of file auth2-none.c.

References auth2_read_banner(), ServerOptions::banner, datafellows, PRIVSEP, SSH_BUG_BANNER, userauth_send_banner(), and xfree().

Referenced by userauth_none().

00092 {
00093         char *banner = NULL;
00094 
00095         if (options.banner == NULL || (datafellows & SSH_BUG_BANNER))
00096                 return;
00097 
00098         if ((banner = PRIVSEP(auth2_read_banner())) == NULL)
00099                 goto done;
00100         userauth_send_banner(banner);
00101 
00102 done:
00103         if (banner)
00104                 xfree(banner);
00105 }

static int userauth_none Authctxt authctxt  )  [static]
 

Definition at line 108 of file auth2-none.c.

References auth_password(), none_enabled, packet_check_eom, ServerOptions::password_authentication, PRIVSEP, Authctxt::pw, and userauth_banner().

Referenced by ssh_userauth2().

00109 {
00110         none_enabled = 0;
00111         packet_check_eom();
00112         userauth_banner();
00113 #ifdef HAVE_CYGWIN
00114         if (check_nt_auth(1, authctxt->pw) == 0)
00115                 return (0);
00116 #endif
00117         if (options.password_authentication)
00118                 return (PRIVSEP(auth_password(authctxt, "")));
00119         return (0);
00120 }

void userauth_send_banner const char msg  ) 
 

Definition at line 78 of file auth2-none.c.

References __func__, datafellows, debug(), packet_put_cstring(), packet_send(), packet_start(), SSH2_MSG_USERAUTH_BANNER, and SSH_BUG_BANNER.

Referenced by userauth_banner(), and userauth_finish().

00079 {
00080         if (datafellows & SSH_BUG_BANNER)
00081                 return;
00082 
00083         packet_start(SSH2_MSG_USERAUTH_BANNER);
00084         packet_put_cstring(msg);
00085         packet_put_cstring("");         /* language, unused */
00086         packet_send();
00087         debug("%s: sent", __func__);
00088 }


Variable Documentation

Authmethod method_none
 

Initial value:

 {
        "none",
        userauth_none,
        &none_enabled
}

Definition at line 122 of file auth2-none.c.

int none_enabled = 1 [static]
 

Definition at line 42 of file auth2-none.c.

Referenced by userauth_none().

ServerOptions options
 

Definition at line 110 of file ssh.c.


© sourcejam.com 2005-2008