[Tile-serving] [openstreetmap/osm2pgsql] How to automate osm2pgsql tasks with a PostgreSQL password (#596)

jcj7421 notifications at github.com
Mon Jun 20 12:28:06 UTC 2016


As osm2pgsql is used in scripts to automate updating of maps, it seems to me that there are only 2 choices to give the PostgreSQL password : 
- either osm2pgsql asks it to the keyboard (it we use the '-W' option)
- or osm2pgsql doesn't send any password to PostgreSQL ; it requires that the database is configured not to ask a password (so the database security is carried over by the Linux account security).

The problem is that, when osm2pgsql asks the password, it reads it on /dev/tty instead of stdin so we cannot use it in a script. So, It means that, if we want an osm server which updates the maps automatically, we must configure the database with no password.  It seems that, previously, osm2pgsql was able to read the password in a Unix variable (something like $PGPASS or $pgpassword) but it does work anymore.

But if osm2pgsql would read the password on stdin (and ask the question on stdout), the problem would be solved : when osm2pgsql will ask the password, the script only has to redirect the standard input .

The modification to be made consists to modify sprompt.cpp : 
replacing : 
 	termin = fopen(DEVTTY, "r");
 	termout = fopen(DEVTTY, "w");
by : 
 	termin = fopen("stdin", "r");
 	termout = fopen("stdout", "w");
and removing the line : 
#define DEVTTY "/dev/tty"

That's what I am doing on my osm server, but I post it here hoping it could help other people or, may be, you could consider modify the original sources.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/issues/596
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20160620/47259371/attachment.html>


More information about the Tile-serving mailing list