Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

452 Commits   2 Branches   1 Tag
Index: Makefile
===================================================================
--- Makefile	(nonexistent)
+++ Makefile	(revision 5)
@@ -0,0 +1,69 @@
+
+COMPONENT_TARGETS = $(HARDWARE_NOARCH)
+
+
+include ../../../../build-system/constants.mk
+
+
+url         = $(DOWNLOAD_SERVER)/sources/packages/n/net-snmp
+
+versions    = 5.9
+pkgname     = net-snmp
+suffix      = tar.gz
+
+tarballs    = $(addsuffix .$(suffix), $(addprefix $(pkgname)-, $(versions)))
+sha1s       = $(addsuffix .sha1sum, $(tarballs))
+
+patches     = $(CURDIR)/patches/net-snmp-5.9-cert-path.patch
+patches    += $(CURDIR)/patches/net-snmp-5.9-cross-python.patch
+patches    += $(CURDIR)/patches/net-snmp-5.9-iterator.patch
+patches    += $(CURDIR)/patches/net-snmp-5.9-modern-rpm-api.patch
+patches    += $(CURDIR)/patches/net-snmp-5.9-remove-U64-typedef.patch
+patches    += $(CURDIR)/patches/net-snmp-5.9-snmp-config.patch
+patches    += $(CURDIR)/patches/net-snmp-5.9-snmpd-conf.patch
+
+
+.NOTPARALLEL: $(patches)
+
+
+BUILD_TARGETS = $(tarballs) $(sha1s) $(patches)
+
+
+include ../../../../build-system/core.mk
+
+
+.PHONY: download_clean
+
+
+$(tarballs):
+	@echo -e "\n======= Downloading source tarballs =======" ; \
+	 for tarball in $(tarballs) ; do \
+	   echo "$(url)/$$tarball" | xargs -n 1 -P 100 wget $(WGET_OPTIONS) - & \
+	 done ; wait
+
+$(sha1s): $(tarballs)
+	@for sha in $@ ; do \
+	   echo -e "\n======= Downloading '$$sha' signature =======\n" ; \
+	   echo "$(url)/$$sha" | xargs -n 1 -P 100 wget $(WGET_OPTIONS) - & wait %1 ; \
+	   touch $$sha ; \
+	   echo -e "\n======= Check the '$$sha' sha1sum =======\n" ; \
+	   sha1sum --check $$sha ; ret="$$?" ; \
+	   if [ "$$ret" == "1" ]; then \
+	     echo -e "\n======= ERROR: Bad '$$sha' sha1sum =======\n" ; \
+	     exit 1 ; \
+	   fi ; \
+	 done
+
+$(patches): $(sha1s)
+	@echo -e "\n======= Create Patches =======\n" ; \
+	 ( cd create-5.9-cert-path-patch          ; ./create.patch.sh ) ; \
+	 ( cd create-5.9-cross-python-patch       ; ./create.patch.sh ) ; \
+	 ( cd create-5.9-iterator-patch           ; ./create.patch.sh ) ; \
+	 ( cd create-5.9-modern-rpm-api-patch     ; ./create.patch.sh ) ; \
+	 ( cd create-5.9-remove-U64-typedef-patch ; ./create.patch.sh ) ; \
+	 ( cd create-5.9-snmp-config-patch        ; ./create.patch.sh ) ; \
+	 ( cd create-5.9-snmpd-conf-patch         ; ./create.patch.sh ) ; \
+	 echo -e "\n"
+
+download_clean:
+	@rm -f $(tarballs) $(sha1s) $(patches)
Index: create-5.9-cert-path-patch/create.patch.sh
===================================================================
--- create-5.9-cert-path-patch/create.patch.sh	(nonexistent)
+++ create-5.9-cert-path-patch/create.patch.sh	(revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=5.9
+
+tar --files-from=file.list -xzvf ../net-snmp-$VERSION.tar.gz
+mv net-snmp-$VERSION net-snmp-$VERSION-orig
+
+cp -rf ./net-snmp-$VERSION-new ./net-snmp-$VERSION
+
+diff --unified -Nr  net-snmp-$VERSION-orig  net-snmp-$VERSION > net-snmp-$VERSION-cert-path.patch
+
+mv net-snmp-$VERSION-cert-path.patch ../patches
+
+rm -rf ./net-snmp-$VERSION
+rm -rf ./net-snmp-$VERSION-orig

Property changes on: create-5.9-cert-path-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-5.9-cert-path-patch/file.list
===================================================================
--- create-5.9-cert-path-patch/file.list	(nonexistent)
+++ create-5.9-cert-path-patch/file.list	(revision 5)
@@ -0,0 +1 @@
+net-snmp-5.9/local/net-snmp-cert
Index: create-5.9-cert-path-patch/net-snmp-5.9-new/local/net-snmp-cert
===================================================================
--- create-5.9-cert-path-patch/net-snmp-5.9-new/local/net-snmp-cert	(nonexistent)
+++ create-5.9-cert-path-patch/net-snmp-5.9-new/local/net-snmp-cert	(revision 5)
@@ -0,0 +1,2689 @@
+#!/usr/bin/perl
+
+use strict;
+use 5.8.0;
+
+use Getopt::Long qw(:config gnu_getopt no_ignore_case pass_through);
+use Cwd qw(getcwd realpath);
+use File::Basename;
+use File::Copy;
+use File::Path;
+use Sys::Hostname;
+use Carp;
+
+our @CC = (
+["AF","AFGHANISTAN"],
+["AX","ÅLAND ISLANDS"],
+["AL","ALBANIA"],
+["DZ","ALGERIA"],
+["AS","AMERICAN SAMOA"],
+["AD","ANDORRA"],
+["AO","ANGOLA"],
+["AI","ANGUILLA"],
+["AQ","ANTARCTICA"],
+["AG","ANTIGUA AND BARBUDA"],
+["AR","ARGENTINA"],
+["AM","ARMENIA"],
+["AW","ARUBA"],
+["AU","AUSTRALIA"],
+["AT","AUSTRIA"],
+["AZ","AZERBAIJAN"],
+["BS","BAHAMAS"],
+["BH","BAHRAIN"],
+["BD","BANGLADESH"],
+["BB","BARBADOS"],
+["BY","BELARUS"],
+["BE","BELGIUM"],
+["BZ","BELIZE"],
+["BJ","BENIN"],
+["BM","BERMUDA"],
+["BT","BHUTAN"],
+["BO","BOLIVIA, PLURINATIONAL STATE OF"],
+["BA","BOSNIA AND HERZEGOVINA"],
+["BW","BOTSWANA"],
+["BV","BOUVET ISLAND"],
+["BR","BRAZIL"],
+["IO","BRITISH INDIAN OCEAN TERRITORY"],
+["BN","BRUNEI DARUSSALAM"],
+["BG","BULGARIA"],
+["BF","BURKINA FASO"],
+["BI","BURUNDI"],
+["KH","CAMBODIA"],
+["CM","CAMEROON"],
+["CA","CANADA"],
+["CV","CAPE VERDE"],
+["KY","CAYMAN ISLANDS"],
+["CF","CENTRAL AFRICAN REPUBLIC"],
+["TD","CHAD"],
+["CL","CHILE"],
+["CN","CHINA"],
+["CX","CHRISTMAS ISLAND"],
+["CC","COCOS (KEELING) ISLANDS"],
+["CO","COLOMBIA"],
+["KM","COMOROS"],
+["CG","CONGO"],
+["CD","CONGO, THE DEMOCRATIC REPUBLIC OF THE"],
+["CK","COOK ISLANDS"],
+["CR","COSTA RICA"],
+["CI","CÔTE D'IVOIRE"],
+["HR","CROATIA"],
+["CU","CUBA"],
+["CY","CYPRUS"],
+["CZ","CZECH REPUBLIC"],
+["DK","DENMARK"],
+["DJ","DJIBOUTI"],
+["DM","DOMINICA"],
+["DO","DOMINICAN REPUBLIC"],
+["EC","ECUADOR"],
+["EG","EGYPT"],
+["SV","EL SALVADOR"],
+["GQ","EQUATORIAL GUINEA"],
+["ER","ERITREA"],
+["EE","ESTONIA"],
+["ET","ETHIOPIA"],
+["FK","FALKLAND ISLANDS (MALVINAS)"],
+["FO","FAROE ISLANDS"],
+["FJ","FIJI"],
+["FI","FINLAND"],
+["FR","FRANCE"],
+["GF","FRENCH GUIANA"],
+["PF","FRENCH POLYNESIA"],
+["TF","FRENCH SOUTHERN TERRITORIES"],
+["GA","GABON"],
+["GM","GAMBIA"],
+["GE","GEORGIA"],
+["DE","GERMANY"],
+["GH","GHANA"],
+["GI","GIBRALTAR"],
+["GR","GREECE"],
+["GL","GREENLAND"],
+["GD","GRENADA"],
+["GP","GUADELOUPE"],
+["GU","GUAM"],
+["GT","GUATEMALA"],
+["GG","GUERNSEY"],
+["GN","GUINEA"],
+["GW","GUINEA-BISSAU"],
+["GY","GUYANA"],
+["HT","HAITI"],
+["HM","HEARD ISLAND AND MCDONALD ISLANDS"],
+["VA","HOLY SEE (VATICAN CITY STATE)"],
+["HN","HONDURAS"],
+["HK","HONG KONG"],
+["HU","HUNGARY"],
+["IS","ICELAND"],
+["IN","INDIA"],
+["ID","INDONESIA"],
+["IR","IRAN, ISLAMIC REPUBLIC OF"],
+["IQ","IRAQ"],
+["IE","IRELAND"],
+["IM","ISLE OF MAN"],
+["IL","ISRAEL"],
+["IT","ITALY"],
+["JM","JAMAICA"],
+["JP","JAPAN"],
+["JE","JERSEY"],
+["JO","JORDAN"],
+["KZ","KAZAKHSTAN"],
+["KE","KENYA"],
+["KI","KIRIBATI"],
+["KP","KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF"],
+["KR","KOREA, REPUBLIC OF"],
+["KW","KUWAIT"],
+["KG","KYRGYZSTAN"],
+["LA","LAO PEOPLE'S DEMOCRATIC REPUBLIC"],
+["LV","LATVIA"],
+["LB","LEBANON"],
+["LS","LESOTHO"],
+["LR","LIBERIA"],
+["LY","LIBYAN ARAB JAMAHIRIYA"],
+["LI","LIECHTENSTEIN"],
+["LT","LITHUANIA"],
+["LU","LUXEMBOURG"],
+["MO","MACAO"],
+["MK","MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF"],
+["MG","MADAGASCAR"],
+["MW","MALAWI"],
+["MY","MALAYSIA"],
+["MV","MALDIVES"],
+["ML","MALI"],
+["MT","MALTA"],
+["MH","MARSHALL ISLANDS"],
+["MQ","MARTINIQUE"],
+["MR","MAURITANIA"],
+["MU","MAURITIUS"],
+["YT","MAYOTTE"],
+["MX","MEXICO"],
+["FM","MICRONESIA, FEDERATED STATES OF"],
+["MD","MOLDOVA, REPUBLIC OF"],
+["MC","MONACO"],
+["MN","MONGOLIA"],
+["ME","MONTENEGRO"],
+["MS","MONTSERRAT"],
+["MA","MOROCCO"],
+["MZ","MOZAMBIQUE"],
+["MM","MYANMAR"],
+["NA","NAMIBIA"],
+["NR","NAURU"],
+["NP","NEPAL"],
+["NL","NETHERLANDS"],
+["AN","NETHERLANDS ANTILLES"],
+["NC","NEW CALEDONIA"],
+["NZ","NEW ZEALAND"],
+["NI","NICARAGUA"],
+["NE","NIGER"],
+["NG","NIGERIA"],
+["NU","NIUE"],
+["NF","NORFOLK ISLAND"],
+["MP","NORTHERN MARIANA ISLANDS"],
+["NO","NORWAY"],
+["OM","OMAN"],
+["PK","PAKISTAN"],
+["PW","PALAU"],
+["PS","PALESTINIAN TERRITORY, OCCUPIED"],
+["PA","PANAMA"],
+["PG","PAPUA NEW GUINEA"],
+["PY","PARAGUAY"],
+["PE","PERU"],
+["PH","PHILIPPINES"],
+["PN","PITCAIRN"],
+["PL","POLAND"],
+["PT","PORTUGAL"],
+["PR","PUERTO RICO"],
+["QA","QATAR"],
+["RE","RÉUNION"],
+["RO","ROMANIA"],
+["RU","RUSSIAN FEDERATION"],
+["RW","RWANDA"],
+["BL","SAINT BARTHÉLEMY"],
+["SH","SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA"],
+["KN","SAINT KITTS AND NEVIS"],
+["LC","SAINT LUCIA"],
+["MF","SAINT MARTIN"],
+["PM","SAINT PIERRE AND MIQUELON"],
+["VC","SAINT VINCENT AND THE GRENADINES"],
+["WS","SAMOA"],
+["SM","SAN MARINO"],
+["ST","SAO TOME AND PRINCIPE"],
+["SA","SAUDI ARABIA"],
+["SN","SENEGAL"],
+["RS","SERBIA"],
+["SC","SEYCHELLES"],
+["SL","SIERRA LEONE"],
+["SG","SINGAPORE"],
+["SK","SLOVAKIA"],
+["SI","SLOVENIA"],
+["SB","SOLOMON ISLANDS"],
+["SO","SOMALIA"],
+["ZA","SOUTH AFRICA"],
+["GS","SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS"],
+["ES","SPAIN"],
+["LK","SRI LANKA"],
+["SD","SUDAN"],
+["SR","SURINAME"],
+["SJ","SVALBARD AND JAN MAYEN"],
+["SZ","SWAZILAND"],
+["SE","SWEDEN"],
+["CH","SWITZERLAND"],
+["SY","SYRIAN ARAB REPUBLIC"],
+["TW","TAIWAN, PROVINCE OF CHINA"],
+["TJ","TAJIKISTAN"],
+["TZ","TANZANIA, UNITED REPUBLIC OF"],
+["TH","THAILAND"],
+["TL","TIMOR-LESTE"],
+["TG","TOGO"],
+["TK","TOKELAU"],
+["TO","TONGA"],
+["TT","TRINIDAD AND TOBAGO"],
+["TN","TUNISIA"],
+["TR","TURKEY"],
+["TM","TURKMENISTAN"],
+["TC","TURKS AND CAICOS ISLANDS"],
+["TV","TUVALU"],
+["UG","UGANDA"],
+["UA","UKRAINE"],
+["AE","UNITED ARAB EMIRATES"],
+["GB","UNITED KINGDOM"],
+["US","UNITED STATES"],
+["UM","UNITED STATES MINOR OUTLYING ISLANDS"],
+["UY","URUGUAY"],
+["UZ","UZBEKISTAN"],
+["VU","VANUATU"],
+["VE","VENEZUELA, BOLIVARIAN REPUBLIC OF"],
+["VN","VIET NAM"],
+["VG","VIRGIN ISLANDS, BRITISH"],
+["VI","VIRGIN ISLANDS, U.S."],
+["WF","WALLIS AND FUTUNA"],
+["EH","WESTERN SAHARA"],
+["YE","YEMEN"],
+["ZM","ZAMBIA"],
+["ZW","ZIMBABWE"],
+);
+
+package NetSNMP::Term;
+# gratefully taken from Wayne Thompson's Term::Complete
+# if newer CORE modules could be used this could be removed
+our($complete, $exit, $done, $kill, $erase1, $erase2, $tty_raw_noecho, $tty_restore, $stty, $tty_safe_restore);
+our($tty_saved_state) = '';
+CONFIG: {
+  $exit   = "\003";
+  $done   = "\004";
+  $kill   = "\025";
+  $erase1 =   "\177";
+  $erase2 =   "\010";
+  foreach my $s (qw(/bin/stty /usr/bin/stty)) {
+    if (-x $s) {
+      $tty_raw_noecho = "$s raw -echo";
+      $tty_restore    = "$s -raw echo";
+      $tty_safe_restore = $tty_restore;
+      $stty = $s;
+      last;
+    }
+  }
+}
+
+sub Complete {
+  my($prompt, $dflt, $help, $match, @cmp_lst);
+  my (%help, $cmp, $test, $l, @match);
+  my ($return, $r, $exitting) = ("", 0, 0);
+  my $tab;
+
+  $prompt = shift;
+  $dflt = shift;
+  $help = shift;
+  $match = shift;
+
+  if (ref $_[0] and ref($_[0][0])) {
+    @cmp_lst = @{$_[0]};
+  } else {
+    @cmp_lst = @_;
+  }
+  @cmp_lst = map {if (ref($_)) { $help{$_->[0]}=$_->[1]; $_->[0]} else {$_;}} @cmp_lst;
+
+  # Attempt to save the current stty state, to be restored later
+  if (defined $stty && defined $tty_saved_state && $tty_saved_state eq '') {
+    $tty_saved_state = qx($stty -g 2>/dev/null);
+    if ($?) {
+      # stty -g not supported
+      $tty_saved_state = undef;
+    } else {
+      $tty_saved_state =~ s/\s+$//g;
+      $tty_restore = qq($stty "$tty_saved_state" 2>/dev/null);
+    }
+  }
+  system $tty_raw_noecho if defined $tty_raw_noecho;
+ LOOP: {
+    local $_;
+    print($prompt, $return);
+    while (($_ = getc(STDIN)) ne "\r") {
+    CASE: {
+	# (TAB) attempt completion
+	$_ eq "\t" && do {
+	  if ($tab) {
+	    print(join("\r\n", '', map {exists $help{$_} ? sprintf("\t%-10.10s - %s", $_, $help{$_}) :
+					  "\t$_"} grep(/^\Q$return/, @cmp_lst)), "\r\n");
+	    $tab--;
+	    redo LOOP;
+	  }
+	  @match = grep(/^\Q$return/, @cmp_lst);
+	  unless ($#match < 0) {
+	    $l = length($test = shift(@match));
+	    foreach $cmp (@match) {
+	      until (substr($cmp, 0, $l) eq substr($test, 0, $l)) {
+		$l--;
+	      }
+	    }
+	    print("\a");
+	    print($test = substr($test, $r, $l - $r));
+	    $r = length($return .= $test);
+	  }
+	  $tab++;
+	  last CASE;
+	};
+
+	# (^C) exit
+	$_ eq $exit && do {
+	  print("\r\naborting application...\r\n");
+	  $exitting++;
+	  undef $return;
+	  last LOOP;
+	};
+
+	# (^D) done
+	$_ eq $done && do {
+	  undef $return;
+	  last LOOP;
+	};
+
+	# (?) show help if available
+	$_ eq '?' && do {
+	  print("\r\n$help\r\n");
+	  if (exists $help{$return}) {
+	    print("\t$return - $help{$return}\r\n");
+	  } else {
+	    print(join("\r\n", map {exists $help{$_} ? "\t$_ - $help{$_}" :
+				      "\t$_"} grep(/^\Q$return/, @cmp_lst)), "\r\n");
+	  }
+	  redo LOOP;
+	};
+
+	# (^U) kill
+	$_ eq $kill && do {
+	  if ($r) {
+	    $r	= 0;
+	    $return	= "";
+	    print("\r\n");
+	    redo LOOP;
+	  }
+	  last CASE;
+	};
+
+	# (DEL) || (BS) erase
+	($_ eq $erase1 || $_ eq $erase2) && do {
+	  if ($r) {
+	    print("\b \b");
+	    chop($return);
+	    $r--;
+	  }
+	  last CASE;
+	};
+
+	# printable char
+	ord >= 32 && do {
+	  $return .= $_;
+	  $r++;
+	  print;
+	  last CASE;
+	};
+      }
+    }
+
+    if (defined $return) {
+      if (length($return) == 0 or $return eq $dflt) {
+	$return = $dflt;
+      } elsif ($match == $NetSNMP::Cert::MATCH and scalar(grep {/^$return$/} @cmp_lst) != 1 or
+	       $match == $NetSNMP::Cert::PREMATCH and scalar(grep {$return=~/$_/} @cmp_lst) != 1) {
+	$r	= 0;
+	$return	= "";
+	print("\r\nChoose a valid option, or ^D to exit\r\n");
+	redo LOOP;
+      }
+    }
+  }
+ DONE:
+  # system $tty_restore if defined $tty_restore;
+  if (defined $tty_saved_state && defined $tty_restore && defined $tty_safe_restore) {
+    system $tty_restore;
+    if ($?) {
+      # tty_restore caused error
+      system $tty_safe_restore;
+    }
+  }
+
+  exit(1) if $exitting;
+  print("\n");
+  return $return;
+}
+
+package NetSNMP::Cert;
+
+our $VERSION      = '0.2.9';
+
+our $PROG         = ::basename($0);
+our $DEBUG        = 0;
+our $OK           = 0;
+our $ERR          = -1;
+
+# user input param
+our $MATCH        = 1;
+our $PREMATCH     = 2;
+
+# Load LWP if possible to import cert from URL
+eval('use LWP::UserAgent;');
+our $haveUserAgent = ($@ ? 0 : 1);
+
+# required executables
+our $OPENSSL     = $ENV{NET_SNMP_CRT_OPENSSL}  || 'openssl';
+our $CFGTOOL     = $ENV{NET_SNMP_CRT_CFGTOOL}  || 'net-snmp-config';
+
+# default app config file
+our $CFGFILE     = $ENV{NET_SNMP_CRT_CFGFILE}  || 'net-snmp-cert.conf';
+
+# default OpenSSL config files
+our $SSLCFGIN    = $ENV{NET_SNMP_CRT_SSLCFGIN} || 'openssl.in';
+our $SSLCFGOUT   = $ENV{NET_SNMP_CRT_SSLCFGIN} || '.openssl.conf';
+our $SSLCFG      = $ENV{NET_SNMP_CRT_SSLCFG};
+
+# default cmd logs
+our $OUTLOG      = $ENV{NET_SNMP_CRT_OUTLOG}   || '.cmd.out.log';
+our $ERRLOG      = $ENV{NET_SNMP_CRT_ERRLOG}   || '.cmd.err.log';
+
+# default cert dirs
+our $TLSDIR      = $ENV{NET_SNMP_CRT_TLSDIR}   || 'tls';
+our $CRTDIR      = $ENV{NET_SNMP_CRT_CRTDIR}   || 'certs';
+our $NEWCRTDIR   = $ENV{NET_SNMP_CRT_NEWCRTDIR}|| 'newcerts';
+our $CADIR       = $ENV{NET_SNMP_CRT_CADIR}    || 'ca-certs';
+our $PRIVDIR     = $ENV{NET_SNMP_CRT_PRIVDIR}  || 'private';
+
+our $SERIAL      = $ENV{NET_SNMP_CRT_SERIAL}   || '.serial';
+our $INDEX       = $ENV{NET_SNMP_CRT_INDEX}    || '.index';
+
+our $DEFCADAYS   = $ENV{NET_SNMP_CRT_DEFCADAYS} || 1825;
+our $DEFCRTDAYS  = $ENV{NET_SNMP_CRT_DEFCRTDAYS}|| 365;
+
+our @TLSDIRS     = ($CRTDIR, $NEWCRTDIR, $CADIR, $PRIVDIR);
+
+our @CRTSUFFIXES = qw(.pem .csr .der .crt);
+
+our @X509FMTS = qw(text modulus serial subject_hash issuer_hash hash subject
+		    purpose issuer startdate enddate dates fingerprint C);
+
+sub dprint {
+  my $str = shift;
+  my $opts = shift;
+  my $dlevel = shift || 1;
+  my $flag = (defined $opts ? int($opts->{'debug'} >= $dlevel) : 1);
+  my ($pkg, $file, $line, $sub) = caller(1);
+  my ($pkg0, $file0, $line0) = caller(0);
+  print("${sub}():$line0: $str") if $flag;
+}
+
+sub dwarn {
+  my $str = shift;
+  my $opts = shift;
+  my $dlevel = shift || 1;
+  my $flag = (defined $opts ? $opts->{'debug'} >= $dlevel : 1);
+  my ($pkg, $file, $line, $sub) = caller(1);
+  my ($pkg0, $file0, $line0) = caller(0);
+  warn("${sub}():$line0: $str") if $flag;
+}
+
+sub vprint {
+  my $str = shift;
+  my $opts = shift;
+  my $flag = (defined $opts ? $opts->{'verbose'} : 1);
+  my $debug = (defined $opts ? $opts->{'debug'} : 1);
+  my ($pkg, $file, $line, $sub) = caller(1);
+  my ($pkg0, $file0, $line0) = caller(0);
+  $str = ($debug ? "${sub}():$line0: $str" : "$str");
+  print("$str") if $flag;
+}
+
+sub vwarn {
+  my $str = shift;
+  my $opts = shift;
+  my $flag = (defined $opts ? $opts->{'verbose'} : 1);
+  my ($pkg, $file, $line, $sub) = caller(1);
+  my ($pkg0, $file0, $line0) = caller(0);
+  warn("${sub}():$line0: $str") if $flag;
+}
+
+sub rsystem {
+  my $cmd = shift;
+  my $flag = shift;
+
+  # if not running as root try to use sudo
+  if ($>) {
+    $cmd = "sudo $flag $cmd";
+  } else {
+    if ($flag =~ /-b/) {
+      $cmd = "$cmd \&";
+    }
+  }
+  die("cmd failed($!): $cmd\n") if system("$cmd");
+}
+
+sub usystem {
+  my $cmd = shift;
+  my $opts = shift;
+  my $ret;
+
+  unlink $NetSNMP::Cert::OUTLOG if -e $NetSNMP::Cert::OUTLOG;
+  unlink $NetSNMP::Cert::ERRLOG if -e $NetSNMP::Cert::ERRLOG;
+
+  $ret = system("$cmd");
+
+  if ($ret) {
+    if ($opts->{'verbose'}) {
+      system("cat $NetSNMP::Cert::OUTLOG") if -r $NetSNMP::Cert::OUTLOG;
+      system("cat $NetSNMP::Cert::ERRLOG") if -r $NetSNMP::Cert::ERRLOG;
+    }
+    die("cmd failed($!): $cmd\n");
+  }
+}
+
+sub home_dir {
+  my $cdir = ::getcwd();
+
+  chdir("~");
+  my $dir = ::getcwd();
+  chdir($cdir);
+
+  return $dir;
+}
+
+sub find_bin_dir {
+  # This code finds the path to the currently invoked program and
+  my $dir;
+
+  $0 =~ m%^(([^/]*)(.*)/)([^/]+)$%;
+  if ($1) {
+    if ($2) {
+      # Invoked using a relative path.  CD there and use pwd.
+      $dir = `cd $1 && pwd`;
+      chomp $dir;
+    } else {
+      # Invoked using an absolute path; that's it!
+      $dir = $3;
+    }
+  } else {
+    # No path.  Look in PATH for the first instance.
+    foreach my $p (split /:/, $ENV{PATH}) {
+      $p ||= '.';
+      -x "$p/$4" or next;
+      $dir = $p;
+    }
+  }
+  $dir or die "Cannot locate program '$0'!";
+}
+
+sub fq_rel_path {
+  my $path = shift;
+  my $cwd = ::getcwd();
+  my $rdir = shift || $cwd;
+
+  chdir($rdir) or die("can't change directory: $rdir");
+  # get fully qualified path
+  if ($path !~ m|^/|) {
+    my $pwd = `pwd`; chomp $pwd;
+    $path = "$pwd/$path";
+    $path = ::realpath($path) if -e $path;
+  }
+  chdir($cwd) or die("can't change directory: $cwd");
+
+  return $path;
+}
+
+sub dir_empty
+  {
+    my $path = shift;
+    opendir(DIR, $path);
+    foreach (readdir(DIR)) {
+      next if /^\.\.?$/;
+      closedir(DIR);
+      return 0;
+    }
+    closedir(DIR);
+    return 1;
+  }
+
+sub make_dirs {
+  my $opts = shift;
+  my $dir = shift;
+  my $mode = shift;
+  my @dirs = @_;
+
+  my $wd = ::getcwd();
+
+  NetSNMP::Cert::dprint("make dirs [$dir:@dirs] from $wd\n", $opts);
+
+  ::mkpath($dir, $opts->{'debug'}, $mode) or die("error - can't make $dir")
+    if defined $dir and not -d $dir;
+
+  foreach my $subdir (@dirs) {
+    my $d = "$subdir";
+    $d = "$dir/$d" if defined $dir;
+    NetSNMP::Cert::dprint("making directory: $d\n", $opts) unless -d $d;
+    mkdir($d, $mode) or die("error - can't make $d") unless -d $d;
+  }
+}
+
+sub is_url {
+  my $url = shift;
+
+  return $url =~ /^(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:\/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|\/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?$/;
+}
+
+sub in_set {
+  my $elem = shift;
+  my $set = shift;
+  for my $e (eval($set)) {
+    return 1 if $e == $elem;
+  }
+  return 0;
+}
+
+sub in_arr {
+  my $elem = shift;
+  my $arr = shift;
+  for my $e (@{$arr}) {
+    return 1 if $e eq $elem;
+  }
+  return 0;
+}
+
+sub map_bool {
+  my $val = shift;
+
+  return 1 if $val =~ /^true$/i;
+  return 0 if $val =~ /^false$/i;
+  return $val;
+}
+
+sub version {
+  my $ret = (@_ ? shift : 1);
+  print "$NetSNMP::Cert::PROG: $NetSNMP::Cert::VERSION\n";
+  exit($ret);
+}
+
+sub GetOptsFromArray {
+  my $args = shift;
+  local *ARGV;
+  @ARGV = @$args;
+  my $ret = ::GetOptions(@_);
+  @$args = @ARGV; # GetOptions strips out the ones it handles and leaves others
+  return $ret;
+}
+sub pull_cmd {
+  my $args = shift;
+  my $cmd;
+
+  foreach (@{$args}) {
+    if (/^(gence?rt|genca|gencsr|signcsr|showcas?|showce?rts?|import)$/) {
+      $cmd = $1;
+    }
+  }
+
+  @{$args} = grep {!/^$cmd$/} @{$args};
+
+  return $cmd;
+}
+
+
+sub usage {
+  my $ret = (@_ ? shift : 1);
+  my $arg = shift;
+
+  print "Command not implmeneted yet: $arg\n" if $ret == 2;
+  print "Unknown: $arg\n" if $ret == 3;
+  print "\n   NAME:\n";
+  print "     $NetSNMP::Cert::PROG: [$NetSNMP::Cert::VERSION] - ";
+  print "Net-SNMP Certificate Management Tool\n";
+  print "\n   DESCRIPTION:\n";
+  print "     net-snmp-cert creates, signs, installs and displays X.509\n";
+  print "     certificates used in the operation of Net-SNMP/(D)TLS.\n";
+  print "\n   SYNOPSIS:\n";
+  print "     net-snmp-cert [--help|-?]\n";
+  print "     net-snmp-cert [--version|-V]\n";
+  print "     net-snmp-cert genca    [<flags>] [<dn-opts>] [--with-ca <ca>]\n";
+  print "     net-snmp-cert gencert  [<flags>] [<dn-opts>] [--with-ca <ca>]\n";
+  print "     net-snmp-cert gencsr   [<flags>] [<dn-opts>] [--from-crt <crt>]\n";
+  print "     net-snmp-cert signcsr  [<flags>] [--install] --csr <csr> --with-ca <ca>\n";
+  print "     net-snmp-cert showca   [<flags>] [<format-opts>] [<file>|<search-tag>]\n";
+  print "     net-snmp-cert showcert [<flags>] [<format-opts>] [<file>|<search-tag>]\n";
+  print "     net-snmp-cert import   [<flags>] <file|url> [<key>]\n";
+  print "\n   COMMANDS:\n";
+  print "     genca    -- generate a signed CA certificate suitable for signing other\n";
+  print "                 certificates. default: self-signed unless --with-ca <ca> supplied\n\n";
+  print "     gencert  -- generate a signed certificate suitable for identification, or\n";
+  print "                 validation. default: self-signed unless --with-ca <ca> supplied\n\n";
+  print "     gencsr   -- generate a certificate signing request. will create a new\n";
+  print "                 key and certificate unless --from-crt <crt> supplied\n\n";
+  print "     signcsr  -- sign a certificate signing request specified by --csr <csr>\n";
+  print "                 with the CA certificate specified by --with-ca <ca>\n";
+  print "     import   -- import an identity or CA certificate, optionally import <key>\n";
+  print "                 if an URL is passed, will attempt to import certificate from site\n";
+  print "     showca,\n";
+  print "     showcert -- show CA or identity certificate(s). may pass fully qualified\n";
+  print "                 file or directory name, or a search-tag which prefix matches\n";
+  print "                 installed CA or identity certificate file name(s)\n";
+  print "                 see FORMAT OPTIONS to specify output format\n\n";
+  print "\n   FLAGS:\n";
+  print "     -?, --help            -- show this text and exit\n";
+  print "     -V, --version         -- show version string and exit\n";
+  print "     -D, --debug           -- raise debug level (-D -D for higher level)\n";
+  print "     -F, --force           -- force overwrite of existing output files\n";
+  print "     -I, --nointeractive   -- non-interactive run (default interactive)\n";
+  print "     -Q, --noverbose       -- non-verbose output (default verbose)\n";
+  print "     -C, --cfgdir   <dir>  -- configuration dir (see man(5) snmp_config)\n";
+  print "     -T, --tlsdir   <dir>  -- root for cert storage (default <cfgdir>/tls)\n";
+  print "     -f, --cfgfile  <file> -- config (default <cfgdir>/net-snmp-cert.conf)\n";
+  print "     -i, --identity <id>   -- identity to use from config\n";
+  print "     -t, --tag      <tag>  -- application tag (default 'snmp')\n";
+  print "     --<cfg-param>[=<val>] -- additional config params\n";  
+  print "\n   CERTIFICATE OPTIONS (<cert-opts>):\n";
+  print "     -a, --with-ca <ca>    -- CA certificate used to sign request\n";
+  print "     -A, --ca <ca>         -- explicit output CA certificate\n";
+  print "     -r, --csr <csr>       -- certificate signing request\n";
+  print "     -x, --from-crt <crt>  -- input certificate for current operation\n";
+  print "     -X, --crt <crt>       -- explicit output certificate\n";
+  print "     -y, --install         -- install result in local repository\n";
+  print "\n   DISTINGUISHED NAME OPTIONS (<dn-opts>):\n";
+  print "     -e, --email <email>       -- email name\n";
+  print "     -h, --host <host>         -- DNS host name, or IP address\n";
+  print "     -d, --days <days>         -- number of days certificate is valid\n";
+  print "     -n, --cn <cn>             -- common name (CN)\n";
+  print "     -o, --org <org>           -- organiztion name\n";
+  print "     -u, --unit <unit>         -- organiztion unit name\n";
+  print "     -c, --country <country>   -- country code (e.g., US)\n";
+  print "     -p, --province <province> -- province name (synomynous w/ state)\n";
+  print "     -p, --state <state>       -- state name (synomynous w/ province)\n";
+  print "     -l, --locality <locality> -- locality name (e.g, town)\n";
+  print "     -s, --san <san>           -- subjectAltName, repeat for each <san>\n";
+  print "                               -- <san> value format (<FMT>:<VAL>):\n";
+  print "                               --   dirName:/usr/share/snmp/tls\n";
+  print "                               --   DNS:net-snmp.org\n";
+  print "                               --   email:admin\@net-snmp.org\n";
+  print "                               --   IP:192.168.1.1\n";
+  print "                               --   RID:1.1.3.6\n";
+  print "                               --   URI:http://net-snmp.org\n";
+  print "\n   FORMAT OPTIONS (<format-opts>): \n";
+  print "     --brief        -- minimized output (values only where applicable)\n";
+  print "     --text         -- full text description\n";
+  print "     --subject      -- subject description\n";
+  print "     --subject_hash -- hash of subject for indexing\n";
+  print "     --issuer       -- issuer description\n";
+  print "     --issuer_hash  -- hash of issuer for indexing\n";
+  print "     --fingerprint  -- SHA1 digest of DER\n";
+  print "     --serial       -- serial number\n";
+  print "     --modulus      -- modulus of the public key\n";
+  print "     --dates        -- start and end dates\n";
+  print "     --purpose      -- displays allowed uses\n";
+  print "     --C            -- C code description\n";
+  print "\n   EXAMPLES: \n";
+  print "     net-snmp-cert genca --cn ca-net-snmp.org --days 1000\n";
+  print "     net-snmp-cert genca -f .snmp/net-snmp-cert.conf -i nocadm -I\n";
+  print "     net-snmp-cert gencert -t snmpd --cn host.net-snmp.org\n";
+  print "     net-snmp-cert gencsr -t snmpapp\n";
+  print "     net-snmp-cert signcsr --csr snmpapp --with-ca ca-net-snmp.org\n";
+  print "     net-snmp-cert showcerts --subject --issuer --dates snmpapp\n";
+  print "     net-snmp-cert showcas --fingerprint ca-net-snmp.org --brief\n";
+  print "     net-snmp-cert import ca-third-party.crt\n";
+  print "     net-snmp-cert import signed-request.crt signed-request.key\n\n";
+
+  exit $ret;
+}
+
+sub set_default {
+  my $opts = shift;
+  my $config = shift;
+  my $field = shift;
+  my $val = shift;
+
+  if (not defined $opts->{$field}) {
+    my $cval = $config->inherit($field);
+    $opts->{$field} = (defined $cval ? $cval : $val);
+  }
+}
+
+sub cfg_path {
+  my $path;
+
+  $path = "/etc/snmp:/usr/share/snmp:/usr/lib/snmp:/var/lib/net-snmp";
+  return (wantarray ? split(':', $path) : $path);
+}
+
+sub find_cfgfile {
+  my $dir = shift;
+  my $file = shift;
+
+  if (defined $dir and -d $dir and 
+      defined $file and $file !~ /^[\.\/]/) {
+    return fq_rel_path("$dir/$file") if -f "$dir/$file";
+  }
+
+  if (defined $file) {
+    if (-f $file) {
+      return fq_rel_path($file);
+    } else {
+      return $file; # file is not found, complain later
+    }
+  }
+
+  my @path = cfg_path();
+  unshift(@path, $dir) if defined $dir;
+  while (@path) {
+    my $p = pop(@path);
+    next if $p eq '/var/lib/snmp';
+    if (-r "$p/$NetSNMP::Cert::CFGFILE") {
+      return fq_rel_path("$p/$NetSNMP::Cert::CFGFILE");
+    }
+  }
+
+  return $file;
+}
+
+sub find_cfgdir {
+  my $dir = shift;
+  my $file = shift;
+
+  if (defined $dir) {
+    $dir = NetSNMP::Cert::fq_rel_path($dir);
+    return $dir;
+  }
+
+  if (defined $file and -f $file) {
+    $dir = ::dirname($file);
+    return NetSNMP::Cert::fq_rel_path($dir);
+  } else {
+    my @path = cfg_path();
+    # search first for writeable tls dir
+    # for root search top down, for user bottom up
+    while (@path) {
+      $dir = ($> ? pop(@path): shift(@path));
+      next if $dir eq '/var/lib/snmp';
+      return $dir if -d "$dir/$NetSNMP::Cert::TLSDIR" and -w "$dir/$NetSNMP::Cert::TLSDIR";
+    }
+    @path = cfg_path();
+    # if no tls dir found, pick first writable config dir
+    # for root search top down, for user bottom up
+    while (@path) {
+      $dir = ($> ? pop(@path): shift(@path));
+      next if $dir eq '/var/lib/snmp';
+      return $dir if -d $dir and -w $dir;
+    }
+    my $home = $ENV{HOME} || die "Unable to determine home directory: set \$HOME\n";
+    return ($> ? "$home/.snmp" : "/usr/share/snmp"); # XXX hack - no dirs existed or were writable
+  }
+  # this should never happen
+  return undef;
+}
+
+sub find_certs {
+  my $opts = shift;
+  my $dir = shift || 'certs';
+  my $targ = shift;
+  my $suffix_regex;
+  my $cwd = ::getcwd();
+
+  if ($dir eq 'csrs') {
+    $dir = $NetSNMP::Cert::NEWCRTDIR;
+    $suffix_regex = '\.csr|\.pem';
+  } else {
+    $suffix_regex = '\.crt|\.pem';
+  }
+
+  NetSNMP::Cert::dprint("find_certs(1:$cwd):$dir:$targ:$suffix_regex\n", $opts);
+
+  if ($targ =~ /\.?\//) {
+    # see if targ could be file - calc orig. rel. path
+    my $arg = NetSNMP::Cert::fq_rel_path($targ, $opts->{'rdir'});
+    NetSNMP::Cert::dprint("find_certs(2):$dir:$targ:$arg\n", $opts);
+    # targ is a file name - use it
+    return (wantarray ? ($arg) : $arg) if -f $arg;
+    # else mark as dir if it is
+    $targ = "$arg" if -d $arg;
+  }
+
+  $targ =~ s/\/*$/\// if -d $targ;
+
+  NetSNMP::Cert::dprint("find_certs(3):$dir:$targ\n", $opts);
+
+  # find certs in targ if a dir (in tlsdir, or relative)
+  $dir = $1 if $targ =~ s/^(\S+)\/([^\/\s]*)$/$2/ and -d $1;
+
+  NetSNMP::Cert::dprint("find_certs(4):${dir}:$targ:$cwd\n", $opts);
+
+  my @certs;
+  my $glob = "$dir/$targ";
+  foreach (<$dir/*>) {
+    NetSNMP::Cert::dprint("checking($dir:$targ): $_\n", $opts);
+    next unless /^$dir\/$targ(.*$suffix_regex)?$/;
+    # return exact match if not wantarray()
+    return $_ if (not wantarray()) and /^$dir\/$targ($suffix_regex)?$/;
+    NetSNMP::Cert::dprint("pushing: $_\n", $opts);
+    push(@certs, $_);
+  }
+
+  return (wantarray ? @certs : $certs[0]);
+}
+
+sub check_output_file {
+  my $opts = shift;
+  my $file = shift;
+  my $interactive = shift;
+  my $force = shift;
+  my $continue = 1;
+
+  if (-w $file) {
+    if ($interactive and not $force) {
+      print "Output file ($file) exists; will be overwritten\nContinue [y/N]: ";
+      $continue = <STDIN>; chomp $continue;
+      $continue = 0 if $continue =~ /^\s*$|^no?\s*$/i;
+    } else {
+      if ($force) {
+	NetSNMP::Cert::vprint("Output file ($file) exists; overwriting...\n", $opts);
+      } else {
+	NetSNMP::Cert::vprint("Output file ($file) exists; exiting...\n", $opts);
+	$continue = 0;
+      }
+    }
+  } elsif (-e $file) {
+    NetSNMP::Cert::vprint("Output file ($file) not writable; exiting...\n", $opts);
+    $continue = 0;
+  }
+  exit(1) unless $continue;
+}
+
+sub is_server {
+  my $tag = shift;
+  return 1 if $tag eq 'snmpd' or $tag eq 'snmptrapd';
+  return 0;
+}
+
+sub is_ca_cert {
+  my $crt = shift;
+  my $output = `openssl x509 -in '$crt' -text -noout`;
+  return ($output =~ /^\s*CA:TRUE\s*$/m ? 1 : 0);
+}
+
+sub x509_format {
+  my $opts = shift;
+  my $fmt;
+
+  foreach my $f (@NetSNMP::Cert::X509FMTS) {
+    $fmt .= " -$f" if defined $opts->{$f};
+  }
+
+  return $fmt;
+}
+
+sub make_openssl_conf {
+  my $file = shift;
+  return if -r $file;
+
+  open(F, ">$file") or die("could not open $file");
+
+  print F <<'END';
+#
+# Net-SNMP (D)TLS OpenSSL configuration file.
+#
+
+rdir            = .
+dir		= $ENV::DIR
+RANDFILE	= $rdir/.rand
+MD		= sha1
+KSIZE		= 2048
+CN		= net-snmp.org
+EMAIL		= admin@net-snmp.org
+COUNTRY	        = US
+STATE		= CA
+LOCALITY	= Davis
+ORG		= Net-SNMP
+ORG_UNIT	= Development
+SAN             = email:copy
+DAYS            = 365
+CRLDAYS         = 30
+
+default_days	= $ENV::DAYS		# how long to certify for
+default_crl_days= $ENV::CRLDAYS		# how long before next CRL
+default_md	= $ENV::MD		# which md to use.
+
+database	= $dir/.index		# database index file.
+serial		= $dir/.serial 		# The current serial number
+certs		= $rdir/certs		# identity certs
+new_certs_dir	= $dir/newcerts	# default place for new certs.
+ca_certs_dir	= $rdir/ca-certs	# default place for new certs.
+key_dir		= $rdir/private
+
+crl_dir		= $dir/crl		# crl's
+crlnumber	= $dir/.crlnumber	# the current crl number
+					# must be commented out to leave V1 CRL
+crl		= $crl_dir/crl.pem	# The current CRL
+
+preserve	= no			# keep passed DN ordering
+unique_subject	= yes			# Set to 'no' to allow creation of
+					# certificates with same subject.
+# Extra OBJECT IDENTIFIER info:
+oid_section		= new_oids
+
+[ new_oids ]
+
+# Add new OIDs in here for use by 'ca' and 'req'.
+# Add a simple OID like this:
+# testoid1=1.2.3.4
+# Use config file substitution like this:
+# testoid2=${testoid1}.5.6
+
+####################################################################
+[ ca ]
+default_ca	= CA_default		# The default ca section
+
+####################################################################
+[ CA_default ]
+# certificate	= $ca_certs_dir/$ENV::TAG.crt 	# CA certificate so sign with
+name_opt 	= ca_default		# Subject Name options
+cert_opt 	= ca_default		# Certificate field options
+policy		= policy_match
+copy_extensions = copy                  # copy v3 extensions (subjectAltName)
+subjectAltName  = copy
+
+# For the CA policy
+[ policy_match ]
+countryName		= match
+stateOrProvinceName	= match
+organizationName	= match
+organizationalUnitName	= optional
+commonName		= supplied
+emailAddress		= optional
+
+# For the 'anything' policy
+# At this point in time, you must list all acceptable 'object'
+# types.
+[ policy_anything ]
+countryName		= optional
+stateOrProvinceName	= optional
+localityName		= optional
+organizationName	= optional
+organizationalUnitName	= optional
+commonName		= supplied
+emailAddress		= optional
+
+####################################################################
+[ req ]
+default_bits		= $ENV::KSIZE
+default_md		= $ENV::MD
+distinguished_name	= req_distinguished_name
+string_mask 		= MASK:0x2002
+req_extensions          = v3_req
+x509_extensions         = v3_user_create
+
+[ req_distinguished_name ]
+countryName			= Country Name (2 letter code)
+countryName_default		= $ENV::COUNTRY
+countryName_min			= 2
+countryName_max			= 2
+
+stateOrProvinceName		= State or Province Name (full name)
+stateOrProvinceName_default	= $ENV::STATE
+
+localityName			= Locality Name (eg, city)
+localityName_default		= $ENV::LOCALITY
+
+0.organizationName		= Organization Name (eg, company)
+0.organizationName_default	= $ENV::ORG
+
+organizationalUnitName		= Organizational Unit Name (eg, section)
+organizationalUnitName_default	= $ENV::ORG_UNIT
+
+commonName			= Common Name (eg, your name or your server\'s hostname)
+commonName_max			= 64
+commonName_default              = $ENV::CN
+
+emailAddress			= Email Address
+emailAddress_max		= 64
+emailAddress_default            = $ENV::EMAIL
+
+[ v3_req ]
+
+# Extensions to add to a certificate request
+basicConstraints = CA:FALSE
+
+# Import the email address and/or specified SANs.
+%[subjectAltName = $ENV::SAN]
+
+[ v3_user_create ]
+
+# Extensions to add to a certificate request
+basicConstraints = CA:FALSE
+#keyUsage = nonRepudiation, digitalSignature, keyEncipherment
+
+# PKIX recommendation.
+subjectKeyIdentifier = hash
+authorityKeyIdentifier = keyid:always,issuer:always
+
+# Import the email address and/or specified SANs.
+%[subjectAltName = $ENV::SAN]
+
+[ v3_ca_create ]
+# Extensions to add to a CA certificate
+basicConstraints = CA:TRUE
+# This will be displayed in Netscape's comment listbox.
+nsComment = "OpenSSL Generated Certificate (net-snmp)"
+
+# PKIX recommendation.
+subjectKeyIdentifier = hash
+authorityKeyIdentifier = keyid:always,issuer:always
+
+# Import the email address and/or specified SANs.
+%[subjectAltName = $ENV::SAN]
+
+[ v3_ca_sign ]
+# Extensions to add when 'ca' signs a request.
+basicConstraints = CA:FALSE
+# This will be displayed in Netscape's comment listbox.
+nsComment = "OpenSSL Generated Certificate (net-snmp)"
+
+keyUsage = nonRepudiation, digitalSignature, keyEncipherment
+
+# PKIX recommendations harmless if included in all certificates.
+subjectKeyIdentifier = hash
+authorityKeyIdentifier = keyid:always,issuer:always
+
+[ v3_ca_sign_ca ]
+# Extensions to add when 'ca' signs a ca request.
+basicConstraints = CA:TRUE
+
+# This will be displayed in Netscape's comment listbox.
+nsComment = "OpenSSL Generated Certificate (net-snmp)"
+
+# PKIX recommendations harmless if included in all certificates.
+subjectKeyIdentifier = hash
+authorityKeyIdentifier = keyid:always,issuer:always
+
+END
+
+}
+
+
+package NetSNMP::Cert::Obj;
+
+sub new {
+  my $class = shift;
+  my $cfield = shift;
+  my $parent = shift;
+  my $ind = shift;
+  my $this = {};
+  bless($this, $class);
+
+  # initialize hash of keys which are dynamically created or internal
+  $this->{'AUTOKEYS'}{'AUTOKEYS'}++;
+
+  # store a reference to ourselves so our children can find us
+  $this->autoSet('CFIELD', $cfield);
+  $this->autoSet($cfield , $this);
+  $this->autoSet('CHILDREN', []);
+  $this->autoSet('INDEX', $ind) if defined $ind;
+
+  if (defined $parent) {
+    # cache 'APP' in all objs for easy reference
+    $this->autoSet('APP', $parent->inherit('APP'));
+    my $app = $this->{'APP'};
+
+    die("net-snmp-cert: error: no NetSNMP::Cert::App context provided")
+      if not defined $app or not ref $app eq 'NetSNMP::Cert::App';
+    # save children for list traversal
+    push(@{$parent->{'CHILDREN'}}, $this) unless $parent eq $this;
+  } else {
+    # we are the top of the list
+    $parent = $this;
+  }
+  $this->autoSet('PARENT' , $parent);
+
+  return $this;
+}
+
+sub autoSet {
+  my $this = shift;
+  my $key = shift;
+  if (@_) {
+    my $val = shift;
+    $this->{'AUTOKEYS'}{$key}++;
+    $this->{$key} = $val;
+  }
+  return exists $this->{'AUTOKEYS'}{$key};
+}
+
+sub inherit {
+  my $this = shift;
+  my $field = shift;
+  my $id;
+
+  # cmd opts override config settings
+  if (exists $this->{'APP'} and exists $this->{'APP'}{'OPTS'}) {
+    my $opts = $this->{'APP'}{'OPTS'};
+    $id = $opts->{'identity'};
+    return $opts->{$field} if defined $opts->{$field};
+  }
+
+  if (defined $id and exists $this->{'identity'} and
+      exists $this->{'identity'}{$id} and
+      exists $this->{'identity'}{$id}{$field}) {
+    return $this->{'identity'}{$id}{$field};
+  }
+
+  # return our field if we have it
+  return $this->{$field} if defined $this->{$field};
+
+  # terminate recursion at top and return undef if not found
+  return undef if not defined $this->{'PARENT'} or $this->{'PARENT'} eq $this;
+
+  # recurse to parent
+  $this->{'PARENT'}->inherit($field);
+}
+
+sub resolve {
+  my $this = shift;
+  my $opts = $this->inherit('OPTS');
+  my $val = shift;
+
+  NetSNMP::Cert::dprint("resolving: $val\n", $opts);
+
+  $val =~ s/(\$(\w+))/$this->inherit($2) or die("unresolved reference in config: $1")/ge;
+  $val =~ s/(\&\{(.*?)\})/$2/gee;
+
+  NetSNMP::Cert::dprint("resolved: $val\n", $opts);
+
+  return $val
+}
+
+sub delete {
+  my $this = shift;
+  my $opts = $this->inherit('OPTS');
+
+  NetSNMP::Cert::dprint("Obj::delete: ($this) [$this->{CFIELD}]\n", $opts);
+
+  my $parent = $this->{'PARENT'};
+  my @children = @{$this->{'CHILDREN'}};
+
+  foreach my $child (@children) {
+    $child->delete();
+  }
+
+  NetSNMP::Cert::dwarn("Obj: children not freed\n", $opts) if @{$this->{'CHILDREN'}};
+
+  # delete all our self-references
+  delete($this->{$this->{'CFIELD'}}) if exists $this->{'CFIELD'};
+  delete($this->{'PARENT'});
+  delete($this->{'CHILDREN'});
+
+  $parent->disown($this) if defined $parent and ref($parent) =~ /NetSNMP::Cert/;
+}
+
+sub disown {
+  my $this = shift;
+  my $thechild = shift;
+  my $opts = $this->inherit('OPTS');
+  my $ind = 0;
+
+  NetSNMP::Cert::dprint("Obj::disown: ($this) [$this->{CFIELD}] disowning ($thechild) [$thechild->{CFIELD}]\n", $opts);
+
+  foreach my $child (@{$this->{'CHILDREN'}}) {
+    last if $child eq $thechild;
+    $ind++;
+  }
+  if ($ind < @{$this->{'CHILDREN'}}) {
+    splice(@{$this->{'CHILDREN'}}, $ind, 1);
+  } else {
+    NetSNMP::Cert::dwarn("Child ($thechild) not found in object ($this)\n", $opts);
+  }
+}
+
+sub disabled {
+  my $this = shift;
+  return (exists $this->{'disable'} ? $this->{'disable'} : 0);
+}
+
+my %cfg = (
+	   'name' => 1,
+	   'type' => 2,
+	   'id' => 6,
+	  );
+
+sub cfgsort {
+  my $self = shift;
+  my $a = shift;
+  my $b = shift;
+  return -1 if exists $cfg{$a} and not exists $cfg{$b};
+  return 1 if exists $cfg{$b} and not exists $cfg{$a};
+  return $cfg{$a} <=> $cfg{$b} if exists $cfg{$a} and exists $cfg{$b};
+  return -1 if !ref($self->{$a}) and ref($self->{$b});
+  return 1 if !ref($self->{$b}) and ref($self->{$a});
+  return -1 if ref($self->{$a}) =~ /NetSNMP::Cert/ and ref($self->{$b}) !~ /NetSNMP::Cert/;
+  return 1 if ref($self->{$b}) =~ /NetSNMP::Cert/ and ref($self->{$a}) !~ /NetSNMP::Cert/;
+  return 0;
+}
+
+sub dump {
+  my $self = shift;
+  my $indent = shift;
+  my $self_str = $self->{'CFIELD'};
+  my @data_keys =  grep {!$self->autoSet($_)} keys %$self;
+  my @lines;
+
+  push(@lines, "\n" . ' ' x $indent . "$self_str = {\n") if defined $indent;
+
+  {
+    my $indent = (defined $indent ? $indent + 3 : 0);
+    foreach my $key (sort {cfgsort($self,$NetSNMP::Cert::Obj::a,
+				   $NetSNMP::Cert::Obj::b)} (sort @data_keys)) {
+      if (ref($self->{$key}) =~ /NetSNMP::Cert/) {
+	push(@lines, $self->{$key}->dump($indent));
+      } elsif (ref($self->{$key}) =~ /ARRAY/) {
+	push(@lines, "\n") if ref(${$self->{$key}}[0]) !~ /NetSNMP::Cert/;
+	foreach my $elem (@{$self->{$key}}) {
+	  if (ref($elem) =~ /NetSNMP::Cert/) {
+	    push(@lines, $elem->dump($indent));
+	  } else {
+	    push(@lines, ' ' x $indent . "$key = $elem\n");
+	  }
+	}
+      } else {
+	my $str = $key . (defined $self->{$key} ? " = $self->{$key}\n" : "\n");
+	push(@lines, ' ' x $indent . $str);
+      }
+    }
+  }
+
+  push(@lines, ' ' x $indent . "}; # end $self_str\n") if defined $indent;
+  return @lines;
+}
+
+sub DESTROY {
+  my $this = shift;
+
+  print("Obj::DESTROY $this [", ref $this, "]\n") if $NetSNMP::Cert::DEBUG >= 3;
+}
+
+package NetSNMP::Cert::App;
+use vars qw(@ISA);
+
+@ISA = qw(NetSNMP::Cert::Obj);
+
+sub new {
+  my $class = shift;
+
+  # the app is god, it is its own parent
+  my $this = $class->SUPER::new('APP');
+
+  bless($this, $class);
+
+  # verify required tools or die
+  $this->checkReqs();
+
+  # internal intitialization
+  $this->initOpts();
+
+  # make a new empty config and init (not parsed)
+  $this->{'config'} = new NetSNMP::Cert::Config($this);
+
+  return $this;
+}
+
+sub checkReqs {
+  my $app = shift;
+
+  die("$NetSNMP::Cert::OPENSSL does not exist or is not executable")
+    if system("$NetSNMP::Cert::OPENSSL version > /dev/null 2>&1");
+
+  my $ossl_ver = `$NetSNMP::Cert::OPENSSL version`; chomp $ossl_ver;
+  $ossl_ver =~ s/^OpenSSL\s+([\d\.]+).*$/$1/;
+  my $ossl_min_ver = $NetSNMP::Cert::OPENSSL_MIN_VER;
+
+  die("$NetSNMP::Cert::OPENSSL (v$ossl_ver): must be $ossl_min_ver or later")
+    if ($ossl_ver cmp $ossl_min_ver) < 0;
+
+#  die("$NetSNMP::Cert::CFGTOOL not found: please install")
+#    if system("$NetSNMP::Cert::CFGTOOL > /dev/null 2>&1");
+}
+
+sub initOpts {
+  my $app = shift;
+  my $opts = {};
+  $app->autoSet('OPTS', $opts);
+
+  # Define directories we need.
+  $opts->{'bindir'} = NetSNMP::Cert::find_bin_dir();
+
+  $opts->{'out'} = "> $NetSNMP::Cert::OUTLOG";
+  $opts->{'err'} = "2> $NetSNMP::Cert::ERRLOG";
+
+  # set up paths for app install and runtime env
+  $ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}";
+  $ENV{PATH} = "$opts->{'bindir'}:$ENV{PATH}";
+
+  # default all privs to -rw-------
+  umask(077);
+}
+
+sub init {
+  my $app = shift;
+  my $opts = $app->{'OPTS'};
+  my $config = $app->{'config'};
+  my @args = @_;   # pass external args (typically ARGV)
+
+  # parse command line
+  $app->parseArgs(@args);
+
+  # lazy config parsing postponed until here, will not reparse
+  $config->parse();
+
+  # set defaults here if not already set in cmdline or config
+  # guided interactive mode by default
+  NetSNMP::Cert::set_default($opts, $config, 'interactive', 1);
+  # verbose output
+  NetSNMP::Cert::set_default($opts, $config, 'verbose', 1);
+
+  # find tlsdir/subdirs or make it
+  $opts->{'tlsdir'} = $app->createTlsDir();
+}
+
+sub parseArgs {
+  my $app = shift;
+  my $opts = $app->{'OPTS'};
+  my @args = @_;
+
+  NetSNMP::Cert::GetOptsFromArray(\@args, $opts, 'help|?', 'version|V',
+		      'interactive!', 'I', 'verbose!', 'Q', 'force|F',
+		      'cfgfile|f=s', 'cfgdir|C=s', 'tlsdir|tlsDir|T=s',
+		      'tag|t=s', 'identity|i=s', 'debug|D+',);
+
+  NetSNMP::Cert::version(0) if $opts->{'version'};
+
+  NetSNMP::Cert::usage(0) if $opts->{'help'};
+
+  # pull out the cmd - getOpts should leave it untouched for us
+  $opts->{'cmd'} = NetSNMP::Cert::pull_cmd(\@args);
+
+  # save extra args for command specific processing
+  $opts->{'cmdargs'} = [@args];
+
+  # Check debug option first
+  $NetSNMP::Cert::DEBUG = $opts->{'debug'};
+  $opts->{'err'} = $opts->{'out'} = "" if $opts->{'debug'};
+  $opts->{'interactive'} = not $opts->{'I'} if defined $opts->{'I'};
+  $opts->{'verbose'} = not $opts->{'Q'} if defined $opts->{'Q'};
+
+  # search for cfgdir and cfgfile based on opts and confpath
+  $opts->{'cfgdir'} = NetSNMP::Cert::find_cfgdir($opts->{'cfgdir'},
+						 $opts->{'cfgfile'});
+  $opts->{'cfgfile'} = NetSNMP::Cert::find_cfgfile($opts->{'cfgdir'},
+						   $opts->{'cfgfile'});
+}
+
+sub createTlsDir {
+  my $app = shift;
+  my $opts = $app->{'OPTS'};
+  my $config = $app->{'config'};
+  my $dir;
+  my $file;
+  my $cmd;
+
+  $dir = $config->inherit('tlsDir');
+
+  if (not defined $dir) {
+    my $cfgdir = $opts->{'cfgdir'};
+    die("undefined cfgdir: unable to creat tlsdir: exiting...\n") unless defined $cfgdir;
+    $dir = "$cfgdir/$NetSNMP::Cert::TLSDIR";
+  }
+
+  NetSNMP::Cert::dprint("tlsDir is: $dir\n", $opts);
+  $dir = NetSNMP::Cert::fq_rel_path($dir);
+  NetSNMP::Cert::dprint("tlsDir is: $dir\n", $opts);
+
+  NetSNMP::Cert::dprint("tlsDir not found, creating\n", $opts) unless -d $dir;
+  NetSNMP::Cert::make_dirs($opts, $dir, 0700, @NetSNMP::Cert::TLSDIRS);
+
+  my $ssl_cfg_in = NetSNMP::Cert::fq_rel_path($NetSNMP::Cert::SSLCFGIN,$dir);
+
+  # Existing openssl.conf tmpl will be preserved
+  if (-f $ssl_cfg_in) {
+    NetSNMP::Cert::dwarn("OpenSSL template exists ($ssl_cfg_in): preserving...", $opts);
+  }
+
+  if (not -f $ssl_cfg_in) {
+    NetSNMP::Cert::dprint("make_openssl_conf($ssl_cfg_in)", $opts);
+    NetSNMP::Cert::make_openssl_conf($ssl_cfg_in);
+    chmod(0600, $ssl_cfg_in);
+  }
+
+  NetSNMP::Cert::dprint("createTlsDir: done\n", $opts);
+  return $dir;
+}
+
+my @interactive_ops = (['gencert', "Generate a signed certificate"],
+	   ['genca', "Generate a CA certificate"],
+	   ['gencsr', "Generate a Certificate Signing Request"],
+	   ['signcsr', "Sign a Certificate Signing Request"],
+	  );
+
+sub run {
+  my $app = shift;
+  my $opts = $app->{'OPTS'};
+  my $cmd = $opts->{'cmd'};
+
+  # must have a command in non-Interactive mode
+  NetSNMP::Cert::usage(3) if !$opts->{'interactive'} and !$opts->{'cmd'};
+
+  #  change dir tls dir - the cwd for all commands - save cwd first
+  $opts->{'rdir'} = ::getcwd();
+  chdir($opts->{'tlsdir'}) or die("could'nt change directory: $opts->{tlsdir}");
+  # display context
+  NetSNMP::Cert::dprint("PATH: $ENV{PATH}\n\n", $opts);
+  NetSNMP::Cert::dprint("config file: $opts->{cfgfile}\n", $opts);
+  NetSNMP::Cert::dprint("config dir:  $opts->{cfgdir}\n", $opts);
+  NetSNMP::Cert::dprint("tls dir:     $opts->{tlsdir}\n", $opts);
+
+  my $cmdstr = join(' ', $cmd, @{$opts->{'cmdargs'}});
+  NetSNMP::Cert::dprint("command:     $cmdstr\n", $opts);
+
+  NetSNMP::Cert::GetOptsFromArray(\@{$opts->{'cmdargs'}}, $opts,
+				  'with-ca|a=s', 'ca|A=s','csr|r=s',
+				  'from-crt|x=s', 'crt|X=s', 'days|d=s',
+				  'cn|n=s', 'email|e=s', 'host|h=s',
+				  'san|s=s@', 'org|o=s', 'unit|u=s',
+				  'country|c=s', 'state|province|p=s',
+				  'locality|l=s', 'brief|b',
+				  @NetSNMP::Cert::X509FMTS);
+
+  # process extra args; --<cfg-name>[=<val>]
+  $app->processExtraArgs();
+
+  # If in interactive mode - fill missing info by interviewing user
+  if (not defined $cmd or grep {/$cmd/} map {$_->[0]} @interactive_ops) {
+    $app->userInput() if $opts->{interactive};
+    $cmd = $opts->{'cmd'}; # may have changed
+  }
+
+  # resolve input args to filenames
+  $app->resolveCrtArgs();
+
+  # use env. or merge template for OpenSSL config
+  $NetSNMP::Cert::SSLCFG ||= $app->opensslCfg();
+
+  if ($cmd =~ /^genca$/) {
+    NetSNMP::Cert::usage(1) if defined $opts->{'from-crt'} or defined $opts->{'csr'};
+    $app->genCa($opts->{'with-ca'});
+  } elsif ($cmd =~ /^gence?rt$/) {
+    NetSNMP::Cert::usage(1) if defined $opts->{'from-crt'} or defined $opts->{'csr'};
+    $app->genCert($opts->{'with-ca'});
+  } elsif ($cmd =~ /^gencsr$/) {
+    NetSNMP::Cert::usage(1) if defined $opts->{'with-ca'} or defined $opts->{'crt'};
+    $app->genCsr();
+  } elsif ($cmd =~ /^signcsr$/) {
+    NetSNMP::Cert::usage(1) unless defined $opts->{'with-ca'} and defined $opts->{'csr'};
+    $app->signCsr();
+  } elsif ($cmd =~ /^show(ce?rts?)?$/) {
+    $app->show('certs');
+  } elsif ($cmd =~ /^showcas?$/) {
+    $app->show('ca-certs');
+  } elsif ($cmd =~ /^import$/) {
+    $app->import();
+  } else {
+    NetSNMP::Cert::usage();
+  }
+}
+
+sub processExtraArgs {
+  my $app = shift;
+  my $opts = $app->{'OPTS'};
+  my @args;
+
+  NetSNMP::Cert::dprint("processing extra args...\n", $opts);
+
+  while (@{$opts->{'cmdargs'}}) {
+    my $arg = shift(@{$opts->{'cmdargs'}});
+    NetSNMP::Cert::dprint("found: arg --> $arg\n", $opts);
+    if ($arg =~ /^-+(\w+)(?:=(.*?))?\s*$/) {
+      NetSNMP::Cert::dprint("found: arg($1) val($2)\n", $opts);
+      if (exists $opts->{$1}) {
+   	NetSNMP::Cert::vwarn("option ($1) already set: overwriting\n", $opts);
+      } 
+      $opts->{$1} = (defined $2 ? $2 : 1);
+    } else {
+      push(@args, $arg);
+    }
+  }
+  @{$opts->{'cmdargs'}} = @args;
+}
+
+sub resolveCrtArgs {
+  my $app = shift;
+  my $opts = $app->{'OPTS'};
+
+  # find ca, crt, csr args if present and return fully qualified path
+  if (defined $opts->{'with-ca'}) {
+    my $ca;
+    $ca = NetSNMP::Cert::find_certs($opts, 'ca-certs', $opts->{'with-ca'});
+    die("unable to locate CA certificate ($opts->{'with-ca'})\n") unless -e $ca;
+    die("unable read CA certificate ($opts->{'with-ca'})\n") unless -r $ca;
+    $opts->{'with-ca'} = $ca;
+  }
+
+  if (defined $opts->{'from-crt'}) {
+    my $crt;
+    $crt = NetSNMP::Cert::find_certs($opts, 'certs', $opts->{'from-crt'});
+    die("unable to locate certificate ($opts->{'from-crt'})\n") unless -e $crt;
+    die("unable read certificate ($opts->{'from-crt'})\n") unless -r $crt;
+    $opts->{'from-crt'} = $crt;
+  }
+
+  if (defined $opts->{'csr'}) {
+    my $csr;
+    $csr = NetSNMP::Cert::find_certs($opts, 'csrs', $opts->{'csr'});
+    die("unable to locate CSR certificate ($opts->{csr})\n") unless -e $csr;
+    die("unable read CSR certificate ($opts->{csr})\n") unless -r $csr;
+    $opts->{'csr'} = $csr;
+  }
+}
+
+sub opensslCfg {
+  my $app = shift;
+  my $config = $app->{'config'};
+  my $opts = $app->{'OPTS'};
+  my $san = $config->inherit('san') || $config->inherit('subjectAltName');
+  my $ssl_cfg_in = NetSNMP::Cert::fq_rel_path($NetSNMP::Cert::SSLCFGIN);
+  my $ssl_cfg_out = NetSNMP::Cert::fq_rel_path($NetSNMP::Cert::SSLCFGOUT);
+
+  if (not -f $ssl_cfg_in) {
+    NetSNMP::Cert::vwarn("OpenSSL template not found: $ssl_cfg_in\n", $opts);
+    die("no OpenSSL template");
+  }
+
+  open(IN, $ssl_cfg_in) or die("unable to open OpenSSL template: $ssl_cfg_in\n");
+  open(OUT, ">$ssl_cfg_out") or die("unable to open OpenSSL config: $ssl_cfg_out\n");
+
+  print OUT "#######################################################\n";
+  print OUT "#####    Warning: Do Not Edit - Generated File    #####\n";
+  print OUT "#######################################################\n";
+  while (<IN>) {
+    if ($san) {
+      s/\%\[([^\]]*?)\]/$1/;
+    } else {
+      s/\%\[([^\]]*?)\]//;
+    }
+    print OUT $_;
+  }
+  close(IN);
+  close(OUT);
+
+  return $ssl_cfg_out;
+}
+
+sub opensslEnv {
+  my $app = shift;
+  my $config = $app->{'config'};
+  my $opts = $app->{'OPTS'};
+
+  my $cn = shift;
+  my $days = shift;
+  my $dir = shift || ".";
+  # XXX - need to handle config'd identity here
+  my $name = $config->inherit("name");
+  my $host = $config->inherit("host");
+  my $email = $config->inherit("email");
+  my $country = $config->inherit("country");
+  my $state = $config->inherit("state");
+  my $locality = $config->inherit("locality");
+  my $org = $config->inherit("org");
+  my $org_unit = $config->inherit("unit") || $config->inherit("orgUnit");
+  my $san;
+  my $san_arr_ref;
+  my $md = $config->inherit("msgDigest");
+  my $ksize = $config->inherit("keySize");
+
+  my $env;
+
+  $env .= " KSIZE=$ksize" if defined $ksize;
+  $env .= " DAYS=$days" if defined $days;
+  $env .= " MD=$md" if defined $md;
+
+  $env .= " DIR='$dir'" if defined $dir;
+
+  $env .= " EMAIL=$email" if defined $email;
+  $env .= " CN='$cn'" if defined $cn;
+  $env .= " ORG='$org'" if defined $org;
+  $env .= " ORG_UNIT='$org_unit'" if defined $org_unit;
+  $env .= " COUNTRY=$country" if defined $country;
+  $env .= " STATE=$state" if defined $state;
+  $env .= " LOCALITY=$locality" if defined $locality;
+
+  $san_arr_ref = $config->inherit('subjectAltName');
+  $san = join('\,\ ', @{$san_arr_ref}) if ref $san_arr_ref;
+  $san_arr_ref = $config->inherit('san');
+  $san .= join('\,\ ', @{$san_arr_ref}) if ref $san_arr_ref;
+  $san =~ s/EMAIL:/email:/g;
+  $env .= " SAN=$san" if defined $san;
+
+  NetSNMP::Cert::dprint("opensslEnv: $env\n", $opts);
+
+  return $env;
+}
+our @san_prefix = (['dirName:', "e.g., dirName:/usr/share/snmp/tls"],
+		   ['DNS:', "e.g., DNS:test.net-snmp.org)"],
+		   ['email:', "e.g., email:admin\@net-snmp.org"],
+		   ['IP:', "e.g., IP:192.168.1.1"],
+		   ['RID:', "e.g., RID:1.1.3.6.20"],
+		   ['URI:', "e.g., URI:http://www.net-snmp.org"]);
+
+sub userInputDN {
+  my $app = shift;
+  my $config = $app->{'config'};
+  my $opts = $app->{'OPTS'};
+  my $prompt;
+  my $ret;
+  my $host = $config->inherit("host") || ::hostname();
+  my $email = $config->inherit('email') || getlogin() . "\@$host";
+
+ # get EMAIL
+  $prompt = "Enter Email";
+  $ret = $email;
+  $prompt .= (defined $ret ? " [$ret]: " : ": ");
+  $ret = NetSNMP::Term::Complete($prompt, $ret,
+				 "\tEmail Address - (e.g., <name>@<domain>)");
+  $email = $opts->{'email'} = $ret if defined $ret;
+  # get CN
+  $prompt = "Enter Common Name";
+  $ret = ($opts->{'cmd'} eq 'genca' ? "ca-$host" : $email);
+  $ret = $config->inherit('cn') || $config->inherit('commonName') || $ret;
+  $prompt .= (defined $ret ? " [$ret]: " : ": ");
+  $ret = NetSNMP::Term::Complete($prompt, $ret,
+				 "\tCommon Name - (e.g., net-snmp.org)");
+  $opts->{'cn'} = $ret if defined $ret;
+  # get ORG
+  $prompt = "Enter Organization";
+  $ret = $config->inherit('org') || 'Net-SNMP';
+  $prompt .= (defined $ret ? " [$ret]: " : ": ");
+  $ret = NetSNMP::Term::Complete($prompt, $ret,
+				 "\tOrganization - (e.g., Net-SNMP)");
+  $opts->{'org'} = $ret if defined $ret;
+  # get ORG_UNIT
+  $prompt = "Enter Organizational Unit";
+  $ret = $config->inherit('unit') || 'Development';
+  $prompt .= (defined $ret ? " [$ret]: " : ": ");
+  $ret = NetSNMP::Term::Complete($prompt, $ret,
+				 "\tOrganizational Unit - (e.g., Development)");
+  $opts->{'unit'} = $ret if defined $ret;
+  # get COUNTRY
+  $prompt = "Enter Country Code";
+  $ret = $config->inherit('country') || 'US';
+  $prompt .= (defined $ret ? " [$ret]: " : ": ");
+  $ret = NetSNMP::Term::Complete($prompt, $ret,
+				 "Country Code, 2 letters (<tab> for options)",
+				 $NetSNMP::Cert::MATCH, \@CC);
+  $opts->{'country'} = $ret if defined $ret;
+  # get STATE(Province)
+  $prompt = "Enter State or Province";
+  $ret = $config->inherit('state') || 'CA';
+  $prompt .= (defined $ret ? " [$ret]: " : ": ");
+  $ret = NetSNMP::Term::Complete($prompt, $ret,
+				 "\tState or Province - (e.g., CA)");
+  $opts->{'state'} = $ret if defined $ret;
+  # get LOCALITY
+  $prompt = "Enter Locality";
+  $ret = $config->inherit('locality') || 'Davis';
+  $prompt .= (defined $ret ? " [$ret]: " : ": ");
+  $ret = NetSNMP::Term::Complete($prompt, $ret, "\tLocality - (e.g., Davis)");
+  $opts->{'locality'} = $ret if defined $ret;
+  # get SAN (loop)
+  if (!$config->{'brief'}) {
+      print "Enter Subject Alt Names.  Examples:\n";
+      foreach my $pair (@san_prefix) {
+	  printf("\t%-10.10s %s\n", $pair->[0], $pair->[1]);
+      }
+  }
+  do {
+    $ret = 'done';
+    $prompt = "Enter Subject Alt Name (enter 'done' when finished) [$ret]: ";
+    $ret = NetSNMP::Term::Complete ($prompt, $ret,
+			    "\tSubject Alt Name - (<type>:<val>)",
+			     $NetSNMP::Cert::PREMATCH, \@san_prefix);
+    push(@{$opts->{'san'}}, $ret) if defined $ret and $ret ne 'done';
+  } while (defined $ret and $ret ne 'done');
+}
+
+our @snmp_apps = (['snmp', 'Generic Certificate'],
+		  ['snmpapp','Client Certificate'],
+		  ['snmpd','Agent Certificate'],
+		  ['snmptrapd','Trap-agent Certificate']);
+
+sub userInputTag {
+  my $app = shift;
+  my $config = $app->{'config'};
+  my $opts = $app->{'OPTS'};
+  my $ret;
+  my $prompt;
+
+  print "Application Tag:\n\tused to name the certificate and dictate its filename\n";
+  print "\tIt may also associate it with a particular application (eg \"snmpd\")\n";
+  print "\tif 'none', a name will be generated from other parameters\n";
+  print "\tenter <tab><tab> for typical options, or enter new name\n";
+  $prompt = "Enter Application Tag";
+  $ret = $config->inherit('tag') || 'none';
+  $prompt .= (defined $ret ? " [$ret]: " : ": ");
+  $ret = NetSNMP::Term::Complete($prompt, $ret,
+				 "Application Tag assocaiated with certificate",
+				 (not $NetSNMP::Cert::MATCH), \@snmp_apps);
+  $opts->{'tag'} = $ret if defined $ret and $ret ne 'none';
+}
+
+sub userInput {
+  my $app = shift;
+  my $config = $app->{'config'};
+  my $opts = $app->{'OPTS'};
+  my $prompt;
+  my $ret;
+
+  print "Choose an operation:\n";
+  foreach my $op (@interactive_ops) {
+    print "\t$op->[0]\t-  $op->[1]\n";
+  }
+
+  $prompt = "Operation";
+  $ret = $config->inherit('cmd') || $interactive_ops[0][0];
+  $prompt .= (defined $ret ? " [$ret]: " : ": ");
+  $ret = NetSNMP::Term::Complete($prompt, $ret,
+				 "Certifciate Operation to perform",
+				 $NetSNMP::Cert::MATCH, \@interactive_ops);
+
+  $opts->{'cmd'} = $ret;
+
+  if ($ret =~ /^gencert$/) {
+    # get tag
+    $app->userInputTag();
+    # get DN
+    $app->userInputDN();
+    # self-signed/CA-signed(ca-cert)
+  } elsif ($ret =~ /^genca$/) {
+    # get DN
+    $app->userInputDN();
+  } elsif ($ret =~ /^gencsr$/) {
+    # get tag
+    $app->userInputTag();
+    # get DN
+    $app->userInputDN();
+  } elsif ($ret =~ /^signcsr$/) {
+    # get csr
+    $prompt = "Choose Certificate Signing Request";
+    $ret = $config->inherit('csr');
+    $prompt .= (defined $ret ? " [$ret]: " : ": ");
+    $ret = NetSNMP::Term::Complete($prompt, $ret);
+    $opts->{'csr'} = $ret if defined $ret;
+    # get ca
+    $prompt = "Choose CA Certificate";
+    $ret = $config->inherit('with-ca');
+    $prompt .= (defined $ret ? " [$ret]: " : ": ");
+    $ret = NetSNMP::Term::Complete($prompt, $ret);
+    $opts->{'with-ca'} = $ret if defined $ret;
+  } else {
+    NetSNMP::Cert::vwarn("aborting operation: exiting...\n", $opts);
+    exit(1);
+  }
+}
+
+sub createCaDir {
+  my $app = shift;
+  my $dir = shift;
+  my $config = $app->{'config'};
+  my $opts = $app->{'OPTS'};
+  my $file;
+  my $cmd;
+
+  NetSNMP::Cert::make_dirs($opts, $dir, 0700,'newcerts','private');
+
+  $file = "$dir/$NetSNMP::Cert::SERIAL";
+  if (not -f $file) {
+    $cmd = "echo '01' > '$file'";
+    NetSNMP::Cert::dprint("$cmd\n", $opts);
+    NetSNMP::Cert::usystem($cmd, $opts);
+    chmod(0600, $file);
+  }
+
+  $file = "$dir/$NetSNMP::Cert::INDEX";
+  if (not -f $file) {
+    $cmd = "touch '$file'";
+    NetSNMP::Cert::dprint("$cmd\n", $opts);
+    NetSNMP::Cert::usystem($cmd, $opts);
+    chmod(0600, $file);
+  }
+}
+
+sub genCa {
+  my $app = shift;
+  my $config = $app->{'config'};
+  my $opts = $app->{'OPTS'};
+  my $host = $config->inherit('host') || ::hostname();
+  my $days = $config->inherit('days') || $config->inherit('caDays') || 
+             $NetSNMP::Cert::DEFCADAYS;
+  my $cn = $config->inherit('cn') || $config->inherit('commonName') ||
+           "ca-$host";
+  my $ca = $config->inherit('with-ca');
+  my $tag = $config->inherit('tag') || $cn;
+
+  # create CA dir
+  my $dir = ".ca/$tag";
+  $app->createCaDir($dir);
+
+  my $outCrt = "$NetSNMP::Cert::CADIR/$tag.crt";
+  my $outKey = "$NetSNMP::Cert::PRIVDIR/$tag.key";
+
+  # set command env
+  my $env = $app->opensslEnv($cn, $days);
+
+  NetSNMP::Cert::check_output_file($opts, $outCrt,
+				   $config->inherit('interactive'),
+				   $config->inherit('force'));
+  NetSNMP::Cert::check_output_file($opts, $outKey,
+				   $config->inherit('interactive'),
+				   $config->inherit('force'));
+
+  my $cmd = "$env openssl req -extensions v3_ca_create -new -days $days -batch -config $NetSNMP::Cert::SSLCFG -keyout '$outKey'";
+  $cmd .= " -nodes";
+
+  if (defined $ca) {
+    # we have to gen a csr and then sign it, must preserve CA:TRUE
+    my $outCsr = "$NetSNMP::Cert::NEWCRTDIR/$tag.csr";
+    NetSNMP::Cert::check_output_file($opts, $outCsr,
+				   $config->inherit('interactive'),
+				   $config->inherit('force'));
+    $cmd .= " -out '$outCsr'";
+
+    NetSNMP::Cert::dprint("genCa (gencsr): $cmd\n", $opts);
+    NetSNMP::Cert::usystem("$cmd $opts->{out} $opts->{err}", $opts);
+
+    my $ca_base = ::basename($ca, @NetSNMP::Cert::CRTSUFFIXES);
+    NetSNMP::Cert::dprint("ca_base: $ca_base\n", $opts);
+
+    # set command env
+    $env = $app->opensslEnv($cn, $days, ".ca/$ca_base");
+
+    $cmd = "$env openssl ca -extensions v3_ca_sign_ca -days $days -cert '$ca' -keyfile '$NetSNMP::Cert::PRIVDIR/$ca_base.key' -in '$outCsr' -batch -config $NetSNMP::Cert::SSLCFG -out '$outCrt'";
+
+    NetSNMP::Cert::dprint("genCa (signcsr): $cmd\n", $opts);
+    NetSNMP::Cert::usystem("$cmd $opts->{out} $opts->{err}", $opts);
+  } else {
+    $cmd .= " -x509 -out '$outCrt'";
+
+    NetSNMP::Cert::dprint("genCa: $cmd\n", $opts);
+    NetSNMP::Cert::usystem("$cmd $opts->{out} $opts->{err}", $opts);
+  }
+
+  NetSNMP::Cert::vprint("CA Generated:\n", $opts);
+  NetSNMP::Cert::vprint("  $outCrt\n", $opts);
+  NetSNMP::Cert::vprint("  $outKey\n", $opts);
+}
+
+sub genCert {
+  my $app = shift;
+  my $config = $app->{'config'};
+  my $opts = $app->{'OPTS'};
+  my $host = $config->inherit("host") || ::hostname();
+  my $email = $config->inherit("email") || getlogin() . "\@$host";
+  my $days = $config->inherit('days') || $config->inherit('crtDays') || $NetSNMP::Cert::DEFCRTDAYS;
+  my $cn = $config->inherit('cn') || $config->inherit('commonName');
+  my $ca = $config->inherit('with-ca');
+  my $cmd;
+
+  my $tag = $opts->{'tag'} || 'snmp';
+  $cn ||= (NetSNMP::Cert::is_server($tag) ? $host : $email);
+
+  my $env = $app->opensslEnv($cn, $days);
+
+  my $outCrt = "$NetSNMP::Cert::CRTDIR/$tag.crt";
+  my $outKey = "$NetSNMP::Cert::PRIVDIR/$tag.key";
+
+  NetSNMP::Cert::check_output_file($opts, $outCrt,
+				   $config->inherit('interactive'),
+				   $config->inherit('force'));
+  NetSNMP::Cert::check_output_file($opts, $outKey,
+				   $config->inherit('interactive'),
+				   $config->inherit('force'));
+
+  $cmd = "$env openssl req -extensions v3_user_create -new -days $days -keyout '$outKey' -batch -config $NetSNMP::Cert::SSLCFG";
+  $cmd .= " -nodes";
+
+  if (defined $ca) {
+    my $outCsr = "$NetSNMP::Cert::NEWCRTDIR/$tag.csr";
+    NetSNMP::Cert::check_output_file($opts, $outCsr,
+				   $config->inherit('interactive'),
+				   $config->inherit('force'));
+    $cmd .= " -out '$outCsr'";
+
+    NetSNMP::Cert::dprint("genCert (gencsr): $cmd\n", $opts);
+    NetSNMP::Cert::usystem("$cmd $opts->{out} $opts->{err}", $opts);
+
+    # XXX cleanup this temp CSR
+    my $ca_base = ::basename($ca, @NetSNMP::Cert::CRTSUFFIXES);
+    NetSNMP::Cert::dprint("ca_base: $ca_base\n", $opts);
+
+    # set command env
+    $env = $app->opensslEnv($cn, $days, ".ca/$ca_base");
+
+    $cmd = "$env openssl ca -extensions v3_ca_sign -days $days -cert '$ca' -keyfile '$NetSNMP::Cert::PRIVDIR/$ca_base.key' -in '$outCsr' -batch -config $NetSNMP::Cert::SSLCFG -out '$outCrt'";
+
+    NetSNMP::Cert::dprint("gencert (signcsr): $cmd\n", $opts);
+    NetSNMP::Cert::usystem("$cmd $opts->{out} $opts->{err}", $opts);
+  } else {
+    $cmd .= " -x509 -out '$outCrt'";
+
+    NetSNMP::Cert::dprint("genCert: $cmd\n", $opts);
+    NetSNMP::Cert::usystem("$cmd $opts->{out} $opts->{err}", $opts);
+  }
+
+  NetSNMP::Cert::vprint("Certificate Generated:\n", $opts);
+  NetSNMP::Cert::vprint("  $outCrt\n", $opts);
+  NetSNMP::Cert::vprint("  $outKey\n", $opts);
+}
+
+sub genCsr {
+  my $app = shift;
+  my $isCa = shift; # XXX - not implemented yet
+  my $config = $app->{'config'};
+  my $opts = $app->{'OPTS'};
+  my $host = $config->inherit("host") || ::hostname();
+  my $email = $config->inherit("email") || getlogin() . "\@$host";
+  my $days = $config->inherit('days') || $config->inherit('crtDays') || $NetSNMP::Cert::DEFCRTDAYS;
+  my $cn = $config->inherit('cn') || $config->inherit('commonName');
+  my $tag = $config->inherit('tag');
+  my $inCrt = $config->inherit('from-crt') || $config->inherit('fromCert');
+  my $outCsr;
+  my $csrKey;
+
+  if (defined $inCrt) {
+    $inCrt = NetSNMP::Cert::find_certs($opts, 'certs', $inCrt);
+    my $crt = ::basename($inCrt, @NetSNMP::Cert::CRTSUFFIXES);
+    $csrKey = "$NetSNMP::Cert::PRIVDIR/$crt.key";
+    $tag ||= $crt;
+  } else {
+    $tag ||= 'snmp';
+    $csrKey ||= "$NetSNMP::Cert::PRIVDIR/$tag.key";
+  }
+
+  $outCsr = "$NetSNMP::Cert::NEWCRTDIR/$tag.csr";
+
+  $cn ||= (NetSNMP::Cert::is_server($tag) ? $host : $email);
+
+  my $env = $app->opensslEnv($cn, $days);
+
+  NetSNMP::Cert::check_output_file($opts, $outCsr,
+				   $config->inherit('interactive'),
+				   $config->inherit('force'));
+  NetSNMP::Cert::check_output_file($opts, $csrKey,
+				   $config->inherit('interactive'),
+				   $config->inherit('force'));
+
+  my $cmd = (defined $inCrt ?
+  "$env openssl x509 -x509toreq -in $inCrt -out '$outCsr' -signkey '$csrKey' -nodes -days $days -batch -config $NetSNMP::Cert::SSLCFG" :
+  "$env openssl req -new -nodes -days $days -batch -keyout '$csrKey' -out '$outCsr' -config $NetSNMP::Cert::SSLCFG");
+
+  $cmd .= ($isCa ? " -extensions v3_ca_create" : " -extensions v3_user_create");
+
+  NetSNMP::Cert::dprint("genCsr: $cmd\n", $opts);
+
+  NetSNMP::Cert::usystem("$cmd $opts->{out} $opts->{err}", $opts);
+
+  NetSNMP::Cert::vprint("Certificate Signing Request Generated:\n", $opts);
+  NetSNMP::Cert::vprint("  $outCsr\n", $opts);
+  NetSNMP::Cert::vprint("  $csrKey\n", $opts);
+}
+
+sub signCsr {
+  my $app = shift;
+  my $isCa = shift;
+  my $config = $app->{'config'};
+  my $opts = $app->{'OPTS'};
+  my $host = $config->inherit("host") || ::hostname();
+  my $email = $config->inherit("email") || getlogin() . "\@$host";
+  my $days = $config->inherit('days') || $config->inherit('crtDays') || $NetSNMP::Cert::DEFCRTDAYS;
+  my $cn = $config->inherit('cn') || $config->inherit('commonName');
+  my $tag = $config->inherit('tag') || 'snmp';
+  my $install = $config->inherit('install');
+
+  $cn = (NetSNMP::Cert::is_server($tag) ? $host : $email);
+
+  my $ca = $opts->{'with-ca'};
+  NetSNMP::Cert::dprint("ca: $ca\n", $opts);
+  my $ca_base = ::basename($ca, @NetSNMP::Cert::CRTSUFFIXES);
+  NetSNMP::Cert::dprint("ca_base: $ca_base\n", $opts);
+  my $ca_key = "$NetSNMP::Cert::PRIVDIR/$ca_base.key"; 
+
+  my $csr = $opts->{'csr'};
+  NetSNMP::Cert::dprint("csr: $csr\n", $opts);
+  my $csr_base = ::basename($csr, @NetSNMP::Cert::CRTSUFFIXES);
+  NetSNMP::Cert::dprint("csr_base: $csr_base\n", $opts);
+  my $outdir = ($install ? $NetSNMP::Cert::CRTDIR : $NetSNMP::Cert::NEWCRTDIR);
+  my $outCrt = "$outdir/$csr_base.crt";
+
+  my $env = $app->opensslEnv($cn, $days, ".ca/$ca_base");
+
+  NetSNMP::Cert::check_output_file($opts, $outCrt,
+				   $config->inherit('interactive'),
+				   $config->inherit('force'));
+
+  # XXX - handle keyfile search??
+  my $cmd = "$env openssl ca -batch -days $days -extensions v3_ca_sign -cert '$ca' -keyfile '$ca_key' -in '$csr' -out '$outCrt' -config $NetSNMP::Cert::SSLCFG";
+
+  # $cmd .= ($isCa ? " -extensions v3_ca_sign_ca" : " -extensions v3_ca_sign");
+
+  NetSNMP::Cert::dprint("signCsr: $cmd\n", $opts);
+
+  NetSNMP::Cert::usystem("$cmd $opts->{out} $opts->{err}", $opts);
+
+  NetSNMP::Cert::vprint("Signed Certificate Signing Request:\n", $opts);
+  NetSNMP::Cert::vprint("  $csr\n", $opts);
+  NetSNMP::Cert::vprint("with CA:\n", $opts);
+  NetSNMP::Cert::vprint("  $ca\n", $opts);
+  NetSNMP::Cert::vprint("  $ca_key\n", $opts);
+  NetSNMP::Cert::vprint("Generated Certificate:\n", $opts);
+  NetSNMP::Cert::vprint("  $outCrt\n", $opts);
+}
+
+sub show {
+  my $app = shift;
+  my $type = shift || 'certs';
+  my $config = $app->{'config'};
+  my $opts = $app->{'OPTS'};
+  my $stag = shift(@{$opts->{'cmdargs'}});
+  my $fmt = NetSNMP::Cert::x509_format($opts) || '-subject';
+  my $brief = $config->inherit('brief');
+  my $output;
+  my $cmd;
+
+  my $cwd = ::getcwd();
+  NetSNMP::Cert::dprint("show ($cwd):$type:$stag:$fmt\n", $opts);
+  NetSNMP::Cert::vprint("$opts->{'tlsdir'}:\n", $opts) unless $brief;
+
+  foreach my $c (NetSNMP::Cert::find_certs($opts, $type, $stag)) {
+    print "\n$c:\n" unless $brief;
+    $cmd = "openssl x509 -in '$c' -noout $fmt";
+    NetSNMP::Cert::dprint("show: $cmd\n", $opts);
+
+    $output = `$cmd`; chomp $output;
+    NetSNMP::Cert::vwarn("show-$type failed ($?): $output\n", $opts) if $?;
+
+    $output =~ s/^[^\n=]+=// if $brief;
+
+    print "$output\n";
+    print "\n" unless $brief;
+  }
+}
+
+sub import_file {
+  my ($file, $suffix, $targ, $rdir, $tag) = @_;
+
+  if (NetSNMP::Cert::is_url($file)) {
+    if ($NetSNMP::Cert::haveUserAgent) {
+
+      require File::Temp;
+      import File::Temp qw(tempfile);
+
+      my ($fh, $newfilename) = tempfile(SUFFIX => $suffix);
+      return if (!$fh || !$newfilename);
+      my $ua = LWP::UserAgent->new;
+      my $response = $ua->get($file);
+      if ($response->is_success) {
+	print $fh $response->decoded_content();
+      } else {
+	NetSNMP::Cert::vwarn("failed to download a certificate from $file");
+	return;
+      }
+      $fh->close;
+      $file = $newfilename;
+    } else {
+      NetSNMP::Cert::vwarn("LWP::UserAgent not installed: unable to import certificate");
+      return;
+    }
+  }
+
+  $file = NetSNMP::Cert::fq_rel_path($file, $rdir);
+  die("file unreadable: $file\n") unless -r $file;
+
+
+  if (! $targ) {
+    $targ = (NetSNMP::Cert::is_ca_cert($file) ? $NetSNMP::Cert::CADIR : $NetSNMP::Cert::CRTDIR);
+  }
+
+  $targ .= "/" . $tag . $suffix if ($tag);
+  ::copy($file, $targ);
+}
+
+
+sub import {
+  my $app = shift;
+  my $config = $app->{'config'};
+  my $opts = $app->{'OPTS'};
+  my $carg = shift(@{$opts->{'cmdargs'}});
+  my $karg = shift(@{$opts->{'cmdargs'}});
+  my $targ;
+
+  if (not defined $carg) {
+    NetSNMP::Cert::vwarn("import: no certificate supplied\n", $opts);
+    NetSNMP::Cert::usage(1);
+  }
+
+  import_file($carg, '.crt', '',,
+	      $opts->{'rdir'}, $opts->{'tag'});
+
+  return unless defined $karg;
+
+  import_file($karg, '.key', 'private',,
+	      $opts->{'rdir'}, $opts->{'tag'});
+}
+
+
+package NetSNMP::Cert::Config;
+use vars qw(@ISA);
+@ISA = qw(NetSNMP::Cert::Obj);
+
+sub new {
+  my $class = shift;
+  my $parent = shift;
+  my $this = $class->SUPER::new('config', $parent);
+
+  bless($this, $class);
+}
+
+sub parse {
+  my $config = shift;
+  my $app = $config->{'APP'};
+  my $opts = $app->{'OPTS'};
+  my $cfgfile = shift;
+  $cfgfile ||= $opts->{'cfgfile'};
+
+  return '0 but true' if $config->{'PARSED'};
+  return '0 but true' unless defined $cfgfile;
+
+  open( CONFIG, "<$cfgfile" )
+    or die "error - could not open configuration file: $cfgfile";
+
+  while (<CONFIG>) {
+    next if /^\s*#/ or /^\s*$/;
+
+    if (/^\s*(\w+)(?:\(([\)\(\d\,\.]+)\))?\s*=\s*{/) {
+      my $obj = $1;
+
+      NetSNMP::Cert::dprint("object: $obj ($2) = {\n", $opts);
+      die "error - identity: indices not supported: $2" if defined $2;
+
+      # Found an object.
+      if ( $obj eq 'identity' ) {
+	my $identity = NetSNMP::Cert::Identity::parse(*CONFIG, $config);
+	my $id = $identity->{'id'};
+	die "error - identity: 'id' not defined" unless defined $id;
+	die "error - identity: duplicate '$id'" if exists $config->{$obj}{$id};
+	$config->{$obj}{$id} = $identity;
+      } else {
+        die "error - unrecognized object ($1) at scope (config)";
+      }
+    } elsif (/^\s*(\w+)\s*=?\s*(.*?)\s*$/) {
+      my $key = $1;
+      my $val = $2;
+
+      $val = $config->resolve($val) if $val =~ /\$\w+|\&\{.*?\}/;
+      # Found a symbol.
+      NetSNMP::Cert::dprint("  $key = $val\n", $opts);
+      if ($key eq 'subjectAltName' or $key eq 'san') {
+	push(@{$config->{$key}}, $val);
+      } elsif ( defined $config->{$key} ) {
+        die "error - duplicate symbol $key";
+      } else {
+        $config->{$key} = (defined $val ? NetSNMP::Cert::map_bool($val) : 1 );
+      }
+    } elsif (/^\s*env\s*(\w+=\S+)\s*$/) {
+      # Found an environment variable.
+      NetSNMP::Cert::dprint("$&\n", $opts);
+      push(@{$config->{'env'}}, $1);
+    } else {
+      die("error in config file [$cfgfile:line $.]");
+    }
+  }
+
+  NetSNMP::Cert::dprint("end parse config\n", $opts);
+  close(CONFIG);
+
+  # augment with any config directives supplied in opts
+  foreach my $cfg (@{$opts->{'config'}}) {
+    NetSNMP::Cert::dprint("augmenting config: $cfg\n", $opts);
+
+    $config->autoSet($1, (defined($2) ? $2 : 1 ))
+      if $cfg =~ /^\s*(\w+)\s*=?\s*(.*?)\s*$/;
+  }
+  $config->autoSet('PARSED', 1);
+  return $config->{'PARSED'};
+}
+
+package NetSNMP::Cert::Identity;
+use vars qw(@ISA);
+@ISA = qw(NetSNMP::Cert::Obj);
+
+sub new {
+  my $class = shift;
+  my $this = shift || $class->SUPER::new('identity', @_);
+  my $ind = $this->{'INDEX'} || 1;
+
+  $this->autoSet('name', "$this->{type}.$ind") unless exists $this->{'name'};
+
+  $this->autoSet('LOG','') unless exists $this->{'LOG'};
+  $this->autoSet('TTY_LOG','') unless exists $this->{TTY_LOG};
+
+  bless($this, $class);
+}
+
+
+sub parse {
+  my $FILE = shift;
+  my $parent = shift;
+  my $opts = $parent->inherit('OPTS');
+  my $identity = new NetSNMP::Cert::Obj('identity', $parent);
+
+  NetSNMP::Cert::dprint("parse identity\n", $opts);
+
+  while (<$FILE>) {
+    next if /^\s*#/ or /^\s*$/;
+
+    if (/^\s*(\w+)\s*=\s*{/) {
+      # Found an object.
+      die "error - can't have nested $1";
+    } elsif (/^\s*(\w+)\s*=?\s*(.*?)\s*$/) {
+      my $key = $1;
+      my $val = $2;
+
+      # Found a symbol.
+      NetSNMP::Cert::dprint("  $key = $val\n", $opts);
+
+      $val = $identity->resolve($val) if $val =~ /\$\w+|\&\{.*?\}/;
+
+      if ( $key eq 'subjectAltName' or $key eq 'san') {
+	push(@{$identity->{$key}}, $val);
+      } elsif ( defined $identity->{$key} ) {
+        die "error - duplicate symbol $key";
+      } else {
+        $identity->{$key} = (defined $val ? NetSNMP::Cert::map_bool($val) : 1 );
+      }
+    } elsif (/\s*\}\s*\;/) {
+      # End of definition.
+      NetSNMP::Cert::dprint("end parse identity\n", $opts);
+      return new NetSNMP::Cert::Identity($identity);
+    } else {
+      die("error in config file [$opts->{cfgfile}:line $.]");
+    }
+  }
+  die "error - unexpected end of conf file";
+}
+
+package main;
+
+my $app = new NetSNMP::Cert::App();
+$app->init(@ARGV);
+$app->run();
+
+__END__
+=pod
+
+=head1   NAME
+
+net-snmp-cert - Net-SNMP Certificate Management Tool
+
+=head1   SYNOPSIS
+
+=over
+
+=item $ net-snmp-cert genca -I --cn ca-Net-SNMP
+
+=item $ net-snmp-cert gencert -I -t snmpapp --with-ca ca-Net-SNMP
+
+=item $ net-snmp-cert gencert -I -t snmpd --cn net-snmp.org
+
+=item $ net-snmp-cert showcas
+
+=item $ net-snmp-cert showcerts
+
+=back
+
+=head1   DESCRIPTION
+
+net-snmp-cert creates, signs, installs and displays X.509
+certificates used in the operation of Net-SNMP/(D)TLS.
+
+=head1   SYNTAX
+
+=over
+
+=item net-snmp-cert [--help|-?]
+
+=item net-snmp-cert [--version|-V]
+
+=item net-snmp-cert genca    [<flags>] [<dn-opts>] [--with-ca <ca>]
+
+=item net-snmp-cert gencert  [<flags>] [<dn-opts>] [--with-ca <ca>]
+
+=item net-snmp-cert gencsr   [<flags>] [<dn-opts>] [--from-crt <crt>]
+
+=item net-snmp-cert signcsr  [<flags>] [--install] --csr <csr> --with-ca <ca>
+
+=item net-snmp-cert showca   [<flags>] [<format-opts>] [<file>|<search-tag>]
+
+=item net-snmp-cert showcert [<flags>] [<format-opts>] [<file>|<search-tag>]
+
+=item net-snmp-cert import   [<flags>] <file|url> [<key>]
+
+=back
+
+=head1   COMMANDS
+
+=over
+
+=item genca
+
+generate a signed CA certificate suitable for signing other
+certificates. default: self-signed unless --with-ca <ca> supplied
+
+=item gencert
+
+generate a signed certificate suitable for identification, or
+validation. default: self-signed unless --with-ca <ca> supplied
+
+=item gencsr
+
+generate a certificate signing request. will create a new
+key and certificate unless --from-crt <crt> supplied
+
+=item signcsr
+
+sign a certificate signing request specified by --csr <csr>
+with the CA certificate specified by --with-ca <ca>
+
+=item import
+
+import an identity or CA certificate, optionally import <key>
+if an URL is passed, will attempt to import certificate from site
+
+=item showca, showcert
+
+show CA or identity certificate(s). may pass fully qualified
+file or directory name, or a search-tag which prefix matches
+installed CA or identity certificate file name(s)
+see FORMAT OPTIONS to specify output format
+
+
+=back
+
+=head1   FLAGS
+
+=over
+
+=item -?, --help            -- show this text and exit
+
+=item -V, --version         -- show version string and exit
+
+=item -D, --debug           -- raise debug level (-D -D for higher level)
+
+=item -F, --force           -- force overwrite of existing output files
+
+=item -I, --nointeractive   -- non-interactive run (default interactive)
+
+=item -Q, --noverbose       -- non-verbose output (default verbose)
+
+=item -C, --cfgdir   <dir>  -- configuration dir (see man(5) snmp_config)
+
+=item -T, --tlsdir   <dir>  -- root for cert storage (default <cfgdir>/tls)
+
+=item -f, --cfgfile  <file> -- config (default <cfgdir>/net-snmp-cert.conf)
+
+=item -i, --identity <id>   -- identity to use from config
+
+=item -t, --tag      <tag>  -- application tag (default 'snmp')
+
+=item --<cfg-param>[=<val>] -- additional config params
+
+=back
+
+=head1   CERTIFICATE OPTIONS (<cert-opts>)
+
+=over
+
+=item -a, --with-ca <ca>    -- CA certificate used to sign request
+
+=item -A, --ca <ca>         -- explicit output CA certificate
+
+=item -r, --csr <csr>       -- certificate signing request
+
+=item -x, --from-crt <crt>  -- input certificate for current operation
+
+=item -X, --crt <crt>       -- explicit output certificate
+
+=item -y, --install         -- install result in local repository
+
+=back
+
+=head1   DISTINGUISHED NAME OPTIONS (<dn-opts>)
+
+=over
+
+=item -e, --email <email>       -- email name
+
+=item -h, --host <host>         -- DNS host name, or IP address
+
+=item -d, --days <days>         -- number of days certificate is valid
+
+=item -n, --cn <cn>             -- common name (CN)
+
+=item -o, --org <org>           -- organiztion name
+
+=item -u, --unit <unit>         -- organiztion unit name
+
+=item -c, --country <country>   -- country code (e.g., US)
+
+=item -p, --province <province> -- province name (synomynous w/ state)
+
+=item -p, --state <state>       -- state name (synomynous w/ province)
+
+=item -l, --locality <locality> -- locality name (e.g, town)
+
+=item -s, --san <san>           -- subjectAltName, repeat for each <san>
+
+=over 2
+
+=item    <san> value format (<FMT>:<VAL>):
+
+=over 3
+
+=item       dirName:/usr/share/snmp/tls
+
+=item       DNS:net-snmp.org
+
+=item       email:admin@net-snmp.org
+
+=item       IP:192.168.1.1
+
+=item       RID:1.1.3.6
+
+=item       URI:http://net-snmp.org
+
+=back
+
+=back
+
+=back
+
+=head1   FORMAT OPTIONS (<format-opts>)
+
+=over
+
+=item --brief        -- minimized output (values only where applicable)
+
+=item --text         -- full text description
+
+=item --subject      -- subject description
+
+=item --subject_hash -- hash of subject for indexing
+
+=item --issuer       -- issuer description
+
+=item --issuer_hash  -- hash of issuer for indexing
+
+=item --fingerprint  -- SHA1 digest of DER
+
+=item --serial       -- serial number
+
+=item --modulus      -- modulus of the public key
+
+=item --dates        -- start and end dates
+
+=item --purpose      -- displays allowed uses
+
+=item --C            -- C code description
+
+=back
+
+=head1   OPERATIONAL NOTES
+
+
+=head2   Interactive Mode
+
+The application operates in interactive mode by default. In this mode
+basic operations of offered and required input is queried through the
+command line. 
+
+Typical <tab> completion is provided when possible and field specific
+help may be obtained by entering '?'.
+
+To turn off interactive mode, supply '--nointeractive' or '-I' on the
+initial command line. Equivalantly, 'interactive = false' maybe placed
+in the configuration file (see below).
+
+=head2   Configuration
+
+A configuration file may be supplied on the command line or found in a
+default location (<snmpconfpath>/net-snmp-cert.conf). This file may
+contain configuration parameters equivalent to those supplied on the
+command line and effectively provides default values for these
+values. If a command line parameter is supplied it will override the
+value in the config file. If neither is present then an application
+value will be used.
+
+=head2   Certificate Naming
+
+Filenames of created certificates, as stored in the configuration
+directory, are chosen in the following manner. If and application tag
+is supplied, it will be used as the basename for the certificate and
+key generated. Otherwise, for CA certificates, the basename will be
+derived from the Common Name. For non-CA certificates the application
+tag defaults to 'snmp' which will then be used as the basename of the
+certificate and key.
+
+=head1   EXAMPLES
+
+=over
+
+=item net-snmp-cert genca --cn ca-net-snmp.org --days 1000
+
+=item net-snmp-cert genca -f .snmp/net-snmp-cert.conf -i nocadm
+
+=item net-snmp-cert gencert -t snmpd --cn host.net-snmp.org
+
+=item net-snmp-cert gencsr -t snmpapp
+
+=item net-snmp-cert signcsr --csr snmpapp --with-ca ca-net-snmp.org
+
+=item net-snmp-cert showcerts --subject --issuer --dates snmpapp
+
+=item net-snmp-cert showcas --fingerprint ca-net-snmp.org --brief
+
+=item net-snmp-cert import ca-third-party.crt
+
+=item net-snmp-cert import signed-request.crt signed-request.key
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (c) 2010 Cobham Analytic Solutions - All rights reserved.
+Copyright (c) 2010 G. S. Marzot -  All rights reserved.
+
+=head1   AUTHOR
+
+G. S. Marzot (marz@users.sourceforge.net)
+
+=cut
+

Property changes on: create-5.9-cert-path-patch/net-snmp-5.9-new/local/net-snmp-cert
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-5.9-cert-path-patch/net-snmp-5.9-new/local
===================================================================
--- create-5.9-cert-path-patch/net-snmp-5.9-new/local	(nonexistent)
+++ create-5.9-cert-path-patch/net-snmp-5.9-new/local	(revision 5)

Property changes on: create-5.9-cert-path-patch/net-snmp-5.9-new/local
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-cert-path-patch/net-snmp-5.9-new
===================================================================
--- create-5.9-cert-path-patch/net-snmp-5.9-new	(nonexistent)
+++ create-5.9-cert-path-patch/net-snmp-5.9-new	(revision 5)

Property changes on: create-5.9-cert-path-patch/net-snmp-5.9-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-cert-path-patch
===================================================================
--- create-5.9-cert-path-patch	(nonexistent)
+++ create-5.9-cert-path-patch	(revision 5)

Property changes on: create-5.9-cert-path-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-cross-python-patch/create.patch.sh
===================================================================
--- create-5.9-cross-python-patch/create.patch.sh	(nonexistent)
+++ create-5.9-cross-python-patch/create.patch.sh	(revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=5.9
+
+tar --files-from=file.list -xzvf ../net-snmp-$VERSION.tar.gz
+mv net-snmp-$VERSION net-snmp-$VERSION-orig
+
+cp -rf ./net-snmp-$VERSION-new ./net-snmp-$VERSION
+
+diff --unified -Nr  net-snmp-$VERSION-orig  net-snmp-$VERSION > net-snmp-$VERSION-cross-python.patch
+
+mv net-snmp-$VERSION-cross-python.patch ../patches
+
+rm -rf ./net-snmp-$VERSION
+rm -rf ./net-snmp-$VERSION-orig

Property changes on: create-5.9-cross-python-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-5.9-cross-python-patch/file.list
===================================================================
--- create-5.9-cross-python-patch/file.list	(nonexistent)
+++ create-5.9-cross-python-patch/file.list	(revision 5)
@@ -0,0 +1 @@
+net-snmp-5.9/Makefile.in
Index: create-5.9-cross-python-patch/net-snmp-5.9-new/Makefile.in
===================================================================
--- create-5.9-cross-python-patch/net-snmp-5.9-new/Makefile.in	(nonexistent)
+++ create-5.9-cross-python-patch/net-snmp-5.9-new/Makefile.in	(revision 5)
@@ -0,0 +1,499 @@
+
+#
+# Makefile.in (at the root of net-snmp)
+#
+
+VPATH		= @srcdir@
+
+SUBDIRS		= snmplib @MAINSUBS@
+FTSUBDIRS	= @FTMAINSUBS@ snmplib
+TESTDIRS	= testing
+
+CPP		= @CPP@ 					        \
+		-Iinclude -I$(srcdir)/include -I$(srcdir)/agent/mibgroup -I. -I$(srcdir)	\
+		-DDONT_INC_STRUCTS -DBINDIR=$(bindir) 		        \
+		$(EXTRACPPFLAGS)
+
+INSTALLHEADERS=version.h net-snmp-features.h
+INCLUDESUBDIR=system
+INCLUDESUBDIRHEADERS= aix.h bsd.h bsdi3.h bsdi4.h bsdi.h cygwin.h \
+	darwin.h darwin7.h darwin8.h darwin9.h darwin10.h darwin11.h darwin12.h \
+	darwin13.h darwin14.h darwin15.h darwin16.h darwin17.h \
+	dragonfly.h dynix.h \
+	freebsd2.h freebsd3.h freebsd4.h freebsd5.h freebsd6.h \
+	freebsd7.h freebsd8.h freebsd9.h freebsd10.h freebsd11.h \
+	freebsd12.h freebsd13.h freebsd14.h freebsd.h \
+	generic.h \
+	hpux.h irix.h linux.h mingw32.h mingw32msvc.h mips.h \
+	netbsd.h nto-qnx6.h osf5.h \
+	openbsd.h openbsd6.h openbsd5.h openbsd4.h \
+	solaris2.3.h solaris2.4.h solaris2.5.h solaris2.6.h \
+	solaris.h sunos.h svr5.h sysv.h ultrix4.h
+INCLUDESUBDIR2=machine
+INCLUDESUBDIRHEADERS2=generic.h
+INSTALLBUILTHEADERS=include/net-snmp/net-snmp-config.h
+INSTALLBUILTINCLUDEHEADERS=@FEATUREHEADERS@
+INSTALLBINSCRIPTS=net-snmp-config net-snmp-create-v3-user
+INSTALLUCDHEADERS=ucd-snmp-config.h version.h mib_module_config.h
+INSTALL_PKGCONFIG=netsnmp.pc netsnmp-agent.pc
+
+#
+# other install rules.
+#
+OTHERINSTALL=copypersistentfiles @PERLINSTALLTARGS@ @PYTHONINSTALLTARGS@
+OTHERUNINSTALL=@PERLUNINSTALLTARGS@ @PYTHONUNINSTALLTARGS@
+COPY_PERSISTENT_FILES=@COPY_PERSISTENT_FILES@
+PERSISTENT_DIRECTORY=@PERSISTENT_DIRECTORY@
+UCDPERSISTENT_DIRECTORY=@UCDPERSISTENT_DIRECTORY@
+
+#
+# perl specific
+#
+# yes, order matters here.  default_store must occur before anything else
+PERLMODULES=default_store SNMP ASN OID agent TrapReceiver
+PERLMODULEFTS=perl/default_store/netsnmp-feature-definitions.ft \
+	perl/SNMP/netsnmp-feature-definitions.ft \
+	perl/ASN/netsnmp-feature-definitions.ft \
+	perl/OID/netsnmp-feature-definitions.ft \
+	perl/agent/netsnmp-feature-definitions.ft \
+	perl/TrapReceiver/netsnmp-feature-definitions.ft
+PERLARGS=@PERLARGS@
+
+#
+# python specific
+#
+PYTHONARGS=@PYTHONARGS@
+PYTHONMODULEFTS=python/netsnmp/netsnmp-feature-definitions.ft
+
+#
+# libtool
+#
+LIBTOOL_DEPS = @LIBTOOL_DEPS@
+
+#
+# feature checks for optional components
+#
+FTOTHERTARGS=@PERLFEATURES@ @PYTHONFEATURES@
+
+#
+# targets
+#
+all:    sedscript EXAMPLE.conf  @FEATURETARGS@ standardall net-snmp-config-x net-snmp-create-v3-user @PERLTARGS@ @PYTHONTARGS@
+
+start-flag:
+	@touch build-in-progress-flag
+
+end-flag:
+	@rm -f build-in-progress-flag > /dev/null 2>&1 
+
+libtool:	$(LIBTOOL_DEPS)
+	$(SHELL) ./config.status --recheck
+
+
+snmplib: @FEATURETARGS@
+	@(cd snmplib; $(MAKE) )
+
+agent: @FEATURETARGS@
+	@(cd snmplib; $(MAKE) )
+	@(cd agent; $(MAKE) )
+
+apps: @FEATURETARGS@
+	@(cd snmplib; $(MAKE) )
+	@(cd agent; $(MAKE) libs)
+	@(cd apps; $(MAKE) )
+
+snmpget snmpbulkget snmpwalk snmpbulkwalk snmptranslate snmpstatus snmpdelta snmptable snmptest snmpset snmpusm snmpvacm snmpgetnext encode_keychange snmpdf snmptrap snmptls: @FEATURETARGS@
+	@(cd snmplib; $(MAKE) )
+	@(cd apps; $(MAKE) $@ )
+
+agentxtrap snmptrapd: @FEATURETARGS@
+	@(cd snmplib; $(MAKE) )
+	@(cd agent; $(MAKE) libs)
+	@(cd apps; $(MAKE) $@ )
+
+#
+# local build rules
+#
+sedscript: sedscript.in include/net-snmp/net-snmp-config.h $(srcdir)/agent/mibgroup/mibdefs.h
+	$(CPP) $(srcdir)/sedscript.in | egrep '^s[/#]' | sed 's/REMOVEME//g;s# */#/#g;s/ *#/#/g;s#/ *#/#g;s/# g/#g/;' > sedscript
+	echo 's/VERSIONINFO/$(VERSION)/g' >> sedscript
+	echo 's#DATADIR#$(datadir)#g' >> sedscript
+	echo 's#LIBDIR#$(libdir)#g' >> sedscript
+	echo 's#BINDIR#$(bindir)#g' >> sedscript
+	echo 's#PERSISTENT_DIRECTORY#$(PERSISTENT_DIRECTORY)#g' >> sedscript
+	echo 's#SYSCONFDIR#@sysconfdir@#g' >> sedscript
+
+EXAMPLE.conf: sedscript EXAMPLE.conf.def
+	$(SED) -f sedscript $(srcdir)/EXAMPLE.conf.def > EXAMPLE.conf
+
+docs: docsdir 
+
+docsdir: docsdox
+
+docsdox: doxygen.conf
+	srcdir=$(srcdir) VERSION=$(VERSION) doxygen $(srcdir)/doxygen.conf
+
+net-snmp-config-x: net-snmp-config
+	chmod a+x net-snmp-config
+	touch net-snmp-config-x
+
+net-snmp-create-v3-user-x: net-snmp-create-v3-user
+	chmod a+x net-snmp-create-v3-user
+	touch net-snmp-create-v3-user-x
+
+#
+# extra install rules
+#
+
+copypersistentfiles:
+	@if test "$(COPY_PERSISTENT_FILES)" = "yes" -a -d $(UCDPERSISTENT_DIRECTORY) -a ! -d $(PERSISTENT_DIRECTORY) ; then \
+		cp -pr $(UCDPERSISTENT_DIRECTORY) $(PERSISTENT_DIRECTORY) ; \
+		echo "copying $(UCDPERSISTENT_DIRECTORY) to $(PERSISTENT_DIRECTORY)" ; \
+	fi
+#
+# test targets
+#
+test test-mibs testall testfailed testsimple: all testdirs
+	( cd testing; $(MAKE) $@ )
+
+testdirs:
+	for i in $(TESTDIRS) ; do	\
+           ( cd $$i ; $(MAKE) ) ;		\
+           if test $$? != 0 ; then \
+              exit 1 ; \
+           fi  \
+	done
+
+distall: ${srcdir}/configure ${srcdir}/include/net-snmp/net-snmp-config.h 
+
+OTHERCLEANTARGETS=EXAMPLE.conf sedscript
+OTHERCLEANTODOS=perlclean @PYTHONCLEANTARGS@ cleanfeatures perlcleanfeatures pythoncleanfeatures
+
+#
+# perl specific build rules
+#
+# override LD_RUN_PATH to avoid dependencies on the build directory
+perlmodules: perlmakefiles subdirs
+	@(cd perl ; $(MAKE) LD_RUN_PATH="$(libdir):`$(PERL) -e 'use Config; print qq($$Config{archlibexp}/CORE);'`") ; \
+        if test $$? != 0 ; then \
+           exit 1 ; \
+        fi
+
+perlmakefiles: perl/Makefile net-snmp-config-x
+
+perl/Makefile: perl/Makefile.PL
+	dir=`pwd` &&							\
+	cd perl &&							\
+	if false; then							\
+	    carp=-MCarp::Always;					\
+	fi &&								\
+	export PERL5LIB="$$dir/perl" &&					\
+	$(PERL) $$carp Makefile.PL -NET-SNMP-IN-SOURCE=true		\
+	    -NET-SNMP-CONFIG="sh $$dir/net-snmp-config" $(PERLARGS)
+
+perlinstall:
+	@(cd perl ; $(MAKE) install) ; \
+        if test $$? != 0 ; then \
+           exit 1 ; \
+        fi
+
+perluninstall:
+	echo "WARNING: perl doesn't support uninstall"
+
+perltest:
+	@(cd perl ; $(MAKE) test) ; \
+	if test $$? != 0 ; then \
+	   exit 1 ; \
+	fi
+
+perlclean:
+	@if test -f perl/Makefile; then \
+	   ( cd perl ; $(MAKE) clean ) ; \
+	fi
+
+perlrealclean:
+	@if test -f perl/Makefile; then \
+	   ( cd perl ; $(MAKE) realclean ) ; \
+	fi
+
+.h.ft:
+	$(FEATURECHECK) --feature-global $(top_builddir)/include/net-snmp/feature-details.h `dirname $<` $< $@ $(CC) -I $(top_builddir)/include -I $(top_srcdir)/include -E $(CPPFLAGS) $(CFLAGS) -c
+
+perlfeatures: $(PERLMODULEFTS)
+
+perlcleanfeatures:
+	$(RM) $(PERLMODULEFTS)
+
+#
+# python specific build rules:
+#
+#   EXTRA_PYTHON_CFLAGS   additional compiler flags to pass when building Python
+#                         library
+#   EXTRA_PYTHON_LDFLAGS  additional linker flags to pass when building Python
+#                         library
+#
+#   PYTHON_CC        cross compiler for Python extension module, for example:
+#                      /opt/toolchains/ppc64-POWER8-linux-glibc/1.2.3/bin/ppc64-power8-linux-gnu-gcc \
+#                        --sysroot=PATH_TO_DEVENV_SYSROOT
+#                    used to define 'CC' environment variable for build Python extensions
+#
+#   PYTHON_LDSHARED  cross linker for Python extension module, for example:
+#                      /opt/toolchains/ppc64-POWER8-linux-glibc/1.2.3/bin/ppc64-power8-linux-gnu-gcc \
+#                        --sysroot=PATH_TO_DEVENV_SYSROOT -shared
+#                    used to define 'LDSHARED' venvironmen varionle for build Python
+#
+#   PYTHON_CCSHARED  cross linker for Python extension module, for example:
+#                      /opt/toolchains/ppc64-POWER8-linux-glibc/1.2.3/bin/ppc64-power8-linux-gnu-gcc \
+#                        --sysroot=PATH_TO_DEVENV_SYSROOT -shared
+#                    used to define 'LDSHARED' venvironmen varionle for build Python
+#
+#   PYTHON_PATH      path to Python lib-dinload directory where placed the sysconfig file
+#                    got build machine Python, for example:
+#                      PYTHON_PATH=PATH_TO_DEVENV_SYSROOT/usr/lib/python3.10/lib-dynload
+#                    if your build machine is an x86_64 Linux machine then the file:
+#                      _sysconfigdata_m_linux_x86_64-linux-gnu.py
+#                    will be used by Python setup tools to get system variables to
+#                    build extension module. For example the suffix of shared library
+#                    defined by EXT_SUFFIX variable in the _sysconfigdata_* file
+#
+PYMAKE = CC="$(PYTHON_CC)" LDSHARED="$(PYTHON_LDSHARED)" CCSHARED="$(PYTHON_CCSHARED)" \
+         CFLAGS="$(EXTRA_PYTHON_CFLAGS)" LDFLAGS="$(EXTRA_PYTHON_LDFLAGS)" \
+         PYTHONPATH=$(PYTHON_PATH) $(PYTHON) setup.py $(PYTHONARGS)
+pythonmodules: subdirs
+	@(dir=`pwd`; cd python; $(PYMAKE) build --basedir=$$dir) ; \
+        if test $$? != 0 ; then \
+           exit 1 ; \
+        fi
+
+pythoninstall:
+	@(dir=`pwd`; cd python; $(PYMAKE) install --basedir=$$dir --root=$(DESTDIR) --prefix=$(prefix)) ; \
+        if test $$? != 0 ; then \
+           exit 1 ; \
+        fi
+
+pythonuninstall:
+	echo "WARNING: python doesn't support uninstall"
+
+pythontest:
+	@(dir=`pwd`; cd python; $(PYMAKE) test --basedir=$$dir) ; \
+	if test $$? != 0 ; then \
+	   exit 1 ; \
+	fi
+
+pythonclean:
+	@(dir=`pwd`; cd python; $(PYMAKE) clean --basedir=$$dir)
+
+pythonfeatures: $(PYTHONMODULEFTS)
+
+pythoncleanfeatures:
+	$(RM) $(PYTHONMODULEFTS)
+
+#
+# make distclean completely removes all traces of building including
+# any files generated by configure itself.
+#
+distclean: perlrealclean clean configclean tarclean
+
+makefileclean:
+	rm -f Makefile snmplib/Makefile				\
+		agent/Makefile agent/mibgroup/Makefile		\
+		agent/helpers/Makefile				\
+		apps/Makefile  apps/snmpnetstat/Makefile	\
+		man/Makefile mibs/Makefile ov/Makefile		\
+		local/Makefile testing/Makefile
+
+configclean: makefileclean
+	rm -f config.cache config.status config.log \
+		libtool include/net-snmp/net-snmp-config.h \
+		net-snmp-config net-snmp-config-x configure-summary \
+		net-snmp-create-v3-user net-snmp-create-v3-user-x
+	rm -f *.pc
+	rm -f mibs/.index
+	rm -f include/net-snmp/agent/mib_module_config.h		\
+		include/net-snmp/agent/agent_module_config.h		\
+		include/net-snmp/library/snmpv3-security-includes.h \
+		include/net-snmp/feature-details.h                  \
+		snmplib/snmpsm_init.h snmplib/snmpsm_shutdown.h     \
+                snmplib/transports/snmp_transport_inits.h           \
+		agent/mibgroup/agent_module_includes.h 	\
+		agent/mibgroup/agent_module_inits.h 	\
+		agent/mibgroup/agent_module_shutdown.h 	\
+		agent/mibgroup/agent_module_dot_conf.h  \
+		agent/mibgroup/mib_module_includes.h 	\
+		agent/mibgroup/mib_module_inits.h 	\
+		agent/mibgroup/mib_module_shutdown.h 	\
+		agent/mibgroup/mib_module_dot_conf.h    \
+		local/snmpconf
+	rm -rf mk
+	rm -f *.core
+
+#
+# Configure script related targets
+#
+touchit:
+	touch configure include/net-snmp/net-snmp-config.h.in
+	touch config.status
+	touch stamp-h stamp-h.in
+
+Makefile: Makefile.in config.status Makefile.rules Makefile.top
+	@if test "x$(NOAUTODEPS)" = "x"; then \
+	    echo "running config.status because the following file(s) changed:"; \
+	    echo "  $?"; \
+	    ./config.status; \
+	else \
+	    echo "WARNING: not running config.status"; \
+	fi
+
+configure_ac = configure.ac \
+	configure.d/config_modules_agent \
+	configure.d/config_modules_lib \
+	configure.d/config_net_snmp_config_h \
+	configure.d/config_os_functions \
+	configure.d/config_os_headers \
+	configure.d/config_os_libs1 \
+	configure.d/config_os_libs2 \
+	configure.d/config_os_misc1 \
+	configure.d/config_os_misc2 \
+	configure.d/config_os_misc3 \
+	configure.d/config_os_misc4 \
+	configure.d/config_os_progs \
+	configure.d/config_os_struct_members \
+	configure.d/config_project_ipv6_types \
+	configure.d/config_project_manual \
+	configure.d/config_project_paths \
+	configure.d/config_project_perl_python \
+	configure.d/config_project_types \
+	configure.d/config_project_with_enable
+
+$(srcdir)/include/net-snmp/net-snmp-config.h.in: stamp-h.in
+$(srcdir)/stamp-h.in: $(configure_ac)
+	@if test "x$(NOAUTODEPS)" = "x" -a "x$(AUTOHEADER)" != "x:"; then \
+	    cd ${srcdir} && LC_COLLATE=C $(AUTOHEADER); \
+	    echo timestamp > ${srcdir}/stamp-h.in; \
+	else \
+	    echo "WARNING: not running autoheader"; \
+	fi
+
+include/net-snmp/net-snmp-config.h: stamp-h
+stamp-h: include/net-snmp/net-snmp-config.h.in config.status
+	@if test "x$(NOAUTODEPS)" = "x"; then \
+	    echo "running config.status because the following file(s) changed:"; \
+	    echo "  $?"; \
+	    ./config.status; \
+	    echo timestamp > stamp-h; \
+	else \
+	    echo "WARNING: not running config.status"; \
+	fi
+
+$(srcdir)/configure: $(configure_ac) aclocal.m4
+	@if test "x$(NOAUTODEPS)" = "x" -a "x$(AUTOCONF)" != "x:"; then \
+	    cd ${srcdir} && $(AUTOCONF); \
+	    echo "Please run configure now."; \
+	    sh -c exit 2; \
+	else \
+	    echo "WARNING: not running autoconf"; \
+	fi
+
+gendir=dist/generation-scripts
+generation-scripts: generation-scripts-dirs $(gendir)/gen-transport-headers $(gendir)/gen-security-headers
+
+$(gendir)/gen-variables: $(gendir)/gen-variables.in
+	./config.status
+
+generation-scripts-dirs:
+	@if [ ! -d dist ] ; then \
+	    mkdir dist ;        \
+	fi
+	@if [ ! -d dist/generation-scripts ] ; then \
+	    mkdir dist/generation-scripts ;        \
+	fi
+
+$(gendir)/gen-transport-headers: $(gendir)/gen-transport-headers.in $(gendir)/gen-variables
+	rm -f $@
+	autoconf -o $@ $<
+	chmod a+x $@
+
+$(gendir)/gen-security-headers: $(gendir)/gen-security-headers.in $(gendir)/gen-variables
+	rm -f $@
+	autoconf -o $@ $<
+	chmod a+x $@
+
+config.status: configure
+	@if test "x$(NOAUTODEPS)" = "x"; then \
+	    echo "running config.status because $? changed"; \
+	    ./config.status --recheck; \
+	else \
+	    echo "WARNING: not running config.status --recheck"; \
+	fi
+
+#
+# Emacs TAGS file
+#
+TAGS:
+	$(FIND) $(srcdir) -path $(srcdir)/dist/rpm -prune -o -name '*.[ch]' -print | etags -
+
+#
+# Internal distribution packaging, etc.
+#
+#tag:
+#	@if test "x$(VERSION)" = "x"; then \
+#	  echo "you need to supply a VERSION string."; \
+#	  exit 2; \
+#	fi
+#	${srcdir}/agent/mibgroup/versiontag $(VERSION) tag
+
+tar:
+	@if test "x$(VERSION)" = "x"; then \
+	  echo "you need to supply a VERSION string."; \
+	  exit 2; \
+	fi
+	${srcdir}/agent/mibgroup/versiontag $(VERSION) tar
+
+tarclean:
+	@if test -x ${srcdir}/agent/mibgroup/versiontag ; then \
+	  ${srcdir}/agent/mibgroup/versiontag Ext clean ; \
+	fi
+
+checks:
+	$(MAKE) -k makefilecheck commentcheck warningcheck dependcheck \
+	assertcheck perlcalloccheck
+
+dependcheck:
+	@echo "Checking for full paths in dependency files..."
+	@if grep -n -E "^/" `$(FIND) $(top_srcdir) -name Makefile.depend`; then false; fi
+
+warningcheck:
+	@echo "Checking for cpp warnings..."
+	@if grep -n "#warning" `$(FIND) $(top_srcdir) -name \*.\[ch\]`; then false; fi
+
+assertcheck:
+	@echo "Checking for non-snmp asserts..."
+	@if grep -n -w "assert" `$(FIND) $(top_srcdir) -name \*.\[ch\] | grep -v snmp_assert.h`; then false; fi
+
+commentcheck:
+	@echo "Checking for C++ style comments..."
+	@if grep -n -E "([^:)n]|^)//" `$(FIND) $(top_srcdir) -path './win32' -prune -o -name \*.\[ch\] | grep -v agent/mibgroup/winExtDLL.c`; then false; fi
+
+makefilecheck:
+	@echo "Checking for non-portable Makefile constructs..."
+	@if grep -n "\.c=" `$(FIND) $(top_srcdir) -name .svn -prune -o -path ./Makefile.in -prune -o -name "Makefile.*" -print`; then false; fi
+
+# Invoking calloc() directly or indirectly from a Perl XSUB and freeing that
+# memory by calling free() from the XSUB is a sure way to trigger "Free to
+# wrong pool" errors on Windows.
+perlcalloccheck:
+	@echo "Checking for calloc() in Perl's external subroutines ..."
+	@if grep -nwE 'calloc|SNMP_MALLOC_STRUCT|SNMP_MALLOC_TYPEDEF' `$(FIND) $(top_srcdir) -name '*.xs'`; then false; fi
+
+dist: tar
+
+FAQ.html:
+	local/FAQ2HTML FAQ
+
+.PHONY: docs docsdir mancp testdirs test TAGS
+# note: tags and docs are phony to force rebulding
+.PHONY: snmplib agent apps \
+	snmpget snmpbulkget snmpwalk snmpbulkwalk snmptranslate snmpstatus \
+	snmpdelta snmptable snmptest snmpset snmpusm snmpvacm snmpgetnext \
+	encode_keychange snmpdf snmptrap snmptrapd
+.PHONY: perlfeatures pythonfeatures
Index: create-5.9-cross-python-patch/net-snmp-5.9-new
===================================================================
--- create-5.9-cross-python-patch/net-snmp-5.9-new	(nonexistent)
+++ create-5.9-cross-python-patch/net-snmp-5.9-new	(revision 5)

Property changes on: create-5.9-cross-python-patch/net-snmp-5.9-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-cross-python-patch
===================================================================
--- create-5.9-cross-python-patch	(nonexistent)
+++ create-5.9-cross-python-patch	(revision 5)

Property changes on: create-5.9-cross-python-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-iterator-patch/create.patch.sh
===================================================================
--- create-5.9-iterator-patch/create.patch.sh	(nonexistent)
+++ create-5.9-iterator-patch/create.patch.sh	(revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=5.9
+
+tar --files-from=file.list -xzvf ../net-snmp-$VERSION.tar.gz
+mv net-snmp-$VERSION net-snmp-$VERSION-orig
+
+cp -rf ./net-snmp-$VERSION-new ./net-snmp-$VERSION
+
+diff --unified -Nr  net-snmp-$VERSION-orig  net-snmp-$VERSION > net-snmp-$VERSION-iterator.patch
+
+mv net-snmp-$VERSION-iterator.patch ../patches
+
+rm -rf ./net-snmp-$VERSION
+rm -rf ./net-snmp-$VERSION-orig

Property changes on: create-5.9-iterator-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-5.9-iterator-patch/file.list
===================================================================
--- create-5.9-iterator-patch/file.list	(nonexistent)
+++ create-5.9-iterator-patch/file.list	(revision 5)
@@ -0,0 +1 @@
+net-snmp-5.9/agent/mibgroup/host/data_access/swrun.c
Index: create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup/host/data_access/swrun.c
===================================================================
--- create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup/host/data_access/swrun.c	(nonexistent)
+++ create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup/host/data_access/swrun.c	(revision 5)
@@ -0,0 +1,397 @@
+/*
+ *  Swrun MIB architecture support
+ *
+ * $Id: swrun.c 15768 2007-01-22 16:18:29Z rstory $
+ */
+/*
+ * Copyright (C) 2007 Apple, Inc. All rights reserved.
+ * Use is subject to license terms specified in the COPYING file
+ * distributed with the Net-SNMP package.
+ */
+#include <net-snmp/net-snmp-config.h>
+#include <net-snmp/net-snmp-features.h>
+#include <net-snmp/net-snmp-includes.h>
+
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+#include <net-snmp/data_access/swrun.h>
+#include "swrun.h"
+#include "swrun_private.h"
+
+#if HAVE_PCRE_H
+#include <pcre.h>
+#endif
+
+netsnmp_feature_child_of(software_running, libnetsnmpmibs);
+
+netsnmp_feature_child_of(swrun_max_processes, software_running);
+netsnmp_feature_child_of(swrun_count_processes_by_name, software_running);
+netsnmp_feature_child_of(swrun_count_processes_by_regex, software_running);
+
+/**---------------------------------------------------------------------*/
+/*
+ * local static vars
+ */
+static int _swrun_init = 0;
+       int _swrun_max  = 0;
+static netsnmp_cache     *swrun_cache     = NULL;
+static netsnmp_container *swrun_container = NULL;
+
+/*
+ * local static prototypes
+ */
+static void _swrun_entry_release(netsnmp_swrun_entry * entry,
+                                            void *unused);
+
+/**
+ * initialization
+ */
+void
+init_swrun(void)
+{
+    DEBUGMSGTL(("swrun:access", "init\n"));
+
+    if (1 == _swrun_init)
+        return;
+
+    _swrun_init = 1;
+
+    (void)netsnmp_swrun_container();
+    netsnmp_arch_swrun_init();
+    (void) netsnmp_swrun_cache();
+}
+
+void
+shutdown_swrun(void)
+{
+    DEBUGMSGTL(("swrun:access", "shutdown\n"));
+
+}
+
+int
+swrun_count_processes(int include_kthreads)
+{
+    netsnmp_swrun_entry *entry;
+    netsnmp_iterator  *it;
+    int i = 0;
+
+    netsnmp_cache_check_and_reload(swrun_cache);
+    if ( !swrun_container )
+        return 0;    /* or -1 */
+
+    if (include_kthreads)
+        return ( swrun_container ? CONTAINER_SIZE(swrun_container) : 0 );
+
+    it = CONTAINER_ITERATOR( swrun_container );
+    while ((entry = (netsnmp_swrun_entry*)ITERATOR_NEXT( it )) != NULL) {
+        if (4 == entry->hrSWRunType)
+            i++;
+    }
+    ITERATOR_RELEASE( it );
+
+    return i;
+}
+
+#ifndef NETSNMP_FEATURE_REMOVE_SWRUN_MAX_PROCESSES
+int
+swrun_max_processes( void )
+{
+    return _swrun_max;
+}
+#endif /* NETSNMP_FEATURE_REMOVE_SWRUN_MAX_PROCESSES */
+
+#ifndef NETSNMP_FEATURE_REMOVE_SWRUN_COUNT_PROCESSES_BY_REGEX
+#if HAVE_PCRE_H
+int
+swrun_count_processes_by_regex( char *name, netsnmp_regex_ptr regexp )
+{
+    netsnmp_swrun_entry *entry;
+    netsnmp_iterator  *it;
+    int i = 0;
+    int found_ndx[30];
+    int found;
+    char fullCommand[64 + 128 + 128 + 3];
+
+    netsnmp_cache_check_and_reload(swrun_cache);
+    if ( !swrun_container || !name || !regexp.regex_ptr )
+        return 0;    /* or -1 */
+
+    it = CONTAINER_ITERATOR( swrun_container );
+    while ((entry = (netsnmp_swrun_entry*)ITERATOR_NEXT( it )) != NULL) {
+        /* need to assemble full command back so regexps can get full picture */
+        sprintf(fullCommand, "%s %s", entry->hrSWRunPath, entry->hrSWRunParameters);
+        found = pcre_exec(regexp.regex_ptr, NULL, fullCommand, strlen(fullCommand), 0, 0, found_ndx, 30);
+        if (found > 0) {
+            i++;
+        }
+    }
+    ITERATOR_RELEASE( it );
+
+    return i;
+}
+#endif /* HAVE_PCRE_H */
+#endif /* NETSNMP_FEATURE_REMOVE_SWRUN_COUNT_PROCESSES_BY_REGEX */
+
+#ifndef NETSNMP_FEATURE_REMOVE_SWRUN_COUNT_PROCESSES_BY_NAME
+int
+swrun_count_processes_by_name( char *name )
+{
+    netsnmp_swrun_entry *entry;
+    netsnmp_iterator  *it;
+    int i = 0;
+
+    netsnmp_cache_check_and_reload(swrun_cache);
+    if ( !swrun_container || !name )
+        return 0;    /* or -1 */
+
+    it = CONTAINER_ITERATOR( swrun_container );
+    for (entry = (netsnmp_swrun_entry*)ITERATOR_FIRST( it );
+         entry;
+         entry = (netsnmp_swrun_entry*)ITERATOR_NEXT( it )) {
+        if (0 == strcmp( entry->hrSWRunName, name ))
+            i++;
+    }
+    ITERATOR_RELEASE( it );
+
+    return i;
+}
+#endif /* NETSNMP_FEATURE_REMOVE_SWRUN_COUNT_PROCESSES_BY_NAME */
+
+/**---------------------------------------------------------------------*/
+/*
+ * cache functions
+ */
+
+static int
+_cache_load( netsnmp_cache *cache,  void *magic )
+{
+    netsnmp_swrun_container_load( swrun_container, 0 );
+    return 0;
+}
+
+static void
+_cache_free( netsnmp_cache *cache,  void *magic )
+{
+    netsnmp_swrun_container_free_items( swrun_container );
+    return;
+}
+
+/**
+ * create swrun cache
+ */
+netsnmp_cache *
+netsnmp_swrun_cache(void)
+{
+    oid    hrSWRunTable_oid[]   = { 1, 3, 6, 1, 2, 1, 25, 4, 2 };
+    size_t hrSWRunTable_oid_len = OID_LENGTH(hrSWRunTable_oid);
+
+    if ( !swrun_cache ) {
+        swrun_cache = netsnmp_cache_create(30,   /* timeout in seconds */
+                           _cache_load,  _cache_free,
+                           hrSWRunTable_oid, hrSWRunTable_oid_len);
+        if (swrun_cache)
+            swrun_cache->flags = NETSNMP_CACHE_DONT_INVALIDATE_ON_SET;
+    }
+    return swrun_cache;
+}
+
+
+/**---------------------------------------------------------------------*/
+/*
+ * container functions
+ */
+/**
+ * create swrun container
+ */
+netsnmp_container *
+netsnmp_swrun_container(void)
+{
+    DEBUGMSGTL(("swrun:container", "init\n"));
+
+    /*
+     * create the container.
+     */
+  if (!swrun_container) {
+    swrun_container = netsnmp_container_find("swrun:table_container");
+    if (NULL == swrun_container)
+        return NULL;
+
+    swrun_container->container_name = strdup("swrun container");
+  }
+
+    return swrun_container;
+}
+
+/**
+ * load swrun information in specified container
+ *
+ * @param container empty container to be filled.
+ *                  pass NULL to have the function create one.
+ * @param load_flags flags to modify behaviour. Examples:
+ *                   NETSNMP_SWRUN_ALL_OR_NONE
+ *
+ * @retval NULL  error
+ * @retval !NULL pointer to container
+ */
+netsnmp_container*
+netsnmp_swrun_container_load(netsnmp_container* user_container, u_int load_flags)
+{
+    netsnmp_container* container = user_container;
+    int rc;
+
+    DEBUGMSGTL(("swrun:container:load", "load\n"));
+    netsnmp_assert(1 == _swrun_init);
+
+    if (NULL == container)
+        container = netsnmp_swrun_container();
+    if (NULL == container) {
+        snmp_log(LOG_ERR, "no container specified/found for swrun\n");
+        return NULL;
+    }
+
+    rc =  netsnmp_arch_swrun_container_load(container, load_flags);
+    if (0 != rc) {
+        if (NULL == user_container) {
+            netsnmp_swrun_container_free(container, NETSNMP_SWRUN_NOFLAGS);
+            container = NULL;
+        }
+        else if (load_flags & NETSNMP_SWRUN_ALL_OR_NONE) {
+            DEBUGMSGTL(("swrun:container:load",
+                        " discarding partial results\n"));
+            netsnmp_swrun_container_free_items(container);
+        }
+    }
+
+    return container;
+}
+
+void
+netsnmp_swrun_container_free(netsnmp_container *container, u_int free_flags)
+{
+    DEBUGMSGTL(("swrun:container", "free\n"));
+
+    if (NULL == container) {
+        snmp_log(LOG_ERR, "invalid container for netsnmp_swrun_container_free\n");
+        return;
+    }
+
+    if(! (free_flags & NETSNMP_SWRUN_DONT_FREE_ITEMS))
+        netsnmp_swrun_container_free_items(container);
+
+    CONTAINER_FREE(container);
+}
+
+void
+netsnmp_swrun_container_free_items(netsnmp_container *container)
+{
+    DEBUGMSGTL(("swrun:container", "free_items\n"));
+
+    if (NULL == container) {
+        snmp_log(LOG_ERR, "invalid container for netsnmp_swrun_container_free_items\n");
+        return;
+    }
+
+    /*
+     * free all items.
+     */
+    CONTAINER_CLEAR(container,
+                    (netsnmp_container_obj_func*)_swrun_entry_release,
+                    NULL);
+}
+
+/**---------------------------------------------------------------------*/
+/*
+ * swrun_entry functions
+ */
+/**
+ */
+netsnmp_swrun_entry *
+netsnmp_swrun_entry_get_by_index(netsnmp_container *container, oid index)
+{
+    netsnmp_index   tmp;
+
+    DEBUGMSGTL(("swrun:entry", "by_index\n"));
+    netsnmp_assert(1 == _swrun_init);
+
+    if (NULL == container) {
+        snmp_log(LOG_ERR,
+                 "invalid container for netsnmp_swrun_entry_get_by_index\n");
+        return NULL;
+    }
+
+    tmp.len = 1;
+    tmp.oids = &index;
+
+    return (netsnmp_swrun_entry *) CONTAINER_FIND(container, &tmp);
+}
+
+/**
+ */
+netsnmp_swrun_entry *
+netsnmp_swrun_entry_create(int32_t index)
+{
+    netsnmp_swrun_entry *entry =
+        SNMP_MALLOC_TYPEDEF(netsnmp_swrun_entry);
+
+    if(NULL == entry)
+        return NULL;
+
+    entry->hrSWRunIndex = index;
+    entry->hrSWRunType = 1; /* unknown */
+    entry->hrSWRunStatus = 2; /* runnable */
+
+    entry->oid_index.len = 1;
+    entry->oid_index.oids = (oid *) & entry->hrSWRunIndex;
+
+    return entry;
+}
+
+/**
+ */
+NETSNMP_INLINE void
+netsnmp_swrun_entry_free(netsnmp_swrun_entry * entry)
+{
+    if (NULL == entry)
+        return;
+
+    /*
+     * SNMP_FREE not needed, for any of these, 
+     * since the whole entry is about to be freed
+     */
+    free(entry);
+}
+
+/**---------------------------------------------------------------------*/
+/*
+ * Utility routines
+ */
+
+/**
+ */
+static void
+_swrun_entry_release(netsnmp_swrun_entry * entry, void *context)
+{
+    netsnmp_swrun_entry_free(entry);
+}
+
+
+#ifdef TEST
+int main(int argc, char *argv[])
+{
+    const char *tokens = getenv("SNMP_DEBUG");
+
+    netsnmp_container_init_list();
+
+    /** swrun,verbose:swrun,9:swrun,8:swrun,5:swrun */
+    if (tokens)
+        debug_register_tokens(tokens);
+    else
+        debug_register_tokens("swrun");
+    snmp_set_do_debugging(1);
+
+    init_swrun();
+    netsnmp_swrun_container_load(NULL, 0);
+    shutdown_swrun();
+
+    return 0;
+}
+#endif
Index: create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup/host/data_access
===================================================================
--- create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup/host/data_access	(nonexistent)
+++ create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup/host/data_access	(revision 5)

Property changes on: create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup/host/data_access
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup/host
===================================================================
--- create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup/host	(nonexistent)
+++ create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup/host	(revision 5)

Property changes on: create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup/host
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup
===================================================================
--- create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup	(nonexistent)
+++ create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup	(revision 5)

Property changes on: create-5.9-iterator-patch/net-snmp-5.9-new/agent/mibgroup
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-iterator-patch/net-snmp-5.9-new/agent
===================================================================
--- create-5.9-iterator-patch/net-snmp-5.9-new/agent	(nonexistent)
+++ create-5.9-iterator-patch/net-snmp-5.9-new/agent	(revision 5)

Property changes on: create-5.9-iterator-patch/net-snmp-5.9-new/agent
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-iterator-patch/net-snmp-5.9-new
===================================================================
--- create-5.9-iterator-patch/net-snmp-5.9-new	(nonexistent)
+++ create-5.9-iterator-patch/net-snmp-5.9-new	(revision 5)

Property changes on: create-5.9-iterator-patch/net-snmp-5.9-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-iterator-patch
===================================================================
--- create-5.9-iterator-patch	(nonexistent)
+++ create-5.9-iterator-patch	(revision 5)

Property changes on: create-5.9-iterator-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-modern-rpm-api-patch/create.patch.sh
===================================================================
--- create-5.9-modern-rpm-api-patch/create.patch.sh	(nonexistent)
+++ create-5.9-modern-rpm-api-patch/create.patch.sh	(revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=5.9
+
+tar --files-from=file.list -xzvf ../net-snmp-$VERSION.tar.gz
+mv net-snmp-$VERSION net-snmp-$VERSION-orig
+
+cp -rf ./net-snmp-$VERSION-new ./net-snmp-$VERSION
+
+diff --unified -Nr  net-snmp-$VERSION-orig  net-snmp-$VERSION > net-snmp-$VERSION-modern-rpm-api.patch
+
+mv net-snmp-$VERSION-modern-rpm-api.patch ../patches
+
+rm -rf ./net-snmp-$VERSION
+rm -rf ./net-snmp-$VERSION-orig

Property changes on: create-5.9-modern-rpm-api-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-5.9-modern-rpm-api-patch/file.list
===================================================================
--- create-5.9-modern-rpm-api-patch/file.list	(nonexistent)
+++ create-5.9-modern-rpm-api-patch/file.list	(revision 5)
@@ -0,0 +1,2 @@
+net-snmp-5.9/agent/mibgroup/host/data_access/swinst_rpm.c
+net-snmp-5.9/agent/mibgroup/host/hr_swinst.c
Index: create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup/host/data_access/swinst_rpm.c
===================================================================
--- create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup/host/data_access/swinst_rpm.c	(nonexistent)
+++ create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup/host/data_access/swinst_rpm.c	(revision 5)
@@ -0,0 +1,195 @@
+/*
+ * swinst_rpm.c:
+ *     hrSWInstalledTable data access:
+ */
+#include <net-snmp/net-snmp-config.h>
+#include <net-snmp/net-snmp-features.h>
+
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#else
+#include <strings.h>
+#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#ifdef HAVE_RPM_RPMLIB_H
+#include <rpm/rpmlib.h>
+#endif
+#ifdef HAVE_RPM_RPMLIB_H
+#include <rpm/header.h>
+#endif
+#ifdef HAVE_RPMGETPATH		/* HAVE_RPM_RPMMACRO_H */
+#include <rpm/rpmmacro.h>
+#endif
+#ifdef HAVE_RPM_RPMTS_H
+#include <rpm/rpmts.h>
+#include <rpm/rpmdb.h>
+#endif
+
+#include <net-snmp/net-snmp-includes.h>
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+#include <net-snmp/library/container.h>
+#include <net-snmp/library/snmp_debug.h>
+#include <net-snmp/data_access/swinst.h>
+#include "swinst_private.h"
+
+netsnmp_feature_require(date_n_time);
+
+   /*
+    * Location of RPM package directory.
+    * Used for:
+    *    - reporting hrSWInstalledLast* objects
+    *    - detecting when the cached contents are out of date.
+    */
+char pkg_directory[SNMP_MAXPATH];
+
+/* ---------------------------------------------------------------------
+ */
+void
+netsnmp_swinst_arch_init(void)
+{
+    char        *rpmdbpath = NULL;
+    const char  *dbpath;
+    struct stat  stat_buf;
+
+#ifdef HAVE_RPMGETPATH
+    rpmReadConfigFiles( NULL, NULL );
+    rpmdbpath = rpmGetPath( "%{_dbpath}", NULL );
+    dbpath = rpmdbpath;
+#else
+    dbpath = "/var/lib/rpm";   /* Most likely */
+#endif
+
+    snprintf( pkg_directory, SNMP_MAXPATH, "%s/Packages", dbpath );
+    SNMP_FREE(rpmdbpath);
+    dbpath = NULL;
+    if (-1 == stat( pkg_directory, &stat_buf )) {
+        snmp_log(LOG_ERR, "Can't find directory of RPM packages");
+        pkg_directory[0] = '\0';
+    }
+}
+
+void
+netsnmp_swinst_arch_shutdown(void)
+{
+     /* Nothing to do */
+     return;
+}
+
+/* ---------------------------------------------------------------------
+ */
+int
+netsnmp_swinst_arch_load( netsnmp_container *container, u_int flags)
+{
+    rpmts                 ts;
+
+    rpmdbMatchIterator    mi;
+    Header                h;
+#if HAVE_HEADERGET
+    const char           *g;
+    rpmtd                 td_name, td_version, td_release, td_group, td_time;
+#else
+    char                 *n, *v, *r, *g;
+#endif
+    time_t                install_time;
+    size_t                date_len;
+    int                   i = 1;
+    netsnmp_swinst_entry *entry;
+
+#if HAVE_HEADERGET
+    td_name = rpmtdNew();
+    td_version = rpmtdNew();
+    td_release = rpmtdNew();
+    td_group = rpmtdNew();
+    td_time = rpmtdNew();
+#endif
+    ts = rpmtsCreate();
+    rpmtsSetVSFlags( ts, (_RPMVSF_NOSIGNATURES|_RPMVSF_NODIGESTS));
+
+    mi = rpmtsInitIterator( ts, RPMDBI_PACKAGES, NULL, 0);
+    if (mi == NULL)
+	NETSNMP_LOGONCE((LOG_ERR, "rpmdbOpen() failed\n"));
+
+    while (NULL != (h = rpmdbNextIterator( mi )))
+    {
+        const u_char *dt;
+
+        entry = netsnmp_swinst_entry_create( i++ );
+        if (NULL == entry)
+            continue;   /* error already logged by function */
+        CONTAINER_INSERT(container, entry);
+
+        h = headerLink( h );
+#if HAVE_HEADERGET
+        headerGet(h, RPMTAG_NAME, td_name, HEADERGET_EXT);
+        headerGet(h, RPMTAG_VERSION, td_version, HEADERGET_EXT);
+        headerGet(h, RPMTAG_RELEASE, td_release, HEADERGET_EXT);
+        headerGet(h, RPMTAG_GROUP, td_group, HEADERGET_EXT);
+        headerGet(h, RPMTAG_INSTALLTIME, td_time, HEADERGET_EXT);
+        entry->swName_len = snprintf( entry->swName, sizeof(entry->swName),
+                                      "%s-%s-%s", rpmtdGetString(td_name),
+                                      rpmtdGetString(td_version),
+                                      rpmtdGetString(td_release));
+        install_time = rpmtdGetNumber(td_time);
+        g = rpmtdGetString(td_group);
+#else
+        n = headerGetString( h, RPMTAG_NAME);
+        v = headerGetString( h, RPMTAG_VERSION);
+        r = headerGetString( h, RPMTAG_RELEASE);
+        g = headerGetString( h, RPMTAG_GROUP);
+        install_time = headerGetNumber( h, RPMTAG_INSTALLTIME);
+        entry->swName_len = snprintf( entry->swName, sizeof(entry->swName),
+                                      "%s-%s-%s", n, v, r);
+#endif
+        entry->swType = (g && NULL != strstr( g, "System Environment"))
+                        ? 2      /* operatingSystem */
+                        : 4;     /*  application    */
+        if (entry->swName_len > sizeof(entry->swName))
+            entry->swName_len = sizeof(entry->swName);
+
+        dt = date_n_time( &install_time, &date_len );
+        if (date_len != 8 && date_len != 11) {
+            snmp_log(LOG_ERR, "Bogus length from date_n_time for %s", entry->swName);
+            entry->swDate_len = 0;
+        }
+        else {
+            entry->swDate_len = date_len;
+            memcpy(entry->swDate, dt, entry->swDate_len);
+        }
+
+#if HAVE_HEADERGET
+        rpmtdFreeData(td_name);
+        rpmtdFreeData(td_version);
+        rpmtdFreeData(td_release);
+        rpmtdFreeData(td_group);
+        rpmtdFreeData(td_time);
+#endif
+        headerFree( h );
+    }
+    rpmdbFreeIterator( mi );
+    rpmtsFree( ts );
+#if HAVE_HEADERGET
+    rpmtdFree(td_name);
+    rpmtdFree(td_version);
+    rpmtdFree(td_release);
+    rpmtdFree(td_group);
+    rpmtdFree(td_time);
+#endif
+
+    DEBUGMSGTL(("swinst:load:arch", "loaded %d entries\n",
+                (int)CONTAINER_SIZE(container)));
+
+    return 0;
+}
Index: create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup/host/data_access
===================================================================
--- create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup/host/data_access	(nonexistent)
+++ create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup/host/data_access	(revision 5)

Property changes on: create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup/host/data_access
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup/host/hr_swinst.c
===================================================================
--- create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup/host/hr_swinst.c	(nonexistent)
+++ create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup/host/hr_swinst.c	(revision 5)
@@ -0,0 +1,731 @@
+/*
+ *  Host Resources MIB - Installed Software group implementation - hr_swinst.c
+ *
+ */
+
+#include <net-snmp/net-snmp-config.h>
+#include <net-snmp/net-snmp-features.h>
+
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#include <sys/stat.h>
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+#if HAVE_DIRENT_H
+#include <dirent.h>
+#else
+# define dirent direct
+# if HAVE_SYS_NDIR_H
+#  include <sys/ndir.h>
+# endif
+# if HAVE_SYS_DIR_H
+#  include <sys/dir.h>
+# endif
+# if HAVE_NDIR_H
+#  include <ndir.h>
+# endif
+#endif
+#ifdef HAVE_PKGLOCS_H
+#include <pkglocs.h>
+#endif
+#ifdef HAVE_PKGINFO_H
+#include <pkginfo.h>
+#endif
+
+#ifdef HAVE_LIBRPM
+#include <rpm/rpmlib.h>
+#include <rpm/header.h>
+#include <fcntl.h>
+
+#ifdef HAVE_RPM_RPMFILEUTIL_H
+#include <rpm/rpmfileutil.h>
+#endif
+
+#ifdef HAVE_RPMGETPATH
+#include <rpm/rpmmacro.h>
+#endif
+
+#ifdef HAVE_RPM_RPMTS_H
+#include <rpm/rpmts.h>
+#include <rpm/rpmdb.h>
+#endif
+#endif
+
+#if HAVE_STRING_H
+#include <string.h>
+#else
+#include <strings.h>
+#endif
+
+#include "host_res.h"
+#include "hr_swinst.h"
+#include <net-snmp/utilities.h>
+
+#define HRSWINST_MONOTONICALLY_INCREASING
+
+netsnmp_feature_require(date_n_time);
+
+        /*********************
+	 *
+	 *  Kernel & interface information,
+	 *   and internal forward declarations
+	 *
+	 *********************/
+
+/*
+ * Reorganize the global data into a single static structure.
+ *
+ *      Old                     New
+ *======================================================
+ *      HRSW_directory          swi->swi_directory
+ *      HRSW_name[100]          swi->swi_name[SNMP_MAXPATH]
+ *      HRSW_index              swi->swi_index
+ *
+ *                              swi->swi_dbpath         (RPM only)
+ *                              swi->swi_maxrec         (RPM only)
+ *                              swi->swi_nrec           (RPM only)
+ *                              swi->swi_recs           (RPM only)
+ *      rpm_db                  swi->swi_rpmdb          (RPM only)
+ *                              swi->swi_h              (RPM only)
+ *                              swi->swi_prevx          (RPM only)
+ *
+ *      dp                      swi->swi_dp
+ *      de_p                    swi->swi_dep
+ */
+typedef struct {
+#if HAVE_LIBRPM
+    char           *swi_directory;
+#else
+    const char     *swi_directory;
+#endif
+    char            swi_name[SNMP_MAXPATH];     /* XXX longest file name */
+    int             swi_index;
+
+#if HAVE_LIBRPM
+    const char     *swi_dbpath;
+
+    time_t          swi_timestamp;      /* modify time on database */
+    int             swi_maxrec; /* no. of allocations */
+    int             swi_nrec;   /* no. of valid offsets */
+    int            *swi_recs;   /* db record offsets */
+    rpmts           swi_rpmts;
+    Header          swi_h;
+    int             swi_prevx;
+#else
+    DIR            *swi_dp;
+    struct dirent  *swi_dep;
+#endif
+
+} SWI_t;
+
+static SWI_t    _myswi = { NULL, "", 0 };       /* XXX static for now */
+
+int             header_hrswinst(struct variable *, oid *, size_t *, int,
+                                size_t *, WriteMethod **);
+int             header_hrswInstEntry(struct variable *, oid *, size_t *,
+                                     int, size_t *, WriteMethod **);
+
+#define starttime (*(const struct timeval*)netsnmp_get_agent_starttime())
+
+        /*********************
+	 *
+	 *  Initialisation & common implementation functions
+	 *
+	 *********************/
+static void     Init_HR_SWInst(void);
+static int      Get_Next_HR_SWInst(void);
+static void     End_HR_SWInst(void);
+static int      Save_HR_SW_info(int ix);
+
+static void     Mark_HRSW_token(void);
+static void     Release_HRSW_token(void);
+
+
+#define	HRSWINST_CHANGE		1
+#define	HRSWINST_UPDATE		2
+#define	HRSWINST_INDEX		3
+#define	HRSWINST_NAME		4
+#define	HRSWINST_ID		5
+#define	HRSWINST_TYPE		6
+#define	HRSWINST_DATE		7
+
+struct variable4 hrswinst_variables[] = {
+    {HRSWINST_CHANGE, ASN_TIMETICKS, NETSNMP_OLDAPI_RONLY,
+     var_hrswinst, 1, {1}},
+    {HRSWINST_UPDATE, ASN_TIMETICKS, NETSNMP_OLDAPI_RONLY,
+     var_hrswinst, 1, {2}},
+    {HRSWINST_INDEX, ASN_INTEGER, NETSNMP_OLDAPI_RONLY,
+     var_hrswinst, 3, {3, 1, 1}},
+    {HRSWINST_NAME, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY,
+     var_hrswinst, 3, {3, 1, 2}},
+    {HRSWINST_ID, ASN_OBJECT_ID, NETSNMP_OLDAPI_RONLY,
+     var_hrswinst, 3, {3, 1, 3}},
+    {HRSWINST_TYPE, ASN_INTEGER, NETSNMP_OLDAPI_RONLY,
+     var_hrswinst, 3, {3, 1, 4}},
+    {HRSWINST_DATE, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY,
+     var_hrswinst, 3, {3, 1, 5}}
+};
+oid             hrswinst_variables_oid[] = { 1, 3, 6, 1, 2, 1, 25, 6 };
+
+
+#ifdef PKGLOC                   /* Description from HRSW_dir/.../pkginfo: DESC= */
+#define	_PATH_HRSW_directory	PKGLOC
+#endif
+#ifdef hpux9                    /* Description from HRSW_dir/.../index:   fd: */
+#define	_PATH_HRSW_directory	"/system"
+#endif
+#ifdef hpux10                   /* Description from HRSW_dir/.../pfiles/INDEX: title */
+#define	_PATH_HRSW_directory	"/var/adm/sw/products"
+#endif
+#ifdef hpux11                   /* Description from HRSW_dir/.../pfiles/INDEX: title */
+#define	_PATH_HRSW_directory	"/var/adm/sw/products"
+#endif
+#ifdef freebsd2
+#define	_PATH_HRSW_directory	"/var/db/pkg"
+#endif
+#if defined(linux) && !defined(HAVE_LIBRPM)
+#define	_PATH_HRSW_directory	"/var/cache/hrmib"
+#endif
+
+void
+init_hr_swinst(void)
+{
+#if defined(HAVE_LIBRPM) || defined(_PATH_HRSW_directory)
+    SWI_t          *swi = &_myswi;      /* XXX static for now */
+#endif
+#ifdef HAVE_LIBRPM
+    struct stat     stat_buf;
+#endif
+
+    /*
+     * Read settings from config file,
+     * or take system-specific defaults 
+     */
+
+#ifdef HAVE_LIBRPM
+    if (swi->swi_directory == NULL) {
+        char            path[SNMP_MAXPATH];
+
+        /*
+         * XXX distinguish between rpm-2.5.x and rpm-2.9x 
+         */
+#ifdef HAVE_RPMGETPATH
+        rpmReadConfigFiles(NULL, NULL);
+        swi->swi_dbpath = rpmGetPath("%{_dbpath}", NULL);
+#else
+        swi->swi_dbpath = "/var/lib/rpm";  /* Most likely */
+#endif
+        if (swi->swi_directory != NULL)
+            free(swi->swi_directory);
+        snprintf(path, sizeof(path), "%s/Packages", swi->swi_dbpath);
+        if (stat(path, &stat_buf) == -1)
+            snprintf(path, sizeof(path), "%s/packages.rpm", swi->swi_dbpath);
+        path[ sizeof(path)-1 ] = 0;
+        swi->swi_directory = strdup(path);
+    }
+#else
+#  ifdef _PATH_HRSW_directory
+    if (swi->swi_directory == NULL) {
+        swi->swi_directory = _PATH_HRSW_directory;
+    }
+    strcpy(swi->swi_name, "[installed name]");  /* default name */
+#  else
+    /*
+     * XXX SunOS4 package directory is ?? -MJS 
+     */
+    return;                     /* packages not known - don't register */
+#  endif
+#endif
+
+    REGISTER_MIB("host/hr_swinst", hrswinst_variables, variable4,
+                 hrswinst_variables_oid);
+}
+
+/*
+ * header_hrswinst(...
+ * Arguments:
+ * vp     IN      - pointer to variable entry that points here
+ * name    IN/OUT  - IN/name requested, OUT/name found
+ * length  IN/OUT  - length of IN/OUT oid's 
+ * exact   IN      - TRUE if an exact match was requested
+ * var_len OUT     - length of variable or 0 if function returned
+ * write_method
+ */
+
+int
+header_hrswinst(struct variable *vp,
+                oid * name,
+                size_t * length,
+                int exact, size_t * var_len, WriteMethod ** write_method)
+{
+#define HRSWINST_NAME_LENGTH	9
+    oid             newname[MAX_OID_LEN];
+    int             result;
+
+    DEBUGMSGTL(("host/hr_swinst", "var_hrswinst: "));
+    DEBUGMSGOID(("host/hr_swinst", name, *length));
+    DEBUGMSG(("host/hr_swinst", " %d\n", exact));
+
+    memcpy((char *) newname, (char *) vp->name, vp->namelen * sizeof(oid));
+    newname[HRSWINST_NAME_LENGTH] = 0;
+    result = snmp_oid_compare(name, *length, newname, vp->namelen + 1);
+    if ((exact && (result != 0)) || (!exact && (result >= 0)))
+        return (MATCH_FAILED);
+    memcpy((char *) name, (char *) newname,
+           (vp->namelen + 1) * sizeof(oid));
+    *length = vp->namelen + 1;
+
+    *write_method = (WriteMethod*)0;
+    *var_len = sizeof(long);    /* default to 'long' results */
+    return (MATCH_SUCCEEDED);
+}
+
+int
+header_hrswInstEntry(struct variable *vp,
+                     oid * name,
+                     size_t * length,
+                     int exact,
+                     size_t * var_len, WriteMethod ** write_method)
+{
+#define HRSWINST_ENTRY_NAME_LENGTH	11
+    oid             newname[MAX_OID_LEN];
+    int             swinst_idx, LowIndex = -1;
+    int             result;
+    int             err = 0, errcount = 0;
+
+    DEBUGMSGTL(("host/hr_swinst", "var_hrswinstEntry: "));
+    DEBUGMSGOID(("host/hr_swinst", name, *length));
+    DEBUGMSG(("host/hr_swinst", " %d\n", exact));
+
+    memcpy((char *) newname, (char *) vp->name, vp->namelen * sizeof(oid));
+    /*
+     * Find "next" installed software entry 
+     */
+
+    do {
+        Init_HR_SWInst();
+        while ((swinst_idx = Get_Next_HR_SWInst()) != -1) {
+            DEBUGMSG(("host/hr_swinst", "(index %d ....", swinst_idx));
+
+            newname[HRSWINST_ENTRY_NAME_LENGTH] = swinst_idx;
+            DEBUGMSGOID(("host/hr_swinst", newname, *length));
+            DEBUGMSG(("host/hr_swinst", "\n"));
+            result = snmp_oid_compare(name, *length, newname, vp->namelen + 1);
+            if (exact && (result == 0)) {
+                LowIndex = swinst_idx;
+                err = Save_HR_SW_info(LowIndex);
+                break;
+            }
+            if ((!exact && (result < 0)) &&
+                (LowIndex == -1 || swinst_idx < LowIndex)) {
+                LowIndex = swinst_idx;
+                err = Save_HR_SW_info(LowIndex);
+#ifdef HRSWINST_MONOTONICALLY_INCREASING
+                break;
+#endif
+            }
+        }
+        if (err != 0 )
+            errcount++;
+    /* restart until Save_HR_SW_info() succeeds,max. 3 times */
+    } while (err != 0 && errcount < 3); 
+    if (err != 0) {
+        DEBUGMSGTL(("host/hr_swinst", "restart did not help, bailing out\n"));
+        return (MATCH_FAILED);
+    }
+	    
+    Mark_HRSW_token();
+    End_HR_SWInst();
+
+    if (LowIndex == -1) {
+        DEBUGMSGTL(("host/hr_swinst", "... index out of range\n"));
+        return (MATCH_FAILED);
+    }
+
+    memcpy((char *) name, (char *) newname,
+           (vp->namelen + 1) * sizeof(oid));
+    *length = vp->namelen + 1;
+    *write_method = (WriteMethod*)0;
+    *var_len = sizeof(long);    /* default to 'long' results */
+
+    DEBUGMSGTL(("host/hr_inst", "... get installed S/W stats "));
+    DEBUGMSGOID(("host/hr_inst", name, *length));
+    DEBUGMSG(("host/hr_inst", "\n"));
+    return LowIndex;
+}
+
+        /*********************
+	 *
+	 *  System specific implementation functions
+	 *
+	 *********************/
+
+
+u_char         *
+var_hrswinst(struct variable * vp,
+             oid * name,
+             size_t * length,
+             int exact, size_t * var_len, WriteMethod ** write_method)
+{
+    SWI_t          *swi = &_myswi;      /* XXX static for now */
+    int             sw_idx = 0;
+    static char     string[SNMP_MAXPATH];
+    u_char         *ret = NULL;
+    struct stat     stat_buf;
+
+    if (vp->magic < HRSWINST_INDEX) {
+        if (header_hrswinst(vp, name, length, exact, var_len, write_method)
+            == MATCH_FAILED)
+            return NULL;
+    } else {
+
+        sw_idx =
+            header_hrswInstEntry(vp, name, length, exact, var_len,
+                                 write_method);
+        if (sw_idx == MATCH_FAILED)
+            return NULL;
+    }
+
+    switch (vp->magic) {
+    case HRSWINST_CHANGE:
+    case HRSWINST_UPDATE:
+        string[0] = '\0';
+
+        if (swi->swi_directory != NULL)
+            strlcpy(string, swi->swi_directory, sizeof(string));
+
+        if (*string && (stat(string, &stat_buf) != -1)) {
+            if (stat_buf.st_mtime > starttime.tv_sec)
+                /*
+                 * changed 'recently' - i.e. since this agent started 
+                 */
+                long_return = (stat_buf.st_mtime - starttime.tv_sec) * 100;
+            else
+                long_return = 0;        /* predates this agent */
+        } else
+#if NETSNMP_NO_DUMMY_VALUES
+            return NULL;
+#else
+            long_return = 363136200;
+#endif
+        ret = (u_char *) & long_return;
+        break;
+
+    case HRSWINST_INDEX:
+        long_return = sw_idx;
+        ret = (u_char *) & long_return;
+        break;
+    case HRSWINST_NAME:
+        {
+#ifdef HAVE_PKGINFO
+            char *pver;
+# endif
+            strlcpy(string, swi->swi_name, sizeof(string));
+
+/* If we are on a solaris machine, the package names do not include versioning info,
+ * so we must add it manually
+ */
+#ifdef HAVE_PKGINFO
+            pver = pkgparam(swi->swi_name, "VERSION");
+            /* 1 spot for the terminating null and one for the dash */
+            if (pver && 
+               (strlen(pver) + 2 + strlen(string) <= sizeof(string))) {
+                strcat(string, "-");
+                strcat(string, pver);
+            }
+# endif
+
+            /*
+             * This will be unchanged from the initial "null"
+             * value, if swi->swi_name is not defined 
+             */
+            string[sizeof(string) - 1] = '\0';
+            *var_len = strlen(string);
+            ret = (u_char *) string;
+        }
+        break;
+    case HRSWINST_ID:
+        *var_len = nullOidLen;
+        ret = (u_char *) nullOid;
+        break;
+    case HRSWINST_TYPE:
+        {
+#ifdef HAVE_PKGINFO
+            /*
+             * at least on solaris2 this works 
+             */
+            char           *catg = pkgparam(swi->swi_name, "CATEGORY");
+
+            if (catg == NULL) {
+                long_return = 1;        /*  unknown  */
+            } else {
+                if (strstr(catg, "system") != NULL) {
+                    long_return = 2;    /*  operatingSystem  */
+                } else if (strstr(catg, "application") != NULL) {
+                    long_return = 4;    /*  applcation  */
+                } else {
+                    long_return = 1;    /*  unknown  */
+                }
+                free(catg);
+            }
+#else
+# ifdef HAVE_LIBRPM
+            const char *rpm_group = headerGetString(swi->swi_h, RPMTAG_GROUP);	
+            if ( NULL != rpm_group ) {
+                if ( strstr(rpm_group, "System Environment") != NULL )
+                    long_return = 2;	/* operatingSystem */
+                else
+                    long_return = 4;	/* applcation */
+            } else {
+                long_return = 1;    /* unknown */
+            }
+# else
+            long_return = 1;    /* unknown */
+# endif
+#endif
+            ret = (u_char *) & long_return;
+        }
+        break;
+    case HRSWINST_DATE:
+        {
+#ifdef HAVE_LIBRPM
+            time_t installTime = headerGetNumber(swi->swi_h, RPMTAG_INSTALLTIME);
+            if ( 0 != installTime ) {
+                ret = date_n_time(&installTime, var_len);
+            } else {
+                ret = date_n_time(NULL, var_len);
+            }
+#else
+            if (swi->swi_directory != NULL) {
+                snprintf(string, sizeof(string), "%s/%s",
+                         swi->swi_directory, swi->swi_name);
+                string[ sizeof(string)-1 ] = 0;
+                if (stat(string, &stat_buf) >= 0)
+                    ret = date_n_time(&stat_buf.st_mtime, var_len);
+                else
+                    goto err;
+            } else {
+err:
+#if NETSNMP_NO_DUMMY_VALUES
+                ret = NULL;
+#else
+                sprintf(string, "back in the mists of time");
+                *var_len = strlen(string);
+                ret = (u_char *) string;
+#endif
+            }
+#endif
+        }
+        break;
+    default:
+        DEBUGMSGTL(("snmpd", "unknown sub-id %d in var_hrswinst\n",
+                    vp->magic));
+        ret = NULL;
+        break;
+    }
+    Release_HRSW_token();
+    return ret;
+}
+
+
+        /*********************
+	 *
+	 *  Internal implementation functions
+	 *
+	 *********************/
+
+#ifdef	HAVE_LIBRPM
+static void
+Check_HRSW_cache(void *xxx)
+{
+    SWI_t          *swi = (SWI_t *) xxx;
+
+    /*
+     * Make sure cache is up-to-date 
+     */
+    if (swi->swi_recs != NULL) {
+        struct stat     sb;
+        lstat(swi->swi_directory, &sb);
+        if (swi->swi_timestamp == sb.st_mtime)
+            return;
+        swi->swi_timestamp = sb.st_mtime;
+        swi->swi_maxrec = 0;
+    }
+
+    /*
+     * Get header offsets 
+     */
+    {
+        int             ix = 0;
+        int             offset;
+
+        rpmdbMatchIterator mi = NULL;
+        Header          h;
+        mi = rpmtsInitIterator(swi->swi_rpmts, RPMDBI_PACKAGES, NULL, 0);
+        while ((h = rpmdbNextIterator(mi)) != NULL) {
+            offset = rpmdbGetIteratorOffset(mi);
+
+            if (ix >= swi->swi_maxrec) {
+                swi->swi_maxrec += 256;
+                swi->swi_recs = (swi->swi_recs == NULL)
+                    ? (int *) malloc(swi->swi_maxrec * sizeof(int))
+                    : (int *) realloc(swi->swi_recs,
+                                      swi->swi_maxrec * sizeof(int));
+            }
+            swi->swi_recs[ix++] = offset;
+        }
+        rpmdbFreeIterator(mi);
+
+        swi->swi_nrec = ix;
+    }
+}
+#endif                          /* HAVE_LIBRPM */
+
+void
+Init_HR_SWInst(void)
+{
+    SWI_t          *swi = &_myswi;      /* XXX static for now */
+    swi->swi_index = 0;
+
+#ifdef HAVE_LIBRPM
+    if (swi->swi_rpmts != NULL)
+        return;
+    swi->swi_rpmts = rpmtsCreate();
+    rpmtsSetVSFlags( swi->swi_rpmts, (_RPMVSF_NOSIGNATURES|_RPMVSF_NODIGESTS));
+    Check_HRSW_cache(swi);
+#else
+    if (swi->swi_directory != NULL) {
+        if (swi->swi_dp != NULL) {
+            closedir(swi->swi_dp);
+            swi->swi_dp = NULL;
+        }
+        if ((swi->swi_dp = opendir(swi->swi_directory)) == NULL)
+            swi->swi_index = -1;
+    } else
+        swi->swi_index = -1;
+#endif
+}
+
+int
+Get_Next_HR_SWInst(void)
+{
+    SWI_t          *swi = &_myswi;      /* XXX static for now */
+
+    if (swi->swi_index == -1)
+        return -1;
+
+#ifdef HAVE_LIBRPM
+    /*
+     * XXX Watchout: index starts with 1 
+     */
+    if (0 <= swi->swi_index && swi->swi_index < swi->swi_nrec)
+        return ++swi->swi_index;
+#else
+    if (swi->swi_directory != NULL) {
+        while ((swi->swi_dep = readdir(swi->swi_dp)) != NULL) {
+            if (swi->swi_dep->d_name[0] == '.')
+                continue;
+
+            /*
+             * Ought to check for "properly-formed" entry 
+             */
+
+            return ++swi->swi_index;
+        }
+    }
+#endif
+
+    return -1;
+}
+
+int
+Save_HR_SW_info(int ix)
+{
+    SWI_t          *swi = &_myswi;      /* XXX static for now */
+
+#ifdef HAVE_LIBRPM
+    /*
+     * XXX Watchout: ix starts with 1 
+     */
+    if (1 <= ix && ix <= swi->swi_nrec && ix != swi->swi_prevx) {
+        int             offset;
+        Header          h;
+        const char     *n, *v, *r;
+
+        offset = swi->swi_recs[ix - 1];
+
+        {
+            rpmdbMatchIterator mi;
+            mi = rpmtsInitIterator(swi->swi_rpmts, RPMDBI_PACKAGES,
+                                   &offset, sizeof(offset));
+            if ((h = rpmdbNextIterator(mi)) != NULL)
+                h = headerLink(h);
+            rpmdbFreeIterator(mi);
+        }
+
+        if (h == NULL) {
+            DEBUGMSGTL(("host/hr_swinst",
+                    "RPM cache has probably expired when reading entry %d, "
+                    "reloading...\n", ix));
+            swi->swi_timestamp = 0;
+            return -1;
+        }
+        if (swi->swi_h != NULL)
+            headerFree(swi->swi_h);
+        swi->swi_h = h;
+        swi->swi_prevx = ix;
+
+        n = headerGetString(swi->swi_h, RPMTAG_NAME);
+        v = headerGetString(swi->swi_h, RPMTAG_VERSION);
+        r = headerGetString(swi->swi_h, RPMTAG_RELEASE);
+        snprintf(swi->swi_name, sizeof(swi->swi_name), "%s-%s-%s", n, v, r);
+        swi->swi_name[ sizeof(swi->swi_name)-1 ] = 0;
+    }
+#else
+    snprintf(swi->swi_name, sizeof(swi->swi_name), "%s", swi->swi_dep->d_name);
+    swi->swi_name[ sizeof(swi->swi_name)-1 ] = 0;
+#endif
+    return 0;
+}
+
+void
+Mark_HRSW_token(void)
+{
+}
+
+void
+Release_HRSW_token(void)
+{
+#ifdef	HAVE_LIBRPM
+    SWI_t          *swi = &_myswi;      /* XXX static for now */
+    if (swi != NULL && swi->swi_h) {
+        headerFree(swi->swi_h);
+        swi->swi_h = NULL;
+        swi->swi_prevx = -1;
+    }
+#endif                          /* HAVE_LIBRPM */
+}
+
+void
+End_HR_SWInst(void)
+{
+    SWI_t          *swi = &_myswi;      /* XXX static for now */
+
+#ifdef HAVE_LIBRPM
+    rpmtsFree(swi->swi_rpmts); /* or only on finishing ? */
+    swi->swi_rpmts = NULL;
+#else
+    if (swi->swi_dp != NULL)
+        closedir(swi->swi_dp);
+    swi->swi_dp = NULL;
+#endif
+}
Index: create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup/host
===================================================================
--- create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup/host	(nonexistent)
+++ create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup/host	(revision 5)

Property changes on: create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup/host
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup
===================================================================
--- create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup	(nonexistent)
+++ create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup	(revision 5)

Property changes on: create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent/mibgroup
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent
===================================================================
--- create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent	(nonexistent)
+++ create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent	(revision 5)

Property changes on: create-5.9-modern-rpm-api-patch/net-snmp-5.9-new/agent
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-modern-rpm-api-patch/net-snmp-5.9-new
===================================================================
--- create-5.9-modern-rpm-api-patch/net-snmp-5.9-new	(nonexistent)
+++ create-5.9-modern-rpm-api-patch/net-snmp-5.9-new	(revision 5)

Property changes on: create-5.9-modern-rpm-api-patch/net-snmp-5.9-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-modern-rpm-api-patch
===================================================================
--- create-5.9-modern-rpm-api-patch	(nonexistent)
+++ create-5.9-modern-rpm-api-patch	(revision 5)

Property changes on: create-5.9-modern-rpm-api-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-remove-U64-typedef-patch/create.patch.sh
===================================================================
--- create-5.9-remove-U64-typedef-patch/create.patch.sh	(nonexistent)
+++ create-5.9-remove-U64-typedef-patch/create.patch.sh	(revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=5.9
+
+tar --files-from=file.list -xzvf ../net-snmp-$VERSION.tar.gz
+mv net-snmp-$VERSION net-snmp-$VERSION-orig
+
+cp -rf ./net-snmp-$VERSION-new ./net-snmp-$VERSION
+
+diff --unified -Nr  net-snmp-$VERSION-orig  net-snmp-$VERSION > net-snmp-$VERSION-remove-U64-typedef.patch
+
+mv net-snmp-$VERSION-remove-U64-typedef.patch ../patches
+
+rm -rf ./net-snmp-$VERSION
+rm -rf ./net-snmp-$VERSION-orig

Property changes on: create-5.9-remove-U64-typedef-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-5.9-remove-U64-typedef-patch/file.list
===================================================================
--- create-5.9-remove-U64-typedef-patch/file.list	(nonexistent)
+++ create-5.9-remove-U64-typedef-patch/file.list	(revision 5)
@@ -0,0 +1 @@
+net-snmp-5.9/include/net-snmp/library/int64.h
Index: create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include/net-snmp/library/int64.h
===================================================================
--- create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include/net-snmp/library/int64.h	(nonexistent)
+++ create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include/net-snmp/library/int64.h	(revision 5)
@@ -0,0 +1,47 @@
+#ifndef INT64_INCLUDED
+#define INT64_INCLUDED
+
+#ifdef __cplusplus
+extern          "C" {
+#endif
+
+#define I64CHARSZ 21
+
+    void            divBy10(struct counter64, struct counter64 *,
+                            unsigned int *);
+    void            multBy10(struct counter64, struct counter64 *);
+    void            incrByU16(struct counter64 *, unsigned int);
+    void            incrByU32(struct counter64 *, unsigned int);
+    NETSNMP_IMPORT
+    void            zeroU64(struct counter64 *);
+    int             isZeroU64(const struct counter64 *);
+    NETSNMP_IMPORT
+    void            printU64(char *, const struct counter64 *);
+    NETSNMP_IMPORT
+    void            printI64(char *, const struct counter64 *);
+    int             read64(struct counter64 *, const char *);
+    NETSNMP_IMPORT
+    void            u64Subtract(const struct counter64 *pu64one,
+                                const struct counter64 *pu64two,
+                                struct counter64 *pu64out);
+    void            u64Incr(struct counter64 *pu64out,
+                            const struct counter64 *pu64one);
+    void            u64UpdateCounter(struct counter64 *pu64out,
+                                     const struct counter64 *pu64one,
+                                     const struct counter64 *pu64two);
+    void            u64Copy(struct counter64 *pu64one,
+                            const struct counter64 *pu64two);
+
+    int             netsnmp_c64_check_for_32bit_wrap(struct counter64 *old_val,
+                                                     struct counter64 *new_val,
+                                                     int adjust);
+    NETSNMP_IMPORT
+    int             netsnmp_c64_check32_and_update(struct counter64 *prev_val,
+                                                   struct counter64 *new_val,
+                                                   struct counter64 *old_prev_val,
+                                                   int *need_wrap_check);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
Index: create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include/net-snmp/library
===================================================================
--- create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include/net-snmp/library	(nonexistent)
+++ create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include/net-snmp/library	(revision 5)

Property changes on: create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include/net-snmp/library
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include/net-snmp
===================================================================
--- create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include/net-snmp	(nonexistent)
+++ create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include/net-snmp	(revision 5)

Property changes on: create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include/net-snmp
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include
===================================================================
--- create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include	(nonexistent)
+++ create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include	(revision 5)

Property changes on: create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new/include
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new
===================================================================
--- create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new	(nonexistent)
+++ create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new	(revision 5)

Property changes on: create-5.9-remove-U64-typedef-patch/net-snmp-5.9-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-remove-U64-typedef-patch
===================================================================
--- create-5.9-remove-U64-typedef-patch	(nonexistent)
+++ create-5.9-remove-U64-typedef-patch	(revision 5)

Property changes on: create-5.9-remove-U64-typedef-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-snmp-config-patch/create.patch.sh
===================================================================
--- create-5.9-snmp-config-patch/create.patch.sh	(nonexistent)
+++ create-5.9-snmp-config-patch/create.patch.sh	(revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=5.9
+
+tar --files-from=file.list -xzvf ../net-snmp-$VERSION.tar.gz
+mv net-snmp-$VERSION net-snmp-$VERSION-orig
+
+cp -rf ./net-snmp-$VERSION-new ./net-snmp-$VERSION
+
+diff --unified -Nr  net-snmp-$VERSION-orig  net-snmp-$VERSION > net-snmp-$VERSION-snmp-config.patch
+
+mv net-snmp-$VERSION-snmp-config.patch ../patches
+
+rm -rf ./net-snmp-$VERSION
+rm -rf ./net-snmp-$VERSION-orig

Property changes on: create-5.9-snmp-config-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-5.9-snmp-config-patch/file.list
===================================================================
--- create-5.9-snmp-config-patch/file.list	(nonexistent)
+++ create-5.9-snmp-config-patch/file.list	(revision 5)
@@ -0,0 +1 @@
+net-snmp-5.9/net-snmp-config.in
Index: create-5.9-snmp-config-patch/net-snmp-5.9-new/net-snmp-config.in
===================================================================
--- create-5.9-snmp-config-patch/net-snmp-5.9-new/net-snmp-config.in	(nonexistent)
+++ create-5.9-snmp-config-patch/net-snmp-5.9-new/net-snmp-config.in	(revision 5)
@@ -0,0 +1,764 @@
+#!/bin/sh
+#
+# $Id$
+#
+# this shell script is designed to merely dump the configuration
+# information about how the net-snmp package was compiled.  The
+# information is particularly useful for applications that need to
+# link against the net-snmp libraries and hence must know about any
+# other libraries that must be linked in as well.
+
+check_build_dir()
+{
+      build_dir=$1
+
+      if test "x$build_dir" = "x" ; then
+         echo "You must specify a build directory."
+         exit 1
+      fi
+      # is it the src dir?
+      if test -f $build_dir/net-snmp-config.in ; then
+         return
+      fi
+      # make sure we can find build dir
+      if test ! -d $build_dir/snmplib/.libs ; then
+         echo "$build_dir does not appear to be a build directory."
+         exit 1
+      fi
+}
+
+# usage: index n arguments
+# effect: returns the (n+1)th argument
+index()
+{
+    [ $# -gt $1 ] || return
+    shift $1
+    echo $1
+}
+
+# usage: count arguments
+# effect: returns the number of arguments
+count()
+{
+    echo $#
+}
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+includedir=@includedir@
+libdir=@libdir@
+# Avoid that configure complains that this script ignores @datarootdir@
+echo "@datarootdir@" >/dev/null
+NSC_LDFLAGS="@LDFLAGS@"
+
+NSC_LIBS="@LIBS@"
+NSC_LNETSNMPLIBS="@LNETSNMPLIBS@"
+NSC_LAGENTLIBS="@LAGENTLIBS@ @PERLLDOPTS_FOR_APPS@"
+NSC_LMIBLIBS="@LMIBLIBS@"
+
+NSC_INCLUDEDIR=${includedir}
+NSC_LIBDIR=-L${libdir}
+
+NSC_SNMPLIBS="-lnetsnmp ${NSC_LNETSNMPLIBS}"
+NSC_SUBAGENTLIBS="-lnetsnmpagent ${NSC_LAGENTLIBS} ${NSC_SNMPLIBS}"
+NSC_AGENTLIBS="-lnetsnmpmibs ${NSC_LMIBLIBS} ${NSC_SUBAGENTLIBS}"
+
+NSC_PREFIX=$prefix
+NSC_EXEC_PREFIX=$exec_prefix
+NSC_SRCDIR=@srcdir@
+NSC_INCDIR=${NSC_PREFIX}/include
+
+NSC_BASE_SNMP_LIBS="-lnetsnmp"
+NSC_BASE_SUBAGENT_LIBS="-lnetsnmpagent ${NSC_BASE_SNMP_LIBS}"
+NSC_BASE_AGENT_LIBS="-lnetsnmpmibs ${NSC_BASE_SUBAGENT_LIBS}"
+
+NSC_SRC_LIBDIRS="agent/.libs snmplib/.libs"
+NSC_SRC_LIBDEPS="agent/.libs/libnetsnmpmibs.a agent/.libs/libnetsnmpagent.a snmplib/.libs/libnetsnmp.a"
+
+if test "x$NSC_SRCDIR" = "x." ; then
+   NSC_SRCDIR="NET-SNMP-SOURCE-DIR"
+elif test "x$NSC_SRCDIR" = "x" ; then
+   NSC_SRCDIR="NET-SNMP-SOURCE-DIR"
+fi
+
+if test "x$1" = "x"; then
+  usage="yes"
+else
+  while test "x$done" = "x" -a "x$1" != "x" -a "x$usage" != "xyes"; do
+  case "$1" in
+    -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+    *) optarg= ;;
+  esac
+
+  unset shifted
+  case $1 in
+    --prefix=*)
+      prefix=$optarg
+      NSC_PREFIX=${prefix}
+      NSC_INCLUDEDIR=${prefix}/include
+      NSC_LIBDIR=-L${prefix}/lib
+      ;;
+
+    --exec-prefix=*)
+      exec_prefix=$optarg
+      NSC_EXEC_PREFIX=${exec_prefix}
+      NSC_LIBDIR=-L${exec_prefix}/lib
+      ;;
+
+    --debug-tokens|--deb*|--dbg*)
+      echo "find $NSC_SRCDIR -name \"*.c\" -print | xargs grep DEBUGMSGT | grep \\\" | cut -f 2 -d\\\" | sort -u"
+      if test "x$NSC_SRCDIR" != "xNET-SNMP-SOURCE-DIR" ; then
+        /usr/bin/find $NSC_SRCDIR -name "*.c" -print | xargs grep DEBUGMSGT | grep \" | cut -f 2 -d\" | sort -u
+      fi
+      ;;
+    --indent-options|--in*)
+      echo "indent -orig -nbc -bap -nut -nfca `(cd $NSC_INCDIR/net-snmp; perl -n -e 'print "-T $1 " if (/}\s*(netsnmp_\w+)\s*;/);' */*.h)`"
+      ;;
+    --configure-options|--con*)
+      echo @CONFIGURE_OPTIONS@
+      ;;
+    --snmpd-module-list|--mod*)
+      @MODULE_LIST@
+      ;;
+    --default-mibs|--mibs|--MIBS)
+      echo @NETSNMP_DEFAULT_MIBS@
+      ;;
+    --default-mibdirs|--mibdirs|--MIBDIRS)
+      echo @NETSNMP_DEFAULT_MIBDIRS@
+      ;;
+    --env-separator)
+      echo "@ENV_SEPARATOR@"
+      ;;
+    --exeext)
+      echo "@EXEEXT@"
+      ;;
+    --snmpconfpath|--SNMPCONFPATH)
+      echo "@SNMPCONFPATH@@ENV_SEPARATOR@@SNMPSHAREPATH@@ENV_SEPARATOR@@SNMPLIBPATH@@ENV_SEPARATOR@$HOME/.snmp@ENV_SEPARATOR@@PERSISTENT_DIRECTORY@"
+      ;;
+    --persistent-directory|--persistent-dir)
+      echo @PERSISTENT_DIRECTORY@
+      ;;
+    --perlprog|--perl)
+      echo @PERLPROG@
+      ;;
+    #################################################### compile
+    --base-cflags)
+      echo @CFLAGS@ @CPPFLAGS@
+      ;;
+    --cflags|--cf*)
+      echo @CFLAGS@ @DEVFLAGS@ @CPPFLAGS@ -I.
+      ;;
+    --srcdir)
+      echo $NSC_SRCDIR
+      ;;
+    #################################################### linking
+    --libdir|--lib-dir)
+      echo $NSC_LIBDIR
+      ;;
+    --ldflags|--ld*)
+      echo $NSC_LDFLAGS
+      ;;
+    --build-lib-dirs)
+      shift
+      build_dir=$1
+      check_build_dir $build_dir
+      for dir in $NSC_SRC_LIBDIRS; do
+          result="$result -L$build_dir/$dir"
+      done
+      echo $result
+      ;;
+    --build-lib-deps)
+      shift
+      build_dir=$1
+      check_build_dir $build_dir
+      for dir in $NSC_SRC_LIBDEPS; do
+          result="$result $build_dir/$dir"
+      done
+      echo $result
+      ;;
+    --build-includes)
+      shift
+      build_dir=$1
+      check_build_dir $build_dir
+      result="-I$build_dir/include"
+      if test "$build_dir" != "$NSC_SRCDIR" -a "$NSC_SRCDIR" != "NET-SNMP-SOURCE-DIR"
+      then
+          result="$result -I$NSC_SRCDIR/include"
+      fi
+      echo $result
+      ;;
+    --build-command)
+      echo "@CC@ @CFLAGS@ @DEVFLAGS@ @CPPFLAGS@"
+      ;;
+    #################################################### client lib
+    --libs)
+      # use this one == --netsnmp-libs + --external-libs
+      echo $NSC_LDFLAGS $NSC_LIBDIR $NSC_SNMPLIBS $NSC_LIBS
+      ;;
+    --netsnmp-libs)
+      echo $NSC_LIBDIR $NSC_BASE_SNMP_LIBS
+      ;;
+    --external-libs)
+      echo $NSC_LDFLAGS $NSC_LNETSNMPLIBS $NSC_LIBS @PERLLDOPTS_FOR_APPS@
+      ;;
+    #################################################### agent lib
+    --base-agent-libs)
+      echo $NSC_BASE_AGENT_LIBS
+      ;;
+    --base-subagent-libs)
+      echo $NSC_BASE_SUBAGENT_LIBS
+      ;;
+    --agent-libs)
+      # use this one == --netsnmp-agent-libs + --external-libs
+      echo $NSC_LDFLAGS $NSC_LIBDIR $NSC_AGENTLIBS $NSC_LIBS
+      ;;
+    --netsnmp-agent-libs)
+      echo $NSC_LIBDIR $NSC_BASE_AGENT_LIBS
+      ;;
+    --external-agent-libs)
+      echo $NSC_LDFLAGS $NSC_LMIBLIBS $NSC_LAGENTLIBS $NSC_LNETSNMPLIBS $NSC_LIBS
+      ;;
+    ####################################################
+    --version|--ver*)
+      echo @VERSION@
+      ;;
+    --help)
+      usage="yes"
+      ;;
+    --prefix|--pre*)
+      echo $NSC_PREFIX
+      ;;
+    --exec-prefix)
+      echo $NSC_EXEC_PREFIX
+      ;;
+    ####################################################
+    --create-snmpv3-user)
+      done=1
+      shift
+      net-snmp-create-v3-user $*
+      exit $?
+      ;;
+
+    ####################################################
+    --compile-subagent)
+      shift
+      shifted=1
+      while test "x$done" = "x" -a "x$1" != "x" ; do
+	case $1 in
+            --norm)
+	        norm=1
+	        shift
+		;;
+            --cflags)
+	        shift
+	        if test "x$1" = "x" ; then
+	            echo "You must specify the extra cflags"
+	            exit 1
+	        fi
+	        cflags="$1"
+	        echo "setting extra cflags: $cflags"
+	        shift
+		;;
+            --ldflags)
+	        shift
+	        if test "x$1" = "x" ; then
+	            echo "You must specify the extra ldflags"
+	            exit 1
+	        fi
+	        ldflags="$1"
+	        echo "setting extra ldflags: $ldflags"
+	        shift
+		;;
+ 	    --*)
+		echo "unknown suboption to --compile-subagent: $1"
+		exit 1
+		;;
+	    *)
+                if test "x$outname" = "x"; then
+                  outname=$1
+                  shift
+                else
+	          done=1
+                fi
+		;;
+	esac
+      done
+      tmpfile=netsnmptmp.$$.c
+      if test -f $tmpfile; then
+	echo "Ack.  Can't create $tmpfile: already exists"
+	exit 1
+      fi
+      echo "generating the temporary code file: $tmpfile"
+      rm -f $tmpfile
+      cat > $tmpfile <<EOF
+/* generated from net-snmp-config */
+#include <net-snmp/net-snmp-config.h>
+#ifdef HAVE_SIGNAL
+#include <signal.h>
+#endif /* HAVE_SIGNAL */
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif /*  HAVE_SYS_STAT_H */
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif /* HAVE_FCNTL_H */
+#include <net-snmp/net-snmp-includes.h>
+#include <net-snmp/agent/net-snmp-agent-includes.h>
+EOF
+
+    # If we were only given a single filename
+    # (and no explicit output name)
+    # then use that as the base of the output name
+    #
+    # If we weren't even given that, then bomb out
+    if test "x$1" = "x"; then
+      if test "x$outname" = "x"; then
+        echo "No MIB module codefile specified"
+        rm -f $tmpfile
+        exit 1
+      else
+        cfiles=$outname
+        outname=`basename $cfiles | sed 's/\.[co]$//'`
+        if test -f $outname.h; then
+          if grep "init_$outname" $outname.h; then
+            echo "  #include \"$outname.h\"" >> $tmpfile
+          fi
+        fi
+      fi
+    fi
+
+    # add include files
+    while test "$1" != ""; do
+      cfiles="$cfiles $1"
+      name=`basename $1 | sed 's/\.[co]$//'`
+      if test -f $name.h; then
+        if grep "init_$name" $name.h; then
+          echo "  #include \"$name.h\"" >> $tmpfile
+        fi
+      fi
+      shift
+    done
+
+      cat >> $tmpfile <<EOF
+const char *app_name = "$outname";
+static int reconfig = 0;
+
+extern int netsnmp_running;
+
+RETSIGTYPE
+stop_server(int a) {
+    netsnmp_running = 0;
+}
+
+#ifdef SIGHUP
+RETSIGTYPE
+hup_handler(int sig)
+{
+    reconfig = 1;
+    signal(SIGHUP, hup_handler);
+}
+#endif
+
+static void
+usage(const char *prog)
+{
+    fprintf(stderr,
+            "USAGE: %s [OPTIONS]\n"
+            "\n"
+            "OPTIONS:\n", prog);
+
+    fprintf(stderr,
+            "  -c FILE[,...]\t\tread FILE(s) as configuration file(s)\n"
+            "  -C\t\t\tdo not read the default configuration files\n"
+            "  -d\t\t\tdump all traffic\n"
+            "  -D TOKEN[,...]\tturn on debugging output for the specified "
+            "TOKENs\n"
+            "\t\t\t   (ALL gives extremely verbose debugging output)\n"
+            "  -f\t\t\tDo not fork() from the calling shell.\n"
+            "  -h\t\t\tdisplay this help message\n"
+            "  -H\t\t\tdisplay a list of configuration file directives\n"
+            "  -L LOGOPTS\t\tToggle various defaults controlling logging:\n");
+    snmp_log_options_usage("\t\t\t  ", stderr);
+#ifndef DISABLE_MIB_LOADING
+    fprintf(stderr,
+            "  -m MIB[" ENV_SEPARATOR "...]\t\tload given list of MIBs (ALL loads "
+            "everything)\n"
+            "  -M DIR[" ENV_SEPARATOR "...]\t\tlook in given list of directories for MIBs\n");
+#endif /* DISABLE_MIB_LOADING */
+    fprintf(stderr,
+            "  -p FILE\t\tstore process id in FILE\n");
+#ifndef DISABLE_MIB_LOADING
+    fprintf(stderr,
+            "  -P MIBOPTS\t\tToggle various defaults controlling mib "
+            "parsing:\n");
+    snmp_mib_toggle_options_usage("\t\t\t  ", stderr);
+#endif /* DISABLE_MIB_LOADING */
+    fprintf(stderr,
+            "  -v\t\t\tdisplay package version number\n"
+            "  -x TRANSPORT\tconnect to master agent using TRANSPORT\n");
+    exit(1);
+}
+
+static void
+version(void)
+{
+    fprintf(stderr, "NET-SNMP version: %s\n", netsnmp_get_version());
+    exit(0);
+}
+
+int
+main (int argc, char **argv)
+{
+  int arg;
+  char* cp = NULL;
+  int dont_fork = 0, do_help = 0;
+  char* pid_file = NULL;
+
+  while ((arg = getopt(argc, argv, "c:CdD:fhHL:"
+#ifndef DISABLE_MIB_LOADING
+                       "m:M:"
+#endif /* DISABLE_MIB_LOADING */
+                       "n:p:"
+#ifndef DISABLE_MIB_LOADING
+                       "P:"
+#endif /* DISABLE_MIB_LOADING */
+                       "vx:")) != EOF) {
+    switch (arg) {
+      case 'c':
+        if (optarg != NULL) {
+          netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
+                                NETSNMP_DS_LIB_OPTIONALCONFIG, optarg);
+        } else {
+          usage(argv[0]);
+        }
+        break;
+
+      case 'C':
+        netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
+                               NETSNMP_DS_LIB_DONT_READ_CONFIGS, 1);
+        break;
+
+    case 'd':
+      netsnmp_ds_set_boolean(NETSNMP_DS_LIBRARY_ID,
+                             NETSNMP_DS_LIB_DUMP_PACKET, 1);
+      break;
+
+    case 'D':
+      debug_register_tokens(optarg);
+      snmp_set_do_debugging(1);
+      break;
+
+    case 'f':
+      dont_fork = 1;
+      break;
+
+    case 'h':
+      usage(argv[0]);
+      break;
+
+    case 'H':
+      do_help = 1;
+      break;
+
+    case 'L':
+      if (snmp_log_options(optarg, argc, argv) < 0) {
+        exit(1);
+      }
+      break;
+
+#ifndef DISABLE_MIB_LOADING
+    case 'm':
+      if (optarg != NULL) {
+        setenv("MIBS", optarg, 1);
+      } else {
+        usage(argv[0]);
+      }
+      break;
+
+    case 'M':
+      if (optarg != NULL) {
+        setenv("MIBDIRS", optarg, 1);
+      } else {
+        usage(argv[0]);
+      }
+      break;
+#endif /* DISABLE_MIB_LOADING */
+
+    case 'n':
+      if (optarg != NULL) {
+        app_name = optarg;
+        netsnmp_ds_set_string(NETSNMP_DS_LIBRARY_ID,
+                              NETSNMP_DS_LIB_APPTYPE, app_name);
+      } else {
+        usage(argv[0]);
+      }
+      break;
+
+    case 'p':
+      if (optarg != NULL) {
+        pid_file = optarg;
+      } else {
+        usage(argv[0]);
+      }
+      break;
+
+#ifndef DISABLE_MIB_LOADING
+    case 'P':
+      cp = snmp_mib_toggle_options(optarg);
+      if (cp != NULL) {
+        fprintf(stderr, "Unknown parser option to -P: %c.\n", *cp);
+        usage(argv[0]);
+      }
+      break;
+#endif /* DISABLE_MIB_LOADING */
+
+    case 'v':
+      version();
+      break;
+
+    case 'x':
+      if (optarg != NULL) {
+        netsnmp_ds_set_string(NETSNMP_DS_APPLICATION_ID,
+                              NETSNMP_DS_AGENT_X_SOCKET, optarg);
+      } else {
+        usage(argv[0]);
+      }
+      break;
+
+    default:
+      fprintf(stderr, "invalid option: -%c\n", arg);
+      usage(argv[0]);
+      break;
+    }
+  }
+
+  if (do_help) {
+    netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
+                           NETSNMP_DS_AGENT_NO_ROOT_ACCESS, 1);
+  } else {
+    /* we are a subagent */
+    netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
+                           NETSNMP_DS_AGENT_ROLE, 1);
+
+    if (!dont_fork) {
+      if (netsnmp_daemonize(1, snmp_stderrlog_status()) != 0)
+        exit(1);
+    }
+
+#if HAVE_GETPID
+    if (pid_file != NULL) {
+      /*
+       * unlink the pid_file, if it exists, prior to open.  Without
+       * doing this the open will fail if the user specified pid_file
+       * already exists.
+       */
+      int fd;
+      unlink(pid_file);
+      fd = open(pid_file, O_CREAT | O_EXCL | O_WRONLY, 0600);
+      if (fd == -1) {
+        snmp_log_perror(pid_file);
+        if (!netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
+                                    NETSNMP_DS_AGENT_NO_ROOT_ACCESS)) {
+          exit(1);
+        }
+      } else {
+        char buf[3 + sizeof(long) * 3];
+        int len = snprintf(buf, sizeof(buf), "%ld\n", (long int)getpid());
+        write(fd, buf, len);
+        close(fd);
+      }
+    }
+#endif
+
+    /* initialize tcpip, if necessary */
+    SOCK_STARTUP;
+  }
+
+  /* initialize the agent library */
+  init_agent(app_name);
+
+  /* initialize your mib code here */
+EOF
+
+    # add init routines
+    for i in $cfiles ; do
+      name=`basename $i | sed 's/\.[co]$//'`
+      echo checking for init_$name in $i
+      if grep "init_$name" $i ; then
+        echo "  init_${name}();" >> $tmpfile
+      fi
+    done
+
+    # handle the main loop
+    cat >> $tmpfile <<EOF
+
+  /* $outname will be used to read $outname.conf files. */
+  init_snmp("$outname");
+
+  if (do_help) {
+    fprintf(stderr, "Configuration directives understood:\n");
+    read_config_print_usage("  ");
+    exit(0);
+  }
+
+  /* In case we received a request to stop (kill -TERM or kill -INT) */
+  netsnmp_running = 1;
+#ifdef SIGTERM
+  signal(SIGTERM, stop_server);
+#endif
+#ifdef SIGINT
+  signal(SIGINT, stop_server);
+#endif
+#ifdef SIGHUP
+  signal(SIGHUP, hup_handler);
+#endif
+
+  /* main loop here... */
+  while(netsnmp_running) {
+    if (reconfig) {
+      free_config();
+      read_configs();
+      reconfig = 0;
+    }
+    agent_check_and_process(1);
+  }
+
+  /* at shutdown time */
+  snmp_shutdown(app_name);
+
+  /* deinitialize your mib code here */
+EOF
+
+    # add shutdown routines
+
+    i=`count $cfiles`
+    while [ $i -gt 0 ] ; do
+      fullname=`index $i $cfiles`
+      name=`basename $fullname | sed 's/\.[co]$//'`
+      echo checking for shutdown_$name in $fullname
+      if grep "shutdown_$name" $fullname ; then
+        echo "  shutdown_${name}();" >> $tmpfile
+      fi
+      i=`expr $i - 1`
+    done
+
+    # finish file
+    cat >> $tmpfile <<EOF
+
+  /* shutdown the agent library */
+  shutdown_agent();
+
+  if (pid_file != NULL) {
+    unlink(pid_file);
+  }
+
+  SOCK_CLEANUP;
+  exit(0);
+}
+EOF
+      if test "$?" != 0 -o ! -f "$tmpfile" ; then
+        echo "Ack.  Can't create $tmpfile."
+	exit 1
+      fi
+      cmd="@CC@ $cflags @CFLAGS@ @DEVFLAGS@ -I. -I${NSC_INCLUDEDIR} -o $outname $tmpfile $cfiles $NSC_LDFLAGS $NSC_LIBDIR $NSC_BASE_AGENT_LIBS $NSC_AGENTLIBS $ldflags"
+      echo "running: $cmd"
+      echo `$cmd`
+      result=$?
+      if test "x$norm" != "x1" ; then
+        echo "removing the temporary code file: $tmpfile"
+        rm -f $tmpfile
+      else
+        echo "leaving the temporary code file: $tmpfile"
+      fi
+      if test "$result" = "0" -a -f "$outname" ; then
+        echo "subagent program $outname created"
+      fi
+      exit $result
+      ;;
+
+    *)
+      echo "unknown option $1"
+      usage="yes"
+      ;;
+  esac
+  if [ "x$shifted" = "x" ] ; then
+      shift
+  fi
+  done
+fi
+
+if test "x$usage" = "xyes"; then
+  echo ""
+  echo "Usage:"
+  echo "  net-snmp-config [--cflags] [--agent-libs] [--libs] [--version]"
+  echo "                  ... [see below for complete flag list]"
+  echo ""
+  echo "    --version         displays the net-snmp version number"
+  echo "    --indent-options  displays the indent options from the Coding Style"
+  echo "    --debug-tokens    displays a example command line to search to source"
+  echo "                      code for a list of available debug tokens"
+  echo ""
+  echo "  SNMP Setup commands:"
+  echo ""
+  echo "    --create-snmpv3-user creates a SNMPv3 user in Net-SNMP config file."
+  echo "                         See net-snmp-create-v3-user --help for list of"
+  echo "                         accepted options."
+  echo ""
+  echo "  These options produce the various compilation flags needed when"
+  echo "  building external SNMP applications:"
+  echo ""
+  echo "    --base-cflags     lists additional compilation flags needed"
+  echo "    --cflags          lists additional compilation flags needed"
+  echo "                      (includes -I. and extra developer warning flags)"
+  echo ""
+  echo "  These options produce the various link flags needed when"
+  echo "  building external SNMP applications:"
+  echo ""
+  echo "    --libs            lists libraries needed for building applications"
+  echo "    --agent-libs      lists libraries needed for building subagents"
+  echo ""
+  echo "  These options produce various link flags broken down into parts."
+  echo "  (Most of the time the simple options above should be used.)"
+  echo ""
+  echo "    --libdir              path to netsnmp libraries"
+  echo ""
+  echo "    --base-agent-libs     netsnmp specific agent libraries"
+  echo ""
+  echo "    --netsnmp-libs        netsnmp specific libraries (with path)"
+  echo "    --netsnmp-agent-libs  netsnmp specific agent libraries (with path)"
+  echo ""
+  echo "    --ldflags             link flags for external libraries"
+  echo "    --external-libs       external libraries needed by netsnmp libs"
+  echo "    --external-agent-libs external libraries needed by netsnmp agent libs"
+  echo ""
+  echo "  These options produce various link flags used when linking an"
+  echo "  external application against an uninstalled build directory."
+  echo ""
+  echo "    --build-includes      include path to build/source includes"
+  echo "    --build-lib-dirs      link path to libraries"
+  echo "    --build-lib-deps      path to libraries for dependency target"
+  echo "    --build-command       command to compile \$3... to \$2"
+  echo ""
+  echo "  Automated subagent building (produces an OUTPUTNAME binary file):"
+  echo "  [this feature has not been tested very well yet.  use at your risk.]"
+  echo ""
+  echo "    --compile-subagent OUTPUTNAME [--norm] [--cflags flags]"
+  echo "                                  [--ldflags flags] mibmodule1.c [...]]"
+  echo ""
+  echo "         --norm           leave the generated .c file around to read."
+  echo "         --cflags flags   extra cflags to use (e.g. -I...)."
+  echo "         --ldflags flags  extra ld flags to use (e.g. -L... -l...)."
+  echo ""
+  echo "  Details on how the net-snmp package was compiled:"
+  echo ""
+  echo "    --configure-options   display original configure arguments"
+  echo "    --prefix              display the installation prefix"
+  echo "    --snmpd-module-list   display the modules compiled into the agent"
+  echo "    --default-mibs        display default list of MIBs"
+  echo "    --default-mibdirs     display default list of MIB directories"
+  echo "    --snmpconfpath        display default SNMPCONFPATH"
+  echo "    --persistent-directory display default persistent directory"
+  echo "    --perlprog            display path to perl for the perl modules"
+  echo ""
+  exit
+fi  
Index: create-5.9-snmp-config-patch/net-snmp-5.9-new
===================================================================
--- create-5.9-snmp-config-patch/net-snmp-5.9-new	(nonexistent)
+++ create-5.9-snmp-config-patch/net-snmp-5.9-new	(revision 5)

