Running Smaug in Raspian

Posted by Lerkista on Tue 25 Jun 2019 04:23 PM — 16 posts, 67,522 views.

#0
Hi

I have a litte problem running Smaugfuss, i have this code in account.c:

"argument" is the name you enter at login:
                argument[0] = UPPER( argument[0] );
                snprintf( buf, MAX_STRING_LENGTH, "Nombre: -%s-\r\n", argument );
                write_to_buffer( d, buf, 0 );


In CYGWIN works fine and shows: "Nombre: -Lerkista-"
but in Raspbian shows: "Nombre: -lerkista-", don't know why UPPER don't work, i also tried to change it to:

               argument[0] = toupper( argument[0] );


But it's the same, don't make the first letter to uppercase

Anyone knows how to fix that?

Thanks
Amended on Tue 25 Jun 2019 04:24 PM by Lerkista
USA Global Moderator #1
When asking for help with code that doesn't work, please link to the complete source code that you're using. We need to see all of it, not just some microscopic part.
Amended on Tue 25 Jun 2019 04:51 PM by Fiendish
#2
Fiendish said:

When asking for help with code that doesn't work, please link to the complete source code that you're using. We need to see all of it, not just some microscopic part.


I don't gonna share my source code, since i've work a lot on it, but with Smaugfuss 1.9.3 from: https://github.com/Arthmoor/SmaugFUSS i can reproduce a similar problem

I only apply this changes to make it run in Raspbian: http://gammon.com.au/Arduino/smaugfuss_diffs.txt

In comm.c line 1840 i add:
  bug("Name: %s", argument);


Raspbian:
Enter your character's name, or type new: lerkista

No such player exists.
Please check your spelling, or type new to start a new player.

Name: lerkista
Password: 

Tue Jun 25 15:25:31 2019 :: [*****] BUG: Name: Vlerkista
Tue Jun 25 15:25:33 2019 :: [*****] BUG: Name: Lerkista
Tue Jun 25 15:25:33 2019 :: Preloading player data for: Lerkista (1K)

First try failed because somehow a V is added first to the name, the second try is register normally and it detected the account

CYGWIN:
Enter your character's name, or type new: lerkista
Password: 

Tue Jun 25 16:31:16 2019 :: [*****] BUG: Name: Lerkista
Tue Jun 25 16:31:16 2019 :: Preloading player data for: Lerkista (1K)


This error don't happended here, same source

Here is a "V" added first, in my source "ÿþV" are added, but just in the first input
Amended on Tue 25 Jun 2019 07:39 PM by Lerkista
Australia Forum Administrator #3
ÿþV is 0xFF 0xFE 0x56 in hex.

That is: IAC DONT TELOPT_COMPRESS2

In other words, your client is telling the server to not use MCCP compression, and you are not detecting that telnet subnegotiation option, and trying to treat it as part of the character name.

The server needs to allow for telnet negotiation sequences and not pass them through as commands that the player types.

When you try to log in a second time it doesn't send that sequence again, and therefore you succeed. The client sends the sequence once after connecting.
#4
Nick Gammon said:

ÿþV is 0xFF 0xFE 0x56 in hex.

That is: IAC DONT TELOPT_COMPRESS2

In other words, your client is telling the server to not use MCCP compression, and you are not detecting that telnet subnegotiation option, and trying to treat it as part of the character name.

The server needs to allow for telnet negotiation sequences and not pass them through as commands that the player types.

When you try to log in a second time it doesn't send that sequence again, and therefore you succeed. The client sends the sequence once after connecting.


Ok, any idea why that behavior is only in Raspbian?
Australia Forum Administrator #5
What client are you using, and are you using the same client in both cases?
#6
Nick Gammon said:

What client are you using, and are you using the same client in both cases?


I've tried with Cygwin terminal, SecureCRT, and Raspbian terminal

I've running Smaug in Cygwin, CentOs and Raspbian, and the problem is only with Raspbian
Australia Forum Administrator #7

