Ejemplo n.º 1
0
static bool wbinfo_get_userdomgroups(const char *user_sid_str)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	uint32_t num_sids;
	uint32_t i;
	struct wbcDomainSid user_sid, *sids = NULL;

	/* Send request */

	wbc_status = wbcStringToSid(user_sid_str, &user_sid);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	wbc_status = wbcLookupUserSids(&user_sid, true, &num_sids, &sids);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	for (i = 0; i < num_sids; i++) {
		char *str = NULL;
		wbc_status = wbcSidToString(&sids[i], &str);
		if (!WBC_ERROR_IS_OK(wbc_status)) {
			wbcFreeMemory(sids);
			return false;
		}
		d_printf("%s\n", str);
		wbcFreeMemory(str);
	}

	wbcFreeMemory(sids);

	return true;
}
Ejemplo n.º 2
0
static bool wbinfo_gid_to_sid(gid_t gid)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	struct wbcDomainSid sid;
	char *sid_str = NULL;

	/* Send request */

	wbc_status = wbcGidToSid(gid, &sid);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	wbc_status = wbcSidToString(&sid, &sid_str);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	/* Display response */

	d_printf("%s\n", sid_str);

	wbcFreeMemory(sid_str);

	return true;
}
Ejemplo n.º 3
0
static bool wbinfo_lookupsid(const char *sid_str)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	struct wbcDomainSid sid;
	char *domain;
	char *name;
	enum wbcSidType type;

	/* Send off request */

	wbc_status = wbcStringToSid(sid_str, &sid);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	wbc_status = wbcLookupSid(&sid, &domain, &name, &type);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	/* Display response */

	d_printf("%s%c%s %d\n",
		 domain, winbind_separator(), name, type);

	return true;
}
Ejemplo n.º 4
0
static bool wbinfo_lookupname(const char *full_name)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	struct wbcDomainSid sid;
	char *sid_str;
	enum wbcSidType type;
	fstring domain_name;
	fstring account_name;

	/* Send off request */

	parse_wbinfo_domain_user(full_name, domain_name,
				 account_name);

	wbc_status = wbcLookupName(domain_name, account_name,
				   &sid, &type);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	wbc_status = wbcSidToString(&sid, &sid_str);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	/* Display response */

	d_printf("%s %s (%d)\n", sid_str, sid_type_lookup(type), type);

	wbcFreeMemory(sid_str);

	return true;
}
Ejemplo n.º 5
0
static bool wbinfo_get_sidaliases(const char *domain,
				  const char *user_sid_str)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	struct wbcDomainInfo *dinfo = NULL;
	uint32_t i;
	struct wbcDomainSid user_sid;
	uint32_t *alias_rids = NULL;
	uint32_t num_alias_rids;
	char *domain_sid_str = NULL;

	/* Send request */
	if ((domain == NULL) || (strequal(domain, ".")) ||
           (domain[0] == '\0')) {
		domain = get_winbind_domain();
	}

	/* Send request */

	wbc_status = wbcDomainInfo(domain, &dinfo);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		d_printf("wbcDomainInfo(%s) failed: %s\n", domain,
			 wbcErrorString(wbc_status));
		goto done;
	}
	wbc_status = wbcStringToSid(user_sid_str, &user_sid);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		goto done;
	}

	wbc_status = wbcGetSidAliases(&dinfo->sid, &user_sid, 1,
	    &alias_rids, &num_alias_rids);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		goto done;
	}

	wbc_status = wbcSidToString(&dinfo->sid, &domain_sid_str);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		goto done;
	}

	for (i = 0; i < num_alias_rids; i++) {
		d_printf("%s-%d\n", domain_sid_str, alias_rids[i]);
	}

	wbcFreeMemory(alias_rids);

done:
	if (domain_sid_str) {
		wbcFreeMemory(domain_sid_str);
	}
	if (dinfo) {
		wbcFreeMemory(dinfo);
	}
	return (WBC_ERR_SUCCESS == wbc_status);
}
Ejemplo n.º 6
0
static bool wbinfo_ping(void)
{
	wbcErr wbc_status;

	wbc_status = wbcPing();

	/* Display response */

	d_printf("Ping to winbindd %s\n",
		 WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");

	return WBC_ERROR_IS_OK(wbc_status);
}
Ejemplo n.º 7
0
/* Convert a Unix uid to a Windows SID, allocating a SID if needed */
wbcErr wbcUidToSid(uid_t uid, struct wbcDomainSid *sid)
{
    int ret;
    char *str_sid;
    enum sss_id_type type;
    wbcErr wbc_status;

    ret = sss_nss_getsidbyid(uid, &str_sid, &type);
    if (ret != 0) {
        return WBC_ERR_UNKNOWN_FAILURE;
    }

    if (type != SSS_ID_TYPE_UID && type != SSS_ID_TYPE_BOTH) {
        free(str_sid);
        return WBC_ERR_UNKNOWN_USER;
    }

    wbc_status = wbcStringToSid(str_sid, sid);
    free(str_sid);
    if (!WBC_ERROR_IS_OK(wbc_status)) {
        return wbc_status;
    }

    return WBC_ERR_SUCCESS;
}
Ejemplo n.º 8
0
wbcErr wbcUnixIdsToSids(const struct wbcUnixId *ids, uint32_t num_ids,
                        struct wbcDomainSid *sids)
{
    size_t c;
    wbcErr wbc_status;

    for (c = 0; c < num_ids; c++) {
        switch (ids[c].type) {
        case WBC_ID_TYPE_UID:
            wbc_status = wbcUidToSid(ids[c].id.uid, &sids[c]);
            break;
        case WBC_ID_TYPE_GID:
            wbc_status = wbcGidToSid(ids[c].id.gid, &sids[c]);
            break;
        default:
            wbc_status = WBC_ERR_INVALID_PARAM;
        }

        if (!WBC_ERROR_IS_OK(wbc_status)) {
            sids[c] = (struct wbcDomainSid){ 0 };
        };
    }

    return WBC_ERR_SUCCESS;
}
Ejemplo n.º 9
0
/* Convert a SID to a domain and name */
wbcErr wbcLookupSid(const struct wbcDomainSid *sid,
		    char **pdomain,
		    char **pname,
		    enum wbcSidType *pname_type)
{
	struct winbindd_request request;
	struct winbindd_response response;
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	char *domain, *name;

	if (!sid) {
		return WBC_ERR_INVALID_PARAM;
	}

	/* Initialize request */

	ZERO_STRUCT(request);
	ZERO_STRUCT(response);

	wbcSidToStringBuf(sid, request.data.sid, sizeof(request.data.sid));

	/* Make request */

	wbc_status = wbcRequestResponse(WINBINDD_LOOKUPSID, &request,
					&response);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return wbc_status;
	}

	/* Copy out result */

	wbc_status = WBC_ERR_NO_MEMORY;
	domain = NULL;
	name = NULL;

	domain = wbcStrDup(response.data.name.dom_name);
	if (domain == NULL) {
		goto done;
	}
	name = wbcStrDup(response.data.name.name);
	if (name == NULL) {
		goto done;
	}
	if (pdomain != NULL) {
		*pdomain = domain;
		domain = NULL;
	}
	if (pname != NULL) {
		*pname = name;
		name = NULL;
	}
	if (pname_type != NULL) {
		*pname_type = (enum wbcSidType)response.data.name.type;
	}
	wbc_status = WBC_ERR_SUCCESS;
done:
	wbcFreeMemory(name);
	wbcFreeMemory(domain);
	return wbc_status;
}
Ejemplo n.º 10
0
static NTSTATUS lwi_get_id_from_sid(struct idmap_domain *dom,
				    struct id_map **ids)
{
	NTSTATUS nt_status = NT_STATUS_NONE_MAPPED;	
	int i;

	for (i = 0; ids[i]; i++) {
		struct wbcDomainSid wbc_sid;
		wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;

		/* Setup */
		memcpy(&wbc_sid, ids[i]->sid, sizeof(wbc_sid));
		ids[i]->status = ID_UNMAPPED;

		switch (ids[i]->xid.type) {
		case ID_TYPE_UID:
			wbc_status = wbcSidToUid(&wbc_sid, (uid_t*)&ids[i]->xid.id);
			break;
		case ID_TYPE_GID:
			wbc_status = wbcSidToGid(&wbc_sid, (gid_t*)&ids[i]->xid.id);
			break;
		default:
			return NT_STATUS_INVALID_PARAMETER;
		}

		if (WBC_ERROR_IS_OK(wbc_status)) {
			ids[i]->status = ID_MAPPED;
			nt_status = NT_STATUS_OK;
		}
	}
	
