コード例 #1
0
static int
Context_setTimeout (Context *self, PyObject *value, void *closure)
{
#if PY_MAJOR_VERSION < 3
  if (!PyInt_Check (value))
#else
  if (!PyLong_Check (value))
#endif
    {
      PyErr_SetString (PyExc_TypeError, "must be long");
      return -1;
    }

#if PY_MAJOR_VERSION < 3
  smbc_setTimeout (self->context, PyInt_AsLong (value));
#else
  smbc_setTimeout (self->context, PyLong_AsLong (value));
#endif
  return 0;
}
コード例 #2
0
SmbFs::SmbFs(QString name, QObject *parent)
		: BaseFs(name,parent)
{
	_ctx = smbc_new_context();
	smbc_setTimeout(_ctx,10000);
	smbc_setOptionUserData(_ctx,this); //set this class as the user data, so we can get it from the auth function
	smbc_setOptionOneSharePerServer(_ctx,true);
	smbc_setFunctionAuthDataWithContext(_ctx,auth_fn); //set the authentication function
	_ctx = smbc_init_context(_ctx);
	if(_ctx == NULL) qDebug() << "Null Context!" << strerror(errno);
}
コード例 #3
0
ファイル: smb.c プロジェクト: CroweCybersecurity/shareenum
static SMBCCTX* create_context(void) {
	SMBCCTX  		*ctx;
	extern int 		gTimeout;
	extern int 		gPassIsHash;

	//Create the Samba context struct , if it didn't work quit. 
	if((ctx = smbc_new_context()) == NULL)
		return NULL;

#ifdef DEBUG
	//Set the options for our context.  a
	//If its enabled at the command line, turn on Samba library debugging
	smbc_setDebug(ctx, 1);

	//We want to log our errors to STDERR instead of STDOUT
	smbc_setOptionDebugToStderr(ctx, 1);
#endif

	//Set the function that the Samba library will call when it needs
	//to authenticate
	smbc_setFunctionAuthData(ctx, auth_fn);
	//Set the timeout, we get the command line option as seconds and the 
	//function takes milliseconds.
	smbc_setTimeout(ctx, 200);
	//If we got a hash at the command line, let the context know we're
	//giving it a hash
	smbc_setOptionUseNTHash(ctx, gPassIsHash);

	//Initialize our context with the options that we have set or null on fail.
	if(smbc_init_context(ctx) == NULL) {
		smbc_free_context(ctx, 1);
		return NULL;
	}

	return ctx;
}
コード例 #4
0
ファイル: libsmb_context.c プロジェクト: 0x24bin/winexe-1
/*
 * Get a new empty handle to fill in with your own info
 */
SMBCCTX *
smbc_new_context(void)
{
        SMBCCTX *context;
        
        /* The first call to this function should initialize the module */
        SMB_THREAD_ONCE(&SMBC_initialized, SMBC_module_init, NULL);

        /*
         * All newly added context fields should be placed in
         * SMBC_internal_data, not directly in SMBCCTX.
         */
        context = SMB_MALLOC_P(SMBCCTX);
        if (!context) {
                errno = ENOMEM;
                return NULL;
        }
        
        ZERO_STRUCTP(context);
        
        context->internal = SMB_MALLOC_P(struct SMBC_internal_data);
        if (!context->internal) {
                SAFE_FREE(context);
                errno = ENOMEM;
                return NULL;
        }
        
        /* Initialize the context and establish reasonable defaults */
        ZERO_STRUCTP(context->internal);
        
        smbc_setDebug(context, 0);
        smbc_setTimeout(context, 20000);
        
        smbc_setOptionFullTimeNames(context, False);
        smbc_setOptionOpenShareMode(context, SMBC_SHAREMODE_DENY_NONE);
        smbc_setOptionSmbEncryptionLevel(context, SMBC_ENCRYPTLEVEL_NONE);
        smbc_setOptionCaseSensitive(context, False);
        smbc_setOptionBrowseMaxLmbCount(context, 3);    /* # LMBs to query */
        smbc_setOptionUrlEncodeReaddirEntries(context, False);
        smbc_setOptionOneSharePerServer(context, False);
        
        smbc_setFunctionAuthData(context, SMBC_get_auth_data);
        smbc_setFunctionCheckServer(context, SMBC_check_server);
        smbc_setFunctionRemoveUnusedServer(context, SMBC_remove_unused_server);
        
        smbc_setOptionUserData(context, NULL);
        smbc_setFunctionAddCachedServer(context, SMBC_add_cached_server);
        smbc_setFunctionGetCachedServer(context, SMBC_get_cached_server);
        smbc_setFunctionRemoveCachedServer(context, SMBC_remove_cached_server);
        smbc_setFunctionPurgeCachedServers(context, SMBC_purge_cached_servers);
        
        smbc_setFunctionOpen(context, SMBC_open_ctx);
        smbc_setFunctionCreat(context, SMBC_creat_ctx);
        smbc_setFunctionRead(context, SMBC_read_ctx);
        smbc_setFunctionWrite(context, SMBC_write_ctx);
        smbc_setFunctionClose(context, SMBC_close_ctx);
        smbc_setFunctionUnlink(context, SMBC_unlink_ctx);
        smbc_setFunctionRename(context, SMBC_rename_ctx);
        smbc_setFunctionLseek(context, SMBC_lseek_ctx);
        smbc_setFunctionFtruncate(context, SMBC_ftruncate_ctx);
        smbc_setFunctionStat(context, SMBC_stat_ctx);
        smbc_setFunctionStatVFS(context, SMBC_statvfs_ctx);
        smbc_setFunctionFstatVFS(context, SMBC_fstatvfs_ctx);
        smbc_setFunctionFstat(context, SMBC_fstat_ctx);
        smbc_setFunctionOpendir(context, SMBC_opendir_ctx);
        smbc_setFunctionClosedir(context, SMBC_closedir_ctx);
        smbc_setFunctionReaddir(context, SMBC_readdir_ctx);
        smbc_setFunctionGetdents(context, SMBC_getdents_ctx);
        smbc_setFunctionMkdir(context, SMBC_mkdir_ctx);
        smbc_setFunctionRmdir(context, SMBC_rmdir_ctx);
        smbc_setFunctionTelldir(context, SMBC_telldir_ctx);
        smbc_setFunctionLseekdir(context, SMBC_lseekdir_ctx);
        smbc_setFunctionFstatdir(context, SMBC_fstatdir_ctx);
        smbc_setFunctionChmod(context, SMBC_chmod_ctx);
        smbc_setFunctionUtimes(context, SMBC_utimes_ctx);
        smbc_setFunctionSetxattr(context, SMBC_setxattr_ctx);
        smbc_setFunctionGetxattr(context, SMBC_getxattr_ctx);
        smbc_setFunctionRemovexattr(context, SMBC_removexattr_ctx);
        smbc_setFunctionListxattr(context, SMBC_listxattr_ctx);
        
        smbc_setFunctionOpenPrintJob(context, SMBC_open_print_job_ctx);
        smbc_setFunctionPrintFile(context, SMBC_print_file_ctx);
        smbc_setFunctionListPrintJobs(context, SMBC_list_print_jobs_ctx);
        smbc_setFunctionUnlinkPrintJob(context, SMBC_unlink_print_job_ctx);
        
        return context;
}