Thread: Starting postgres with a password

Starting postgres with a password

From
Doug Silver
Date:
I've searched around but didn't see this answered (at least in the first 100
answers!).  If the postgres user has a password (in Postgres, not the system)
*and* the hba_conf file does not trust the 127.0.0.1 host but requires a
password, how can you start up Postgresql?  Can you pass this during the init
script, e.g. "password=test"?

I don't trust some of the users on a server and want to make sure they can't
just login to postgres as the admin (psql -U pgsql).

Thanks!

-doug


Re: Starting postgres with a password

From
Tom Lane
Date:
Doug Silver <dsilver@urchin.com> writes:
> I've searched around but didn't see this answered (at least in the first 100
> answers!).  If the postgres user has a password (in Postgres, not the system)
> *and* the hba_conf file does not trust the 127.0.0.1 host but requires a
> password, how can you start up Postgresql?

The postmaster doesn't need a password to start.  If it can access the
data directory it figures you're authorized to start it.

            regards, tom lane


Re: Starting postgres with a password

From
Doug Silver
Date:
On Thursday 24 April 2003 04:59 pm, Tom Lane wrote:
> Doug Silver <dsilver@urchin.com> writes:
> > I've searched around but didn't see this answered (at least in the first
> > 100 answers!).  If the postgres user has a password (in Postgres, not the
> > system) *and* the hba_conf file does not trust the 127.0.0.1 host but
> > requires a password, how can you start up Postgresql?
>
> The postmaster doesn't need a password to start.  If it can access the
> data directory it figures you're authorized to start it.
>
>             regards, tom lane

Ah, found the culprit in the supplied startup script  -- it was using "-w" on
startup which caused it to prompt for the password.

Thanks!

-doug


Re: Starting postgres with a password

From
"M. Bastin"
Date:
I'm trying to write my own frontend.  I found the info below (thanks
Tom) about the StartupPacket.

1. For pgsql 7.3.2, what should the protocol version number be?

2. Also, what exactly is a limstring?  (I'm not using C, but a
language called REALbasic.)  Is this a string of exactly 64 (or 32)
bits?  Must it be null terminated?  Must empty space be filled with
zeros?  etc?

3. What could 'Any additional command line arguments' be?  Which
arguments could be valid at this stage?

Thanks,

Marc

>  StartupPacket (F)
>  Int32(296)     - The size of the packet in bytes.
>  Int32          - The protocol version number. The most significant 16
>  bits are the major version number. The least 16 significant bits are
>  the minor version number.
>  LimString64    - The database name, defaults to the user name if
>  empty.
>  LimString32    - The user name.
>  LimString64    - Any additional command line arguments to be passed to
>  the backend child process by the server.
>  LimString64    - Unused.
>  LimString64    - The optional tty the backend should use for debugging
>  messages. (Currently, this field is unsupported and ignored.)


Re: Starting postgres with a password

From
Tom Lane
Date:
"M. Bastin" <marcbastin@mindspring.com> writes:
> I'm trying to write my own frontend.

Sounds like you need to read all of the protocol description, not just
one packet's worth.  See
http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/protocol.html

            regards, tom lane