From owner-freebsd-ports Mon Sep 6 14:20:14 1999 Delivered-To: freebsd-ports@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id ECFC0159C9 for ; Mon, 6 Sep 1999 14:20:00 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id OAA73289; Mon, 6 Sep 1999 14:20:00 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from backup.af.speednet.com.au (af.speednet.com.au [202.135.206.244]) by hub.freebsd.org (Postfix) with ESMTP id BC30B154F0; Mon, 6 Sep 1999 14:13:57 -0700 (PDT) (envelope-from andyf@speednet.com.au) Received: from localhost (localhost [127.0.0.1]) by backup.af.speednet.com.au (8.9.3/8.9.3) with ESMTP id HAA15921; Tue, 7 Sep 1999 07:13:12 +1000 (EST) (envelope-from andyf@speednet.com.au) Message-Id: Date: Tue, 7 Sep 1999 07:13:11 +1000 (EST) From: Andy Farkas To: FreeBSD-gnats-submit@freebsd.org Cc: ache@freebsd.org Subject: ports/13606: Apache's suEXEC wrapper doesn't enforce user limits Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 13606 >Category: ports >Synopsis: Apache's suEXEC wrapper doesn't enforce user limits >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Sep 6 14:20:00 PDT 1999 >Closed-Date: >Last-Modified: >Originator: Andy Farkas >Release: FreeBSD 3.2-STABLE i386 >Organization: Speednet Communications Pty Ltd >Environment: Apache-1.3.9 on FreeBSD 3.2-STABLE >Description: Apache's suEXEC wrapper doesn't enforce user limits. Users may exhaust various system resources, even though resource limits have been properly set. >How-To-Repeat: Enable the suEXEC wrapper for user CGI scripts and expect the system to be 'more stable'. Weep as the system grounds to a halt when user 'bob' uploads his "for(;;)" code and tells his mates to "click here as many times as you can!". Note that user bob has maxproc set to 2 and cputime to 60 secs. >Fix: This patch is for Apache-1.3.9: --- suexec.c.orig Tue Jun 22 10:51:41 1999 +++ suexec.c Mon Sep 6 21:47:33 1999 @@ -75,6 +75,7 @@ #include #include #include +#include #include @@ -250,6 +251,7 @@ char *cmd; /* command to be executed */ char cwd[AP_MAXPATH]; /* current working directory */ char dwd[AP_MAXPATH]; /* docroot working directory */ + login_cap_t *lc; /* user resource limits */ struct passwd *pw; /* password entry holder */ struct group *gr; /* group entry holder */ struct stat dir_info; /* directory info holder */ @@ -401,6 +403,19 @@ if ((gid == 0) || (gid < GID_MIN)) { log_err("cannot run as forbidden gid (%d/%s)\n", gid, cmd); exit(108); + } + + /* + * Apply user resource limits based on login class. + */ + if ((lc = login_getclassbyname(pw->pw_class, pw)) == NULL) { + log_err("failed to login_getclassbyname()\n"); + exit(109); + } + + if ((setusercontext(lc, pw, uid, LOGIN_SETRESOURCES)) != 0) { + log_err("failed to setusercontext()\n"); + exit(109); } /* >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message