summaryrefslogtreecommitdiffstats
path: root/util/bbsctl.c
diff options
context:
space:
mode:
authorin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-16 21:47:12 +0800
committerin2 <in2@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2002-03-16 21:47:12 +0800
commit29d876cdef4b32738321498a77ba833d828bfbe4 (patch)
tree973523a857524a60523fcd6008e4be64701f3cc2 /util/bbsctl.c
parent7c81f751b1e395ad0a7c69de1d8f9d1c7f549395 (diff)
downloadpttbbs-29d876cdef4b32738321498a77ba833d828bfbe4.tar
pttbbs-29d876cdef4b32738321498a77ba833d828bfbe4.tar.gz
pttbbs-29d876cdef4b32738321498a77ba833d828bfbe4.tar.bz2
pttbbs-29d876cdef4b32738321498a77ba833d828bfbe4.tar.lz
pttbbs-29d876cdef4b32738321498a77ba833d828bfbe4.tar.xz
pttbbs-29d876cdef4b32738321498a77ba833d828bfbe4.tar.zst
pttbbs-29d876cdef4b32738321498a77ba833d828bfbe4.zip
add test
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@30 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util/bbsctl.c')
-rw-r--r--util/bbsctl.c36
1 files changed, 33 insertions, 3 deletions
diff --git a/util/bbsctl.c b/util/bbsctl.c
index db158c77..1020f7d2 100644
--- a/util/bbsctl.c
+++ b/util/bbsctl.c
@@ -9,16 +9,25 @@
#ifdef FreeBSD
#include <sys/syslimits.h>
- #define SU "/usr/bin/su"
+ #define SU "/usr/bin/su"
+ #define CP "/bin/cp"
+ #define KILLALL "/usr/bin/killall"
#endif
#ifdef Linux
#include <linux/limits.h>
- #define SU "/bin/su"
+ #define SU "/bin/su"
+ #define CP "/bin/cp"
+ #define KILLALL "/usr/bin/killall"
#endif
void usage(void)
{
- printf("usage: bbsctl [start|stop|restart|bbsadm]\n");
+ printf("usage: bbsctl [start|stop|restart|bbsadm|test]\n"
+ " bbsctl start start mbbsd at 23,3000-3010\n"
+ " bbsctl stop killall listening mbbsd\n"
+ " bbsctl restart stop + start\n"
+ " bbsctl bbsadm su to bbsadm\n"
+ " bbsctl test use bbsadm permission to exec ./mbbsd 9000\n");
exit(0);
}
@@ -111,6 +120,26 @@ void bbsadm(void)
execl(SU, "su", "bbsadm", NULL);
}
+void bbstest(void)
+{
+ if( access("mbbsd", 0) < 0 ){
+ perror("./mbbsd");
+ return;
+ }
+ system(CP " -f mbbsd testmbbsd");
+ if( setuid(0) < 0 ){
+ perror("setuid(0)");
+ return;
+ }
+ if( setuid(9999) < 0 ){
+ perror("setuid(9999)");
+ return;
+ }
+ system(KILLALL " testmbbsd");
+ execl("./testmbbsd", "testmbbsd", "9000", NULL);
+ perror("execl()");
+}
+
struct {
char *cmd;
void (*func)();
@@ -118,6 +147,7 @@ struct {
{"stop", stopbbs},
{"restart", restartbbs},
{"bbsadm", bbsadm},
+ {"test", bbstest},
{NULL, NULL} };
int main(int argc, char **argv)