Ejemplo n.º 1
0
Archivo: account.c Proyecto: 91D2/pvpgn
static t_account * account_create3(char const * username, char const * passhash1, char const * email)
{
    t_account * account;
    
    if (username && !passhash1) {
	eventlog(eventlog_level_error,__FUNCTION__,"got NULL passhash1");
	return NULL;
    }

    if (username && account_check_name(username)) {
	eventlog(eventlog_level_error,__FUNCTION__,"got invalid chars in username");
	return NULL;
    }

    account = xmalloc(sizeof(t_account));

    account->name     = NULL;
    account->clanmember = NULL;
    account->attrgroup   = NULL;
    account->friends  = NULL;
    account->teams    = NULL;
    account->conn = NULL;
    FLAG_ZERO(&account->flags);

    account->namehash = 0; /* hash it later before inserting */
    account->uid      = 0; /* hash it later before inserting */

    if (username) { /* actually making a new account */
	/* first check if such a username already owns an account.
	 * we search in the memory hash mainly for non-indexed storage types.
	 * indexed storage types check themselves if the username exists already 
	 * in the storage (see storage_sql.c) */
	if (accountlist_find_account(username)) {
		eventlog(eventlog_level_debug,__FUNCTION__,"user \"%s\" already has an account",username);
		goto err;
	}

	account->attrgroup =  attrgroup_create_newuser(username);
	if(!account->attrgroup) {
	    eventlog(eventlog_level_error,__FUNCTION__,"failed to add user");
	    goto err;
	}

	account->name = xstrdup(username);

        if (account_set_strattr(account,"BNET\\acct\\username",username)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set username");
            goto err;
        }

        if (account_set_numattr(account,"BNET\\acct\\userid",maxuserid+1)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set userid");
            goto err;
        }

		if (account_set_strattr(account,"BNET\\acct\\passhash1",passhash1)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set passhash1");
            goto err;
        }

        if (account_set_numattr(account,"BNET\\acct\\ctime",(unsigned int)now)) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set ctime");
            goto err;
        }

		if (account_set_strattr(account,"BNET\\acct\\email",email)<0) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set email");
            goto err;
        }

        if (account_set_numattr(account,"BNET\\auth\\vip_expire",(unsigned int)now+prefs_get_vip_experience())) {
            eventlog(eventlog_level_error,__FUNCTION__,"could not set vip_expire");
            goto err;
        }
    }

    return account;

err:
    account_destroy(account);
    return NULL;
}
Ejemplo n.º 2
0
Archivo: vm.c Proyecto: Hooman3/minix
#include "inc.h"

#include <sys/mman.h>
#include <sys/resource.h>

static int
vm_brk_out(struct trace_proc * proc, const message * m_out)
{

	put_ptr(proc, "addr", (vir_bytes)m_out->m_lc_vm_brk.addr);

	return CT_DONE;
}

static const struct flags mmap_prot[] = {
	FLAG_ZERO(PROT_NONE),
	FLAG(PROT_READ),
	FLAG(PROT_WRITE),
	FLAG(PROT_EXEC),
};

static const struct flags mmap_flags[] = {
	FLAG(MAP_SHARED),
	FLAG(MAP_PRIVATE),
	FLAG(MAP_FIXED),
	FLAG(MAP_RENAME),
	FLAG(MAP_NORESERVE),
	FLAG(MAP_INHERIT),
	FLAG(MAP_HASSEMAPHORE),
	FLAG(MAP_TRYFIXED),
	FLAG(MAP_WIRED),