Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!pacbell.com!ames!mindcraft.com!karish From: karish@mindcraft.com (Chuck Karish) Newsgroups: news.software.b Subject: Re: (C News) limit filesize and inews Message-ID: <663302894.24807@mindcraft.com> Date: 8 Jan 91 02:48:13 GMT References: <1991Jan6.073729.21354@zoo.toronto.edu> <3464@gazette.bcm.tmc.edu> <1991Jan7.182907.13583@zoo.toronto.edu> <3480@gazette.bcm.tmc.edu> Organization: Mindcraft, Inc. Lines: 51 In article <3480@gazette.bcm.tmc.edu> sob@tmc.edu (Stan Barber) writes: >Okey, WHAT IS THE SOLUTION THEN? First, to restrain our petulence just a little. >Just for fun, let's eliminate the "Get the OS fixed" answer. That's the only real answer. Workaround follows. "Get the OS fixed" isn't even enough. Per-user limits management is done in different ways on different systems, because the standards don't specify the behavior. The choices are to (a) make c-news look like c-kermit inside, or (b) to use a workaround until vendors converge on a reasonable way of specifying the limit. >For even more fun, let's eliminate "change the system wide parameters" >answer, too. Okay. >Now, what's the answer? For SysV-based systems: Call relaynews and expire from a wrapper that runs with root's effective UID, uses ulimit() to set a usable file size, does setuid() and setgid() to the news user's ID, values, and execs its argument. #define NEWSUID 55 #define NEWSGID 56 #define FILESIZE 204800 /* 512-byte blocks; this is 1 GB */ main(argc, argv) int argc; char **argv; { if(argc < 2) exit(1); ++ argv; if((ulimit(2, FILESIZE) >= 0) && (setgid(NEWSGID) == 0) && (setuid(NEWSUID) == 0)) exit(execvp(*argv, argv)); else exit(1); } -- Chuck Karish karish@mindcraft.com Mindcraft, Inc. (415) 323-9000