Re: Feature request: psql --idle

From: Mateusz Henicz <mateuszhenicz(at)gmail(dot)com>
To: Wiwwo Staff <wiwwo(at)wiwwo(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Feature request: psql --idle
Date: 2022-07-27 14:06:09
Message-ID: CAN6i3YPdfxeKckLdoJ-HSu_04qQvOxbODXes2a4No1trVjYrhg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
Your first sentence is wrong. Changing pg_hba.conf file does not require
server restart. It is enough to reload the configuration using "pg_ctl
reload", "select pg_reload_conf();" in psql or just sending SIGHUP from
linux terminal to postmaster process after changing the pg_hba file.

To achieve something like this you could use simple bash script like the
one below and add it to your /etc/passwd file, like
/etc/passwd
test:x:1001:1001::/home/test:/home/test/skrypt.sh

/home/test/skrypt.sh
#!/bin/bash
echo "Select a database"
echo "1. local"
echo "2. other_dbs"

read dbname

if [ "$dbname" == "1" ] || [ "$dbname" == "local" ]
then
psql -h 127.0.0.1 -p 5432 -U postgres postgres
elif [ "$dbname" == "2" ] || [ "$dbname" == " other_dbs " ]
then
psql -h 127.0.0.1 -p 5555 -U postgres postgres
fi

Hope it helps.

Cheers,
Mateusz

śr., 27 lip 2022 o 14:50 Wiwwo Staff <wiwwo(at)wiwwo(dot)com> napisał(a):

> Since changing ph_hda.conf file to give users access involves the restart
> of server, many companies I work(ed) use a bastion host, where users ssh
> to, and are allowed "somehow" use postgresql.
>
> Still, those users need some login shell.
>
> It would be great to give them psql as a login shell (in /etc/passwd).
> But doing so, will result in psql exiting with error with the usual
> $ psql
> psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed:
> No such file or directory
> Is the server running locally and accepting connections on that socket?
>
> What would help, is a --idle option, where psql does not exit, stays idle
> and waits for user to give a \conn command.
> Something similar to
> sqlplus /nolog
>
> Is anything like that feasible or is there another solution/workaround?
>
> Tnx!
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Julien Rouhaud 2022-07-27 14:07:02 Re: Feature request: psql --idle
Previous Message Wiwwo Staff 2022-07-27 12:49:45 Feature request: psql --idle