From da02f57f298b20e9d6c6b94aa1b292e88a3eef28 Mon Sep 17 00:00:00 2001 From: Pavel Březina Date: Wed, 14 May 2014 10:03:57 +0200 Subject: SSSD CIM provider --- CMakeLists.txt | 1 + README | 8 +- doc/admin/CMakeLists.txt | 6 + doc/admin/sssd/index.rst | 22 ++ mof/60_LMI_SSSD.mof | 237 +++++++++++++++++ mof/CMakeLists.txt | 3 + openlmi-providers.spec | 64 +++++ src/CMakeLists.txt | 4 + src/sssd/90_LMI_SSSD_Profile.mof.skel | 22 ++ src/sssd/CMakeLists.txt | 43 +++ src/sssd/LMI_HostedSSSDServiceProvider.c | 237 +++++++++++++++++ src/sssd/LMI_SSSDAvailableComponentProvider.c | 303 +++++++++++++++++++++ src/sssd/LMI_SSSDAvailableDomainProvider.c | 273 +++++++++++++++++++ src/sssd/LMI_SSSDBackendDomainProvider.c | 281 ++++++++++++++++++++ src/sssd/LMI_SSSDBackendProvider.c | 264 +++++++++++++++++++ src/sssd/LMI_SSSDBackendProviderProvider.c | 310 ++++++++++++++++++++++ src/sssd/LMI_SSSDComponentProvider.c | 201 ++++++++++++++ src/sssd/LMI_SSSDDomainProvider.c | 216 +++++++++++++++ src/sssd/LMI_SSSDDomainSubdomainProvider.c | 365 ++++++++++++++++++++++++++ src/sssd/LMI_SSSDMonitorProvider.c | 227 ++++++++++++++++ src/sssd/LMI_SSSDProviderProvider.c | 170 ++++++++++++ src/sssd/LMI_SSSDResponderProvider.c | 264 +++++++++++++++++++ src/sssd/LMI_SSSDServiceProvider.c | 227 ++++++++++++++++ src/sssd/cmpiLMI_SSSD-cimprovagt | 21 ++ src/sssd/sssd_components.c | 360 +++++++++++++++++++++++++ src/sssd/sssd_components.h | 78 ++++++ src/sssd/sssd_domains.c | 196 ++++++++++++++ src/sssd/sssd_domains.h | 36 +++ src/sssd/utils.c | 45 ++++ src/sssd/utils.h | 67 +++++ 30 files changed, 4550 insertions(+), 1 deletion(-) create mode 100644 doc/admin/sssd/index.rst create mode 100644 mof/60_LMI_SSSD.mof create mode 100644 src/sssd/90_LMI_SSSD_Profile.mof.skel create mode 100644 src/sssd/CMakeLists.txt create mode 100644 src/sssd/LMI_HostedSSSDServiceProvider.c create mode 100644 src/sssd/LMI_SSSDAvailableComponentProvider.c create mode 100644 src/sssd/LMI_SSSDAvailableDomainProvider.c create mode 100644 src/sssd/LMI_SSSDBackendDomainProvider.c create mode 100644 src/sssd/LMI_SSSDBackendProvider.c create mode 100644 src/sssd/LMI_SSSDBackendProviderProvider.c create mode 100644 src/sssd/LMI_SSSDComponentProvider.c create mode 100644 src/sssd/LMI_SSSDDomainProvider.c create mode 100644 src/sssd/LMI_SSSDDomainSubdomainProvider.c create mode 100644 src/sssd/LMI_SSSDMonitorProvider.c create mode 100644 src/sssd/LMI_SSSDProviderProvider.c create mode 100644 src/sssd/LMI_SSSDResponderProvider.c create mode 100644 src/sssd/LMI_SSSDServiceProvider.c create mode 100755 src/sssd/cmpiLMI_SSSD-cimprovagt create mode 100644 src/sssd/sssd_components.c create mode 100644 src/sssd/sssd_components.h create mode 100644 src/sssd/sssd_domains.c create mode 100644 src/sssd/sssd_domains.h create mode 100644 src/sssd/utils.c create mode 100644 src/sssd/utils.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 1931e17..3ff7a6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ option(WITH-SOFTWARE "Build software provider" ON) option(WITH-SOFTWARE-DBUS ${OPTDESC-SOFTWARE-DBUS} OFF) option(WITH-JOURNALD "Build journald provider" ON) option(WITH-LOCALE "Build locale provider" ON) +option(WITH-SSSD "Build SSSD provider" ON) option(WITH-DEVASSISTANT "Install Developer Assistant templates" OFF) diff --git a/README b/README index 084c86c..688660d 100644 --- a/README +++ b/README @@ -82,11 +82,14 @@ Following providers are part of this sub-project: * PCP This is a CIM interface for the PCP (Performance Co-Pilot) daemon. Allows reading of PCP metrics on the local host. - + * Locale Locale provider is a CIM interface for systemd-localed. Allows to control system locale variables (LANG, LC_PAPER, ...) and keyboard mapping for virtual console and X11. + +* SSSD + This is a CIM interface for the SSSD daemon. ******************************************************************************* * Build Dependencies * @@ -133,6 +136,9 @@ Provider specific dependencies: * Locale - glib2-devel 2.26+ - systemd 30+ (systemd-localed) +* SSSD + - dbus-devel + - libsss_simpleifp-devel ******************************************************************************* * Compilation and installation * diff --git a/doc/admin/CMakeLists.txt b/doc/admin/CMakeLists.txt index d33427f..ef9743d 100644 --- a/doc/admin/CMakeLists.txt +++ b/doc/admin/CMakeLists.txt @@ -68,6 +68,12 @@ if (WITH-LOCALE) set(PROVIDER_MOFS ${PROVIDER_MOFS} "60_LMI_Locale.mof") endif (WITH-LOCALE) +if (WITH-SSSD) + set(PROVIDERS ${PROVIDERS} "sssd") + set(PROVIDER_CAPTIONS ${PROVIDER_CAPTIONS} "SSSD") + set(PROVIDER_MOFS ${PROVIDER_MOFS} "60_LMI_SSSD.mof") +endif (WITH-SSSD) + list(LENGTH PROVIDERS LEN) math(EXPR LEN '${LEN}-1') diff --git a/doc/admin/sssd/index.rst b/doc/admin/sssd/index.rst new file mode 100644 index 0000000..89193dd --- /dev/null +++ b/doc/admin/sssd/index.rst @@ -0,0 +1,22 @@ +OpenLMI SSSD Provider documentation +=========================================== +OpenLMI SSSD is a CIM provider for managing the System Security Services +Daemon. + +It provides only the basic functionality: managing SSSD components and +providing information about active domains. + +Contents: + +.. toctree:: + :maxdepth: 2 + +.. ifconfig:: includeClasses + + OpenLMI SSSD CIM Classes: + + .. toctree:: + :maxdepth: 1 + + mof/tree + mof/index diff --git a/mof/60_LMI_SSSD.mof b/mof/60_LMI_SSSD.mof new file mode 100644 index 0000000..bb6dda7 --- /dev/null +++ b/mof/60_LMI_SSSD.mof @@ -0,0 +1,237 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +[Version("0.1.0"), Provider("cmpi:cmpiLMI_SSSD"), + Description("System Security Services Daemon")] +class LMI_SSSDService : CIM_Service +{ + +}; + +[Version("0.1.0"), Provider("cmpi:cmpiLMI_SSSD"), + Abstract, Description("Base class for SSSD's components.")] +class LMI_SSSDComponent : CIM_ManagedElement +{ + [Key, Description("Name of the SSSD component.")] + string Name; + + [Description("Type of the SSSD component."), + ValueMap { "0", "1", "2" }, + Values { "Monitor", "Responder", "Backend" }] + uint16 Type; + + [BitValues{"Reserved", + "Reserved", + "Reserved", + "Reserved", + "Fatal failures", + "Critical failures", + "Operation failures", + "Minor failures", + "Configuration settings", + "Function data", + "Trace function", + "Reserved", + "Trace libraries", + "Trace internal", + "Trace all", + "Reserved"}, + Description("Debug level used within this component.")] + uint16 DebugLevel; + + [Description("True if this process is enabled at SSSD startup and false " + "otherwise.")] + boolean IsEnabled; + + [Description("Permanently change debug level of this component."), + ValueMap { "0", "1", "2", "3" }, + Values { "Success", "Failed", "Operation not supported", "I/O error" }] + uint32 SetDebugLevelPermanently([In] uint16 debug_level); + + [Description("Change debug level of this component but switch it back " + "to the original value when SSSD is restarted."), + ValueMap { "0", "1", "2", "3" }, + Values { "Success", "Failed", "Operation not supported", "I/O error" }] + uint32 SetDebugLevelTemporarily([In] uint16 debug_level); + + [Description("Enable this component. SSSD has to be restarted in order " + "this change to take any effect."), + ValueMap { "0", "1", "2", "3" }, + Values { "Success", "Failed", "Operation not supported", "I/O error" }] + uint32 Enable(); + + [Description("Disable this component. SSSD has to be restarted in order " + "this change to take any effect."), + ValueMap { "0", "1", "2", "3" }, + Values { "Success", "Failed", "Operation not supported", "I/O error" }] + uint32 Disable(); +}; + +[Version("0.1.0"), Provider("cmpi:cmpiLMI_SSSD"), + Description("SSSD monitor. An SSSD component that executes the other " + "components and makes sure they stay running. This component " + "can not be disabled.")] +class LMI_SSSDMonitor : LMI_SSSDComponent +{ + +}; + +[Version("0.1.0"), Provider("cmpi:cmpiLMI_SSSD"), + Description("SSSD responder. An SSSD component that implements one of the " + "supported services and provides data to clients.")] +class LMI_SSSDResponder : LMI_SSSDComponent +{ + +}; + +[Version("0.1.0"), Provider("cmpi:cmpiLMI_SSSD"), + Description("SSSD backend. An SSSD component that manages data from one " + "domain and its subdomains.")] +class LMI_SSSDBackend : LMI_SSSDComponent +{ + +}; + +[Version("0.1.0"), Provider("cmpi:cmpiLMI_SSSD"), + Description("Data provider module information.")] +class LMI_SSSDProvider : CIM_ManagedElement +{ + [Key, Description("Name of data class handled by the provider.")] + string Type; + + [Key, Description("Name of the module that provides the desired data.")] + string Module; +}; + +[Version("0.1.0"), Provider("cmpi:cmpiLMI_SSSD"), + Description("SSSD domain.")] +class LMI_SSSDDomain : CIM_ManagedElement +{ + [Key, Description("Name of the domain.")] + string Name; + + [Description("List of primary servers for this domain.")] + string PrimaryServers[]; + + [Description("List of backup servers for this domain.")] + string BackupServers[]; + + [Description("Main provider for this domain.")] + string Provider; + + [Description("The Kerberos realm this domain is configured with.")] + string Realm; + + [Description("The domain forest this domain belongs to.")] + string Forest; + + [Description("Name of the parent domain. It is not set if this " + "domain is on top of the domain hierarchy.")] + string ParentDomain; + + [Description("True if this is an autodiscovered subdomain.")] + boolean IsSubdomain; + + [Description("Minimum UID and GID value for this domain.")] + uint32 MinId; + + [Description("Maximum UID and GID value for this domain.")] + uint32 MaxId; + + [Description("True if this domain supports enumeration.")] + boolean Enumerate; + + [Description("True if objects from this domain can be accessed only via " + "fully qualified name.")] + boolean UseFullyQualifiedNames; + + [Description("The login format this domain expects.")] + string LoginFormat; + + [Description("Format of fully qualified name this domain uses.")] + string FullyQualifiedNameFormat; +}; + +[Version("0.1.0"), Provider("cmpi:cmpiLMI_SSSD"), Association, + Description("All available SSSD components.")] +class LMI_SSSDAvailableComponent +{ + [Key, Min(1), Max(1)] + LMI_SSSDService REF SSSD; + + [Key] + LMI_SSSDComponent REF Component; +}; + +[Version("0.1.0"), Provider("cmpi:cmpiLMI_SSSD"), Association, + Description("Data provider modules configured for given backend.")] +class LMI_SSSDBackendProvider +{ + [Key, Max(1)] + LMI_SSSDBackend REF Backend; + + [Key] + LMI_SSSDProvider REF Provider; +}; + +[Version("0.1.0"), Provider("cmpi:cmpiLMI_SSSD"), Association, + Description("All domains managed by SSSD.")] +class LMI_SSSDAvailableDomain +{ + [Key, Min(1), Max(1)] + LMI_SSSDService REF SSSD; + + [Key] + LMI_SSSDDomain REF Domain; +}; + +[Version("0.1.0"), Provider("cmpi:cmpiLMI_SSSD"), Association, + Description("All top level domains associated with given backend.")] +class LMI_SSSDBackendDomain +{ + [Key, Max(1)] + LMI_SSSDBackend REF Backend; + + [Key, Max(1)] + LMI_SSSDDomain REF Domain; +}; + +[Version("0.1.0"), Provider("cmpi:cmpiLMI_SSSD"), Association, + Description("All subdomains associated with given parent domain.")] +class LMI_SSSDDomainSubdomain +{ + [Key, Max(1)] + LMI_SSSDDomain REF ParentDomain; + + [Key] + LMI_SSSDDomain REF Subdomain; +}; + +[Version("0.1.0"), Provider("cmpi:cmpiLMI_SSSD"), Association] +class LMI_HostedSSSDService: CIM_HostedService +{ + [Override("Antecedent"), + Description("The hosting System.") ] + CIM_ComputerSystem REF Antecedent; + + [Override("Dependent"), + Description("Instance of SSSD service.")] + LMI_SSSDService REF Dependent; +}; diff --git a/mof/CMakeLists.txt b/mof/CMakeLists.txt index d9a2985..6a1ae15 100644 --- a/mof/CMakeLists.txt +++ b/mof/CMakeLists.txt @@ -55,3 +55,6 @@ if (WITH-LOCALE) install(FILES 60_LMI_Locale.mof DESTINATION share/openlmi-providers/) endif (WITH-LOCALE) +if (WITH-SSSD) + install(FILES 60_LMI_SSSD.mof DESTINATION share/openlmi-providers/) +endif (WITH-SSSD) diff --git a/openlmi-providers.spec b/openlmi-providers.spec index fd1b833..813bdd5 100644 --- a/openlmi-providers.spec +++ b/openlmi-providers.spec @@ -22,6 +22,7 @@ %global with_locale 1 %global with_indsender 1 %global with_jobmanager 1 +%global with_sssd 1 %if 0%{?rhel} == 6 %global with_journald 0 @@ -33,6 +34,7 @@ %global with_locale 0 %global with_indsender 0 %global with_jobmanager 0 +%global with_sssd 0 %global interop root/PG_InterOp %endif @@ -74,6 +76,7 @@ Obsoletes: cura-providers < 0.0.10-1 %global pcp_version %{providers_version_release} %global journald_version %{providers_version_release} %global realmd_version %{providers_version_release} +%global sssd_version %{providers_version_release} # Storage and networking providers are built out of tree # We will require a minimum and maximum version of them @@ -143,6 +146,9 @@ BuildRequires: dbus-1-devel %else BuildRequires: dbus-devel %endif +%if 0%{?with_sssd} +BuildRequires: libsss_simpleifp-devel +%endif # sblim-sfcb or tog-pegasus # (required to be present during install/uninstall for registration) Requires: cim-server @@ -541,6 +547,23 @@ BuildArch: noarch This package contains the documents for OpenLMI Journald provider. %endif +%if 0%{?with_sssd} +%package -n openlmi-sssd +Summary: CIM provider for SSSD +Requires: %{name}%{?_isa} = %{providers_version_release} + +%description -n openlmi-sssd +The openlmi-sssd package contains CMPI providers for SSSD service. + +%package -n openlmi-sssd-doc +Summary: CIM SSSD provider documentation +Group: Documentation +BuildArch: noarch + +%description -n openlmi-sssd-doc +This package contains the documents for OpenLMI SSSD provider. +%endif + %if 0%{?with_devassistant} %package -n openlmi-devassistant Summary: OpenLMI provider templates for Developer Assistant @@ -620,6 +643,9 @@ pushd %{_target_platform} %endif %if ! 0%{with_jobmanager} -DWITH-JOBMANAGER=OFF \ +%endif +%if ! 0%{with_sssd} + -DWITH-SSSD=OFF \ %endif %{source_dir} @@ -713,6 +739,9 @@ for provider in \ %endif %if 0%{?with_locale} locale \ +%endif +%if 0%{?with_sssd} + sssd \ %endif software; do @@ -960,6 +989,19 @@ cp -pr tools/openlmitheme/* $RPM_BUILD_ROOT/%{python_sitelib}/sphinx/themes/open %{_docdir}/%{name}/journald/ %endif +%if 0%{with_sssd} +%files -n openlmi-sssd +%doc README COPYING +%{_libdir}/cmpi/libcmpiLMI_SSSD.so +%{_datadir}/%{name}/60_LMI_SSSD.mof +%{_datadir}/%{name}/60_LMI_SSSD.reg +%{_datadir}/%{name}/90_LMI_SSSD_Profile.mof +%attr(755, root, root) %{_libexecdir}/pegasus/cmpiLMI_SSSD-cimprovagt + +%files -n openlmi-sssd-doc +%{_docdir}/%{name}/sssd/ +%endif + %if 0%{with_devassistant} %files -n openlmi-devassistant %dir %{_datadir}/devassistant/files/crt/python/openlmi/ @@ -1262,6 +1304,17 @@ if [ "$1" -ge 1 ]; then fi >> %logfile 2>&1 %endif +%if 0%{with_sssd} +%post -n openlmi-sssd +if [ "$1" -ge 1 ]; then + %{_bindir}/openlmi-mof-register -v %{providers_version} register \ + %{_datadir}/%{name}/60_LMI_SSSD.mof \ + %{_datadir}/%{name}/60_LMI_SSSD.reg || :; + %{_bindir}/openlmi-mof-register --just-mofs -n root/interop -c tog-pegasus register \ + %{_datadir}/%{name}/90_LMI_SSSD_Profile.mof || :; +fi >> %logfile 2>&1 +%endif + %if 0%{with_fan} %preun -n openlmi-fan # Deregister only if not upgrading @@ -1389,6 +1442,17 @@ if [ "$1" -eq 0 ]; then fi >> %logfile 2>&1 %endif +%if 0%{with_sssd} +%preun -n openlmi-sssd +if [ "$1" -eq 0 ]; then + %{_bindir}/openlmi-mof-register -v %{providers_version} unregister \ + %{_datadir}/%{name}/60_LMI_SSSD.mof \ + %{_datadir}/%{name}/60_LMI_SSSD.reg || :; + %{_bindir}/openlmi-mof-register --just-mofs -n root/interop -c tog-pegasus unregister \ + %{_datadir}/%{name}/90_LMI_SSSD_Profile.mof || :; +fi >> %logfile 2>&1 +%endif + %changelog * Thu Jun 26 2014 Radek Novacek 0.4.2-16 - Add BR: json-glib-devel for jobmanager diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0b8a8ff..58d72f5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -74,6 +74,10 @@ if (WITH-LOCALE) add_subdirectory(locale) endif (WITH-LOCALE) +if (WITH-SSSD) + add_subdirectory(sssd) +endif (WITH-SSSD) + file(GLOB INIT_SKELS "*/lmi/*/__init__.skel") foreach(SKEL ${INIT_SKELS}) #TODO: find a way how to do it in cmake diff --git a/src/sssd/90_LMI_SSSD_Profile.mof.skel b/src/sssd/90_LMI_SSSD_Profile.mof.skel new file mode 100644 index 0000000..7edcf44 --- /dev/null +++ b/src/sssd/90_LMI_SSSD_Profile.mof.skel @@ -0,0 +1,22 @@ +instance of PG_ProviderProfileCapabilities +{ + CapabilityID = "@CLASS@"; + + ProviderModuleName = "cmpiLMI_SSSD"; + + ProviderName = "@CLASS@"; + + RegisteredProfile = 0; + + OtherRegisteredProfile = "OpenLMI-SSSD"; + OtherProfileOrganization = "OpenLMI"; + + ProfileVersion = "@VERSION@"; + + RegisteredSubProfiles = {}; + + ConformingElements = { + "@CLASS@" + }; +}; + diff --git a/src/sssd/CMakeLists.txt b/src/sssd/CMakeLists.txt new file mode 100644 index 0000000..7a2efd0 --- /dev/null +++ b/src/sssd/CMakeLists.txt @@ -0,0 +1,43 @@ +pkg_check_modules(DBUS1 dbus-1 REQUIRED) +pkg_check_modules(SSS_SIMPLEIFP sss_simpleifp REQUIRED) + +set(PROVIDER_NAME SSSD) +set(LIBRARY_NAME cmpiLMI_${PROVIDER_NAME}) +set(MOF 60_LMI_${PROVIDER_NAME}.mof) +set(CIMPROVAGT_SCRIPT cmpiLMI_${PROVIDER_NAME}-cimprovagt) + +# Source files +set(provider_SRCS + utils.c + sssd_components.c + sssd_domains.c) + +konkretcmpi_generate(${MOF} CIM_PROVIDERS CIM_HEADERS CIM_CLASSES) + +include_directories(${CMAKE_CURRENT_BINARY_DIR} + ${CMPI_INCLUDE_DIR} + ${GLIB_INCLUDE_DIRS} + ${DBUS1_INCLUDE_DIRS} + ${SSS_SIMPLEIFP_INCLUDE_DIR}) + +add_library(${LIBRARY_NAME} SHARED + ${provider_SRCS} + ${CIM_PROVIDERS} + ${CIM_HEADERS}) + +target_link_libraries(${LIBRARY_NAME} + openlmicommon + ${KONKRETCMPI_LIBRARIES} + ${GLIB_LIBRARIES} + ${DBUS1_LIBRARIES} + ${SSS_SIMPLEIFP_LIBRARIES}) + +# Create registration file +cim_registration(${PROVIDER_NAME} ${LIBRARY_NAME} ${MOF} share/openlmi-providers) + +set(TARGET_MOF "${CMAKE_BINARY_DIR}/mof/90_LMI_SSSD_Profile.mof") +profile_mof_generate("90_LMI_SSSD_Profile.mof.skel" "${TARGET_MOF}" "LMI_SSSD") + +install(PROGRAMS ${CIMPROVAGT_SCRIPT} DESTINATION libexec/pegasus) +install(TARGETS ${LIBRARY_NAME} DESTINATION lib${LIB_SUFFIX}/cmpi) +install(FILES ${TARGET_MOF} DESTINATION share/openlmi-providers/) diff --git a/src/sssd/LMI_HostedSSSDServiceProvider.c b/src/sssd/LMI_HostedSSSDServiceProvider.c new file mode 100644 index 0000000..ed61454 --- /dev/null +++ b/src/sssd/LMI_HostedSSSDServiceProvider.c @@ -0,0 +1,237 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include "LMI_HostedSSSDService.h" +#include "utils.h" + +static const CMPIBroker* _cb; + +static void LMI_HostedSSSDServiceInitialize(const CMPIContext *ctx) +{ + lmi_init(PROVIDER_NAME, _cb, ctx, NULL); +} + +static CMPIStatus LMI_HostedSSSDServiceCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_HostedSSSDServiceEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_HostedSSSDServiceEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_SSSDServiceRef ref; + LMI_HostedSSSDService association; + const char *namespace = KNameSpace(cop); + + LMI_SSSDService_Get_Ref(cc, _cb, namespace, &ref); + + LMI_HostedSSSDService_Init(&association, _cb, namespace); + LMI_HostedSSSDService_Set_Dependent(&association, &ref); + LMI_HostedSSSDService_SetObjectPath_Antecedent(&association, + lmi_get_computer_system_safe(cc)); + + KReturnInstance(cr, association); + + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_HostedSSSDServiceGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + return KDefaultGetInstance( + _cb, mi, cc, cr, cop, properties); +} + +static CMPIStatus LMI_HostedSSSDServiceCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_HostedSSSDServiceModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char**properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_HostedSSSDServiceDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_HostedSSSDServiceExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_HostedSSSDServiceAssociationCleanup( + CMPIAssociationMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_HostedSSSDServiceAssociators( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole, + const char** properties) +{ + return KDefaultAssociators( + _cb, + mi, + cc, + cr, + cop, + LMI_HostedSSSDService_ClassName, + assocClass, + resultClass, + role, + resultRole, + properties); +} + +static CMPIStatus LMI_HostedSSSDServiceAssociatorNames( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole) +{ + return KDefaultAssociatorNames( + _cb, + mi, + cc, + cr, + cop, + LMI_HostedSSSDService_ClassName, + assocClass, + resultClass, + role, + resultRole); +} + +static CMPIStatus LMI_HostedSSSDServiceReferences( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* role, + const char** properties) +{ + return KDefaultReferences( + _cb, + mi, + cc, + cr, + cop, + LMI_HostedSSSDService_ClassName, + assocClass, + role, + properties); +} + +static CMPIStatus LMI_HostedSSSDServiceReferenceNames( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* role) +{ + return KDefaultReferenceNames( + _cb, + mi, + cc, + cr, + cop, + LMI_HostedSSSDService_ClassName, + assocClass, + role); +} + +CMInstanceMIStub( + LMI_HostedSSSDService, + LMI_HostedSSSDService, + _cb, + LMI_HostedSSSDServiceInitialize(ctx)) + +CMAssociationMIStub( + LMI_HostedSSSDService, + LMI_HostedSSSDService, + _cb, + LMI_HostedSSSDServiceInitialize(ctx)) + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_HostedSSSDService", + "LMI_HostedSSSDService", + "instance association") diff --git a/src/sssd/LMI_SSSDAvailableComponentProvider.c b/src/sssd/LMI_SSSDAvailableComponentProvider.c new file mode 100644 index 0000000..366bd43 --- /dev/null +++ b/src/sssd/LMI_SSSDAvailableComponentProvider.c @@ -0,0 +1,303 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include +#include +#include "LMI_SSSDAvailableComponent.h" +#include "LMI_SSSDMonitor.h" +#include "LMI_SSSDResponder.h" +#include "LMI_SSSDBackend.h" +#include "utils.h" + +static const CMPIBroker* _cb; + +static void LMI_SSSDAvailableComponentInitialize(const CMPIContext *ctx) +{ + lmi_init(PROVIDER_NAME, _cb, ctx, NULL); +} + +static CMPIStatus LMI_SSSDAvailableComponentCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDAvailableComponentEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_SSSDAvailableComponentEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + const char *namespace = KNameSpace(cop); + LMI_SSSDAvailableComponent association; + LMI_SSSDServiceRef ref_sssd; + LMI_SSSDMonitorRef ref_monitor; + LMI_SSSDResponderRef ref_responder; + LMI_SSSDBackendRef ref_backend; + CMPIObjectPath *op; + sss_sifp_ctx *sifp_ctx = NULL; + sss_sifp_attr **attrs = NULL; + sss_sifp_error error; + char **paths = NULL; + const char *name = NULL; + const char *type = NULL; + CMPIStatus cmpi_ret; + CMPIrc ret; + int i; + + LMI_SSSDService_Get_Ref(cc, _cb, namespace, &ref_sssd); + + error = sss_sifp_init(&sifp_ctx); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_invoke_list(sifp_ctx, SSSD_DBUS_LIST_COMPONENTS, &paths, + DBUS_TYPE_INVALID); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + for (i = 0; paths[i] != NULL; i++) { + error = sss_sifp_fetch_all_attrs(sifp_ctx, paths[i], + SSS_SIFP_IFACE_COMPONENTS, &attrs); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_find_attr_as_string(attrs, "name", &name); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_find_attr_as_string(attrs, "type", &type); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + if (strcmp(type, "monitor") == 0) { + LMI_SSSDMonitorRef_Init(&ref_monitor, _cb, namespace); + LMI_SSSDMonitorRef_Set_Name(&ref_monitor, name); + op = LMI_SSSDMonitorRef_ToObjectPath(&ref_monitor, &cmpi_ret); + } else if (strcmp(type, "responder") == 0) { + LMI_SSSDResponderRef_Init(&ref_responder, _cb, namespace); + LMI_SSSDResponderRef_Set_Name(&ref_responder, name); + op = LMI_SSSDResponderRef_ToObjectPath(&ref_responder, &cmpi_ret); + } else if (strcmp(type, "backend") == 0) { + LMI_SSSDBackendRef_Init(&ref_backend, _cb, namespace); + LMI_SSSDBackendRef_Set_Name(&ref_backend, name); + op = LMI_SSSDBackendRef_ToObjectPath(&ref_backend, &cmpi_ret); + } else { + /* unknown type */ + continue; + } + + if (!KOkay(cmpi_ret)) { + ret = CMPI_RC_ERR_FAILED; + goto done; + } + + LMI_SSSDAvailableComponent_Init(&association, _cb, namespace); + LMI_SSSDAvailableComponent_Set_SSSD(&association, &ref_sssd); + LMI_SSSDAvailableComponent_SetObjectPath_Component(&association, op); + + KReturnInstance(cr, association); + + sss_sifp_free_attrs(sifp_ctx, &attrs); + } + + ret = CMPI_RC_OK; + +done: + sss_sifp_free_string_array(sifp_ctx, &paths); + sss_sifp_free_attrs(sifp_ctx, &attrs); + sss_sifp_free(&sifp_ctx); + CMReturn(ret); +} + +static CMPIStatus LMI_SSSDAvailableComponentGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + return KDefaultGetInstance( + _cb, mi, cc, cr, cop, properties); +} + +static CMPIStatus LMI_SSSDAvailableComponentCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDAvailableComponentModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char**properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDAvailableComponentDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDAvailableComponentExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDAvailableComponentAssociationCleanup( + CMPIAssociationMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDAvailableComponentAssociators( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole, + const char** properties) +{ + return KDefaultAssociators( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDAvailableComponent_ClassName, + assocClass, + resultClass, + role, + resultRole, + properties); +} + +static CMPIStatus LMI_SSSDAvailableComponentAssociatorNames( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole) +{ + return KDefaultAssociatorNames( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDAvailableComponent_ClassName, + assocClass, + resultClass, + role, + resultRole); +} + +static CMPIStatus LMI_SSSDAvailableComponentReferences( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* role, + const char** properties) +{ + return KDefaultReferences( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDAvailableComponent_ClassName, + assocClass, + role, + properties); +} + +static CMPIStatus LMI_SSSDAvailableComponentReferenceNames( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* role) +{ + return KDefaultReferenceNames( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDAvailableComponent_ClassName, + assocClass, + role); +} + +CMInstanceMIStub( + LMI_SSSDAvailableComponent, + LMI_SSSDAvailableComponent, + _cb, + LMI_SSSDAvailableComponentInitialize(ctx)) + +CMAssociationMIStub( + LMI_SSSDAvailableComponent, + LMI_SSSDAvailableComponent, + _cb, + LMI_SSSDAvailableComponentInitialize(ctx)) + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_SSSDAvailableComponent", + "LMI_SSSDAvailableComponent", + "instance association") diff --git a/src/sssd/LMI_SSSDAvailableDomainProvider.c b/src/sssd/LMI_SSSDAvailableDomainProvider.c new file mode 100644 index 0000000..ad36147 --- /dev/null +++ b/src/sssd/LMI_SSSDAvailableDomainProvider.c @@ -0,0 +1,273 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include +#include +#include "LMI_SSSDAvailableDomain.h" +#include "utils.h" + +static const CMPIBroker* _cb; + +static void LMI_SSSDAvailableDomainInitialize(const CMPIContext *ctx) +{ + lmi_init(PROVIDER_NAME, _cb, ctx, NULL); +} + +static CMPIStatus LMI_SSSDAvailableDomainCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDAvailableDomainEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_SSSDAvailableDomainEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + const char *namespace = KNameSpace(cop); + LMI_SSSDAvailableDomain association; + LMI_SSSDServiceRef ref_sssd; + LMI_SSSDDomainRef ref_domain; + sss_sifp_ctx *sifp_ctx = NULL; + sss_sifp_attr **attrs = NULL; + sss_sifp_error error; + char **paths = NULL; + const char *name = NULL; + CMPIrc ret; + int i; + + LMI_SSSDService_Get_Ref(cc, _cb, namespace, &ref_sssd); + + error = sss_sifp_init(&sifp_ctx); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_invoke_list(sifp_ctx, SSSD_DBUS_LIST_DOMAINS, &paths, + DBUS_TYPE_INVALID); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + for (i = 0; paths[i] != NULL; i++) { + error = sss_sifp_fetch_attr(sifp_ctx, paths[i], SSS_SIFP_IFACE_DOMAINS, + "name", &attrs); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_find_attr_as_string(attrs, "name", &name); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + LMI_SSSDDomainRef_Init(&ref_domain, _cb, namespace); + LMI_SSSDDomainRef_Set_Name(&ref_domain, name); + + LMI_SSSDAvailableDomain_Init(&association, _cb, namespace); + LMI_SSSDAvailableDomain_Set_SSSD(&association, &ref_sssd); + LMI_SSSDAvailableDomain_Set_Domain(&association, &ref_domain); + + KReturnInstance(cr, association); + + sss_sifp_free_attrs(sifp_ctx, &attrs); + } + + ret = CMPI_RC_OK; + +done: + sss_sifp_free_string_array(sifp_ctx, &paths); + sss_sifp_free_attrs(sifp_ctx, &attrs); + sss_sifp_free(&sifp_ctx); + CMReturn(ret); +} + +static CMPIStatus LMI_SSSDAvailableDomainGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + return KDefaultGetInstance( + _cb, mi, cc, cr, cop, properties); +} + +static CMPIStatus LMI_SSSDAvailableDomainCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDAvailableDomainModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char**properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDAvailableDomainDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDAvailableDomainExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDAvailableDomainAssociationCleanup( + CMPIAssociationMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDAvailableDomainAssociators( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole, + const char** properties) +{ + return KDefaultAssociators( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDAvailableDomain_ClassName, + assocClass, + resultClass, + role, + resultRole, + properties); +} + +static CMPIStatus LMI_SSSDAvailableDomainAssociatorNames( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole) +{ + return KDefaultAssociatorNames( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDAvailableDomain_ClassName, + assocClass, + resultClass, + role, + resultRole); +} + +static CMPIStatus LMI_SSSDAvailableDomainReferences( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* role, + const char** properties) +{ + return KDefaultReferences( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDAvailableDomain_ClassName, + assocClass, + role, + properties); +} + +static CMPIStatus LMI_SSSDAvailableDomainReferenceNames( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* role) +{ + return KDefaultReferenceNames( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDAvailableDomain_ClassName, + assocClass, + role); +} + +CMInstanceMIStub( + LMI_SSSDAvailableDomain, + LMI_SSSDAvailableDomain, + _cb, + LMI_SSSDAvailableDomainInitialize(ctx)) + +CMAssociationMIStub( + LMI_SSSDAvailableDomain, + LMI_SSSDAvailableDomain, + _cb, + LMI_SSSDAvailableDomainInitialize(ctx)) + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_SSSDAvailableDomain", + "LMI_SSSDAvailableDomain", + "instance association") diff --git a/src/sssd/LMI_SSSDBackendDomainProvider.c b/src/sssd/LMI_SSSDBackendDomainProvider.c new file mode 100644 index 0000000..05d7482 --- /dev/null +++ b/src/sssd/LMI_SSSDBackendDomainProvider.c @@ -0,0 +1,281 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include +#include +#include "LMI_SSSDBackendDomain.h" +#include "utils.h" + +static const CMPIBroker* _cb; + +static void LMI_SSSDBackendDomainInitialize(const CMPIContext *ctx) +{ + lmi_init(PROVIDER_NAME, _cb, ctx, NULL); +} + +static CMPIStatus LMI_SSSDBackendDomainCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDBackendDomainEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_SSSDBackendDomainEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + const char *namespace = KNameSpace(cop); + LMI_SSSDBackendDomain association; + LMI_SSSDBackendRef ref_backend; + LMI_SSSDDomainRef ref_domain; + sss_sifp_ctx *sifp_ctx = NULL; + sss_sifp_attr **attrs = NULL; + sss_sifp_error error; + char **paths = NULL; + const char *name = NULL; + bool is_subdomain; + CMPIrc ret; + int i; + + error = sss_sifp_init(&sifp_ctx); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_invoke_list(sifp_ctx, SSSD_DBUS_LIST_DOMAINS, &paths, + DBUS_TYPE_INVALID); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + for (i = 0; paths[i] != NULL; i++) { + error = sss_sifp_fetch_all_attrs(sifp_ctx, paths[i], + SSS_SIFP_IFACE_DOMAINS, &attrs); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_find_attr_as_string(attrs, "name", &name); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_find_attr_as_bool(attrs, "subdomain", &is_subdomain); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + if (!is_subdomain) { + LMI_SSSDBackendRef_Init(&ref_backend, _cb, namespace); + LMI_SSSDBackendRef_Set_Name(&ref_backend, name); + + LMI_SSSDDomainRef_Init(&ref_domain, _cb, namespace); + LMI_SSSDDomainRef_Set_Name(&ref_domain, name); + + LMI_SSSDBackendDomain_Init(&association, _cb, namespace); + LMI_SSSDBackendDomain_Set_Backend(&association, &ref_backend); + LMI_SSSDBackendDomain_Set_Domain(&association, &ref_domain); + + + KReturnInstance(cr, association); + } + + sss_sifp_free_attrs(sifp_ctx, &attrs); + } + + ret = CMPI_RC_OK; + +done: + sss_sifp_free_string_array(sifp_ctx, &paths); + sss_sifp_free_attrs(sifp_ctx, &attrs); + sss_sifp_free(&sifp_ctx); + CMReturn(ret); +} + +static CMPIStatus LMI_SSSDBackendDomainGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + return KDefaultGetInstance( + _cb, mi, cc, cr, cop, properties); +} + +static CMPIStatus LMI_SSSDBackendDomainCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDBackendDomainModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char**properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDBackendDomainDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDBackendDomainExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDBackendDomainAssociationCleanup( + CMPIAssociationMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDBackendDomainAssociators( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole, + const char** properties) +{ + return KDefaultAssociators( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDBackendDomain_ClassName, + assocClass, + resultClass, + role, + resultRole, + properties); +} + +static CMPIStatus LMI_SSSDBackendDomainAssociatorNames( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole) +{ + return KDefaultAssociatorNames( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDBackendDomain_ClassName, + assocClass, + resultClass, + role, + resultRole); +} + +static CMPIStatus LMI_SSSDBackendDomainReferences( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* role, + const char** properties) +{ + return KDefaultReferences( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDBackendDomain_ClassName, + assocClass, + role, + properties); +} + +static CMPIStatus LMI_SSSDBackendDomainReferenceNames( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* role) +{ + return KDefaultReferenceNames( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDBackendDomain_ClassName, + assocClass, + role); +} + +CMInstanceMIStub( + LMI_SSSDBackendDomain, + LMI_SSSDBackendDomain, + _cb, + LMI_SSSDBackendDomainInitialize(ctx)) + +CMAssociationMIStub( + LMI_SSSDBackendDomain, + LMI_SSSDBackendDomain, + _cb, + LMI_SSSDBackendDomainInitialize(ctx)) + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_SSSDBackendDomain", + "LMI_SSSDBackendDomain", + "instance association") diff --git a/src/sssd/LMI_SSSDBackendProvider.c b/src/sssd/LMI_SSSDBackendProvider.c new file mode 100644 index 0000000..a572094 --- /dev/null +++ b/src/sssd/LMI_SSSDBackendProvider.c @@ -0,0 +1,264 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include +#include "LMI_SSSDBackend.h" +#include "utils.h" +#include "sssd_components.h" + +static const CMPIBroker* _cb = NULL; + +static void LMI_SSSDBackendInitialize(const CMPIContext *ctx) +{ + lmi_init(PROVIDER_NAME, _cb, ctx, NULL); +} + +static CMPIStatus LMI_SSSDBackendCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDBackendEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_SSSDBackendEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_SSSDBackend instance; + const char *namespace = KNameSpace(cop); + sss_sifp_ctx *sifp_ctx = NULL; + sss_sifp_error error; + char **paths = NULL; + sssd_method_error mret; + CMPIrc ret; + int i; + + error = sss_sifp_init(&sifp_ctx); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_invoke_list(sifp_ctx, SSSD_DBUS_LIST_BACKENDS, &paths, + DBUS_TYPE_INVALID); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + for (i = 0; paths[i] != NULL; i++) { + mret = sssd_backend_set_instance(sifp_ctx, paths[i], _cb, namespace, + &instance); + if (mret != SSSD_METHOD_ERROR_OK) { + ret = CMPI_RC_ERR_FAILED; + goto done; + } + + KReturnInstance(cr, instance); + } + + ret = CMPI_RC_OK; + +done: + sss_sifp_free_string_array(sifp_ctx, &paths); + sss_sifp_free(&sifp_ctx); + CMReturn(ret); +} + +static CMPIStatus LMI_SSSDBackendGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_SSSDBackend instance; + LMI_SSSDBackendRef ref; + const char *namespace = KNameSpace(cop); + sss_sifp_ctx *sifp_ctx = NULL; + sss_sifp_error error; + const char *name = NULL; + char *path = NULL; + sssd_method_error mret; + CMPIrc ret; + + LMI_SSSDBackendRef_InitFromObjectPath(&ref, _cb, cop); + name = ref.Name.chars; + + error = sss_sifp_init(&sifp_ctx); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_invoke_find(sifp_ctx, SSSD_DBUS_FIND_BACKEND, &path, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_NOT_FOUND, done); + + mret = sssd_backend_set_instance(sifp_ctx, path, _cb, namespace, + &instance); + if (mret != SSSD_METHOD_ERROR_OK) { + ret = CMPI_RC_ERR_FAILED; + goto done; + } + + KReturnInstance(cr, instance); + ret = CMPI_RC_OK; + +done: + sss_sifp_free_string(sifp_ctx, &path); + sss_sifp_free(&sifp_ctx); + CMReturn(ret); +} + +static CMPIStatus LMI_SSSDBackendCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDBackendModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char** properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDBackendDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDBackendExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +CMInstanceMIStub( + LMI_SSSDBackend, + LMI_SSSDBackend, + _cb, + LMI_SSSDBackendInitialize(ctx)) + +static CMPIStatus LMI_SSSDBackendMethodCleanup( + CMPIMethodMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDBackendInvokeMethod( + CMPIMethodMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* meth, + const CMPIArgs* in, + CMPIArgs* out) +{ + return LMI_SSSDBackend_DispatchMethod( + _cb, mi, cc, cr, cop, meth, in, out); +} + +CMMethodMIStub( + LMI_SSSDBackend, + LMI_SSSDBackend, + _cb, + LMI_SSSDBackendInitialize(ctx)) + +KUint32 LMI_SSSDBackend_SetDebugLevelPermanently( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDBackendRef* self, + const KUint16* debug_level, + CMPIStatus* status) +{ + return sssd_component_set_debug_permanently(self->Name.chars, + SSSD_COMPONENT_BACKEND, + debug_level, status); +} + +KUint32 LMI_SSSDBackend_SetDebugLevelTemporarily( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDBackendRef* self, + const KUint16* debug_level, + CMPIStatus* status) +{ + return sssd_component_set_debug_temporarily(self->Name.chars, + SSSD_COMPONENT_BACKEND, + debug_level, status); +} + +KUint32 LMI_SSSDBackend_Enable( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDBackendRef* self, + CMPIStatus* status) +{ + return sssd_component_enable(self->Name.chars, SSSD_COMPONENT_BACKEND, + status); +} + +KUint32 LMI_SSSDBackend_Disable( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDBackendRef* self, + CMPIStatus* status) +{ + return sssd_component_disable(self->Name.chars, SSSD_COMPONENT_BACKEND, + status); +} + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_SSSDBackend", + "LMI_SSSDBackend", + "instance method") diff --git a/src/sssd/LMI_SSSDBackendProviderProvider.c b/src/sssd/LMI_SSSDBackendProviderProvider.c new file mode 100644 index 0000000..ca9d400 --- /dev/null +++ b/src/sssd/LMI_SSSDBackendProviderProvider.c @@ -0,0 +1,310 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include +#include +#include +#include "LMI_SSSDBackendProvider.h" +#include "utils.h" + +static const CMPIBroker* _cb; + +static void LMI_SSSDBackendProviderInitialize(const CMPIContext *ctx) +{ + lmi_init(PROVIDER_NAME, _cb, ctx, NULL); +} + +static CMPIStatus LMI_SSSDBackendProviderCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDBackendProviderEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_SSSDBackendProviderEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_SSSDBackendProvider association; + LMI_SSSDBackendRef ref_backend; + LMI_SSSDProviderRef ref_provider; + const char *namespace = KNameSpace(cop); + sss_sifp_ctx *sifp_ctx = NULL; + sss_sifp_attr **attrs = NULL; + sss_sifp_error error; + char **paths = NULL; + const char *backend_name = NULL; + const char * const *providers = NULL; + char *provider_type = NULL; + char *provider_module = NULL; + unsigned int num_providers; + CMPIrc ret; + unsigned int j; + int i; + + error = sss_sifp_init(&sifp_ctx); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_invoke_list(sifp_ctx, SSSD_DBUS_LIST_BACKENDS, &paths, + DBUS_TYPE_INVALID); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + for (i = 0; paths[i] != NULL; i++) { + error = sss_sifp_fetch_all_attrs(sifp_ctx, paths[i], + SSS_SIFP_IFACE_COMPONENTS, &attrs); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_find_attr_as_string(attrs, "name", &backend_name); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_find_attr_as_string_array(attrs, "providers", + &num_providers, &providers); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + if (num_providers == 0) { + sss_sifp_free_attrs(sifp_ctx, &attrs); + continue; + } + + LMI_SSSDBackendRef_Init(&ref_backend, _cb, namespace); + LMI_SSSDBackendRef_Set_Name(&ref_backend, backend_name); + + for (j = 0; j < num_providers; j++) { + /* provider is a key=value pair */ + provider_type = strdup(providers[j]); + if (provider_type == NULL) { + goto done; + } + + provider_module = strchr(provider_type, '='); + if (provider_module == NULL) { + provider_module = ""; + } else { + *provider_module = '\0'; + provider_module++; + } + + LMI_SSSDProviderRef_Init(&ref_provider, _cb, namespace); + LMI_SSSDProviderRef_Set_Type(&ref_provider, provider_type); + LMI_SSSDProviderRef_Set_Module(&ref_provider, provider_module); + free(provider_type); + + LMI_SSSDBackendProvider_Init(&association, _cb, namespace); + LMI_SSSDBackendProvider_Set_Backend(&association, &ref_backend); + LMI_SSSDBackendProvider_Set_Provider(&association, &ref_provider); + + KReturnInstance(cr, association); + } + + sss_sifp_free_attrs(sifp_ctx, &attrs); + } + + ret = CMPI_RC_OK; + +done: + if (attrs != NULL) { + sss_sifp_free_attrs(sifp_ctx, &attrs); + } + + sss_sifp_free_string_array(sifp_ctx, &paths); + sss_sifp_free(&sifp_ctx); + CMReturn(ret); +} + +static CMPIStatus LMI_SSSDBackendProviderGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + return KDefaultGetInstance( + _cb, mi, cc, cr, cop, properties); +} + +static CMPIStatus LMI_SSSDBackendProviderCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDBackendProviderModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char**properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDBackendProviderDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDBackendProviderExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDBackendProviderAssociationCleanup( + CMPIAssociationMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDBackendProviderAssociators( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole, + const char** properties) +{ + return KDefaultAssociators( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDBackendProvider_ClassName, + assocClass, + resultClass, + role, + resultRole, + properties); +} + +static CMPIStatus LMI_SSSDBackendProviderAssociatorNames( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole) +{ + return KDefaultAssociatorNames( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDBackendProvider_ClassName, + assocClass, + resultClass, + role, + resultRole); +} + +static CMPIStatus LMI_SSSDBackendProviderReferences( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* role, + const char** properties) +{ + return KDefaultReferences( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDBackendProvider_ClassName, + assocClass, + role, + properties); +} + +static CMPIStatus LMI_SSSDBackendProviderReferenceNames( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* role) +{ + return KDefaultReferenceNames( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDBackendProvider_ClassName, + assocClass, + role); +} + +CMInstanceMIStub( + LMI_SSSDBackendProvider, + LMI_SSSDBackendProvider, + _cb, + LMI_SSSDBackendProviderInitialize(ctx)) + +CMAssociationMIStub( + LMI_SSSDBackendProvider, + LMI_SSSDBackendProvider, + _cb, + LMI_SSSDBackendProviderInitialize(ctx)) + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_SSSDBackendProvider", + "LMI_SSSDBackendProvider", + "instance association") diff --git a/src/sssd/LMI_SSSDComponentProvider.c b/src/sssd/LMI_SSSDComponentProvider.c new file mode 100644 index 0000000..efc1147 --- /dev/null +++ b/src/sssd/LMI_SSSDComponentProvider.c @@ -0,0 +1,201 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include "LMI_SSSDComponent.h" + +static const CMPIBroker* _cb = NULL; + +static void LMI_SSSDComponentInitialize() +{ +} + +static CMPIStatus LMI_SSSDComponentCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDComponentEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_SSSDComponentEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDComponentGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + return KDefaultGetInstance( + _cb, mi, cc, cr, cop, properties); +} + +static CMPIStatus LMI_SSSDComponentCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDComponentModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char** properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDComponentDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDComponentExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +CMInstanceMIStub( + LMI_SSSDComponent, + LMI_SSSDComponent, + _cb, + LMI_SSSDComponentInitialize()) + +static CMPIStatus LMI_SSSDComponentMethodCleanup( + CMPIMethodMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDComponentInvokeMethod( + CMPIMethodMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* meth, + const CMPIArgs* in, + CMPIArgs* out) +{ + return LMI_SSSDComponent_DispatchMethod( + _cb, mi, cc, cr, cop, meth, in, out); +} + +CMMethodMIStub( + LMI_SSSDComponent, + LMI_SSSDComponent, + _cb, + LMI_SSSDComponentInitialize()) + +KUint32 LMI_SSSDComponent_SetDebugLevelPermanently( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDComponentRef* self, + const KUint16* debug_level, + CMPIStatus* status) +{ + KUint32 result = KUINT32_INIT; + + KSetStatus(status, ERR_NOT_SUPPORTED); + return result; +} + +KUint32 LMI_SSSDComponent_SetDebugLevelTemporarily( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDComponentRef* self, + const KUint16* debug_level, + CMPIStatus* status) +{ + KUint32 result = KUINT32_INIT; + + KSetStatus(status, ERR_NOT_SUPPORTED); + return result; +} + +KUint32 LMI_SSSDComponent_Enable( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDComponentRef* self, + CMPIStatus* status) +{ + KUint32 result = KUINT32_INIT; + + KSetStatus(status, ERR_NOT_SUPPORTED); + return result; +} + +KUint32 LMI_SSSDComponent_Disable( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDComponentRef* self, + CMPIStatus* status) +{ + KUint32 result = KUINT32_INIT; + + KSetStatus(status, ERR_NOT_SUPPORTED); + return result; +} + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_SSSDComponent", + "LMI_SSSDComponent", + "instance method") diff --git a/src/sssd/LMI_SSSDDomainProvider.c b/src/sssd/LMI_SSSDDomainProvider.c new file mode 100644 index 0000000..4b80134 --- /dev/null +++ b/src/sssd/LMI_SSSDDomainProvider.c @@ -0,0 +1,216 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include +#include "LMI_SSSDDomain.h" +#include "utils.h" +#include "sssd_domains.h" + +static const CMPIBroker* _cb = NULL; + +static void LMI_SSSDDomainInitialize(const CMPIContext *ctx) +{ + lmi_init(PROVIDER_NAME, _cb, ctx, NULL); +} + +static CMPIStatus LMI_SSSDDomainCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDDomainEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_SSSDDomainEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_SSSDDomain instance; + const char *namespace = KNameSpace(cop); + sss_sifp_ctx *sifp_ctx = NULL; + sss_sifp_error error; + char **paths = NULL; + sssd_method_error mret; + CMPIrc ret; + int i; + + error = sss_sifp_init(&sifp_ctx); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_invoke_list(sifp_ctx, SSSD_DBUS_LIST_DOMAINS, &paths, + DBUS_TYPE_INVALID); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + for (i = 0; paths[i] != NULL; i++) { + mret = sssd_domain_set_instance(sifp_ctx, paths[i], _cb, namespace, + &instance); + if (mret != SSSD_METHOD_ERROR_OK) { + ret = CMPI_RC_ERR_FAILED; + goto done; + } + + KReturnInstance(cr, instance); + } + + ret = CMPI_RC_OK; + +done: + sss_sifp_free_string_array(sifp_ctx, &paths); + sss_sifp_free(&sifp_ctx); + CMReturn(ret); +} + +static CMPIStatus LMI_SSSDDomainGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_SSSDDomain instance; + LMI_SSSDDomainRef ref; + const char *namespace = KNameSpace(cop); + sss_sifp_ctx *sifp_ctx = NULL; + sss_sifp_error error; + const char *name = NULL; + char *path = NULL; + sssd_method_error mret; + CMPIrc ret; + + LMI_SSSDDomainRef_InitFromObjectPath(&ref, _cb, cop); + name = ref.Name.chars; + + error = sss_sifp_init(&sifp_ctx); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_invoke_find(sifp_ctx, SSSD_DBUS_FIND_DOMAIN, &path, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_NOT_FOUND, done); + + mret = sssd_domain_set_instance(sifp_ctx, path, _cb, namespace, + &instance); + if (mret != SSSD_METHOD_ERROR_OK) { + ret = CMPI_RC_ERR_FAILED; + goto done; + } + + KReturnInstance(cr, instance); + ret = CMPI_RC_OK; + +done: + sss_sifp_free_string(sifp_ctx, &path); + sss_sifp_free(&sifp_ctx); + CMReturn(ret); +} + +static CMPIStatus LMI_SSSDDomainCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDDomainModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char** properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDDomainDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDDomainExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +CMInstanceMIStub( + LMI_SSSDDomain, + LMI_SSSDDomain, + _cb, + LMI_SSSDDomainInitialize(ctx)) + +static CMPIStatus LMI_SSSDDomainMethodCleanup( + CMPIMethodMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDDomainInvokeMethod( + CMPIMethodMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* meth, + const CMPIArgs* in, + CMPIArgs* out) +{ + return LMI_SSSDDomain_DispatchMethod( + _cb, mi, cc, cr, cop, meth, in, out); +} + +CMMethodMIStub( + LMI_SSSDDomain, + LMI_SSSDDomain, + _cb, + LMI_SSSDDomainInitialize(ctx)) + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_SSSDDomain", + "LMI_SSSDDomain", + "instance method") diff --git a/src/sssd/LMI_SSSDDomainSubdomainProvider.c b/src/sssd/LMI_SSSDDomainSubdomainProvider.c new file mode 100644 index 0000000..de7a287 --- /dev/null +++ b/src/sssd/LMI_SSSDDomainSubdomainProvider.c @@ -0,0 +1,365 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include +#include +#include +#include "LMI_SSSDDomainSubdomain.h" +#include "utils.h" + +static const CMPIBroker* _cb; + +static void LMI_SSSDDomainSubdomainInitialize(const CMPIContext *ctx) +{ + lmi_init(PROVIDER_NAME, _cb, ctx, NULL); +} + +static CMPIStatus LMI_SSSDDomainSubdomainCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDDomainSubdomainEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_SSSDDomainSubdomainEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + const char *namespace = KNameSpace(cop); + LMI_SSSDDomainSubdomain association; + LMI_SSSDDomainRef ref_parent; + LMI_SSSDDomainRef ref_sub; + sss_sifp_ctx *sifp_ctx = NULL; + sss_sifp_attr **subdomain = NULL; + sss_sifp_attr **parent = NULL; + sss_sifp_error error; + char **paths = NULL; + const char *parent_path = NULL; + const char *parent_name = NULL; + const char *sub_name = NULL; + bool is_subdomain; + GHashTable *table = NULL; + char *key = NULL; + char *value = NULL; + CMPIrc ret; + int i; + + error = sss_sifp_init(&sifp_ctx); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_invoke_list(sifp_ctx, SSSD_DBUS_LIST_DOMAINS, &paths, + DBUS_TYPE_INVALID); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + table = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); + if (table == NULL) { + ret = CMPI_RC_ERR_FAILED; + goto done; + } + + for (i = 0; paths[i] != NULL; i++) { + /* fetch information about potential subdomain */ + error = sss_sifp_fetch_all_attrs(sifp_ctx, paths[i], + SSS_SIFP_IFACE_DOMAINS, &subdomain); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_find_attr_as_bool(subdomain, "subdomain", + &is_subdomain); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + /* if it is not subdomain just continue with the next one */ + if (!is_subdomain) { + sss_sifp_free_attrs(sifp_ctx, &subdomain); + continue; + } + + /* get subdomain name and parent */ + error = sss_sifp_find_attr_as_string(subdomain, "name", + &sub_name); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_find_attr_as_string(subdomain, "parent_domain", + &parent_path); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + /* first try to lookup the parent in the hash table */ + key = strdup(parent_path); + if (key == NULL) { + ret = CMPI_RC_ERR_FAILED; + goto done; + } + + value = (char*)g_hash_table_lookup(table, key); + if (value != NULL) { + parent_name = (const char*)value; + free(key); + + /* forget the pointers */ + key = NULL; + value = NULL; + } else { + /* fetch the parent and store it in the hash table */ + error = sss_sifp_fetch_attr(sifp_ctx, parent_path, + SSS_SIFP_IFACE_DOMAINS, "name", + &parent); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_find_attr_as_string(parent, "name", + &parent_name); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + value = strdup(parent_name); + if (value == NULL) { + ret = CMPI_RC_ERR_FAILED; + goto done; + } + + g_hash_table_insert(table, key, value); + + /* the entry is now owned by the hash table */ + key = NULL; + value= NULL; + } + + /* create association */ + LMI_SSSDDomainRef_Init(&ref_parent, _cb, namespace); + LMI_SSSDDomainRef_Set_Name(&ref_parent, parent_name); + + LMI_SSSDDomainRef_Init(&ref_sub, _cb, namespace); + LMI_SSSDDomainRef_Set_Name(&ref_sub, sub_name); + + LMI_SSSDDomainSubdomain_Init(&association, _cb, namespace); + LMI_SSSDDomainSubdomain_Set_ParentDomain(&association, &ref_parent); + LMI_SSSDDomainSubdomain_Set_Subdomain(&association, &ref_sub); + + KReturnInstance(cr, association); + + sss_sifp_free_attrs(sifp_ctx, &subdomain); + sss_sifp_free_attrs(sifp_ctx, &parent); + } + + ret = CMPI_RC_OK; + +done: + if (key != NULL) { + free(key); + } + + if (value != NULL) { + free(value); + } + + if (table != NULL) { + g_hash_table_destroy(table); + } + + if (subdomain != NULL) { + sss_sifp_free_attrs(sifp_ctx, &subdomain); + } + + if (parent != NULL) { + sss_sifp_free_attrs(sifp_ctx, &parent); + } + + sss_sifp_free_string_array(sifp_ctx, &paths); + sss_sifp_free(&sifp_ctx); + CMReturn(ret); +} + +static CMPIStatus LMI_SSSDDomainSubdomainGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + return KDefaultGetInstance( + _cb, mi, cc, cr, cop, properties); +} + +static CMPIStatus LMI_SSSDDomainSubdomainCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDDomainSubdomainModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char**properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDDomainSubdomainDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDDomainSubdomainExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDDomainSubdomainAssociationCleanup( + CMPIAssociationMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDDomainSubdomainAssociators( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole, + const char** properties) +{ + return KDefaultAssociators( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDDomainSubdomain_ClassName, + assocClass, + resultClass, + role, + resultRole, + properties); +} + +static CMPIStatus LMI_SSSDDomainSubdomainAssociatorNames( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* resultClass, + const char* role, + const char* resultRole) +{ + return KDefaultAssociatorNames( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDDomainSubdomain_ClassName, + assocClass, + resultClass, + role, + resultRole); +} + +static CMPIStatus LMI_SSSDDomainSubdomainReferences( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* role, + const char** properties) +{ + return KDefaultReferences( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDDomainSubdomain_ClassName, + assocClass, + role, + properties); +} + +static CMPIStatus LMI_SSSDDomainSubdomainReferenceNames( + CMPIAssociationMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* assocClass, + const char* role) +{ + return KDefaultReferenceNames( + _cb, + mi, + cc, + cr, + cop, + LMI_SSSDDomainSubdomain_ClassName, + assocClass, + role); +} + +CMInstanceMIStub( + LMI_SSSDDomainSubdomain, + LMI_SSSDDomainSubdomain, + _cb, + LMI_SSSDDomainSubdomainInitialize(ctx)) + +CMAssociationMIStub( + LMI_SSSDDomainSubdomain, + LMI_SSSDDomainSubdomain, + _cb, + LMI_SSSDDomainSubdomainInitialize(ctx)) + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_SSSDDomainSubdomain", + "LMI_SSSDDomainSubdomain", + "instance association") diff --git a/src/sssd/LMI_SSSDMonitorProvider.c b/src/sssd/LMI_SSSDMonitorProvider.c new file mode 100644 index 0000000..06b32c4 --- /dev/null +++ b/src/sssd/LMI_SSSDMonitorProvider.c @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include +#include +#include "LMI_SSSDMonitor.h" +#include "utils.h" +#include "sssd_components.h" + +static const CMPIBroker* _cb = NULL; + +static void LMI_SSSDMonitorInitialize(const CMPIContext *ctx) +{ + lmi_init(PROVIDER_NAME, _cb, ctx, NULL); +} + +static CMPIStatus LMI_SSSDMonitorCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDMonitorEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_SSSDMonitorEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_SSSDMonitor instance; + const char *namespace = KNameSpace(cop); + sss_sifp_ctx *sifp_ctx = NULL; + sss_sifp_error error; + char *path = NULL; + sssd_method_error mret; + CMPIrc ret; + + error = sss_sifp_init(&sifp_ctx); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_invoke_find(sifp_ctx, "Monitor", &path, DBUS_TYPE_INVALID); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_NOT_FOUND, done); + + mret = sssd_monitor_set_instance(sifp_ctx, path, _cb, namespace, + &instance); + if (mret != SSSD_METHOD_ERROR_OK) { + ret = CMPI_RC_ERR_FAILED; + goto done; + } + + KReturnInstance(cr, instance); + ret = CMPI_RC_OK; + +done: + sss_sifp_free_string(sifp_ctx, &path); + sss_sifp_free(&sifp_ctx); + CMReturn(ret); +} + +static CMPIStatus LMI_SSSDMonitorGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + return KDefaultGetInstance( + _cb, mi, cc, cr, cop, properties); +} + +static CMPIStatus LMI_SSSDMonitorCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDMonitorModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char** properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDMonitorDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDMonitorExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +CMInstanceMIStub( + LMI_SSSDMonitor, + LMI_SSSDMonitor, + _cb, + LMI_SSSDMonitorInitialize(ctx)) + +static CMPIStatus LMI_SSSDMonitorMethodCleanup( + CMPIMethodMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDMonitorInvokeMethod( + CMPIMethodMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* meth, + const CMPIArgs* in, + CMPIArgs* out) +{ + return LMI_SSSDMonitor_DispatchMethod( + _cb, mi, cc, cr, cop, meth, in, out); +} + +CMMethodMIStub( + LMI_SSSDMonitor, + LMI_SSSDMonitor, + _cb, + LMI_SSSDMonitorInitialize(ctx)) + +KUint32 LMI_SSSDMonitor_SetDebugLevelPermanently( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDMonitorRef* self, + const KUint16* debug_level, + CMPIStatus* status) +{ + return sssd_component_set_debug_permanently(self->Name.chars, + SSSD_COMPONENT_MONITOR, + debug_level, status); +} + +KUint32 LMI_SSSDMonitor_SetDebugLevelTemporarily( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDMonitorRef* self, + const KUint16* debug_level, + CMPIStatus* status) +{ + return sssd_component_set_debug_temporarily(self->Name.chars, + SSSD_COMPONENT_MONITOR, + debug_level, status); +} + +KUint32 LMI_SSSDMonitor_Enable( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDMonitorRef* self, + CMPIStatus* status) +{ + return sssd_component_enable(self->Name.chars, SSSD_COMPONENT_MONITOR, + status); +} + +KUint32 LMI_SSSDMonitor_Disable( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDMonitorRef* self, + CMPIStatus* status) +{ + return sssd_component_disable(self->Name.chars, SSSD_COMPONENT_MONITOR, + status); +} + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_SSSDMonitor", + "LMI_SSSDMonitor", + "instance method") diff --git a/src/sssd/LMI_SSSDProviderProvider.c b/src/sssd/LMI_SSSDProviderProvider.c new file mode 100644 index 0000000..63bad6d --- /dev/null +++ b/src/sssd/LMI_SSSDProviderProvider.c @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include "LMI_SSSDProvider.h" +#include "utils.h" + +static const CMPIBroker* _cb = NULL; + +static void LMI_SSSDProviderInitialize(const CMPIContext *ctx) + { + lmi_init(PROVIDER_NAME, _cb, ctx, NULL); + } + +static CMPIStatus LMI_SSSDProviderCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDProviderEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_SSSDProviderEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + /* no instances to enumerate */ + + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDProviderGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + const char *namespace = KNameSpace(cop); + LMI_SSSDProvider instance; + LMI_SSSDProviderRef ref; + CMPIStatus ret; + + ret = LMI_SSSDProviderRef_InitFromObjectPath(&ref, _cb, cop); + if (!KOkay(ret)) { + return ret; + } + + LMI_SSSDProvider_Init(&instance, _cb, namespace); + LMI_SSSDProvider_Set_Type(&instance, ref.Type.chars); + LMI_SSSDProvider_Set_Module(&instance, ref.Module.chars); + + LMI_SSSDProvider_Set_Caption(&instance, "SSSD Provider Module"); + LMI_SSSDProvider_Set_Description(&instance, "SSSD Provider Module"); + LMI_SSSDProvider_Set_ElementName(&instance, ref.Type.chars); + + KReturnInstance(cr, instance); + + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDProviderCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDProviderModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char** properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDProviderDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDProviderExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +CMInstanceMIStub( + LMI_SSSDProvider, + LMI_SSSDProvider, + _cb, + LMI_SSSDProviderInitialize(ctx)) + +static CMPIStatus LMI_SSSDProviderMethodCleanup( + CMPIMethodMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDProviderInvokeMethod( + CMPIMethodMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* meth, + const CMPIArgs* in, + CMPIArgs* out) +{ + return LMI_SSSDProvider_DispatchMethod( + _cb, mi, cc, cr, cop, meth, in, out); +} + +CMMethodMIStub( + LMI_SSSDProvider, + LMI_SSSDProvider, + _cb, + LMI_SSSDProviderInitialize(ctx)) + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_SSSDProvider", + "LMI_SSSDProvider", + "instance method") diff --git a/src/sssd/LMI_SSSDResponderProvider.c b/src/sssd/LMI_SSSDResponderProvider.c new file mode 100644 index 0000000..11837b2 --- /dev/null +++ b/src/sssd/LMI_SSSDResponderProvider.c @@ -0,0 +1,264 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include +#include "LMI_SSSDResponder.h" +#include "utils.h" +#include "sssd_components.h" + +static const CMPIBroker* _cb = NULL; + +static void LMI_SSSDResponderInitialize(const CMPIContext *ctx) +{ + lmi_init(PROVIDER_NAME, _cb, ctx, NULL); +} + +static CMPIStatus LMI_SSSDResponderCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDResponderEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_SSSDResponderEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_SSSDResponder instance; + const char *namespace = KNameSpace(cop); + sss_sifp_ctx *sifp_ctx = NULL; + sss_sifp_error error; + char **paths = NULL; + sssd_method_error mret; + CMPIrc ret; + int i; + + error = sss_sifp_init(&sifp_ctx); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_invoke_list(sifp_ctx, SSSD_DBUS_LIST_RESPONDERS, &paths, + DBUS_TYPE_INVALID); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + for (i = 0; paths[i] != NULL; i++) { + mret = sssd_responder_set_instance(sifp_ctx, paths[i], _cb, namespace, + &instance); + if (mret != SSSD_METHOD_ERROR_OK) { + ret = CMPI_RC_ERR_FAILED; + goto done; + } + + KReturnInstance(cr, instance); + } + + ret = CMPI_RC_OK; + +done: + sss_sifp_free_string_array(sifp_ctx, &paths); + sss_sifp_free(&sifp_ctx); + CMReturn(ret); +} + +static CMPIStatus LMI_SSSDResponderGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_SSSDResponder instance; + LMI_SSSDResponderRef ref; + const char *namespace = KNameSpace(cop); + sss_sifp_ctx *sifp_ctx = NULL; + sss_sifp_error error; + const char *name = NULL; + char *path = NULL; + sssd_method_error mret; + CMPIrc ret; + + LMI_SSSDResponderRef_InitFromObjectPath(&ref, _cb, cop); + name = ref.Name.chars; + + error = sss_sifp_init(&sifp_ctx); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_FAILED, done); + + error = sss_sifp_invoke_find(sifp_ctx, SSSD_DBUS_FIND_RESPONDER, &path, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID); + check_sss_sifp_error(error, ret, CMPI_RC_ERR_NOT_FOUND, done); + + mret = sssd_responder_set_instance(sifp_ctx, path, _cb, namespace, + &instance); + if (mret != SSSD_METHOD_ERROR_OK) { + ret = CMPI_RC_ERR_FAILED; + goto done; + } + + KReturnInstance(cr, instance); + ret = CMPI_RC_OK; + +done: + sss_sifp_free_string(sifp_ctx, &path); + sss_sifp_free(&sifp_ctx); + CMReturn(ret); +} + +static CMPIStatus LMI_SSSDResponderCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDResponderModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char** properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDResponderDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDResponderExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +CMInstanceMIStub( + LMI_SSSDResponder, + LMI_SSSDResponder, + _cb, + LMI_SSSDResponderInitialize(ctx)) + +static CMPIStatus LMI_SSSDResponderMethodCleanup( + CMPIMethodMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDResponderInvokeMethod( + CMPIMethodMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* meth, + const CMPIArgs* in, + CMPIArgs* out) +{ + return LMI_SSSDResponder_DispatchMethod( + _cb, mi, cc, cr, cop, meth, in, out); +} + +CMMethodMIStub( + LMI_SSSDResponder, + LMI_SSSDResponder, + _cb, + LMI_SSSDResponderInitialize(ctx)) + +KUint32 LMI_SSSDResponder_SetDebugLevelPermanently( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDResponderRef* self, + const KUint16* debug_level, + CMPIStatus* status) +{ + return sssd_component_set_debug_permanently(self->Name.chars, + SSSD_COMPONENT_RESPONDER, + debug_level, status); +} + +KUint32 LMI_SSSDResponder_SetDebugLevelTemporarily( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDResponderRef* self, + const KUint16* debug_level, + CMPIStatus* status) +{ + return sssd_component_set_debug_temporarily(self->Name.chars, + SSSD_COMPONENT_RESPONDER, + debug_level, status); +} + +KUint32 LMI_SSSDResponder_Enable( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDResponderRef* self, + CMPIStatus* status) +{ + return sssd_component_enable(self->Name.chars, SSSD_COMPONENT_RESPONDER, + status); +} + +KUint32 LMI_SSSDResponder_Disable( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDResponderRef* self, + CMPIStatus* status) +{ + return sssd_component_disable(self->Name.chars, SSSD_COMPONENT_RESPONDER, + status); +} + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_SSSDResponder", + "LMI_SSSDResponder", + "instance method") diff --git a/src/sssd/LMI_SSSDServiceProvider.c b/src/sssd/LMI_SSSDServiceProvider.c new file mode 100644 index 0000000..e65e9be --- /dev/null +++ b/src/sssd/LMI_SSSDServiceProvider.c @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include "LMI_SSSDService.h" +#include "utils.h" + +static const CMPIBroker* _cb = NULL; + +static void LMI_SSSDServiceInitialize(const CMPIContext *ctx) +{ + lmi_init(PROVIDER_NAME, _cb, ctx, NULL); +} + +static CMPIStatus LMI_SSSDServiceCleanup( + CMPIInstanceMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDServiceEnumInstanceNames( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + return KDefaultEnumerateInstanceNames( + _cb, mi, cc, cr, cop); +} + +static CMPIStatus LMI_SSSDServiceEnumInstances( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + LMI_SSSDService lmi_sssd; + const char *namespace = KNameSpace(cop); + const char *hostname = lmi_get_system_name_safe(cc); + + /* LMI_SSSDService is a singleton. */ + + LMI_SSSDService_Init(&lmi_sssd, _cb, namespace); + LMI_SSSDService_Set_Name(&lmi_sssd, SERVICE_NAME); + LMI_SSSDService_Set_SystemName(&lmi_sssd, hostname); + LMI_SSSDService_Set_CreationClassName(&lmi_sssd, LMI_SSSDService_ClassName); + LMI_SSSDService_Set_SystemCreationClassName(&lmi_sssd, + lmi_get_system_creation_class_name()); + + LMI_SSSDService_Set_Caption(&lmi_sssd, SERVICE_NAME); + LMI_SSSDService_Set_Description(&lmi_sssd, + "System Security Services Daemon"); + LMI_SSSDService_Set_ElementName(&lmi_sssd, SERVICE_NAME); + + KReturnInstance(cr, lmi_sssd); + + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDServiceGetInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char** properties) +{ + return KDefaultGetInstance( + _cb, mi, cc, cr, cop, properties); +} + +static CMPIStatus LMI_SSSDServiceCreateInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDServiceModifyInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const CMPIInstance* ci, + const char** properties) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDServiceDeleteInstance( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +static CMPIStatus LMI_SSSDServiceExecQuery( + CMPIInstanceMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* lang, + const char* query) +{ + CMReturn(CMPI_RC_ERR_NOT_SUPPORTED); +} + +CMInstanceMIStub( + LMI_SSSDService, + LMI_SSSDService, + _cb, + LMI_SSSDServiceInitialize(ctx)) + +static CMPIStatus LMI_SSSDServiceMethodCleanup( + CMPIMethodMI* mi, + const CMPIContext* cc, + CMPIBoolean term) +{ + CMReturn(CMPI_RC_OK); +} + +static CMPIStatus LMI_SSSDServiceInvokeMethod( + CMPIMethodMI* mi, + const CMPIContext* cc, + const CMPIResult* cr, + const CMPIObjectPath* cop, + const char* meth, + const CMPIArgs* in, + CMPIArgs* out) +{ + return LMI_SSSDService_DispatchMethod( + _cb, mi, cc, cr, cop, meth, in, out); +} + +CMMethodMIStub( + LMI_SSSDService, + LMI_SSSDService, + _cb, + LMI_SSSDServiceInitialize(ctx)) + +KUint32 LMI_SSSDService_RequestStateChange( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDServiceRef* self, + const KUint16* RequestedState, + KRef* Job, + const KDateTime* TimeoutPeriod, + CMPIStatus* status) +{ + KUint32 result = KUINT32_INIT; + + KSetStatus(status, ERR_NOT_SUPPORTED); + return result; +} + +KUint32 LMI_SSSDService_StartService( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDServiceRef* self, + CMPIStatus* status) +{ + KUint32 result = KUINT32_INIT; + + KSetStatus(status, ERR_NOT_SUPPORTED); + return result; +} + +KUint32 LMI_SSSDService_StopService( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDServiceRef* self, + CMPIStatus* status) +{ + KUint32 result = KUINT32_INIT; + + KSetStatus(status, ERR_NOT_SUPPORTED); + return result; +} + +KUint32 LMI_SSSDService_ChangeAffectedElementsAssignedSequence( + const CMPIBroker* cb, + CMPIMethodMI* mi, + const CMPIContext* context, + const LMI_SSSDServiceRef* self, + const KRefA* ManagedElements, + const KUint16A* AssignedSequence, + KRef* Job, + CMPIStatus* status) +{ + KUint32 result = KUINT32_INIT; + + KSetStatus(status, ERR_NOT_SUPPORTED); + return result; +} + +KONKRET_REGISTRATION( + "root/cimv2", + "LMI_SSSDService", + "LMI_SSSDService", + "instance method") diff --git a/src/sssd/cmpiLMI_SSSD-cimprovagt b/src/sssd/cmpiLMI_SSSD-cimprovagt new file mode 100755 index 0000000..1f1de47 --- /dev/null +++ b/src/sssd/cmpiLMI_SSSD-cimprovagt @@ -0,0 +1,21 @@ +#!/bin/sh +# +# Copyright (C) 2013-2014 Red Hat, Inc. All rights reserved. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Authors: Jan Synacek + +/usr/libexec/pegasus/cimprovagt "$@" diff --git a/src/sssd/sssd_components.c b/src/sssd/sssd_components.c new file mode 100644 index 0000000..2bd53ba --- /dev/null +++ b/src/sssd/sssd_components.c @@ -0,0 +1,360 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include +#include +#include +#include "sssd_components.h" +#include "utils.h" + +static sss_sifp_error +sssd_component_find(sss_sifp_ctx *sifp_ctx, + const char *name, + sssd_component_type type, + char **_path) +{ + sss_sifp_error error; + + switch (type) { + case SSSD_COMPONENT_MONITOR: + error = sss_sifp_invoke_find(sifp_ctx, SSSD_DBUS_FIND_MONITOR, _path, + DBUS_TYPE_INVALID); + break; + case SSSD_COMPONENT_RESPONDER: + error = sss_sifp_invoke_find(sifp_ctx, SSSD_DBUS_FIND_RESPONDER, _path, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID); + break; + case SSSD_COMPONENT_BACKEND: + error = sss_sifp_invoke_find(sifp_ctx, SSSD_DBUS_FIND_BACKEND, _path, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID); + break; + } + + return error; +} + +static sssd_method_error +sssd_component_send_message(sss_sifp_ctx *sifp_ctx, + DBusMessage *message) +{ + sss_sifp_error error; + + error = sss_sifp_send_message(sifp_ctx, message, NULL); + if (error == SSS_SIFP_IO_ERROR) { + if (strcmp(sss_sifp_get_last_io_error_name(sifp_ctx), + DBUS_ERROR_NOT_SUPPORTED) == 0) { + return SSSD_METHOD_ERROR_NOT_SUPPORTED; + } + + return SSSD_METHOD_ERROR_IO; + } else if (error != SSS_SIFP_OK) { + return SSSD_METHOD_ERROR_FAILED; + } + + return SSSD_METHOD_ERROR_OK; +} + +static KUint32 +sssd_component_set_debug_level(const char *method, + const char *name, + sssd_component_type type, + const KUint16* debug_level, + CMPIStatus* _status) +{ + KUint32 result = KUINT32_INIT; + DBusMessage *msg = NULL; + sss_sifp_ctx *sifp_ctx = NULL; + sss_sifp_error error; + dbus_bool_t dbret; + sssd_method_error ret; + char *path = NULL; + uint32_t level; + + KSetStatus(_status, OK); + + error = sss_sifp_init(&sifp_ctx); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_IO, done); + + error = sssd_component_find(sifp_ctx, name, type, &path); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_IO, done); + + if (!debug_level->exists || debug_level->null) { + KSetStatus(_status, ERR_INVALID_PARAMETER); + ret = SSSD_METHOD_ERROR_FAILED; + goto done; + } + + level = debug_level->value; + + msg = sss_sifp_create_message(path, SSS_SIFP_IFACE_COMPONENTS, method); + if (msg == NULL) { + ret = SSSD_METHOD_ERROR_FAILED; + goto done; + } + + dbret = dbus_message_append_args(msg, DBUS_TYPE_UINT32, &level, + DBUS_TYPE_INVALID); + if (!dbret) { + ret = SSSD_METHOD_ERROR_FAILED; + goto done; + } + + ret = sssd_component_send_message(sifp_ctx, msg); + +done: + if (msg != NULL) { + dbus_message_unref(msg); + } + + sss_sifp_free_string(sifp_ctx, &path); + sss_sifp_free(&sifp_ctx); + + KUint32_Set(&result, ret); + return result; +} + +static KUint32 +sssd_component_set_state(const char *method, + const char *name, + sssd_component_type type, + CMPIStatus* _status) +{ + KUint32 result = KUINT32_INIT; + DBusMessage *msg = NULL; + sss_sifp_ctx *sifp_ctx = NULL; + sss_sifp_error error; + sssd_method_error ret; + char *path = NULL; + + error = sss_sifp_init(&sifp_ctx); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_IO, done); + + error = sssd_component_find(sifp_ctx, name, type, &path); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_IO, done); + + msg = sss_sifp_create_message(path, SSS_SIFP_IFACE_COMPONENTS, method); + if (msg == NULL) { + ret = SSSD_METHOD_ERROR_FAILED; + goto done; + } + + ret = sssd_component_send_message(sifp_ctx, msg); + +done: + if (msg != NULL) { + dbus_message_unref(msg); + } + + sss_sifp_free_string(sifp_ctx, &path); + sss_sifp_free(&sifp_ctx); + + KSetStatus(_status, OK); + KUint32_Set(&result, ret); + return result; +} + +KUint32 +sssd_component_set_debug_permanently(const char *name, + sssd_component_type type, + const KUint16* debug_level, + CMPIStatus* _status) +{ + return sssd_component_set_debug_level("ChangeDebugLevel", + name, type, debug_level, _status); +} + +KUint32 +sssd_component_set_debug_temporarily(const char *name, + sssd_component_type type, + const KUint16* debug_level, + CMPIStatus* _status) +{ + return sssd_component_set_debug_level("ChangeDebugLevelTemporarily", + name, type, debug_level, _status); +} + +KUint32 sssd_component_enable(const char *name, + sssd_component_type type, + CMPIStatus* _status) +{ + return sssd_component_set_state("Enable", name, type, _status); +} + +KUint32 sssd_component_disable(const char *name, + sssd_component_type type, + CMPIStatus* _status) +{ + return sssd_component_set_state("Disable", name, type, _status); +} + +struct sssd_component_attrs { + const char *name; + bool enabled; + uint32_t debug; +}; + +static sssd_method_error +sssd_component_get_attrs(sss_sifp_attr **attrs, + const char *path, + struct sssd_component_attrs *out) +{ + sss_sifp_error error; + sssd_method_error ret; + + error = sss_sifp_find_attr_as_string(attrs, "name", &out->name); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + error = sss_sifp_find_attr_as_bool(attrs, "enabled", &out->enabled); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + error = sss_sifp_find_attr_as_uint32(attrs, "debug_level", &out->debug); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + ret = SSSD_METHOD_ERROR_OK; + +done: + return ret; +} + +sssd_method_error +sssd_monitor_set_instance(sss_sifp_ctx *sifp_ctx, + const char *path, + const CMPIBroker* cb, + const char *namespace, + LMI_SSSDMonitor *instance) +{ + sss_sifp_attr **attrs = NULL; + sss_sifp_error error; + struct sssd_component_attrs values; + sssd_method_error ret; + + error = sss_sifp_fetch_all_attrs(sifp_ctx, path, + SSS_SIFP_IFACE_COMPONENTS, &attrs); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_IO, done); + + ret = sssd_component_get_attrs(attrs, path, &values); + if (ret != SSSD_METHOD_ERROR_OK) { + goto done; + } + + LMI_SSSDMonitor_Init(instance, cb, namespace); + + /* CIM_ManagedElement */ + LMI_SSSDMonitor_Set_Caption(instance, "SSSD Monitor Component"); + LMI_SSSDMonitor_Set_Description(instance, "SSSD Monitor Component"); + LMI_SSSDMonitor_Set_ElementName(instance, values.name); + + /* LMI_SSSDMonitor */ + LMI_SSSDMonitor_Set_Name(instance, values.name); + LMI_SSSDMonitor_Set_Type(instance, SSSD_COMPONENT_MONITOR); + LMI_SSSDMonitor_Set_IsEnabled(instance, values.enabled); + LMI_SSSDMonitor_Set_DebugLevel(instance, values.debug); + + ret = SSSD_METHOD_ERROR_OK; + +done: + sss_sifp_free_attrs(sifp_ctx, &attrs); + return ret; +} + +sssd_method_error +sssd_responder_set_instance(sss_sifp_ctx *sifp_ctx, + const char *path, + const CMPIBroker* cb, + const char *namespace, + LMI_SSSDResponder *instance) +{ + sss_sifp_attr **attrs = NULL; + sss_sifp_error error; + struct sssd_component_attrs values; + sssd_method_error ret; + + error = sss_sifp_fetch_all_attrs(sifp_ctx, path, + SSS_SIFP_IFACE_COMPONENTS, &attrs); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_IO, done); + + ret = sssd_component_get_attrs(attrs, path, &values); + if (ret != SSSD_METHOD_ERROR_OK) { + goto done; + } + + LMI_SSSDResponder_Init(instance, cb, namespace); + + /* CIM_ManagedElement */ + LMI_SSSDResponder_Set_Caption(instance, "SSSD Responder Component"); + LMI_SSSDResponder_Set_Description(instance, "SSSD Responder Component"); + LMI_SSSDResponder_Set_ElementName(instance, values.name); + + /* LMI_SSSDResponder */ + LMI_SSSDResponder_Set_Name(instance, values.name); + LMI_SSSDResponder_Set_Type(instance, SSSD_COMPONENT_RESPONDER); + LMI_SSSDResponder_Set_IsEnabled(instance, values.enabled); + LMI_SSSDResponder_Set_DebugLevel(instance, values.debug); + + ret = SSSD_METHOD_ERROR_OK; + +done: + sss_sifp_free_attrs(sifp_ctx, &attrs); + return ret; +} + +sssd_method_error +sssd_backend_set_instance(sss_sifp_ctx *sifp_ctx, + const char *path, + const CMPIBroker* cb, + const char *namespace, + LMI_SSSDBackend *instance) +{ + sss_sifp_attr **attrs = NULL; + sss_sifp_error error; + struct sssd_component_attrs values; + sssd_method_error ret; + + error = sss_sifp_fetch_all_attrs(sifp_ctx, path, + SSS_SIFP_IFACE_COMPONENTS, &attrs); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_IO, done); + + ret = sssd_component_get_attrs(attrs, path, &values); + if (ret != SSSD_METHOD_ERROR_OK) { + goto done; + } + + LMI_SSSDBackend_Init(instance, cb, namespace); + + /* CIM_ManagedElement */ + LMI_SSSDBackend_Set_Caption(instance, "SSSD Responder Component"); + LMI_SSSDBackend_Set_Description(instance, "SSSD Responder Component"); + LMI_SSSDBackend_Set_ElementName(instance, values.name); + + /* LMI_SSSDBackend */ + LMI_SSSDBackend_Set_Name(instance, values.name); + LMI_SSSDBackend_Set_Type(instance, SSSD_COMPONENT_RESPONDER); + LMI_SSSDBackend_Set_IsEnabled(instance, values.enabled); + LMI_SSSDBackend_Set_DebugLevel(instance, values.debug); + + ret = SSSD_METHOD_ERROR_OK; + +done: + sss_sifp_free_attrs(sifp_ctx, &attrs); + return ret; +} diff --git a/src/sssd/sssd_components.h b/src/sssd/sssd_components.h new file mode 100644 index 0000000..0205492 --- /dev/null +++ b/src/sssd/sssd_components.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#ifndef SSSD_COMPONENTS_H_ +#define SSSD_COMPONENTS_H_ + +#include +#include +#include "LMI_SSSDMonitor.h" +#include "LMI_SSSDResponder.h" +#include "LMI_SSSDBackend.h" +#include "utils.h" + +typedef enum sssd_component_type { + SSSD_COMPONENT_MONITOR = 0, + SSSD_COMPONENT_RESPONDER, + SSSD_COMPONENT_BACKEND +} sssd_component_type; + +KUint32 +sssd_component_set_debug_permanently(const char *name, + sssd_component_type type, + const KUint16* debug_level, + CMPIStatus* _status); + +KUint32 +sssd_component_set_debug_temporarily(const char *name, + sssd_component_type type, + const KUint16* debug_level, + CMPIStatus* _status); + +KUint32 sssd_component_enable(const char *name, + sssd_component_type type, + CMPIStatus* _status); + +KUint32 sssd_component_disable(const char *name, + sssd_component_type type, + CMPIStatus* _status); + +sssd_method_error +sssd_monitor_set_instance(sss_sifp_ctx *sifp_ctx, + const char *path, + const CMPIBroker* cb, + const char *namespace, + LMI_SSSDMonitor *instance); + +sssd_method_error +sssd_responder_set_instance(sss_sifp_ctx *sifp_ctx, + const char *path, + const CMPIBroker* cb, + const char *namespace, + LMI_SSSDResponder *instance); + +sssd_method_error +sssd_backend_set_instance(sss_sifp_ctx *sifp_ctx, + const char *path, + const CMPIBroker* cb, + const char *namespace, + LMI_SSSDBackend *instance); + +#endif /* SSSD_COMPONENTS_H_ */ diff --git a/src/sssd/sssd_domains.c b/src/sssd/sssd_domains.c new file mode 100644 index 0000000..be9481c --- /dev/null +++ b/src/sssd/sssd_domains.c @@ -0,0 +1,196 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include +#include +#include "sssd_domains.h" +#include "utils.h" + +struct sssd_domain_attrs { + const char *name; + const char *provider; + const char * const *primary_servers; + unsigned int num_primary; + const char * const *backup_servers; + unsigned int num_backup; + uint32_t min_id; + uint32_t max_id; + const char *realm; + const char *forest; + const char *login_format; + const char *fqn_format; + bool enumerable; + bool use_fqn; + bool subdomain; + const char *parent_domain; +}; + +static sssd_method_error +sssd_domain_get_attrs(sss_sifp_attr **attrs, + const char *path, + struct sssd_domain_attrs *out) +{ + sss_sifp_error error; + sssd_method_error ret; + + error = sss_sifp_find_attr_as_string(attrs, "name", &out->name); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + error = sss_sifp_find_attr_as_string(attrs, "provider", &out->provider); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + error = sss_sifp_find_attr_as_uint32(attrs, "min_id", &out->min_id); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + error = sss_sifp_find_attr_as_uint32(attrs, "max_id", &out->max_id); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + error = sss_sifp_find_attr_as_string(attrs, "realm", &out->realm); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + error = sss_sifp_find_attr_as_string(attrs, "forest", &out->forest); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + error = sss_sifp_find_attr_as_string(attrs, "login_format", + &out->login_format); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + error = sss_sifp_find_attr_as_string(attrs, "fully_qualified_name_format", + &out->fqn_format); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + error = sss_sifp_find_attr_as_bool(attrs, "enumerable", &out->enumerable); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + error = sss_sifp_find_attr_as_bool(attrs, "use_fully_qualified_names", + &out->use_fqn); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + error = sss_sifp_find_attr_as_bool(attrs, "subdomain", &out->subdomain); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + error = sss_sifp_find_attr_as_string(attrs, "parent_domain", + &out->parent_domain); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + /* server list may be empty */ + error = sss_sifp_find_attr_as_string_array(attrs, "primary_servers", + &out->num_primary, &out->primary_servers); + if (error == SSS_SIFP_ATTR_NULL) { + out->num_primary = 0; + out->primary_servers = NULL; + } else if (error != SSS_SIFP_OK) { + ret = SSSD_METHOD_ERROR_FAILED; + goto done; + } + + error = sss_sifp_find_attr_as_string_array(attrs, "backup_servers", + &out->num_backup, &out->backup_servers); + if (error == SSS_SIFP_ATTR_NULL) { + out->num_backup = 0; + out->backup_servers = NULL; + } else if (error != SSS_SIFP_OK) { + ret = SSSD_METHOD_ERROR_FAILED; + goto done; + } + + ret = SSSD_METHOD_ERROR_OK; + +done: + return ret; +} + +sssd_method_error +sssd_domain_set_instance(sss_sifp_ctx *sifp_ctx, + const char *path, + const CMPIBroker* cb, + const char *namespace, + LMI_SSSDDomain *instance) +{ + sss_sifp_attr **attrs = NULL; + sss_sifp_attr **parent = NULL; + sss_sifp_error error; + struct sssd_domain_attrs values; + sssd_method_error ret; + int i; + + error = sss_sifp_fetch_all_attrs(sifp_ctx, path, + SSS_SIFP_IFACE_DOMAINS, &attrs); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_IO, done); + + ret = sssd_domain_get_attrs(attrs, path, &values); + if (ret != SSSD_METHOD_ERROR_OK) { + goto done; + } + + LMI_SSSDDomain_Init(instance, cb, namespace); + + /* CIM_ManagedElement */ + LMI_SSSDDomain_Set_Caption(instance, "SSSD Domain"); + LMI_SSSDDomain_Set_Description(instance, "SSSD Domain"); + LMI_SSSDDomain_Set_ElementName(instance, values.name); + + /* LMI_SSSDDomain */ + LMI_SSSDDomain_Set_Name(instance, values.name); + LMI_SSSDDomain_Set_Provider(instance, values.provider); + LMI_SSSDDomain_Set_MinId(instance, values.min_id); + LMI_SSSDDomain_Set_MaxId(instance, values.max_id); + LMI_SSSDDomain_Set_Realm(instance, values.realm); + LMI_SSSDDomain_Set_Forest(instance, values.forest); + LMI_SSSDDomain_Set_LoginFormat(instance, values.login_format); + LMI_SSSDDomain_Set_FullyQualifiedNameFormat(instance, values.fqn_format); + LMI_SSSDDomain_Set_Enumerate(instance, values.enumerable); + LMI_SSSDDomain_Set_UseFullyQualifiedNames(instance, values.use_fqn); + LMI_SSSDDomain_Set_IsSubdomain(instance, values.subdomain); + + LMI_SSSDDomain_Init_PrimaryServers(instance, values.num_primary); + for (i = 0; i < values.num_primary; i++) { + LMI_SSSDDomain_Set_PrimaryServers(instance, i, + values.primary_servers[i]); + } + + LMI_SSSDDomain_Init_BackupServers(instance, values.num_backup); + for (i = 0; i < values.num_backup; i++) { + LMI_SSSDDomain_Set_BackupServers(instance, i, + values.backup_servers[i]); + } + + if (strcmp(values.parent_domain, "/") == 0) { + LMI_SSSDDomain_Null_ParentDomain(instance); + } else { + error = sss_sifp_fetch_attr(sifp_ctx, values.parent_domain, + SSS_SIFP_IFACE_DOMAINS, "name", &parent); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_IO, done); + + error = sss_sifp_find_attr_as_string(parent, "name", + &values.parent_domain); + check_sss_sifp_error(error, ret, SSSD_METHOD_ERROR_FAILED, done); + + LMI_SSSDDomain_Set_ParentDomain(instance, values.parent_domain); + } + + ret = SSSD_METHOD_ERROR_OK; + +done: + sss_sifp_free_attrs(sifp_ctx, &attrs); + sss_sifp_free_attrs(sifp_ctx, &parent); + return ret; +} diff --git a/src/sssd/sssd_domains.h b/src/sssd/sssd_domains.h new file mode 100644 index 0000000..b3a48b8 --- /dev/null +++ b/src/sssd/sssd_domains.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#ifndef SSSD_DOMAINS_H_ +#define SSSD_DOMAINS_H_ + +#include +#include +#include "LMI_SSSDDomain.h" +#include "utils.h" + +sssd_method_error +sssd_domain_set_instance(sss_sifp_ctx *sifp_ctx, + const char *path, + const CMPIBroker* cb, + const char *namespace, + LMI_SSSDDomain *_instance); + +#endif /* SSSD_DOMAINS_H_ */ diff --git a/src/sssd/utils.c b/src/sssd/utils.c new file mode 100644 index 0000000..cf7db10 --- /dev/null +++ b/src/sssd/utils.c @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#include +#include "openlmi.h" +#include "utils.h" + +void LMI_SSSDService_Get_Ref(const CMPIContext *cc, + const CMPIBroker *cb, + const char *namespace, + LMI_SSSDServiceRef *ref) +{ + const char *hostname = lmi_get_system_name_safe(cc); + const char *sysclass = lmi_get_system_creation_class_name(); + + LMI_SSSDServiceRef_Init(ref, cb, namespace); + LMI_SSSDServiceRef_Set_Name(ref, SERVICE_NAME); + LMI_SSSDServiceRef_Set_SystemName(ref, hostname); + LMI_SSSDServiceRef_Set_CreationClassName(ref, LMI_SSSDService_ClassName); + LMI_SSSDServiceRef_Set_SystemCreationClassName(ref, sysclass); +} + +void hash_delete_cb(hash_entry_t *item, + hash_destroy_enum type, + void *pvt) +{ + free(item->value.ptr); +} diff --git a/src/sssd/utils.h b/src/sssd/utils.h new file mode 100644 index 0000000..1e60d07 --- /dev/null +++ b/src/sssd/utils.h @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2014 Red Hat, Inc. All rights reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: Pavel Březina + */ + +#ifndef LMI_SSSD_UTILS_H_ +#define LMI_SSSD_UTILS_H_ + +#include +#include "openlmi.h" +#include "LMI_SSSDService.h" +#include "LMI_SSSDMonitor.h" +#include "LMI_SSSDResponder.h" +#include "LMI_SSSDDomain.h" + +#define PROVIDER_NAME "sssd" +#define SERVICE_NAME "OpenLMI SSSD Service" + +/* SSSD D-Bus methods */ +#define SSSD_DBUS_LIST_COMPONENTS "Components" +#define SSSD_DBUS_LIST_RESPONDERS "Responders" +#define SSSD_DBUS_LIST_BACKENDS "Backends" +#define SSSD_DBUS_LIST_DOMAINS "Domains" +#define SSSD_DBUS_FIND_MONITOR "Monitor" +#define SSSD_DBUS_FIND_RESPONDER "ResponderByName" +#define SSSD_DBUS_FIND_BACKEND "BackendByName" +#define SSSD_DBUS_FIND_DOMAIN "DomainByName" + +typedef enum { + SSSD_METHOD_ERROR_OK, + SSSD_METHOD_ERROR_FAILED, + SSSD_METHOD_ERROR_NOT_SUPPORTED, + SSSD_METHOD_ERROR_IO +} sssd_method_error; + +#define check_sss_sifp_error(error, ret, val, label) do { \ +if (error != SSS_SIFP_OK) { \ + ret = val; \ + goto label; \ +} \ +} while (0) + +void LMI_SSSDService_Get_Ref(const CMPIContext *cc, + const CMPIBroker *cb, + const char *namespace, + LMI_SSSDServiceRef *ref); + +void hash_delete_cb(hash_entry_t *item, + hash_destroy_enum type, + void *pvt); + +#endif /* LMI_SSSD_UTILS_H_ */ -- cgit