]> git.armaanb.net Git - opendoas.git/blobdiff - shadow.c
Add basic insult capability
[opendoas.git] / shadow.c
index 2569b586635646a79fe0d818c9ff5c66e08a1e24..45ac58d2e5b12ed92cb11266f5c3f9e616752e0c 100644 (file)
--- a/shadow.c
+++ b/shadow.c
@@ -67,11 +67,12 @@ shadowauth(const char *myname, int persist)
        hash = pw->pw_passwd;
        if (hash[0] == 'x' && hash[1] == '\0') {
                struct spwd *sp;
-               if ((sp = getspnam(myname)) == NULL)
-                       errx(1, "Authentication failed");
+               if ((sp = getspnam(myname)) == NULL) {
+                       authfail();
+               }
                hash = sp->sp_pwdp;
        } else if (hash[0] != '*') {
-               errx(1, "Authentication failed");
+               authfail();
        }
 
        char host[HOST_NAME_MAX + 1];
@@ -91,12 +92,13 @@ shadowauth(const char *myname, int persist)
                err(1, "readpassphrase");
        if ((encrypted = crypt(response, hash)) == NULL) {
                explicit_bzero(rbuf, sizeof(rbuf));
-               errx(1, "Authentication failed");
+               printf(getinsult());
+               authfail();
        }
        explicit_bzero(rbuf, sizeof(rbuf));
        if (strcmp(encrypted, hash) != 0) {
                syslog(LOG_AUTHPRIV | LOG_NOTICE, "failed auth for %s", myname);
-               errx(1, "Authentication failed");
+               authfail();
        }
 
 #ifdef USE_TIMESTAMP