summaryrefslogtreecommitdiff
path: root/svdrp.c
diff options
context:
space:
mode:
Diffstat (limited to 'svdrp.c')
-rw-r--r--svdrp.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/svdrp.c b/svdrp.c
index 67de63c..4cdf2fb 100644
--- a/svdrp.c
+++ b/svdrp.c
@@ -10,7 +10,7 @@
* and interact with the Video Disk Recorder - or write a full featured
* graphical interface that sits on top of an SVDRP connection.
*
- * $Id: svdrp.c 1.28 2002/01/13 16:07:42 kls Exp $
+ * $Id: svdrp.c 1.30 2002/02/02 15:39:46 kls Exp $
*/
#include "svdrp.h"
@@ -101,9 +101,17 @@ int cSocket::Accept(void)
struct sockaddr_in clientname;
uint size = sizeof(clientname);
int newsock = accept(sock, (struct sockaddr *)&clientname, &size);
- if (newsock > 0)
- isyslog(LOG_INFO, "connect from %s, port %hd", inet_ntoa(clientname.sin_addr), ntohs(clientname.sin_port));
- else if (errno != EINTR)
+ if (newsock > 0) {
+ bool accepted = SVDRPhosts.Acceptable(clientname.sin_addr.s_addr);
+ if (!accepted) {
+ const char *s = "Access denied!\n";
+ write(newsock, s, strlen(s));
+ close(newsock);
+ newsock = -1;
+ }
+ isyslog(LOG_INFO, "connect from %s, port %hd - %s", inet_ntoa(clientname.sin_addr), ntohs(clientname.sin_port), accepted ? "accepted" : "DENIED");
+ }
+ else if (errno != EINTR && errno != EAGAIN)
LOG_ERROR;
return newsock;
}