	return nt_status;
}
Ejemplo n.º 11
0
static NTSTATUS lwi_get_sid_from_id(struct idmap_domain *dom,
				    struct id_map **ids)
{
	int i;
	NTSTATUS nt_status = NT_STATUS_NONE_MAPPED;	

	/* loop over the array and issue requests one at a time */

	for (i = 0; ids[i]; i++) {
		struct wbcDomainSid wbc_sid;
		wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;

		ids[i]->status = ID_UNMAPPED;

		switch (ids[i]->xid.type) {
		case ID_TYPE_UID:
			wbc_status = wbcUidToSid(ids[i]->xid.id, &wbc_sid);			
			break;
		case ID_TYPE_GID:
			wbc_status = wbcGidToSid(ids[i]->xid.id, &wbc_sid);
			break;
		default:
			return NT_STATUS_INVALID_PARAMETER;
		}

		if (WBC_ERROR_IS_OK(wbc_status)) {
			memcpy(ids[i]->sid, &wbc_sid, sizeof(*ids[i]->sid));
			ids[i]->status = ID_MAPPED;
			nt_status = NT_STATUS_OK;			
		}
	}

	return nt_status;
}
Ejemplo n.º 12
0
/* show sequence numbers */
static bool wbinfo_show_onlinestatus(const char *domain)
{
	struct wbcDomainInfo *domain_list = NULL;
	size_t num_domains;
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	int i;

	wbc_status = wbcListTrusts(&domain_list, &num_domains);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	for (i=0; i<num_domains; i++) {
		bool is_offline;

		if (domain) {
			if (!strequal(domain_list[i].short_name, domain)) {
				continue;
			}
		}

		is_offline = (domain_list[i].domain_flags & WBC_DOMINFO_DOMAIN_OFFLINE);
		
		d_printf("%s : %s\n", 
			 domain_list[i].short_name,
			 is_offline ? "offline" : "online" );
	}

	return true;
}
Ejemplo n.º 13
0
static bool print_domain_groups(const char *domain)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	uint32_t i;
	uint32_t num_groups = 0;
	const char **groups = NULL;

	/* Send request to winbind daemon */

	/* '.' is the special sign for our own domain */
	if (domain && strcmp(domain, ".") == 0) {
		domain = get_winbind_domain();
	}

	wbc_status = wbcListGroups(domain, &num_groups, &groups);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	for (i=0; i < num_groups; i++) {
		d_printf("%s\n", groups[i]);
	}

	wbcFreeMemory(groups);

	return true;
}
Ejemplo n.º 14
0
wbcErr wbcSidToGid(const struct wbcDomainSid *sid, gid_t *pgid)
{
    int ret;
    char *sid_str;
    uint32_t id;
    enum sss_id_type type;
    wbcErr wbc_status;

    wbc_status = wbcSidToString(sid, &sid_str);
    if (!WBC_ERROR_IS_OK(wbc_status)) {
        return wbc_status;
    }

    ret = sss_nss_getidbysid(sid_str, &id, &type);
    wbcFreeMemory(sid_str);
    if (ret != 0) {
        return WBC_ERR_UNKNOWN_FAILURE;
    }

    if (type != SSS_ID_TYPE_GID && type != SSS_ID_TYPE_BOTH) {
        return WBC_ERR_UNKNOWN_GROUP;
    }

    *pgid = (gid_t) id;

    return WBC_ERR_SUCCESS;
}
Ejemplo n.º 15
0
static wbcErr wbc_create_domain_controller_info_ex(const struct winbindd_response *resp,
						   struct wbcDomainControllerInfoEx **_i)
{
	wbcErr wbc_status = WBC_ERR_SUCCESS;
	struct wbcDomainControllerInfoEx *i;
	struct wbcGuid guid;

	i = (struct wbcDomainControllerInfoEx *)wbcAllocateMemory(
		1, sizeof(struct wbcDomainControllerInfoEx),
		wbcDomainControllerInfoExDestructor);
	BAIL_ON_PTR_ERROR(i, wbc_status);

	i->dc_unc = strdup(resp->data.dsgetdcname.dc_unc);
	BAIL_ON_PTR_ERROR(i->dc_unc, wbc_status);

