30 static struct option long_options[] = {
66 const char *newuser = NULL;
76 bool interactive =
false;
79 char *newpassword = NULL;
80 char *pwexpiry = NULL;
102 while ((
c =
getopt_long(argc, argv,
"a:c:dDeEg:h:iIlLm:p:PrRsSU:v:wW",
103 long_options, &optindex)) != -1)
112 -1, INT_MAX, &conn_limit))
208 pg_log_error(
"too many command-line arguments (first is \"%s\")",
218 newuser =
simple_prompt(
"Enter name of role to add: ",
true);
222 if (getenv(
"PGUSER"))
223 newuser = getenv(
"PGUSER");
233 newpassword =
simple_prompt(
"Enter password for new role: ",
false);
235 if (strcmp(newpassword, pw2) != 0)
237 fprintf(stderr,
_(
"Passwords didn't match.\n"));
245 if (interactive &&
yesno_prompt(
"Shall the new role be a superuser?"))
260 if (interactive &&
yesno_prompt(
"Shall the new role be allowed to create databases?"))
268 if (interactive &&
yesno_prompt(
"Shall the new role be allowed to create more new roles?"))
300 char *encrypted_password;
308 if (!encrypted_password)
309 pg_fatal(
"password encryption failed: %s",
336 if (replication ==
TRI_NO)
342 if (conn_limit >= -1)
344 if (pwexpiry != NULL)
349 if (roles.
head != NULL)
355 for (cell = roles.
head; cell; cell = cell->
next)
363 if (members.
head != NULL)
369 for (cell = members.
head; cell; cell = cell->
next)
377 if (admins.
head != NULL)
383 for (cell = admins.
head; cell; cell = cell->
next)
bool yesno_prompt(const char *question)
#define PG_TEXTDOMAIN(domain)
void set_pglocale_pgservice(const char *argv0, const char *app)
PGconn * connectMaintenanceDatabase(ConnParams *cparams, const char *progname, bool echo)
static void help(const char *progname)
Oid createdb(ParseState *pstate, const CreatedbStmt *stmt)
char * PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm)
char * PQerrorMessage(const PGconn *conn)
void PQfinish(PGconn *conn)
void PQfreemem(void *ptr)
ExecStatusType PQresultStatus(const PGresult *res)
PGresult * PQexec(PGconn *conn, const char *query)
char * pg_strdup(const char *in)
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
#define required_argument
void pg_logging_init(const char *argv0)
#define pg_log_error(...)
#define pg_log_error_hint(...)
bool option_parse_int(const char *optarg, const char *optname, int min_range, int max_range, int *result)
void handle_help_version_opts(int argc, char *argv[], const char *fixed_progname, help_handler hlp)
PGDLLIMPORT char * optarg
const char * get_progname(const char *argv0)
void printfPQExpBuffer(PQExpBuffer str, const char *fmt,...)
void initPQExpBuffer(PQExpBuffer str)
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
void appendPQExpBufferChar(PQExpBuffer str, char ch)
void appendPQExpBufferStr(PQExpBuffer str, const char *data)
void simple_string_list_append(SimpleStringList *list, const char *val)
char * simple_prompt(const char *prompt, bool echo)
void appendStringLiteralConn(PQExpBuffer buf, const char *str, PGconn *conn)
const char * fmtId(const char *rawid)
char val[FLEXIBLE_ARRAY_MEMBER]
struct SimpleStringListCell * next
SimpleStringListCell * head
enum trivalue prompt_password
const char * get_user_name_or_exit(const char *progname)