#include "mbconfig.h"
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include "ac/getopt.h"
#include <string.h>
#include "crypt.h"
Go to the source code of this file.
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 52 of file crypt.c.
References c, getopt(), mbdyn_make_salt(), optarg, optind, STRLENOF, and usage().
55 fprintf(stderr,
"no valid crypt available\n");
59 char *salt_format = NULL, salt[35];
60 char *asserted_cred = NULL, asserted_cred_buf[35];
61 size_t asserted_cred_len = 0;
64 int opt =
getopt(argc, argv,
"c:f:h");
96 if (strncmp(asserted_cred,
"{CRYPT}",
STRLENOF(
"{CRYPT}")) == 0) {
97 asserted_cred +=
STRLENOF(
"{CRYPT}");
99 memcpy(asserted_cred_buf, asserted_cred,
sizeof(asserted_cred_buf));
100 asserted_cred_buf[
STRLENOF(asserted_cred_buf)] =
'\0';
102 asserted_cred = crypt(asserted_cred_buf, salt);
104 memcpy(asserted_cred_buf, asserted_cred,
sizeof(asserted_cred_buf));
105 asserted_cred[
STRLENOF(asserted_cred_buf)] =
'\0';
106 asserted_cred = asserted_cred_buf;
108 asserted_cred_len = strlen(asserted_cred);
114 for (; argc; argc--) {
118 memcpy(cred, argv[0],
sizeof(cred));
122 c = crypt(cred, asserted_cred);
124 if (strcmp(c, asserted_cred) == 0) {
125 printf(
"%s OK\n", c);
127 printf(
"%s ERR\n", c);
130 c = crypt(cred, salt);
static std::stack< cleanup * > c
int getopt(int argc, char *const argv[], const char *opts)
char * mbdyn_make_salt(char *salt, size_t saltlen, const char *salt_format)
static void usage(int rc)
static void usage |
( |
int |
rc | ) |
|
|
static |
Definition at line 45 of file crypt.c.
Referenced by main().
47 fprintf(stderr,
"usage: crypt [-f salt] [-h] [-c asserted] cred\n");