home *** CD-ROM | disk | FTP | other *** search
- Xref: wupost alt.sex.pictures.d:6819 alt.sources:3875
- Path: wupost!uunet!lll-winken!sun-barr!cronkite.Central.Sun.COM!exodus!athena.Eng.Sun.COM!williamt
- From: williamt@athena.Eng.Sun.COM (William Turnbow)
- Newsgroups: alt.sex.pictures.d,alt.sources
- Subject: ftp limit source
- Message-ID: <18815@exodus.Eng.Sun.COM>
- Date: 22 Aug 91 00:00:30 GMT
- Sender: news@exodus.Eng.Sun.COM
- Reply-To: williamt@athena.Eng.sun.com (William Turnbow)
- Followup-To: alt.sex.pictures.d
- Lines: 44
-
-
- Don't know if this is of any use to anyone. It's just something I
- cooked up on short notice and it seems to work, but there is no warrantee
- expressed or implied...etc.
-
- I renamed the ftp demon (in.ftpd) to in.ftpd.2, and put the program
- below in its place. I am running under SunOS 4.1, a BSD variant, so
- your path for wc and args to ps may be different. But the program is
- sufficiently short and simple that it should be easily modifiable.
-
-
- /* ftp limit demon -- limits ftp connections
- * author: William.Turnbow@Sun.COM
- */
-
- #include <stdio.h>
- main(argc,argv)
- int argc; char * argv[];
- {
- int maxusers;
- int nusers;
-
- if (argc>1) maxusers=atoi(argv[1]); /* any errors means 0 users get in */
- else maxusers=1; /* default = 1 here */
- /* get number of ftp demons running:
- ps for all process,
- only look for ftpd (demons),
- filter out the grep that did the looking, and
- do a line count
- */
-
- nusers=system("a=`ps x|grep ftpd|grep -v grep |/usr/ucb/wc -l`;exit $a")>>8;
- /* if under limit, do the real ftp demon */
- if (nusers<=maxusers) execl("/usr/etc/in.ftpd.2","/usr/etc/in.ftpd",0);
- else {
- /* too many users: bye bye */
- fprintf(stderr,"Too many users. Sorry, try again later.\n");
- exit(0);
- }
- }
- --
-
- Help! I've tripped and I can't get down!
- -- Bumper sticker at Eel River Jerry Show
-