Exemplo n.º 1
0
static void irix_release_kernel_oplock(files_struct *fsp)
{
	if (DEBUGLVL(10)) {
		/*
		 * Check and print out the current kernel
		 * oplock state of this file.
		 */
		int state = sys_fcntl_long(fsp->fh->fd, F_OPLKACK, -1);
		dbgtext("irix_release_kernel_oplock: file %s, dev = %x, "
			"inode = %.0f file_id = %ul, has kernel oplock state "
			"of %x.\n", fsp->fsp_name, (unsigned int)fsp->dev,
                        (double)fsp->inode, fsp->fh->file_id, state );
	}

	/*
	 * Remove the kernel oplock on this file.
	 */
	if(sys_fcntl_long(fsp->fh->fd, F_OPLKACK, OP_REVOKE) < 0) {
		if( DEBUGLVL( 0 )) {
			dbgtext("irix_release_kernel_oplock: Error when "
				"removing kernel oplock on file " );
			dbgtext("%s, dev = %x, inode = %.0f, file_id = %ul. "
				"Error was %s\n",
				fsp->fsp_name, (unsigned int)fsp->dev, 
				(double)fsp->inode, fsp->fh->file_id,
				strerror(errno) );
		}
	}
}
Exemplo n.º 2
0
static void irix_release_kernel_oplock(struct kernel_oplocks *_ctx,
				       files_struct *fsp, int oplock_type)
{
	if (DEBUGLVL(10)) {
		/*
		 * Check and print out the current kernel
		 * oplock state of this file.
		 */
		int state = sys_fcntl_long(fsp->fh->fd, F_OPLKACK, -1);
		dbgtext("irix_release_kernel_oplock: file %s, file_id = %s"
			"gen_id = %ul, has kernel oplock state "
			"of %x.\n", fsp_str_dbg(fsp),
		        file_id_string_tos(&fsp->file_id),
                        fsp->fh->gen_id, state );
	}

	/*
	 * Remove the kernel oplock on this file.
	 */
	if(sys_fcntl_long(fsp->fh->fd, F_OPLKACK, OP_REVOKE) < 0) {
		if( DEBUGLVL( 0 )) {
			dbgtext("irix_release_kernel_oplock: Error when "
				"removing kernel oplock on file " );
			dbgtext("%s, file_id = %s gen_id = %ul. "
				"Error was %s\n",
				fsp_str_dbg(fsp),
			        file_id_string_tos(&fsp->file_id),
				fsp->fh->gen_id,
				strerror(errno) );
		}
	}
}
Exemplo n.º 3
0
static void linux_release_kernel_oplock(struct kernel_oplocks *ctx,
					files_struct *fsp, int oplock_type)
{
	if (DEBUGLVL(10)) {
		/*
		 * Check and print out the current kernel
		 * oplock state of this file.
		 */
		int state = fcntl(fsp->fh->fd, F_GETLEASE, 0);
		dbgtext("linux_release_kernel_oplock: file %s, file_id = %s "
			"gen_id = %lu has kernel oplock state "
			"of %x.\n", fsp_str_dbg(fsp),
		        file_id_string_tos(&fsp->file_id),
			fsp->fh->gen_id, state );
	}

	/*
	 * Remove the kernel oplock on this file.
	 */
	if ( SMB_VFS_LINUX_SETLEASE(fsp, F_UNLCK) == -1) {
		if (DEBUGLVL(0)) {
			dbgtext("linux_release_kernel_oplock: Error when "
				"removing kernel oplock on file " );
			dbgtext("%s, file_id = %s, gen_id = %lu. "
				"Error was %s\n", fsp_str_dbg(fsp),
				file_id_string_tos(&fsp->file_id),
				fsp->fh->gen_id, strerror(errno) );
		}
	}
}
Exemplo n.º 4
0
static void find_all_domain_master_names_query_success(struct subnet_record *subrec,
                        struct userdata_struct *userdata_in,
                        struct nmb_name *q_name, struct in_addr answer_ip, struct res_rec *rrec)
{
  /* 
   * We now have a list of all the domain master browsers for all workgroups
   * that have registered with the WINS server. Now do a node status request
   * to each one and look for the first 1b name in the reply. This will be
   * the workgroup name that we will add to the unicast subnet as a 'non-local'
   * workgroup.
   */

  struct nmb_name nmbname;
  struct in_addr send_ip;
  int i;

  if( DEBUGLVL( 5 ) )
  {
    dbgtext( "find_all_domain_master_names_query_succes:\n" );
    dbgtext( "Got answer from WINS server of %d ", (rrec->rdlength / 6) );
    dbgtext( "IP addresses for Domain Master Browsers.\n" );
  }

  for(i = 0; i < rrec->rdlength / 6; i++)
  {
    /* Initiate the node status requests. */
    make_nmb_name(&nmbname, "*", 0);

    putip((char *)&send_ip, (char *)&rrec->rdata[(i*6) + 2]);

    /* 
     * Don't send node status requests to ourself.
     */

    if(ismyip( send_ip ))
    {
      if( DEBUGLVL( 5 ) )
      {
        dbgtext( "find_all_domain_master_names_query_succes:\n" );
        dbgtext( "Not sending node status to our own IP " );
        dbgtext( "%s.\n", inet_ntoa(send_ip) );
      }
      continue;
    }

    if( DEBUGLVL( 5 ) )
    {
      dbgtext( "find_all_domain_master_names_query_success:\n" );
      dbgtext( "Sending node status request to IP %s.\n", inet_ntoa(send_ip) );
    }

    node_status( subrec, &nmbname, send_ip, 
                 get_domain_master_name_node_status_success,
                 get_domain_master_name_node_status_fail,
                 NULL);
  }
}
Exemplo n.º 5
0
/*
  receive some data on a WREPL connection
*/
static NTSTATUS wreplsrv_process(struct wreplsrv_in_connection *wrepl_conn,
				 struct wreplsrv_in_call **_call)
{
	struct wrepl_wrap packet_out_wrap;
	NTSTATUS status;
	enum ndr_err_code ndr_err;
	struct wreplsrv_in_call *call = *_call;

