Skip to content

Commit 97f22dc

Browse files
author
drscholl
committed
changed basename() to my_basename() to avoid compilation errors on some
systems. look for -lz in /usr/local/lib opennap should return message 13 when receving unknown commands prior to receipt of the login (2) message. added support for tcp_wrappers mods+ could not bypass the strict channel join setting opennap should send the 316 numeric prior to disconnecting clients to be compatible with the napster.com servers updated napster.txt with new information sysv-init style script for starting opennap at boot from Geoffrey Lee <[email protected]>
1 parent af0e77e commit 97f22dc

13 files changed

+229
-122
lines changed

Makefile.am

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
bin_PROGRAMS=opennap metaserver setup #mkpass
1+
sbin_PROGRAMS=opennap metaserver setup #mkpass
22
opennap_SOURCES=opennap.h main.c add_file.c search.c \
33
motd.c hash.h hash.c privmsg.c browse.c \
44
debug.c debug.h login.c whois.c free_user.c \
@@ -18,7 +18,7 @@ EXTRA_DIST=sample.conf sample.motd napster.txt .indent.pro \
1818
FAQ patchnap.c spyserv.c opennap.dsw opennap.dsp \
1919
opennap.opt sample.users sample.servers opennap.spec \
2020
getopt.c mkpass.dsp sample.channels \
21-
napchk logchk setup.dsp
21+
napchk logchk setup.dsp opennap.init
2222
INCLUDES=-DSHAREDIR=\"$(pkgdatadir)\"
2323

2424
.PHONY: log

Makefile.in

+37-88
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ MAKEINFO = @MAKEINFO@
6363
PACKAGE = @PACKAGE@
6464
VERSION = @VERSION@
6565

66-
bin_PROGRAMS = opennap metaserver setup #mkpass
66+
sbin_PROGRAMS = opennap metaserver setup #mkpass
6767
opennap_SOURCES = opennap.h main.c add_file.c search.c motd.c hash.h hash.c privmsg.c browse.c debug.c debug.h login.c whois.c free_user.c join.c part.c public.c part_channel.c announce.c kill_user.c remove_connection.c config.c download.c upload_complete.c topic.c muzzle.c level.c client_quit.c server_login.c server_connect.c synch.c util.c md5.c md5.h hotlist.c remove_file.c list_channels.c list_users.c ping.c resume.c change.c ban.c network.c buffer.c server_usage.c server_links.c init.c handler.c timer.c list.c list.h userdb.c serverlib.c kick.c usermode.c channel.c glob.c redirect.c
6868

6969
#mkpass_SOURCES=mkpass.c md5.c debug.c util.c
7070
metaserver_SOURCES = metaserver.c
7171
setup_SOURCES = setup.c
72-
EXTRA_DIST = sample.conf sample.motd napster.txt .indent.pro FAQ patchnap.c spyserv.c opennap.dsw opennap.dsp opennap.opt sample.users sample.servers opennap.spec getopt.c mkpass.dsp sample.channels napchk logchk setup.dsp
72+
EXTRA_DIST = sample.conf sample.motd napster.txt .indent.pro FAQ patchnap.c spyserv.c opennap.dsw opennap.dsp opennap.opt sample.users sample.servers opennap.spec getopt.c mkpass.dsp sample.channels napchk logchk setup.dsp opennap.init
7373

7474
INCLUDES = -DSHAREDIR=\"$(pkgdatadir)\"
7575
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
7676
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
7777
CONFIG_CLEAN_FILES =
78-
PROGRAMS = $(bin_PROGRAMS)
78+
PROGRAMS = $(sbin_PROGRAMS)
7979

8080

8181
DEFS = @DEFS@ -I. -I$(srcdir)
@@ -115,31 +115,16 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
115115

116116
TAR = gtar
117117
GZIP_ENV = --best
118-
DEP_FILES = .deps/add_file.P .deps/announce.P .deps/ban.P \
119-
.deps/browse.P .deps/buffer.P .deps/change.P .deps/channel.P \
120-
.deps/client_quit.P .deps/config.P .deps/debug.P .deps/download.P \
121-
.deps/free_user.P .deps/glob.P .deps/handler.P .deps/hash.P \
122-
.deps/hotlist.P .deps/init.P .deps/join.P .deps/kick.P \
123-
.deps/kill_user.P .deps/level.P .deps/list.P .deps/list_channels.P \
124-
.deps/list_users.P .deps/login.P .deps/main.P .deps/md5.P \
125-
.deps/metaserver.P .deps/motd.P .deps/muzzle.P .deps/network.P \
126-
.deps/part.P .deps/part_channel.P .deps/ping.P .deps/privmsg.P \
127-
.deps/public.P .deps/redirect.P .deps/remove_connection.P \
128-
.deps/remove_file.P .deps/resume.P .deps/search.P \
129-
.deps/server_connect.P .deps/server_links.P .deps/server_login.P \
130-
.deps/server_usage.P .deps/serverlib.P .deps/setup.P .deps/synch.P \
131-
.deps/timer.P .deps/topic.P .deps/upload_complete.P .deps/userdb.P \
132-
.deps/usermode.P .deps/util.P .deps/whois.P
133118
SOURCES = $(opennap_SOURCES) $(metaserver_SOURCES) $(setup_SOURCES)
134119
OBJECTS = $(opennap_OBJECTS) $(metaserver_OBJECTS) $(setup_OBJECTS)
135120

