885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose/*
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose Unix SMB/CIFS implementation.
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose Winbind client API - SSSD version
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose Copyright (C) Sumit Bose <sbose@redhat.com> 2014
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose This library is free software; you can redistribute it and/or
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose modify it under the terms of the GNU Lesser General Public
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose License as published by the Free Software Foundation; either
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose version 3 of the License, or (at your option) any later version.
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose This library is distributed in the hope that it will be useful,
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose but WITHOUT ANY WARRANTY; without even the implied warranty of
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose Library General Public License for more details.
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose You should have received a copy of the GNU Lesser General Public License
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose along with this program. If not, see <http://www.gnu.org/licenses/>.
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose*/
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose/* Required Headers */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose#include "libwbclient.h"
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose#include "wbc_sssd_internal.h"
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose#define WINBIND_INTERFACE_VERSION 27
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose/** @brief Ping winbindd to see if the daemon is running
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose *
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose * @return #wbcErr
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose **/
885386b7e3f1c3e74b354576b98a092b0835d64eSumit BosewbcErr wbcPing(void)
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose{
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose /* TODO: add real check */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose return WBC_ERR_SUCCESS;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose}
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bosestatic void wbcInterfaceDetailsDestructor(void *ptr)
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose{
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose struct wbcInterfaceDetails *i = (struct wbcInterfaceDetails *)ptr;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose free(i->winbind_version);
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose free(i->netbios_name);
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose free(i->netbios_domain);
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose free(i->dns_domain);
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose}
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose/**
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose * @brief Query useful information about the winbind service
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose *
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose * @param *_details pointer to hold the struct wbcInterfaceDetails
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose *
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose * @return #wbcErr
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit BosewbcErr wbcInterfaceDetails(struct wbcInterfaceDetails **_details)
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose{
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose struct wbcInterfaceDetails *info;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose info = (struct wbcInterfaceDetails *)wbcAllocateMemory(
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose 1, sizeof(struct wbcInterfaceDetails),
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose wbcInterfaceDetailsDestructor);
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose if (info == NULL) {
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose return WBC_ERR_NO_MEMORY;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose }
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose /* TODO: currently this call just returns a suitable winbind_separator
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose * for wbinfo. */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose info->interface_version = WINBIND_INTERFACE_VERSION;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose info->winbind_version = strdup("libwbclient for SSSD");
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose if (info->winbind_version == NULL) {
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose wbc_status = WBC_ERR_NO_MEMORY;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose goto done;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose }
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose info->winbind_separator = '\\';
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose info->netbios_name = strdup("-not available-");
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose if (info->netbios_name == NULL) {
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose wbc_status = WBC_ERR_NO_MEMORY;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose goto done;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose }
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose info->netbios_domain = strdup("-not available-");
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose if (info->netbios_domain == NULL) {
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose wbc_status = WBC_ERR_NO_MEMORY;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose goto done;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose }
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose info->dns_domain = strdup("-not available-");
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose if (info->dns_domain == NULL) {
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose wbc_status = WBC_ERR_NO_MEMORY;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose goto done;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose }
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose *_details = info;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose info = NULL;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose wbc_status = WBC_ERR_SUCCESS;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bosedone:
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose wbcFreeMemory(info);
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose return wbc_status;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose}
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose/** @brief Lookup the current status of a trusted domain, sync wrapper
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose *
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose * @param domain Domain to query
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose * @param *dinfo Pointer to returned struct wbcDomainInfo
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose *
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose * @return #wbcErr
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit BosewbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose{
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose WBC_SSSD_NOT_IMPLEMENTED;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose}
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose/* Get the list of current DCs */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit BosewbcErr wbcDcInfo(const char *domain, size_t *num_dcs,
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose const char ***dc_names, const char ***dc_ips)
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose{
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose WBC_SSSD_NOT_IMPLEMENTED;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose}
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose/* Resolve a NetbiosName via WINS */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit BosewbcErr wbcResolveWinsByName(const char *name, char **ip)
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose{
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose /* SSSD does not support WINS */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose WBC_SSSD_NOT_IMPLEMENTED;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose}
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose/* Resolve an IP address via WINS into a NetbiosName */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit BosewbcErr wbcResolveWinsByIP(const char *ip, char **name)
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose{
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose /* SSSD does not support WINS */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose WBC_SSSD_NOT_IMPLEMENTED;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose}
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose/* Enumerate the domain trusts known by Winbind */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit BosewbcErr wbcListTrusts(struct wbcDomainInfo **domains, size_t *num_domains)
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose{
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose WBC_SSSD_NOT_IMPLEMENTED;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose}
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose/* Enumerate the domain trusts known by Winbind */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit BosewbcErr wbcLookupDomainController(const char *domain,
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose uint32_t flags,
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose struct wbcDomainControllerInfo **dc_info)
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose{
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose WBC_SSSD_NOT_IMPLEMENTED;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose}
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose/* Get extended domain controller information */
885386b7e3f1c3e74b354576b98a092b0835d64eSumit BosewbcErr wbcLookupDomainControllerEx(const char *domain,
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose struct wbcGuid *guid,
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose const char *site,
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose uint32_t flags,
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose struct wbcDomainControllerInfoEx **dc_info)
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose{
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose WBC_SSSD_NOT_IMPLEMENTED;
885386b7e3f1c3e74b354576b98a092b0835d64eSumit Bose}