	ndr_err = ndr_pull_struct_blob(&call->in, call,
				       &call->req_packet,
				       (ndr_pull_flags_fn_t)ndr_pull_wrepl_packet);
	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
		return ndr_map_error2ntstatus(ndr_err);
	}

	if (DEBUGLVL(10)) {
		DEBUG(10,("Received WINS-Replication packet of length %u\n",
			  (unsigned int) call->in.length + 4));
		NDR_PRINT_DEBUG(wrepl_packet, &call->req_packet);
	}

	status = wreplsrv_in_call(call);
	NT_STATUS_IS_ERR_RETURN(status);
	if (!NT_STATUS_IS_OK(status)) {
		/* w2k just ignores invalid packets, so we do */
		DEBUG(10,("Received WINS-Replication packet was invalid, we just ignore it\n"));
		TALLOC_FREE(call);
		*_call = NULL;
		return NT_STATUS_OK;
	}

	/* and now encode the reply */
	packet_out_wrap.packet = call->rep_packet;
	ndr_err = ndr_push_struct_blob(&call->out, call,
				       &packet_out_wrap,
				       (ndr_push_flags_fn_t) ndr_push_wrepl_wrap);
	if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
		return ndr_map_error2ntstatus(ndr_err);
	}

	if (DEBUGLVL(10)) {
		DEBUG(10,("Sending WINS-Replication packet of length %u\n",
			 (unsigned int) call->out.length));
		NDR_PRINT_DEBUG(wrepl_packet, &call->rep_packet);
	}

	return NT_STATUS_OK;
}
Exemplo n.º 6
0
int samba_ldb_connect(struct ldb_context *ldb, struct loadparm_context *lp_ctx,
		      const char *url, unsigned int flags)
{
	int ret;
	char *real_url = NULL;

	/* allow admins to force non-sync ldb for all databases */
	if (lpcfg_parm_bool(lp_ctx, NULL, "ldb", "nosync", false)) {
		flags |= LDB_FLG_NOSYNC;
	}

	if (DEBUGLVL(10)) {
		flags |= LDB_FLG_ENABLE_TRACING;
	}

	real_url = lpcfg_private_path(ldb, lp_ctx, url);
	if (real_url == NULL) {
		return LDB_ERR_OPERATIONS_ERROR;
	}

	ret = ldb_connect(ldb, real_url, flags, NULL);

	if (ret != LDB_SUCCESS) {
		return ret;
	}

	/* setup for leak detection */
	ldb_set_opaque(ldb, "wrap_url", real_url);

	return LDB_SUCCESS;
}
Exemplo n.º 7
0
void dump_data(int level, const uint8_t *buf, size_t len)
{
	int i=0;

	if (len<=0) return;

	if (!DEBUGLVL(level)) return;

	DEBUG(level, (__location__ " dump data of size %i:\n", (int)len));
	DEBUGADD(level,("[%03X] ",i));
	for (i=0;i<len;) {
		DEBUGADD(level,("%02X ",(int)buf[i]));
		i++;
		if (i%8 == 0) DEBUGADD(level,(" "));
		if (i%16 == 0) {
			print_asc(level,&buf[i-16],8); DEBUGADD(level,(" "));
			print_asc(level,&buf[i-8],8); DEBUGADD(level,("\n"));
			if (i<len) DEBUGADD(level,("[%03X] ",i));
		}
	}
	if (i%16) {
		int n;
		n = 16 - (i%16);
		DEBUGADD(level,(" "));
		if (n>8) DEBUGADD(level,(" "));
		while (n--) DEBUGADD(level,("   "));
		n = MIN(8,i%16);
		print_asc(level,&buf[i-(i%16)],n); DEBUGADD(level,( " " ));
		n = (i%16) - n;
		if (n>0) print_asc(level,&buf[i-n],n);
		DEBUGADD(level,("\n"));
	}
	DEBUG(level, (__location__ " dump data of size %i finished\n", (int)len));
}
Exemplo n.º 8
0
/*
  send a close
*/
static NTSTATUS torture_smb2_close(struct smb2_tree *tree, struct smb2_handle handle)
{
	struct smb2_close io;
	NTSTATUS status;
	TALLOC_CTX *tmp_ctx = talloc_new(tree);

	ZERO_STRUCT(io);
	io.in.file.handle	= handle;
	io.in.flags		= SMB2_CLOSE_FLAGS_FULL_INFORMATION;
	status = smb2_close(tree, &io);
	if (!NT_STATUS_IS_OK(status)) {
		printf("close failed - %s\n", nt_errstr(status));
		return status;
	}

	if (DEBUGLVL(1)) {
		printf("Close gave:\n");
		printf("create_time     = %s\n", nt_time_string(tmp_ctx, io.out.create_time));
		printf("access_time     = %s\n", nt_time_string(tmp_ctx, io.out.access_time));
		printf("write_time      = %s\n", nt_time_string(tmp_ctx, io.out.write_time));
		printf("change_time     = %s\n", nt_time_string(tmp_ctx, io.out.change_time));
		printf("alloc_size      = %lld\n", (long long)io.out.alloc_size);
		printf("size            = %lld\n", (long long)io.out.size);
		printf("file_attr       = 0x%x\n", io.out.file_attr);
	}

	talloc_free(tmp_ctx);
	
	return status;
}
Exemplo n.º 9
0
/* initialise a dcerpc pipe. */
_PUBLIC_ struct dcerpc_pipe *dcerpc_pipe_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
				     struct smb_iconv_convenience *ic)
{
	struct dcerpc_pipe *p;

	p = talloc(mem_ctx, struct dcerpc_pipe);
	if (!p) {
		return NULL;
	}

	p->conn = dcerpc_connection_init(p, ev, ic);
	if (p->conn == NULL) {
		talloc_free(p);
		return NULL;
	}

	p->last_fault_code = 0;
	p->context_id = 0;
	p->request_timeout = DCERPC_REQUEST_TIMEOUT;
	p->binding = NULL;

	ZERO_STRUCT(p->syntax);
	ZERO_STRUCT(p->transfer_syntax);

	if (DEBUGLVL(100)) {
		p->conn->flags |= DCERPC_DEBUG_PRINT_BOTH;
	}

	return p;
}
Exemplo n.º 10
0
void announce_and_sync_with_domain_master_browser( struct subnet_record *subrec,
                                                   struct work_record *work)
{
  struct nmb_name nmbname;

  /* Only do this if we are using a WINS server. */
  if(we_are_a_wins_client() == False)
  {
    if( DEBUGLVL( 10 ) )
    {
      dbgtext( "announce_and_sync_with_domain_master_browser:\n" );
      dbgtext( "Ignoring, as we are not a WINS client.\n" );
    }
    return;
  }

  make_nmb_name(&nmbname,work->work_group,0x1b);

  /* First, query for the WORKGROUP<1b> name from the WINS server. */
  query_name(unicast_subnet, nmbname.name, nmbname.name_type,
             find_domain_master_name_query_success,
             find_domain_master_name_query_fail,
             NULL);

}
Exemplo n.º 11
0
void collect_all_workgroup_names_from_wins_server(time_t t)
{
	static time_t lastrun = 0;
	struct work_record *work;

	/* Only do this if we are using a WINS server. */
	if(we_are_a_wins_client() == False)
		return;

	/* Check to see if we are a domain master browser on the unicast subnet. */
	if((work = find_workgroup_on_subnet( unicast_subnet, lp_workgroup())) == NULL) {
		if( DEBUGLVL( 0 ) ) {
			dbgtext( "collect_all_workgroup_names_from_wins_server:\n" );
			dbgtext( "Cannot find my workgroup %s ", lp_workgroup() );
			dbgtext( "on subnet %s.\n", unicast_subnet->subnet_name );
		}
		return;
	}

	if(!AM_DOMAIN_MASTER_BROWSER(work))
		return;

	if ((lastrun != 0) && (t < lastrun + (15 * 60)))
		return;
     
	lastrun = t;

	/* First, query for the *<1b> name from the WINS server. */
	query_name(unicast_subnet, "*", 0x1b,
		find_all_domain_master_names_query_success,
		find_all_domain_master_names_query_fail,
		NULL);
} 
Exemplo n.º 12
0
void msg_close_file(struct messaging_context *msg_ctx,
			void *private_data,
			uint32_t msg_type,
			struct server_id server_id,
			DATA_BLOB *data)
{
	files_struct *fsp = NULL;
	struct share_mode_entry e;
	struct smbd_server_connection *sconn =
		talloc_get_type_abort(private_data,
		struct smbd_server_connection);

	message_to_share_mode_entry(&e, (char *)data->data);

	if(DEBUGLVL(10)) {
		char *sm_str = share_mode_str(NULL, 0, &e);
		if (!sm_str) {
			smb_panic("talloc failed");
		}
		DEBUG(10,("msg_close_file: got request to close share mode "
			"entry %s\n", sm_str));
		TALLOC_FREE(sm_str);
	}

	fsp = file_find_dif(sconn, e.id, e.share_file_id);
	if (!fsp) {
		DEBUG(10,("msg_close_file: failed to find file.\n"));
		return;
	}
	close_file(NULL, fsp, NORMAL_CLOSE);
}
Exemplo n.º 13
0
/*
  we received a badly formed packet - log it
*/
void nbtd_bad_packet(struct nbt_name_packet *packet, 
		     const struct socket_address *src, const char *reason)
{
	DEBUG(2,("nbtd: bad packet '%s' from %s:%d\n", reason, src->addr, src->port));
	if (DEBUGLVL(5)) {
		NDR_PRINT_DEBUG(nbt_name_packet, packet);		
	}
}
Exemplo n.º 14
0
static void announce_local_master_browser_to_domain_master_browser( struct work_record *work)
{
	char outbuf[1024];
	unstring myname;
	unstring dmb_name;
	char *p;

	if(ismyip_v4(work->dmb_addr)) {
		if( DEBUGLVL( 2 ) ) {
			dbgtext( "announce_local_master_browser_to_domain_master_browser:\n" );
			dbgtext( "We are both a domain and a local master browser for " );
			dbgtext( "workgroup %s.  ", work->work_group );
			dbgtext( "Do not announce to ourselves.\n" );
		}
		return;
	}

	memset(outbuf,'\0',sizeof(outbuf));
	p = outbuf;
	SCVAL(p,0,ANN_MasterAnnouncement);
	p++;

	unstrcpy(myname, lp_netbios_name());
	if (!strupper_m(myname)) {
		DEBUG(2,("strupper_m %s failed\n", myname));
		return;
	}
	myname[15]='\0';
	/* The call below does CH_UNIX -> CH_DOS conversion. JRA */
	push_ascii(p, myname, sizeof(outbuf)-PTR_DIFF(p,outbuf)-1, STR_TERMINATE);

	p = skip_string(outbuf,sizeof(outbuf),p);

	if( DEBUGLVL( 4 ) ) {
		dbgtext( "announce_local_master_browser_to_domain_master_browser:\n" );
		dbgtext( "Sending local master announce to " );
		dbgtext( "%s for workgroup %s.\n", nmb_namestr(&work->dmb_name),
					work->work_group );
	}

	/* Target name for send_mailslot must be in UNIX charset. */
	pull_ascii_nstring(dmb_name, sizeof(dmb_name), work->dmb_name.name);
	send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
		lp_netbios_name(), 0x0, dmb_name, 0x0,
		work->dmb_addr, FIRST_SUBNET->myip, DGRAM_PORT);
}
Exemplo n.º 15
0
/****************************************************************************
As a domain master browser, do a sync with a local master browser.
**************************************************************************/
static void sync_with_lmb(struct browse_cache_record *browc)
{                     
  struct work_record *work;

  if( !(work = find_workgroup_on_subnet(unicast_subnet, browc->work_group)) )
  {
    if( DEBUGLVL( 0 ) )
    {
      dbgtext( "sync_with_lmb:\n" );
      dbgtext( "Failed to get a workgroup for a local master browser " );
      dbgtext( "cache entry workgroup " );
      dbgtext( "%s, server %s\n", browc->work_group, browc->lmb_name );
    }
    return;
  }

  /* We should only be doing this if we are a domain master browser for
     the given workgroup. Ensure this is so. */

  if(!AM_DOMAIN_MASTER_BROWSER(work))
  {
    if( DEBUGLVL( 0 ) )
    {
      dbgtext( "sync_with_lmb:\n" );
      dbgtext( "We are trying to sync with a local master browser " );
      dbgtext( "%s for workgroup %s\n", browc->lmb_name, browc->work_group );
      dbgtext( "and we are not a domain master browser on this workgroup.\n" );
      dbgtext( "Error!\n" );
    }
    return;
  }

  if( DEBUGLVL( 2 ) )
  {
    dbgtext( "sync_with_lmb:\n" );
    dbgtext( "Initiating sync with local master browser " );
    dbgtext( "%s<0x20> at IP %s ", browc->lmb_name, inet_ntoa(browc->ip) );
    dbgtext( "for workgroup %s\n", browc->work_group );
  }

  sync_browse_lists(work, browc->lmb_name, 0x20, browc->ip, True, True);

  browc->sync_time += (CHECK_TIME_DMB_TO_LMB_SYNC * 60);
}
Exemplo n.º 16
0
static void get_domain_master_name_node_status_fail(struct subnet_record *subrec,
                       struct response_record *rrec)
{
	if( DEBUGLVL( 0 ) ) {
		dbgtext( "get_domain_master_name_node_status_fail:\n" );
		dbgtext( "Doing a node status request to the domain master browser " );
		dbgtext( "at IP %s failed.\n", inet_ntoa(rrec->packet->ip) );
		dbgtext( "Cannot get workgroup name.\n" );
	}
}
Exemplo n.º 17
0
static bool recalc_brl_timeout(void)
{
	struct blocking_lock_record *blr;
	struct timeval next_timeout;

	TALLOC_FREE(brl_timeout);

	next_timeout = timeval_zero();	

	for (blr = blocking_lock_queue; blr; blr = blr->next) {
		if (timeval_is_zero(&blr->expire_time)) {
			/*
			 * If we're blocked on pid 0xFFFFFFFF this is
			 * a POSIX lock, so calculate a timeout of
			 * 10 seconds into the future.
			 */
                        if (blr->blocking_pid == 0xFFFFFFFF) {
				struct timeval psx_to = timeval_current_ofs(10, 0);
				next_timeout = timeval_min(&next_timeout, &psx_to);
                        }

			continue;
		}

		if (timeval_is_zero(&next_timeout)) {
			next_timeout = blr->expire_time;
		}
		else {
			next_timeout = timeval_min(&next_timeout,
						   &blr->expire_time);
		}
	}

	if (timeval_is_zero(&next_timeout)) {
		DEBUG(10, ("Next timeout = Infinite.\n"));
		return True;
	}

	if (DEBUGLVL(10)) {
		struct timeval cur, from_now;

		cur = timeval_current();
		from_now = timeval_until(&cur, &next_timeout);
		DEBUG(10, ("Next timeout = %d.%d seconds from now.\n",
		    (int)from_now.tv_sec, (int)from_now.tv_usec));
	}

	if (!(brl_timeout = event_add_timed(smbd_event_context(), NULL,
					    next_timeout,
					    brl_timeout_fn, NULL))) {
		return False;
	}

	return True;
}
Exemplo n.º 18
0
/****************************************************************************
  Function called when a query for *<1b> name fails.
  ****************************************************************************/
static void find_all_domain_master_names_query_fail(struct subnet_record *subrec,
                                    struct response_record *rrec,
                                    struct nmb_name *question_name, int fail_code)
{
	if( DEBUGLVL( 10 ) ) {
		dbgtext( "find_domain_master_name_query_fail:\n" );
		dbgtext( "WINS server did not reply to a query for name " );
		dbgtext( "%s.\nThis means it ", nmb_namestr(question_name) );
		dbgtext( "is probably not a Samba 1.9.18 or above WINS server.\n" );
	}
}
Exemplo n.º 19
0
static void onefs_cbrl_enumerate_blq(const char *fn)
{
	struct blocking_lock_record *blr;

	if (DEBUGLVL(10))
		return;

	DEBUG(10, ("CBRL BLR records (%s):\n", fn));

	for (blr = blocking_lock_queue; blr; blr = blr->next)
		DEBUGADD(10, ("%s\n", onefs_cbrl_blr_state_str(blr)));
}
Exemplo n.º 20
0
static void find_domain_master_name_query_fail(struct subnet_record *subrec,
                                    struct response_record *rrec,
                                    struct nmb_name *question_name, int fail_code)
{
	if( DEBUGLVL( 0 ) ) {
		dbgtext( "find_domain_master_name_query_fail:\n" );
		dbgtext( "Unable to find the Domain Master Browser name " );
		dbgtext( "%s for the workgroup %s.\n",
			nmb_namestr(question_name), question_name->name );
		dbgtext( "Unable to sync browse lists in this workgroup.\n" );
	}
}
Exemplo n.º 21
0
static void domain_master_node_status_fail(struct subnet_record *subrec,
                       struct response_record *rrec)
{
	struct userdata_struct *userdata = rrec->userdata;

	if( DEBUGLVL( 0 ) ) {
		dbgtext( "domain_master_node_status_fail:\n" );
		dbgtext( "Doing a node status request to the domain master browser\n" );
		dbgtext( "for workgroup %s ", userdata ? userdata->data : "NULL" );
		dbgtext( "at IP %s failed.\n", inet_ntoa(rrec->packet->ip) );
		dbgtext( "Cannot sync browser lists.\n" );
	}
}
Exemplo n.º 22
0
static void announce_local_master_browser_to_domain_master_browser( struct work_record *work)
{
  pstring outbuf;
  char *p;

  if(ismyip(work->dmb_addr))
  {
    if( DEBUGLVL( 2 ) )
    {
      dbgtext( "announce_local_master_browser_to_domain_master_browser:\n" );
      dbgtext( "We are both a domain and a local master browser for " );
      dbgtext( "workgroup %s.  ", work->work_group );
      dbgtext( "Do not announce to ourselves.\n" );
    }
    return;
  }

  memset(outbuf,'\0',sizeof(outbuf));
  p = outbuf;
  SCVAL(p,0,ANN_MasterAnnouncement);
  p++;

  StrnCpy(p,global_myname,15);
  strupper(p);
  p = skip_string(p,1);

  if( DEBUGLVL( 4 ) )
  {
    dbgtext( "announce_local_master_browser_to_domain_master_browser:\n" );
    dbgtext( "Sending local master announce to " );
    dbgtext( "%s for workgroup %s.\n", nmb_namestr(&work->dmb_name),
                                       work->work_group );
  }

  send_mailslot(True, BROWSE_MAILSLOT, outbuf,PTR_DIFF(p,outbuf),
		global_myname, 0x0, work->dmb_name.name, 0x0, 
		work->dmb_addr, FIRST_SUBNET->myip, DGRAM_PORT);

}
Exemplo n.º 23
0
void mprLog(int level, const char *fmt, ...)
{
	va_list	args;
	char	*buf;

	if (DEBUGLVL(level)) {
		va_start(args, fmt);
		mprAllocVsprintf(&buf, MPR_MAX_STRING, fmt, args);
		va_end(args);
		DEBUG(level, ("mprLog: %s", buf));
		mprFree(buf);
	}
}
Exemplo n.º 24
0
NTSTATUS smbXsrv_tcon_update(struct smbXsrv_tcon *tcon)
{
	struct smbXsrv_tcon_table *table = tcon->table;
	NTSTATUS status;
	uint8_t key_buf[SMBXSRV_TCON_GLOBAL_TDB_KEY_SIZE];
	TDB_DATA key;

	if (tcon->global->db_rec != NULL) {
		DEBUG(0, ("smbXsrv_tcon_update(0x%08x): "
			  "Called with db_rec != NULL'\n",
			  tcon->global->tcon_global_id));
		return NT_STATUS_INTERNAL_ERROR;
	}

	key = smbXsrv_tcon_global_id_to_key(tcon->global->tcon_global_id,
					    key_buf);

	tcon->global->db_rec = dbwrap_fetch_locked(table->global.db_ctx,
						   tcon->global, key);
	if (tcon->global->db_rec == NULL) {
		DEBUG(0, ("smbXsrv_tcon_update(0x%08x): "
			  "Failed to lock global key '%s'\n",
			  tcon->global->tcon_global_id,
			  hex_encode_talloc(talloc_tos(), key.dptr,
					    key.dsize)));
		return NT_STATUS_INTERNAL_DB_ERROR;
	}

	status = smbXsrv_tcon_global_store(tcon->global);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0,("smbXsrv_tcon_update: "
			 "global_id (0x%08x) store failed - %s\n",
			 tcon->global->tcon_global_id,
			 nt_errstr(status)));
		return status;
	}

	if (DEBUGLVL(10)) {
		struct smbXsrv_tconB tcon_blob;

		ZERO_STRUCT(tcon_blob);
		tcon_blob.version = SMBXSRV_VERSION_0;
		tcon_blob.info.info0 = tcon;

		DEBUG(10,("smbXsrv_tcon_update: global_id (0x%08x) stored\n",
			  tcon->global->tcon_global_id));
		NDR_PRINT_DEBUG(smbXsrv_tconB, &tcon_blob);
	}

	return NT_STATUS_OK;
}
Exemplo n.º 25
0
NTSTATUS svc_pipe_connect(struct dcerpc_pipe **psvc_pipe,
			  const char *hostname,
			  struct cli_credentials *credentials)
{
	NTSTATUS status;
	char *binding;

	asprintf(&binding, "ncacn_np:%s%s", hostname, DEBUGLVL(9)?"[print]":"");
	status =
	    dcerpc_pipe_connect(NULL, psvc_pipe, binding,
				&ndr_table_svcctl, credentials, ev_ctx, cmdline_lp_ctx);
	free(binding);
	return status;
}
Exemplo n.º 26
0
static void sync_with_dmb(struct work_record *work)
{
  if( DEBUGLVL( 2 ) )
  {
    dbgtext( "sync_with_dmb:\n" );
    dbgtext( "Initiating sync with domain master browser " );
    dbgtext( "%s ", nmb_namestr(&work->dmb_name) );
    dbgtext( "at IP %s ", inet_ntoa(work->dmb_addr) );
    dbgtext( "for workgroup %s\n", work->work_group );
  }

  sync_browse_lists(work, work->dmb_name.name, work->dmb_name.name_type, 
                    work->dmb_addr, False, True);
}
Exemplo n.º 27
0
static NTSTATUS svc_pipe_connect(struct tevent_context *ev_ctx, 
                          struct dcerpc_pipe **psvc_pipe,
			  const char *hostname,
			  struct cli_credentials *credentials,
			  struct loadparm_context *cllp_ctx)
{
	NTSTATUS status;
	char *binding;

