]> git.armaanb.net Git - opendoas.git/blobdiff - shadow.c
Add insult option to doas.conf
[opendoas.git] / shadow.c
index 45ac58d2e5b12ed92cb11266f5c3f9e616752e0c..01509f03df15d25315b0de364fd40341bd2d51bb 100644 (file)
--- a/shadow.c
+++ b/shadow.c
@@ -41,7 +41,7 @@
 #define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
 #endif
 
-void
+int
 shadowauth(const char *myname, int persist)
 {
        const char *hash;
@@ -68,11 +68,11 @@ shadowauth(const char *myname, int persist)
        if (hash[0] == 'x' && hash[1] == '\0') {
                struct spwd *sp;
                if ((sp = getspnam(myname)) == NULL) {
-                       authfail();
+                       return(5);
                }
                hash = sp->sp_pwdp;
        } else if (hash[0] != '*') {
-               authfail();
+               return(5);
        }
 
        char host[HOST_NAME_MAX + 1];
@@ -93,12 +93,12 @@ shadowauth(const char *myname, int persist)
        if ((encrypted = crypt(response, hash)) == NULL) {
                explicit_bzero(rbuf, sizeof(rbuf));
                printf(getinsult());
-               authfail();
+               return(5);
        }
        explicit_bzero(rbuf, sizeof(rbuf));
        if (strcmp(encrypted, hash) != 0) {
                syslog(LOG_AUTHPRIV | LOG_NOTICE, "failed auth for %s", myname);
-               authfail();
+               return(5);
        }
 
 #ifdef USE_TIMESTAMP
@@ -108,4 +108,5 @@ good:
                close(fd);
        }
 #endif
+       return(0);
 }