summaryrefslogtreecommitdiffstats
path: root/nest/password.c
diff options
context:
space:
mode:
authorOndrej Filip <feela@network.cz>2004-06-26 22:11:14 +0200
committerOndrej Filip <feela@network.cz>2004-06-26 22:11:14 +0200
commit5236fb03afecd3d7a6ec6e96712c79a31be32132 (patch)
treeafee4d3766107cdc205d7da70a66d09014aa1ef6 /nest/password.c
parent98ac61766d81d9f20c4a7c7e12859c3b82b24f4c (diff)
downloadbird-5236fb03afecd3d7a6ec6e96712c79a31be32132.tar
bird-5236fb03afecd3d7a6ec6e96712c79a31be32132.zip
Password management redesigned (untested).
Diffstat (limited to 'nest/password.c')
-rw-r--r--nest/password.c63
1 files changed, 12 insertions, 51 deletions
diff --git a/nest/password.c b/nest/password.c
index 594569c..6309602 100644
--- a/nest/password.c
+++ b/nest/password.c
@@ -1,7 +1,8 @@
/*
* BIRD -- Password handling
*
- * Copyright 1999 Pavel Machek <pavel@ucw.cz>
+ * (c) 1999 Pavel Machek <pavel@ucw.cz>
+ * (c) 2004 Ondrej Filip <feela@network.cz>
*
* Can be freely distributed and used under the terms of the GNU GPL.
*/
@@ -12,62 +13,22 @@
struct password_item *last_password_item = NULL;
-static int
-password_goodness(struct password_item *i)
-{
- if (i->from > now)
- return 0;
- if (i->to < now)
- return 0;
- if (i->passive < now)
- return 1;
- return 2;
-}
-
struct password_item *
-get_best_password(struct password_item *head, int flags UNUSED)
+password_find(list *l)
{
- int good = -1;
- struct password_item *best = NULL;
+ struct password_item *pi;
- while (head) {
- int cur = password_goodness(head);
- if (cur > good) {
- good = cur;
- best = head;
- }
- head=head->next;
+ WALK_LIST(pi, *l)
+ {
+ if ((pi->genfrom > now) && (pi->gento < now))
+ return pi;
}
- return best;
+ return NULL;
}
-void
-password_strncpy(char *to, char *from, int len)
+void password_cpy(char *dst, char *src, int size)
{
- int i;
- for (i=0; i<len; i++) {
- *to++ = *from;
- if (*from)
- from++;
- }
+ bzero(dst, size);
+ memcpy(dst, src, strlen(src) < size ? strlen(src) : size);
}
-int
-password_same(struct password_item *old, struct password_item *new)
-{
- for(;;)
- {
- if (old == new)
- return 1;
- if (!old || !new)
- return 0;
- if (old->from != new->from ||
- old->to != new->to ||
- old->passive != new->passive ||
- old->id != new->id ||
- strcmp(old->password, new->password))
- return 0;
- old = old->next;
- new = new->next;
- }
-}