Skip to content

Commit 484c112

Browse files
committed
session_client: fix user searchpath for unix/fd transports
The nc_session_new_ctx() function creates a fresh libyang context (unless an explicit context has been provided) and initializes the context search dirs with the user search path (if set) and NC_SCHEMAS_DIR. This function is only called for the SSH and TLS transports. Making the user searchpath ignored when using the UNIX and FD transports. Call it for all transports. Fixes: fd5b668 ("client CHANGE rewrite loading the schemas into context when connecting to a server") Fixes: ac7fa2f ("add support for unix socket transport") Signed-off-by: Robin Jarry <robin.jarry@6wind.com> Acked-by: Olivier Matz <olivier.matz@6wind.com>
1 parent 373a40a commit 484c112

1 file changed

Lines changed: 6 additions & 22 deletions

File tree

src/session_client.c

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,18 +1098,10 @@ nc_connect_inout(int fdin, int fdout, struct ly_ctx *ctx)
10981098
session->ti.fd.in = fdin;
10991099
session->ti.fd.out = fdout;
11001100

1101-
/* assign context (dicionary needed for handshake) */
1102-
if (!ctx) {
1103-
ctx = ly_ctx_new(NC_SCHEMAS_DIR, LY_CTX_NOYANGLIBRARY);
1104-
/* definitely should not happen, but be ready */
1105-
if (!ctx && !(ctx = ly_ctx_new(NULL, 0))) {
1106-
/* that's just it */
1107-
goto fail;
1108-
}
1109-
} else {
1110-
session->flags |= NC_SESSION_SHAREDCTX;
1101+
if (nc_session_new_ctx(session, ctx) != EXIT_SUCCESS) {
1102+
goto fail;
11111103
}
1112-
session->ctx = ctx;
1104+
ctx = session->ctx;
11131105

11141106
/* NETCONF handshake */
11151107
if (nc_handshake_io(session) != NC_MSG_HELLO) {
@@ -1182,18 +1174,10 @@ nc_connect_unix(const char *address, struct ly_ctx *ctx)
11821174
session->ti.unixsock.sock = sock;
11831175
sock = -1; /* do not close sock in fail label anymore */
11841176

1185-
/* assign context (dictionary needed for handshake) */
1186-
if (!ctx) {
1187-
ctx = ly_ctx_new(NC_SCHEMAS_DIR, LY_CTX_NOYANGLIBRARY);
1188-
/* definitely should not happen, but be ready */
1189-
if (!ctx && !(ctx = ly_ctx_new(NULL, 0))) {
1190-
/* that's just it */
1191-
goto fail;
1192-
}
1193-
} else {
1194-
session->flags |= NC_SESSION_SHAREDCTX;
1177+
if (nc_session_new_ctx(session, ctx) != EXIT_SUCCESS) {
1178+
goto fail;
11951179
}
1196-
session->ctx = ctx;
1180+
ctx = session->ctx;
11971181

11981182
session->path = lydict_insert(ctx, address, 0);
11991183

0 commit comments

Comments
 (0)