diff options
author | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-06-03 17:59:32 +0800 |
---|---|---|
committer | in2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2002-06-03 17:59:32 +0800 |
commit | ab7fd5ecdca4ff9fc31e8695453f97bf82fdb6e1 (patch) | |
tree | 0a206f38f8197f79c00a645c014e4bf1bbb487f2 /util | |
parent | e35187865e63744e4bfd812af31ea35bc9d26ba3 (diff) | |
download | pttbbs-ab7fd5ecdca4ff9fc31e8695453f97bf82fdb6e1.tar pttbbs-ab7fd5ecdca4ff9fc31e8695453f97bf82fdb6e1.tar.gz pttbbs-ab7fd5ecdca4ff9fc31e8695453f97bf82fdb6e1.tar.bz2 pttbbs-ab7fd5ecdca4ff9fc31e8695453f97bf82fdb6e1.tar.lz pttbbs-ab7fd5ecdca4ff9fc31e8695453f97bf82fdb6e1.tar.xz pttbbs-ab7fd5ecdca4ff9fc31e8695453f97bf82fdb6e1.tar.zst pttbbs-ab7fd5ecdca4ff9fc31e8695453f97bf82fdb6e1.zip |
permission report
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@278 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util')
-rw-r--r-- | util/bbsctl.c | 54 |
1 files changed, 46 insertions, 8 deletions
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 <grp.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <signal.h> #include <sys/types.h> -#include <grp.h> #include <dirent.h> +#include <fcntl.h> +#include <ctype.h> +#include "config.h" +#include "pttstruct.h" +#include "perm.h" #ifdef FreeBSD #include <sys/syslimits.h> @@ -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) |