Property changes on: create-5.9-snmp-config-patch/net-snmp-5.9-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-snmp-config-patch
===================================================================
--- create-5.9-snmp-config-patch	(nonexistent)
+++ create-5.9-snmp-config-patch	(revision 5)

Property changes on: create-5.9-snmp-config-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-snmpd-conf-patch/create.patch.sh
===================================================================
--- create-5.9-snmpd-conf-patch/create.patch.sh	(nonexistent)
+++ create-5.9-snmpd-conf-patch/create.patch.sh	(revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=5.9
+
+tar --files-from=file.list -xzvf ../net-snmp-$VERSION.tar.gz
+mv net-snmp-$VERSION net-snmp-$VERSION-orig
+
+cp -rf ./net-snmp-$VERSION-new ./net-snmp-$VERSION
+
+diff --unified -Nr  net-snmp-$VERSION-orig  net-snmp-$VERSION > net-snmp-$VERSION-snmpd-conf.patch
+
+mv net-snmp-$VERSION-snmpd-conf.patch ../patches
+
+rm -rf ./net-snmp-$VERSION
+rm -rf ./net-snmp-$VERSION-orig

Property changes on: create-5.9-snmpd-conf-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-5.9-snmpd-conf-patch/file.list
===================================================================
--- create-5.9-snmpd-conf-patch/file.list	(nonexistent)
+++ create-5.9-snmpd-conf-patch/file.list	(revision 5)
@@ -0,0 +1 @@
+net-snmp-5.9/net-snmp-create-v3-user.in
Index: create-5.9-snmpd-conf-patch/net-snmp-5.9-new/net-snmp-create-v3-user.in
===================================================================
--- create-5.9-snmpd-conf-patch/net-snmp-5.9-new/net-snmp-create-v3-user.in	(nonexistent)
+++ create-5.9-snmpd-conf-patch/net-snmp-5.9-new/net-snmp-create-v3-user.in	(revision 5)
@@ -0,0 +1,144 @@
+#!/bin/sh
+#
+# $Id$
+#
+# this shell script is designed to add new SNMPv3 users
+# to Net-SNMP config file.
+
+if @PSCMD@ | egrep ' snmpd *$' > /dev/null 2>&1 ; then
+    echo "Apparently at least one snmpd demon is already running."
+    echo "You must stop them in order to use this command."
+    exit 1
+fi
+
+Aalgorithm="MD5"
+Xalgorithm="DES"
+token=rwuser
+
+while test "x$done" = "x" -a "x$1" != "x" -a "x$usage" != "xyes"; do
+
+unset shifted
+case $1 in
+    --version|--ver*)
+      echo @VERSION@
+      ;;
+    --help)
+      usage="yes"
+      ;;
+
+    -A|-a)
+	shift
+	if test "x$1" = "x" ; then
+	    echo "You must specify an authentication algorithm or pass phrase"
+	    exit 1
+	fi
+        case $1 in
+            MD5|SHA|SHA-512|SHA-384|SHA-256|SHA-224)
+	    Aalgorithm=$1
+	    shift
+	    ;;
+            md5|sha)
+	    Aalgorithm=`echo $1 | tr a-z A-Z`
+	    shift
+	    ;;
+            *)
+	    apassphrase=$1
+	    shift
+	    ;;
+        esac
+        ;;
+    -X|-x)
+	shift
+	if test "x$1" = "x" ; then
+	    echo "You must specify an encryption algorithm or pass phrase"
+	    exit 1
+	fi
+        case $1 in
+            DES|AES|AES128)
+	    Xalgorithm=$1
+	    shift
+	    ;;
+            des|aes|aes128)
+	    Xalgorithm=`echo $1 | tr a-z A-Z`
+	    shift
+	    ;;
+            *)
+	    xpassphrase=$1
+	    shift
+	    ;;
+	esac
+	;;
+    -ro)
+        token="rouser"
+	shift
+	;;
+    -*)
+	echo "unknown suboption to $0: $1"
+	usage=yes
+	done=1
+	;;
+    *)
+        done=1
+        ;;
+    esac
+done
+
+if test "x$usage" = "xyes"; then
+    echo ""
+    echo "Usage:"
+    echo "  net-snmp-create-v3-user [-ro] [-A authpass] [-X privpass]"
+    echo "                          [-a MD5|SHA|SHA-512|SHA-384|SHA-256|SHA-224] [-x DES|AES] [username]"
+    echo ""
+    exit
+fi
+
+if test "x$1" = "x" ; then
+    prompt=yes
+    echo "Enter a SNMPv3 user name to create: "
+    read user
+else
+    user=$1
+    shift
+fi
+if test "x$user" = "x" ; then
+    echo "You must specify a user name"
+    exit 1
+fi
+if test "x$apassphrase" = "x" ; then
+    prompt=yes
+    echo "Enter authentication pass-phrase: "
+    read apassphrase
+fi
+if test "x$apassphrase" = "x" ; then
+    echo "You must specify an authentication pass-phrase"
+    exit 1
+fi
+    if test "x$prompt" = "xyes" -a "x$xpassphrase" = "x" ; then
+    echo "Enter encryption pass-phrase: "
+    echo "  [press return to reuse the authentication pass-phrase]"
+    read xpassphrase
+fi
+outdir="@PERSISTENT_DIRECTORY@"
+outfile="$outdir/snmpd.conf"
+line="createUser $user $Aalgorithm \"$apassphrase\" $Xalgorithm \"$xpassphrase\""
+echo "adding the following line to $outfile:"
+echo "  " $line
+# in case it hasn't ever been started yet, start it.
+if test ! -d $outdir ; then
+    mkdir $outdir
+fi
+if test ! -d $outfile ; then
+    touch $outfile
+fi
+echo $line >> $outfile
+prefix="@prefix@"
+# Avoid that configure complains that this script ignores @datarootdir@
+echo "@datarootdir@" >/dev/null
+outfile="/etc/snmp/snmpd.conf"
+line="$token $user"
+echo "adding the following line to $outfile:"
+echo "  " $line
+if test ! -d $outfile ; then
+    touch $outfile
+fi
+echo $line >> $outfile
Index: create-5.9-snmpd-conf-patch/net-snmp-5.9-new
===================================================================
--- create-5.9-snmpd-conf-patch/net-snmp-5.9-new	(nonexistent)
+++ create-5.9-snmpd-conf-patch/net-snmp-5.9-new	(revision 5)

Property changes on: create-5.9-snmpd-conf-patch/net-snmp-5.9-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-5.9-snmpd-conf-patch
===================================================================
--- create-5.9-snmpd-conf-patch	(nonexistent)
+++ create-5.9-snmpd-conf-patch	(revision 5)

Property changes on: create-5.9-snmpd-conf-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: patches/README
===================================================================
--- patches/README	(nonexistent)
+++ patches/README	(revision 5)
@@ -0,0 +1,6 @@
+
+/* begin *
+
+   TODO: Leave some comment here.
+
+ * end */
Index: patches
===================================================================
--- patches	(nonexistent)
+++ patches	(revision 5)

Property changes on: patches
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: .
===================================================================
--- .	(nonexistent)
+++ .	(revision 5)

Property changes on: .
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~