	i->dc_address = strdup(resp->data.dsgetdcname.dc_address);
	BAIL_ON_PTR_ERROR(i->dc_address, wbc_status);

	i->dc_address_type = resp->data.dsgetdcname.dc_address_type;

	wbc_status = wbcStringToGuid(resp->data.dsgetdcname.domain_guid, &guid);
	if (WBC_ERROR_IS_OK(wbc_status)) {
		i->domain_guid = (struct wbcGuid *)malloc(
			sizeof(struct wbcGuid));
		BAIL_ON_PTR_ERROR(i->domain_guid, wbc_status);

		*i->domain_guid = guid;
	}

	i->domain_name = strdup(resp->data.dsgetdcname.domain_name);
	BAIL_ON_PTR_ERROR(i->domain_name, wbc_status);

	if (resp->data.dsgetdcname.forest_name[0] != '\0') {
		i->forest_name = strdup(resp->data.dsgetdcname.forest_name);
		BAIL_ON_PTR_ERROR(i->forest_name, wbc_status);
	}

	i->dc_flags = resp->data.dsgetdcname.dc_flags;

	if (resp->data.dsgetdcname.dc_site_name[0] != '\0') {
		i->dc_site_name = strdup(resp->data.dsgetdcname.dc_site_name);
		BAIL_ON_PTR_ERROR(i->dc_site_name, wbc_status);
	}

	if (resp->data.dsgetdcname.client_site_name[0] != '\0') {
		i->client_site_name = strdup(
			resp->data.dsgetdcname.client_site_name);
		BAIL_ON_PTR_ERROR(i->client_site_name, wbc_status);
	}

	*_i = i;
	i = NULL;

done:
	if (i != NULL) {
		wbcFreeMemory(i);
	}
	return wbc_status;
}
Ejemplo n.º 16
0
/* Lookup the current status of a trusted domain */
wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
{
	struct winbindd_request request;
	struct winbindd_response response;
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	struct wbcDomainInfo *info = NULL;

	if (!domain || !dinfo) {
		wbc_status = WBC_ERR_INVALID_PARAM;
		BAIL_ON_WBC_ERROR(wbc_status);
	}

	/* Initialize request */

	ZERO_STRUCT(request);
	ZERO_STRUCT(response);

	strncpy(request.domain_name, domain,
		sizeof(request.domain_name)-1);

	wbc_status = wbcRequestResponse(WINBINDD_DOMAIN_INFO,
					&request,
					&response);
	BAIL_ON_WBC_ERROR(wbc_status);

	info = talloc(NULL, struct wbcDomainInfo);
	BAIL_ON_PTR_ERROR(info, wbc_status);

	info->short_name = talloc_strdup(info,
					 response.data.domain_info.name);
	BAIL_ON_PTR_ERROR(info->short_name, wbc_status);

	info->dns_name = talloc_strdup(info,
				       response.data.domain_info.alt_name);
	BAIL_ON_PTR_ERROR(info->dns_name, wbc_status);

	wbc_status = wbcStringToSid(response.data.domain_info.sid,
				    &info->sid);
	BAIL_ON_WBC_ERROR(wbc_status);

	if (response.data.domain_info.native_mode)
		info->domain_flags |= WBC_DOMINFO_DOMAIN_NATIVE;
	if (response.data.domain_info.active_directory)
		info->domain_flags |= WBC_DOMINFO_DOMAIN_AD;
	if (response.data.domain_info.primary)
		info->domain_flags |= WBC_DOMINFO_DOMAIN_PRIMARY;

	*dinfo = info;

	wbc_status = WBC_ERR_SUCCESS;

 done:
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		talloc_free(info);
	}

	return wbc_status;
}
Ejemplo n.º 17
0
static bool wbinfo_auth(char *username, const char *pass)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;

	wbc_status = wbcAuthenticateUser(username, pass);

	d_printf("plaintext password authentication %s\n",
		 WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");

#if 0
	if (response.data.auth.nt_status)
		d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n", 
			 response.data.auth.nt_status_string,
			 response.data.auth.nt_status,
			 response.data.auth.error_string);
