aboutsummaryrefslogtreecommitdiffstats
path: root/key2root.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-06-23 19:15:49 +0200
committerMattias Andrée <maandree@kth.se>2023-06-23 19:15:49 +0200
commit7281ae7db4d9bc9eb2b59134e1dea1231013f1af (patch)
tree14d15e56dea896c71b0b4576a9633ea759080d58 /key2root.c
parentFix exit status (diff)
downloadkey2root-7281ae7db4d9bc9eb2b59134e1dea1231013f1af.tar.gz
key2root-7281ae7db4d9bc9eb2b59134e1dea1231013f1af.tar.bz2
key2root-7281ae7db4d9bc9eb2b59134e1dea1231013f1af.tar.xz
Use libar2simplified instead of crypt as crypt has a verily limited imput size, and add -h to key2root-addkey, and add key2root-crypt
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--key2root.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/key2root.c b/key2root.c
index 450ca00..49febd2 100644
--- a/key2root.c
+++ b/key2root.c
@@ -12,6 +12,7 @@
#include <unistd.h>
#include "arg.h"
+#include "crypt.h"
#define EXIT_AUTH 124
@@ -276,8 +277,9 @@ checkauth(char *data, size_t whead, size_t *rheadp, size_t *rhead2p, size_t *lin
*rheadp += keyname_len + 1;
*key_foundp = 1;
data[(*rhead2p)++] = '\0';
- hash = crypt(key, &data[*rheadp]);
+ hash = key2root_crypt(key, key_len, &data[*rheadp], 0);
match = hash && hashequal(hash, &data[*rheadp]);
+ free(hash);
*rheadp = *rhead2p;
return match;
}
@@ -360,7 +362,6 @@ main(int argc, char *argv[])
char path_user_id[sizeof(KEYPATH"/") + 3 * sizeof(uintmax_t)];
char *path_user_name;
struct passwd *pwd;
- size_t i;
ARGBEGIN {
case 'e':
@@ -378,9 +379,6 @@ main(int argc, char *argv[])
if (!argc)
usage();
- if (mlockall(MCL_CURRENT | MCL_FUTURE))
- fprintf(stderr, "%s: mlockall MCL_CURRENT|MCL_FUTURE: %s\n", argv0, strerror(errno));
-
sprintf(path_user_id, "%s/%ju", KEYPATH, (uintmax_t)getuid());
errno = 0;
pwd = getpwuid(getuid());
@@ -421,10 +419,6 @@ main(int argc, char *argv[])
}
key_len += (size_t)r;
}
- for (i = 0; i < key_len; i++)
- if (!key[i])
- key[i] = (char)255;
- key[key_len] = '\0';
key_found = 0;
if (!authenticate(path_user_id, key_name, key, key_len, &key_found) &&