Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
7a62818f
Commit
7a62818f
authored
Jan 20, 2010
by
Davide Camurri
Committed by
Max Kellermann
Jan 20, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: optionally use libwrap
parent
acb0ff1e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
0 deletions
+72
-0
Makefile.am
Makefile.am
+2
-0
NEWS
NEWS
+1
-0
configure.ac
configure.ac
+2
-0
libwrap.m4
m4/libwrap.m4
+37
-0
client_new.c
src/client_new.c
+30
-0
No files found.
Makefile.am
View file @
7a62818f
...
@@ -9,6 +9,7 @@ bin_PROGRAMS = src/mpd
...
@@ -9,6 +9,7 @@ bin_PROGRAMS = src/mpd
src_mpd_CFLAGS
=
$(AM_CFLAGS)
$(MPD_CFLAGS)
src_mpd_CFLAGS
=
$(AM_CFLAGS)
$(MPD_CFLAGS)
src_mpd_CPPFLAGS
=
$(AM_CPPFLAGS)
\
src_mpd_CPPFLAGS
=
$(AM_CPPFLAGS)
\
$(LIBWRAP_CFLAGS)
\
$(SQLITE_CFLAGS)
\
$(SQLITE_CFLAGS)
\
$(ARCHIVE_CFLAGS)
\
$(ARCHIVE_CFLAGS)
\
$(INPUT_CFLAGS)
\
$(INPUT_CFLAGS)
\
...
@@ -18,6 +19,7 @@ src_mpd_CPPFLAGS = $(AM_CPPFLAGS) \
...
@@ -18,6 +19,7 @@ src_mpd_CPPFLAGS = $(AM_CPPFLAGS) \
$(FILTER_CFLAGS)
\
$(FILTER_CFLAGS)
\
$(OUTPUT_CFLAGS)
$(OUTPUT_CFLAGS)
src_mpd_LDADD
=
$(MPD_LIBS)
\
src_mpd_LDADD
=
$(MPD_LIBS)
\
$(LIBWRAP_LDFLAGS)
\
$(SQLITE_LIBS)
\
$(SQLITE_LIBS)
\
$(ARCHIVE_LIBS)
\
$(ARCHIVE_LIBS)
\
$(INPUT_LIBS)
\
$(INPUT_LIBS)
\
...
...
NEWS
View file @
7a62818f
...
@@ -86,6 +86,7 @@ ver 0.16 (20??/??/??)
...
@@ -86,6 +86,7 @@ ver 0.16 (20??/??/??)
* build with large file support by default
* build with large file support by default
* added test suite ("make check")
* added test suite ("make check")
* require GLib 2.12
* require GLib 2.12
* added libwrap support
ver 0.15.8 (2010/01/17)
ver 0.15.8 (2010/01/17)
...
...
configure.ac
View file @
7a62818f
...
@@ -205,6 +205,8 @@ dnl ##
...
@@ -205,6 +205,8 @@ dnl ##
dnl misc libraries
dnl misc libraries
dnl ##
dnl ##
AC_CHECK_LIBWRAP
AC_ARG_ENABLE(cue,
AC_ARG_ENABLE(cue,
AS_HELP_STRING([--enable-cue],
AS_HELP_STRING([--enable-cue],
[enable support for libcue support]),,
[enable support for libcue support]),,
...
...
m4/libwrap.m4
0 → 100644
View file @
7a62818f
dnl
dnl Usage:
dnl AC_CHECK_LIBWRAP([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
dnl
AC_DEFUN([AC_CHECK_LIBWRAP],
[dnl start
AC_ARG_ENABLE([libwrap],
[AS_HELP_STRING([--disable-libwrap],
[use libwrap (default enabled)])], ,
[
AC_CHECK_HEADERS([tcpd.h],
[],
[AC_MSG_ERROR([tpcd.h libwrap header not found])]
$3)
AC_CHECK_LIB([wrap],
[request_init],
[],
[AC_MSG_ERROR([libwrap not found !])]
$3)
AC_DEFINE(HAVE_LIBWRAP, 1, [define to enable libwrap library])
LIBWRAP_CFLAGS=""
LIBWRAP_LDFLAGS="-lwrap"
AC_SUBST([LIBWRAP_CFLAGS])
AC_SUBST([LIBWRAP_LDFLAGS])
dnl ACTION-IF-FOUND
$2
]) dnl AC_ARG_ENABLE
]) dnl AC_DEFUN
src/client_new.c
View file @
7a62818f
...
@@ -26,6 +26,11 @@
...
@@ -26,6 +26,11 @@
#include <assert.h>
#include <assert.h>
#include <unistd.h>
#include <unistd.h>
#ifdef HAVE_LIBWRAP
#include <tcpd.h>
#endif
#define LOG_LEVEL_SECURE G_LOG_LEVEL_INFO
#define LOG_LEVEL_SECURE G_LOG_LEVEL_INFO
static
const
char
GREETING
[]
=
"OK MPD "
PROTOCOL_VERSION
"
\n
"
;
static
const
char
GREETING
[]
=
"OK MPD "
PROTOCOL_VERSION
"
\n
"
;
...
@@ -38,6 +43,31 @@ void client_new(int fd, const struct sockaddr *sa, size_t sa_length, int uid)
...
@@ -38,6 +43,31 @@ void client_new(int fd, const struct sockaddr *sa, size_t sa_length, int uid)
assert
(
fd
>=
0
);
assert
(
fd
>=
0
);
#ifdef HAVE_LIBWRAP
if
(
sa
->
sa_family
!=
AF_UNIX
)
{
char
*
hostaddr
=
sockaddr_to_string
(
sa
,
sa_length
,
NULL
);
const
char
*
progname
=
g_get_prgname
();
struct
request_info
req
;
request_init
(
&
req
,
RQ_FILE
,
fd
,
RQ_DAEMON
,
progname
,
0
);
fromhost
(
&
req
);
if
(
!
hosts_access
(
&
req
))
{
/* tcp wrappers says no */
g_log
(
G_LOG_DOMAIN
,
LOG_LEVEL_SECURE
,
"libwrap refused connection (libwrap=%s) from %s"
,
progname
,
hostaddr
);
g_free
(
hostaddr
);
close
(
fd
);
return
;
}
g_free
(
hostaddr
);
}
#endif
/* HAVE_WRAP */
if
(
client_list_is_full
())
{
if
(
client_list_is_full
())
{
g_warning
(
"Max Connections Reached!"
);
g_warning
(
"Max Connections Reached!"
);
close
(
fd
);
close
(
fd
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment