Thread: createuser ignores stdin in 8.1.0?
We're migrating from 7.3.4 to 8.1.0, and I'm seeing different behavior with the createuser command. What we are wanting is to streamline our product installs, to require minimal user interaction, so we basically embed the password like this in our bourne-shell wrapper script: $POSTGRESQL_HOME/bin/createuser -d -P $PGUSER <<END $PGPASSWORD $PGPASSWORD END ...and in 7.3.4, this works just fine, with the shell consuming the stdin and redirecting it to the createuser command, which subsequently doesn't bother the user with the prompt (i.e. the prompts are responded to automatically). However, this doesn't work at all in 8.1.0 -- regardless of the stdin redirection, the createuser program appears to ignore the stdin information and insists on prompting for the input instead. Is this a known expected behavior? Do we have a workaround to get this to behave automatically like it did for 7.3.4? Thanks so much for anyone's insights. And, if you would be so kind, please cc me at my email since I'm not signed up to receive interest-list messages... -Gary Horton
Gary Horton wrote: > ...and in 7.3.4, this works just fine, with the shell consuming the > stdin and redirecting it to the createuser command, which subsequently > doesn't bother the user with the prompt (i.e. the prompts are responded > to automatically). However, this doesn't work at all in 8.1.0 -- > regardless of the stdin redirection, the createuser program appears to > ignore the stdin information and insists on prompting for the input > instead. Don't know what's changed, but it could be something that happened when roles were introduced. A way to work around it would be to issue the SQL "CREATE USER... PASSWORD 'foo'" via psql. Oh - anything else you come across in the upgrade would be of interest to many here, myself included ;-) -- Richard Huxton Archonet Ltd
Richard Huxton wrote: > Gary Horton wrote: > >> ...and in 7.3.4, this works just fine, with the shell consuming the >> stdin and redirecting it to the createuser command, which >> subsequently doesn't bother the user with the prompt (i.e. the >> prompts are responded to automatically). However, this doesn't work >> at all in 8.1.0 -- regardless of the stdin redirection, the >> createuser program appears to ignore the stdin information and >> insists on prompting for the input instead. > > > Don't know what's changed, but it could be something that happened > when roles were introduced. A way to work around it would be to issue > the SQL "CREATE USER... PASSWORD 'foo'" via psql. That's a great idea, Richard - thanks, I'll give this a shot -- > > Oh - anything else you come across in the upgrade would be of interest > to many here, myself included ;-) So far, so good in general -- I was unable to execute the regression tests (installcheck) - the C compilation fails. But I'm successfully executing all of our own app-level tests, so I'm optimistic...other than that, I did send out a list of questions around configure options, but haven't gotten any responses; but I will post to the list about anything else I come across! -gh
Gary Horton wrote: > > > Richard Huxton wrote: > > > Gary Horton wrote: > > > >> ...and in 7.3.4, this works just fine, with the shell consuming the > >> stdin and redirecting it to the createuser command, which > >> subsequently doesn't bother the user with the prompt (i.e. the > >> prompts are responded to automatically). However, this doesn't work > >> at all in 8.1.0 -- regardless of the stdin redirection, the > >> createuser program appears to ignore the stdin information and > >> insists on prompting for the input instead. > > > > > > Don't know what's changed, but it could be something that happened > > when roles were introduced. A way to work around it would be to issue > > the SQL "CREATE USER... PASSWORD 'foo'" via psql. > > That's a great idea, Richard - thanks, I'll give this a shot -- createuser was converted from a shell script to a C program in 7.4, so I guess something changed at that point. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Gary Horton <Gary.Horton@Sun.COM> writes: > We're migrating from 7.3.4 to 8.1.0, and I'm seeing different behavior > with the createuser command. What we are wanting is to streamline our > product installs, to require minimal user interaction, so we basically > embed the password like this in our bourne-shell wrapper script: > $POSTGRESQL_HOME/bin/createuser -d -P $PGUSER <<END > $PGPASSWORD We changed all the clients some time ago to insist on getting passwords from /dev/tty not stdin. There was a security argument for it, I think, but I don't recall the reasoning exactly. regards, tom lane
Thanks, Tom, that explains it. I'm using Richard Huxton's suggested workaround and it's working just fine -
-gh
Tom Lane wrote:
-gh
Tom Lane wrote:
Gary Horton <Gary.Horton@Sun.COM> writes:We're migrating from 7.3.4 to 8.1.0, and I'm seeing different behavior with the createuser command. What we are wanting is to streamline our product installs, to require minimal user interaction, so we basically embed the password like this in our bourne-shell wrapper script:$POSTGRESQL_HOME/bin/createuser -d -P $PGUSER <<END $PGPASSWORDWe changed all the clients some time ago to insist on getting passwords from /dev/tty not stdin. There was a security argument for it, I think, but I don't recall the reasoning exactly. regards, tom lane