[1436] in linux-security and linux-alert archive

home help back first fref pref prev next nref lref last post

[linux-security] Re: dos-attack on inetd.

daemon@ATHENA.MIT.EDU (Mike Jagdis)
Wed Feb 5 12:03:09 1997

Date: Wed, 5 Feb 1997 15:00:42 +0000 (GMT/BST)
From: Mike Jagdis <mike@roan.co.uk>
To: "Alexander O. Yuriev" <alex@bach.cis.temple.edu>
cc: linux-security@redhat.com
In-Reply-To: <199701200007.TAA09435@bach.cis.temple.edu>
Resent-From: linux-security@redhat.com
Reply-To: linux-security@redhat.com

On Sun, 19 Jan 1997, Alexander O. Yuriev wrote:

> > Uh no... Now you mention it it's one of those little patches that
> > I never quite get round to sending anywhere (in spite of the
> > ridulous length of time I've had it :-) ). I guess I should do
> > all the "MUST NOT" crash daemons really. Restarting things is
> > _exactly_ what inittab is for - init even knows to back off if
> > something has to be restarted too often.
> 
> Sorry took so long. Feel like making that quick patch publically available
> so we cab close this inetd discussion?

Yeah, it's mailbox clearing time again :-).

This one is against inet.c from the linux NetKit-0.09. It adds a -D
option to prevent inetd from self-daemonizing so you can just add
"inetd -D" as a respawn job in /etc/inittab (and stop it starting
elsewhere as well of course!). This one isn't actually tested either.

  (Of course, if you hammer inetd into the ground init will disable
it for about 5 minutes so starvation attacks are possible but
not quite so completely fatal.)

				Mike

[mod: Isn't the "-d" flag already there, and does exactly what we'd want
here? Are there more references to the "debug" or options variables? --REW]

--- inetd.c.old	Wed Feb  5 14:41:22 1997
+++ inetd.c	Wed Feb  5 14:46:19 1997
@@ -320,7 +320,7 @@
 	struct group *grp = NULL;
 	int tmpint;
 	struct sigaction sa;
-	int ch, pid, dofork;
+	int ch, pid, dofork, nodaemon = 0;
 	char buf[50];
 
 	Argv = argv;
@@ -333,8 +333,11 @@
 	progname = strrchr(argv[0], '/');
 	progname = progname ? progname + 1 : argv[0];
 
-	while ((ch = getopt(argc, argv, "dq:")) != EOF)
+	while ((ch = getopt(argc, argv, "Ddq:")) != EOF)
 		switch(ch) {
+		case 'D':
+			nodaemon = 1;
+			break;
 		case 'd':
 			debug = 1;
 			options |= SO_DEBUG;
@@ -355,7 +358,7 @@
 	if (argc > 0)
 		CONFIG = argv[0];
 
-	if (debug == 0)
+	if (debug == 0 && !nodaemon)
 		daemon(0, 0);
 	openlog(progname, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
 	logpid();


-- 
.----------------------------------------------------------------------.
|  Mike Jagdis                  |  Internet:  mailto:mike@roan.co.uk   |
|  Roan Technology Ltd.         |                                      |
|  54A Peach Street, Wokingham  |  Telephone:  +44 118 989 0403        |
|  RG40 1XG, ENGLAND            |  Fax:        +44 118 989 1195        |
`----------------------------------------------------------------------'


home help back first fref pref prev next nref lref last post