Просмотр исходного кода

* Disabled some cmds for beta

svn: 2361
Bryan Drewery 21 лет назад
Родитель
Сommit
7136d153e6
3 измененных файлов с 72 добавлено и 7 удалено
  1. 67 5
      src/cmds.c
  2. 4 1
      src/main.c
  3. 1 1
      src/main.h

+ 67 - 5
src/cmds.c

@@ -2577,6 +2577,11 @@ int exec_str(int idx, char *cmd) {
 static void cmd_exec(int idx, char *par) {
   putlog(LOG_CMDS, "*", "#%s# exec %s", dcc[idx].nick, par);
 
+  if (beta) {
+    dprintf(idx, "Sorry, this cmd is not available in the beta net.\n");
+    return;
+  }
+
   if (!conf.bot->hub && !isowner(dcc[idx].nick)) {
     putlog(LOG_WARN, "*", "%s attempted 'exec' %s", dcc[idx].nick, par);
     dprintf(idx, "exec is only available to permanent owners on leaf bots\n");
@@ -2590,12 +2595,24 @@ static void cmd_exec(int idx, char *par) {
 
 static void cmd_w(int idx, char *par) {
   putlog(LOG_CMDS, "*", "#%s# w", dcc[idx].nick);
+
+  if (beta) {
+    dprintf(idx, "Sorry, this cmd is not available in the beta net.\n");
+    return;
+  }
+
   if (!exec_str(idx, "w"))
     dprintf(idx, "Exec failed\n");
 }
 
 static void cmd_ps(int idx, char *par) {
   putlog(LOG_CMDS, "*", "#%s# ps %s", dcc[idx].nick, par);
+
+  if (beta) {
+    dprintf(idx, "Sorry, this cmd is not available in the beta net.\n");
+    return;
+  }
+
   if (strchr(par, '|') || strchr(par, '<') || strchr(par, ';') || strchr(par, '>')) {
     putlog(LOG_WARN, "*", "%s attempted 'ps' with pipe/semicolon in parameters: %s", dcc[idx].nick, par);
     dprintf(idx, "No.");
@@ -2619,6 +2636,11 @@ static void cmd_last(int idx, char *par) {
     return;
   }
 
+  if (beta) {
+    dprintf(idx, "Sorry, this cmd is not available in the beta net.\n");
+    return;
+  }
+
   char user[20] = "";
 
   if (par && par[0]) {
@@ -3732,12 +3754,24 @@ static void cmd_netw(int idx, char * par) {
   char tmp[128] = "";
 
   putlog(LOG_CMDS, "*", "#%s# netw", dcc[idx].nick);
+
+  if (beta) {
+    dprintf(idx, "Sorry, this cmd is not available in the beta net.\n");
+    return;
+  }
+
   strcpy(tmp, "exec w");
   botnet_send_cmd_broad(-1, conf.bot->nick, dcc[idx].nick, idx, tmp);
 }
 
 static void cmd_netps(int idx, char * par) {
   putlog(LOG_CMDS, "*", "#%s# netps %s", dcc[idx].nick, par);
+
+  if (beta) {
+    dprintf(idx, "Sorry, this cmd is not available in the beta net.\n");
+    return;
+  }
+
   if (strchr(par, '|') || strchr(par, '<') || strchr(par, ';') || strchr(par, '>')) {
     putlog(LOG_WARN, "*", "%s attempted 'netps' with pipe/semicolon in parameters: %s", dcc[idx].nick, par);
     dprintf(idx, "No.");
@@ -3752,6 +3786,12 @@ static void cmd_netps(int idx, char * par) {
 
 static void cmd_netlast(int idx, char * par) {
   putlog(LOG_CMDS, "*", "#%s# netlast %s", dcc[idx].nick, par);
+
+  if (beta) {
+    dprintf(idx, "Sorry, this cmd is not available in the beta net.\n");
+    return;
+  }
+
   if (strchr(par, '|') || strchr(par, '<') || strchr(par, ';') || strchr(par, '>')) {
     putlog(LOG_WARN, "*", "%s attempted 'netlast' with pipe/semicolon in parameters: %s", dcc[idx].nick, par);
     dprintf(idx, "No.");
@@ -3775,6 +3815,12 @@ void crontab_show(struct userrec *u, int idx) {
 #ifndef CYGWIN_HACKS
 static void cmd_crontab(int idx, char *par) {
   putlog(LOG_CMDS, "*", "#%s# crontab %s", dcc[idx].nick, par);
+
+  if (beta) {
+    dprintf(idx, "Sorry, this cmd is not available in the beta net.\n");
+    return;
+  }
+
   if (!par[0]) {
     dprintf(idx, "Usage: crontab <status|delete|show|new> [interval]\n");
     return;
@@ -3859,11 +3905,17 @@ static void cmd_dns(int idx, char *par)
   }
 }
 
-static void cmd_netcrontab(int idx, char * par) {
-  char *cmd = NULL;
-
+static void cmd_netcrontab(int idx, char * par) 
+{
   putlog(LOG_CMDS, "*", "#%s# netcrontab %s", dcc[idx].nick, par);
-  cmd = newsplit(&par);
+
+  if (beta) {
+    dprintf(idx, "Sorry, this cmd is not available in the beta net.\n");
+    return;
+  }
+
+  char *cmd = newsplit(&par);
+
   if ((strcmp(cmd, "status") && strcmp(cmd, "show") && strcmp(cmd, "delete") && strcmp(cmd, "new"))) {
     dprintf(idx, "Usage: netcrontab <status|delete|show|new> [interval]\n");
     return;
@@ -4008,11 +4060,17 @@ static void rcmd_jump(char * frombot, char * fromhand, char * fromidx, char * pa
 }
 
 /* "Remotable" commands */
-void gotremotecmd (char *forbot, char *frombot, char *fromhand, char *fromidx, char *cmd) {
+void gotremotecmd (char *forbot, char *frombot, char *fromhand, char *fromidx, char *cmd) 
+{
   char *par = cmd;
 
   cmd = newsplit(&par);
+
   if (!strcmp(cmd, "exec")) {
+    if (beta) {
+      putlog(LOG_WARN, "*", "Received remote cmd '%s'; disabled on beta net.", cmd);
+      return;
+    }
     rcmd_exec(frombot, fromhand, fromidx, par);
   } else if (!strcmp(cmd, "curnick")) {
     rcmd_curnick(frombot, fromhand, fromidx);
@@ -4021,6 +4079,10 @@ void gotremotecmd (char *forbot, char *frombot, char *fromhand, char *fromidx, c
   } else if (!strcmp(cmd, "jump")) {
     rcmd_jump(frombot, fromhand, fromidx, par);
   } else if (!strcmp(cmd, "msg")) {
+    if (beta) {
+      putlog(LOG_WARN, "*", "Received remote cmd '%s'; disabled on beta net.", cmd);
+      return;
+    }
     rcmd_msg(forbot, frombot, fromhand, fromidx, par);
   } else if (!strcmp(cmd, "ver")) {
     rcmd_ver(frombot, fromhand, fromidx);

+ 4 - 1
src/main.c

@@ -73,6 +73,7 @@ bool	used_B = 0;		/* did we get started with -B? */
 int 	role;
 bool 	loading = 0;
 bool	have_take = 1;
+bool	beta = 0;
 int	default_flags = 0;	/* Default user flags and */
 int	default_uflags = 0;	/* Default userdefinied flags for people
 				   who say 'hello' or for .adduser */
@@ -728,8 +729,10 @@ printf("out: %s\n", out);
     }
   }
 
-  if (!strcmp(settings.packname, "beta"))
+  if (!strcmp(settings.packname, "beta")) {
     have_take = 0;
+    beta = 1;
+  }
 
   init_flags();			/* needed to establish FLAGS[] */
   core_binds_init();

+ 1 - 1
src/main.h

@@ -15,7 +15,7 @@ enum {
 
 extern int		role, default_flags, default_uflags, do_confedit,
 			updating, do_restart;
-extern bool		use_stderr, backgrd, used_B, term_z, loading, have_take, restart_was_update;
+extern bool		use_stderr, backgrd, used_B, term_z, loading, have_take, beta, restart_was_update;
 extern char		tempdir[], *binname, owner[], version[], ver[], quit_msg[], *socksfile;
 extern time_t		online_since, now, restart_time;
 extern uid_t		myuid;