summaryrefslogtreecommitdiff
path: root/sys/lib/libsa
diff options
context:
space:
mode:
authordsl <dsl@NetBSD.org>2003-04-15 22:26:42 +0000
committerdsl <dsl@NetBSD.org>2003-04-15 22:26:42 +0000
commit7c8e4cdaea97777b3515e647caa1ca8a97e405c2 (patch)
tree55ee63e5bf95586a7161a51067932e3c52288405 /sys/lib/libsa
parentc0cc8d30c1b6a2cb5fce7c429d96558a6162cfa2 (diff)
Add interface to boot password checking code that takes password parameter.
Diffstat (limited to 'sys/lib/libsa')
-rw-r--r--sys/lib/libsa/checkpasswd.c14
-rw-r--r--sys/lib/libsa/stand.h3
2 files changed, 12 insertions, 5 deletions
diff --git a/sys/lib/libsa/checkpasswd.c b/sys/lib/libsa/checkpasswd.c
index f26fccb0e04..5b6cc4be89e 100644
--- a/sys/lib/libsa/checkpasswd.c
+++ b/sys/lib/libsa/checkpasswd.c
@@ -1,4 +1,4 @@
-/* $NetBSD: checkpasswd.c,v 1.4 2000/03/30 12:19:47 augustss Exp $ */
+/* $NetBSD: checkpasswd.c,v 1.5 2003/04/15 22:26:42 dsl Exp $ */
/*-
* Copyright (c) 1993
@@ -96,7 +96,13 @@ getpass(prompt)
char bootpasswd[16] = {'\0'}; /* into data segment! */
int
-checkpasswd()
+checkpasswd(void)
+{
+ return check_password(bootpasswd);
+}
+
+int
+check_password(const char *password)
{
int i;
char *passwd;
@@ -104,7 +110,7 @@ checkpasswd()
char pwdigest[16];
for (i = 0; i < 16; i++)
- if (bootpasswd[i])
+ if (password[i])
break;
if (i == 16)
return (1); /* no password set */
@@ -114,7 +120,7 @@ checkpasswd()
MD5Init(&md5ctx);
MD5Update(&md5ctx, passwd, strlen(passwd));
MD5Final(pwdigest, &md5ctx);
- if (bcmp(pwdigest, bootpasswd, 16) == 0)
+ if (bcmp(pwdigest, password, 16) == 0)
return (1);
}
diff --git a/sys/lib/libsa/stand.h b/sys/lib/libsa/stand.h
index e6109d9e680..41d2a4aa0b4 100644
--- a/sys/lib/libsa/stand.h
+++ b/sys/lib/libsa/stand.h
@@ -1,4 +1,4 @@
-/* $NetBSD: stand.h,v 1.47 2003/04/11 10:34:38 dsl Exp $ */
+/* $NetBSD: stand.h,v 1.48 2003/04/15 22:26:42 dsl Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@@ -259,6 +259,7 @@ int getopt(int, char * const *, const char *);
char *getpass(const char *);
int checkpasswd(void);
+int check_password(const char *);
int nodev(void);
int noioctl(struct open_file *, u_long, void *);