コード例 #1
0
static int dbwrap_tool_fetch_hex(struct db_context *db,
				 const char *keyname,
				 const char *data)
{
	TDB_DATA tdbdata;
	DATA_BLOB datablob;
	NTSTATUS status;
	TALLOC_CTX *tmp_ctx = talloc_stackframe();
	char *hex_string;
	int ret;

	status = dbwrap_fetch_bystring(db, tmp_ctx, keyname, &tdbdata);
	if (NT_STATUS_IS_OK(status)) {
	        datablob.data = tdbdata.dptr;
		datablob.length = tdbdata.dsize;

		hex_string = data_blob_hex_string_upper(tmp_ctx, &datablob);
		if (hex_string == NULL) {
			d_fprintf(stderr, "ERROR: could not get hex string "
				  "from data blob\n");
			ret = -1;
		} else {
			d_printf("%s\n", hex_string);
			ret =  0;
		}
	} else {
		d_fprintf(stderr, "ERROR: could not fetch hex key '%s': "
			  "%s\n", nt_errstr(status), keyname);
		ret = -1;
	}

	talloc_free(tmp_ctx);
	return ret;
}
コード例 #2
0
ファイル: dsdb_dn.c プロジェクト: endisd/samba
static char *dsdb_dn_get_with_postfix(TALLOC_CTX *mem_ctx, 
				     struct dsdb_dn *dsdb_dn,
				     const char *postfix)
{
	if (!postfix) {
		return NULL;
	}

	switch (dsdb_dn->dn_format) {
	case DSDB_NORMAL_DN:
	{
		return talloc_strdup(mem_ctx, postfix);
	}
	case DSDB_BINARY_DN:
	{
		char *hexstr = data_blob_hex_string_upper(mem_ctx, &dsdb_dn->extra_part);
	
		char *p = talloc_asprintf(mem_ctx, "B:%u:%s:%s", (unsigned)(dsdb_dn->extra_part.length*2), hexstr, 
					  postfix);
		talloc_free(hexstr);
		return p;
	}
	case DSDB_STRING_DN:
	{
		return talloc_asprintf(mem_ctx, "S:%u:%*.*s:%s", 
				    (unsigned)(dsdb_dn->extra_part.length), 
				    (int)(dsdb_dn->extra_part.length), 
				    (int)(dsdb_dn->extra_part.length), 
				    (const char *)dsdb_dn->extra_part.data, 
				    postfix);
	}
	default:
		return NULL;
	}
}
コード例 #3
0
ファイル: ndr_drsuapi.c プロジェクト: Alexander--/samba
_PUBLIC_ void ndr_print_drsuapi_DsReplicaOID(struct ndr_print *ndr, const char *name, const struct drsuapi_DsReplicaOID *r)
{
	ndr_print_struct(ndr, name, "drsuapi_DsReplicaOID");
	ndr->depth++;
	ndr_print_uint32(ndr, "length", r->length);
	ndr->print(ndr, "%-25s: length=%u", "oid", r->length);
	if (r->binary_oid) {
		char *partial_oid = NULL;
		DATA_BLOB oid_blob = data_blob_const(r->binary_oid, r->length);
		char *hex_str = data_blob_hex_string_upper(ndr, &oid_blob);
		ber_read_partial_OID_String(ndr, oid_blob, &partial_oid);
		ndr->depth++;
		ndr->print(ndr, "%-25s: 0x%s (%s)", "binary_oid", hex_str, partial_oid);
		ndr->depth--;
		talloc_free(hex_str);
		talloc_free(partial_oid);
	}
	ndr->depth--;
}
コード例 #4
0
ファイル: uuid.c プロジェクト: 0x24bin/winexe-1
_PUBLIC_ char *GUID_hexstring(TALLOC_CTX *mem_ctx, const struct GUID *guid)
{
	char *ret;
	DATA_BLOB guid_blob;
	TALLOC_CTX *tmp_mem;
	NTSTATUS status;

	tmp_mem = talloc_new(mem_ctx);
	if (!tmp_mem) {
		return NULL;
	}
	status = GUID_to_ndr_blob(guid, tmp_mem, &guid_blob);
	if (!NT_STATUS_IS_OK(status)) {
		talloc_free(tmp_mem);
		return NULL;
	}

	ret = data_blob_hex_string_upper(mem_ctx, &guid_blob);
	talloc_free(tmp_mem);
	return ret;
}
コード例 #5
0
const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor)
{
	struct ndr_syntax_id syntax;
	NTSTATUS status;

	switch(epm_floor->lhs.protocol) {
		case EPM_PROTOCOL_UUID:
			status = dcerpc_floor_get_lhs_data(epm_floor, &syntax);
			if (NT_STATUS_IS_OK(status)) {
				/* lhs is used: UUID */
				char *uuidstr;

				if (GUID_equal(&syntax.uuid, &ndr_transfer_syntax_ndr.uuid)) {
					return "NDR";
				} 

				if (GUID_equal(&syntax.uuid, &ndr_transfer_syntax_ndr64.uuid)) {
					return "NDR64";
				} 

				uuidstr = GUID_string(mem_ctx, &syntax.uuid);

				return talloc_asprintf(mem_ctx, " uuid %s/0x%02x", uuidstr, syntax.if_version);
			} else { /* IPX */
				return talloc_asprintf(mem_ctx, "IPX:%s", 
						data_blob_hex_string_upper(mem_ctx, &epm_floor->rhs.uuid.unknown));
			}

		case EPM_PROTOCOL_NCACN:
			return "RPC-C";

		case EPM_PROTOCOL_NCADG:
			return "RPC";

		case EPM_PROTOCOL_NCALRPC:
			return "NCALRPC";

		case EPM_PROTOCOL_DNET_NSP:
			return "DNET/NSP";

		case EPM_PROTOCOL_IP:
			return talloc_asprintf(mem_ctx, "IP:%s", epm_floor->rhs.ip.ipaddr);

		case EPM_PROTOCOL_NAMED_PIPE:
			return talloc_asprintf(mem_ctx, "NAMED-PIPE:%s", epm_floor->rhs.named_pipe.path);

		case EPM_PROTOCOL_SMB:
			return talloc_asprintf(mem_ctx, "SMB:%s", epm_floor->rhs.smb.unc);

		case EPM_PROTOCOL_UNIX_DS:
			return talloc_asprintf(mem_ctx, "Unix:%s", epm_floor->rhs.unix_ds.path);

		case EPM_PROTOCOL_NETBIOS:
			return talloc_asprintf(mem_ctx, "NetBIOS:%s", epm_floor->rhs.netbios.name);

		case EPM_PROTOCOL_NETBEUI:
			return "NETBeui";

		case EPM_PROTOCOL_SPX:
			return "SPX";

		case EPM_PROTOCOL_NB_IPX:
			return "NB_IPX";

		case EPM_PROTOCOL_HTTP:
			return talloc_asprintf(mem_ctx, "HTTP:%d", epm_floor->rhs.http.port);

		case EPM_PROTOCOL_TCP:
			return talloc_asprintf(mem_ctx, "TCP:%d", epm_floor->rhs.tcp.port);

		case EPM_PROTOCOL_UDP:
			return talloc_asprintf(mem_ctx, "UDP:%d", epm_floor->rhs.udp.port);

		default:
			return talloc_asprintf(mem_ctx, "UNK(%02x):", epm_floor->lhs.protocol);
	}
}