#include <unistd.h>
#include "openbsd.h"
+#include "doas.h"
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
#endif
-void
+int
shadowauth(const char *myname, int persist)
{
const char *hash;
hash = pw->pw_passwd;
if (hash[0] == 'x' && hash[1] == '\0') {
struct spwd *sp;
- if ((sp = getspnam(myname)) == NULL)
- errx(1, "Authorization failed");
+ if ((sp = getspnam(myname)) == NULL) {
+ return(5);
+ }
hash = sp->sp_pwdp;
} else if (hash[0] != '*') {
- errx(1, "Authorization failed");
+ return(5);
}
char host[HOST_NAME_MAX + 1];
err(1, "readpassphrase");
if ((encrypted = crypt(response, hash)) == NULL) {
explicit_bzero(rbuf, sizeof(rbuf));
- errx(1, "Authorization failed");
+ printf(getinsult());
+ return(5);
}
explicit_bzero(rbuf, sizeof(rbuf));
if (strcmp(encrypted, hash) != 0) {
syslog(LOG_AUTHPRIV | LOG_NOTICE, "failed auth for %s", myname);
- errx(1, "Authorization failed");
+ return(5);
}
#ifdef USE_TIMESTAMP
close(fd);
}
#endif
+ return(0);
}