]> git.armaanb.net Git - opendoas.git/blobdiff - doas.c
Add -std=c99 to Makefile
[opendoas.git] / doas.c
diff --git a/doas.c b/doas.c
index eb9c47a47b43a3c0bdc62a53e7219960087bf50a..2cd227d1adf322e846b616524e1c11afdad2d7ef 100644 (file)
--- a/doas.c
+++ b/doas.c
@@ -237,9 +237,14 @@ mygetpwuid_r(uid_t uid, struct passwd *pwd, struct passwd **result)
 }
 
 void
-authfail(void)
+authfail(int opt)
 {
-       printf("%s\n", getinsult());
+
+#ifdef DOAS_INSULTS
+       if (opt)
+               printf("%s\n", getinsult());
+#endif
+
        errx(1, "Authentication failed");
 }
 
@@ -357,19 +362,14 @@ main(int argc, char **argv)
                errc(1, EPERM, NULL);
        }
 
-#if defined(USE_SHADOW)
        if (!(rule->options & NOPASS)) {
                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 */
-       (void) nflag;
-       if (!(rule->options & NOPASS))
-               errx(1, "Authentication required");
-#endif
 
        if ((p = getenv("PATH")) != NULL)
                formerpath = strdup(p);
@@ -387,11 +387,6 @@ main(int argc, char **argv)
        if (targpw == NULL)
                errx(1, "no passwd entry for target");
 
-#if defined(USE_PAM)
-       pamauth(targpw->pw_name, mypw->pw_name, !nflag, rule->options & NOPASS,
-           rule->options & PERSIST);
-#endif
-
 #ifdef HAVE_LOGIN_CAP_H
        if (setusercontext(NULL, targpw, target, LOGIN_SETGROUP |
            LOGIN_SETPATH |