Skip to content

Commit

Permalink
system-plugin: switch to building the core ietf-system sysrepo plugin…
Browse files Browse the repository at this point in the history
… library
  • Loading branch information
zinccyy committed Jan 3, 2023
1 parent b640169 commit f41ab13
Show file tree
Hide file tree
Showing 73 changed files with 226 additions and 261 deletions.
153 changes: 59 additions & 94 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project(sysrepo-plugin-system C)

include(CompileOptions.cmake)

set(PLUGIN_LIRBARY_NAME srplg-ietf-system)
set(PLUGIN_LIRBARY_NAME srplg-ietf-system-core)

set(PLUGIN 0 CACHE BOOL "Build a plugin")
option(ENABLE_BUILD_TESTS, "Build tests" OFF)
Expand Down Expand Up @@ -35,112 +35,77 @@ include_directories(
set(
SOURCES

src/plugin.c
src/plugin/common.c
src/plugin/ly_tree.c
src/core/common.c
src/core/ly_tree.c

# startup
src/plugin/startup/load.c
src/plugin/startup/store.c
src/core/startup/load.c
src/core/startup/store.c

# subs
src/plugin/subscription/change.c
src/plugin/subscription/operational.c
src/plugin/subscription/rpc.c
src/core/subscription/change.c
src/core/subscription/operational.c
src/core/subscription/rpc.c

# data
src/plugin/data/system/ip_address.c
src/plugin/data/system/dns_resolver/search.c
src/plugin/data/system/dns_resolver/search/list.c
src/plugin/data/system/dns_resolver/server.c
src/plugin/data/system/dns_resolver/server/list.c
src/plugin/data/system/ntp/server.c
src/plugin/data/system/ntp/server/list.c
src/plugin/data/system/authentication/authorized_key.c
src/plugin/data/system/authentication/authorized_key/list.c
src/plugin/data/system/authentication/local_user.c
src/plugin/data/system/authentication/local_user/list.c
src/core/data/system/ip_address.c
src/core/data/system/dns_resolver/search.c
src/core/data/system/dns_resolver/search/list.c
src/core/data/system/dns_resolver/server.c
src/core/data/system/dns_resolver/server/list.c
src/core/data/system/ntp/server.c
src/core/data/system/ntp/server/list.c
src/core/data/system/authentication/authorized_key.c
src/core/data/system/authentication/authorized_key/list.c
src/core/data/system/authentication/local_user.c
src/core/data/system/authentication/local_user/list.c

# system API
src/plugin/api/system/load.c
src/plugin/api/system/check.c
src/plugin/api/system/store.c
src/plugin/api/system/change.c
src/plugin/api/system/ntp/load.c
src/plugin/api/system/ntp/check.c
src/plugin/api/system/ntp/store.c
src/plugin/api/system/ntp/change.c
src/plugin/api/system/dns_resolver/load.c
src/plugin/api/system/dns_resolver/check.c
src/plugin/api/system/dns_resolver/store.c
src/plugin/api/system/dns_resolver/change.c
src/plugin/api/system/authentication/load.c
src/plugin/api/system/authentication/check.c
src/plugin/api/system/authentication/store.c
src/plugin/api/system/authentication/change.c
src/core/api/system/load.c
src/core/api/system/check.c
src/core/api/system/store.c
src/core/api/system/change.c
src/core/api/system/ntp/load.c
src/core/api/system/ntp/check.c
src/core/api/system/ntp/store.c
src/core/api/system/ntp/change.c
src/core/api/system/dns_resolver/load.c
src/core/api/system/dns_resolver/check.c
src/core/api/system/dns_resolver/store.c
src/core/api/system/dns_resolver/change.c
src/core/api/system/authentication/load.c
src/core/api/system/authentication/check.c
src/core/api/system/authentication/store.c
src/core/api/system/authentication/change.c
)

# build plugin static library
# build plugin core library
add_library(${PLUGIN_LIRBARY_NAME} STATIC ${SOURCES})
install(TARGETS ${PLUGIN_LIRBARY_NAME} DESTINATION lib)

if(NOT PLUGIN)
add_executable(
${CMAKE_PROJECT_NAME}
src/main.c
)
# link executable
target_link_libraries(
${CMAKE_PROJECT_NAME}
${PLUGIN_LIRBARY_NAME}
${SYSREPO_LIBRARIES}
${LIBYANG_LIBRARIES}
${SRPC_LIBRARIES}
${UMGMT_LIBRARIES}
)
install(TARGETS ${CMAKE_PROJECT_NAME} DESTINATION bin)
else()
# build plugin as a module for sysrepo-plugind
add_library(
${CMAKE_PROJECT_NAME}
MODULE
${SOURCES}
)
# remove lib prefix from plugin library
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES PREFIX "")
# link executable
target_link_libraries(
${CMAKE_PROJECT_NAME}
${SYSREPO_LIBRARIES}
${LIBYANG_LIBRARIES}
${SRPC_LIBRARIES}
${UMGMT_LIBRARIES}
)
endif()

