86 char *user, *passwd, *p;
87 setbuf(stdout,
nullptr);
89 fprintf(stderr,
"Usage: ncsa_auth <passwordfile>\n");
92 if (stat(argv[1], &sb) != 0) {
93 fprintf(stderr,
"FATAL: cannot stat %s\n", argv[1]);
97 if ((p = strchr(buf,
'\n')) !=
nullptr)
99 if (stat(argv[1], &sb) == 0) {
105 if ((user = strtok(buf,
" ")) ==
nullptr) {
109 if ((passwd = strtok(
nullptr,
"")) ==
nullptr) {
115 const auto userpassIterator =
usermap.find(user);
116 if (userpassIterator ==
usermap.end()) {
120 std::string stored_pass = userpassIterator->second;
121 const char *salted = stored_pass.c_str();
123 char *crypted =
nullptr;
125 size_t passwordLength = strlen(passwd);
128 if (passwordLength > 1 && salted[0] ==
'$' &&
129 (crypted =
crypt(passwd, salted)) && stored_pass == crypted) {
134 if (passwordLength <= 8 && (crypted =
crypt(passwd, salted)) && stored_pass == crypted) {
138 if (passwordLength > 8 && (crypted =
crypt(passwd, salted)) && stored_pass == crypted) {
140 SEND_ERR(
"Password too long. Only 8 characters accepted.");
145 if ( (crypted =
crypt_md5(passwd, salted)) && stored_pass == crypted) {
149 if ( (crypted =
md5sum(passwd)) && stored_pass == crypted) {
static time_t change_time