Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 570a9466 authored by rswindell's avatar rswindell
Browse files

Added usernum member to client_t which tracks if the client_t.user (name)

is actually an authenticated local user (when usernum != 0).

msg_client_hfields() no longer saves the client->user as the SMB SENDERUSERID
hfield when the client hasn't been authenticated (as is the case with normal
SMTP). The SENDUSERIDs were redundant and misleading for unauthenticated
SMTP-received mail messages, so that's now fixed.
parent e3dedf97
......@@ -51,6 +51,7 @@ typedef struct {
time32_t time; /* connect time */
const char* protocol; /* protocol description */
const char* user; /* user name */
uint32_t usernum; /* user number (authenticated when non-zero) */
} client_t;
/* Used for ctrl/client.dab */
......
......@@ -3142,6 +3142,7 @@ static void ctrl_thread(void* arg)
client.port=inet_addrport(&ftp.client_addr);
client.protocol="FTP";
client.user=STR_UNKNOWN_USER;
client.usernum = 0;
client_on(sock,&client,FALSE /* update */);
if(startup->login_attempt.throttle
......@@ -3408,6 +3409,7 @@ static void ctrl_thread(void* arg)
sprintf(str,"%s <%.32s>",user.alias,password);
client.user=str;
}
client.usernum = user.number;
client_on(sock,&client,TRUE /* update */);
lprintf(LOG_INFO,"%04d <%s> logged in (%u today, %u total)"
......
......@@ -63,6 +63,7 @@ bool sbbs_t::logon()
return(false);
client.user=useron.alias;
client.usernum = useron.number;
client_on(client_socket,&client,TRUE /* update */);
#ifdef JAVASCRIPT
......
......@@ -1105,6 +1105,7 @@ static void pop3_thread(void* arg)
SAFECOPY(client.host,host_name);
client.port=inet_addrport(&pop3.client_addr);
client.user=STR_UNKNOWN_USER;
client.usernum = 0;
client_on(socket,&client,FALSE /* update */);
SAFEPRINTF2(str,"%s: %s", client.protocol, host_ip);
......@@ -1291,6 +1292,7 @@ static void pop3_thread(void* arg)
/* Update client display */
client.user=user.alias;
client.usernum = user.number;
client_on(socket,&client,TRUE /* update */);
activity=FALSE;
......@@ -3149,6 +3151,7 @@ static void smtp_thread(void* arg)
SAFECOPY(client.host,host_name);
client.port=inet_addrport(&smtp.client_addr);
client.user=STR_UNKNOWN_USER;
client.usernum = 0;
client_on(socket,&client,FALSE /* update */);
SAFEPRINTF(str,"SMTP: %s",host_ip);
......@@ -4169,6 +4172,7 @@ static void smtp_thread(void* arg)
/* Update client display */
client.user=relay_user.alias;
client.usernum = relay_user.number;
client_on(socket,&client,TRUE /* update */);
lprintf(LOG_INFO,"%04d %s %s authenticated using %s authentication"
......@@ -4256,6 +4260,7 @@ static void smtp_thread(void* arg)
/* Update client display */
client.user=relay_user.alias;
client.usernum = relay_user.number;
client_on(socket,&client,TRUE /* update */);
lprintf(LOG_INFO,"%04d %s %s authenticated using CRAM-MD5 authentication"
......
......@@ -5645,6 +5645,7 @@ NO_SSH:
SAFECOPY(client.host,host_name);
client.port=inet_addrport(&client_addr);
client.user=STR_UNKNOWN_USER;
client.usernum = 0;
client_on(client_socket,&client,FALSE /* update */);
for(i=first_node;i<=last_node;i++) {
......
......@@ -358,7 +358,7 @@ extern "C" int DLLCALL msg_client_hfields(smbmsg_t* msg, client_t* client)
if(client==NULL)
return(-1);
if(client->user!=NULL && (i=smb_hfield_str(msg,SENDERUSERID,client->user))!=SMB_SUCCESS)
if(client->user!=NULL && client->usernum && (i=smb_hfield_str(msg,SENDERUSERID,client->user))!=SMB_SUCCESS)
return(i);
if(client->time
&& (i=smb_hfield_str(msg,SENDERTIME,xpDateTime_to_isoDateTimeStr(gmtime_to_xpDateTime(client->time)
......
......@@ -442,6 +442,7 @@ js_login(JSContext *cx, uintN argc, jsval *arglist)
if(client->client!=NULL) {
client->client->user=client->user.alias;
client->client->usernum = client->user.number;
client_on(client->socket,client->client,TRUE /* update */);
}
......@@ -621,6 +622,7 @@ js_client_add(JSContext *cx, uintN argc, jsval *arglist)
client.protocol=service_client->service->protocol;
client.time=time32(NULL);
client.user=STR_UNKNOWN_USER;
client.usernum = 0;
SAFECOPY(client.host,client.user);
sock=js_socket(cx,argv[0]);
......@@ -1085,6 +1087,7 @@ static void js_service_thread(void* arg)
client.port=inet_addrport(&service_client.addr);
client.protocol=service->protocol;
client.user=STR_UNKNOWN_USER;
client.usernum = 0;
service_client.client=&client;
/* Initialize client display */
......@@ -1435,6 +1438,7 @@ static void native_service_thread(void* arg)
client.port=inet_addrport(&service_client.addr);
client.protocol=service->protocol;
client.user=STR_UNKNOWN_USER;
client.usernum = 0;
#ifdef _WIN32
if(!DuplicateHandle(GetCurrentProcess(),
......
......@@ -1613,6 +1613,7 @@ void http_logon(http_session_t * session, user_t *usr)
putuserdat(&scfg, &session->user);
}
session->client.user=session->username;
session->client.usernum = session->user.number;
client_on(session->socket, &session->client, /* update existing client record? */TRUE);
session->last_user_num=session->user.number;
......@@ -6462,6 +6463,7 @@ void http_session_thread(void* arg)
session.client.protocol=session.is_tls ? "HTTPS":"HTTP";
session.client.user=session.username;
session.client.size=sizeof(session.client);
session.client.usernum = 0;
client_on(session.socket, &session.client, /* update existing client record? */FALSE);
if(startup->login_attempt.throttle
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment