示例#1
0
BOOL init_dfs_q_dfs_remove(DFS_Q_DFS_REMOVE *q_d, const char *entrypath, 
			   const char *servername, const char *sharename)
{
	DEBUG(5,("init_dfs_q_dfs_remove\n"));
	init_unistr2(&q_d->DfsEntryPath, entrypath, UNI_STR_TERMINATE);
	init_unistr2(&q_d->ServerName, servername, UNI_STR_TERMINATE);
	init_unistr2(&q_d->ShareName, sharename, UNI_STR_TERMINATE);
	q_d->ptr_ServerName = q_d->ptr_ShareName = 1;
	return True;
}
示例#2
0
文件: srv_dfs_nt.c 项目: jophxy/samba
static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, DFS_INFO_3* dfs3, int num_j)
{
  int i=0,ii=0;
  for(i=0;i<num_j;i++)
    {
      pstring str;
      dfs3[i].ptr_entrypath = 1;
      if (j[i].volume_name[0] == '\0')
	      slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s",
		       global_myname, j[i].service_name);
      else
	      slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname,
		       j[i].service_name, j[i].volume_name);

      init_unistr2(&dfs3[i].entrypath, str, strlen(str)+1);
      dfs3[i].ptr_comment = 1;
      init_unistr2(&dfs3[i].comment, "", 1); 
      dfs3[i].state = 1;
      dfs3[i].num_storages = dfs3[i].num_storage_infos = j[i].referral_count;
      dfs3[i].ptr_storages = 1;
     
      /* also enumerate the storages */
      dfs3[i].storages = (DFS_STORAGE_INFO*) talloc(ctx, j[i].referral_count * 
						    sizeof(DFS_STORAGE_INFO));
      if (!dfs3[i].storages)
        return False;

      memset(dfs3[i].storages, '\0', j[i].referral_count * sizeof(DFS_STORAGE_INFO));

      for(ii=0;ii<j[i].referral_count;ii++)
	{
	  char* p; 
	  pstring path;
	  DFS_STORAGE_INFO* stor = &(dfs3[i].storages[ii]);
	  struct referral* ref = &(j[i].referral_list[ii]);
	  
	  pstrcpy(path, ref->alternate_path);
	  trim_string(path,"\\","");
	  p = strrchr(path,'\\');
	  if(p==NULL)
	    {
	      DEBUG(4,("init_reply_dfs_info_3: invalid path: no \\ found in %s\n",path));
	      continue;
	    }
	  *p = '\0';
	  DEBUG(5,("storage %d: %s.%s\n",ii,path,p+1));
	  stor->state = 2; /* set all storages as ONLINE */
	  init_unistr2(&stor->servername, path, strlen(path)+1);
	  init_unistr2(&stor->sharename,  p+1, strlen(p+1)+1);
	  stor->ptr_servername = stor->ptr_sharename = 1;
	}
    }
  return True;
}
示例#3
0
void init_buf_unistr2(UNISTR2 *str, uint32 *ptr, const char *buf)
{
	if (buf != NULL) {
		*ptr = 1;
		init_unistr2(str, buf, UNI_STR_TERMINATE);
	} else {
		*ptr = 0;
		init_unistr2(str, NULL, UNI_FLAGS_NONE);

	}
}
示例#4
0
BOOL init_dfs_q_dfs_get_info(DFS_Q_DFS_GET_INFO *q_d, const char *entrypath,
			     const char *servername, const char *sharename, 
			     uint32 info_level)
{
	DEBUG(5,("init_dfs_q2_get_info\n"));
	init_unistr2(&q_d->uni_path, entrypath, UNI_STR_TERMINATE);
	init_unistr2(&q_d->uni_server, servername, UNI_STR_TERMINATE);
	init_unistr2(&q_d->uni_share, sharename, UNI_STR_TERMINATE);
	q_d->level = info_level;
	q_d->ptr_server = q_d->ptr_share = 1;
	return True;
}
示例#5
0
static BOOL init_reply_dfs_info_3(TALLOC_CTX *ctx, struct junction_map* j, NETDFS_DFS_INFO3* dfs3)
{
	int ii;
	pstring str;
	dfs3->ptr0_path = 1;
	if (j->volume_name[0] == '\0')
		slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s",
			global_myname(), j->service_name);
	else
		slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(),
			j->service_name, j->volume_name);

	init_unistr2(&dfs3->path, str, UNI_STR_TERMINATE);
	dfs3->ptr0_comment = 1;
	init_unistr2(&dfs3->comment, j->comment, UNI_STR_TERMINATE);
	dfs3->state = 1;
	dfs3->num_stores = dfs3->size_stores = j->referral_count;
    
	/* also enumerate the stores */
	if (j->referral_count) {
		dfs3->stores = TALLOC_ARRAY(ctx, NETDFS_DFS_STORAGEINFO, j->referral_count);
		if (!dfs3->stores)
			return False;
		memset(dfs3->stores, '\0', j->referral_count * sizeof(NETDFS_DFS_STORAGEINFO));
		dfs3->ptr0_stores = 1;
	} else {
		dfs3->stores = NULL;
		dfs3->ptr0_stores = 0;
	}

	for(ii=0;ii<j->referral_count;ii++) {
		char* p; 
		pstring path;
		NETDFS_DFS_STORAGEINFO* stor = &(dfs3->stores[ii]);
		struct referral* ref = &(j->referral_list[ii]);
  
		pstrcpy(path, ref->alternate_path);
		trim_char(path,'\\','\0');
		p = strrchr_m(path,'\\');
		if(p==NULL) {
			DEBUG(4,("init_reply_dfs_info_3: invalid path: no \\ found in %s\n",path));
			continue;
		}
		*p = '\0';
		DEBUG(5,("storage %d: %s.%s\n",ii,path,p+1));
		stor->state = 2; /* set all stores as ONLINE */
		init_unistr2(&stor->server, path, UNI_STR_TERMINATE);
		init_unistr2(&stor->share,  p+1, UNI_STR_TERMINATE);
		stor->ptr0_server = stor->ptr0_share = 1;
	}
	return True;
}
示例#6
0
static BOOL init_reply_dfs_info_2(struct junction_map* j, NETDFS_DFS_INFO2* dfs2)
{
	pstring str;
	dfs2->ptr0_path = 1;
	slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(),
		j->service_name, j->volume_name);
	init_unistr2(&dfs2->path, str, UNI_STR_TERMINATE);
	dfs2->ptr0_comment = 0;
	init_unistr2(&dfs2->comment, j->comment, UNI_STR_TERMINATE);
	dfs2->state = 1; /* set up state of dfs junction as OK */
	dfs2->num_stores = j->referral_count;
	return True;
}
示例#7
0
static void init_netinfo_2(NETLOGON_INFO_2 *info, uint32 flags, uint32 pdc_status,
				uint32 tc_status, char *trusted_dc_name)
{
	int len_dc_name = strlen(trusted_dc_name);
	info->flags      = flags;
	info->pdc_status = pdc_status;
	info->ptr_trusted_dc_name = 1;
	info->tc_status  = tc_status;

	if (trusted_dc_name != NULL)
		init_unistr2(&(info->uni_trusted_dc_name), trusted_dc_name, len_dc_name+1);
	else
		init_unistr2(&(info->uni_trusted_dc_name), "", 1);
}
示例#8
0
void init_log_info(DOM_LOG_INFO *loginfo, const char *logon_srv, const char *acct_name,
		uint16 sec_chan, const char *comp_name)
{
	DEBUG(5,("make_log_info %d\n", __LINE__));

	loginfo->undoc_buffer = 1;

	init_unistr2(&loginfo->uni_logon_srv, logon_srv, UNI_STR_TERMINATE);
	init_unistr2(&loginfo->uni_acct_name, acct_name, UNI_STR_TERMINATE);

	loginfo->sec_chan = sec_chan;

	init_unistr2(&loginfo->uni_comp_name, comp_name, UNI_STR_TERMINATE);
}
示例#9
0
void init_id_info2(NET_ID_INFO_2 *id, char *domain_name,
				uint32 param_ctrl, uint32 log_id_low, uint32 log_id_high,
				char *user_name, char *wksta_name,
				unsigned char lm_challenge[8],
				unsigned char lm_chal_resp[24],
				unsigned char nt_chal_resp[24])
{
	int len_domain_name = strlen(domain_name);
	int len_user_name   = strlen(user_name  );
	int len_wksta_name  = strlen(wksta_name );
	int nt_chal_resp_len = ((nt_chal_resp != NULL) ? 24 : 0);
	int lm_chal_resp_len = ((lm_chal_resp != NULL) ? 24 : 0);
	unsigned char lm_owf[24];
	unsigned char nt_owf[24];

	DEBUG(5,("init_id_info2: %d\n", __LINE__));

	id->ptr_id_info2 = 1;

	init_uni_hdr(&id->hdr_domain_name, len_domain_name);

	id->param_ctrl = param_ctrl;
	init_logon_id(&id->logon_id, log_id_low, log_id_high);

	init_uni_hdr(&id->hdr_user_name, len_user_name);
	init_uni_hdr(&id->hdr_wksta_name, len_wksta_name);

	if (nt_chal_resp) {
		/* oops.  can only send what-ever-it-is direct */
		memcpy(nt_owf, nt_chal_resp, 24);
		nt_chal_resp = nt_owf;
	}
	if (lm_chal_resp) {
		/* oops.  can only send what-ever-it-is direct */
		memcpy(lm_owf, lm_chal_resp, 24);
		lm_chal_resp = lm_owf;
	}

	memcpy(id->lm_chal, lm_challenge, sizeof(id->lm_chal));
	init_str_hdr(&id->hdr_nt_chal_resp, 24, nt_chal_resp_len, (nt_chal_resp != NULL) ? 1 : 0);
	init_str_hdr(&id->hdr_lm_chal_resp, 24, lm_chal_resp_len, (lm_chal_resp != NULL) ? 1 : 0);

	init_unistr2(&id->uni_domain_name, domain_name, len_domain_name);
	init_unistr2(&id->uni_user_name, user_name, len_user_name);
	init_unistr2(&id->uni_wksta_name, wksta_name, len_wksta_name);

	init_string2(&id->nt_chal_resp, (char *)nt_chal_resp, nt_chal_resp_len);
	init_string2(&id->lm_chal_resp, (char *)lm_chal_resp, lm_chal_resp_len);
}
示例#10
0
void init_q_req_chal(NET_Q_REQ_CHAL *q_c,
				char *logon_srv, char *logon_clnt,
				DOM_CHAL *clnt_chal)
{
	DEBUG(5,("make_q_req_chal: %d\n", __LINE__));

	q_c->undoc_buffer = 1; /* don't know what this buffer is */

	init_unistr2(&q_c->uni_logon_srv, logon_srv , strlen(logon_srv )+1);
	init_unistr2(&q_c->uni_logon_clnt, logon_clnt, strlen(logon_clnt)+1);

	memcpy(q_c->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data));

	DEBUG(5,("make_q_req_chal: %d\n", __LINE__));
}
示例#11
0
void init_r_trust_dom(NET_R_TRUST_DOM_LIST *r_t,
			uint32 num_doms, char *dom_name)
{
	int i = 0;

	DEBUG(5,("make_r_trust_dom\n"));

	for (i = 0; i < MAX_TRUST_DOMS; i++) {
		r_t->uni_trust_dom_name[i].uni_str_len = 0;
		r_t->uni_trust_dom_name[i].uni_max_len = 0;
	}
	if (num_doms > MAX_TRUST_DOMS)
		num_doms = MAX_TRUST_DOMS;

	for (i = 0; i < num_doms; i++) {
		fstring domain_name;
		fstrcpy(domain_name, dom_name);
		strupper(domain_name);
		init_unistr2(&r_t->uni_trust_dom_name[i], domain_name, strlen(domain_name)+1);
		/* the use of UNISTR2 here is non-standard. */
		r_t->uni_trust_dom_name[i].undoc = 0x1;
	}
	
	r_t->status = 0;
}
示例#12
0
WERROR rpccli_svcctl_open_service( struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, 
                                POLICY_HND *hSCM, POLICY_HND *hService, 
				const char *servicename, uint32 access_desired )
{
	SVCCTL_Q_OPEN_SERVICE in;
	SVCCTL_R_OPEN_SERVICE out;
	prs_struct qbuf, rbuf;
	
	ZERO_STRUCT(in);
	ZERO_STRUCT(out);
	
	memcpy( &in.handle, hSCM, sizeof(POLICY_HND) );
	init_unistr2( &in.servicename, servicename, UNI_STR_TERMINATE );
	in.access = access_desired;
	
	CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_OPEN_SERVICE_W, 
	            in, out, 
	            qbuf, rbuf,
	            svcctl_io_q_open_service,
	            svcctl_io_r_open_service, 
	            WERR_GENERAL_FAILURE );
	
	if ( !W_ERROR_IS_OK( out.status ) )
		return out.status;

	memcpy( hService, &out.handle, sizeof(POLICY_HND) );
	
	return out.status;
}
示例#13
0
BOOL init_svcctl_r_get_display_name( SVCCTL_R_GET_DISPLAY_NAME *r_u, const char *displayname )
{
	r_u->display_name_len = strlen(displayname);
	init_unistr2( &r_u->displayname, displayname, UNI_STR_TERMINATE );

	return True;
}
示例#14
0
static void init_clnt_srv(DOM_CLNT_SRV *logcln, const char *logon_srv, const char *comp_name)
{
	DEBUG(5,("init_clnt_srv: %d\n", __LINE__));

	if (logon_srv != NULL) {
		logcln->undoc_buffer = 1;
		init_unistr2(&logcln->uni_logon_srv, logon_srv, UNI_STR_TERMINATE);
	} else {
		logcln->undoc_buffer = 0;
	}

	if (comp_name != NULL) {
		logcln->undoc_buffer2 = 1;
		init_unistr2(&logcln->uni_comp_name, comp_name, UNI_STR_TERMINATE);
	} else {
		logcln->undoc_buffer2 = 0;
	}
}
示例#15
0
PyObject *spoolss_hnd_addform(PyObject *self, PyObject *args, PyObject *kw)
{
	spoolss_policy_hnd_object *hnd = (spoolss_policy_hnd_object *)self;
	WERROR werror;
	PyObject *info;
	FORM form;
	int level;
	static char *kwlist[] = {"form", NULL};

	/* Parse parameters */
	
	if (!PyArg_ParseTupleAndKeywords(
		    args, kw, "O!", kwlist, &PyDict_Type, &info))
		return NULL;
	
	/* Call rpc function */
	
	if (!py_to_FORM(&form, info)) {
		PyErr_SetString(spoolss_error, "invalid form");
		return NULL;
	}

	if (!get_level_value(info, &level)) {
		PyErr_SetString(spoolss_error, "invalid info level");
		return NULL;
	}

	if (level != 1) {
		PyErr_SetString(spoolss_error, "unsupported info level");
		return NULL;
	}
	
	switch (level) {
	case 1: {
		PyObject *obj = PyDict_GetItemString(info, "name");
		char *form_name = PyString_AsString(obj);

		init_unistr2(&form.name, form_name, UNI_STR_TERMINATE);
		break;
	}
	default:
		PyErr_SetString(spoolss_error, "unsupported info level");
		return NULL;
	}
		
	werror = rpccli_spoolss_addform(hnd->cli, hnd->mem_ctx, &hnd->pol,
					level, &form);


	if (!W_ERROR_IS_OK(werror)) {
		PyErr_SetObject(spoolss_werror, py_werror_tuple(werror));
		return NULL;
	}

	Py_INCREF(Py_None);
	return Py_None;
}
示例#16
0
static BOOL init_reply_dfs_info_1(struct junction_map* j, NETDFS_DFS_INFO1* dfs1)
{
	pstring str;
	dfs1->ptr0_path = 1;
	slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname(), 
		j->service_name, j->volume_name);
	DEBUG(5,("init_reply_dfs_info_1: initing entrypath: %s\n",str));
	init_unistr2(&dfs1->path,str,UNI_STR_TERMINATE);
	return True;
}
示例#17
0
BOOL init_dfs_q_dfs_add(DFS_Q_DFS_ADD *q_d, const char *entrypath, 
			const char *servername, const char *sharename, 
			const char *comment, uint32 flags)
{
	DEBUG(5,("init_dfs_q_dfs_add\n"));
	q_d->ptr_DfsEntryPath = q_d->ptr_ServerName = q_d->ptr_ShareName = 1;
	init_unistr2(&q_d->DfsEntryPath, entrypath, UNI_STR_TERMINATE);
	init_unistr2(&q_d->ServerName, servername, UNI_STR_TERMINATE);
	init_unistr2(&q_d->ShareName, sharename, UNI_STR_TERMINATE);
	if(comment != NULL) {
		init_unistr2(&q_d->Comment, comment,UNI_STR_TERMINATE);
		q_d->ptr_Comment = 1;
	} else {
		q_d->ptr_Comment = 0;
	}

	q_d->Flags = flags;
	return True;
}
示例#18
0
void init_unistr4(UNISTR4 *uni4, const char *buf, enum unistr2_term_codes flags)
{
	uni4->string = TALLOC_P( get_talloc_ctx(), UNISTR2 );
	if (!uni4->string) {
		smb_panic("init_unistr4: talloc fail\n");
		return;
	}
	init_unistr2( uni4->string, buf, flags );

	uni4->length = 2 * (uni4->string->uni_str_len);
	uni4->size   = 2 * (uni4->string->uni_max_len);
}
示例#19
0
文件: srv_dfs_nt.c 项目: jophxy/samba
static BOOL init_reply_dfs_info_1(struct junction_map* j, DFS_INFO_1* dfs1, int num_j)
{
  int i=0;
  for(i=0;i<num_j;i++) 
    {
      pstring str;
      dfs1[i].ptr_entrypath = 1;
      slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname, 
	       j[i].service_name, j[i].volume_name);
      DEBUG(5,("init_reply_dfs_info_1: %d) initing entrypath: %s\n",i,str));
      init_unistr2(&dfs1[i].entrypath,str,strlen(str)+1);
    }
  return True;
}
示例#20
0
BOOL init_q_ds_enum_domain_trusts( DS_Q_ENUM_DOM_TRUSTS *q, const char *server, 
                                 uint32 flags )
{
	q->flags = flags;
	
	if ( server && *server )
		q->server_ptr = 1;
	else
		q->server_ptr = 0;

	init_unistr2( &q->server, server, UNI_STR_TERMINATE);
		
	return True;
}
示例#21
0
文件: srv_dfs_nt.c 项目: jophxy/samba
static BOOL init_reply_dfs_info_2(struct junction_map* j, DFS_INFO_2* dfs2, int num_j)
{
  int i=0;
  for(i=0;i<num_j;i++)
    {
      pstring str;
      dfs2[i].ptr_entrypath = 1;
      slprintf(str, sizeof(pstring)-1, "\\\\%s\\%s\\%s", global_myname,
	       j[i].service_name, j[i].volume_name);
      init_unistr2(&dfs2[i].entrypath, str, strlen(str)+1);
      dfs2[i].ptr_comment = 0;
      dfs2[i].state = 1; /* set up state of dfs junction as OK */
      dfs2[i].num_storages = j[i].referral_count;
    }
  return True;
}
示例#22
0
void init_unistr2_from_datablob(UNISTR2 *str, DATA_BLOB *blob) 
{
	/* Allocs the unistring */
	init_unistr2(str, NULL, UNI_FLAGS_NONE);
	
	/* Sets the values */
	str->uni_str_len = blob->length / sizeof(uint16);
	str->uni_max_len = str->uni_str_len;
	str->offset = 0;
	if (blob->length) {
		str->buffer = (uint16 *) memdup(blob->data, blob->length);
	} else {
		str->buffer = NULL;
	}
	if ((str->buffer == NULL) && (blob->length > 0)) {
		smb_panic("init_unistr2_from_datablob: malloc fail\n");
	}
}
示例#23
0
WERROR rpccli_svcctl_open_scm(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, 
                              POLICY_HND *hSCM, uint32 access_desired )
{
	SVCCTL_Q_OPEN_SCMANAGER in;
	SVCCTL_R_OPEN_SCMANAGER out;
	prs_struct qbuf, rbuf;
	fstring server;
	
	ZERO_STRUCT(in);
	ZERO_STRUCT(out);
	
	/* leave the database name NULL to get the default service db */

	in.database = NULL;

	/* set the server name */

	if ( !(in.servername = TALLOC_P( mem_ctx, UNISTR2 )) )
		return WERR_NOMEM;
	fstr_sprintf( server, "\\\\%s", cli->cli->desthost );
	init_unistr2( in.servername, server, UNI_STR_TERMINATE );

	in.access = access_desired;
	
	CLI_DO_RPC_WERR( cli, mem_ctx, PI_SVCCTL, SVCCTL_OPEN_SCMANAGER_W, 
	            in, out, 
	            qbuf, rbuf,
	            svcctl_io_q_open_scmanager,
	            svcctl_io_r_open_scmanager, 
	            WERR_GENERAL_FAILURE );
	
	if ( !W_ERROR_IS_OK( out.status ) )
		return out.status;

	memcpy( hSCM, &out.handle, sizeof(POLICY_HND) );
	
	return out.status;
}
示例#24
0
static void fill_in_driver_values( NT_PRINTER_DRIVER_INFO_LEVEL_3 *info3, REGVAL_CTR *values )
{
	char *buffer = NULL;
	int buffer_size = 0;
	int i, length;
	char *filename;
	UNISTR2	data;
	
	filename = dos_basename( info3->driverpath );
	init_unistr2( &data, filename, UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Driver", REG_SZ, (char*)data.buffer, 
		data.uni_str_len*sizeof(uint16) );
	
	filename = dos_basename( info3->configfile );
	init_unistr2( &data, filename, UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Configuration File", REG_SZ, (char*)data.buffer, 
		data.uni_str_len*sizeof(uint16) );
	
	filename = dos_basename( info3->datafile );
	init_unistr2( &data, filename, UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Data File", REG_SZ, (char*)data.buffer, 
		data.uni_str_len*sizeof(uint16) );
	
	filename = dos_basename( info3->helpfile );
	init_unistr2( &data, filename, UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Help File", REG_SZ, (char*)data.buffer, 
		data.uni_str_len*sizeof(uint16) );
	
	init_unistr2( &data, info3->defaultdatatype, UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Data Type", REG_SZ, (char*)data.buffer, 
		data.uni_str_len*sizeof(uint16) );
	
	regval_ctr_addvalue( values, "Version", REG_DWORD, (char*)&info3->cversion, 
		sizeof(info3->cversion) );
	
	if ( info3->dependentfiles ) {
		/* place the list of dependent files in a single 
		   character buffer, separating each file name by
		   a NULL */
		   
		for ( i=0; strcmp(info3->dependentfiles[i], ""); i++ ) {
			/* strip the path to only the file's base name */
		
			filename = dos_basename( info3->dependentfiles[i] );
			
			length = strlen(filename);
		
			buffer = (char *)SMB_REALLOC( buffer, buffer_size + (length + 1)*sizeof(uint16) );
			if ( !buffer ) {
				break;
			}
			
			init_unistr2( &data, filename, UNI_STR_TERMINATE);
			memcpy( buffer+buffer_size, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );
		
			buffer_size += (length + 1)*sizeof(uint16);
		}
		
		/* terminated by double NULL.  Add the final one here */
		
		buffer = (char *)SMB_REALLOC( buffer, buffer_size + 2 );
		if ( !buffer ) {
			buffer_size = 0;
		} else {
			buffer[buffer_size++] = '\0';
			buffer[buffer_size++] = '\0';
		}
	}
	
	regval_ctr_addvalue( values, "Dependent Files",    REG_MULTI_SZ, buffer, buffer_size );
		
	SAFE_FREE( buffer );
	
	return;
}
示例#25
0
static void fill_in_printer_values( NT_PRINTER_INFO_LEVEL_2 *info2, REGVAL_CTR *values )
{
	DEVICEMODE	*devmode;
	prs_struct	prs;
	uint32		offset;
	UNISTR2		data;
	char 		*p;
	uint32 printer_status = PRINTER_STATUS_OK;
	
	regval_ctr_addvalue( values, "Attributes",       REG_DWORD, (char*)&info2->attributes,       sizeof(info2->attributes) );
	regval_ctr_addvalue( values, "Priority",         REG_DWORD, (char*)&info2->priority,         sizeof(info2->attributes) );
	regval_ctr_addvalue( values, "ChangeID",         REG_DWORD, (char*)&info2->changeid,         sizeof(info2->changeid) );
	regval_ctr_addvalue( values, "Default Priority", REG_DWORD, (char*)&info2->default_priority, sizeof(info2->default_priority) );
	
	/* lie and say everything is ok since we don't want to call print_queue_length() to get the real status */
	regval_ctr_addvalue( values, "Status",           REG_DWORD, (char*)&printer_status,          sizeof(info2->status) );

	regval_ctr_addvalue( values, "StartTime",        REG_DWORD, (char*)&info2->starttime,        sizeof(info2->starttime) );
	regval_ctr_addvalue( values, "UntilTime",        REG_DWORD, (char*)&info2->untiltime,        sizeof(info2->untiltime) );

	/* strip the \\server\ from this string */
	if ( !(p = strrchr( info2->printername, '\\' ) ) )
		p = info2->printername;
	else
		p++;
	init_unistr2( &data, p, UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Name", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );

	init_unistr2( &data, info2->location, UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Location", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );

	init_unistr2( &data, info2->comment, UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Description", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );

	init_unistr2( &data, info2->parameters, UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Parameters", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );

	init_unistr2( &data, info2->portname, UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Port", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );

	init_unistr2( &data, info2->sharename, UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Share Name", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );

	init_unistr2( &data, info2->drivername, UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Printer Driver", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );

	init_unistr2( &data, info2->sepfile, UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Separator File", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );

	init_unistr2( &data, "WinPrint", UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Print Processor",  REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );

	init_unistr2( &data, "RAW", UNI_STR_TERMINATE);
	regval_ctr_addvalue( values, "Datatype", REG_SZ, (char*)data.buffer, data.uni_str_len*sizeof(uint16) );

		
	/* use a prs_struct for converting the devmode and security 
	   descriptor to REG_BINARY */
	
	prs_init( &prs, RPC_MAX_PDU_FRAG_LEN, values, MARSHALL);

	/* stream the device mode */
		
	if ( (devmode = construct_dev_mode( info2->sharename )) != NULL ) {
		if ( spoolss_io_devmode( "devmode", &prs, 0, devmode ) ) {
			offset = prs_offset( &prs );
			regval_ctr_addvalue( values, "Default Devmode", REG_BINARY, prs_data_p(&prs), offset );
		}
	}
		
	prs_mem_clear( &prs );
	prs_set_offset( &prs, 0 );
		
	/* stream the printer security descriptor */
	
	if ( info2->secdesc_buf && info2->secdesc_buf->len )  {
		if ( sec_io_desc("sec_desc", &info2->secdesc_buf->sec, &prs, 0 ) ) {
			offset = prs_offset( &prs );
			regval_ctr_addvalue( values, "Security", REG_BINARY, prs_data_p(&prs), offset );
		}
	}

	prs_mem_free( &prs );

	return;		
}
示例#26
0
bool eventlog_init_keys(void)
{
    /* Find all of the eventlogs, add keys for each of them */
    const char **elogs = lp_eventlog_list();
    char *evtlogpath = NULL;
    char *evtfilepath = NULL;
    struct regsubkey_ctr *subkeys;
    REGVAL_CTR *values;
    uint32 uiMaxSize;
    uint32 uiRetention;
    uint32 uiCategoryCount;
    UNISTR2 data;
    TALLOC_CTX *ctx = talloc_tos();
    WERROR werr;

    while (elogs && *elogs) {
        werr = regsubkey_ctr_init(ctx, &subkeys);
        if (!W_ERROR_IS_OK(werr)) {
            DEBUG( 0, ( "talloc() failure!\n" ) );
            return False;
        }
        regdb_fetch_keys(KEY_EVENTLOG, subkeys);
        regsubkey_ctr_addkey( subkeys, *elogs );
        if ( !regdb_store_keys( KEY_EVENTLOG, subkeys ) ) {
            TALLOC_FREE(subkeys);
            return False;
        }
        TALLOC_FREE(subkeys);

        /* add in the key of form KEY_EVENTLOG/Application */
        DEBUG( 5,
               ( "Adding key of [%s] to path of [%s]\n", *elogs,
                 KEY_EVENTLOG ) );

        evtlogpath = talloc_asprintf(ctx, "%s\\%s",
                                     KEY_EVENTLOG, *elogs);
        if (!evtlogpath) {
            return false;
        }
        /* add in the key of form KEY_EVENTLOG/Application/Application */
        DEBUG( 5,
               ( "Adding key of [%s] to path of [%s]\n", *elogs,
                 evtlogpath ) );
        werr = regsubkey_ctr_init(ctx, &subkeys);
        if (!W_ERROR_IS_OK(werr)) {
            DEBUG( 0, ( "talloc() failure!\n" ) );
            return False;
        }
        regdb_fetch_keys( evtlogpath, subkeys );
        regsubkey_ctr_addkey( subkeys, *elogs );

        if ( !regdb_store_keys( evtlogpath, subkeys ) ) {
            TALLOC_FREE(subkeys);
            return False;
        }
        TALLOC_FREE( subkeys );

        /* now add the values to the KEY_EVENTLOG/Application form key */
        if (!(values = TALLOC_ZERO_P(ctx, REGVAL_CTR))) {
            DEBUG( 0, ( "talloc() failure!\n" ) );
            return False;
        }
        DEBUG( 5,
               ( "Storing values to eventlog path of [%s]\n",
                 evtlogpath ) );
        regdb_fetch_values( evtlogpath, values );


        if (!regval_ctr_key_exists(values, "MaxSize")) {

            /* assume we have none, add them all */

            /* hard code some initial values */

            /* uiDisplayNameId = 0x00000100; */
            uiMaxSize = 0x00080000;
            uiRetention = 0x93A80;

            regval_ctr_addvalue(values, "MaxSize", REG_DWORD,
                                (char *)&uiMaxSize,
                                sizeof(uint32));

            regval_ctr_addvalue(values, "Retention", REG_DWORD,
                                (char *)&uiRetention,
                                sizeof(uint32));
            init_unistr2(&data, *elogs, UNI_STR_TERMINATE);

            regval_ctr_addvalue(values, "PrimaryModule", REG_SZ,
                                (char *)data.buffer,
                                data.uni_str_len *
                                sizeof(uint16));
            init_unistr2(&data, *elogs, UNI_STR_TERMINATE);

            regval_ctr_addvalue(values, "Sources", REG_MULTI_SZ,
                                (char *)data.buffer,
                                data.uni_str_len *
                                sizeof(uint16));

            evtfilepath = talloc_asprintf(ctx,
                                          "%%SystemRoot%%\\system32\\config\\%s.tdb",
                                          *elogs);
            if (!evtfilepath) {
                TALLOC_FREE(values);
            }
            init_unistr2(&data, evtfilepath, UNI_STR_TERMINATE);
            regval_ctr_addvalue(values, "File", REG_EXPAND_SZ, (char *)data.buffer,
                                data.uni_str_len * sizeof(uint16));
            regdb_store_values(evtlogpath, values);

        }

        TALLOC_FREE(values);

        /* now do the values under KEY_EVENTLOG/Application/Application */
        TALLOC_FREE(evtlogpath);
        evtlogpath = talloc_asprintf(ctx, "%s\\%s\\%s",
                                     KEY_EVENTLOG, *elogs, *elogs);
        if (!evtlogpath) {
            return false;
        }
        if (!(values = TALLOC_ZERO_P(ctx, REGVAL_CTR))) {
            DEBUG( 0, ( "talloc() failure!\n" ) );
            return False;
        }
        DEBUG( 5,
               ( "Storing values to eventlog path of [%s]\n",
                 evtlogpath));
        regdb_fetch_values(evtlogpath, values);
        if (!regval_ctr_key_exists( values, "CategoryCount")) {

            /* hard code some initial values */

            uiCategoryCount = 0x00000007;
            regval_ctr_addvalue( values, "CategoryCount",
                                 REG_DWORD,
                                 ( char * ) &uiCategoryCount,
                                 sizeof( uint32 ) );
            init_unistr2( &data,
                          "%SystemRoot%\\system32\\eventlog.dll",
                          UNI_STR_TERMINATE );

            regval_ctr_addvalue( values, "CategoryMessageFile",
                                 REG_EXPAND_SZ,
                                 ( char * ) data.buffer,
                                 data.uni_str_len *
                                 sizeof( uint16 ) );
            regdb_store_values( evtlogpath, values );
        }
        TALLOC_FREE(values);
        elogs++;
    }

    return true;
}
示例#27
0
static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN_INFO_BASIC **info) 
{
	DSROLE_PRIMARY_DOMAIN_INFO_BASIC *basic;
	const char *netbios_domain = "";
	fstring dnsdomain;

	DEBUG(10,("fill_dsrole_dominfo_basic: enter\n"));

	if ( !(basic = TALLOC_ZERO_P(ctx, DSROLE_PRIMARY_DOMAIN_INFO_BASIC)) ) {
		DEBUG(0,("fill_dsrole_dominfo_basic: FATAL error!  talloc_xero() failed\n"));
		return NT_STATUS_NO_MEMORY;
	}

	switch ( lp_server_role() ) {
		case ROLE_STANDALONE:
			basic->machine_role = DSROLE_STANDALONE_SRV;
			basic->netbios_ptr = 1;
			netbios_domain = get_global_sam_name();
			break;
		case ROLE_DOMAIN_MEMBER:
			basic->netbios_ptr = 1;
			netbios_domain = lp_workgroup();
			basic->machine_role = DSROLE_DOMAIN_MEMBER_SRV;
			break;
		case ROLE_DOMAIN_BDC:
			basic->netbios_ptr = 1;
			netbios_domain = get_global_sam_name();
			basic->machine_role = DSROLE_BDC;
			break;
		case ROLE_DOMAIN_PDC:
			basic->netbios_ptr = 1;
			netbios_domain = get_global_sam_name();
			basic->machine_role = DSROLE_PDC;
			break;
	}

	/* always set netbios name */

	init_unistr2( &basic->netbios_domain, netbios_domain, UNI_STR_TERMINATE);

	if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) )
		basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT;

	/* fill in some additional fields if we are a member of an AD domain */

	if ( lp_security() == SEC_ADS ) {
		fstrcpy( dnsdomain, lp_realm() );
		strlower_m( dnsdomain );
		
		basic->dnsname_ptr = 1;
		init_unistr2( &basic->dns_domain, dnsdomain, UNI_STR_TERMINATE);

		/* FIXME!! We really should fill in the correct forest
		   name.  Should get this information from winbindd.  */
		basic->forestname_ptr = 1;
		init_unistr2( &basic->forest_domain, dnsdomain, UNI_STR_TERMINATE);
	} else {
		/* security = domain should not fill in the dns or
		   forest name */
		basic->dnsname_ptr = 0;
		basic->forestname_ptr = 0;
	}

	*info = basic;

	return NT_STATUS_OK;
}
示例#28
0
文件: srv_reg_nt.c 项目: jophxy/samba
NTSTATUS _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u)
{
	NTSTATUS status = NT_STATUS_OK;
	const char *key = NULL;
	uint32 type=0x1; /* key type: REG_SZ */

	UNISTR2 *uni_key = NULL;
	BUFFER2 *buf = NULL;
	fstring name;

	DEBUG(5,("_reg_info: %d\n", __LINE__));

	if (!find_policy_by_hnd(p, &q_u->pol, NULL))
		return NT_STATUS_INVALID_HANDLE;

	fstrcpy(name, dos_unistrn2(q_u->uni_type.buffer, q_u->uni_type.uni_str_len));

	DEBUG(5,("reg_info: checking key: %s\n", name));

	uni_key = (UNISTR2 *)talloc_zero(p->mem_ctx, sizeof(UNISTR2));
	buf = (BUFFER2 *)talloc_zero(p->mem_ctx, sizeof(BUFFER2));

	if (!uni_key || !buf)
		return NT_STATUS_NO_MEMORY;

	if ( strequal(name, "RefusePasswordChange") ) {
		type=0xF770;
		status = NT_STATUS_NO_SUCH_FILE;
		init_unistr2(uni_key, "", 0);
		init_buffer2(buf, (uint8*) uni_key->buffer, uni_key->uni_str_len*2);
		
		buf->buf_max_len=4;

		goto out;
	}

	switch (lp_server_role()) {
	case ROLE_DOMAIN_PDC:
	case ROLE_DOMAIN_BDC:
		key = "LanmanNT";
		break;
	case ROLE_STANDALONE:
		key = "ServerNT";
		break;
	case ROLE_DOMAIN_MEMBER:
		key = "WinNT";
		break;
	}

	/* This makes the server look like a member server to clients */
	/* which tells clients that we have our own local user and    */
	/* group databases and helps with ACL support.                */

	init_unistr2(uni_key, key, strlen(key)+1);
	init_buffer2(buf, (uint8*)uni_key->buffer, uni_key->uni_str_len*2);
  
 out:
	init_reg_r_info(q_u->ptr_buf, r_u, buf, type, status);

	DEBUG(5,("reg_open_entry: %d\n", __LINE__));

	return status;
}
示例#29
0
static BOOL init_reply_dfs_info_100(struct junction_map* j, NETDFS_DFS_INFO100* dfs100)
{
	dfs100->ptr0_comment = 1;
	init_unistr2(&dfs100->comment, j->comment, UNI_STR_TERMINATE);
	return True;
}
示例#30
0
static NTSTATUS fill_dsrole_dominfo_basic(TALLOC_CTX *ctx, DSROLE_PRIMARY_DOMAIN_INFO_BASIC **info) 
{
	DSROLE_PRIMARY_DOMAIN_INFO_BASIC *basic;
	const char *netbios_domain;
	fstring dnsdomain;

	DEBUG(10,("fill_dsrole_dominfo_basic: enter\n"));

	if ( !(basic = talloc_zero(ctx, sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC))) ) {
		DEBUG(0,("fill_dsrole_dominfo_basic: FATAL error!  talloc_xero() failed\n"));
		return NT_STATUS_NO_MEMORY;
	}

	switch ( lp_server_role() ) {
		case ROLE_STANDALONE:
			basic->machine_role = DSROLE_STANDALONE_SRV;
			break;
		case ROLE_DOMAIN_MEMBER:
			basic->machine_role = DSROLE_DOMAIN_MEMBER_SRV;
			break;
		case ROLE_DOMAIN_BDC:
			basic->machine_role = DSROLE_BDC;
			basic->flags = DSROLE_PRIMARY_DS_RUNNING|DSROLE_PRIMARY_DS_MIXED_MODE;
			if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) )
				basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT;
			get_mydnsdomname(dnsdomain);
			strlower_m(dnsdomain);
			break;
		case ROLE_DOMAIN_PDC:
			basic->machine_role = DSROLE_PDC;
			basic->flags = DSROLE_PRIMARY_DS_RUNNING|DSROLE_PRIMARY_DS_MIXED_MODE;
			if ( secrets_fetch_domain_guid( lp_workgroup(), &basic->domain_guid ) )
				basic->flags |= DSROLE_PRIMARY_DOMAIN_GUID_PRESENT;
			get_mydnsdomname(dnsdomain);
			strlower_m(dnsdomain);
			break;
	}

	basic->unknown = 0x6173;		/* seen on the wire; maybe padding */

	/* always set netbios name */

	basic->netbios_ptr = 1;
	netbios_domain = get_global_sam_name();
	init_unistr2( &basic->netbios_domain, netbios_domain, UNI_FLAGS_NONE);

	basic->dnsname_ptr = 1;
	init_unistr2( &basic->dns_domain, dnsdomain, UNI_FLAGS_NONE);
	basic->forestname_ptr = 1;
	init_unistr2( &basic->forest_domain, dnsdomain, UNI_FLAGS_NONE);
	

	/* fill in some additional fields if we are a member of an AD domain */

	if ( lp_security() == SEC_ADS ) {	
		/* TODO */
		;;
	}

	*info = basic;

	return NT_STATUS_OK;
}