Building 22.4 from source on ubuntu 22.04.1: Filesystem Permission Errors / Role "USERNAME" does not exist

Hi there!
I just tried to build and install on a fresh ubuntu 22.04.1 vm. Sadly, there seems to be a problem with the documentation.
I followed https://greenbone.github.io/docs/latest/22.4/source-build/index.htm and it fails here:
https://greenbone.github.io/docs/latest/22.4/source-build/index.html#id128

gvmd --create-user=admin
md   main-Message: 16:51:14.368:    Greenbone Vulnerability Manager version 22.4.0~dev1 (DB revision 250)                                                                                 
(gvmd:17404): md manage-WARNING **: 16:51:14.368: Failed to open lock file '/run/gvmd/gvm-checking': No such file or directory

Permissions for /run/gvmd are:

drwxr-xr-x 2 gvm gvm 120 Jan 11 17:00 gvmd

Weird. So i went ahead and touched that file as sudo, changed the ownership to gvm:gvm and got past that error.

Next error is:
“Can not open ‘/var/log/gvm/gvmd.log’ logfile: Permission denied”

Permission for folder /var/log/gvm/:
drwxr-xr-x 2 gvm gvm 4.0K Jan 11 17:11 gvm

Permission for file:
-rw-r--r-- 1 gvm gvm 0 Jan 11 17:11 /var/log/gvm/gvmd.log

So i did a chmod 664 for the gvmd.log. (Since i start it as normal user, which is part of the gvm group)
error is gone, but:
I dont get any output from the command.

The gvmd.log now contains a fatal error:
“sql_open: PQerrorMessage (conn): connection to server on socket “/var/run/postgresql/.s.PGSQL.5432” failed:role $MYUSERNAME” does not exist."

$MYUSERNAME is my actual username that i replaced in the output.

I followed every single step throughout the documentation, so i guess its wrong or missing a important step at one point.

Can somebody help?

Kind regards

Hi, something must be wrong with your current user. Maybe try to login again, set the environment variables and go on.

hi @bricks!
Thanks for your response. I just went through the entire process again, and ended up with the same result.
I guess there is something wrong with the documentation.
I noticed a few times when i used the “copy button” next to the commands to run on console: its not doing what its supposed to do!
for example, https://greenbone.github.io/docs/latest/22.4/source-build/index.html#id117
when i copy the block using the button the directory “/run/gvmd” doesnt get created.

How is it “supposed” to work?
I run all the commands as normal user, some of them as sudo. (where told to)
My user is member of the group gvm.
But… i dont see where postgresql is told that all members of the group gvm get dba rights: only the user gvm.
So thats probably why the error message appears:
“failed: FATAL: role “MYUSERNAME” does not exist”
yep, from my understanding: it never got created.
So i guess the command “gvmd --create-user=admin” should get run as gvm user, and not as “normal” user OR the normal user needs a role in posgresql?

EDIT: I just tested this theory, once i ran “gvmd --create-user=admin” as gvm the command worked and i got a password for the admin. (had to change owner of files in /run/gvmd to gvm:gvm since they were owned by my user)

Works for me as it should with Firefox 109. Never heard complains before. You can of course also copy and paste the texts manually.

Because that isn’t necessary when following the docs. In https://greenbone.github.io/docs/latest/22.4/source-build/index.html#id118 we are setting the SUID and SGID bits on the gvmd executable which allows the users of the gvm group to run the gvmd command as gvmd user.

1 Like

okay, makes sense. But on the other hand: i didnt get an error running gvmd, the error is from postgresql.
Why does postgresql complain that my user has no role then?

Did you check if the suid and sgid bits are set on gvmd? Of course you can run gvmd as gvm user alternatively without setting these bits (sudo -u gvm gvmd ...).

1 Like

I ran those commands, but i suspect that there might was another problem with the copy function of the site with that script block as well.
I run firefox 109 on windows and connected to the server via putty.
shrug nothing fancy or extraordinary here.
Since i now know that there is a problem with that button, maybe i should do the entire build process once more and copy all the commands without the use of this button.
weird…

Maybe no, but If your Ubuntu VM already has postgreSQL installed, there may be some conflict. I have had this issue with GVM install on Ubuntu before. Then maybe it can’t find the username because looking at the different PG service?