From ab7fd5ecdca4ff9fc31e8695453f97bf82fdb6e1 Mon Sep 17 00:00:00 2001 From: in2 Date: Mon, 3 Jun 2002 09:59:32 +0000 Subject: permission report git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@278 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/bbsctl.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 8 deletions(-) (limited to 'util/bbsctl.c') diff --git a/util/bbsctl.c b/util/bbsctl.c index 03a68689..64e54e61 100644 --- a/util/bbsctl.c +++ b/util/bbsctl.c @@ -1,11 +1,16 @@ +#include #include #include #include #include #include #include -#include #include +#include +#include +#include "config.h" +#include "pttstruct.h" +#include "perm.h" #ifdef FreeBSD #include @@ -188,17 +193,50 @@ int Xipcrm(int argc, char **argv) return 0; } +int permreport(int argc, char **argv) +{ + int fd, i, count; + userec_t usr; + struct { + int perm; + char *desc; + } check[] = {{PERM_ACCOUNTS, "PERM_ACCOUNTS"}, + {PERM_SYSOP, "PERM_SYSOP"}, + {PERM_SYSSUBOP, "PERM_SYSSUBOP"}, + {PERM_MANAGER, "PERM_MANAGER"}, + {0, NULL}}; + + if( (fd = open(".PASSWDS", O_RDONLY)) < 0 ){ + perror(".PASSWDS"); + return 1; + } + for( count = i = 0 ; check[i].perm != 0 ; ++i ){ + lseek(fd, 0, SEEK_SET); + printf("%s\n", check[i].desc); + while( read(fd, &usr, sizeof(usr)) > 0 ){ + if( usr.userid[0] != 0 && isalpha(usr.userid[0]) && + usr.userlevel & check[i].perm ){ + ++count; + printf("%-20s%-10s\n", usr.userid, usr.realname); + } + } + printf("total %d users\n\n", count); + } + return 0; +} + struct { int (*func)(int, char **); char *cmd, *descript; } cmds[] = - { {startbbs, "start", "start mbbsd at port 23, 3000~3010"}, - {stopbbs, "stop", "killall listening mbbsd"}, - {restartbbs, "restart", "stop and then start"}, - {bbsadm, "bbsadm", "switch to user: bbsadm"}, - {bbstest, "test", "run ./mbbsd as bbsadm"}, - {Xipcrm, "ipcrm", "ipcrm all msg, shm, sem"}, - {STOP, "STOP", "killall ALL mbbsd"}, + { {startbbs, "start", "start mbbsd at port 23, 3000~3010"}, + {stopbbs, "stop", "killall listening mbbsd"}, + {restartbbs, "restart", "stop and then start"}, + {bbsadm, "bbsadm", "switch to user: bbsadm"}, + {bbstest, "test", "run ./mbbsd as bbsadm"}, + {Xipcrm, "ipcrm", "ipcrm all msg, shm, sem"}, + {STOP, "STOP", "killall ALL mbbsd"}, + {permreport, "permreport", "permission report"}, {NULL, NULL, NULL} }; int main(int argc, char **argv) -- cgit v1.2.3