mirror of https://github.com/dirtbags/moth.git
I didn't need the team listing code in in.tokend
This commit is contained in:
parent
442ac5e27f
commit
354200b449
|
@ -1,5 +1,4 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
@ -11,33 +10,8 @@
|
|||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sysexits.h>
|
||||
#include <dirent.h>
|
||||
#include "common.h"
|
||||
#include "arc4.h"
|
||||
#include "md5.h"
|
||||
|
||||
void
|
||||
list_teams()
|
||||
{
|
||||
struct dirent *ent;
|
||||
DIR *dir;
|
||||
|
||||
dir = opendir(state_path("teams/names"));
|
||||
if (! dir) return;
|
||||
while ((ent = readdir(dir))) {
|
||||
struct stat buf;
|
||||
|
||||
if ((0 == stat(state_path("teams/names/%s", ent->d_name), &buf)) &&
|
||||
(S_ISREG(buf.st_mode))) {
|
||||
char digest[MD5_HEXDIGEST_LEN + 1];
|
||||
|
||||
md5_hexdigest((uint8_t *)ent->d_name, strlen(ent->d_name), digest);
|
||||
digest[MD5_HEXDIGEST_LEN] = '\n';
|
||||
write(1, digest, sizeof(digest));
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
|
@ -55,20 +29,11 @@ main(int argc, char *argv[])
|
|||
|
||||
len = read(0, category, sizeof(category));
|
||||
if (0 >= len) return 0;
|
||||
|
||||
/* Category name of "?" lists arc4 hashes of all teams */
|
||||
if ((1 == len) && ('?' == category[0])) {
|
||||
list_teams();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Strip invalid characters */
|
||||
for (categorylen = 0;
|
||||
(categorylen < len) && isalnum(category[categorylen]);
|
||||
categorylen += 1);
|
||||
}
|
||||
|
||||
|
||||
/* Read in that category's key. */
|
||||
{
|
||||
int fd;
|
||||
|
|
Loading…
Reference in New Issue