Are you using the same client in the version that works, compared to the version that doesn’t work? Please clearly state what you are doing.

Australia Forum Administrator #8

In comm.c in my version of SmaugFUSS I see this directly after the client connects:

   LINK( dnew, first_descriptor, last_descriptor, next, prev );

   /*
    * MCCP Compression 
    */
   write_to_buffer( dnew, will_compress2_str, 0 );

   /*
    * Send the greeting.
    */
   {
      extern char *help_greeting;
      if( help_greeting[0] == '.' )
         send_to_desc_color( help_greeting + 1, dnew );
      else
         send_to_desc_color( help_greeting, dnew );
   }

The string will_compress2_str is this:

char will_compress2_str[] = { ( char )IAC, ( char )WILL, TELOPT_COMPRESS2, '\0' };

Some clients may not recognize TELOPT_COMPRESS2 and therefore reply IAC DONT TELOPT_COMPRESS2 (as I mentioned earlier, is happening to you).

The code in read_from_buffer looks like it should handle IAC DONT, however to see what is going wrong I suggest running under the debugger.

Debugging with gdb

#9
I finally fix the problem

I edit read_to_buffer and add this:

  for (p = (unsigned char *)d->inbuf; *p; p++)
  {
    if (*p == IAC)
    {
      bug("IAC %s", d->inbuf);
      if (memcmp (p, (unsigned char *)do_mxp_str, strlen ((const char *)do_mxp_str)) == 0)
      {
        bug("MXP ON");
        turn_on_mxp (d);
        /* remove string from input buffer */
        memmove (p, (unsigned char *)&p [strlen ((const char *)do_mxp_str)], strlen ((const char*)&p [strlen ((const char *)do_mxp_str)]) + 1);
        p--; /* adjust to allow for discarded bytes */
      } /* end of turning on MXP */
      else  if (memcmp (p, (unsigned char *)dont_mxp_str, strlen ((const char*)dont_mxp_str)) == 0)
      {
        bug("MXP OFF");
        d->mxp = FALSE;
        /* remove string from input buffer */
        memmove (p, (unsigned char *)&p [strlen ((const char *)dont_mxp_str)], strlen ((const char *)&p [strlen ((const char *)dont_mxp_str)]) + 1);
        p--; /* adjust to allow for discarded bytes */
      } /* end of turning off MXP */
      else if(memcmp (p, (unsigned char *)do_mccp_str, strlen ((const char *)do_mccp_str)) == 0)
      {
        bug("MCCP ON");   
        compressStart( d );
        /* remove string from input buffer */
        memmove (p, (unsigned char *)&p [strlen ((const char *)do_mccp_str)], strlen ((const char*)&p [strlen ((const char *)do_mccp_str)]) + 1);
        p--; /* adjust to allow for discarded bytes */
      } /* end of turning on MCCP */
      else if(memcmp (p, (unsigned char *)dont_mccp_str, strlen ((const char*)dont_mccp_str)) == 0)
      {
        bug("MCCP OFF");
        compressEnd( d );
        /* remove string from input buffer */
        memmove (p, (unsigned char *)&p [strlen ((const char *)dont_mccp_str)], strlen ((const char *)&p [strlen ((const char *)dont_mccp_str)]) + 1);
        p--; /* adjust to allow for discarded bytes */
      }
      else if(memcmp (p, (unsigned char *)do_echo_str, strlen ((const char *)do_echo_str)) == 0)
      {
        bug("ECHO ON");   
        /* remove string from input buffer */
        memmove (p, (unsigned char *)&p [strlen ((const char *)do_echo_str)], strlen ((const char*)&p [strlen ((const char *)do_echo_str)]) + 1);
        p--; /* adjust to allow for discarded bytes */
      } /* end of turning on ECHO */
      else if(memcmp (p, (unsigned char *)dont_echo_str, strlen ((const char*)dont_echo_str)) == 0)
      {
        bug("ECHO OFF");
        /* remove string from input buffer */
        memmove (p, (unsigned char *)&p [strlen ((const char *)dont_echo_str)], strlen ((const char *)&p [strlen ((const char *)dont_echo_str)]) + 1);
        p--; /* adjust to allow for discarded bytes */
      }         
    } /* end of finding an IAC */
  }


Don't remember where i get the MXP code, but i copy and adjust it to COMPRESS2 and ECHO, because the IAC sent by the client keeps repeating without this code and mess with my inputs

With the bug messages as debug the log show:
MUD startup - Lua extension called
Wed Jun 26 00:14:37 2019 :: [*****] BUG: IAC ÿýVÿý[
Wed Jun 26 00:14:37 2019 :: [*****] BOOT: [*****] BUG: IAC ÿýVÿý[
Wed Jun 26 00:14:37 2019 :: [*****] BUG: MCCP ON
Wed Jun 26 00:14:37 2019 :: [*****] BOOT: [*****] BUG: MCCP ON
Wed Jun 26 00:14:37 2019 :: [*****] BUG: IAC ÿý[
Wed Jun 26 00:14:37 2019 :: [*****] BOOT: [*****] BUG: IAC ÿý[
Wed Jun 26 00:14:37 2019 :: [*****] BUG: MXP ON
Wed Jun 26 00:14:37 2019 :: [*****] BOOT: [*****] BUG: MXP ON
Wed Jun 26 00:14:39 2019 :: [*****] BUG: IAC ÿý\
Wed Jun 26 00:14:39 2019 :: [*****] BOOT: [*****] BUG: IAC ÿý\
Wed Jun 26 00:14:39 2019 :: [*****] BUG: ECHO OFF
Wed Jun 26 00:14:39 2019 :: [*****] BOOT: [*****] BUG: ECHO OFF
Wed Jun 26 00:14:41 2019 :: Cargando cuenta: Lerkista
Wed Jun 26 00:14:42 2019 :: [*****] BUG: IAC ÿþ\
Wed Jun 26 00:14:42 2019 :: [*****] BOOT: [*****] BUG: IAC ÿþ\
Wed Jun 26 00:14:42 2019 :: [*****] BUG: ECHO ON
Wed Jun 26 00:14:42 2019 :: [*****] BOOT: [*****] BUG: ECHO ON
Wed Jun 26 00:14:45 2019 :: Preloading player data for: Lerkista (2K)
Wed Jun 26 00:14:45 2019 :: Loading player data for: Lerkista (2K)


Still don't understand why this happened only in Raspbian
Australia Forum Administrator #10
Probably because of a different client, however you chose not to disclose whether or not you use a different client with Raspian.
#11
Nick Gammon said:

Probably because of a different client, however you chose not to disclose whether or not you use a different client with Raspian.


As i said before, i've used SecureCRT, Cygwin terminal and Rasbian terminal

I have the same source (except for the changes you suggest to make it run in Raspbian), in Cygwin, CentOS and Raspbian, and don't matter which client i use, the problem only happened when connected to the Raspbian server

i download mushclient and mudlet, but since i changed the source in Raspbian, i haven't tried with those
#12
Here is a sourcecode:

https://www.dropbox.com/s/ia7xkteo9stvy7j/smaugfuss193-mxp.tgz?dl=0

running in Raspbian, the first attempt to login fail, because it adds a V before the name (i've added a bug() to see that in log)
Australia Forum Administrator #13
Lerkista said:

I finally fix the problem ...


So it is fixed, then?
#14
Nick Gammon said:

Lerkista said:

I finally fix the problem ...


So it is fixed, then?


Yes, i know that maybe the solution is not the optimal but works (at least for the moment without many tests)

I only shared the source code in case you want to investigate because the error only shows in Raspbian and not in another distro
Australia Forum Administrator #15
Thank you, but I don't have the Raspian distro up on any of my PCs so I think I'll leave it for now.

If anyone has similar problems they can refer to your solution above. Thanks for posting it.