mirror of
https://github.com/osmarks/ngircd.git
synced 2025-05-21 16:44:09 +00:00
Move client password from the Client to the Connection struct.
This is a relatively naive implementation, basically doing the bare minimum necessary to make the switchover go. Subsequent commits can focus on improving the implementation.
This commit is contained in:
parent
4cf65b973c
commit
0d5de60584
@ -440,18 +440,6 @@ Client_SetFlags( CLIENT *Client, const char *Flags )
|
|||||||
} /* Client_SetFlags */
|
} /* Client_SetFlags */
|
||||||
|
|
||||||
|
|
||||||
GLOBAL void
|
|
||||||
Client_SetPassword( CLIENT *Client, const char *Pwd )
|
|
||||||
{
|
|
||||||
/* set password sent by client */
|
|
||||||
|
|
||||||
assert( Client != NULL );
|
|
||||||
assert( Pwd != NULL );
|
|
||||||
|
|
||||||
strlcpy(Client->pwd, Pwd, sizeof(Client->pwd));
|
|
||||||
} /* Client_SetPassword */
|
|
||||||
|
|
||||||
|
|
||||||
GLOBAL void
|
GLOBAL void
|
||||||
Client_SetAway( CLIENT *Client, const char *Txt )
|
Client_SetAway( CLIENT *Client, const char *Txt )
|
||||||
{
|
{
|
||||||
@ -714,14 +702,6 @@ Client_HostnameCloaked(CLIENT *Client)
|
|||||||
} /* Client_HostnameCloaked */
|
} /* Client_HostnameCloaked */
|
||||||
|
|
||||||
|
|
||||||
GLOBAL char *
|
|
||||||
Client_Password( CLIENT *Client )
|
|
||||||
{
|
|
||||||
assert( Client != NULL );
|
|
||||||
return Client->pwd;
|
|
||||||
} /* Client_Password */
|
|
||||||
|
|
||||||
|
|
||||||
GLOBAL char *
|
GLOBAL char *
|
||||||
Client_Modes( CLIENT *Client )
|
Client_Modes( CLIENT *Client )
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,6 @@ typedef struct _CLIENT
|
|||||||
CONN_ID conn_id; /* ID of the connection (if local) or NONE (remote) */
|
CONN_ID conn_id; /* ID of the connection (if local) or NONE (remote) */
|
||||||
struct _CLIENT *introducer; /* ID of the servers which the client is connected to */
|
struct _CLIENT *introducer; /* ID of the servers which the client is connected to */
|
||||||
struct _CLIENT *topserver; /* toplevel servers (only valid if client is a server) */
|
struct _CLIENT *topserver; /* toplevel servers (only valid if client is a server) */
|
||||||
char pwd[CLIENT_PASS_LEN]; /* password received of the client */
|
|
||||||
char host[CLIENT_HOST_LEN]; /* hostname of the client */
|
char host[CLIENT_HOST_LEN]; /* hostname of the client */
|
||||||
char user[CLIENT_USER_LEN]; /* user name ("login") */
|
char user[CLIENT_USER_LEN]; /* user name ("login") */
|
||||||
#if defined(PAM) && defined(IDENTAUTH)
|
#if defined(PAM) && defined(IDENTAUTH)
|
||||||
@ -109,7 +108,6 @@ GLOBAL char *Client_OrigUser PARAMS(( CLIENT *Client ));
|
|||||||
#endif
|
#endif
|
||||||
GLOBAL char *Client_Hostname PARAMS(( CLIENT *Client ));
|
GLOBAL char *Client_Hostname PARAMS(( CLIENT *Client ));
|
||||||
GLOBAL char *Client_HostnameCloaked PARAMS(( CLIENT *Client ));
|
GLOBAL char *Client_HostnameCloaked PARAMS(( CLIENT *Client ));
|
||||||
GLOBAL char *Client_Password PARAMS(( CLIENT *Client ));
|
|
||||||
GLOBAL char *Client_Modes PARAMS(( CLIENT *Client ));
|
GLOBAL char *Client_Modes PARAMS(( CLIENT *Client ));
|
||||||
GLOBAL char *Client_Flags PARAMS(( CLIENT *Client ));
|
GLOBAL char *Client_Flags PARAMS(( CLIENT *Client ));
|
||||||
GLOBAL CLIENT *Client_Introducer PARAMS(( CLIENT *Client ));
|
GLOBAL CLIENT *Client_Introducer PARAMS(( CLIENT *Client ));
|
||||||
@ -129,7 +127,6 @@ GLOBAL void Client_SetID PARAMS(( CLIENT *Client, const char *Nick ));
|
|||||||
GLOBAL void Client_SetUser PARAMS(( CLIENT *Client, const char *User, bool Idented ));
|
GLOBAL void Client_SetUser PARAMS(( CLIENT *Client, const char *User, bool Idented ));
|
||||||
GLOBAL void Client_SetOrigUser PARAMS(( CLIENT *Client, const char *User ));
|
GLOBAL void Client_SetOrigUser PARAMS(( CLIENT *Client, const char *User ));
|
||||||
GLOBAL void Client_SetInfo PARAMS(( CLIENT *Client, const char *Info ));
|
GLOBAL void Client_SetInfo PARAMS(( CLIENT *Client, const char *Info ));
|
||||||
GLOBAL void Client_SetPassword PARAMS(( CLIENT *Client, const char *Pwd ));
|
|
||||||
GLOBAL void Client_SetType PARAMS(( CLIENT *Client, int Type ));
|
GLOBAL void Client_SetType PARAMS(( CLIENT *Client, int Type ));
|
||||||
GLOBAL void Client_SetHops PARAMS(( CLIENT *Client, int Hops ));
|
GLOBAL void Client_SetHops PARAMS(( CLIENT *Client, int Hops ));
|
||||||
GLOBAL void Client_SetToken PARAMS(( CLIENT *Client, int Token ));
|
GLOBAL void Client_SetToken PARAMS(( CLIENT *Client, int Token ));
|
||||||
|
@ -918,6 +918,20 @@ va_dcl
|
|||||||
return ok;
|
return ok;
|
||||||
} /* Conn_WriteStr */
|
} /* Conn_WriteStr */
|
||||||
|
|
||||||
|
GLOBAL const char*
|
||||||
|
Conn_Password( CONN_ID Idx )
|
||||||
|
{
|
||||||
|
assert( Idx > NONE );
|
||||||
|
return My_Connections[Idx].pwd;
|
||||||
|
} /* Conn_Password */
|
||||||
|
|
||||||
|
GLOBAL void
|
||||||
|
Conn_SetPassword( CONN_ID Idx, const char *Pwd )
|
||||||
|
{
|
||||||
|
assert( Idx > NONE );
|
||||||
|
strlcpy( My_Connections[Idx].pwd, Pwd,
|
||||||
|
sizeof(My_Connections[Idx].pwd) );
|
||||||
|
} /* Conn_SetPassword */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append Data to the outbound write buffer of a connection.
|
* Append Data to the outbound write buffer of a connection.
|
||||||
|
@ -72,6 +72,7 @@ typedef struct _Connection
|
|||||||
ng_ipaddr_t addr; /* Client address */
|
ng_ipaddr_t addr; /* Client address */
|
||||||
PROC_STAT proc_stat; /* Status of resolver process */
|
PROC_STAT proc_stat; /* Status of resolver process */
|
||||||
char host[HOST_LEN]; /* Hostname */
|
char host[HOST_LEN]; /* Hostname */
|
||||||
|
char pwd[CLIENT_PASS_LEN]; /* password received of the client */
|
||||||
array rbuf; /* Read buffer */
|
array rbuf; /* Read buffer */
|
||||||
array wbuf; /* Write buffer */
|
array wbuf; /* Write buffer */
|
||||||
time_t signon; /* Signon ("connect") time */
|
time_t signon; /* Signon ("connect") time */
|
||||||
@ -115,6 +116,9 @@ GLOBAL void Conn_Handler PARAMS(( void ));
|
|||||||
|
|
||||||
GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, const char *Format, ... ));
|
GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, const char *Format, ... ));
|
||||||
|
|
||||||
|
GLOBAL const char* Conn_Password PARAMS(( CONN_ID Idx ));
|
||||||
|
GLOBAL void Conn_SetPassword PARAMS(( CONN_ID Idx, const char *Pwd ));
|
||||||
|
|
||||||
GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, const char *LogMsg, const char *FwdMsg, bool InformClient ));
|
GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, const char *LogMsg, const char *FwdMsg, bool InformClient ));
|
||||||
|
|
||||||
GLOBAL void Conn_SyncServerStruct PARAMS(( void ));
|
GLOBAL void Conn_SyncServerStruct PARAMS(( void ));
|
||||||
|
@ -87,7 +87,7 @@ IRC_PASS( CLIENT *Client, REQUEST *Req )
|
|||||||
Client_ID(Client));
|
Client_ID(Client));
|
||||||
}
|
}
|
||||||
|
|
||||||
Client_SetPassword(Client, Req->argv[0]);
|
Conn_SetPassword(Client_Conn(Client), Req->argv[0]);
|
||||||
|
|
||||||
/* Protocol version */
|
/* Protocol version */
|
||||||
if (Req->argc >= 2 && strlen(Req->argv[1]) >= 4) {
|
if (Req->argc >= 2 && strlen(Req->argv[1]) >= 4) {
|
||||||
|
@ -80,7 +80,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
|
|||||||
Conn_Close( Client_Conn( Client ), NULL, "Server not configured here", true);
|
Conn_Close( Client_Conn( Client ), NULL, "Server not configured here", true);
|
||||||
return DISCONNECTED;
|
return DISCONNECTED;
|
||||||
}
|
}
|
||||||
if( strcmp( Client_Password( Client ), Conf_Server[i].pwd_in ) != 0 )
|
if( strcmp( Conn_Password( Client_Conn( Client ) ), Conf_Server[i].pwd_in ) != 0 )
|
||||||
{
|
{
|
||||||
/* wrong password */
|
/* wrong password */
|
||||||
Log( LOG_ERR, "Connection %d: Got bad password from server \"%s\"!", Client_Conn( Client ), Req->argv[0] );
|
Log( LOG_ERR, "Connection %d: Got bad password from server \"%s\"!", Client_Conn( Client ), Req->argv[0] );
|
||||||
|
@ -93,13 +93,14 @@ Login_User(CLIENT * Client)
|
|||||||
* the beahiour of the daemon compiled without PAM support:
|
* the beahiour of the daemon compiled without PAM support:
|
||||||
* because there can't be any "server password", all
|
* because there can't be any "server password", all
|
||||||
* passwords supplied are classified as "wrong". */
|
* passwords supplied are classified as "wrong". */
|
||||||
if(Client_Password(Client)[0] == '\0')
|
if(Conn_Password(Client_Conn(Client))[0] == '\0')
|
||||||
return Login_User_PostAuth(Client);
|
return Login_User_PostAuth(Client);
|
||||||
Client_Reject(Client, "Non-empty password", false);
|
Client_Reject(Client, "Non-empty password", false);
|
||||||
return DISCONNECTED;
|
return DISCONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Conf_PAMIsOptional && strcmp(Client_Password(Client), "") == 0) {
|
if (Conf_PAMIsOptional &&
|
||||||
|
strcmp(Conn_Password(Client_Conn(Client)), "") == 0) {
|
||||||
/* Clients are not required to send a password and to be PAM-
|
/* Clients are not required to send a password and to be PAM-
|
||||||
* authenticated at all. If not, they won't become "identified"
|
* authenticated at all. If not, they won't become "identified"
|
||||||
* and keep the "~" in their supplied user name.
|
* and keep the "~" in their supplied user name.
|
||||||
@ -129,7 +130,7 @@ Login_User(CLIENT * Client)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Check global server password ... */
|
/* Check global server password ... */
|
||||||
if (strcmp(Client_Password(Client), Conf_ServerPwd) != 0) {
|
if (strcmp(Conn_Password(Client_Conn(Client)), Conf_ServerPwd) != 0) {
|
||||||
/* Bad password! */
|
/* Bad password! */
|
||||||
Client_Reject(Client, "Bad server password", false);
|
Client_Reject(Client, "Bad server password", false);
|
||||||
return DISCONNECTED;
|
return DISCONNECTED;
|
||||||
|
@ -102,8 +102,8 @@ PAM_Authenticate(CLIENT *Client) {
|
|||||||
/* Set supplied client password */
|
/* Set supplied client password */
|
||||||
if (password)
|
if (password)
|
||||||
free(password);
|
free(password);
|
||||||
password = strdup(Client_Password(Client));
|
password = strdup(Conn_Password(Client_Conn(Client)));
|
||||||
conv.appdata_ptr = Client_Password(Client);
|
conv.appdata_ptr = Conn_Password(Client_Conn(Client));
|
||||||
|
|
||||||
/* Initialize PAM */
|
/* Initialize PAM */
|
||||||
retval = pam_start("ngircd", Client_OrigUser(Client), &conv, &pam);
|
retval = pam_start("ngircd", Client_OrigUser(Client), &conv, &pam);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user