Configuration from current directory
authorArjen Baart <arjen@andromeda.nl>
Wed, 9 Sep 2020 15:04:10 +0000 (17:04 +0200)
committerArjen Baart <arjen@andromeda.nl>
Wed, 9 Sep 2020 15:04:10 +0000 (17:04 +0200)
22 files changed:
src/database/create.sql
src/database/destroy.sql
src/gcm_daemon/classes/gnucomo_db_version.php
src/include/gnucomo_config.h
src/phpclasses/configuration.class.php
src/phpclasses/configuration.class.php5
test/Makefile.am
test/createdb [new file with mode: 0755]
test/gnucomo_test.conf [new file with mode: 0644]
test/messages
test/read_messages [new file with mode: 0755]
test/read_messages.log.expect [new file with mode: 0644]
test/t0001.errors [deleted file]
test/t0001.expect [deleted file]
test/t0001.sh [deleted file]
test/t0002a.errors [deleted file]
test/t0002a.expect [deleted file]
test/t0002a.sh [deleted file]
test/t0008.errors [deleted file]
test/t0008.expect [deleted file]
test/t0008.sh [deleted file]
test/upgradedb [new file with mode: 0755]

index e89b7ed..1728ae1 100644 (file)
@@ -179,7 +179,7 @@ CREATE TABLE "db_value"
 
 
 COPY "db_value" FROM stdin;
-db_version     53
+db_version     54
 gcm_daemon_version     5
 log_processing 0
 log_servicecheck       0
index 17d06a8..2b54ea4 100644 (file)
@@ -88,3 +88,8 @@ DROP TABLE "type_of_issue";
 
 DROP TABLE "usr";
 
+DROP GROUP IF EXISTS "view";
+DROP GROUP IF EXISTS "ops";
+DROP GROUP IF EXISTS "admin";
+DROP GROUP IF EXISTS "daemon";
+DROP ROLE IF EXISTS "gnucomo";
index d84a3e5..a172a44 100644 (file)
@@ -83,9 +83,6 @@
        $dbms->query($local_sql);
       
     case 9:
-       $local_sql = "ALTER TABLE log_adv_kernel_network ADD COLUMN window TEXT";
-       $dbms->query($local_sql);
        $local_sql = "ALTER TABLE log_adv_kernel_network ADD COLUMN urgp INT";
        $dbms->query($local_sql);
 
@@ -665,11 +662,45 @@ case 43:
 
    case 53:
 
+     $dbms->query("CREATE GROUP daemon");
+     $dbms->query("CREATE ROLE gnucomo LOGIN PASSWORD 'gnucomo' IN GROUP daemon");
+
      $dbms->query("GRANT UPDATE ON action_user_actionstepid_seq TO GROUP ops, GROUP admin");
 
      $dbms->query("GRANT INSERT ON property TO GROUP admin");
      $dbms->query("GRANT UPDATE ON property TO GROUP admin");
      $dbms->query("CREATE INDEX log_ab_src ON log_abuse (source, objectid)");
+     $dbms->query("CREATE UNIQUE INDEX log_ab_log ON log_abuse (logid)");
+     $dbms->query("GRANT INSERT ON action_user TO GROUP daemon");
+     $dbms->query("GRANT DELETE ON action_user TO GROUP daemon");
+     $dbms->query("GRANT INSERT ON log_abuse TO GROUP daemon");
+     $dbms->query("GRANT DELETE ON log_abuse TO GROUP daemon");
+     $dbms->query("GRANT SELECT ON log_abuse TO GROUP daemon");
+     $dbms->query("GRANT INSERT ON log_notification TO GROUP daemon");
+     $dbms->query("GRANT DELETE ON log_notification TO GROUP daemon");
+     $dbms->query("GRANT SELECT ON log_notification TO GROUP daemon");
+     $dbms->query("GRANT SELECT,INSERT,DELETE ON log TO GROUP daemon");
+     $dbms->query("GRANT SELECT,INSERT,DELETE ON notification TO GROUP daemon");
+     $dbms->query("GRANT SELECT,INSERT,DELETE,UPDATE ON parameter_class TO GROUP admin");
+     $dbms->query("GRANT SELECT,INSERT ON parameter TO GROUP daemon");
+     $dbms->query("GRANT SELECT,INSERT ON parameter_notification TO GROUP daemon");
+     $dbms->query("GRANT SELECT,INSERT ON history TO GROUP daemon");
+     $dbms->query("GRANT SELECT,INSERT,UPDATE ON object_abuse TO GROUP daemon");
+     $dbms->query("GRANT SELECT,INSERT,UPDATE ON object_statistics TO GROUP daemon");
+     $dbms->query("GRANT SELECT,INSERT,UPDATE ON property TO GROUP daemon");
+     $dbms->query("GRANT SELECT ON object_service TO GROUP daemon");
+     $dbms->query("GRANT SELECT ON object_user TO GROUP daemon");
+     $dbms->query("GRANT SELECT ON parameter_class TO GROUP daemon");
+     $dbms->query("GRANT SELECT ON service_pattern TO GROUP daemon");
+     $dbms->query("GRANT SELECT ON service TO GROUP daemon");
+     $dbms->query("GRANT SELECT ON type_of_issue TO GROUP daemon");
+     $dbms->query("GRANT SELECT ON usr TO GROUP daemon");
+     $dbms->query("GRANT SELECT,UPDATE ON notification_notificationid_seq TO GROUP daemon");
+     $dbms->query("GRANT SELECT,UPDATE ON db_value TO GROUP daemon");
+     $dbms->query("GRANT SELECT,UPDATE ON object TO GROUP daemon");
+     $dbms->query("GRANT UPDATE ON SEQUENCE action_user_actionstepid_seq TO daemon");
+     $dbms->query("GRANT UPDATE ON SEQUENCE log_logid_seq TO daemon");
+     $dbms->query("GRANT UPDATE ON SEQUENCE paramid_seq TO daemon");
 
 /*
 TODO:
index 68558f7..cb35aa9 100644 (file)
@@ -40,7 +40,7 @@
 
 /* static const char *RCSID = "$Id: gnucomo_config.h,v 1.3 2002-12-06 22:30:50 arjen Exp $"; */
 
-#include <AXE/configuration.h>
+#include <configuration.h>
 
 /*
 ///////////////////////////////////////////////////////////////////////////
index 692e918..84ca56b 100644 (file)
@@ -84,33 +84,39 @@ class configuration
          }
       }
 
-      if (isset($_ENV['HOME']) && $_ENV['HOME'] != '/')
+      // First try the user's config in the current dir.
+      $filename = $app_name . ".conf";
+      if (!is_readable($filename))
       {
-         //  Read configurations from the user's homedir.
-
-         $filename = $_ENV['HOME'] . "/." . $app_name . ".conf";
-         if (is_readable($filename))
+         print("Can not read $filename");
+         if (isset($_ENV['HOME']) && $_ENV['HOME'] != '/')
          {
+            //  Read configurations from the user's homedir.
 
-            $this->user = domxml_open_file($filename);
+            $filename = $_ENV['HOME'] . "/." . $app_name . ".conf";
+         }
+      }
+      if (is_readable($filename))
+      {
 
-            if ($this->user)
-            {
-               $root = $this->user->root();
+         $this->user = domxml_open_file($filename);
 
-               if ($root->tagname != $app_name)
-               {
-                  print("Configuration error: Wrong configuration file.<br>");
-                  $this->user = false;
-               }
+         if ($this->user)
+         {
+            $root = $this->user->root();
+
+            if ($root->tagname != $app_name)
+            {
+               print("Configuration error: Wrong configuration file.<br>");
+               $this->user = false;
             }
          }
-         
       }
+         
 
       if ($this->system == false && $this->user == false)
       {
-         print("Configuration error: Configuration file for $app_name not found.<br>\n");
+         print("Configuration error: Configuration file for $app_name is not found.<br>\n");
       }
 
       return $this->system != false || $this->user != false;
index 68c529e..88419e2 100644 (file)
@@ -86,28 +86,33 @@ class configuration
          }
       }
 
-      if (isset($_ENV['HOME']) && $_ENV['HOME'] != '/')
+      // First try the user's config in the current dir.
+      $filename = $app_name . ".conf";
+      if (!is_readable($filename))
       {
-         //  Read configurations from the user's homedir.
-
-         $filename = $_ENV['HOME'] . "/." . $app_name . ".conf";
-         if (is_readable($filename))
+         print("Can not read $filename");
+         if (isset($_ENV['HOME']) && $_ENV['HOME'] != '/')
          {
+            //  Read configurations from the user's homedir.
+
+            $filename = $_ENV['HOME'] . "/." . $app_name . ".conf";
+         }
+      }
+      if (is_readable($filename))
+      {
 
-            $this->user = new DOMDocument();
+         $this->user = new DOMDocument();
+         if ($this->user->load($filename))
+         {
+            $root = $this->user->documentElement;
 
-            if ($this->user->load($filename))
+            if ($root->tagName != $app_name)
             {
-               $root = $this->user->documentElement;
-
-               if ($root->tagName != $app_name)
-               {
-                  print("Configuration error: Wrong configuration file.<br>");
-                  $this->user = false;
-               }
+               print("Configuration error: Wrong configuration file.<br>");
+               $this->user = false;
             }
          }
-         
+
       }
 
       if ($this->system == false && $this->user == false)
index d2293eb..feb3f55 100644 (file)
@@ -1 +1 @@
-TESTS = gcmtest
+TESTS = createdb upgradedb read_messages
diff --git a/test/createdb b/test/createdb
new file mode 100755 (executable)
index 0000000..19221f3
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# First test. Create and destroy the database.
+
+createdb gnucomo_test
+
+if psql gnucomo_test -q <../src/database/create.sql
+then
+   psql gnucomo_test -c 'select statuscode from status'
+   result=$?
+   psql gnucomo_test -f ../src/database/destroy.sql -q
+else
+   echo Can not create test database
+   result=1
+fi
+
+dropdb gnucomo_test
+exit $result
diff --git a/test/gnucomo_test.conf b/test/gnucomo_test.conf
new file mode 100644 (file)
index 0000000..dff8843
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version='1.0'?>
+<gnucomo_test version='0.0.8'>
+   <database>
+      <type>PostgreSQL</type>
+      <name>gnucomo_test</name>
+      <user>arjen</user>
+      <password>guess-again:-)</password>
+      <!--    We do not use a TCP connection
+      <host>localhost</host>
+      <port>5432</port>
+      -->
+   </database>
+   <logging>
+      <method>file</method>
+      <destination>./gcm_input</destination>
+      <level>0</level>
+   </logging>
+   <gcm_daemon>
+      <user>arjen</user>
+      <password>test</password>
+   </gcm_daemon>
+</gnucomo_test>
+
index 42a23b3..e49d11b 100644 (file)
@@ -1,28 +1,28 @@
-Sep  1 04:02:51 kithira syslogd 1.4.1: restart.
-Sep  1 04:10:00 kithira CROND[17405]: (root) CMD (   /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as) 
-Sep  1 04:11:07 kithira kernel: isdn_net: local hangup ippp0
-Sep  1 04:11:07 kithira kernel: ippp0: Chargesum is 0
-Sep  1 04:11:07 kithira ipppd[1513]: Modem hangup
-Sep  1 04:11:07 kithira ipppd[1513]: Connection terminated.
-Sep  1 04:11:07 kithira ipppd[1513]: taking down PHASE_DEAD link 0, linkunit: 0
-Sep  1 04:11:07 kithira ipppd[1513]: closing fd 7 from unit 0
-Sep  1 04:11:07 kithira ipppd[1513]: link 0 closed , linkunit: 0
-Sep  1 04:11:07 kithira ipppd[1513]: reinit_unit: 0 
-Sep  1 04:11:07 kithira ipppd[1513]: Connect[0]: /dev/ippp0, fd: 7
-Sep  1 04:15:00 kithira CROND[17423]: (uucp) CMD (/usr/sbin/uucico -r1) 
-Sep  1 04:20:00 kithira CROND[17581]: (root) CMD (   /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as) 
-Sep  1 04:20:00 kithira kernel: solo1: unloading
-Sep  1 04:20:00 kithira kernel: Uniform CD-ROM driver unloaded
-Sep  1 04:20:01 kithira kernel: ide-floppy driver 0.99.newide
-Sep  1 04:20:02 kithira kernel: hdb: ATAPI 40X CD-ROM drive, 128kB Cache, DMA
-Sep  1 04:20:02 kithira kernel: Uniform CD-ROM driver Revision: 3.12
-Sep  1 04:20:02 kithira kernel: Attached scsi CD-ROM sr0 at scsi0, channel 0, id 4, lun 0
-Sep  1 04:20:02 kithira kernel: sr0: scsi3-mmc drive: 20x/20x writer cd/rw xa/form2 cdda tray
-Sep  1 04:22:00 kithira CROND[17587]: (root) CMD (run-parts /etc/cron.weekly) 
-Sep  1 04:22:00 kithira anacron[17591]: Error opening /etc/anacrontab: No such file or directory
-Sep  1 04:22:00 kithira anacron[17591]: Aborted
-Sep  1 04:30:00 kithira CROND[27975]: (root) CMD (   /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as) 
-Sep  1 04:30:51 kithira su(pam_unix)[27979]: session opened for user news by (uid=0)
-Sep  1 04:30:51 kithira su(pam_unix)[27979]: session closed for user news
-Sep  1 04:31:03 kithira named[996]: listening on IPv4 interface ippp0, 195.121.198.124#53
-Sep  1 04:31:03 kithira named[996]: no longer listening on 195.121.198.217#53
+Sep  1 04:02:51 example1 syslogd 1.4.1: restart.
+Sep  1 04:10:00 example1 CROND[17405]: (root) CMD (   /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as) 
+Sep  1 04:11:07 example1 kernel: isdn_net: local hangup ippp0
+Sep  1 04:11:07 example1 kernel: ippp0: Chargesum is 0
+Sep  1 04:11:07 example1 ipppd[1513]: Modem hangup
+Sep  1 04:11:07 example1 ipppd[1513]: Connection terminated.
+Sep  1 04:11:07 example1 ipppd[1513]: taking down PHASE_DEAD link 0, linkunit: 0
+Sep  1 04:11:07 example1 ipppd[1513]: closing fd 7 from unit 0
+Sep  1 04:11:07 example1 ipppd[1513]: link 0 closed , linkunit: 0
+Sep  1 04:11:07 example1 ipppd[1513]: reinit_unit: 0 
+Sep  1 04:11:07 example1 ipppd[1513]: Connect[0]: /dev/ippp0, fd: 7
+Sep  1 04:15:00 example1 CROND[17423]: (uucp) CMD (/usr/sbin/uucico -r1) 
+Sep  1 04:20:00 example1 CROND[17581]: (root) CMD (   /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as) 
+Sep  1 04:20:00 example1 kernel: solo1: unloading
+Sep  1 04:20:00 example1 kernel: Uniform CD-ROM driver unloaded
+Sep  1 04:20:01 example1 kernel: ide-floppy driver 0.99.newide
+Sep  1 04:20:02 example1 kernel: hdb: ATAPI 40X CD-ROM drive, 128kB Cache, DMA
+Sep  1 04:20:02 example1 kernel: Uniform CD-ROM driver Revision: 3.12
+Sep  1 04:20:02 example1 kernel: Attached scsi CD-ROM sr0 at scsi0, channel 0, id 4, lun 0
+Sep  1 04:20:02 example1 kernel: sr0: scsi3-mmc drive: 20x/20x writer cd/rw xa/form2 cdda tray
+Sep  1 04:22:00 example1 CROND[17587]: (root) CMD (run-parts /etc/cron.weekly) 
+Sep  1 04:22:00 example1 anacron[17591]: Error opening /etc/anacrontab: No such file or directory
+Sep  1 04:22:00 example1 anacron[17591]: Aborted
+Sep  1 04:30:00 example1 CROND[27975]: (root) CMD (   /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as) 
+Sep  1 04:30:51 example1 su(pam_unix)[27979]: session opened for user news by (uid=0)
+Sep  1 04:30:51 example1 su(pam_unix)[27979]: session closed for user news
+Sep  1 04:31:03 example1 named[996]: listening on IPv4 interface ippp0, 195.121.198.124#53
+Sep  1 04:31:03 example1 named[996]: no longer listening on 195.121.198.217#53
diff --git a/test/read_messages b/test/read_messages
new file mode 100755 (executable)
index 0000000..36c861e
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+#
+#  Create an object 'kithira.andromeda.nl' in the database and
+#  parse a piece of a syslog file.
+#  This tests normal operation in which gcm_input reads a syslog file
+#  directly.
+
+
+createdb gnucomo_test
+
+if psql gnucomo_test -q <../src/database/create.sql >/dev/null
+then
+   psql gnucomo_test -q -c "insert into object (objectname) values ('example1.gnucomo.test')"
+   ../src/gcm_input/gcm_input -c gnucomo_test -h example1.gnucomo.test -d 'sep 5 2002 20:30:45' <messages
+   psql gnucomo_test -q -t -c "select * from log" -o log.tbl
+   diff read_messages.log.expect log.tbl
+   result=$?
+   psql gnucomo_test -f ../src/database/destroy.sql -q
+   dropdb gnucomo_test
+   exit $result
+else
+   echo Can not create test database
+   dropdb gnucomo_test
+   exit 1
+fi
diff --git a/test/read_messages.log.expect b/test/read_messages.log.expect
new file mode 100644 (file)
index 0000000..c2303ae
--- /dev/null
@@ -0,0 +1,29 @@
+     1 |        1 |                   | syslogd     | 2002-09-01 04:02:51+02 | 2002-09-05 20:30:45+02 | Sep  1 04:02:51 example1 syslogd 1.4.1: restart.                                                         | f         | f
+     2 |        1 |                   | CROND       | 2002-09-01 04:10:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:10:00 example1 CROND[17405]: (root) CMD (   /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as)  | f         | f
+     3 |        1 |                   | kernel      | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 example1 kernel: isdn_net: local hangup ippp0                                            | f         | f
+     4 |        1 |                   | kernel      | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 example1 kernel: ippp0: Chargesum is 0                                                   | f         | f
+     5 |        1 |                   | ipppd       | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 example1 ipppd[1513]: Modem hangup                                                       | f         | f
+     6 |        1 |                   | ipppd       | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 example1 ipppd[1513]: Connection terminated.                                             | f         | f
+     7 |        1 |                   | ipppd       | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 example1 ipppd[1513]: taking down PHASE_DEAD link 0, linkunit: 0                         | f         | f
+     8 |        1 |                   | ipppd       | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 example1 ipppd[1513]: closing fd 7 from unit 0                                           | f         | f
+     9 |        1 |                   | ipppd       | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 example1 ipppd[1513]: link 0 closed , linkunit: 0                                        | f         | f
+    10 |        1 |                   | ipppd       | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 example1 ipppd[1513]: reinit_unit: 0                                                     | f         | f
+    11 |        1 |                   | ipppd       | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 example1 ipppd[1513]: Connect[0]: /dev/ippp0, fd: 7                                      | f         | f
+    12 |        1 |                   | CROND       | 2002-09-01 04:15:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:15:00 example1 CROND[17423]: (uucp) CMD (/usr/sbin/uucico -r1)                                 | f         | f
+    13 |        1 |                   | CROND       | 2002-09-01 04:20:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:00 example1 CROND[17581]: (root) CMD (   /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as)  | f         | f
+    14 |        1 |                   | kernel      | 2002-09-01 04:20:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:00 example1 kernel: solo1: unloading                                                        | f         | f
+    15 |        1 |                   | kernel      | 2002-09-01 04:20:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:00 example1 kernel: Uniform CD-ROM driver unloaded                                          | f         | f
+    16 |        1 |                   | kernel      | 2002-09-01 04:20:01+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:01 example1 kernel: ide-floppy driver 0.99.newide                                           | f         | f
+    17 |        1 |                   | kernel      | 2002-09-01 04:20:02+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:02 example1 kernel: hdb: ATAPI 40X CD-ROM drive, 128kB Cache, DMA                           | f         | f
+    18 |        1 |                   | kernel      | 2002-09-01 04:20:02+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:02 example1 kernel: Uniform CD-ROM driver Revision: 3.12                                    | f         | f
+    19 |        1 |                   | kernel      | 2002-09-01 04:20:02+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:02 example1 kernel: Attached scsi CD-ROM sr0 at scsi0, channel 0, id 4, lun 0               | f         | f
+    20 |        1 |                   | kernel      | 2002-09-01 04:20:02+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:02 example1 kernel: sr0: scsi3-mmc drive: 20x/20x writer cd/rw xa/form2 cdda tray           | f         | f
+    21 |        1 |                   | CROND       | 2002-09-01 04:22:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:22:00 example1 CROND[17587]: (root) CMD (run-parts /etc/cron.weekly)                           | f         | f
+    22 |        1 |                   | anacron     | 2002-09-01 04:22:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:22:00 example1 anacron[17591]: Error opening /etc/anacrontab: No such file or directory        | f         | f
+    23 |        1 |                   | anacron     | 2002-09-01 04:22:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:22:00 example1 anacron[17591]: Aborted                                                         | f         | f
+    24 |        1 |                   | CROND       | 2002-09-01 04:30:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:30:00 example1 CROND[27975]: (root) CMD (   /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as)  | f         | f
+    25 |        1 |                   | su          | 2002-09-01 04:30:51+02 | 2002-09-05 20:30:45+02 | Sep  1 04:30:51 example1 su(pam_unix)[27979]: session opened for user news by (uid=0)                    | f         | f
+    26 |        1 |                   | su          | 2002-09-01 04:30:51+02 | 2002-09-05 20:30:45+02 | Sep  1 04:30:51 example1 su(pam_unix)[27979]: session closed for user news                               | f         | f
+    27 |        1 |                   | named       | 2002-09-01 04:31:03+02 | 2002-09-05 20:30:45+02 | Sep  1 04:31:03 example1 named[996]: listening on IPv4 interface ippp0, 195.121.198.124#53               | f         | f
+    28 |        1 |                   | named       | 2002-09-01 04:31:03+02 | 2002-09-05 20:30:45+02 | Sep  1 04:31:03 example1 named[996]: no longer listening on 195.121.198.217#53                           | f         | f
+
diff --git a/test/t0001.errors b/test/t0001.errors
deleted file mode 100644 (file)
index 9bdf288..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "object_abuse_pkey" for table "object_abuse"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "object_statistics_pkey" for table "object_statistics"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "parameter_pkey" for table "parameter"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "parameter_class_pkey" for table "parameter_class"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "parameter_notification_pkey" for table "parameter_notification"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "property_pkey" for table "property"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "service_pattern_pkey" for table "service_pattern"
-ERROR:  role "view" already exists
-ERROR:  role "ops" already exists
-ERROR:  role "admin" already exists
-ERROR:  role "daemon" already exists
-ERROR:  role "gnucomo" already exists
diff --git a/test/t0001.expect b/test/t0001.expect
deleted file mode 100644 (file)
index 7ae921f..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
- statuscode 
-------------
- new
- opn
- pen
- ver
- rej
- cls
- inv
-(7 rows)
-
diff --git a/test/t0001.sh b/test/t0001.sh
deleted file mode 100644 (file)
index 257d505..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-# First test. Create and destroy the database.
-
-cd ..
-
-if psql gnucomo_test -q <src/database/create.sql >/dev/null
-then
-   psql gnucomo_test -c 'select statuscode from status'
-   result=$?
-   psql gnucomo_test -f src/database/destroy.sql -q
-   exit $result
-else
-   echo Can not create test database
-   exit 1
-fi
diff --git a/test/t0002a.errors b/test/t0002a.errors
deleted file mode 100644 (file)
index 9bdf288..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "object_abuse_pkey" for table "object_abuse"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "object_statistics_pkey" for table "object_statistics"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "parameter_pkey" for table "parameter"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "parameter_class_pkey" for table "parameter_class"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "parameter_notification_pkey" for table "parameter_notification"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "property_pkey" for table "property"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "service_pattern_pkey" for table "service_pattern"
-ERROR:  role "view" already exists
-ERROR:  role "ops" already exists
-ERROR:  role "admin" already exists
-ERROR:  role "daemon" already exists
-ERROR:  role "gnucomo" already exists
diff --git a/test/t0002a.expect b/test/t0002a.expect
deleted file mode 100644 (file)
index c1d233c..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
- objectid |      objectname      | objectcode | scp_enabled | scp_inet | mail_enabled | mail_from | sms_enabled | sms_number | fax_enabled | fax_number | object_description | object_owner | physical_location | timezone | remark | os | os_version | log_count | notification_count | parameter_count 
-----------+----------------------+------------+-------------+----------+--------------+-----------+-------------+------------+-------------+------------+--------------------+--------------+-------------------+----------+--------+----+------------+-----------+--------------------+-----------------
-        1 | kithira.andromeda.nl |            |             |          |              |           |             |            |             |            |                    |              |                   |          |        |    |            |           |                    |                
-(1 row)
-
- logid | objectid | original_filename | servicecode |    object_timestamp    |       timestamp        |                                                 rawdata                                                 | processed | recognized 
--------+----------+-------------------+-------------+------------------------+------------------------+---------------------------------------------------------------------------------------------------------+-----------+------------
-     1 |        1 |                   | syslogd     | 2002-09-01 04:02:51+02 | 2002-09-05 20:30:45+02 | Sep  1 04:02:51 kithira syslogd 1.4.1: restart.                                                         | f         | f
-     2 |        1 |                   | CROND       | 2002-09-01 04:10:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:10:00 kithira CROND[17405]: (root) CMD (   /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as)  | f         | f
-     3 |        1 |                   | kernel      | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 kithira kernel: isdn_net: local hangup ippp0                                            | f         | f
-     4 |        1 |                   | kernel      | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 kithira kernel: ippp0: Chargesum is 0                                                   | f         | f
-     5 |        1 |                   | ipppd       | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 kithira ipppd[1513]: Modem hangup                                                       | f         | f
-     6 |        1 |                   | ipppd       | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 kithira ipppd[1513]: Connection terminated.                                             | f         | f
-     7 |        1 |                   | ipppd       | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 kithira ipppd[1513]: taking down PHASE_DEAD link 0, linkunit: 0                         | f         | f
-     8 |        1 |                   | ipppd       | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 kithira ipppd[1513]: closing fd 7 from unit 0                                           | f         | f
-     9 |        1 |                   | ipppd       | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 kithira ipppd[1513]: link 0 closed , linkunit: 0                                        | f         | f
-    10 |        1 |                   | ipppd       | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 kithira ipppd[1513]: reinit_unit: 0                                                     | f         | f
-    11 |        1 |                   | ipppd       | 2002-09-01 04:11:07+02 | 2002-09-05 20:30:45+02 | Sep  1 04:11:07 kithira ipppd[1513]: Connect[0]: /dev/ippp0, fd: 7                                      | f         | f
-    12 |        1 |                   | CROND       | 2002-09-01 04:15:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:15:00 kithira CROND[17423]: (uucp) CMD (/usr/sbin/uucico -r1)                                 | f         | f
-    13 |        1 |                   | CROND       | 2002-09-01 04:20:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:00 kithira CROND[17581]: (root) CMD (   /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as)  | f         | f
-    14 |        1 |                   | kernel      | 2002-09-01 04:20:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:00 kithira kernel: solo1: unloading                                                        | f         | f
-    15 |        1 |                   | kernel      | 2002-09-01 04:20:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:00 kithira kernel: Uniform CD-ROM driver unloaded                                          | f         | f
-    16 |        1 |                   | kernel      | 2002-09-01 04:20:01+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:01 kithira kernel: ide-floppy driver 0.99.newide                                           | f         | f
-    17 |        1 |                   | kernel      | 2002-09-01 04:20:02+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:02 kithira kernel: hdb: ATAPI 40X CD-ROM drive, 128kB Cache, DMA                           | f         | f
-    18 |        1 |                   | kernel      | 2002-09-01 04:20:02+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:02 kithira kernel: Uniform CD-ROM driver Revision: 3.12                                    | f         | f
-    19 |        1 |                   | kernel      | 2002-09-01 04:20:02+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:02 kithira kernel: Attached scsi CD-ROM sr0 at scsi0, channel 0, id 4, lun 0               | f         | f
-    20 |        1 |                   | kernel      | 2002-09-01 04:20:02+02 | 2002-09-05 20:30:45+02 | Sep  1 04:20:02 kithira kernel: sr0: scsi3-mmc drive: 20x/20x writer cd/rw xa/form2 cdda tray           | f         | f
-    21 |        1 |                   | CROND       | 2002-09-01 04:22:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:22:00 kithira CROND[17587]: (root) CMD (run-parts /etc/cron.weekly)                           | f         | f
-    22 |        1 |                   | anacron     | 2002-09-01 04:22:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:22:00 kithira anacron[17591]: Error opening /etc/anacrontab: No such file or directory        | f         | f
-    23 |        1 |                   | anacron     | 2002-09-01 04:22:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:22:00 kithira anacron[17591]: Aborted                                                         | f         | f
-    24 |        1 |                   | CROND       | 2002-09-01 04:30:00+02 | 2002-09-05 20:30:45+02 | Sep  1 04:30:00 kithira CROND[27975]: (root) CMD (   /sbin/lsmod >/var/log/lsmod.log; /sbin/rmmod -as)  | f         | f
-    25 |        1 |                   | su          | 2002-09-01 04:30:51+02 | 2002-09-05 20:30:45+02 | Sep  1 04:30:51 kithira su(pam_unix)[27979]: session opened for user news by (uid=0)                    | f         | f
-    26 |        1 |                   | su          | 2002-09-01 04:30:51+02 | 2002-09-05 20:30:45+02 | Sep  1 04:30:51 kithira su(pam_unix)[27979]: session closed for user news                               | f         | f
-    27 |        1 |                   | named       | 2002-09-01 04:31:03+02 | 2002-09-05 20:30:45+02 | Sep  1 04:31:03 kithira named[996]: listening on IPv4 interface ippp0, 195.121.198.124#53               | f         | f
-    28 |        1 |                   | named       | 2002-09-01 04:31:03+02 | 2002-09-05 20:30:45+02 | Sep  1 04:31:03 kithira named[996]: no longer listening on 195.121.198.217#53                           | f         | f
-(28 rows)
-
diff --git a/test/t0002a.sh b/test/t0002a.sh
deleted file mode 100644 (file)
index 4c9e1d5..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh
-
-#
-#  Create an object 'kithira.andromeda.nl' in the database and
-#  parse a piece of a syslog file.
-#  This tests normal operation in which gcm_input reads a syslog file
-#  directly.
-
-LD_LIBRARY_PATH=/usr/local/pqxx/lib
-export LD_LIBRARY_PATH
-
-cd ..
-
-if psql gnucomo_test -q <src/database/create.sql >/dev/null
-then
-   psql gnucomo_test -q -c "insert into object (objectname) values ('kithira.andromeda.nl')"
-   psql gnucomo_test -c "select * from object"
-   src/gcm_input/gcm_input -c gnucomo_test -h kithira.andromeda.nl -d 'sep 5 2002 20:30:45' <test/messages
-   psql gnucomo_test -c "select * from log"
-   psql gnucomo_test -f src/database/destroy.sql -q
-   exit $result
-else
-   echo Can not create test database
-   exit 1
-fi
diff --git a/test/t0008.errors b/test/t0008.errors
deleted file mode 100644 (file)
index fcf3d85..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "parameter_pkey" for table "parameter"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "property_pkey" for table "property"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "object_abuse_pkey" for table "object_abuse"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "object_statistics_pkey" for table "object_statistics"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "parameter_pkey" for table "parameter"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "parameter_class_pkey" for table "parameter_class"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "parameter_notification_pkey" for table "parameter_notification"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "property_pkey" for table "property"
-NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "service_pattern_pkey" for table "service_pattern"
diff --git a/test/t0008.expect b/test/t0008.expect
deleted file mode 100644 (file)
index 8bf53e4..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-Content-type: text/html\r
-X-Powered-By: PHP/4.3.4\r
-\r
-
-621a622,624
-> 
-> 
-> 
-697c700
-< 1    manual entry    4       A manual entry of a notification        t       t       1       \N      \N
----
-> 1    manual entry    4       A manual entry of a notification        t       \N      \N      \N      \N
-701,702c704,705
-< 2    parameter created       3       A new parameter was created     t       t       1       \N      \N
-< 3    property modified       3       The STATIC property of a parameter was modified t       t       1       \N      \N
----
-> 2    parameter created       3       A new parameter was created     t       \N      \N      \N      \N
-> 3    property modified       3       The STATIC property of a parameter was modified t       \N      \N      \N      \N
-704c707
-< 4    parameter removed       3       A parameter was removed t       t       1       \N      \N
----
-> 4    parameter removed       3       A parameter was removed t       \N      \N      \N      \N
-707c710
-< 5    service unknown 5       Service in log entry is unknown t       t       1       \N      \N
----
-> 5    service unknown 5       Service in log entry is unknown t       \N      \N      \N      \N
-709,710c712,713
-< 6    service not used        5       Service in log entry is not used        t       t       1       \N      \N
-< 7    abuses exceeded 5       Abuse treshold exceeded from an IP address      t       t       1       \N      \N
----
-> 6    service not used        5       Service in log entry is not used        t       \N      \N      \N      \N
-> 7    abuses exceeded 5       Abuse treshold exceeded from an IP address      t       \N      \N      \N      \N
-768c771
-< COPY log_adv_kernel_network (log_advid, logid, detailed_table, device_in, device_out, hw_address, source_ip, destination_ip, packet_length, tos_bit, prec_bit, ttl, header_id, source_port, destination_port, body_length, protocol, body_len, window, urgp, syn, "type", code, sequence_number, res, rst, df) FROM stdin;
----
-> COPY log_adv_kernel_network (log_advid, logid, detailed_table, device_in, device_out, source_ip, destination_ip, packet_length, tos_bit, prec_bit, ttl, header_id, source_port, destination_port, body_length, protocol, body_len, window, urgp, syn, "type", code, sequence_number, res, rst, df, hw_address) FROM stdin;
-848a852
-> CREATE RULE log_update AS ON UPDATE TO log DO INSTEAD NOTHING;
-937,940c941,944
-<     detailed_table text
-<     device_in text,
-<     device_out text,
-<     df boolean
----
->     detailed_table character varying(75)
->     device_in character varying(15),
->     device_out character varying(15),
->     df boolean,
-1045c1049
-<     hw_address text,
----
->     hw_address text
-1079a1084
-> log_servicecheck     0
-1161c1166
-<     prec_bit text,
----
->     prec_bit character varying(5),
-1169c1174
-<     protocol text,
----
->     protocol character varying(5),
-1182c1187
-<     res text,
----
->     res character varying(5),
-1231c1236
-< SELECT pg_catalog.setval('type_of_issue_type_of_issue_seq', 6, true);
----
-> SELECT pg_catalog.setval('type_of_issue_type_of_issue_seq', 7, true);
-1291c1296
-<     tos_bit text,
----
->     tos_bit character varying(5),
diff --git a/test/t0008.sh b/test/t0008.sh
deleted file mode 100644 (file)
index bdb3e48..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-
-#
-#  Test the database upgrades in gcm_daemon.
-#  Create an old, version 1, database and run gcm_daemon to perform
-#  an upgrade to the latest version.
-#  Then, create a latest-version database and compare dumps of these
-#  database. They should be essentially the same.
-
-cd ..
-
-if psql gnucomo_test <test/create_v1.sql -q >/dev/null
-then
-   cd src/gcm_daemon; ./gcm_daemon.php -c gnucomo_test ; cd ../..
-   pg_dump gnucomo_test |grep -v '^--' | sort >test/dump.upgraded.sql
-   psql gnucomo_test -f src/database/destroy.sql -q
-   psql gnucomo_test <src/database/create.sql -q >/dev/null
-   pg_dump gnucomo_test |grep -v '^--' | sort >test/dump.latest.sql
-   psql gnucomo_test -f src/database/destroy.sql -q
-
-   #  Expect 28 lines of diff output (character varying vs. text types)
-   diff test/dump.latest.sql test/dump.upgraded.sql
-
-   exit 0
-else
-   echo Can not create test database
-   exit 1
-fi
diff --git a/test/upgradedb b/test/upgradedb
new file mode 100755 (executable)
index 0000000..009cee0
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+#
+#  Test the database upgrades in gcm_daemon.
+#  Create an old, version 1, database and run gcm_daemon to perform
+#  an upgrade to the latest version.
+#  Then, create a latest-version database and compare dumps of these
+#  database. They should be essentially the same.
+
+
+createdb gnucomo_test
+
+if psql gnucomo_test <create_v1.sql -q >/dev/null
+then
+   cd ../src/gcm_daemon; ln -f -s ../../test/gnucomo_test.conf .; ./gcm_daemon.php -c gnucomo_test ; cd ../../test
+   pg_dump gnucomo_test |grep -v '^--' | sort >dump.upgraded.sql
+   psql gnucomo_test -f ../src/database/destroy.sql -q
+   psql gnucomo_test <../src/database/create.sql -q >/dev/null
+   pg_dump gnucomo_test |grep -v '^--' | sort >dump.latest.sql
+   psql gnucomo_test -f ../src/database/destroy.sql -q
+
+   #  Expect 28 lines of diff output (character varying vs. text types)
+   echo Comparing dump.latest.sql with dump.upgraded.sql
+   diff dump.latest.sql dump.upgraded.sql
+   result=$?
+
+   dropdb gnucomo_test
+   exit $result
+else
+   echo Can not create test database
+   dropdb gnucomo_test
+   exit 1
+fi