if(SYSTEMD_FOUND)
if(DEFINED SYSTEMD_IFINDEX)
add_compile_definitions(SYSTEMD_IFINDEX=${SYSTEMD_IFINDEX})
else()
message(SEND_ERROR "No SYSTEMD_IFINDEX value set for default interface index to use with systemd... Unable to build without it")
endif()

add_compile_definitions(SYSTEMD)
target_link_libraries(
${CMAKE_PROJECT_NAME}
${SYSTEMD_LIBRARIES}
)
include_directories(
${SYSTEMD_INCLUDE_DIRS}
)
endif()

# augyang support
if(AUGYANG_FOUND)
add_compile_definitions(AUGYANG)
else(AUGYANG_FOUND)
message(WARNING "AUGYANG not found - augeas support will be disabled")
endif()
# if(SYSTEMD_FOUND)
# if(DEFINED SYSTEMD_IFINDEX)
# add_compile_definitions(SYSTEMD_IFINDEX=${SYSTEMD_IFINDEX})
# else()
# message(SEND_ERROR "No SYSTEMD_IFINDEX value set for default interface index to use with systemd... Unable to build without it")
# endif()

# add_compile_definitions(SYSTEMD)
# target_link_libraries(
# ${CMAKE_PROJECT_NAME}
# ${SYSTEMD_LIBRARIES}
# )
# include_directories(
# ${SYSTEMD_INCLUDE_DIRS}
# )
# endif()

# # augyang support
# if(AUGYANG_FOUND)
# add_compile_definitions(AUGYANG)
# else(AUGYANG_FOUND)
# message(WARNING "AUGYANG not found - augeas support will be disabled")
# endif()