#endif

	return WBC_ERROR_IS_OK(wbc_status);
}
Ejemplo n.º 18
0
static bool wbinfo_domain_info(const char *domain)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	struct wbcDomainInfo *dinfo = NULL;
	char *sid_str = NULL;

	if ((domain == NULL) || (strequal(domain, ".")) || (domain[0] == '\0')) {
		domain = get_winbind_domain();
	}

	/* Send request */

	wbc_status = wbcDomainInfo(domain, &dinfo);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	wbc_status = wbcSidToString(&dinfo->sid, &sid_str);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		wbcFreeMemory(dinfo);
		return false;
	}

	/* Display response */

	d_printf("Name              : %s\n", dinfo->short_name);
	d_printf("Alt_Name          : %s\n", dinfo->dns_name);

	d_printf("SID               : %s\n", sid_str);

	d_printf("Active Directory  : %s\n",
		 (dinfo->domain_flags & WBC_DOMINFO_DOMAIN_AD) ? "Yes" : "No");
	d_printf("Native            : %s\n",
		 (dinfo->domain_flags & WBC_DOMINFO_DOMAIN_NATIVE) ? "Yes" : "No");

	d_printf("Primary           : %s\n",
		 (dinfo->domain_flags & WBC_DOMINFO_DOMAIN_PRIMARY) ? "Yes" : "No");

	wbcFreeMemory(sid_str);
	wbcFreeMemory(dinfo);

	return true;
}
Ejemplo n.º 19
0
static bool wbinfo_change_user_password(const char *username)
{
	wbcErr wbc_status;
	char *old_password = NULL;
	char *new_password = NULL;

	old_password = wbinfo_prompt_pass("old", username);
	new_password = wbinfo_prompt_pass("new", username);

	wbc_status = wbcChangeUserPassword(username, old_password, new_password);

	/* Display response */

	d_printf("Password change for user %s %s\n", username,
		WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");

	SAFE_FREE(old_password);
	SAFE_FREE(new_password);

	return WBC_ERROR_IS_OK(wbc_status);
}
Ejemplo n.º 20
0
static bool wbinfo_check_secret(void)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	struct wbcAuthErrorInfo *error = NULL;

	wbc_status = wbcCheckTrustCredentials(NULL, &error);

	d_printf("checking the trust secret via RPC calls %s\n",
		 WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");

	if (wbc_status == WBC_ERR_AUTH_ERROR) {
		d_fprintf(stderr, "error code was %s (0x%x)\n",
			  error->nt_string, error->nt_status);
		wbcFreeMemory(error);
	}
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	return true;
}
Ejemplo n.º 21
0
static bool wbinfo_auth(char *username)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	char *s = NULL;
	char *p = NULL;
	char *password = NULL;
	char *name = NULL;

	if ((s = SMB_STRDUP(username)) == NULL) {
		return false;
	}

	if ((p = strchr(s, '%')) != NULL) {
		*p = 0;
		p++;
		password = SMB_STRDUP(p);
	} else {
		password = wbinfo_prompt_pass(NULL, username);
	}

	name = s;

	wbc_status = wbcAuthenticateUser(name, password);

	d_printf("plaintext password authentication %s\n",
		 WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");

#if 0
	if (response.data.auth.nt_status)
		d_fprintf(stderr, "error code was %s (0x%x)\nerror messsage was: %s\n",
			 response.data.auth.nt_status_string,
			 response.data.auth.nt_status,
			 response.data.auth.error_string);
#endif

	SAFE_FREE(s);
	SAFE_FREE(password);

	return WBC_ERROR_IS_OK(wbc_status);
}
Ejemplo n.º 22
0
wbcErr wb_is_trusted_domain(const char *domain)
{
	wbcErr result;
	struct wbcDomainInfo *info = NULL;

	result = wbcDomainInfo(domain, &info);

	if (WBC_ERROR_IS_OK(result)) {
		wbcFreeMemory(info);
	}

	return result;	
}
Ejemplo n.º 23
0
static bool wbinfo_set_uid_mapping(uid_t uid, const char *sid_str)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	struct wbcDomainSid sid;

	/* Send request */

	wbc_status = wbcStringToSid(sid_str, &sid);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	wbc_status = wbcSetUidMapping(uid, &sid);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	/* Display response */

	d_printf("uid %d now mapped to sid %s\n", uid, sid_str);

	return true;
}
Ejemplo n.º 24
0
static bool wbinfo_remove_gid_mapping(gid_t gid, const char *sid_str)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	struct wbcDomainSid sid;

	/* Send request */

	wbc_status = wbcStringToSid(sid_str, &sid);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	wbc_status = wbcRemoveGidMapping(gid, &sid);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	/* Display response */

	d_printf("Removed gid %d to sid %s mapping\n", gid, sid_str);

	return true;
}
Ejemplo n.º 25
0
static bool wbinfo_sid_to_gid(const char *sid_str)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	struct wbcDomainSid sid;
	gid_t gid;

	/* Send request */

	wbc_status = wbcStringToSid(sid_str, &sid);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	wbc_status = wbcSidToGid(&sid, &gid);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	/* Display response */

	d_printf("%d\n", (int)gid);

	return true;
}
Ejemplo n.º 26
0
static struct wbcInterfaceDetails *init_interface_details(void)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	static struct wbcInterfaceDetails *details;

	if (details) {
		return details;
	}

	wbc_status = wbcInterfaceDetails(&details);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		d_fprintf(stderr, "could not obtain winbind interface details!\n");
	}

	return details;
}
Ejemplo n.º 27
0
/* Enumerate the domain trusts known by Winbind */
wbcErr wbcLookupDomainController(const char *domain,
				 uint32_t flags,
				struct wbcDomainControllerInfo **dc_info)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	struct winbindd_request request;
	struct winbindd_response response;
	struct wbcDomainControllerInfo *dc = NULL;

	/* validate input params */

	if (!domain || !dc_info) {
		wbc_status = WBC_ERR_INVALID_PARAM;
		BAIL_ON_WBC_ERROR(wbc_status);
	}

	ZERO_STRUCT(request);
	ZERO_STRUCT(response);

	strncpy(request.domain_name, domain, sizeof(request.domain_name)-1);

	request.flags = flags;

	dc = talloc(NULL, struct wbcDomainControllerInfo);
	BAIL_ON_PTR_ERROR(dc, wbc_status);

	/* Send request */

	wbc_status = wbcRequestResponse(WINBINDD_DSGETDCNAME,
					&request,
					&response);
	BAIL_ON_WBC_ERROR(wbc_status);

	dc->dc_name = talloc_strdup(dc, response.data.dc_name);
	BAIL_ON_PTR_ERROR(dc->dc_name, wbc_status);

	*dc_info = dc;

