Beispiel #1
0
void SV_RemoveAccount_f(void)
{
	int i, c;

	if (Cmd_Argc() < 2)
	{
		Con_Printf("usage: acc_remove <login>\n");
		return;
	}

	for (i = 0, c = 0; c < num_accounts; i++)
	{
		if (accounts[i].state == a_free)
			continue;

		if (!strcasecmp(accounts[i].login, Cmd_Argv(1)))
		{
			if (accounts[i].inuse)
				SV_Logout(&svs.clients[accounts[i].inuse -1]);

			accounts[i].state = a_free;
			num_accounts--;
			Con_Printf("login %s removed\n", accounts[i].login);
			WriteAccounts();
			return;
		}

		c++;
	}

	Con_Printf("account for %s not found\n", Cmd_Argv(1));
}
Beispiel #2
0
void Plugin::handleAuthSuccess (QObject *accObj)
{
    Account_ptr acc (qobject_cast<Account*> (accObj));
    Accounts_ << acc;
    WriteAccounts ();
    emit accountAdded (accObj);
}
Beispiel #3
0
void SV_BlockAccount_f(void)
{
	if (Cmd_Argc() < 2)
	{
		Con_Printf("usage: acc_block <login>\n");
		return;
	}

	SV_blockAccount(true);
	WriteAccounts();
}
	void Plugin::RegisterAccount (const QString& accName)
	{
		Account_ptr acc (new Account (this));
		acc->SetAccountName (accName);

		if (!acc->ExecConfigDialog ())
			return;

		Accounts_ << acc;
		WriteAccounts ();
		emit accountAdded (acc.get ());
	}
Beispiel #5
0
void Plugin::RemoveAccount (QObject *accObj)
{
    auto pos = std::find_if (Accounts_.begin (), Accounts_.end (),
                             [accObj] (decltype (Accounts_.front ()) acc)
    {
        return acc.get () == accObj;
    });
    if (pos == Accounts_.end ())
        return;

    emit accountRemoved (accObj);
    Accounts_.erase (pos);
    WriteAccounts ();
}
Beispiel #6
0
/*
=================
checklogin

returns positive value if login/pass are valid
values <= 0 indicates a failure
=================
*/
static int checklogin(char *log1, char *pass, int num, quse_t use)
{
	int i,c;

	for (i = 0, c = 0; c < num_accounts; i++)
	{
		if (accounts[i].state == a_free)
			continue;

		if (use == accounts[i].use &&
		        /*use == use_log && accounts[i].use == use_log && */
			!strcasecmp(log1, accounts[i].login))
		{
			if (accounts[i].inuse && accounts[i].use == use_log)
				return -1;

			if (accounts[i].state == a_blocked)
				return -2;

			if (use == use_ip ||
			        (!(int)sv_hashpasswords.value && !strcasecmp(pass,       accounts[i].pass)) ||
			        ( (int)sv_hashpasswords.value && !strcasecmp(SHA1(pass), accounts[i].pass)))
			{
				accounts[i].failures = 0;
				accounts[i].inuse++;
				return i+1;
			}

			if (++accounts[i].failures >= MAX_FAILURES)
			{
				Sys_Printf("account %s blocked after %d failed login attempts\n", accounts[i].login, accounts[i].failures);
				accounts[i].state = a_blocked;
			}

			WriteAccounts();

			return 0;
		}

		c++;
	}

	return 0;
}
Beispiel #7
0
void SV_CreateAccount_f(void)
{
	int i, spot, c;
	ipfilter_t adr;
	quse_t use;

	if (Cmd_Argc() < 2)
	{
		Con_Printf("usage: acc_create <login> [<password>]\n       acc_create <address> <username>\nmaximum %d characters for login/pass\n", MAX_LOGINNAME - 1); //bliP: adress typo
		return;
	}

	if (num_accounts == MAX_ACCOUNTS)
	{
		Con_Printf("MAX_ACCOUNTS reached\n");
		return;
	}

	if (StringToFilter(Cmd_Argv(1), &adr))
	{
		use = use_ip;
		if (Cmd_Argc() < 3)
		{
			Con_Printf("usage: acc_create <address> <username>\nmaximum %d characters for username\n", MAX_LOGINNAME - 1); //bliP; adress typo
			return;
		}
	}
	else
	{
		use = use_log;

		// validate user login/pass
		if (!validAcc(Cmd_Argv(1)))
		{
			Con_Printf("Invalid login!\n");
			return;
		}

		if (Cmd_Argc() == 4 && !validAcc(Cmd_Argv(2)))
		{
			Con_Printf("Invalid pass!\n");
			return;
		}
	}

	// find free spot, check if login exist;
	for (i = 0, c = 0, spot = -1 ; c < num_accounts; i++)
	{
		if (accounts[i].state == a_free)
		{
			if (spot == -1)	spot = i;
			continue;
		}

		if (!strcasecmp(accounts[i].login, Cmd_Argv(1)) ||
			(use == use_ip && !strcasecmp(accounts[i].login, Cmd_Argv(2))))
			break;

		c++;
	}

	if (c < num_accounts)
	{
		Con_Printf("Login already in use\n");
		return;
	}

	if (spot == -1)
		spot = i;

	// create an account
	num_accounts++;
	strlcpy(accounts[spot].login, Cmd_Argv(1), MAX_LOGINNAME);
	if (Cmd_Argc() == 3)
		i = 2;
	else
		i = 1;
	strlcpy(accounts[spot].pass, (int)sv_hashpasswords.value && use == use_log ?
	        SHA1(Cmd_Argv(i)) : Cmd_Argv(i), MAX_LOGINNAME);

	accounts[spot].state = a_ok;
	accounts[spot].use = use;

	Con_Printf("login %s created\n", Cmd_Argv(1));
	WriteAccounts();
}