Skip to content

Commit a32e395

Browse files
committed
Merge branch 'PR64' into persistent_timeout_fix_pr
2 parents 25b9bb1 + 9f838b0 commit a32e395

9 files changed

Lines changed: 326 additions & 162 deletions

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ set(CMAKE_C_FLAGS_DEBUG "-g -O0")
3232
# set version
3333
set(LIBNETCONF2_MAJOR_VERSION 0)
3434
set(LIBNETCONF2_MINOR_VERSION 11)
35-
set(LIBNETCONF2_MICRO_VERSION 38)
35+
set(LIBNETCONF2_MICRO_VERSION 44)
3636
set(LIBNETCONF2_VERSION ${LIBNETCONF2_MAJOR_VERSION}.${LIBNETCONF2_MINOR_VERSION}.${LIBNETCONF2_MICRO_VERSION})
3737
set(LIBNETCONF2_SOVERSION ${LIBNETCONF2_MAJOR_VERSION}.${LIBNETCONF2_MINOR_VERSION})
3838

schemas/ietf-netconf-acm.yin

Lines changed: 71 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<module xmlns="urn:ietf:params:xml:ns:yang:yin:1" xmlns:nacm="urn:ietf:params:xml:ns:yang:ietf-netconf-acm" xmlns:yang="urn:ietf:params:xml:ns:yang:ietf-yang-types" name="ietf-netconf-acm">
2+
<module name="ietf-netconf-acm"
3+
xmlns="urn:ietf:params:xml:ns:yang:yin:1"
4+
xmlns:nacm="urn:ietf:params:xml:ns:yang:ietf-netconf-acm"
5+
xmlns:yang="urn:ietf:params:xml:ns:yang:ietf-yang-types">
36
<namespace uri="urn:ietf:params:xml:ns:yang:ietf-netconf-acm"/>
47
<prefix value="nacm"/>
58
<import module="ietf-yang-types">
@@ -9,40 +12,44 @@
912
<text>IETF NETCONF (Network Configuration) Working Group</text>
1013
</organization>
1114
<contact>
12-
<text>WG Web: &lt;http://tools.ietf.org/wg/netconf/&gt;
15+
<text>WG Web: &lt;https://datatracker.ietf.org/wg/netconf/&gt;
1316
WG List: &lt;mailto:netconf@ietf.org&gt;
1417

15-
WG Chair: Mehmet Ersue
16-
&lt;mailto:mehmet.ersue@nsn.com&gt;
17-
18-
WG Chair: Bert Wijnen
19-
&lt;mailto:bertietf@bwijnen.net&gt;
20-
21-
Editor: Andy Bierman
18+
Author: Andy Bierman
2219
&lt;mailto:andy@yumaworks.com&gt;
2320

24-
Editor: Martin Bjorklund
21+
Author: Martin Bjorklund
2522
&lt;mailto:mbj@tail-f.com&gt;</text>
2623
</contact>
2724
<description>
28-
<text>NETCONF Access Control Model.
25+
<text>Network Configuration Access Control Model.
2926

30-
Copyright (c) 2012 IETF Trust and the persons identified as
31-
authors of the code. All rights reserved.
27+
Copyright (c) 2012 - 2018 IETF Trust and the persons
28+
identified as authors of the code. All rights reserved.
3229

