Screwed-up postgresql13 install

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Screwed-up postgresql13 install

Peter West
MacOS Big Sur 11.2 MacBook Air M1

I’m migrating to the M1 from an Intel MacBook Pro running Mojave.

I installed postgresql13 and -server, and copied my defaultdb across from the Pro.

I can’t vouch for the order of these things, because I wasn’t expecting to get into a quagmire.

I tried to give the postgres user a password using passwd as root. That’s not enough. I have to use a command ’security’ with a reference to a Keychain to complete the process. In the wake of all this, I assume that the user postgres is created without a password, and that’s Ok with the default pg_hba.conf.

Then I thought that maybe I should build up the databases by dumping databases from the Pro and restoring to the M1. So I uninstalled the postgresql ports and tried to delete /opt/local/var/db/postgresql13. The defaultdb disappeared but root was not allowed to remove a directory Library sitting beside the defaultdb. It had Preferences and Keychains subdirs, and they wouldn’t go.

I deleted the postgres user through the System Preferences, but that left the entry for _postgres in /etc/passwd.

Ok, install postgresql13 again. Installation proceeded, but this time did not create the postgres user visible through System Preferences, which I assume was created when I first installed.

When I try to access the macports wrapper (via su) to start the database, I get the complaint
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
could not identify current directory: Permission denied (3times)
The program “postgres” is needed by pg_ctl but was not found in the same directory as pg_ctl
(for obvious reasons, me)
Check your installation.
(you don’t say)

Any advice on how I can clean this up and start again.

Peter

--
Peter West
[hidden email]
“…a light for revelation to the Gentiles, and for glory to your people Israel.”

Reply | Threaded
Open this post in threaded view
|

Re: Screwed-up postgresql13 install

Peter West
Where is the function add_users defined? I see it in the Portfile for postgresql13-server.

Peter

--
Peter West
[hidden email]
“…a light for revelation to the Gentiles, and for glory to your people Israel.”

> On 4 Feb 2021, at 1:04 am, Peter West <[hidden email]> wrote:
>
> MacOS Big Sur 11.2 MacBook Air M1
>
> I’m migrating to the M1 from an Intel MacBook Pro running Mojave.
>
> I installed postgresql13 and -server, and copied my defaultdb across from the Pro.
>
> I can’t vouch for the order of these things, because I wasn’t expecting to get into a quagmire.
>
> I tried to give the postgres user a password using passwd as root. That’s not enough. I have to use a command ’security’ with a reference to a Keychain to complete the process. In the wake of all this, I assume that the user postgres is created without a password, and that’s Ok with the default pg_hba.conf.
>
> Then I thought that maybe I should build up the databases by dumping databases from the Pro and restoring to the M1. So I uninstalled the postgresql ports and tried to delete /opt/local/var/db/postgresql13. The defaultdb disappeared but root was not allowed to remove a directory Library sitting beside the defaultdb. It had Preferences and Keychains subdirs, and they wouldn’t go.
>
> I deleted the postgres user through the System Preferences, but that left the entry for _postgres in /etc/passwd.
>
> Ok, install postgresql13 again. Installation proceeded, but this time did not create the postgres user visible through System Preferences, which I assume was created when I first installed.
>
> When I try to access the macports wrapper (via su) to start the database, I get the complaint
> shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
> could not identify current directory: Permission denied (3times)
> The program “postgres” is needed by pg_ctl but was not found in the same directory as pg_ctl
> (for obvious reasons, me)
> Check your installation.
> (you don’t say)
>
> Any advice on how I can clean this up and start again.
>
> Peter
>
> --
> Peter West
> [hidden email]
> “…a light for revelation to the Gentiles, and for glory to your people Israel.”
>



Reply | Threaded
Open this post in threaded view
|

Re: Screwed-up postgresql13 install

ryandesign2
Administrator


On Feb 3, 2021, at 18:25, Peter West wrote:

> Where is the function add_users defined? I see it in the Portfile for postgresql13-server.

It is documented in "man portfile"

The option is created here:

https://github.com/macports/macports-base/blob/master/src/port1.0/portmain.tcl#L63

Its default value (empty) is set here:

https://github.com/macports/macports-base/blob/master/src/port1.0/portmain.tcl#L124

The code that creates the macOS users and groups based on the value the portfile sets this option to is here:

https://github.com/macports/macports-base/blob/master/src/port1.0/portutil.tcl#L2318-L2339

The adduser and addgroup procedures that add_users calls are below that.

Reply | Threaded
Open this post in threaded view
|

Re: Screwed-up postgresql13 install

ryandesign2
Administrator
In reply to this post by Peter West


On Feb 3, 2021, at 09:04, Peter West wrote:

> MacOS Big Sur 11.2 MacBook Air M1
>
> I’m migrating to the M1 from an Intel MacBook Pro running Mojave.
>
> I installed postgresql13 and -server, and copied my defaultdb across from the Pro.
>
> I can’t vouch for the order of these things, because I wasn’t expecting to get into a quagmire.
>
> I tried to give the postgres user a password using passwd as root. That’s not enough. I have to use a command ’security’ with a reference to a Keychain to complete the process. In the wake of all this, I assume that the user postgres is created without a password, and that’s Ok with the default pg_hba.conf.

As far as I know, anytime MacPorts creates a macOS user account on behalf of a portfile that requests it, it does so without a password, and this is not thought to be a problem. The user accounts do not have a shell set so nobody could log into them.


> Then I thought that maybe I should build up the databases by dumping databases from the Pro and restoring to the M1. So I uninstalled the postgresql ports and tried to delete /opt/local/var/db/postgresql13. The defaultdb disappeared but root was not allowed to remove a directory Library sitting beside the defaultdb. It had Preferences and Keychains subdirs, and they wouldn’t go.

I am not certain why. I do not have much experience with macOS 11 yet.


> I deleted the postgres user through the System Preferences, but that left the entry for _postgres in /etc/passwd.

The fact that the postgres user was visible in System Preferences indicates a problem. macOS user accounts that MacPorts creates for you are not visible in System Preferences.

You said you migrated from another Mac. In my experience, the migration assistant will migrate any MacPorts-created user accounts improperly. After migration, the accounts will appear in System Preferences, and their home directories will have been moved into /Users, which may make the ports that use those user accounts not work correctly. Cleaning up the user migration mess that the migration assistant leaves behind is not easy. Whenever I migrate, I choose not to migrate MacPorts-created user accounts and instead have MacPorts recreate them properly.

I believe the entry for _postgres in /etc/passwd is fine and normal on any macOS system. Apple puts it there, along with creating the _postgres macOS user account. This is unrelated to the postgres macOS user account the MacPorts postgresql-server ports create.


> Ok, install postgresql13 again. Installation proceeded, but this time did not create the postgres user visible through System Preferences, which I assume was created when I first installed.

You can check on the command line whether the postgres user created by MacPorts exists:

id postgres

If that doesn't show "no such user", you're fine.


> When I try to access the macports wrapper (via su) to start the database, I get the complaint
> shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
> could not identify current directory: Permission denied (3times)
> The program “postgres” is needed by pg_ctl but was not found in the same directory as pg_ctl
> (for obvious reasons, me)
> Check your installation.
> (you don’t say)

Not sure, but try cd'ing to a different directory before doing what you did. Maybe you were in a directory that no longer existed. MacPorts has a similar error message that can appear if you are in a port's directory when you run `sudo port sync` because (if you sync with rsync) that deletes all port directories and recreates them.

Reply | Threaded
Open this post in threaded view
|

Re: Screwed-up postgresql13 install

Peter West
Firstly, the su problem was because I was still in my home directory. When I sudo su - Postgres (note the minus) all is OK.

In my travels I discovered dscl, which I had managed not to encounter over many long year. How very handy it is. I deleted the postgres user with ddcl, and then re-installed postgresql13 and server.

One thing that causes confusion is that the _postgres user in /etc/passwd has a different UID and GID from the dscl user and group. It’s the same on Mojave. I have no idea what these /etc/passwd entries are about, given the underlying differences.

Peter


Peter West
[hidden email]
“A prophet is not without honor, except in his hometown and among his relatives and in his own household.”


> On 4 Feb 2021, at 11:45 am, Ryan Schmidt <[hidden email]> wrote:
>
>
>
> On Feb 3, 2021, at 09:04, Peter West wrote:
>
>> MacOS Big Sur 11.2 MacBook Air M1
>>
>> I’m migrating to the M1 from an Intel MacBook Pro running Mojave.
>>
>> I installed postgresql13 and -server, and copied my defaultdb across from the Pro.
>>
>> I can’t vouch for the order of these things, because I wasn’t expecting to get into a quagmire.
>>
>> I tried to give the postgres user a password using passwd as root. That’s not enough. I have to use a command ’security’ with a reference to a Keychain to complete the process. In the wake of all this, I assume that the user postgres is created without a password, and that’s Ok with the default pg_hba.conf.
>
> As far as I know, anytime MacPorts creates a macOS user account on behalf of a portfile that requests it, it does so without a password, and this is not thought to be a problem. The user accounts do not have a shell set so nobody could log into them.
>
>
>> Then I thought that maybe I should build up the databases by dumping databases from the Pro and restoring to the M1. So I uninstalled the postgresql ports and tried to delete /opt/local/var/db/postgresql13. The defaultdb disappeared but root was not allowed to remove a directory Library sitting beside the defaultdb. It had Preferences and Keychains subdirs, and they wouldn’t go.
>
> I am not certain why. I do not have much experience with macOS 11 yet.
>
>
>> I deleted the postgres user through the System Preferences, but that left the entry for _postgres in /etc/passwd.
>
> The fact that the postgres user was visible in System Preferences indicates a problem. macOS user accounts that MacPorts creates for you are not visible in System Preferences.
>
> You said you migrated from another Mac. In my experience, the migration assistant will migrate any MacPorts-created user accounts improperly. After migration, the accounts will appear in System Preferences, and their home directories will have been moved into /Users, which may make the ports that use those user accounts not work correctly. Cleaning up the user migration mess that the migration assistant leaves behind is not easy. Whenever I migrate, I choose not to migrate MacPorts-created user accounts and instead have MacPorts recreate them properly.
>
> I believe the entry for _postgres in /etc/passwd is fine and normal on any macOS system. Apple puts it there, along with creating the _postgres macOS user account. This is unrelated to the postgres macOS user account the MacPorts postgresql-server ports create.
>
>
>> Ok, install postgresql13 again. Installation proceeded, but this time did not create the postgres user visible through System Preferences, which I assume was created when I first installed.
>
> You can check on the command line whether the postgres user created by MacPorts exists:
>
> id postgres
>
> If that doesn't show "no such user", you're fine.
>
>
>> When I try to access the macports wrapper (via su) to start the database, I get the complaint
>> shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
>> could not identify current directory: Permission denied (3times)
>> The program “postgres” is needed by pg_ctl but was not found in the same directory as pg_ctl
>> (for obvious reasons, me)
>> Check your installation.
>> (you don’t say)
>
> Not sure, but try cd'ing to a different directory before doing what you did. Maybe you were in a directory that no longer existed. MacPorts has a similar error message that can appear if you are in a port's directory when you run `sudo port sync` because (if you sync with rsync) that deletes all port directories and recreates them.
>