示例#1
0
文件: auxprop.c 项目: 1ack/Impala
/* add an auxiliary property plugin */
int sasl_auxprop_add_plugin(const char *plugname,
			    sasl_auxprop_init_t *auxpropfunc)
{
    int result, out_version;
    auxprop_plug_list_t *new_item;
    sasl_auxprop_plug_t *plug;
    
    result = auxpropfunc(sasl_global_utils, SASL_AUXPROP_PLUG_VERSION,
			 &out_version, &plug, plugname);

    if(result != SASL_OK) {
	_sasl_log(NULL, SASL_LOG_ERR, "auxpropfunc error %s\n",
		  sasl_errstring(result, NULL, NULL));
	return result;
    }

    /* We require that this function is implemented */
    if(!plug->auxprop_lookup) return SASL_BADPROT;

    new_item = sasl_ALLOC(sizeof(auxprop_plug_list_t));
    if(!new_item) return SASL_NOMEM;    

    /* These will load from least-important to most important */
    new_item->plug = plug;
    new_item->next = auxprop_head;
    auxprop_head = new_item;

    return SASL_OK;
}
示例#2
0
/* loads a plugin library */
int _sasl_get_plugin(const char *file,
		     const sasl_callback_t *verifyfile_cb,
		     void **libraryptr)
{
    int r = 0;
    HINSTANCE library;
    lib_list_t *newhead;
    
    r = ((sasl_verifyfile_t *)(verifyfile_cb->proc))
		    (verifyfile_cb->context, file, SASL_VRFY_PLUGIN);
    if (r != SASL_OK) return r;

    newhead = sasl_ALLOC(sizeof(lib_list_t));
    if (!newhead) return SASL_NOMEM;

    if (!(library = LoadLibrary (file))) {
	_sasl_log(NULL, SASL_LOG_ERR,
		  "unable to LoadLibrary %s: %s", file, GetLastError());
	sasl_FREE(newhead);
	return SASL_FAIL;
    }

    newhead->library = library;
    newhead->next = lib_list_head;
    lib_list_head = newhead;

    *libraryptr = library;
    return SASL_OK;
}
示例#3
0
/* loads a plugin library */
static int _tsasl_get_plugin(TCHAR *tfile,
    const sasl_callback_t *verifyfile_cb,
    void **libraryptr)
{
    HINSTANCE library = NULL;
    lib_list_t *newhead;
    char *file;
    int retCode = SASL_OK;

    if (sizeof(TCHAR) != sizeof(char)) {
        file = _sasl_wchar_to_utf8(tfile);
        if (!file) {
            retCode = SASL_NOMEM;
            goto cleanup;
        }
    }
    else {
        file = (char*)tfile;
    }
    retCode = ((sasl_verifyfile_t *)(verifyfile_cb->proc))
		    (verifyfile_cb->context, file, SASL_VRFY_PLUGIN);
    if (retCode != SASL_OK)
        goto cleanup;

    newhead = sasl_ALLOC(sizeof(lib_list_t));
    if (!newhead) {
        retCode = SASL_NOMEM;
        goto cleanup;
    }

    if (!(library = LoadLibrary(tfile))) {
	    _sasl_log(NULL, SASL_LOG_ERR,
		      "unable to LoadLibrary %s: %s", file, GetLastError());
	    sasl_FREE(newhead);
        retCode = SASL_FAIL;
        goto cleanup;
    }

    newhead->library = library;
    newhead->next = lib_list_head;
    lib_list_head = newhead;

    *libraryptr = library;
cleanup:
    if (sizeof(TCHAR) != sizeof(char)) {
        sasl_FREE(file);
    }
    return retCode;
}
示例#4
0
文件: auxprop.c 项目: 1ack/Impala
static struct proppool *alloc_proppool(size_t size) 
{
    struct proppool *ret;
    /* minus 1 for the one that is already a part of the array
     * in the struct */
    size_t total_size = sizeof(struct proppool) + size - 1;
    ret = sasl_ALLOC(total_size);
    if(!ret) return NULL;

    memset(ret, 0, total_size);

    ret->size = ret->unused = size;

    return ret;
}
示例#5
0
文件: auxprop.c 项目: 1ack/Impala
/* create a property context
 *  estimate -- an estimate of the storage needed for requests & responses
 *              0 will use module default
 * returns NULL on error
 */
struct propctx *prop_new(unsigned estimate) 
{
    struct propctx *new_ctx;

    if(!estimate) estimate = PROP_DEFAULT * 255;

    new_ctx = sasl_ALLOC(sizeof(struct propctx));
    if(!new_ctx) return NULL;

    if(prop_init(new_ctx, estimate) != SASL_OK) {
	prop_dispose(&new_ctx);
    }

    return new_ctx;
}
示例#6
0
文件: dlopen.c 项目: 1ack/Impala
/* loads a plugin library */
int _sasl_get_plugin(const char *file,
		     const sasl_callback_t *verifyfile_cb,
		     void **libraryptr)
{
#ifdef DO_DLOPEN
    int r = 0;
    int flag;
    void *library;
    lib_list_t *newhead;
    
    r = ((sasl_verifyfile_t *)(verifyfile_cb->proc))
		    (verifyfile_cb->context, file, SASL_VRFY_PLUGIN);
    if (r != SASL_OK) return r;

#ifdef RTLD_NOW
    flag = RTLD_NOW;
#else
    flag = 0;
#endif

    newhead = sasl_ALLOC(sizeof(lib_list_t));
    if(!newhead) return SASL_NOMEM;

    if (!(library = dlopen(file, flag))) {
	_sasl_log(NULL, SASL_LOG_ERR,
		  "unable to dlopen %s: %s", file, dlerror());
	sasl_FREE(newhead);
	return SASL_FAIL;
    }

    newhead->library = library;
    newhead->next = lib_list_head;
    lib_list_head = newhead;

    *libraryptr = library;
    return SASL_OK;
#else
    return SASL_FAIL;
#endif /* DO_DLOPEN */
}
示例#7
0
/* we store the following secret to check plaintext passwords:
 *
 * <salt> \0 <secret>
 *
 * where <secret> = MD5(<salt>, "sasldb", <pass>)
 */
static int _sasl_make_plain_secret(const char *salt, 
				   const char *passwd, size_t passlen,
				   sasl_secret_t **secret)
{
    MD5_CTX ctx;
    unsigned sec_len = 16 + 1 + 16; /* salt + "\0" + hash */

    *secret = (sasl_secret_t *) sasl_ALLOC(sizeof(sasl_secret_t) +
					   sec_len * sizeof(char));
    if (*secret == NULL) {
	return SASL_NOMEM;
    }

    _sasl_MD5Init(&ctx);
    _sasl_MD5Update(&ctx, salt, 16);
    _sasl_MD5Update(&ctx, "sasldb", 6);
    _sasl_MD5Update(&ctx, passwd, (unsigned int) passlen);
    memcpy((*secret)->data, salt, 16);
    (*secret)->data[16] = '\0';
    _sasl_MD5Final((*secret)->data + 17, &ctx);
    (*secret)->len = sec_len;
    
    return SASL_OK;
}