예제 #1
0
/**
 * Respond to a POOL_USAGE message by sending back string form of memory
 * usage stats.
 **/
static void msg_pool_usage(struct messaging_context *msg_ctx,
			   void *private_data, 
			   uint32_t msg_type, 
			   struct server_id src,
			   DATA_BLOB *data)
{
	struct msg_pool_usage_state state;

	SMB_ASSERT(msg_type == MSG_REQ_POOL_USAGE);
	
	DEBUG(2,("Got POOL_USAGE\n"));

	state.mem_ctx = talloc_init("msg_pool_usage");
	if (!state.mem_ctx) {
		return;
	}
	state.len	= 0;
	state.buflen	= 512;
	state.s		= NULL;

	talloc_report_depth_cb(NULL, 0, -1, msg_pool_usage_helper, &state);

	if (!state.s) {
		talloc_destroy(state.mem_ctx);
		return;
	}
	
	messaging_send_buf(msg_ctx, src, MSG_POOL_USAGE,
			   (uint8 *)state.s, strlen(state.s)+1);

	talloc_destroy(state.mem_ctx);
}
예제 #2
0
파일: tallocmsg.c 프로젝트: AllardJ/Tomato
/**
 * Respond to a POOL_USAGE message by sending back string form of memory
 * usage stats.
 **/
void msg_pool_usage(int msg_type, struct process_id src_pid,
		    void *UNUSED(buf), size_t UNUSED(len),
		    void *private_data)
{
	struct msg_pool_usage_state state;

	SMB_ASSERT(msg_type == MSG_REQ_POOL_USAGE);
	
	DEBUG(2,("Got POOL_USAGE\n"));

	state.mem_ctx = talloc_init("msg_pool_usage");
	if (!state.mem_ctx) {
		return;
	}
	state.len	= 0;
	state.buflen	= 512;
	state.s		= NULL;

	talloc_report_depth_cb(NULL, 0, -1, msg_pool_usage_helper, &state);

	if (!state.s) {
		talloc_destroy(state.mem_ctx);
		return;
	}
	
	message_send_pid(src_pid, MSG_POOL_USAGE,
			 state.s, strlen(state.s)+1, True);

	talloc_destroy(state.mem_ctx);
}
예제 #3
0
/* 
   determine the netbios workgroup name for a domain
 */
static int net_ads_workgroup(int argc, const char **argv)
{
	ADS_STRUCT *ads;
	TALLOC_CTX *ctx;
	const char *workgroup;

	if (!(ads = ads_startup())) return -1;

	if (!(ctx = talloc_init("net_ads_workgroup"))) {
		ads_destroy(&ads);
		return -1;
	}

	if (!ADS_ERR_OK(ads_workgroup_name(ads, ctx, &workgroup))) {
		d_printf("Failed to find workgroup for realm '%s'\n", 
			 ads->config.realm);
		talloc_destroy(ctx);
		ads_destroy(&ads);
		return -1;
	}

	d_printf("Workgroup: %s\n", workgroup);

	talloc_destroy(ctx);
	ads_destroy(&ads);
	return 0;
}
예제 #4
0
static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
				TALLOC_CTX *mem_ctx,
				uint32 *num_entries, 
				struct acct_info **info)
{
	uint32 des_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
	CLI_POLICY_HND *hnd;
	POLICY_HND dom_pol;
	NTSTATUS result;
	int retry;

	*num_entries = 0;
	*info = NULL;

	retry = 0;
	do {
		if ( !NT_STATUS_IS_OK(result = cm_get_sam_handle(domain, &hnd)) )
			return result;

		result = cli_samr_open_domain( hnd->cli, mem_ctx, &hnd->pol, 
						des_access, &domain->sid, &dom_pol);
	} while (!NT_STATUS_IS_OK(result) && (retry++ < 1) && hnd && hnd->cli && hnd->cli->fd == -1);

	if ( !NT_STATUS_IS_OK(result))
		return result;

	do {
		struct acct_info *info2 = NULL;
		uint32 count = 0, start = *num_entries;
		TALLOC_CTX *mem_ctx2;

		mem_ctx2 = talloc_init("enum_dom_local_groups[rpc]");

		result = cli_samr_enum_als_groups( hnd->cli, mem_ctx2, &dom_pol,
					  &start, 0xFFFF, &info2, &count);
					  
		if ( !NT_STATUS_IS_OK(result) 
			&& !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES) ) 
		{
			talloc_destroy(mem_ctx2);
			break;
		}

		(*info) = talloc_realloc(mem_ctx, *info, 
					 sizeof(**info) * ((*num_entries) + count));
		if (! *info) {
			talloc_destroy(mem_ctx2);
			cli_samr_close(hnd->cli, mem_ctx, &dom_pol);
			return NT_STATUS_NO_MEMORY;
		}

		memcpy(&(*info)[*num_entries], info2, count*sizeof(*info2));
		(*num_entries) += count;
		talloc_destroy(mem_ctx2);
	} while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES));

	cli_samr_close(hnd->cli, mem_ctx, &dom_pol);

	return result;
}
예제 #5
0
static int atalk_rmdir(struct vfs_handle_struct *handle,
			const struct smb_filename *smb_fname)
{
	bool add = False;
	TALLOC_CTX *ctx = 0;
	const char *path = smb_fname->base_name;
	char *dpath;

	if (!handle->conn->cwd || !path) goto exit_rmdir;

	/* due to there is no way to change bDeleteVetoFiles variable
	 * from this module, gotta use talloc stuff..
	 */

	strstr_m(path, APPLEDOUBLE) ? (add = False) : (add = True);

	if (!(ctx = talloc_init("remove_directory")))
		goto exit_rmdir;

	if (!(dpath = talloc_asprintf(ctx, "%s/%s%s", 
	  handle->conn->cwd, path, add ? "/"APPLEDOUBLE : "")))
		goto exit_rmdir;

	atalk_rrmdir(ctx, dpath);

exit_rmdir:
	talloc_destroy(ctx);
	return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
}
예제 #6
0
static int atalk_chmod(struct vfs_handle_struct *handle, const char *path, mode_t mode)
{
	int ret = 0;
	char *adbl_path = 0;
	char *orig_path = 0;
	SMB_STRUCT_STAT adbl_info;
	SMB_STRUCT_STAT orig_info;
	TALLOC_CTX *ctx;

	ret = SMB_VFS_NEXT_CHMOD(handle, path, mode);

	if (!path) return ret;

	if (!(ctx = talloc_init("chmod_file")))
		return ret;

	if (atalk_build_paths(ctx, handle->conn->origpath, path, &adbl_path,
			      &orig_path, &adbl_info, &orig_info,
			      false) != 0)
		goto exit_chmod;

	if (!S_ISDIR(orig_info.st_ex_mode) && !S_ISREG(orig_info.st_ex_mode)) {
		DEBUG(3, ("ATALK: %s has passed..\n", orig_path));		
		goto exit_chmod;
	}

	chmod(adbl_path, ADOUBLEMODE);

exit_chmod:	
	talloc_destroy(ctx);
	return ret;
}
예제 #7
0
void main_loop_TALLOC_FREE(void)
{
    if (!main_loop_talloc)
        return;
    talloc_destroy(main_loop_talloc);
    main_loop_talloc = NULL;
}
예제 #8
0
파일: fake_file.c 프로젝트: hajuuk/R7000
struct _FAKE_FILE_HANDLE *init_fake_file_handle(enum FAKE_FILE_TYPE type)
{
    TALLOC_CTX *mem_ctx = NULL;
    FAKE_FILE_HANDLE *fh = NULL;
    int i;

    for (i=0; fake_files[i].name!=NULL; i++) {
        if (fake_files[i].type==type) {
            DEBUG(5,("init_fake_file_handle: for [%s]\n",fake_files[i].name));

            if ((mem_ctx=talloc_init("fake_file_handle"))==NULL) {
                DEBUG(0,("talloc_init(fake_file_handle) failed.\n"));
                return NULL;
            }

            if ((fh =TALLOC_ZERO_P(mem_ctx, FAKE_FILE_HANDLE))==NULL) {
                DEBUG(0,("talloc_zero() failed.\n"));
                talloc_destroy(mem_ctx);
                return NULL;
            }

            fh->type = type;
            fh->mem_ctx = mem_ctx;

            if (fake_files[i].init_pd)
                fh->pd = fake_files[i].init_pd(fh->mem_ctx);

            fh->free_pd = fake_files[i].free_pd;

            return fh;
        }
    }

    return NULL;
}
예제 #9
0
파일: py_samr.c 프로젝트: AllardJ/Tomato
static PyObject *samr_delete_dom_user(PyObject *self, PyObject *args, 
				      PyObject *kw)
{
	samr_user_hnd_object *user_hnd = (samr_user_hnd_object *)self;
	static char *kwlist[] = { NULL };
	NTSTATUS ntstatus;
	TALLOC_CTX *mem_ctx;
	PyObject *result = NULL;
	
	if (!PyArg_ParseTupleAndKeywords(
		    args, kw, "", kwlist))
		return NULL;

	if (!(mem_ctx = talloc_init("samr_delete_dom_user"))) {
		PyErr_SetString(samr_error, "unable to init talloc context");
		return NULL;
	}

	ntstatus = rpccli_samr_delete_dom_user(
		user_hnd->cli, mem_ctx, &user_hnd->user_pol);

	if (!NT_STATUS_IS_OK(ntstatus)) {
		PyErr_SetObject(samr_ntstatus, py_ntstatus_tuple(ntstatus));
		goto done;
	}

	Py_INCREF(Py_None);
	result = Py_None;

done:
	talloc_destroy(mem_ctx);

	return result;
}
예제 #10
0
bool cli_rpc_pipe_close(struct rpc_pipe_client *cli)
{
	bool ret;

	if (!cli) {
		return false;
	}

	ret = cli_close(cli->cli, cli->fnum);

	if (!ret) {
		DEBUG(1,("cli_rpc_pipe_close: cli_close failed on pipe %s, "
                         "fnum 0x%x "
                         "to machine %s.  Error was %s\n",
                         cli->pipe_name,
                         (int) cli->fnum,
                         cli->cli->desthost,
                         cli_errstr(cli->cli)));
	}

	if (cli->auth.cli_auth_data_free_func) {
		(*cli->auth.cli_auth_data_free_func)(&cli->auth);
	}

	DEBUG(10,("cli_rpc_pipe_close: closed pipe %s to machine %s\n",
		cli->pipe_name, cli->cli->desthost ));

	DLIST_REMOVE(cli->cli->pipe_list, cli);
	talloc_destroy(cli->mem_ctx);
	return ret;
}
예제 #11
0
static int atalk_lchown(struct vfs_handle_struct *handle,
			const struct smb_filename *smb_fname,
			uid_t uid,
			gid_t gid)
{
	int ret = 0;
	char *adbl_path = 0;
	char *orig_path = 0;
	SMB_STRUCT_STAT adbl_info;
	SMB_STRUCT_STAT orig_info;
	TALLOC_CTX *ctx;

	ret = SMB_VFS_NEXT_LCHOWN(handle, smb_fname, uid, gid);

	if (!(ctx = talloc_init("lchown_file")))
		return ret;

	if (atalk_build_paths(ctx, handle->conn->cwd, smb_fname->base_name,
			      &adbl_path, &orig_path,
			      &adbl_info, &orig_info) != 0)
		goto exit_lchown;

	if (!S_ISDIR(orig_info.st_ex_mode) && !S_ISREG(orig_info.st_ex_mode)) {
		DEBUG(3, ("ATALK: %s has passed..\n", orig_path));		
		goto exit_lchown;
	}

	if (lchown(adbl_path, uid, gid) == -1) {
		DEBUG(3, ("ATALK: lchown error %s\n", strerror(errno)));
	}

exit_lchown:	
	talloc_destroy(ctx);
	return ret;
}
예제 #12
0
파일: auth_ntlmssp.c 프로젝트: endisd/samba
NTSTATUS auth_ntlmssp_start(AUTH_NTLMSSP_STATE **auth_ntlmssp_state)
{
	NTSTATUS nt_status;
	TALLOC_CTX *mem_ctx;

	mem_ctx = talloc_init("AUTH NTLMSSP context");
	
	*auth_ntlmssp_state = TALLOC_ZERO_P(mem_ctx, AUTH_NTLMSSP_STATE);
	if (!*auth_ntlmssp_state) {
		DEBUG(0,("auth_ntlmssp_start: talloc failed!\n"));
		talloc_destroy(mem_ctx);
		return NT_STATUS_NO_MEMORY;
	}

	ZERO_STRUCTP(*auth_ntlmssp_state);

	(*auth_ntlmssp_state)->mem_ctx = mem_ctx;

	if (!NT_STATUS_IS_OK(nt_status = ntlmssp_server_start(&(*auth_ntlmssp_state)->ntlmssp_state))) {
		return nt_status;
	}

	if (!NT_STATUS_IS_OK(nt_status = make_auth_context_subsystem(&(*auth_ntlmssp_state)->auth_context))) {
		return nt_status;
	}

	(*auth_ntlmssp_state)->ntlmssp_state->auth_context = (*auth_ntlmssp_state);
	(*auth_ntlmssp_state)->ntlmssp_state->get_challenge = auth_ntlmssp_get_challenge;
	(*auth_ntlmssp_state)->ntlmssp_state->may_set_challenge = auth_ntlmssp_may_set_challenge;
	(*auth_ntlmssp_state)->ntlmssp_state->set_challenge = auth_ntlmssp_set_challenge;
	(*auth_ntlmssp_state)->ntlmssp_state->check_password = auth_ntlmssp_check_password;
	(*auth_ntlmssp_state)->ntlmssp_state->server_role = (enum server_types)lp_server_role();

	return NT_STATUS_OK;
}
예제 #13
0
파일: ntlmssp.c 프로젝트: berte/mediaplayer
NTSTATUS ntlmssp_client_start(NTLMSSP_STATE **ntlmssp_state)
{
	*ntlmssp_state = TALLOC_ZERO_P(NULL, NTLMSSP_STATE);
	if (!*ntlmssp_state) {
		DEBUG(0,("ntlmssp_client_start: talloc failed!\n"));
		talloc_destroy(*ntlmssp_state);
		return NT_STATUS_NO_MEMORY;
	}

	(*ntlmssp_state)->role = NTLMSSP_CLIENT;

	(*ntlmssp_state)->get_global_myname = global_myname;
	(*ntlmssp_state)->get_domain = lp_workgroup;

	(*ntlmssp_state)->unicode = True;

	(*ntlmssp_state)->use_ntlmv2 = lp_client_ntlmv2_auth();

	(*ntlmssp_state)->expected_state = NTLMSSP_INITIAL;

	(*ntlmssp_state)->ref_count = 1;

	(*ntlmssp_state)->neg_flags = 
		NTLMSSP_NEGOTIATE_128 |
		NTLMSSP_NEGOTIATE_ALWAYS_SIGN |
		NTLMSSP_NEGOTIATE_NTLM |
		NTLMSSP_NEGOTIATE_NTLM2 |
		NTLMSSP_NEGOTIATE_KEY_EXCH |
		NTLMSSP_REQUEST_TARGET;

	return NT_STATUS_OK;
}
예제 #14
0
static int atalk_chown(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path, uid_t uid, gid_t gid)
{
	int ret = 0;
	char *adbl_path = 0;
	char *orig_path = 0;
	SMB_STRUCT_STAT adbl_info;
	SMB_STRUCT_STAT orig_info;
	TALLOC_CTX *ctx;

	ret = SMB_VFS_NEXT_CHOWN(handle, conn, path, uid, gid);

	if (!conn || !path) return ret;

	if (!(ctx = talloc_init("chown_file")))
		return ret;

	if (atalk_build_paths(ctx, conn->origpath, path, &adbl_path, &orig_path,
	  &adbl_info, &orig_info) != 0)
		return ret;

	if (!S_ISDIR(orig_info.st_mode) && !S_ISREG(orig_info.st_mode)) {
		DEBUG(3, ("ATALK: %s has passed..\n", orig_path));		
		goto exit_chown;
	}

	chown(adbl_path, uid, gid);

exit_chown:	
	talloc_destroy(ctx);
	return ret;
}
예제 #15
0
static int atalk_rename(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *oldname, const char *newname)
{
	int ret = 0;
	char *adbl_path = 0;
	char *orig_path = 0;
	SMB_STRUCT_STAT adbl_info;
	SMB_STRUCT_STAT orig_info;
	TALLOC_CTX *ctx;

	ret = SMB_VFS_NEXT_RENAME(handle, conn, oldname, newname);

	if (!conn || !oldname) return ret;

	if (!(ctx = talloc_init("rename_file")))
		return ret;

	if (atalk_build_paths(ctx, conn->origpath, oldname, &adbl_path, &orig_path, 
	  &adbl_info, &orig_info) != 0)
		return ret;

	if (S_ISDIR(orig_info.st_mode) || S_ISREG(orig_info.st_mode)) {
		DEBUG(3, ("ATALK: %s has passed..\n", adbl_path));		
		goto exit_rename;
	}

	atalk_unlink_file(adbl_path);

exit_rename:
	talloc_destroy(ctx);
	return ret;
}
예제 #16
0
파일: sharesec.c 프로젝트: AllardJ/Tomato
BOOL share_access_check(const NT_USER_TOKEN *token, const char *sharename,
			uint32 desired_access)
{
	uint32 granted;
	NTSTATUS status;
	TALLOC_CTX *mem_ctx = NULL;
	SEC_DESC *psd = NULL;
	size_t sd_size;
	BOOL ret = True;

	if (!(mem_ctx = talloc_init("share_access_check"))) {
		return False;
	}

	psd = get_share_security(mem_ctx, sharename, &sd_size);

	if (!psd) {
		TALLOC_FREE(mem_ctx);
		return True;
	}

	ret = se_access_check(psd, token, desired_access, &granted, &status);

	talloc_destroy(mem_ctx);
	return ret;
}
예제 #17
0
static int net_groupmap_memberships(struct net_context *c, int argc, const char **argv)
{
	TALLOC_CTX *mem_ctx;
	struct dom_sid *domain_sid, member;

	if ( (argc != 1) ||
	     c->display_usage ||
	     !string_to_sid(&member, argv[0]) ) {
		d_printf("%s\n%s",
			 _("Usage:"),
			 _("net groupmap memberships sid\n"));
		return -1;
	}

	mem_ctx = talloc_init("net_groupmap_memberships");
	if (mem_ctx == NULL) {
		d_fprintf(stderr, _("talloc_init failed\n"));
		return -1;
	}

	domain_sid = get_global_sam_sid();
	if (domain_sid == NULL) {
		d_fprintf(stderr, _("Could not get domain sid\n"));
		return -1;
	}

	if (!print_alias_memberships(mem_ctx, domain_sid, &member) ||
	    !print_alias_memberships(mem_ctx, &global_sid_Builtin, &member))
		return -1;

	talloc_destroy(mem_ctx);

	return 0;
}
예제 #18
0
static int atalk_rmdir(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path)
{
	BOOL add = False;
	TALLOC_CTX *ctx = 0;
	char *dpath;

	if (!conn || !conn->origpath || !path) goto exit_rmdir;

	/* due to there is no way to change bDeleteVetoFiles variable
	 * from this module, gotta use talloc stuff..
	 */

	strstr(path, APPLEDOUBLE) ? (add = False) : (add = True);

	if (!(ctx = talloc_init("remove_directory")))
		goto exit_rmdir;

	if (!(dpath = talloc_asprintf(ctx, "%s/%s%s", 
	  conn->origpath, path, add ? "/"APPLEDOUBLE : "")))
		goto exit_rmdir;

	atalk_rrmdir(ctx, dpath);

exit_rmdir:
	talloc_destroy(ctx);
	return SMB_VFS_NEXT_RMDIR(handle, conn, path);
}
static NTSTATUS net_sh_run(struct net_context *c,
			   struct rpc_sh_ctx *ctx, struct rpc_sh_cmd *cmd,
			   int argc, const char **argv)
{
	TALLOC_CTX *mem_ctx;
	struct rpc_pipe_client *pipe_hnd = NULL;
	NTSTATUS status;

	mem_ctx = talloc_new(ctx);
	if (mem_ctx == NULL) {
		d_fprintf(stderr, _("talloc_new failed\n"));
		return NT_STATUS_NO_MEMORY;
	}

	status = cli_rpc_pipe_open_noauth(ctx->cli, &cmd->table->syntax_id,
					  &pipe_hnd);
	if (!NT_STATUS_IS_OK(status)) {
		d_fprintf(stderr, _("Could not open pipe: %s\n"),
			  nt_errstr(status));
		return status;
	}

	status = cmd->fn(c, mem_ctx, ctx, pipe_hnd, argc, argv);

	TALLOC_FREE(pipe_hnd);

	talloc_destroy(mem_ctx);

	return status;
}
예제 #20
0
void destroy_privilege(PRIVILEGE_SET **priv_set)
{
	reset_privilege(*priv_set);
	if (!((*priv_set)->ext_ctx))
		/* mem_ctx is local, destroy it */
		talloc_destroy((*priv_set)->mem_ctx);
	*priv_set = NULL;
}
예제 #21
0
파일: vfs_afsacl.c 프로젝트: AllardJ/Tomato
static void free_afs_acl(struct afs_acl *acl)
{
	if (acl->ctx != NULL)
		talloc_destroy(acl->ctx);
	acl->ctx = NULL;
	acl->num_aces = 0;
	acl->acelist = NULL;
}
예제 #22
0
static NTSTATUS cmd_quit(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
	/* Cleanup */
	talloc_destroy(mem_ctx);

	exit(0);
	return NT_STATUS_OK; /* NOTREACHED */
}
예제 #23
0
파일: enable.c 프로젝트: AllardJ/Tomato
int main(int argc, char **argv) {
   CacServerHandle *hnd = NULL;
   TALLOC_CTX *mem_ctx = NULL;

   struct SamOpenUser ou;

   fstring tmp;

   mem_ctx = talloc_init("cac_samgroup");

   hnd = cac_NewServerHandle(True);

   cac_SetAuthDataFn(hnd, cactest_GetAuthDataFn);

   cac_parse_cmd_line(argc, argv, hnd);

   if(!cac_Connect(hnd, NULL)) {
      fprintf(stderr, "Could not connect to server %s. Error: %s\n", hnd->server, nt_errstr(hnd->status));
      exit(-1);
   }

   struct SamOpenDomain sod;
   ZERO_STRUCT(sod);

   sod.in.access = MAXIMUM_ALLOWED_ACCESS; 

   if(!cac_SamOpenDomain(hnd, mem_ctx, &sod)) {
      fprintf(stderr, "Could not open domain. Error: %s\n", nt_errstr(hnd->status));
      goto done;
   }

   ZERO_STRUCT(ou);
   printf("Enter username: "******"Could not open user. Error: %s\n", nt_errstr(hnd->status));
      goto done;
   }

   /*enable the user*/
   if(!cac_SamEnableUser(hnd, mem_ctx, ou.out.user_hnd)) {
      fprintf(stderr, "Could not enable user: %s\n", nt_errstr(hnd->status));
   }

