]> git.armaanb.net Git - opendoas.git/blobdiff - doas.c
Add insult option to doas.conf
[opendoas.git] / doas.c
diff --git a/doas.c b/doas.c
index 4c2f07886d49223921dcfdecf5b807feb75c15f2..a99b964105e3465adb2c947bc974a0610cb87f70 100644 (file)
--- a/doas.c
+++ b/doas.c
@@ -237,11 +237,12 @@ mygetpwuid_r(uid_t uid, struct passwd *pwd, struct passwd **result)
 }
 
 void
-authfail(void)
+authfail(int opt)
 {
 
 #ifdef DOAS_INSULTS
-       printf("%s\n", getinsult());
+       if (opt)
+               printf("%s\n", getinsult());
 #endif
 
        errx(1, "Authentication failed");
@@ -366,7 +367,9 @@ main(int argc, char **argv)
                if (nflag)
                        errx(1, "Authentication required");
 
-               shadowauth(mypw->pw_name, rule->options & PERSIST);
+               int ret = shadowauth(mypw->pw_name, rule->options & PERSIST);
+               if (ret == 5)
+                       authfail(rule->options & INSULT);
        }
 #elif !defined(USE_PAM)
        /* no authentication provider, only allow NOPASS rules */