Blame SOURCES/net-snmp-5.7.2-CVE-2020-15862.patch

17224f
diff -urNp old/agent/mibgroup/agent/extend.c new/agent/mibgroup/agent/extend.c
17224f
--- old/agent/mibgroup/agent/extend.c	2020-11-11 12:41:46.377115142 +0100
17224f
+++ new/agent/mibgroup/agent/extend.c	2020-11-11 12:50:28.047142105 +0100
17224f
@@ -16,6 +16,12 @@
17224f
 #define SHELLCOMMAND 3
17224f
 #endif
17224f
 
17224f
+/*  This mib is potentially dangerous to turn on by default, since it
17224f
+ *  allows arbitrary commands to be set by anyone with SNMP WRITE
17224f
+ *  access to the MIB table.  If all of your users are "root" level
17224f
+ *  users, then it may be safe to turn on. */
17224f
+#define ENABLE_EXTEND_WRITE_ACCESS 0
17224f
+
17224f
 netsnmp_feature_require(extract_table_row_data)
17224f
 netsnmp_feature_require(table_data_delete_table)
17224f
 #ifndef NETSNMP_NO_WRITE_SUPPORT
17224f
@@ -723,7 +729,7 @@ handle_nsExtendConfigTable(netsnmp_mib_h
17224f
          *
17224f
          **********/
17224f
 
17224f
-#ifndef NETSNMP_NO_WRITE_SUPPORT
17224f
+#if !defined(NETSNMP_NO_WRITE_SUPPORT) && ENABLE_EXTEND_WRITE_ACCESS
17224f
         case MODE_SET_RESERVE1:
17224f
             /*
17224f
              * Validate the new assignments
17224f
@@ -1049,7 +1055,7 @@ handle_nsExtendConfigTable(netsnmp_mib_h
17224f
                 }
17224f
             }
17224f
             break;
17224f
-#endif /* !NETSNMP_NO_WRITE_SUPPORT */ 
17224f
+#endif /* !NETSNMP_NO_WRITE_SUPPORT and ENABLE_EXTEND_WRITE_ACCESS */
17224f
 
17224f
         default:
17224f
             netsnmp_set_request_error(reqinfo, request, SNMP_ERR_GENERR);
17224f
@@ -1057,7 +1063,7 @@ handle_nsExtendConfigTable(netsnmp_mib_h
17224f
         }
17224f
     }
17224f
 
17224f
-#ifndef NETSNMP_NO_WRITE_SUPPORT
17224f
+#if !defined(NETSNMP_NO_WRITE_SUPPORT) && ENABLE_EXTEND_WRITE_ACCESS
17224f
     /*
17224f
      * If we're marking a given row as active,
17224f
      *  then we need to check that it's ready.
17224f
@@ -1082,7 +1088,7 @@ handle_nsExtendConfigTable(netsnmp_mib_h
17224f
             }
17224f
         }
17224f
     }
17224f
-#endif /* !NETSNMP_NO_WRITE_SUPPORT */
17224f
+#endif /* !NETSNMP_NO_WRITE_SUPPORT && ENABLE_EXTEND_WRITE_ACCESS */
17224f
     
17224f
     return SNMP_ERR_NOERROR;
17224f
 }
17224f
@@ -1571,7 +1577,7 @@ fixExec2Error(int action,
17224f
     idx = name[name_len-1] -1;
17224f
     exten = &compatability_entries[ idx ];
17224f
 
17224f
-#ifndef NETSNMP_NO_WRITE_SUPPORT
17224f
+#if !defined(NETSNMP_NO_WRITE_SUPPORT) && ENABLE_EXTEND_WRITE_ACCESS
17224f
     switch (action) {
17224f
     case MODE_SET_RESERVE1:
17224f
         if (var_val_type != ASN_INTEGER) {
17224f
@@ -1592,7 +1598,7 @@ fixExec2Error(int action,
17224f
     case MODE_SET_COMMIT:
17224f
         netsnmp_cache_check_and_reload( exten->efix_entry->cache );
17224f
     }
17224f
-#endif /* !NETSNMP_NO_WRITE_SUPPORT */
17224f
+#endif /* !NETSNMP_NO_WRITE_SUPPORT && ENABLE_EXTEND_WRITE_ACCESS */
17224f
     return SNMP_ERR_NOERROR;
17224f
 }
17224f
 #endif /* USING_UCD_SNMP_EXTENSIBLE_MODULE */