diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-28 05:09:14 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-28 05:09:14 +0000 |
commit | 7762619e95272974f90a38d8d85aafbe0e94add5 (patch) | |
tree | d7f756687beb883406489d59d13f722995fd7660 /src/backend/libpq/crypt.c | |
parent | 977530d8da2683dff036c2994395ab518527b93e (diff) | |
download | postgresql-7762619e95272974f90a38d8d85aafbe0e94add5.tar.gz postgresql-7762619e95272974f90a38d8d85aafbe0e94add5.zip |
Replace pg_shadow and pg_group by new role-capable catalogs pg_authid
and pg_auth_members. There are still many loose ends to finish in this
patch (no documentation, no regression tests, no pg_dump support for
instance). But I'm going to commit it now anyway so that Alvaro can
make some progress on shared dependencies. The catalog changes should
be pretty much done.
Diffstat (limited to 'src/backend/libpq/crypt.c')
-rw-r--r-- | src/backend/libpq/crypt.c | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c index 58e80334f61..d9c95d1b9ac 100644 --- a/src/backend/libpq/crypt.c +++ b/src/backend/libpq/crypt.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.62 2005/02/20 04:45:57 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/libpq/crypt.c,v 1.63 2005/06/28 05:08:56 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -29,7 +29,7 @@ int -md5_crypt_verify(const Port *port, const char *user, char *client_pass) +md5_crypt_verify(const Port *port, const char *role, char *client_pass) { char *shadow_pass = NULL, *valuntil = NULL, @@ -39,16 +39,14 @@ md5_crypt_verify(const Port *port, const char *user, char *client_pass) ListCell *token; char *crypt_client_pass = client_pass; - if ((line = get_user_line(user)) == NULL) + if ((line = get_role_line(role)) == NULL) return STATUS_ERROR; - /* Skip over username and usesysid */ + /* Skip over rolename */ token = list_head(*line); if (token) token = lnext(token); if (token) - token = lnext(token); - if (token) { shadow_pass = (char *) lfirst(token); token = lnext(token); @@ -146,17 +144,28 @@ md5_crypt_verify(const Port *port, const char *user, char *client_pass) /* * Password OK, now check to be sure we are not past valuntil */ - AbsoluteTime vuntil; - if (valuntil == NULL || *valuntil == '\0') - vuntil = INVALID_ABSTIME; - else - vuntil = DatumGetAbsoluteTime(DirectFunctionCall1(abstimein, - CStringGetDatum(valuntil))); - if (vuntil != INVALID_ABSTIME && vuntil < GetCurrentAbsoluteTime()) - retval = STATUS_ERROR; - else retval = STATUS_OK; + else + { + TimestampTz vuntil; + AbsoluteTime sec; + int usec; + TimestampTz curtime; + + vuntil = DatumGetTimestampTz(DirectFunctionCall3(timestamptz_in, + CStringGetDatum(valuntil), + ObjectIdGetDatum(InvalidOid), + Int32GetDatum(-1))); + + sec = GetCurrentAbsoluteTimeUsec(&usec); + curtime = AbsoluteTimeUsecToTimestampTz(sec, usec); + + if (vuntil < curtime) + retval = STATUS_ERROR; + else + retval = STATUS_OK; + } } if (port->auth_method == uaMD5) |