config UPDATE new unix socket API
diff --git a/src/config_new.c b/src/config_new.c
index dacb9d3..01f63d6 100644
--- a/src/config_new.c
+++ b/src/config_new.c
@@ -1364,6 +1364,69 @@
#endif /* NC_ENABLED_SSH_TLS */
API int
+nc_server_config_new_unix_socket(const struct ly_ctx *ctx, const char *endpt_name, const char *path,
+ mode_t mode, uid_t uid, gid_t gid, struct lyd_node **config)
+{
+ int ret = 0;
+ char *tree_path = NULL;
+ char buf[12] = {0};
+
+ NC_CHECK_ARG_RET(NULL, ctx, endpt_name, path, config, 1);
+
+ if (asprintf(&tree_path, "/ietf-netconf-server:netconf-server/listen/endpoint[name='%s']/libnetconf2-netconf-server:unix-socket", endpt_name) == -1) {
+ ERRMEM;
+ tree_path = NULL;
+ ret = 1;
+ goto cleanup;
+ }
+
+ /* path to unix socket */
+ ret = nc_config_new_create_append(ctx, tree_path, "path", path, config);
+ if (ret) {
+ goto cleanup;
+ }
+
+ /* mode */
+ if (mode != (mode_t)-1) {
+ if (mode > 0777) {
+ ERR(NULL, "Invalid mode value (%o).", mode);
+ ret = 1;
+ goto cleanup;
+ }
+
+ sprintf(buf, "%o", mode);
+ ret = nc_config_new_create_append(ctx, tree_path, "mode", buf, config);
+ if (ret) {
+ goto cleanup;
+ }
+ }
+
+ /* uid */
+ if (uid != (uid_t)-1) {
+ memset(buf, 0, 12);
+ sprintf(buf, "%u", uid);
+ ret = nc_config_new_create_append(ctx, tree_path, "uid", buf, config);
+ if (ret) {
+ goto cleanup;
+ }
+ }
+
+ /* gid */
+ if (gid != (gid_t)-1) {
+ memset(buf, 0, 12);
+ sprintf(buf, "%u", gid);
+ ret = nc_config_new_create_append(ctx, tree_path, "gid", buf, config);
+ if (ret) {
+ goto cleanup;
+ }
+ }
+
+cleanup:
+ free(tree_path);
+ return ret;
+}
+
+API int
nc_server_config_new_ch_persistent(const struct ly_ctx *ctx, const char *ch_client_name, struct lyd_node **config)
{
NC_CHECK_ARG_RET(NULL, ctx, ch_client_name, config, 1);
diff --git a/src/server_config.c b/src/server_config.c
index b6f693e..439071d 100644
--- a/src/server_config.c
+++ b/src/server_config.c
@@ -870,6 +870,7 @@
close(bind->sock);
}
+ unlink(bind->address);
free(bind->address);
free(opts->address);
diff --git a/src/server_config.h b/src/server_config.h
index bf12757..1bfa885 100644
--- a/src/server_config.h
+++ b/src/server_config.h
@@ -123,6 +123,23 @@
#endif /* NC_ENABLED_SSH_TLS */
/**
+ * @brief Creates new YANG data nodes for a UNIX socket.
+ *
+ * @param[in] ctx libyang context.
+ * @param[in] endpt_name Arbitrary identifier of the endpoint.
+ * If an endpoint with this identifier already exists, its contents might be changed.
+ * @param[in] path Path to the socket.
+ * @param[in] mode New mode, use -1 for default.
+ * @param[in] uid New uid, use -1 for default
+ * @param[in] gid New gid, use -1 for default
+ * @param[in,out] config Configuration YANG data tree. If *config is NULL, it will be created.
+ * Otherwise the new YANG data will be added to the previous data and may override it.
+ * @return 0 on success, non-zero otherwise.
+ */
+int nc_server_config_new_unix_socket(const struct ly_ctx *ctx, const char *endpt_name, const char *path,
+ mode_t mode, uid_t uid, gid_t gid, struct lyd_node **config);
+
+/**
* @brief Deletes an endpoint from the YANG data.
*
* @param[in] endpt_name Optional identifier of an endpoint to be deleted.