Freeciv-3.2
Loading...
Searching...
No Matches
Macros | Functions | Variables
auth.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "fcintl.h"
#include "log.h"
#include "md5.h"
#include "registry.h"
#include "shared.h"
#include "support.h"
#include "connection.h"
#include "packets.h"
#include "luascript_types.h"
#include "connecthand.h"
#include "fcdb.h"
#include "notify.h"
#include "sernet.h"
#include "srv_main.h"
#include "script_fcdb.h"
#include "auth.h"

Go to the source code of this file.

Macros

#define GUEST_NAME   "guest"
 
#define MIN_PASSWORD_LEN   6 /* minimum length of password */
 
#define MIN_PASSWORD_CAPS   0 /* minimum number of capital letters required */
 
#define MIN_PASSWORD_NUMS   0 /* minimum number of numbers required */
 
#define MAX_AUTH_TRIES   3
 
#define MAX_WAIT_TIME   300 /* max time we'll wait on a password */
 

Functions

static bool is_guest_name (const char *name)
 
static void get_unique_guest_name (char *name)
 
static bool is_good_password (const char *password, char *msg)
 
bool auth_user (struct connection *pconn, char *username)
 
bool auth_handle_reply (struct connection *pconn, char *password)
 
void auth_process_status (struct connection *pconn)
 
const charauth_get_username (struct connection *pconn)
 
const charauth_get_ipaddr (struct connection *pconn)
 

Variables

static const int auth_fail_wait [] = { 1, 1, 2, 3 }
 

Macro Definition Documentation

◆ GUEST_NAME

#define GUEST_NAME   "guest"

Definition at line 49 of file auth.c.

◆ MAX_AUTH_TRIES

#define MAX_AUTH_TRIES   3

Definition at line 55 of file auth.c.

◆ MAX_WAIT_TIME

#define MAX_WAIT_TIME   300 /* max time we'll wait on a password */

Definition at line 56 of file auth.c.

◆ MIN_PASSWORD_CAPS

#define MIN_PASSWORD_CAPS   0 /* minimum number of capital letters required */

Definition at line 52 of file auth.c.

◆ MIN_PASSWORD_LEN

#define MIN_PASSWORD_LEN   6 /* minimum length of password */

Definition at line 51 of file auth.c.

◆ MIN_PASSWORD_NUMS

#define MIN_PASSWORD_NUMS   0 /* minimum number of numbers required */

Definition at line 53 of file auth.c.

Function Documentation

◆ auth_get_ipaddr()

const char * auth_get_ipaddr ( struct connection pconn)

Get connection ip address

Definition at line 358 of file auth.c.

Referenced by api_auth_get_ipaddr().

◆ auth_get_username()

const char * auth_get_username ( struct connection pconn)

Get username for connection

Definition at line 348 of file auth.c.

Referenced by api_auth_get_username().

◆ auth_handle_reply()

bool auth_handle_reply ( struct connection pconn,
char password 
)

Receives a password from a client and verifies it.

Definition at line 156 of file auth.c.

Referenced by server_packet_input().

◆ auth_process_status()

void auth_process_status ( struct connection pconn)

Checks on where in the authentication process we are.

Definition at line 207 of file auth.c.

Referenced by server_sniff_all_input().

◆ auth_user()

bool auth_user ( struct connection pconn,
char username 
)

Handle authentication of a user; called by handle_login_request() if authentication is enabled.

If the connection is rejected right away, return FALSE, otherwise this function will return TRUE.

Definition at line 73 of file auth.c.

Referenced by handle_login_request().

◆ get_unique_guest_name()

static void get_unique_guest_name ( char name)
static

Return a unique guest name WARNING: do not pass pconn->username to this function: it won't return!

Definition at line 266 of file auth.c.

Referenced by auth_user().

◆ is_good_password()

static bool is_good_password ( const char password,
char msg 
)
static

Verifies that a password is valid. Does some [very] rudimentary safety checks. TODO: do we want to frown on non-printing characters? Fill the msg (length MAX_LEN_MSG) with any worthwhile information that the client ought to know.

Definition at line 301 of file auth.c.

Referenced by auth_handle_reply().

◆ is_guest_name()

static bool is_guest_name ( const char name)
static

See if the name qualifies as a guest login name

Definition at line 257 of file auth.c.

Referenced by auth_user(), and get_unique_guest_name().

Variable Documentation

◆ auth_fail_wait

const int auth_fail_wait[] = { 1, 1, 2, 3 }
static

Definition at line 60 of file auth.c.

Referenced by auth_handle_reply().