Upgrade CVS to 0.33.18 current

This commit is contained in:
Michiel Broek
2001-08-25 19:53:11 +00:00
parent 2ff822f657
commit e90745a139
111 changed files with 3126 additions and 3121 deletions

View File

@@ -11,13 +11,13 @@ taskcomm.c taskcomm.h taskstat.c taskstat.h taskdisk.c taskdisk.h \
taskregs.c taskregs.h taskinfo.c taskinfo.h outstat.c outstat.h \
scanout.c scanout.h nodelist.c nodelist.h callstat.c callstat.h libs.h
LDADD = ../lib/libmemwatch.a
# LDADD = ../lib/libmemwatch.a
install-exec-local:
@if [ "$(shell whoami)" != "root" ] ; then \
@if [ "`id -un`" != "root" ] ; then \
echo; echo " Must be root to install!"; echo; exit 3; \
fi
$(INSTALL) -s -o root -g root -m 6711 mbtask $(bindir)
$(INSTALL) -s -o `id -un` -g `id -gn` -m 6711 mbtask $(bindir)
@if [ -f $(sysconfdir)/mbsed.conf ]; then \
rm $(sysconfdir)/mbsed.conf ; \
fi

View File

@@ -59,6 +59,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
AWK = @AWK@
CC = @CC@
CHOWN = @CHOWN@
COMPRESS = @COMPRESS@
GROUP = @GROUP@
GZIP = @GZIP@
@@ -70,7 +71,6 @@ OWNER = @OWNER@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
VERSION = @VERSION@
YACC = @YACC@
SUBDIRS = .
@@ -80,8 +80,6 @@ noinst_PROGRAMS = mbtask
mbtask_SOURCES = mbtask.c mbtask.h signame.c signame.h taskutil.c taskutil.h taskcomm.c taskcomm.h taskstat.c taskstat.h taskdisk.c taskdisk.h taskregs.c taskregs.h taskinfo.c taskinfo.h outstat.c outstat.h scanout.c scanout.h nodelist.c nodelist.h callstat.c callstat.h libs.h
LDADD = ../lib/libmemwatch.a
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES =
@@ -96,7 +94,7 @@ mbtask_OBJECTS = mbtask.o signame.o taskutil.o taskcomm.o taskstat.o \
taskdisk.o taskregs.o taskinfo.o outstat.o scanout.o nodelist.o \
callstat.o
mbtask_LDADD = $(LDADD)
mbtask_DEPENDENCIES = ../lib/libmemwatch.a
mbtask_DEPENDENCIES =
mbtask_LDFLAGS =
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -109,6 +107,10 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
DEP_FILES = .deps/callstat.P .deps/mbtask.P .deps/nodelist.P \
.deps/outstat.P .deps/scanout.P .deps/signame.P .deps/taskcomm.P \
.deps/taskdisk.P .deps/taskinfo.P .deps/taskregs.P .deps/taskstat.P \
.deps/taskutil.P
SOURCES = $(mbtask_SOURCES)
OBJECTS = $(mbtask_OBJECTS)
@@ -116,9 +118,9 @@ all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .o .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps mbtask/Makefile
cd $(top_srcdir) && $(AUTOMAKE) --gnu mbtask/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
@@ -132,9 +134,6 @@ distclean-noinstPROGRAMS:
maintainer-clean-noinstPROGRAMS:
.c.o:
$(COMPILE) -c $<
.s.o:
$(COMPILE) -c $<
@@ -249,6 +248,11 @@ distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
subdir = mbtask
distdir: $(DISTFILES)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(top_distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu mbtask/Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
if test -d $$d/$$file; then \
@@ -269,32 +273,38 @@ distdir: $(DISTFILES)
|| exit 1; \
fi; \
done
callstat.o: callstat.c libs.h ../config.h ../lib/memwatch.h \
../lib/structs.h taskutil.h callstat.h
mbtask.o: mbtask.c libs.h ../config.h ../lib/memwatch.h ../lib/structs.h \
signame.h taskstat.h taskutil.h taskregs.h taskcomm.h outstat.h \
nodelist.h mbtask.h
nodelist.o: nodelist.c libs.h ../config.h ../lib/memwatch.h \
../lib/structs.h taskutil.h nodelist.h
outstat.o: outstat.c libs.h ../config.h ../lib/memwatch.h \
../lib/structs.h taskutil.h scanout.h nodelist.h callstat.h \
outstat.h
scanout.o: scanout.c libs.h ../config.h ../lib/memwatch.h \
../lib/structs.h taskutil.h scanout.h
signame.o: signame.c signame.h
taskcomm.o: taskcomm.c libs.h ../config.h ../lib/memwatch.h taskstat.h \
taskregs.h taskdisk.h taskinfo.h taskutil.h taskcomm.h
taskdisk.o: taskdisk.c libs.h ../config.h ../lib/memwatch.h taskdisk.h \
taskutil.h
taskinfo.o: taskinfo.c libs.h ../config.h ../lib/memwatch.h \
../lib/structs.h taskinfo.h
taskregs.o: taskregs.c libs.h ../config.h ../lib/memwatch.h taskstat.h \
taskregs.h taskutil.h
taskstat.o: taskstat.c libs.h ../config.h ../lib/memwatch.h \
../lib/structs.h taskstat.h outstat.h taskutil.h
taskutil.o: taskutil.c libs.h ../config.h ../lib/memwatch.h \
../lib/structs.h signame.h scanout.h taskutil.h
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
-include $(DEP_FILES)
mostlyclean-depend:
clean-depend:
distclean-depend:
-rm -rf .deps
maintainer-clean-depend:
%.o: %.c
@echo '$(COMPILE) -c $<'; \
$(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-cp .deps/$(*F).pp .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm .deps/$(*F).pp
%.lo: %.c
@echo '$(LTCOMPILE) -c $<'; \
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $<
@-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \
< .deps/$(*F).pp > .deps/$(*F).P; \
tr ' ' '\012' < .deps/$(*F).pp \
| sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
>> .deps/$(*F).P; \
rm -f .deps/$(*F).pp
info-am:
info: info-recursive
dvi-am:
@@ -332,23 +342,24 @@ distclean-generic:
maintainer-clean-generic:
mostlyclean-am: mostlyclean-noinstPROGRAMS mostlyclean-compile \
mostlyclean-tags mostlyclean-generic
mostlyclean-tags mostlyclean-depend mostlyclean-generic
mostlyclean: mostlyclean-recursive
clean-am: clean-noinstPROGRAMS clean-compile clean-tags clean-generic \
mostlyclean-am
clean-am: clean-noinstPROGRAMS clean-compile clean-tags clean-depend \
clean-generic mostlyclean-am
clean: clean-recursive
distclean-am: distclean-noinstPROGRAMS distclean-compile distclean-tags \
distclean-generic clean-am
distclean-depend distclean-generic clean-am
distclean: distclean-recursive
maintainer-clean-am: maintainer-clean-noinstPROGRAMS \
maintainer-clean-compile maintainer-clean-tags \
maintainer-clean-generic distclean-am
maintainer-clean-depend maintainer-clean-generic \
distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
@@ -363,20 +374,23 @@ uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \
all-recursive check-recursive installcheck-recursive info-recursive \
dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \
maintainer-clean-recursive tags tags-recursive mostlyclean-tags \
distclean-tags clean-tags maintainer-clean-tags distdir info-am info \
dvi-am dvi check check-am installcheck-am installcheck \
install-exec-local install-exec-am install-exec install-data-am \
install-data install-am install uninstall-am uninstall all-redirect \
all-am all installdirs-am installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean
distclean-tags clean-tags maintainer-clean-tags distdir \
mostlyclean-depend distclean-depend clean-depend \
maintainer-clean-depend info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-local install-exec-am \
install-exec install-data-am install-data install-am install \
uninstall-am uninstall all-redirect all-am all installdirs-am \
installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# LDADD = ../lib/libmemwatch.a
install-exec-local:
@if [ "$(shell whoami)" != "root" ] ; then \
@if [ "`id -un`" != "root" ] ; then \
echo; echo " Must be root to install!"; echo; exit 3; \
fi
$(INSTALL) -s -o root -g root -m 6711 mbtask $(bindir)
$(INSTALL) -s -o `id -un` -g `id -gn` -m 6711 mbtask $(bindir)
@if [ -f $(sysconfdir)/mbsed.conf ]; then \
rm $(sysconfdir)/mbsed.conf ; \
fi

View File

@@ -2,7 +2,7 @@
*
* File ..................: libs.h
* Purpose ...............: Libraries include list
* Last modification date : 05-jul-2001
* Last modification date : 11-Aug-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -60,16 +60,22 @@
#include <stdarg.h>
#include <netdb.h>
#include <arpa/inet.h>
#ifdef HAVE_SYS_VFS_H
#include <sys/vfs.h>
#include <wait.h>
#endif
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/wait.h>
#include <pwd.h>
#include <stddef.h>
#include <fcntl.h>
#ifdef __FreeBSD__
#include <netinet/in_systm.h>
#endif
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include "../lib/memwatch.h"
/*
@@ -94,11 +100,15 @@ struct icmp_filter {
/* Ancillary data object manipulation macros. */
/*
# if !defined __STRICT_ANSI__ && defined __GNUC__ && __GNUC__ >= 2
# define CMSG_DATA(cmsg) ((cmsg)->__cmsg_data)
# else
# define CMSG_DATA(cmsg) ((unsigned char *) ((struct cmsghdr *) (cmsg) + 1))
# endif
*/
/*
# define CMSG_NXTHDR(mhdr, cmsg) __cmsg_nxthdr (mhdr, cmsg)
# define CMSG_FIRSTHDR(mhdr) \
((size_t) (mhdr)->msg_controllen >= sizeof (struct cmsghdr) \
@@ -118,20 +128,21 @@ _EXTERN_INLINE struct cmsghdr *
__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg) __THROW
{
if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
/* The kernel header does this so there may be a reason. */
*/ /* The kernel header does this so there may be a reason. */ /*
return 0;
*/
/*
__cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
+ CMSG_ALIGN (__cmsg->cmsg_len));
if ((unsigned char *) (__cmsg + 1) >= ((unsigned char *) __mhdr->msg_control
+ __mhdr->msg_controllen)
|| ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)
>= ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
/* No more entries. */
*/ /* No more entries. */ /*
return 0;
return __cmsg;
}
# endif /* Use `extern inline'. */
# endif */ /* Use `extern inline'. */
# endif

View File

@@ -2,7 +2,7 @@
*
* File ..................: mbtask/mbtask.c
* Purpose ...............: MBSE BBS Task Manager
* Last modification date : 09-Jul-2001
* Last modification date : 13-Aug-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -126,10 +126,12 @@ void load_maincfg(void)
#ifdef __USE_GNU
sprintf(CFG.sysdomain, "%s.%s", un.nodename, un.domainname);
#else
#ifdef __linux__
sprintf(CFG.sysdomain, "%s.%s", un.nodename, un.__domainname);
#endif
sprintf(CFG.comment, "MBSE Linux BBS development");
sprintf(CFG.origin, "MBSE Linux BBS. Made in the Netherlands");
#endif
sprintf(CFG.comment, "MBSE BBS development");
sprintf(CFG.origin, "MBSE BBS. Made in the Netherlands");
sprintf(CFG.location, "Earth");
/*
@@ -391,9 +393,6 @@ void load_maincfg(void)
if ((fp = fopen(cfgfn, "a+")) == NULL) {
perror("");
fprintf(stderr, "Can't create %s\n", cfgfn);
#ifdef MEMWATCH
mwTerm();
#endif
exit(2);
}
fwrite(&CFG, sizeof(CFG), 1, fp);
@@ -491,33 +490,21 @@ pid_t launch(char *cmd, char *opts, char *name, int tasktype)
close(0);
if (open("/dev/null", O_RDONLY) != 0) {
tasklog('?', "$Launch: \"%s\": reopen of stdin to /dev/null failed", buf);
#ifdef MEMWATCH
mwTerm();
#endif
_exit(-1);
}
close(1);
if (open("/dev/null", O_WRONLY | O_APPEND | O_CREAT,0600) != 1) {
tasklog('?', "$Launch: \"%s\": reopen of stdout to /dev/null failed", buf);
#ifdef MEMWATCH
mwTerm();
#endif
_exit(-1);
}
close(2);
if (open("/dev/null", O_WRONLY | O_APPEND | O_CREAT,0600) != 2) {
tasklog('?', "$Launch: \"%s\": reopen of stderr to /dev/null failed", buf);
#ifdef MEMWATCH
mwTerm();
#endif
_exit(-1);
}
errno = 0;
rc = execv(vector[0],vector);
tasklog('?', "$Launch: execv \"%s\" failed, returned %d", cmd, rc);
#ifdef MEMWATCH
mwTerm();
#endif
_exit(-1);
default:
/* grandchild's daddy's process */
@@ -697,9 +684,6 @@ void die(int onsig)
unlink(spath);
}
tasklog(' ', "MBTASK finished");
#ifdef MEMWATCH
mwTerm();
#endif
exit(onsig);
}
@@ -774,6 +758,37 @@ void ulocktask(void)
}
/* different names, same thing... be careful, as these are macros... */
#ifdef __FreeBSD__
# define icmphdr icmp
# define iphdr ip
# define ip_saddr ip_src.s_addr
# define ip_daddr ip_dst.s_addr
#else
# define ip_saddr saddr
# define ip_daddr daddr
# define ip_hl ihl
# define ip_p protocol
#endif
#ifdef __linux__
# define icmp_type type
# define icmp_code code
# define icmp_cksum checksum
# define icmp_id un.echo.id
# define icmp_seq un.echo.sequence
#endif
#ifdef __FreeBSD__
# define ICMP_DEST_UNREACH ICMP_UNREACH
# define ICMP_TIME_EXCEEDED ICMP_TIMXCEED
#endif
#define ICMP_BASEHDR_LEN 8
#define ICMP4_ECHO_LEN ICMP_BASEHDR_LEN
/*
* Takes a packet as send out and a recieved ICMP packet and looks whether the ICMP packet is
@@ -794,14 +809,14 @@ static int icmp4_errcmp(char *packet, int plen, struct in_addr *to, char *errmsg
if (elen < sizeof(struct iphdr))
return 0;
memcpy(&iph, errmsg, sizeof(iph));
if (iph.protocol != IPPROTO_ICMP || elen < iph.ihl * 4 + ICMP_BASEHDR_LEN + sizeof(eiph))
if (iph.ip_p != IPPROTO_ICMP || elen < iph.ip_hl * 4 + ICMP_BASEHDR_LEN + sizeof(eiph))
return 0;
memcpy(&icmph, errmsg + iph.ihl * 4, ICMP_BASEHDR_LEN);
memcpy(&eiph, errmsg + iph.ihl * 4 + ICMP_BASEHDR_LEN, sizeof(eiph));
if (elen < iph.ihl * 4 + ICMP_BASEHDR_LEN + eiph.ihl * 4 + 8)
memcpy(&icmph, errmsg + iph.ip_hl * 4, ICMP_BASEHDR_LEN);
memcpy(&eiph, errmsg + iph.ip_hl * 4 + ICMP_BASEHDR_LEN, sizeof(eiph));
if (elen < iph.ip_hl * 4 + ICMP_BASEHDR_LEN + eiph.ip_hl * 4 + 8)
return 0;
data = errmsg + iph.ihl * 4 + ICMP_BASEHDR_LEN + eiph.ihl * 4;
return icmph.type == errtype && memcmp(&to->s_addr, &eiph.daddr, sizeof(to->s_addr)) == 0 &&
data = errmsg + iph.ip_hl * 4 + ICMP_BASEHDR_LEN + eiph.ip_hl * 4;
return icmph.icmp_type == errtype && memcmp(&to->s_addr, &eiph.ip_daddr, sizeof(to->s_addr)) == 0 &&
memcmp(data, packet, plen < 8 ?plen:8) == 0;
}
@@ -825,14 +840,28 @@ int ping_send(struct in_addr addr)
{
int len;
int isock;
#ifdef __linux__
struct icmp_filter f;
#else
struct protoent *pe;
int SOL_IP;
#endif
unsigned long sum;
unsigned short *ptr;
#ifndef __linux__
if (!(pe = getprotobyname("ip"))) {
tasklog('?', "icmp ping: getprotobyname() failed: %s", strerror(errno));
return -1;
}
SOL_IP = pe->p_proto;
#endif
isock = ping_isocket;
p_sequence = 1;
id = (unsigned short)get_rand16(); /* randomize a ping id */
#ifdef __linux__
/* Fancy ICMP filering -- only on Linux (as far is I know) */
/* In fact, there should be macros for treating icmp_filter, but I haven't found them in Linux 2.2.15.
@@ -845,12 +874,13 @@ int ping_send(struct in_addr addr)
tasklog('?', "$icmp ping: setsockopt() failed %d", isock);
return -1;
}
#endif
icmpd.type = ICMP_ECHO;
icmpd.code = 0;
icmpd.checksum = 0;
icmpd.un.echo.id = htons((short)id);
icmpd.un.echo.sequence = htons(p_sequence);
icmpd.icmp_type = ICMP_ECHO;
icmpd.icmp_code = 0;
icmpd.icmp_cksum = 0;
icmpd.icmp_id = htons((short)id);
icmpd.icmp_seq = htons(p_sequence);
/* Checksumming - Algorithm taken from nmap. Thanks... */
@@ -862,14 +892,14 @@ int ping_send(struct in_addr addr)
}
sum = (sum >> 16) + (sum & 0xffff);
sum += (sum >> 16);
icmpd.checksum = ~sum;
icmpd.icmp_cksum = ~sum;
memset(&to, 0, sizeof(to));
to.sin_family = AF_INET;
to.sin_port = 0;
to.sin_addr = addr;
SET_SOCKA_LEN4(to);
if (sendto(isock, &icmpd, ICMP_BASEHDR_LEN, 0, (struct sockaddr *)&to, sizeof(to)) == -1) {
if (sendto(isock, &icmpd, ICMP4_ECHO_LEN, 0, (struct sockaddr *)&to, sizeof(to)) == -1) {
if (icmp_errs < ICMP_MAX_ERRS)
tasklog('?', "$icmp ping: sendto()");
return -2;
@@ -908,18 +938,18 @@ int ping_receive(struct in_addr addr)
if ((len = recvfrom(isock, &buf, sizeof(buf), 0,(struct sockaddr *)&ffrom, &sl)) != -1) {
if (len > sizeof(struct iphdr)) {
memcpy(&iph, buf, sizeof(iph));
if (len - iph.ihl * 4 >= ICMP_BASEHDR_LEN) {
memcpy(&icmpp, ((unsigned long int *)buf)+iph.ihl, sizeof(icmpp));
if (iph.saddr == addr.s_addr &&
icmpp.type == ICMP_ECHOREPLY &&
ntohs(icmpp.un.echo.id) == id &&
ntohs(icmpp.un.echo.sequence) <= p_sequence) {
if (len - iph.ip_hl * 4 >= ICMP_BASEHDR_LEN) {
memcpy(&icmpp, ((unsigned long int *)buf)+iph.ip_hl, sizeof(icmpp));
if (iph.ip_saddr == addr.s_addr &&
icmpp.icmp_type == ICMP_ECHOREPLY &&
ntohs(icmpp.icmp_id) == id &&
ntohs(icmpp.icmp_seq) <= p_sequence) {
return 0;
} else {
/* No regular echo reply. Maybe an error? */
if (icmp4_errcmp((char *)&icmpd, ICMP_BASEHDR_LEN,
if (icmp4_errcmp((char *)&icmpd, ICMP4_ECHO_LEN,
&to.sin_addr, buf, len, ICMP_DEST_UNREACH) ||
icmp4_errcmp((char *)&icmpd, ICMP_BASEHDR_LEN,
icmp4_errcmp((char *)&icmpd, ICMP4_ECHO_LEN,
&to.sin_addr, buf, len, ICMP_TIME_EXCEEDED)) {
return -4;
}
@@ -935,6 +965,21 @@ int ping_receive(struct in_addr addr)
/*
* External Semafore Checks
*/
void test_sema(char *);
void test_sema(char *sema)
{
if (IsSema(sema)) {
RemoveSema(sema);
tasklog('s', "Semafore %s detected", sema);
sem_set(sema, TRUE);
}
}
/*
* Check semafore's, system status flags etc. This is called
* each second to test for condition changes.
@@ -969,12 +1014,13 @@ void check_sema(void)
get_zmh();
/*
* Newnews semafore can also be set in the semafore directory.
* Semafore's that still can be detected, usefull for
* external programs that create them.
*/
if (IsSema((char *)"newnews")) {
RemoveSema((char *)"newnews");
s_newnews = TRUE;
}
test_sema((char *)"newnews");
test_sema((char *)"mailout");
test_sema((char *)"mailin");
test_sema((char *)"scanout");
}
@@ -1227,8 +1273,6 @@ void scheduler(void)
if (inet_aton(pingaddress, &paddr)) {
rc = ping_send(paddr);
if (internet)
tasklog('p', "ping send %s id=%d rc=%d", pingaddress, id, rc);
if (rc) {
if (icmp_errs++ < ICMP_MAX_ERRS)
tasklog('?', "ping send %s rc=%d", pingaddress, rc);
@@ -1279,8 +1323,6 @@ void scheduler(void)
if (!rc) {
pingstate = P_OK;
pingresult[pingnr] = TRUE;
if (internet)
tasklog('p', "ping recv %s id=%d rc=%d", pingaddress, id, rc);
} else {
if (rc != -6)
tasklog('p', "ping recv %s id=%d rc=%d", pingaddress, id, rc);
@@ -1306,9 +1348,6 @@ int main(int argc, char **argv)
pid_t frk;
FILE *fp;
#ifdef MEMWATCH
mwInit();
#endif
/*
* Print copyright notices and setup logging.
*/
@@ -1332,9 +1371,6 @@ int main(int argc, char **argv)
if ((ping_isocket = socket(PF_INET, SOCK_RAW, IPPROTO_ICMP)) == -1) {
perror("");
printf("socket init failed, is mbtask not installed setuid root?\n");
#ifdef MEMWATCH
mwTerm();
#endif
exit(1);
}
@@ -1348,27 +1384,18 @@ int main(int argc, char **argv)
perror("");
printf("can't setuid to mbse\n");
close(ping_isocket);
#ifdef MEMWATCH
mwTerm();
#endif
exit(1);
}
if (setgid(pw->pw_gid)) {
perror("");
printf("can't setgid to bbs\n");
close(ping_isocket);
#ifdef MEMWATCH
mwTerm();
#endif
exit(1);
}
umask(007);
if (locktask(pw->pw_dir)) {
close(ping_isocket);
#ifdef MEMWATCH
mwTerm();
#endif
exit(1);
}
@@ -1385,6 +1412,13 @@ int main(int argc, char **argv)
memset(&reginfo, 0, sizeof(reginfo));
sprintf(spath, "%s/tmp/mbtask", getenv("MBSE_ROOT"));
/*
* Now that init is complete and this program is locked, it is
* safe to remove a stale socket if it is there after a crash.
*/
if (!file_exist(spath, R_OK))
unlink(spath);
/*
* Server initialization is complete. Now we can fork the
* daemon and return to the user. We need to do a setpgrp
@@ -1394,8 +1428,8 @@ int main(int argc, char **argv)
* if the child were to open a terminal, it would become
* associated with that terminal as its control terminal.
*/
if ((pgrp = setpgrp()) == -1) {
tasklog('?', "$setpgrp failed");
if ((pgrp = setpgid(0, 0)) == -1) {
tasklog('?', "$setpgid failed");
die(0);
}
@@ -1424,9 +1458,6 @@ int main(int argc, char **argv)
fclose(fp);
}
tasklog('+', "Starting daemon with pid %d", frk);
#ifdef MEMWATCH
mwTerm();
#endif
exit(0);
}

View File

@@ -2,7 +2,7 @@
*
* File ..................: mbtask/taskstat.c
* Purpose ...............: Keep track of server status
* Last modification date : 09-Jul-2001
* Last modification date : 30-Jul-2001
*
*****************************************************************************
* Copyright (C) 1997-2001
@@ -115,9 +115,6 @@ void status_init()
cnt = read(stat_fd, &status, sizeof(status_r));
if (cnt != sizeof(status_r)) {
printf("Error reading status file\n");
#ifdef MEMWATCH
mwTerm();
#endif
exit(1);
}
status.startups++;
@@ -128,9 +125,6 @@ void status_init()
cnt = write(stat_fd, &status, sizeof(status_r));
if (cnt != sizeof(status_r)) {
tasklog('?', "$Error rewrite status file\n");
#ifdef MEMWATCH
mwTerm();
#endif
exit(1);
}
close(stat_fd);