
When you run postgresql as root, the command it gives for putting in
your startup script is a little weird.  The main issue is that 2>&1
only works in bash, not tcsh.  >& works in both, so it seems
preferable.  Another minor issue is that it echoes the command and
pipes it through su.  Shouldn't this be "su - postgres -c 'cmd'"?  Do
all versions of su have the '-c' argument?  piping it through seems
weird, but maybe it isn't.

this is a straight diff for src/backend/main/main.c

--cut here--
38c38
< echo \"postmaster -B 256 >/var/log/pglog 2>&1 &\" | su - postgres\n\n"
---
> su - postgres -c 'postmaster -B 256 >& /var/log/pglog' &\n\n"
--cut here--

Wed, 29 Apr 1998 20:09:05 -0700 (PDT)
Brett McCormick <brett@work.chicken.org>
text patch -- sugg cmd when run as root
> When you run postgresql as root, the command it gives for putting in
> your startup script is a little weird.  The main issue is that 2>&1
> only works in bash, not tcsh.  >& works in both, so it seems
> preferable.  Another minor issue is that it echoes the command and
> pipes it through su.  Shouldn't this be "su - postgres -c 'cmd'"?  Do
> all versions of su have the '-c' argument?  piping it through seems
> weird, but maybe it isn't.
> 
> this is a straight diff for src/backend/main/main.c
> 
> --cut here--
> 38c38
> < echo \"postmaster -B 256 >/var/log/pglog 2>&1 &\" | su - postgres\n\n"
> ---
> > su - postgres -c 'postmaster -B 256 >& /var/log/pglog' &\n\n"
> --cut here--

You have tcsh as the root shell??? 

Seriously, most systems have 'sh' as the root shell, with bash a distant
second possibility. And, the '2>&1' syntax works in 'sh', and 'ksh' and 'bash'.

-dg

David Gould            dg@illustra.com           510.628.3783 or 510.305.9468 
Informix Software  (No, really)         300 Lakeside Drive  Oakland, CA 94612
"(Windows NT) version 5.0 will build on a proven system architecture
 and incorporate tens of thousands of bug fixes from version 4.0."
                 -- <http://www.microsoft.com/y2k.asp?A=7&B=5>

Wed, 29 Apr 1998 23:28:42 -0700 (PDT)
dg@illustra.com (David Gould)
Re: [HACKERS] text patch -- sugg cmd when run as root
On Wed, 29 Apr 1998, David Gould wrote:

> > When you run postgresql as root, the command it gives for putting in
> > your startup script is a little weird.  The main issue is that 2>&1
> > only works in bash, not tcsh.  >& works in both, so it seems
> > preferable.  Another minor issue is that it echoes the command and
> > pipes it through su.  Shouldn't this be "su - postgres -c 'cmd'"?  Do
> > all versions of su have the '-c' argument?  piping it through seems
> > weird, but maybe it isn't.
> > 
> > this is a straight diff for src/backend/main/main.c
> > 
> > --cut here--
> > 38c38
> > < echo \"postmaster -B 256 >/var/log/pglog 2>&1 &\" | su - postgres\n\n"
> > ---
> > > su - postgres -c 'postmaster -B 256 >& /var/log/pglog' &\n\n"
> > --cut here--
> 
> You have tcsh as the root shell??? 

	As do I...so?  I just make sure I put a copy in /bin and you're
fine...or, at least, I haven't been burnt yet.  I can't stand the other
shells :(



Thu, 30 Apr 1998 09:53:43 -0400 (EDT)
The Hermit Hacker <scrappy@hub.org>
Re: [HACKERS] text patch -- sugg cmd when run as root
On Thu, 30 Apr 1998, The Hermit Hacker wrote:

>On Wed, 29 Apr 1998, David Gould wrote:
>
>> > When you run postgresql as root, the command it gives for putting in
>> > your startup script is a little weird.  The main issue is that 2>&1
>> > only works in bash, not tcsh.  >& works in both, so it seems
>> > preferable.  Another minor issue is that it echoes the command and
>> > pipes it through su.  Shouldn't this be "su - postgres -c 'cmd'"?  Do
>> > all versions of su have the '-c' argument?  piping it through seems
>> > weird, but maybe it isn't.
>> > 
>> > this is a straight diff for src/backend/main/main.c
>> > 
>> > --cut here--
>> > 38c38
>> > < echo \"postmaster -B 256 >/var/log/pglog 2>&1 &\" | su - postgres\n\n"
>> > ---
>> > > su - postgres -c 'postmaster -B 256 >& /var/log/pglog' &\n\n"
>> > --cut here--
>> 
>> You have tcsh as the root shell??? 
>
>	As do I...so?  I just make sure I put a copy in /bin and you're
>fine...or, at least, I haven't been burnt yet.  I can't stand the other
>shells :(

IMHO, the startup script should be written for plain sh (best) or plain
csh, because those are the shells that are guaranteed to exist on any Un*x
system. And, it doesn't matter which shell you are using (bash, tcsh, ksh,
zsh or whatever), simply put "#!/bin/sh" or "#!/bin/csh" as the first line
on the script, and you're done.

As a side note: Marc, if you use tcsh as root's shell, you also must check
that tcsh is statically linked. Anyway, I keep /bin/sh as root's shell,
and the first command I execute when I log on as root is "bash ; exit". I
could even modify root's .profile to execute it automatically, but I'm too
lazy :-)

-------------------------------------------------------------------
Pedro José Lobo Perea                   Tel:    +34 91 336 78 19
Centro de Cálculo                       Fax:    +34 91 331 92 29
EUIT Telecomunicación - UPM             e-mail: pjlobo@euitt.upm.es


Thu, 30 Apr 1998 16:28:45 +0200 (MET DST)
"Pedro J. Lobo" <pjlobo@euitt.upm.es>
Re: [HACKERS] text patch -- sugg cmd when run as root
Pedro:
> IMHO, the startup script should be written for plain sh (best) or plain
> csh, because those are the shells that are guaranteed to exist on any Un*x
> system. And, it doesn't matter which shell you are using (bash, tcsh, ksh,
> zsh or whatever), simply put "#!/bin/sh" or "#!/bin/csh" as the first line
> on the script, and you're done.

I don't have csh on some of my systems. I think the only safe choice is 
plain sh.
-dg

Thu, 30 Apr 1998 11:23:55 -0700 (PDT)
dg@illustra.com (David Gould)
Re: [HACKERS] text patch -- sugg cmd when run as root
> 
> When you run postgresql as root, the command it gives for putting in
> your startup script is a little weird.  The main issue is that 2>&1
> only works in bash, not tcsh.  >& works in both, so it seems
> preferable.  Another minor issue is that it echoes the command and
> pipes it through su.  Shouldn't this be "su - postgres -c 'cmd'"?  Do
> all versions of su have the '-c' argument?  piping it through seems
> weird, but maybe it isn't.
> 
> this is a straight diff for src/backend/main/main.c
> 
> --cut here--
> 38c38
> < echo \"postmaster -B 256 >/var/log/pglog 2>&1 &\" | su - postgres\n\n"
> ---
> > su - postgres -c 'postmaster -B 256 >& /var/log/pglog' &\n\n"
> --cut here--
> 
> 

I have changed the text to:

\n\"root\" execution of the PostgreSQL backend is not permitted.\n\n\
The backend must be started under it's own userid to prevent\n\ 
a possible system security compromise. See the INSTALL file for\n\
more information on how to properly start the postmaster.\n\n"          
       


-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

Tue, 12 May 1998 16:17:28 -0400 (EDT)
Bruce Momjian <maillist@candle.pha.pa.us>
Re: [HACKERS] text patch -- sugg cmd when run as root

beautiful -- it turns out that it was my mistake (I am very used to
bash) and vanilla sh does not handle tcsh-style redirection, as in:

command >& file

On Tue, 12 May 1998, at 16:17:28, Bruce Momjian wrote:

> I have changed the text to:
> 
> \n\"root\" execution of the PostgreSQL backend is not permitted.\n\n\
> The backend must be started under it's own userid to prevent\n\ 
> a possible system security compromise. See the INSTALL file for\n\
> more information on how to properly start the postmaster.\n\n"          

Tue, 12 May 1998 13:39:16 -0700 (PDT)
Brett McCormick <brett@work.chicken.org>
Re: [HACKERS] text patch -- sugg cmd when run as root