Commit 04dfc877 authored by Tom Lane's avatar Tom Lane

If a role has a password expiration date, show that in psql's \du output.

Per a suggestion from Euler Taveira, it seems like a good idea to include
this information in \du (and \dg) output.  This costs nothing for people
who are not using the VALID UNTIL feature, while for those who are, it's
rather critical information.

Fabrízio de Royes Mello
parent f2386d71
...@@ -1267,12 +1267,15 @@ testdb=> ...@@ -1267,12 +1267,15 @@ testdb=>
<term><literal>\dg[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> <term><literal>\dg[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
<listitem> <listitem>
<para> <para>
Lists database roles. If <replaceable Lists database roles.
class="parameter">pattern</replaceable> is specified, only (Since the concepts of <quote>users</> and <quote>groups</> have been
those roles whose names match the pattern are listed. unified into <quote>roles</>, this command is now equivalent to
(This command is now effectively the same as <literal>\du</literal>). <literal>\du</literal>.)
If <replaceable class="parameter">pattern</replaceable> is specified,
only those roles whose names match the pattern are listed.
If the form <literal>\dg+</literal> is used, additional information If the form <literal>\dg+</literal> is used, additional information
is shown about each role, including the comment for each role. is shown about each role; currently this adds the comment for each
role.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1421,11 +1424,15 @@ testdb=&gt; ...@@ -1421,11 +1424,15 @@ testdb=&gt;
<term><literal>\du[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term> <term><literal>\du[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
<listitem> <listitem>
<para> <para>
Lists database roles. If <replaceable Lists database roles.
class="parameter">pattern</replaceable> is specified, only (Since the concepts of <quote>users</> and <quote>groups</> have been
those roles whose names match the pattern are listed. unified into <quote>roles</>, this command is now equivalent to
<literal>\dg</literal>.)
If <replaceable class="parameter">pattern</replaceable> is specified,
only those roles whose names match the pattern are listed.
If the form <literal>\du+</literal> is used, additional information If the form <literal>\du+</literal> is used, additional information
is shown about each role, including the comment for each role. is shown about each role; currently this adds the comment for each
role.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
...@@ -2378,7 +2378,7 @@ describeRoles(const char *pattern, bool verbose) ...@@ -2378,7 +2378,7 @@ describeRoles(const char *pattern, bool verbose)
printfPQExpBuffer(&buf, printfPQExpBuffer(&buf,
"SELECT r.rolname, r.rolsuper, r.rolinherit,\n" "SELECT r.rolname, r.rolsuper, r.rolinherit,\n"
" r.rolcreaterole, r.rolcreatedb, r.rolcanlogin,\n" " r.rolcreaterole, r.rolcreatedb, r.rolcanlogin,\n"
" r.rolconnlimit,\n" " r.rolconnlimit, r.rolvaliduntil,\n"
" ARRAY(SELECT b.rolname\n" " ARRAY(SELECT b.rolname\n"
" FROM pg_catalog.pg_auth_members m\n" " FROM pg_catalog.pg_auth_members m\n"
" JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)\n" " JOIN pg_catalog.pg_roles b ON (m.roleid = b.oid)\n"
...@@ -2406,7 +2406,8 @@ describeRoles(const char *pattern, bool verbose) ...@@ -2406,7 +2406,8 @@ describeRoles(const char *pattern, bool verbose)
" u.usesuper AS rolsuper,\n" " u.usesuper AS rolsuper,\n"
" true AS rolinherit, false AS rolcreaterole,\n" " true AS rolinherit, false AS rolcreaterole,\n"
" u.usecreatedb AS rolcreatedb, true AS rolcanlogin,\n" " u.usecreatedb AS rolcreatedb, true AS rolcanlogin,\n"
" -1 AS rolconnlimit,\n" " -1 AS rolconnlimit,"
" u.valuntil as rolvaliduntil,\n"
" ARRAY(SELECT g.groname FROM pg_catalog.pg_group g WHERE u.usesysid = ANY(g.grolist)) as memberof" " ARRAY(SELECT g.groname FROM pg_catalog.pg_group g WHERE u.usesysid = ANY(g.grolist)) as memberof"
"\nFROM pg_catalog.pg_user u\n"); "\nFROM pg_catalog.pg_user u\n");
...@@ -2453,7 +2454,7 @@ describeRoles(const char *pattern, bool verbose) ...@@ -2453,7 +2454,7 @@ describeRoles(const char *pattern, bool verbose)
add_role_attribute(&buf, _("Cannot login")); add_role_attribute(&buf, _("Cannot login"));
if (pset.sversion >= 90100) if (pset.sversion >= 90100)
if (strcmp(PQgetvalue(res, i, (verbose ? 9 : 8)), "t") == 0) if (strcmp(PQgetvalue(res, i, (verbose ? 10 : 9)), "t") == 0)
add_role_attribute(&buf, _("Replication")); add_role_attribute(&buf, _("Replication"));
conns = atoi(PQgetvalue(res, i, 6)); conns = atoi(PQgetvalue(res, i, 6));
...@@ -2471,14 +2472,22 @@ describeRoles(const char *pattern, bool verbose) ...@@ -2471,14 +2472,22 @@ describeRoles(const char *pattern, bool verbose)
conns); conns);
} }
if (strcmp(PQgetvalue(res, i, 7), "") != 0)
{
if (buf.len > 0)
appendPQExpBufferStr(&buf, "\n");
appendPQExpBufferStr(&buf, _("Password valid until "));
appendPQExpBufferStr(&buf, PQgetvalue(res, i, 7));
}
attr[i] = pg_strdup(buf.data); attr[i] = pg_strdup(buf.data);
printTableAddCell(&cont, attr[i], false, false); printTableAddCell(&cont, attr[i], false, false);
printTableAddCell(&cont, PQgetvalue(res, i, 7), false, false); printTableAddCell(&cont, PQgetvalue(res, i, 8), false, false);
if (verbose && pset.sversion >= 80200) if (verbose && pset.sversion >= 80200)
printTableAddCell(&cont, PQgetvalue(res, i, 8), false, false); printTableAddCell(&cont, PQgetvalue(res, i, 9), false, false);
} }
termPQExpBuffer(&buf); termPQExpBuffer(&buf);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment