GithubHelp home page GithubHelp logo

greenbone / pg-gvm Goto Github PK

View Code? Open in Web Editor NEW
7.0 13.0 15.0 186 KB

Greenbone Library for helper functions in PostgreSQL

License: GNU General Public License v3.0

CMake 50.37% C 33.98% PLpgSQL 7.60% Shell 6.16% Dockerfile 1.89%
greenbone postgresql ical icalendar database cmake extended techops tooling

pg-gvm's Introduction

Greenbone Logo

Greenbone Library for ical functions

This library contains functionality for ical object manipulation.

Build and Installation

Prerequisites

  • GCC
  • cmake >= 3.0
  • pkg-config
  • libical >= 1.0.0
  • glib >= 2.42
  • PostgreSQL dev >= 9.6
  • libgvm-base >= 20.8

Install these packages using (on Debian GNU/Linux bookworm 12):

apt-get install gcc cmake pkg-config libical-dev libglib2.0-dev postgresql-server-dev-15

and build the gvm-libs as described in the README.

Configure and Build

This extension can be configured, built and installed with the following commands:

cmake .
make && make install

Use the extension

To use the extension in a database create the extension using

CREATE EXTENSION "pg-gvm";

Test the extension

The tests are based on pgTAP, a unit test tool for PostgreSQL Databases.

Setup for tests

Install pgTAP cloning the repository

and follow the instructions in the setup documentation

Integration

To use pgTAP in a database use

CREATE EXTENSION IF NOT EXISTS pgtap;

as postgres user. To check if the extension exists use

\dx

Running the tests

The tests are located in the tests folder of this repository.

As postgres user run (replace MY_DATABASE with the real name of the database)

