Re: [HACKERS] TODO list updated
Karl DeBisschop <kdebisschop@range.infoplease.com>
From: Karl DeBisschop <kdebisschop@range.infoplease.com>
To: tgl@sss.pgh.pa.us
Cc: pgman@candle.pha.pa.us, peter_e@gmx.net, scrappy@hub.org, pgsql-hackers@postgresql.org
Date: 2000-01-13T16:58:26Z
Lists: pgsql-hackers
> What I am starting to think is that we do need a C program. However,
> it could be very small; it shouldn't try to do all of what initdb does.
> All it needs to do is fetch the password from stdin and then echo it
> to stdout in an ALTER USER command. The invocation in initdb would
> look something like
>
> securepassword $SUPERUSERNAME | standalone-backend ...
>
> and the code would be on the order of
>
> fprintf(stderr, "Please enter password for %s: ", argv[1]);
> fgets(stdin, password);
> printf("ALTER USER %s PASSWORD '%s'\n", argv[1], password);
Why not something like:
#include <libpq-fe.h>
char *pghost;
char *pgport;
char *pgoptions;
char *pgtty;
char *dbName;
char *user;
char *password;
char *query;
PGconn *conn;
PGresult *res;
fprintf(stderr, "Please enter password for %s: ", argv[1]);
fgets(stdin, password);
pgoptions = NULL; /* special options to start up the backend server */
pgtty = NULL; /* debugging tty for the backend server */
conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);
sprintf(query,"ALTER USER postgres SET PASSWORD='%s'",password)
PGresult= PQexec(conn,query);
PQfinish(conn);
--
Karl DeBisschop <kdebisschop@alert.infoplease.com>
617.832.0332 (Fax: 617.956.2696)
Information Please - your source for FREE online reference
http://www.infoplease.com - Your Ultimate Fact Finder
http://kids.infoplease.com - The Great Homework Helper
Netsaint Plugins Development
http://netsaintplug.sourceforge.net