done:
   cac_SamClose(hnd, mem_ctx, sod.out.dom_hnd);

   cac_FreeHandle(hnd);

   talloc_destroy(mem_ctx);
   
   return 0;
}
예제 #24
0
static NTSTATUS cmd_freemem(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
	/* Cleanup */
	talloc_destroy(mem_ctx);
	mem_ctx = NULL;
	vfs->data = NULL;
	vfs->data_size = 0;
	return NT_STATUS_OK;
}
예제 #25
0
 void cell_destroy(struct likewise_cell *c)
{
	if (!c)
		return;

	if (c->conn)
		ads_destroy(&c->conn);

	talloc_destroy(c);
}
예제 #26
0
void privilege_set_free(PRIVILEGE_SET *priv_set)
{
	if ( !priv_set )
		return;

	if ( !( priv_set->ext_ctx ) )
		talloc_destroy( priv_set->mem_ctx );

	ZERO_STRUCTP( priv_set );
}
예제 #27
0
static int atalk_unlink(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path)
{
	int ret = 0, i;
	char *adbl_path = 0;
	char *orig_path = 0;
	SMB_STRUCT_STAT adbl_info;
	SMB_STRUCT_STAT orig_info;
	TALLOC_CTX *ctx;

	ret = SMB_VFS_NEXT_UNLINK(handle, conn, path);

	if (!conn || !path) return ret;

	/* no .AppleDouble sync if veto or hide list is empty,
	 * otherwise "Cannot find the specified file" error will be caused
	 */

	if (!conn->veto_list) return ret;
	if (!conn->hide_list) return ret;

	for (i = 0; conn->veto_list[i].name; i ++) {
		if (strstr(conn->veto_list[i].name, APPLEDOUBLE))
			break;
	}

	if (!conn->veto_list[i].name) {
		for (i = 0; conn->hide_list[i].name; i ++) {
			if (strstr(conn->hide_list[i].name, APPLEDOUBLE))
				break;
			else {
				DEBUG(3, ("ATALK: %s is not hidden, skipped..\n",
				  APPLEDOUBLE));		
				return ret;
			}
		}
	}

	if (!(ctx = talloc_init("unlink_file")))
		return ret;

	if (atalk_build_paths(ctx, conn->origpath, path, &adbl_path, &orig_path, 
	  &adbl_info, &orig_info) != 0)
		return ret;

	if (S_ISDIR(orig_info.st_mode) || S_ISREG(orig_info.st_mode)) {
		DEBUG(3, ("ATALK: %s has passed..\n", adbl_path));
		goto exit_unlink;
	}

	atalk_unlink_file(adbl_path);

exit_unlink:	
	talloc_destroy(ctx);
	return ret;
}
예제 #28
0
파일: fake_file.c 프로젝트: hajuuk/R7000
void destroy_fake_file_handle(FAKE_FILE_HANDLE **fh)
{
    if (!fh||!(*fh))
        return;

    if ((*fh)->free_pd)
        (*fh)->free_pd(&(*fh)->pd);

    talloc_destroy((*fh)->mem_ctx);
    (*fh) = NULL;
}
예제 #29
0
파일: cliquota.c 프로젝트: AllardJ/Tomato
void free_ntquota_list(SMB_NTQUOTA_LIST **qt_list)
{
	if (!qt_list)
		return;

	if ((*qt_list)->mem_ctx)
		talloc_destroy((*qt_list)->mem_ctx);

	(*qt_list) = NULL;

	return;	
}
void update_trustdom_cache( void )
{
	char **domain_names;
	struct dom_sid *dom_sids;
	uint32 num_domains;
	uint32 last_check;
	int time_diff;
	TALLOC_CTX *mem_ctx = NULL;
	time_t now = time(NULL);
	int i;

	/* get the timestamp.  We have to initialise it if the last timestamp == 0 */	
	if ( (last_check = trustdom_cache_fetch_timestamp()) == 0 ) 
		trustdom_cache_store_timestamp(0, now+TRUSTDOM_UPDATE_INTERVAL);

	time_diff = (int) (now - last_check);

	if ( (time_diff > 0) && (time_diff < TRUSTDOM_UPDATE_INTERVAL) ) {
		DEBUG(10,("update_trustdom_cache: not time to update trustdom_cache yet\n"));
		return;
	}

	/* note that we don't lock the timestamp. This prevents this
	   smbd from blocking all other smbd daemons while we
	   enumerate the trusted domains */
	trustdom_cache_store_timestamp(now, now+TRUSTDOM_UPDATE_INTERVAL);

	if ( !(mem_ctx = talloc_init("update_trustdom_cache")) ) {
		DEBUG(0,("update_trustdom_cache: talloc_init() failed!\n"));
		goto done;
	}

	/* get the domains and store them */

	if ( enumerate_domain_trusts(mem_ctx, lp_workgroup(), &domain_names, 
		&num_domains, &dom_sids)) {
		for ( i=0; i<num_domains; i++ ) {
			trustdom_cache_store( domain_names[i], NULL, &dom_sids[i], 
				now+TRUSTDOM_UPDATE_INTERVAL);
		}		
	} else {
		/* we failed to fetch the list of trusted domains - restore the old
		   timestamp */
		trustdom_cache_store_timestamp(last_check, 
					       last_check+TRUSTDOM_UPDATE_INTERVAL);
	}

done:	
	talloc_destroy( mem_ctx );

	return;
}