]> git.pond.sub.org Git - empserver/commitdiff
Disable nested execute. The execute protocol is flawed and cannot be
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 9 Dec 2007 17:24:30 +0000 (17:24 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 9 Dec 2007 17:24:30 +0000 (17:24 +0000)
implemented correctly by asynchronous clients --- unless a client
waits for a prompt after sending the execute command and its argument,
it is prone to send more input before the C_EXECUTE arrives.  That
input overtakes the contents of the script file.  This is almost
certain to happen when the execute is in a script file.  Disabling
that is probably more useful and certainly less painful than
documenting this mess.  The client rejects nested execute since
servcmd.c rev. 1.42.
(EXEC): new.
(player_coms): Require it for execute.
(player_set_nstat): Set it in nstat.
(execute): Clear it in nstat.

include/player.h
src/lib/player/empmod.c
src/lib/player/init_nats.c
src/lib/player/player.c

index c38fc27bfbb14a8f3f22289478ffd7a742fb9532..21ded57f8afcec2d3e746f833dfdfe586978e634 100644 (file)
@@ -46,6 +46,7 @@
 #define SANCT          (bit(1) | VIS)
 #define NORM           (bit(2) | VIS)
 #define GOD            (bit(3) | NORM | VIS)
 #define SANCT          (bit(1) | VIS)
 #define NORM           (bit(2) | VIS)
 #define GOD            (bit(3) | NORM | VIS)
+#define EXEC           bit(5)
 #define        CAP             bit(6)
 #define        MONEY           bit(7)
 
 #define        CAP             bit(6)
 #define        MONEY           bit(7)
 
index 190854a20e5f40e9d3b95154c915791a4e5f61a7..a7968a1a526b11a05a102debb616544a8e580e6d 100644 (file)
@@ -100,7 +100,7 @@ struct cmndstr player_coms[] = {
      0, edit, C_MOD, GOD},
     {"enable", 0, enab, C_MOD, GOD},
     {"enlist <SECTS> <NUM>", 2, enli, C_MOD, NORM + MONEY + CAP},
      0, edit, C_MOD, GOD},
     {"enable", 0, enab, C_MOD, GOD},
     {"enlist <SECTS> <NUM>", 2, enli, C_MOD, NORM + MONEY + CAP},
-    {"execute <INPUT FILE>", 0, execute, 0, VIS},
+    {"execute <INPUT FILE>", 0, execute, 0, VIS + EXEC },
     {"explore <c|m> <SECT> <NUM> <PATH|DESTINATION>",
      1, explore, C_MOD, NORM + MONEY + CAP},
     {"financial", 0, fina, 0, NORM},
     {"explore <c|m> <SECT> <NUM> <PATH|DESTINATION>",
      1, explore, C_MOD, NORM + MONEY + CAP},
     {"financial", 0, fina, 0, NORM},
index 239eaa74f35e092e054c39ad144af61f851bc479..6836aa47f97afb74a688e5c78b3d2c809ac4e203 100644 (file)
@@ -82,5 +82,6 @@ player_set_nstat(struct player *pl, struct natstr *np)
        pl->nstat |= MONEY;
     if (np->nat_stat == STAT_ACTIVE && !influx(np))
        pl->nstat |= CAP;
        pl->nstat |= MONEY;
     if (np->nat_stat == STAT_ACTIVE && !influx(np))
        pl->nstat |= CAP;
+    pl->nstat |= EXEC;
     return pl->nstat;
 }
     return pl->nstat;
 }
index 9814ceb84ed6067aa7a0bf9aa00bfa9e1f68a446..ac71b7b3ef9324ffacb6297667108249702676e5 100644 (file)
@@ -261,6 +261,7 @@ execute(void)
     prexec(p);
 
     while (!failed && status()) {
     prexec(p);
 
     while (!failed && status()) {
+       player->nstat &= ~EXEC;
        if (recvclient(buf, sizeof(buf)) < 0)
            break;
        if (parse(buf, scanspace, player->argp, player->comtail,
        if (recvclient(buf, sizeof(buf)) < 0)
            break;
        if (parse(buf, scanspace, player->argp, player->comtail,
@@ -278,6 +279,7 @@ execute(void)
     if (failed) {
        while (recvclient(buf, sizeof(buf)) >= 0) ;
     }
     if (failed) {
        while (recvclient(buf, sizeof(buf)) >= 0) ;
     }
+
     pr("Execute : %s\n", failed ? "aborted" : "terminated");
     player->eof = 0;
     return RET_OK;
     pr("Execute : %s\n", failed ? "aborted" : "terminated");
     player->eof = 0;
     return RET_OK;