136121
all: all-redirect
137122
.SUFFIXES:
138123
.SUFFIXES: .S .c .o .s
139124
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
140-
cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile
125+
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps Makefile
141126

142-
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
127+
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
143128
cd $(top_builddir) \
144129
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
145130

@@ -151,31 +136,34 @@ config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
151136
$(srcdir)/configure: @MAINTAINER_MODE_TRUE@$(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
152137
cd $(srcdir) && $(AUTOCONF)
153138

154-
mostlyclean-binPROGRAMS:
139+
mostlyclean-sbinPROGRAMS:
155140

156-
clean-binPROGRAMS:
157-
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
141+
clean-sbinPROGRAMS:
142+
-test -z "$(sbin_PROGRAMS)" || rm -f $(sbin_PROGRAMS)
158143

159-
distclean-binPROGRAMS:
144+
distclean-sbinPROGRAMS:
160145

161-
maintainer-clean-binPROGRAMS:
146+
maintainer-clean-sbinPROGRAMS:
162147

163-
install-binPROGRAMS: $(bin_PROGRAMS)
148+
install-sbinPROGRAMS: $(sbin_PROGRAMS)
164149
@$(NORMAL_INSTALL)
165-
$(mkinstalldirs) $(DESTDIR)$(bindir)
166-
@list='$(bin_PROGRAMS)'; for p in $$list; do \
150+
$(mkinstalldirs) $(DESTDIR)$(sbindir)
151+
@list='$(sbin_PROGRAMS)'; for p in $$list; do \
167152
if test -f $$p; then \
168-
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
169-
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
153+
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
154+
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
170155
else :; fi; \
171156
done
172157

173-
uninstall-binPROGRAMS:
158+
uninstall-sbinPROGRAMS:
174159
@$(NORMAL_UNINSTALL)
175-
list='$(bin_PROGRAMS)'; for p in $$list; do \
176-
rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
160+
list='$(sbin_PROGRAMS)'; for p in $$list; do \
161+
rm -f $(DESTDIR)$(sbindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
177162
done
178163

164+
.c.o:
165+
$(COMPILE) -c $<
166+
179167
.s.o:
180168
$(COMPILE) -c $<
181169

@@ -271,11 +259,6 @@ distdir: $(DISTFILES)
271259
-rm -rf $(distdir)
272260
mkdir $(distdir)
273261
-chmod 777 $(distdir)
274-
here=`cd $(top_builddir) && pwd`; \
275-
top_distdir=`cd $(distdir) && pwd`; \
276-
distdir=`cd $(distdir) && pwd`; \
277-
cd $(top_srcdir) \
278-
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu Makefile
279262
@for file in $(DISTFILES); do \
280263
d=$(srcdir); \
281264
if test -d $$d/$$file; then \
@@ -286,38 +269,6 @@ distdir: $(DISTFILES)
286269
|| cp -p $$d/$$file $(distdir)/$$file || :; \
287270
fi; \
288271
done
289-
290-
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
291-
292-
-include $(DEP_FILES)
293-
294-
mostlyclean-depend:
295-
296-
clean-depend:
297-
298-
distclean-depend:
299-
-rm -rf .deps
300-
301-
maintainer-clean-depend:
302-
303-
%.o: %.c
304-
@echo '$(COMPILE) -c $<'; \
305-
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
306-
@-cp .deps/$(*F).pp .deps/$(*F).P; \
307-
tr ' ' '\012' < .deps/$(*F).pp \
308-
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
309-
>> .deps/$(*F).P; \
310-
rm .deps/$(*F).pp
311-
312-
%.lo: %.c
313-
@echo '$(LTCOMPILE) -c $<'; \
314-
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
315-
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
316-
< .deps/$(*F).pp > .deps/$(*F).P; \
317-
tr ' ' '\012' < .deps/$(*F).pp \
318-
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
319-
>> .deps/$(*F).P; \
320-
rm -f .deps/$(*F).pp
321272
info-am:
322273
info: info-am
323274
dvi-am:
@@ -326,7 +277,7 @@ check-am: all-am
326277
check: check-am
327278
installcheck-am:
328279
installcheck: installcheck-am
329-
install-exec-am: install-binPROGRAMS
280+
install-exec-am: install-sbinPROGRAMS
330281
install-exec: install-exec-am
331282

332283
install-data-am:
@@ -335,14 +286,14 @@ install-data: install-data-am
335286
install-am: all-am
336287
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
337288
install: install-am
338-
uninstall-am: uninstall-binPROGRAMS
289+
uninstall-am: uninstall-sbinPROGRAMS
339290
uninstall: uninstall-am
340291
all-am: Makefile $(PROGRAMS)
341292
all-redirect: all-am
342293
install-strip:
343294
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
344295
installdirs:
345-
$(mkinstalldirs) $(DESTDIR)$(bindir)
296+
$(mkinstalldirs) $(DESTDIR)$(sbindir)
346297

347298

348299
mostlyclean-generic:
@@ -354,38 +305,36 @@ distclean-generic:
354305
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
355306

356307
maintainer-clean-generic:
357-
mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \
358-
mostlyclean-tags mostlyclean-depend mostlyclean-generic
308+
mostlyclean-am: mostlyclean-sbinPROGRAMS mostlyclean-compile \
309+
mostlyclean-tags mostlyclean-generic
359310

360311
mostlyclean: mostlyclean-am
361312

362-
clean-am: clean-binPROGRAMS clean-compile clean-tags clean-depend \
363-
clean-generic mostlyclean-am
313+
clean-am: clean-sbinPROGRAMS clean-compile clean-tags clean-generic \
314+
mostlyclean-am
364315

365316
clean: clean-am
366317

367-
distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \
368-
distclean-depend distclean-generic clean-am
318+
distclean-am: distclean-sbinPROGRAMS distclean-compile distclean-tags \
319+
distclean-generic clean-am
369320

370321
distclean: distclean-am
371322
-rm -f config.status
372323

373-
maintainer-clean-am: maintainer-clean-binPROGRAMS \
324+
maintainer-clean-am: maintainer-clean-sbinPROGRAMS \
374325
maintainer-clean-compile maintainer-clean-tags \
375-
maintainer-clean-depend maintainer-clean-generic \
376-
distclean-am
326+
maintainer-clean-generic distclean-am
377327
@echo "This command is intended for maintainers to use;"
378328
@echo "it deletes files that may require special tools to rebuild."
379329

380330
maintainer-clean: maintainer-clean-am
381331
-rm -f config.status
382332

383-
.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
384-
maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
385-
mostlyclean-compile distclean-compile clean-compile \
386-
maintainer-clean-compile tags mostlyclean-tags distclean-tags \
387-
clean-tags maintainer-clean-tags distdir mostlyclean-depend \
388-
distclean-depend clean-depend maintainer-clean-depend info-am info \
333+
.PHONY: mostlyclean-sbinPROGRAMS distclean-sbinPROGRAMS \
334+
clean-sbinPROGRAMS maintainer-clean-sbinPROGRAMS uninstall-sbinPROGRAMS \
335+
install-sbinPROGRAMS mostlyclean-compile distclean-compile \
336+
clean-compile maintainer-clean-compile tags mostlyclean-tags \
337+
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
389338
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
390339
install-exec install-data-am install-data install-am install \
391340
uninstall-am uninstall all-redirect all-am all installdirs \

NEWS

+10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ searches will be considered valid before timing out.
1919
Added new config variable `stats_port' to make the port 8889 stats
2020
configurable since napigator now supports alternate ports.
2121

22+
Added support for `tcp_wrappers' to control access to the server.
23+
24+
Added opennap.init sample file for SysV-style init scripts
25+
[Geoffrey Lee <[email protected]>]
26+
27+
Programs are now installed in /usr/local/sbin by default.
28+
29+
If `stats_port' is set to -1 in the config file, opennap will not listen
30+
for stats reporting (by default it listens on port 8889).
31+
2232
[opennap 0.35]
2333

2434
added `max_clones' configuration variable to control how many clients may

browse.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ dirname (char *d, int dsize, /* const */ char *s)
154154
}
155155

156156
static char *
157-
basename (char *d, int dsize, /* const */ char *s)
157+
my_basename (char *d, int dsize, /* const */ char *s)
158158
{
159159
s = last_slash (s);
160160
strncpy (d, s + 1, dsize - 1);
@@ -216,7 +216,7 @@ HANDLER (browse_new)
216216
DATUM *d = tmpList->data;
217217

218218
dirname (path, sizeof (path), d->filename);
219-
basename (base, sizeof (base), d->filename);
219+
my_basename (base, sizeof (base), d->filename);
220220
if (count < 5 && dir[0] && !strcasecmp (dir, path))
221221
{
222222
/* same directory as previous result, append */

configure

+50-3
Original file line numberDiff line numberDiff line change
@@ -1634,15 +1634,62 @@ else
16341634
echo "$ac_t""no" 1>&6
16351635
fi
16361636

1637+
echo $ac_n "checking for request_init in -lwrap""... $ac_c" 1>&6
1638+
echo "configure:1639: checking for request_init in -lwrap" >&5
1639+
ac_lib_var=`echo wrap'_'request_init | sed 'y%./+-%__p_%'`
1640+
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
1641+
echo $ac_n "(cached) $ac_c" 1>&6
1642+
else
1643+
ac_save_LIBS="$LIBS"
1644+
LIBS="-lwrap $LIBS"
1645+
cat > conftest.$ac_ext <<EOF
1646+
#line 1647 "configure"
1647+
#include "confdefs.h"
1648+
/* Override any gcc2 internal prototype to avoid an error. */
1649+
/* We use char because int might match the return type of a gcc2
1650+
builtin and then its argument prototype would still apply. */
1651+
char request_init();
1652+
1653+
int main() {
1654+
request_init()
1655+
; return 0; }
1656+
EOF
1657+
if { (eval echo configure:1658: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
1658+
rm -rf conftest*
1659+
eval "ac_cv_lib_$ac_lib_var=yes"
1660+
else
1661+
echo "configure: failed program was:" >&5
1662+
cat conftest.$ac_ext >&5
1663+
rm -rf conftest*
1664+
eval "ac_cv_lib_$ac_lib_var=no"
1665+
fi
1666+
rm -f conftest*
1667+
LIBS="$ac_save_LIBS"
1668+
1669+
fi
1670+
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
1671+
echo "$ac_t""yes" 1>&6
1672+
ac_tr_lib=HAVE_LIB`echo wrap | sed -e 's/[^a-zA-Z0-9_]/_/g' \
1673+
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
1674+
cat >> confdefs.h <<EOF
1675+
#define $ac_tr_lib 1
1676+
EOF
1677+
1678+
LIBS="-lwrap $LIBS"
1679+
1680+
else
1681+
echo "$ac_t""no" 1>&6
1682+
fi
1683+
16371684
for ac_func in mlockall
16381685
do
16391686
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
1640-
echo "configure:1641: checking for $ac_func" >&5
1687+
echo "configure:1688: checking for $ac_func" >&5
16411688
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
16421689
echo $ac_n "(cached) $ac_c" 1>&6
16431690
else
16441691
cat > conftest.$ac_ext <<EOF
1645-
#line 1646 "configure"
1692+
#line 1693 "configure"
16461693
#include "confdefs.h"
16471694
/* System header to define __stub macros and hopefully few prototypes,
16481695
which can conflict with char $ac_func(); below. */
@@ -1665,7 +1712,7 @@ $ac_func();
16651712
16661713
; return 0; }
16671714
EOF
1668-
if { (eval echo configure:1669: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
1715+
if { (eval echo configure:1716: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
16691716
rm -rf conftest*
16701717
eval "ac_cv_func_$ac_func=yes"
16711718
else

configure.in

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fi
2424
AC_CHECK_LIB(xnet,gethostbyname)
2525
AC_CHECK_LIB(nsl,socket)
2626
AC_CHECK_LIB(socket,gethostbyname)
27+
AC_CHECK_LIB(wrap,request_init)
2728
AC_CHECK_FUNCS(mlockall)
2829

2930
ac_cv_warnings=yes

handler.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,13 @@ handle_connection (CONNECTION * con)
458458
*(con->recvbuf->data + con->recvbuf->consumed + 4 + len) = 0;
459459
log ("handle_connection(): tag=%hu, len=%hu, data=%s", tag, len,
460460
con->recvbuf->data + con->recvbuf->consumed + 4);
461-
send_cmd (con, MSG_SERVER_ERROR, "Unknown command code %hu", tag);
462-
con->destroy = 1;
461+
462+
/* not sure why the official servers do this, but lets
463+
* be compatible.
464+
*/
465+
send_cmd (con, MSG_SERVER_ECHO, "%hu: %s", tag,
466+
con->recvbuf->data + con->recvbuf->consumed + 4);
467+
463468
return;
464469
}
465470
if (Servers && ISUSER (con))

join.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ HANDLER (join)
110110
if (!chan)
111111
{
112112
/* check if this server allows normals to create channels */
113-
if (Server_Flags & ON_STRICT_CHANNELS)
113+
if ((Server_Flags & ON_STRICT_CHANNELS) &&
114+
user->level < LEVEL_MODERATOR)
114115
{
115116
permission_denied (con);
116117
return;

0 commit comments

Comments
 (0)