pg_prove -d MY_DATABASE tests/*.sql

pg-gvm's People

Contributors

bjoernricks avatar cfi-gb avatar dependabot[bot] avatar dexus avatar greenbonebot avatar nichtsfrei avatar rrenkert avatar s-l-teichmann avatar tacire avatar timopollmeier avatar y0urself avatar ygerlach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pg-gvm's Issues

CMAKE_INSTALL_DEV_PREFIX ?

Hi,
the build script outputs the value of
CMAKE_INSTALL_PREFIX as "install prefix" but then actually uses
CMAKE_INSTALL_DEV_PREFIX instead...

CMake errors while building

I am currently building version 22.6.1 on Fedora 38, and encountered an error. While running cmake :

CMake Error at CMakeLists.txt:116 (string):
  string sub-command REGEX, mode MATCH needs at least 5 arguments total to
  command.


CMake Error at CMakeLists.txt:118 (message):
  Error matching PostgreSQL version.

I have spent some time debugging and found that there are two main problems.

Delusive error message with regex

In CMakeLists.txt:116 the variable PostgreSQL_VERSION_STRING is empty, which creates the first error, because there is nothing there. This can be bypassed by quoting the variable to "${PostgreSQL_VERSION_STRING}" which removes the first, unnecessary and delusive error message.

Not found version to an installed package

The second error is caused by the version query algorithm in cmake/FindPostgreSQL.cmake. To my current understanding, this script iterates through the include paths, and find all files named: pg_config*.h. Then iterates through these files and tries to find a specific C macro called #define PG_VERSION_NUM <some-version-info>. I have tweaked my way around this problem, by adding the next line to CMakeLists.txt before the find_package call:

set(PostgreSQL_INCLUDE_DIR "/usr/include") 

Apparently CMake on this distribution fails to find the appropriate include directory, and after this modification the package seems to compile without further trouble .

I am not sure if there is any other, more elegant way of getting rid of these errors, as I am far from an expert in cmake, but this may worth a fix.

Unable to start container

I have translated docker-compose file into helm yamls.

Looking at the scripts , unsure what needs to occur for it to utilize a PV properly.

Using: greenbone/pg-gvm:stable

chmod: cannot access '/var/lib/postgresql/13/main': No such file or directory
2024-06-04T18:26:17.345517125-04:00 Error: /var/lib/postgresql/13/main is not accessible or does not exist
psql: error: could not connect to server: No such file or directory
2024-06-04T18:26:17.395796744-04:00 	Is the server running locally and accepting
2024-06-04T18:26:17.395804363-04:00 	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
2024-06-04T18:26:17.433237460-04:00 createuser: error: could not connect to database template1: could not connect to server: No such file or directory
2024-06-04T18:26:17.433272681-04:00 	Is the server running locally and accepting
	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
2024-06-04T18:26:17.484543504-04:00 psql: error: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
2024-06-04T18:26:17.531692107-04:00 createdb: error: could not connect to database template1: could not connect to server: No such file or directory
	Is the server running locally and accepting
2024-06-04T18:26:17.531717569-04:00 	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
2024-06-04T18:26:17.576425530-04:00 psql: error: could not connect to server: No such file or directory
2024-06-04T18:26:17.576451161-04:00 	Is the server running locally and accepting
2024-06-04T18:26:17.576458841-04:00 	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
psql: error: could not connect to server: No such file or directory
2024-06-04T18:26:17.631803575-04:00 	Is the server running locally and accepting
2024-06-04T18:26:17.631811695-04:00 	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
psql: error: could not connect to server: No such file or directory
2024-06-04T18:26:17.691172941-04:00 	Is the server running locally and accepting
2024-06-04T18:26:17.691181081-04:00 	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
2024-06-04T18:26:17.735564474-04:00 psql: error: could not connect to server: No such file or directory
	Is the server running locally and accepting
2024-06-04T18:26:17.735594423-04:00 	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
2024-06-04T18:26:17.782956829-04:00 psql: error: could not connect to server: No such file or directory
	Is the server running locally and accepting
2024-06-04T18:26:17.783063361-04:00 	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
2024-06-04T18:26:17.829794470-04:00 psql: error: could not connect to server: No such file or directory
2024-06-04T18:26:17.829812880-04:00 	Is the server running locally and accepting
2024-06-04T18:26:17.829818150-04:00 	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
2024-06-04T18:26:17.878226895-04:00 psql: error: could not connect to server: No such file or directory
	Is the server running locally and accepting
2024-06-04T18:26:17.878266696-04:00 	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
2024-06-04T18:26:17.934704148-04:00 psql: error: could not connect to server: No such file or directory
2024-06-04T18:26:17.934724958-04:00 	Is the server running locally and accepting
2024-06-04T18:26:17.934729599-04:00 	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
psql: error: could not connect to server: No such file or directory
	Is the server running locally and accepting
	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
2024-06-04T18:26:18.046965723-04:00 Error: /var/lib/postgresql/13/main is not accessible or does not exist
2024-06-04T18:26:18.097667445-04:00 Error: /var/lib/postgresql/13/main is not accessible or does not exist
2024-06-04T18:26:18.100285848-04:00 Deleted verification file.

Latest stable version doesn't work

I faced with starting issue of GVM a few days ago and it's still actual for the latest stable image from docker hub.
PG doesn't start in pg-gvm service because postgresql extension can't be found:

Logs of the pg-gvm service
cat /var/log/postgresql/postgresql-13-main.log

2022-07-16 12:07:54.984 UTC [23] LOG:  starting PostgreSQL 13.7 (Debian 13.7-0+deb11u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2022-07-16 12:07:55.000 UTC [23] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2022-07-16 12:07:55.000 UTC [23] LOG:  could not bind IPv6 address "::1": Cannot assign requested address
2022-07-16 12:07:55.000 UTC [23] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2022-07-16 12:07:55.005 UTC [23] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2022-07-16 12:07:55.054 UTC [24] LOG:  database system was shut down at 2022-07-15 11:38:33 UTC
2022-07-16 12:07:55.060 UTC [23] LOG:  database system is ready to accept connections

2022-07-16 12:08:25.816 UTC [79] postgres@gvmd ERROR:  could not open extension control file "/usr/share/postgresql/13/extension/pg-gvm.control": No such file or directory

2022-07-16 12:08:25.816 UTC [79] postgres@gvmd STATEMENT:  create extension "pg-gvm";
2022-07-16 12:08:25.867 UTC [23] LOG:  received fast shutdown request
2022-07-16 12:08:25.870 UTC [23] LOG:  aborting any active transactions
2022-07-16 12:08:25.871 UTC [23] LOG:  background worker "logical replication launcher" (PID 30) exited with exit code 1
2022-07-16 12:08:25.871 UTC [25] LOG:  shutting down
2022-07-16 12:08:25.898 UTC [23] LOG:  database system is shut down
736f7eef24d0

I guess that this issue the reason why gvmd container is going to infinity loop:

Logs of the gvmd service
docker-compose -p greenbone-community-edition logs -f gvmd

greenbone-community-edition-gvmd-1  | waiting 1 second for ready postgres container
greenbone-community-edition-gvmd-1  | waiting 1 second for ready postgres container
greenbone-community-edition-gvmd-1  | waiting 1 second for ready postgres container
greenbone-community-edition-gvmd-1  | waiting 1 second for ready postgres container
greenbone-community-edition-gvmd-1  | waiting 1 second for ready postgres container

A previous image worked properly and contained missed pg extension.

Can you look into it, maybe something wrong with a builder?

Extension "pg-gvm" has no installation script nor update path for version "1.1"

The above error message is being thrown when using the latest 22.5.0 build of pg-gvm (automatically download using community-containers).

Is this the same issue as the previous Issue with the same title? #39

Container built yesterday prior to 22.5.0 being released:

2023-06-19 02:27:41.341 UTC [23] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2023-06-19 02:27:41.341 UTC [23] LOG:  could not bind IPv6 address "::1": Cannot assign requested address
2023-06-19 02:27:41.341 UTC [23] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2023-06-19 02:27:41.352 UTC [23] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2023-06-19 02:27:41.365 UTC [24] LOG:  database system was interrupted; last known up at 2023-06-19 02:23:17 UTC
2023-06-19 02:27:41.802 UTC [24] LOG:  database system was not properly shut down; automatic recovery in progress
2023-06-19 02:27:41.805 UTC [24] LOG:  redo starts at 3/4A64FA28
2023-06-19 02:27:41.806 UTC [24] LOG:  invalid record length at 3/4A650538: wanted 24, got 0
2023-06-19 02:27:41.806 UTC [24] LOG:  redo done at 3/4A650508
2023-06-19 02:27:41.828 UTC [23] LOG:  database system is ready to accept connections
createuser: error: creation of new role failed: ERROR:  role "gvmd" already exists
createdb: error: database creation failed: ERROR:  database "gvmd" already exists
ERROR:  role "dba" already exists
NOTICE:  role "gvmd" is already a member of role "dba"
GRANT ROLE
ERROR:  extension "uuid-ossp" already exists
ERROR:  extension "pgcrypto" already exists
ERROR:  extension "pg-gvm" already exists
2023-06-19 02:28:13.315 UTC [83] LOG:  starting PostgreSQL 13.8 (Debian 13.8-0+deb11u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2023-06-19 02:28:13.316 UTC [83] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2023-06-19 02:28:13.316 UTC [83] LOG:  could not bind IPv6 address "::1": Cannot assign requested address
2023-06-19 02:28:13.316 UTC [83] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2023-06-19 02:28:13.320 UTC [83] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-06-19 02:28:13.325 UTC [84] LOG:  database system was shut down at 2023-06-19 02:28:13 UTC
2023-06-19 02:28:13.331 UTC [83] LOG:  database system is ready to accept connections

Container built today using 22.5.0:

2023-06-20 03:59:36.430 UTC [23] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2023-06-20 03:59:36.430 UTC [23] LOG:  could not bind IPv6 address "::1": Cannot assign requested address
2023-06-20 03:59:36.430 UTC [23] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2023-06-20 03:59:36.558 UTC [23] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2023-06-20 03:59:36.779 UTC [24] LOG:  database system was interrupted; last known up at 2023-06-20 03:58:53 UTC
2023-06-20 03:59:49.112 UTC [24] LOG:  database system was not properly shut down; automatic recovery in progress
2023-06-20 03:59:49.121 UTC [24] LOG:  invalid record length at 0/1610C48: wanted 24, got 0
2023-06-20 03:59:49.121 UTC [24] LOG:  redo is not required
2023-06-20 03:59:49.207 UTC [23] LOG:  database system is ready to accept connections
createuser: error: creation of new role failed: ERROR:  role "gvmd" already exists
createdb: error: database creation failed: ERROR:  database "gvmd" already exists
ERROR:  role "dba" already exists
GRANT ROLE
NOTICE:  role "gvmd" is already a member of role "dba"
ERROR:  extension "uuid-ossp" already exists
ERROR:  extension "pgcrypto" already exists
ERROR:  extension "pg-gvm" has no installation script nor update path for version "1.1"
2023-06-20 04:00:19.997 UTC [83] LOG:  starting PostgreSQL 13.11 (Debian 13.11-0+deb11u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2023-06-20 04:00:19.998 UTC [83] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2023-06-20 04:00:19.998 UTC [83] LOG:  could not bind IPv6 address "::1": Cannot assign requested address
2023-06-20 04:00:19.998 UTC [83] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2023-06-20 04:00:20.005 UTC [83] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-06-20 04:00:20.017 UTC [84] LOG:  database system was shut down at 2023-06-20 04:00:19 UTC
2023-06-20 04:00:20.017 UTC [85] gvmd@gvmd FATAL:  the database system is starting up
2023-06-20 04:00:20.024 UTC [83] LOG:  database system is ready to accept connections
2023-06-20 04:00:21.164 UTC [93] gvmd@gvmd ERROR:  extension "pg-gvm" has no installation script nor update path for version "1.1"
2023-06-20 04:00:21.164 UTC [93] gvmd@gvmd STATEMENT:  CREATE EXTENSION IF NOT EXISTS "pg-gvm"
2023-06-20 04:00:21.191 UTC [94] gvmd@gvmd ERROR:  relation "public.meta" does not exist at character 19
2023-06-20 04:00:21.191 UTC [94] gvmd@gvmd STATEMENT:  SELECT value FROM public.meta WHERE name = 'database_version';
2023-06-20 04:00:21.199 UTC [94] gvmd@gvmd ERROR:  extension "pg-gvm" has no installation script nor update path for version "1.1"
2023-06-20 04:00:21.199 UTC [94] gvmd@gvmd STATEMENT:  CREATE EXTENSION IF NOT EXISTS "pg-gvm"
2023-06-20 04:00:21.220 UTC [95] gvmd@gvmd ERROR:  relation "public.meta" does not exist at character 19
2023-06-20 04:00:21.220 UTC [95] gvmd@gvmd STATEMENT:  SELECT value FROM public.meta WHERE name = 'database_version';
2023-06-20 04:00:21.229 UTC [95] gvmd@gvmd ERROR:  extension "pg-gvm" has no installation script nor update path for version "1.1"
2023-06-20 04:00:21.229 UTC [95] gvmd@gvmd STATEMENT:  CREATE EXTENSION IF NOT EXISTS "pg-gvm"
2023-06-20 04:00:21.249 UTC [96] gvmd@gvmd ERROR:  relation "public.meta" does not exist at character 19
2023-06-20 04:00:21.249 UTC [96] gvmd@gvmd STATEMENT:  SELECT value FROM public.meta WHERE name = 'database_version';
2023-06-20 04:00:21.257 UTC [96] gvmd@gvmd ERROR:  extension "pg-gvm" has no installation script nor update path for version "1.1"
2023-06-20 04:00:21.257 UTC [96] gvmd@gvmd STATEMENT:  CREATE EXTENSION IF NOT EXISTS "pg-gvm"
2023-06-20 04:00:21.277 UTC [97] gvmd@gvmd ERROR:  relation "public.meta" does not exist at character 19
2023-06-20 04:00:21.277 UTC [97] gvmd@gvmd STATEMENT:  SELECT value FROM public.meta WHERE name = 'database_version';
2023-06-20 04:00:21.283 UTC [97] gvmd@gvmd ERROR:  extension "pg-gvm" has no installation script nor update path for version "1.1"
2023-06-20 04:00:21.283 UTC [97] gvmd@gvmd STATEMENT:  CREATE EXTENSION IF NOT EXISTS "pg-gvm"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.