Skip to content

Commit 06f17d6

Browse files
committed
Merge branch 'V5-7-patches'
* V5-7-patches: make python client build with --enable-read-only CHANGES: snmpd: BUG: 2846: fix agent compile when both --enable-read-only and --disable-set-support are given. CHANGES: snmpd: BUG: 2845: fix compilation error with NETSNMP_NO_WRITE_SUPPORT CHANGES: snmpd: BUG: 2810: from "Minzhuan Gong": fix compile with --enable-read-only
2 parents ea60ff1 + 38fb989 commit 06f17d6

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

agent/helpers/table.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,9 @@ table_helper_handler(netsnmp_mib_handler *handler,
491491
if (reqinfo->mode == MODE_SET_RESERVE1)
492492
table_helper_cleanup(reqinfo, request,
493493
SNMP_ERR_NOTWRITABLE);
494-
else if (reqinfo->mode == MODE_GET)
494+
else
495495
#endif /* NETSNMP_NO_WRITE_SUPPORT */
496+
if (reqinfo->mode == MODE_GET)
496497
table_helper_cleanup(reqinfo, request,
497498
SNMP_NOSUCHOBJECT);
498499
else

agent/snmp_agent.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,7 +1970,10 @@ netsnmp_wrap_up_request(netsnmp_agent_session *asp, int status)
19701970
* types to throw an error for a v1 query.
19711971
* See RFC2576 - section 4.1.2.3
19721972
*/
1973-
if ((asp->pdu->command != SNMP_MSG_SET) &&
1973+
if (
1974+
#ifndef NETSNMP_NO_WRITE_SUPPORT
1975+
(asp->pdu->command != SNMP_MSG_SET) &&
1976+
#endif /* NETSNMP_NO_WRITE_SUPPORT */
19741977
(asp->pdu->version == SNMP_VERSION_1)) {
19751978
netsnmp_variable_list *var_ptr = asp->pdu->variables;
19761979
int i = 1;
@@ -2211,15 +2214,15 @@ handle_snmp_packet(int op, netsnmp_session * session, int reqid,
22112214
status = asp->status;
22122215
}
22132216

2214-
#ifdef NETSNMP_DISABLE_SET_SUPPORT
2217+
#if defined(NETSNMP_DISABLE_SET_SUPPORT) && !defined(NETSNMP_NO_WRITE_SUPPORT)
22152218
if (pdu->command == SNMP_MSG_SET) {
22162219
/** Silvercreek protocol tests send set with 0 varbinds */
22172220
if (NULL == pdu->variables)
22182221
return netsnmp_wrap_up_request(asp, SNMP_ERR_NOERROR);
22192222
asp->index = 1;
22202223
return netsnmp_wrap_up_request(asp, SNMP_ERR_NOTWRITABLE);
22212224
}
2222-
#endif /* NETSNMP_DISABLE_SET_SUPPORT */
2225+
#endif /* NETSNMP_DISABLE_SET_SUPPORT && !NETSNMP_NO_WRITE_SUPPORT */
22232226

22242227
if ((access_ret = check_access(asp->pdu)) != 0) {
22252228
if (access_ret == VACM_NOSUCHCONTEXT) {

python/netsnmp/client_intf.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ typedef netsnmp_session SnmpSession;
4545
typedef struct tree SnmpMibNode;
4646
static int __is_numeric_oid (char*);
4747
static int __is_leaf (struct tree*);
48-
static int __translate_appl_type (const char *);
4948
static int __translate_asn_type (int);
5049
static int __snprint_value (char **, size_t *,
5150
netsnmp_variable_list*, struct tree *,
@@ -56,8 +55,6 @@ static int __get_type_str (int, char *);
5655
static int __get_label_iid (char *, char **, char **, int);
5756
static struct tree * __tag2oid (char *, char *, oid *, int *, int *, int);
5857
static int __concat_oid_str (oid *, int *, char *);
59-
static int __add_var_val_str (netsnmp_pdu *, oid *, int, char *,
60-
int, int);
6158
#define USE_NUMERIC_OIDS 0x08
6259
#define NON_LEAF_NAME 0x04
6360
#define USE_LONG_NAMES 0x02
@@ -140,6 +137,7 @@ static const struct type_table_entry type_table[] = {
140137
{ }
141138
};
142139

140+
#ifndef NETSNMP_NO_WRITE_SUPPORT
143141
static int
144142
__translate_appl_type(const char *typestr)
145143
{
@@ -156,6 +154,7 @@ __translate_appl_type(const char *typestr)
156154

157155
return TYPE_UNKNOWN;
158156
}
157+
#endif /* NETSNMP_NO_WRITE_SUPPORT */
159158

160159
static int
161160
__translate_asn_type(int asn_type)
@@ -609,6 +608,7 @@ __concat_oid_str(oid *doid_arr, int *doid_arr_len, char *soid_str)
609608
return(SUCCESS);
610609
}
611610

611+
#ifndef NETSNMP_NO_WRITE_SUPPORT
612612
/*
613613
* add a varbind to PDU
614614
*/
@@ -734,6 +734,7 @@ __add_var_val_str(netsnmp_pdu *pdu, oid *name, int name_length, char *val,
734734

735735
return ret;
736736
}
737+
#endif /* NETSNMP_NO_WRITE_SUPPORT */
737738

738739
/* takes ss and pdu as input and updates the 'response' argument */
739740
/* the input 'pdu' argument will be freed */
@@ -2325,10 +2326,11 @@ netsnmp_getbulk(PyObject *self, PyObject *args)
23252326
static PyObject *
23262327
netsnmp_set(PyObject *self, PyObject *args)
23272328
{
2329+
PyObject *ret = NULL;
2330+
#ifndef NETSNMP_NO_WRITE_SUPPORT
23282331
PyObject *session;
23292332
PyObject *varlist;
23302333
PyObject *varbind;
2331-
PyObject *ret = NULL;
23322334
netsnmp_session *ss;
23332335
netsnmp_pdu *pdu, *response;
23342336
struct tree *tp;
@@ -2461,6 +2463,7 @@ netsnmp_set(PyObject *self, PyObject *args)
24612463
done:
24622464
Py_XDECREF(varbind);
24632465
free(oid_arr);
2466+
#endif /* NETSNMP_NO_WRITE_SUPPORT */
24642467
return (ret ? ret : Py_BuildValue(""));
24652468
}
24662469

0 commit comments

Comments
 (0)