chiark
/
gitweb
/
~mdw
/
disorder
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib/configuration.c, lib/home.c: Introduce environment variables.
[disorder]
/
lib
/
cookies.c
diff --git
a/lib/cookies.c
b/lib/cookies.c
index e32fc0c194fd2940790e77046fd81f2233d780b4..c216d86e0728f08e1d67eeb2f465abf723ed0eeb 100644
(file)
--- a/
lib/cookies.c
+++ b/
lib/cookies.c
@@
-24,7
+24,6
@@
#include <errno.h>
#include <time.h>
#include <gcrypt.h>
#include <errno.h>
#include <time.h>
#include <gcrypt.h>
-#include <pcre.h>
#include "cookies.h"
#include "hash.h"
#include "cookies.h"
#include "hash.h"
@@
-99,11
+98,11
@@
static char *sign(const uint8_t *key,
char *sig64;
if((e = gcry_md_open(&h, ALGO, GCRY_MD_FLAG_HMAC))) {
char *sig64;
if((e = gcry_md_open(&h, ALGO, GCRY_MD_FLAG_HMAC))) {
- error(0, "gcry_md_open: %s", gcry_strerror(e));
+
disorder_
error(0, "gcry_md_open: %s", gcry_strerror(e));
return 0;
}
if((e = gcry_md_setkey(h, key, HASHSIZE))) {
return 0;
}
if((e = gcry_md_setkey(h, key, HASHSIZE))) {
- error(0, "gcry_md_setkey: %s", gcry_strerror(e));
+
disorder_
error(0, "gcry_md_setkey: %s", gcry_strerror(e));
gcry_md_close(h);
return 0;
}
gcry_md_close(h);
return 0;
}
@@
-125,13
+124,13
@@
char *make_cookie(const char *user) {
/* dollar signs aren't allowed in usernames */
if(strchr(user, '$')) {
/* dollar signs aren't allowed in usernames */
if(strchr(user, '$')) {
- error(0, "make_cookie for username with dollar sign");
+
disorder_
error(0, "make_cookie for username with dollar sign");
return 0;
}
/* look up the password */
password = trackdb_get_password(user);
if(!password) {
return 0;
}
/* look up the password */
password = trackdb_get_password(user);
if(!password) {
- error(0, "make_cookie for nonexistent user");
+
disorder_
error(0, "make_cookie for nonexistent user");
return 0;
}
/* make sure we have a valid signing key */
return 0;
}
/* make sure we have a valid signing key */
@@
-165,24
+164,24
@@
char *verify_cookie(const char *cookie, rights_type *rights) {
/* check the revocation list */
if(revoked && hash_find(revoked, cookie)) {
/* check the revocation list */
if(revoked && hash_find(revoked, cookie)) {
- error(0, "attempt to log in with revoked cookie");
+
disorder_
error(0, "attempt to log in with revoked cookie");
return 0;
}
/* parse the cookie */
errno = 0;
t = strtoimax(cookie, &c1, 16);
if(errno) {
return 0;
}
/* parse the cookie */
errno = 0;
t = strtoimax(cookie, &c1, 16);
if(errno) {
- error(errno, "error parsing cookie timestamp");
+
disorder_
error(errno, "error parsing cookie timestamp");
return 0;
}
if(*c1 != '$') {
return 0;
}
if(*c1 != '$') {
- error(0, "invalid cookie timestamp");
+
disorder_
error(0, "invalid cookie timestamp");
return 0;
}
/* There'd better be two dollar signs */
c2 = strchr(c1 + 1, '$');
if(c2 == 0) {
return 0;
}
/* There'd better be two dollar signs */
c2 = strchr(c1 + 1, '$');
if(c2 == 0) {
- error(0, "invalid cookie syntax");
+
disorder_
error(0, "invalid cookie syntax");
return 0;
}
/* Extract the username */
return 0;
}
/* Extract the username */
@@
-190,13
+189,13
@@
char *verify_cookie(const char *cookie, rights_type *rights) {
/* check expiry */
xtime(&now);
if(now >= t) {
/* check expiry */
xtime(&now);
if(now >= t) {
- error(0, "cookie has expired");
+
disorder_
error(0, "cookie has expired");
return 0;
}
/* look up the password */
k = trackdb_getuserinfo(user);
if(!k) {
return 0;
}
/* look up the password */
k = trackdb_getuserinfo(user);
if(!k) {
- error(0, "verify_cookie for nonexistent user");
+
disorder_
error(0, "verify_cookie for nonexistent user");
return 0;
}
password = kvp_get(k, "password");
return 0;
}
password = kvp_get(k, "password");
@@
-218,7
+217,7
@@
char *verify_cookie(const char *cookie, rights_type *rights) {
if(!strcmp(sig, c2 + 1))
return user;
/* that didn't match either */
if(!strcmp(sig, c2 + 1))
return user;
/* that didn't match either */
- error(0, "cookie signature does not match");
+
disorder_
error(0, "cookie signature does not match");
return 0;
}
return 0;
}