diff options
-rw-r--r-- | util/.cvsignore | 2 | ||||
-rw-r--r-- | util/Makefile | 10 | ||||
-rw-r--r-- | util/mdclean.c | 98 | ||||
-rw-r--r-- | util/splitpasswd.c | 32 |
4 files changed, 2 insertions, 140 deletions
diff --git a/util/.cvsignore b/util/.cvsignore index d33e906f..28defeaa 100644 --- a/util/.cvsignore +++ b/util/.cvsignore @@ -41,6 +41,4 @@ jungo bbsctl mandex shmctl -mdclean -splitpasswd indexuser diff --git a/util/Makefile b/util/Makefile index e3b2a783..8e0479e4 100644 --- a/util/Makefile +++ b/util/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.21 2002/11/04 08:46:50 in2 Exp $ +# $Id: Makefile,v 1.22 2002/11/08 21:16:25 in2 Exp $ BBSHOME?=$(HOME) OSTYPE!=uname @@ -30,7 +30,7 @@ CPROGS= bbsmail BM_money post account birth deluserfile expire mandex\ poststat showboard antispam countalldice webgrep bbsrf\ initbbs outmail xchatd userlist tunepasswd buildir reaper shmsweep\ merge_passwd merge_board inndBM buildAnnounce rmuid \ - toplazyBM jungo toplazyBBM shmctl mdclean splitpasswd indexuser + toplazyBM jungo toplazyBBM shmctl indexuser PROGS= $(CPROGS) BM_money.sh backpasswd.sh mailog.sh opendice.sh\ openticket.sh stock.sh topsong.sh weather.sh stock.perl weather.perl\ @@ -162,12 +162,6 @@ bbsctl: bbsctl.c shmctl: shmctl.c $(OBJS) $(CC) $(CFLAGS) -o $@ $@.c $(OBJS) -mdclean: mdclean.c - $(CC) $(CFLAGS) -o $@ $@.c - -splitpasswd: splitpasswd.c - $(CC) $(CFLAGS) -o $@ $@.c - install: $(PROGS) install -d $(BBSHOME)/bin/ install -c -m 755 $(PROGS) $(BBSHOME)/bin/ diff --git a/util/mdclean.c b/util/mdclean.c deleted file mode 100644 index 196fc9ee..00000000 --- a/util/mdclean.c +++ /dev/null @@ -1,98 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include "config.h" -#include <sys/types.h> -#include <dirent.h> -#include <unistd.h> -#include <err.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/param.h> -#include <sys/mount.h> - -#define MAXDSs 1048576 - -typedef struct { - time_t atime; - char name[60]; -} DS; - -DS ds[MAXDSs]; -int nDSs; - -int compar(const void *a, const void *b) -{ - return ((DS *)a)->atime - ((DS *)b)->atime; -} - -int main(int argc, char **argv) -{ - DIR *dirp; - struct dirent *dp; - struct stat sb; - struct statfs sf; - char *fn; - time_t now; - int sleeptime, leavespace, clean; - - if( argc != 4 ){ - puts("usage:\tmdclean sleeptime(secs) leavespace(k) clean(%%)\n"); - return 0; - } - sleeptime = (atoi(argv[1]) < 1) ? 1 : atoi(argv[1]); - leavespace= (atoi(argv[2]) <100)?100: atoi(argv[2]); - clean = (atoi(argv[3]) < 1) ? 1 : atoi(argv[3]); - - if( chdir(BBSHOME "/cache") < 0 ) - err(1, "chdir"); - - while( 1 ){ - puts("sleeping..."); - sleep(sleeptime); - if( (dirp = opendir(".")) == NULL ) - err(1, "opendir"); - - statfs(".", &sf); - if( sf.f_bfree * sf.f_bsize / 1024 > leavespace ) - continue; - - nDSs = 0; - now = time(NULL); - while( (dp = readdir(dirp)) != NULL ){ - fn = dp->d_name; - if( fn[0] != 'e' && fn[0] != 'b' ){ - unlink(fn); - continue; - } - if( stat(fn, &sb) < 0 ) - continue; - if( sb.st_atime < now - 1800 ){ - printf("atime: %s\n", fn); - unlink(fn); - } - else if( sb.st_mtime < now - 10800 ){ - printf("mtime: %s\n", fn); - unlink(fn); - } - else{ - if( nDSs != MAXDSs ){ - strcpy(ds[nDSs].name, fn); - ds[nDSs].atime = sb.st_atime; - ++nDSs; - } - } - } - closedir(dirp); - - statfs(".", &sf); - if( sf.f_bfree * sf.f_bsize / 1024 <= leavespace ){ - qsort(ds, nDSs, sizeof(DS), compar); - nDSs = nDSs * clean / 100; - while( nDSs-- ){ - printf("%s\n", ds[nDSs].name); - unlink(ds[nDSs].name); - } - } - } - return 0; -} diff --git a/util/splitpasswd.c b/util/splitpasswd.c deleted file mode 100644 index 1a800f6c..00000000 --- a/util/splitpasswd.c +++ /dev/null @@ -1,32 +0,0 @@ -#include "bbs.h" -#include <err.h> - -int main(int argc, char **argv) -{ - userec_t xuser; - int fd, ufd; - char path[80], fn[80]; - - chdir(BBSHOME); - if( (fd = open(".PASSWDS", O_RDONLY)) < 0 ) - err(1, ".PASSWDS"); - - while( read(fd, &xuser, sizeof(xuser)) > 0 ){ - if( strcmp(xuser.userid, "in2") != 0 ) - continue; - sprintf(path, "home/%c/%s", xuser.userid[0], xuser.userid); - if( access(path, 0) < 0 ){ - printf("user home error (%s) (%s)\n", xuser.userid, path); - continue; - } - sprintf(fn, "%s/.passwd", path); - if( (ufd = open(fn, O_WRONLY | O_CREAT, 0600)) < 0 ){ - perror(path); - continue; - } - write(ufd, &xuser, sizeof(xuser)); - close(ufd); - } - - return 0; -} |