From: Todd C. Miller <Todd.Miller@courtesan.com>
Date: Sat, 24 Oct 1998 23:28:04 +0000 (+0000)
Subject: add pass_warn() which prints out INCORRECT_PASSWORD or an insult to stderr
X-Git-Tag: SUDO_1_5_7~43
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=261cdb5d876ffb767214d2e3c75a7fd8f6fbfe85;p=sudo

add pass_warn() which prints out INCORRECT_PASSWORD or an insult to stderr
---

diff --git a/check.c b/check.c
index c2d3da5d4..63f44a3b2 100644
--- a/check.c
+++ b/check.c
@@ -464,11 +464,7 @@ static void check_passwd()
 	}
 
 	--counter;		/* otherwise, try again  */
-#ifdef USE_INSULTS
-	(void) fprintf(stderr, "%s\n", INSULT);
-#else
-	(void) fprintf(stderr, "%s\n", INCORRECT_PASSWORD);
-#endif /* USE_INSULTS */
+	pass_warn(stderr);
     }
     set_perms(PERM_USER, 0);
 
@@ -620,11 +616,7 @@ static void check_passwd()
 #endif /* HAVE_AUTHENTICATE */
 
 	--counter;		/* otherwise, try again  */
-#ifdef USE_INSULTS
-	(void) fprintf(stderr, "%s\n", INSULT);
-#else
-	(void) fprintf(stderr, "%s\n", INCORRECT_PASSWORD);
-#endif /* USE_INSULTS */
+	pass_warn(stderr);
     }
 
     if (counter > 0) {
@@ -724,11 +716,7 @@ static void pam_attempt_auth()
         }
 
         --counter;
-#ifdef USE_INSULTS
-        (void) fprintf(stderr, "%s\n", INSULT);
-#else
-        (void) fprintf(stderr, "%s\n", INCORRECT_PASSWORD);
-#endif /* USE_INSULTS */
+        pass_warn(stderr);
     }
     set_perms(PERM_USER, 0);
 
@@ -924,3 +912,23 @@ static void reminder()
     );
 }
 #endif /* NO_MESSAGE */
+
+
+/********************************************************************
+ *
+ *  pass_warn()
+ *
+ *  warn the user that the password was incorrect
+ *  (and insult them if insults are configured).
+ */
+
+void pass_warn(fp)
+    FILE *fp;
+{
+
+#ifdef USE_INSULTS
+    (void) fprintf(fp, "%s\n", INSULT);
+#else
+    (void) fprintf(fp, "%s\n", INCORRECT_PASSWORD);
+#endif /* USE_INSULTS */
+}
diff --git a/check_sia.c b/check_sia.c
index 2bc896637..cc08c6f85 100644
--- a/check_sia.c
+++ b/check_sia.c
@@ -114,11 +114,7 @@ void sia_attempt_auth()
 	}
 
 	--counter;
-#ifdef USE_INSULTS
-	(void) fprintf(stderr, "%s\n", INSULT);
-#else
-	(void) fprintf(stderr, "%s\n", INCORRECT_PASSWORD);
-#endif /* USE_INSULTS */
+	pass_warn(stderr);
     }
     set_perms(PERM_USER, 0);
 
diff --git a/sudo.h b/sudo.h
index af16bf7e8..cbde069d1 100644
--- a/sudo.h
+++ b/sudo.h
@@ -232,6 +232,7 @@ void load_interfaces	__P((void));
 int check_secureware	__P((char *));
 void sia_attempt_auth	__P((void));
 int yyparse		__P((void));
+void pass_warn		__P((FILE *));
 YY_DECL;