	asprintf(&binding, "ncacn_np:%s%s", hostname, DEBUGLVL(9)?"[print]":"");
	status =
	    dcerpc_pipe_connect(ev_ctx, psvc_pipe, binding,
				&ndr_table_svcctl, credentials, ev_ctx, cllp_ctx);
	free(binding);
	return status;
}
Exemplo n.º 28
0
/* ************************************************************************** **
 *  Expire timed out browsers in the browserlist.
 *
 *  Input:  t - Expiration time.  Entries with death times less than this
 *              value will be removed from the list.
 *  Output: none.
 *
 * ************************************************************************** **
 */
void expire_lmb_browsers( time_t t )
{
	struct browse_cache_record *browc;
	struct browse_cache_record *nextbrowc;

	for( browc = lmb_browserlist; browc; browc = nextbrowc) {
		nextbrowc = browc->next;

		if( browc->death_time < t ) {
			if( DEBUGLVL( 3 ) ) {
				Debug1( "nmbd_browserdb:expire_lmb_browsers()\n" );
				Debug1( "  Removing timed out lmb entry %s\n", browc->lmb_name );
			}
			remove_lmb_browser_entry( browc );
		}
	}
}
Exemplo n.º 29
0
/*
  send a create
*/
static struct smb2_handle torture_smb2_create(struct smb2_tree *tree, 
					      const char *fname)
{
	struct smb2_create io;
	NTSTATUS status;
	TALLOC_CTX *tmp_ctx = talloc_new(tree);

	ZERO_STRUCT(io);
	io.in.oplock_flags = 0;
	io.in.access_mask = SEC_RIGHTS_FILE_ALL;
	io.in.file_attr   = FILE_ATTRIBUTE_NORMAL;
	io.in.open_disposition = NTCREATEX_DISP_OPEN_IF;
	io.in.share_access = 
		NTCREATEX_SHARE_ACCESS_DELETE|
		NTCREATEX_SHARE_ACCESS_READ|
		NTCREATEX_SHARE_ACCESS_WRITE;
	io.in.create_options = NTCREATEX_OPTIONS_WRITE_THROUGH;
	io.in.fname = fname;

	status = smb2_create(tree, tmp_ctx, &io);
	if (!NT_STATUS_IS_OK(status)) {
		printf("create1 failed - %s\n", nt_errstr(status));
		return io.out.file.handle;
	}

	if (DEBUGLVL(1)) {
		printf("Open gave:\n");
		printf("oplock_flags    = 0x%x\n", io.out.oplock_flags);
		printf("create_action   = 0x%x\n", io.out.create_action);
		printf("create_time     = %s\n", nt_time_string(tmp_ctx, io.out.create_time));
		printf("access_time     = %s\n", nt_time_string(tmp_ctx, io.out.access_time));
		printf("write_time      = %s\n", nt_time_string(tmp_ctx, io.out.write_time));
		printf("change_time     = %s\n", nt_time_string(tmp_ctx, io.out.change_time));
		printf("alloc_size      = %lld\n", (long long)io.out.alloc_size);
		printf("size            = %lld\n", (long long)io.out.size);
		printf("file_attr       = 0x%x\n", io.out.file_attr);
		printf("handle          = %016llx%016llx\n", 
		       (long long)io.out.file.handle.data[0], 
		       (long long)io.out.file.handle.data[1]);
	}

	talloc_free(tmp_ctx);
	
	return io.out.file.handle;
}
Exemplo n.º 30
0
static void print_socket_options(int s)
{
	int value;
	socklen_t vlen = 4;
	const smb_socket_option *p = &socket_options[0];

	/* wrapped in if statement to prevent streams leak in SCO Openserver 5.0 */
	/* reported on samba-technical  --jerry */
	if (DEBUGLVL(5)) {
	for (; p->name != NULL; p++) {
		if (getsockopt(s, p->level, p->option, (void *)&value, &vlen) == -1) {
			DEBUG(5,("Could not test socket option %s.\n", p->name));
		} else {
			DEBUG(5,("socket option %s = %d\n",p->name,value));
			}
		}
	}
 }