3330
Redistribution and use in source and binary forms, with or
3431
without modification, is permitted pursuant to, and subject
3532
to the license terms contained in, the Simplified BSD
3633
License set forth in Section 4.c of the IETF Trust's
3734
Legal Provisions Relating to IETF Documents
38-
(http://trustee.ietf.org/license-info).
35+
(https://trustee.ietf.org/license-info).
3936

40-
This version of this YANG module is part of RFC 6536; see
37+
This version of this YANG module is part of RFC 8341; see
4138
the RFC itself for full legal notices.</text>
4239
</description>
40+
<revision date="2018-02-14">
41+
<description>
42+
<text>Added support for YANG 1.1 actions and notifications tied to
43+
data nodes. Clarified how NACM extensions can be used by
44+
other data models.</text>
45+
</description>
46+
<reference>
47+
<text>RFC 8341: Network Configuration Access Control Model</text>
48+
</reference>
49+
</revision>
4350
<revision date="2012-02-22">
4451
<description>
45-
<text>Initial version</text>
52+
<text>Initial version.</text>
4653
</description>
4754
<reference>
4855
<text>RFC 6536: Network Configuration Protocol (NETCONF)
@@ -54,11 +61,13 @@ the RFC itself for full legal notices.</text>
5461
<text>Used to indicate that the data model node
5562
represents a sensitive security system parameter.
5663

57-
If present, and the NACM module is enabled (i.e.,
58-
/nacm/enable-nacm object equals 'true'), the NETCONF server
59-
will only allow the designated 'recovery session' to have
60-
write access to the node. An explicit access control rule is
61-
required for all other users.
64+
If present, the NETCONF server will only allow the designated
65+
'recovery session' to have write access to the node. An
66+
explicit access control rule is required for all other users.
67+
68+
If the NACM module is used, then it must be enabled (i.e.,
69+
/nacm/enable-nacm object equals 'true'), or this extension
70+
is ignored.
6271

6372
The 'default-deny-write' extension MAY appear within a data
6473
definition statement. It is ignored otherwise.</text>
@@ -69,11 +78,14 @@ definition statement. It is ignored otherwise.</text>
6978
<text>Used to indicate that the data model node
7079
controls a very sensitive security system parameter.
7180

72-
If present, and the NACM module is enabled (i.e.,
73-
/nacm/enable-nacm object equals 'true'), the NETCONF server
74-
will only allow the designated 'recovery session' to have
75-
read, write, or execute access to the node. An explicit
76-
access control rule is required for all other users.
81+
If present, the NETCONF server will only allow the designated
82+
'recovery session' to have read, write, or execute access to
83+
the node. An explicit access control rule is required for all
84+
other users.
85+
86+
If the NACM module is used, then it must be enabled (i.e.,
87+
/nacm/enable-nacm object equals 'true'), or this extension
88+
is ignored.
7789

7890
The 'default-deny-all' extension MAY appear within a data
7991
definition statement, 'rpc' statement, or 'notification'
@@ -85,7 +97,7 @@ statement. It is ignored otherwise.</text>
8597
<length value="1..max"/>
8698
</type>
8799
<description>
88-
<text>General Purpose Username string.</text>
100+
<text>General-purpose username string.</text>
89101
</description>
90102
</typedef>
91103
<typedef name="matchall-string-type">
@@ -130,7 +142,7 @@ data node.</text>
130142
</bit>
131143
</type>
132144
<description>
133-
<text>NETCONF Access Operation.</text>
145+
<text>Access operation.</text>
134146
</description>
135147
</typedef>
136148
<typedef name="group-name-type">
@@ -165,35 +177,40 @@ rule matches.</text>
165177
<type name="yang:xpath1.0"/>
166178
<description>
167179
<text>Path expression used to represent a special
168-
data node instance identifier string.
180+
data node, action, or notification instance-identifier
181+
string.
169182

170183
A node-instance-identifier value is an
171184
unrestricted YANG instance-identifier expression.
172-
All the same rules as an instance-identifier apply
173-
except predicates for keys are optional. If a key
185+
All the same rules as an instance-identifier apply,
186+
except that predicates for keys are optional. If a key
174187
predicate is missing, then the node-instance-identifier
175188
represents all possible server instances for that key.
176189

177-
This XPath expression is evaluated in the following context:
190+
This XML Path Language (XPath) expression is evaluated in the
191+
following context:
192+
193+
o The set of namespace declarations are those in scope on
194+
the leaf element where this type is used.
178195

179-
o The set of namespace declarations are those in scope on
180-
the leaf element where this type is used.
196+
o The set of variable bindings contains one variable,
197+
'USER', which contains the name of the user of the
198+
current session.
181199

182-
o The set of variable bindings contains one variable,
183-
'USER', which contains the name of the user of the current
184-
session.
200+
o The function library is the core function library, but
201+
note that due to the syntax restrictions of an
202+
instance-identifier, no functions are allowed.
185203

186-
o The function library is the core function library, but
187-
note that due to the syntax restrictions of an
188-
instance-identifier, no functions are allowed.
204+
o The context node is the root node in the data tree.
189205

190-
o The context node is the root node in the data tree.</text>
206+
The accessible tree includes actions and notifications tied
207+
to data nodes.</text>
191208
</description>
192209
</typedef>
193210
<container name="nacm">
194211
<nacm:default-deny-all/>
195212
<description>
196-
<text>Parameters for NETCONF Access Control Model.</text>
213+
<text>Parameters for NETCONF access control model.</text>
197214
</description>
198215
<leaf name="enable-nacm">
199216
<type name="boolean"/>
@@ -273,12 +290,12 @@ access to the event type was denied.</text>
273290
</leaf>
274291
<container name="groups">
275292
<description>
276-
<text>NETCONF Access Control Groups.</text>
293+
<text>NETCONF access control groups.</text>
277294
</description>
278295
<list name="group">
279296
<key value="name"/>
280297
<description>
281-
<text>One NACM Group Entry. This list will only contain
298+
<text>One NACM group entry. This list will only contain
282299
configured entries, not any entries learned from
283300
any transport protocols.</text>
284301
</description>
@@ -335,8 +352,8 @@ entry.</text>
335352
Rules are processed in user-defined order until a match is
336353
found. A rule matches if 'module-name', 'rule-type', and
337354
'access-operations' match the request. If a rule
338-
matches, the 'action' leaf determines if access is granted
339-
or not.</text>
355+
matches, the 'action' leaf determines whether or not
356+
access is granted.</text>
340357
</description>
341358
<leaf name="name">
342359
<type name="string">
@@ -396,13 +413,14 @@ value equals the requested notification name.</text>
396413
<type name="node-instance-identifier"/>
397414
<mandatory value="true"/>
398415
<description>
399-
<text>Data Node Instance Identifier associated with the
400-
data node controlled by this rule.
416+
<text>Data node instance-identifier associated with the
417+
data node, action, or notification controlled by
418+
this rule.
401419

402-
Configuration data or state data instance
403-
identifiers start with a top-level data node. A
404-
complete instance identifier is required for this
405-
type of path value.
420+
Configuration data or state data
421+
instance-identifiers start with a top-level
422+
data node. A complete instance-identifier is
423+
required for this type of path value.
406424

407425
The special value '/' refers to all possible
408426
datastore contents.</text>
@@ -428,7 +446,7 @@ bit corresponding to the requested operation is set.</text>
428446
<mandatory value="true"/>
429447
<description>
430448
<text>The access control action associated with the
431-
rule. If a rule is determined to match a
449+
rule. If a rule has been determined to match a
432450
particular request, then this object is used
433451
to determine whether to permit or deny the
434452
request.</text>

src/io.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ nc_read_until(struct nc_session *session, const char *endtag, size_t limit, uint
197197
struct timespec *ts_act_timeout, char **result)
198198
{
199199
char *chunk = NULL;
200-
size_t size, count = 0, r, len;
200+
size_t size, count = 0, r, len, i, matched = 0;
201201

202202
assert(session);
203203
assert(endtag);
@@ -223,7 +223,7 @@ nc_read_until(struct nc_session *session, const char *endtag, size_t limit, uint
223223
}
224224

225225
/* resize buffer if needed */
226-
if (count == size) {
226+
if ((count + (len - matched)) >= size) {
227227
/* get more memory */
228228
size = size + BUFFERSIZE;
229229
chunk = realloc(chunk, (size + 1) * sizeof *chunk);
@@ -234,21 +234,28 @@ nc_read_until(struct nc_session *session, const char *endtag, size_t limit, uint
234234
}
235235

236236
/* get another character */
237-
r = nc_read(session, &(chunk[count]), 1, inact_timeout, ts_act_timeout);
238-
if (r != 1) {
237+
r = nc_read(session, &(chunk[count]), len - matched, inact_timeout, ts_act_timeout);
238+
if (r != len - matched) {
239239
free(chunk);
240240
return -1;
241241
}
242242

243-
count++;
243+
count += len - matched;
244244

245-
/* check endtag */
246-
if (count >= len) {
247-
if (!strncmp(endtag, &(chunk[count - len]), len)) {
248-
/* endtag found */
245+
for (i = len - matched; i > 0; i--) {
246+
if (!strncmp(&endtag[matched], &(chunk[count - i]), i)) {
247+
/*part of endtag found */
248+
matched += i;
249249
break;
250+
} else {
251+
matched = 0;
250252
}
251253
}
254+
255+
/* whole endtag found */
256+
if (matched == len) {
257+
break;
258+
}
252259
}
253260

254261
/* terminating null byte */
@@ -1264,3 +1271,4 @@ nc_realloc(void *ptr, size_t size)
12641271

12651272
return ret;
12661273
}
1274+

0 commit comments

Comments
 (0)