Exemplo n.º 1
0
static int is_subscriber(sip_msg_t *msg, str *suri, str *stable, int iflags)
{
	int ret;
	sip_uri_t puri;

	if (suri->len<=0) {
		LM_ERR("invalid uri parameter - empty value\n");
		return -1;
	}
	if(parse_uri(suri->s, suri->len, &puri)<0){
		LM_ERR("invalid uri parameter format\n");
		return -1;
	}
	if (stable->len<=0) {
		LM_ERR("invalid table parameter - empty value\n");
		return -1;
	}

	LM_DBG("uri [%.*s] table [%.*s] flags [%d]\n", suri->len, suri->s,
			stable->len,  stable->s, iflags);
	ret = fetch_credentials(msg, &puri.user,
				(iflags&AUTH_DB_SUBS_USE_DOMAIN)?&puri.host:NULL,
				stable, iflags);

	if(ret>=0)
		return 1;
	return ret;
}
Exemplo n.º 2
0
/**
 * check if the subscriber identified by _uri has a valid record in
 * database table _table
 */
static int w_is_subscriber(sip_msg_t *msg, char *_uri, char* _table,
		char *_flags)
{
	str suri;
	str stable;
	int iflags;
	int ret;
	sip_uri_t puri;

	if(msg==NULL || _uri==NULL || _table==NULL || _flags==NULL) {
		LM_ERR("invalid parameters\n");
		return AUTH_ERROR;
	}

	if (get_str_fparam(&suri, msg, (fparam_t*)_uri) < 0) {
		LM_ERR("failed to get uri value\n");
		return -1;
	}

	if (suri.len==0) {
		LM_ERR("invalid uri parameter - empty value\n");
		return -1;
	}
	if(parse_uri(suri.s, suri.len, &puri)<0){
		LM_ERR("invalid uri parameter format\n");
		return -1;
	}

	if (get_str_fparam(&stable, msg, (fparam_t*)_table) < 0) {
		LM_ERR("failed to get table value\n");
		return -1;
	}

	if (stable.len==0) {
		LM_ERR("invalid table parameter - empty value\n");
		return -1;
	}

	if(fixup_get_ivalue(msg, (gparam_p)_flags, &iflags)!=0)
	{
		LM_ERR("invalid flags parameter\n");
		return -1;
	}

	LM_DBG("uri [%.*s] table [%.*s] flags [%d]\n", suri.len, suri.s,
			stable.len,  stable.s, iflags);
	ret = fetch_credentials(msg, &puri.user, (iflags==1)?&puri.host:NULL,
			&stable);

	if(ret>=0)
		return 1;
	return ret;
}
Exemplo n.º 3
0
void
send_bh_or_ld(char const *bhmessage, ntlm_authenticate * failedauth, int authlen)
{
#ifdef NTLM_FAIL_OPEN
    char *creds = NULL;
    if (last_ditch_enabled) {
        creds = fetch_credentials(failedauth, authlen);
        if (creds) {
            lc(creds);
            SEND2("LD %s", creds);
        } else {
            SEND("NA last-ditch on, but no credentials");
        }
    } else {
#endif
        SEND2("BH %s", bhmessage);
#ifdef NTLM_FAIL_OPEN
    }
#endif
}