Merge branch 'feature/KASM-5213_email_username' into 'master'

Allow emails as usernames

Closes KASM-5213

See merge request kasm-technologies/internal/KasmVNC!115
pull/212/head
Matthew McClaskey 2 years ago
commit b2d965b58d

@ -550,7 +550,7 @@ void GetAPIMessager::netGetBottleneckStats(char *buf, uint32_t len) {
const char *id = it->first.c_str(); const char *id = it->first.c_str();
const char *data = it->second.c_str(); const char *data = it->second.c_str();
const char *at = strchr(id, '@'); const char *at = strrchr(id, '@');
if (!at) if (!at)
continue; continue;

@ -33,7 +33,6 @@
#include <openssl/sha.h> /* sha1 hash */ #include <openssl/sha.h> /* sha1 hash */
#include "websocket.h" #include "websocket.h"
#include "jsonescape.h" #include "jsonescape.h"
#include "kasmpasswd.h"
#include <network/Blacklist.h> #include <network/Blacklist.h>
/* /*
@ -1756,7 +1755,7 @@ ws_ctx_t *do_handshake(int sock, char * const ip) {
} }
unsigned char owner = 0; unsigned char owner = 0;
char inuser[32] = "-"; char inuser[USERNAME_LEN] = "-";
if (!settings.disablebasicauth) { if (!settings.disablebasicauth) {
const char *hdr = strstr(handshake, "Authorization: Basic "); const char *hdr = strstr(handshake, "Authorization: Basic ");
if (!hdr) { if (!hdr) {
@ -1794,7 +1793,7 @@ ws_ctx_t *do_handshake(int sock, char * const ip) {
if (resppw && *resppw) if (resppw && *resppw)
resppw++; resppw++;
if (settings.passwdfile) { if (settings.passwdfile) {
if (resppw && *resppw && resppw - response < 32) { if (resppw && *resppw && resppw - response < USERNAME_LEN + 1) {
char pwbuf[4096]; char pwbuf[4096];
struct kasmpasswd_t *set = readkasmpasswd(settings.passwdfile); struct kasmpasswd_t *set = readkasmpasswd(settings.passwdfile);
if (!set->num) { if (!set->num) {

@ -2,6 +2,7 @@
#include <stdint.h> #include <stdint.h>
#include "GetAPIEnums.h" #include "GetAPIEnums.h"
#include "datelog.h" #include "datelog.h"
#include "kasmpasswd.h"
#define BUFSIZE 65536 #define BUFSIZE 65536
#define DBUFSIZE (BUFSIZE * 3) / 4 - 20 #define DBUFSIZE (BUFSIZE * 3) / 4 - 20
@ -57,7 +58,7 @@ typedef struct {
char *tin_buf; char *tin_buf;
char *tout_buf; char *tout_buf;
char user[32]; char user[USERNAME_LEN];
char ip[64]; char ip[64];
} ws_ctx_t; } ws_ctx_t;

@ -88,8 +88,8 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
wordfree(&wexp); wordfree(&wexp);
user[0] = '\0'; user[0] = '\0';
const char *at = strchr(peerEndpoint.buf, '@'); const char *at = strrchr(peerEndpoint.buf, '@');
if (at && at - peerEndpoint.buf > 1 && at - peerEndpoint.buf < 32) { if (at && at - peerEndpoint.buf > 1 && at - peerEndpoint.buf < USERNAME_LEN) {
memcpy(user, peerEndpoint.buf, at - peerEndpoint.buf); memcpy(user, peerEndpoint.buf, at - peerEndpoint.buf);
user[at - peerEndpoint.buf] = '\0'; user[at - peerEndpoint.buf] = '\0';
} }
@ -1635,7 +1635,7 @@ void VNCSConnectionST::sendStats(const bool toClient) {
void VNCSConnectionST::handleFrameStats(rdr::U32 all, rdr::U32 render) void VNCSConnectionST::handleFrameStats(rdr::U32 all, rdr::U32 render)
{ {
if (server->apimessager) { if (server->apimessager) {
const char *at = strchr(peerEndpoint.buf, '@'); const char *at = strrchr(peerEndpoint.buf, '@');
if (!at) if (!at)
at = peerEndpoint.buf; at = peerEndpoint.buf;
else else

@ -35,6 +35,8 @@
#include <rfb/Timer.h> #include <rfb/Timer.h>
#include <rfb/unixRelayLimits.h> #include <rfb/unixRelayLimits.h>
#include "kasmpasswd.h"
namespace rfb { namespace rfb {
class VNCServerST; class VNCServerST;
@ -318,7 +320,7 @@ namespace rfb {
rdr::U64 bstats_total[BS_NUM]; rdr::U64 bstats_total[BS_NUM];
struct timeval connStart; struct timeval connStart;
char user[32]; char user[USERNAME_LEN];
char kasmpasswdpath[4096]; char kasmpasswdpath[4096];
bool needsPermCheck; bool needsPermCheck;

@ -814,7 +814,7 @@ static void upgradeClientToUdp(const network::GetAPIMessager::action_data &act,
inet_ntop(AF_INET, &act.udp.ip, buf, 32); inet_ntop(AF_INET, &act.udp.ip, buf, 32);
const char * const who = (*ci)->getPeerEndpoint(); const char * const who = (*ci)->getPeerEndpoint();
const char *start = strchr(who, '@'); const char *start = strrchr(who, '@');
if (!start) if (!start)
continue; continue;
start++; start++;

@ -6,7 +6,7 @@ extern "C" {
#endif #endif
struct kasmpasswd_entry_t { struct kasmpasswd_entry_t {
char user[32]; char user[128];
char password[128]; char password[128];
unsigned char read : 1; unsigned char read : 1;
unsigned char write : 1; unsigned char write : 1;

Loading…
Cancel
Save