done:
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		talloc_free(dc);
	}

	return wbc_status;
}
Ejemplo n.º 28
0
static bool wbinfo_allocate_gid(void)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	gid_t gid;

	/* Send request */

	wbc_status = wbcAllocateGid(&gid);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	/* Display response */

	d_printf("New gid: %d\n", gid);

	return true;
}
Ejemplo n.º 29
0
static bool wbinfo_wins_byip(const char *ip)
{
	wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
	char *name = NULL;

	wbc_status = wbcResolveWinsByIP(ip, &name);
	if (!WBC_ERROR_IS_OK(wbc_status)) {
		return false;
	}

	/* Display response */

	d_printf("%s\n", name);

	wbcFreeMemory(name);

	return true;
}
Ejemplo n.º 30
0
wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid,
			 char **pdomain,
			 char **pfullname,
			 enum wbcSidType *pname_type)
{
	wbcErr wbc_status;
	char *domain = NULL;
	char *name = NULL;
	enum wbcSidType name_type;

	wbc_status = wbcLookupSid(sid, &domain, &name, &name_type);
	BAIL_ON_WBC_ERROR(wbc_status);

	if (name_type == WBC_SID_NAME_USER) {
		uid_t uid;
		struct passwd *pwd;

		wbc_status = wbcSidToUid(sid, &uid);
		BAIL_ON_WBC_ERROR(wbc_status);

		wbc_status = wbcGetpwuid(uid, &pwd);
		BAIL_ON_WBC_ERROR(wbc_status);

		wbcFreeMemory(name);

		name = wbcStrDup(pwd->pw_gecos);
		wbcFreeMemory(pwd);
		BAIL_ON_PTR_ERROR(name, wbc_status);
	}

	wbc_status = WBC_ERR_SUCCESS;

 done:
	if (WBC_ERROR_IS_OK(wbc_status)) {
		*pdomain = domain;
		*pfullname = name;
		*pname_type = name_type;
	} else {
		wbcFreeMemory(domain);
		wbcFreeMemory(name);
	}

	return wbc_status;
}