summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Hall <GMCH@hestia.halldom.com>2010-04-28 12:09:58 +0100
committerChris Hall <GMCH@hestia.halldom.com>2010-04-28 12:09:58 +0100
commit6c2482c466aa420875f330893dc36101c3e7fd46 (patch)
tree6bfe4f1caffc00dc9c2543cf2431faac285349e3
parent45e56ea7b20686d425030bd43f665cd0e690eb31 (diff)
downloadquagga-6c2482c466aa420875f330893dc36101c3e7fd46.tar.bz2
quagga-6c2482c466aa420875f330893dc36101c3e7fd46.tar.xz
Don't return "Not Supported" when setting NULL MD5 password
If TCP MD5 signature is not supported, sockopt_tcp_signature() returns ENOSYS. This change means that if the given password is NULL or an empty string, then returns OK, even when TCP MD5 signature is not supported. If the password is being cleared, it doesn't matter that it could never have bee set in the first place ! This means that unless a password is required, it is safe to call sockopt_tcp_signature() whether the facility is supported or not. Which further means that only this function needs to worry about the circumstances under which it is supported !
-rw-r--r--lib/sockopt.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/sockopt.c b/lib/sockopt.c
index bf3c5d50..a8fae4f1 100644
--- a/lib/sockopt.c
+++ b/lib/sockopt.c
@@ -674,9 +674,14 @@ sockopt_tcp_signature (int sock_fd, union sockunion *su, const char *password)
return (err == 0) ? 0 : -1 ;
-#else /* HAVE_TCP_MD5SIG */
+#else
+
+ /* TCP MD5 is not supported */
+
+ if ((password == NULL) || (*password == '\0'))
+ return 0 ; /* OK if not required ! */
- errno = ENOSYS ; /* TCP MD5 is not supported */
+ errno = ENOSYS ; /* manufactured error */
return -1 ;
#endif /* !HAVE_TCP_MD5SIG */