if(ENABLE_BUILD_TESTS)
find_package(CMOCKA REQUIRED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "change.h"
#include "plugin/common.h"
#include "core/common.h"
#include "libyang/tree_data.h"
#include "plugin/api/system/authentication/store.h"
#include "plugin/data/system/authentication/authorized_key.h"
#include "plugin/data/system/authentication/authorized_key/list.h"
#include "plugin/data/system/authentication/local_user.h"
#include "plugin/data/system/authentication/local_user/list.h"
#include "plugin/types.h"
#include "core/api/system/authentication/store.h"
#include "core/data/system/authentication/authorized_key.h"
#include "core/data/system/authentication/authorized_key/list.h"
#include "core/data/system/authentication/local_user.h"
#include "core/data/system/authentication/local_user/list.h"
#include "core/types.h"
#include "umgmt/db.h"
#include "umgmt/types.h"
#include "umgmt/user.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef SYSTEM_PLUGIN_API_AUTHENTICATION_CHANGE_H
#define SYSTEM_PLUGIN_API_AUTHENTICATION_CHANGE_H

#include "plugin/context.h"
#include "core/context.h"

#include <srpc.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/
#include "check.h"
#include "load.h"
#include "plugin/common.h"
#include "plugin/data/system/authentication/local_user/list.h"
#include "plugin/data/system/authentication/authorized_key/list.h"
#include "core/common.h"
#include "core/data/system/authentication/local_user/list.h"
#include "core/data/system/authentication/authorized_key/list.h"

#include <sysrepo.h>
#include <utlist.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#ifndef SYSTEM_PLUGIN_API_AUTHENTICATION_CHECK_H
#define SYSTEM_PLUGIN_API_AUTHENTICATION_CHECK_H

#include "plugin/context.h"
#include "plugin/types.h"
#include "core/context.h"
#include "core/types.h"
#include <srpc.h>

srpc_check_status_t system_authentication_check_user(system_ctx_t *ctx, system_local_user_element_t *head, system_local_user_element_t **system_head);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
*/
#include "load.h"
#include "sysrepo.h"
#include "plugin/types.h"
#include "plugin/common.h"
#include "core/types.h"
#include "core/common.h"

#include "plugin/data/system/authentication/authorized_key/list.h"
#include "plugin/data/system/authentication/authorized_key.h"
#include "plugin/data/system/authentication/local_user/list.h"
#include "plugin/data/system/authentication/local_user.h"
#include "core/data/system/authentication/authorized_key/list.h"
#include "core/data/system/authentication/authorized_key.h"
#include "core/data/system/authentication/local_user/list.h"
#include "core/data/system/authentication/local_user.h"
#include "umgmt/user.h"

#include <unistd.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#ifndef SYSTEM_PLUGIN_API_AUTHENTICATION_LOAD_H
#define SYSTEM_PLUGIN_API_AUTHENTICATION_LOAD_H

#include "plugin/context.h"
#include "plugin/types.h"
#include "core/context.h"
#include "core/types.h"

int system_authentication_load_user(system_ctx_t *ctx, system_local_user_element_t **head);
int system_authentication_load_user_authorized_key(system_ctx_t *ctx, const char *user, system_authorized_key_element_t **head);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "store.h"
#include "plugin/common.h"
#include "core/common.h"
#include "umgmt/group.h"

#include <asm-generic/errno-base.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef SYSTEM_PLUGIN_API_AUTHENTICATION_STORE_H
#define SYSTEM_PLUGIN_API_AUTHENTICATION_STORE_H

#include "plugin/context.h"
#include "core/context.h"

int system_authentication_store_user(system_ctx_t *ctx, system_local_user_element_t *head);
int system_authentication_store_user_authorized_key(system_ctx_t *ctx, const char *user, system_authorized_key_element_t *head);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef SYSTEM_PLUGIN_API_CHANGE_H
#define SYSTEM_PLUGIN_API_CHANGE_H

#include "plugin/context.h"
#include "core/context.h"

#include <srpc.h>

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/plugin/api/system/check.h → src/core/api/system/check.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#ifndef SYSTEM_PLUGIN_API_CHECK_H
#define SYSTEM_PLUGIN_API_CHECK_H

#include "plugin/common.h"
#include "plugin/context.h"
#include "core/common.h"
#include "core/context.h"

#include <srpc.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
#include "srpc/types.h"
#include "store.h"
#include "sysrepo_types.h"
#include "plugin/types.h"
#include "plugin/common.h"
#include "core/types.h"
#include "core/common.h"

// data
#include "plugin/data/system/dns_resolver/server/list.h"
#include "plugin/data/system/dns_resolver/search/list.h"
#include "plugin/data/system/dns_resolver/search.h"
#include "plugin/data/system/dns_resolver/server.h"
#include "plugin/data/system/ip_address.h"
#include "core/data/system/dns_resolver/server/list.h"
#include "core/data/system/dns_resolver/search/list.h"
#include "core/data/system/dns_resolver/search.h"
#include "core/data/system/dns_resolver/server.h"
#include "core/data/system/ip_address.h"

#include <sysrepo.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifndef SYSTEM_PLUGIN_API_DNS_RESOLVER_CHANGE_H
#define SYSTEM_PLUGIN_API_DNS_RESOLVER_CHANGE_H

#include "plugin/context.h"
#include "core/context.h"

#include <srpc.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
#include "check.h"
#include "load.h"
#include "srpc/types.h"
#include "plugin/types.h"
#include "plugin/common.h"
#include "plugin/data/system/dns_resolver/search/list.h"
#include "plugin/data/system/dns_resolver/server/list.h"
#include "core/types.h"
#include "core/common.h"
#include "core/data/system/dns_resolver/search/list.h"
#include "core/data/system/dns_resolver/server/list.h"

#include <sysrepo.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#ifndef SYSTEM_PLUGIN_API_DNS_RESOLVER_CHECK_H
#define SYSTEM_PLUGIN_API_DNS_RESOLVER_CHECK_H

#include "plugin/context.h"
#include "plugin/types.h"
#include "core/context.h"
#include "core/types.h"

#include <srpc.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
#include "load.h"
#include "plugin/common.h"
#include "core/common.h"

// data
#include "plugin/data/system/dns_resolver/server.h"
#include "plugin/data/system/dns_resolver/server/list.h"
#include "plugin/data/system/dns_resolver/search/list.h"
#include "plugin/data/system/ip_address.h"
#include "core/data/system/dns_resolver/server.h"
#include "core/data/system/dns_resolver/server/list.h"
#include "core/data/system/dns_resolver/search/list.h"
#include "core/data/system/ip_address.h"

#include <systemd/sd-bus.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#ifndef SYSTEM_PLUGIN_API_DNS_RESOLVER_LOAD_H
#define SYSTEM_PLUGIN_API_DNS_RESOLVER_LOAD_H

#include "plugin/types.h"
#include "plugin/context.h"
#include "core/types.h"
#include "core/context.h"

int system_dns_resolver_load_search(system_ctx_t *ctx, system_dns_search_element_t **head);
int system_dns_resolver_load_server(system_ctx_t *ctx, system_dns_server_element_t **head);
Expand Down
Loading

0 comments on commit f41ab13

Please sign in to comment.