So, thanks to @KamilMaciorowski I got it working.
Long story short: the problem is caused by use_pty in the sudoers file, commenting the Default use_pty line that my sudoers file had made it to work correctly.
Long story: well, after reading the source code of os_io.c I checked were it did the piping of data between processes and how it changed when use_pty is enabled. In the case of use_pty being enabled it creates a pseudo-terminal and pipes the data through it. The thing is that when the slave pseudo-terminal is created it has a function called setup_terminal_slave and this function explicitly sets the data bits to 8:
___HIDDEN int setup_terminal_slave
___P((int slave_fd),
(slave_fd)
int slave_fd;)
{
struct termios tios;
if (tcgetattr (slave_fd, &tios) >= 0)
{
tios.c_lflag &= ~(ECHO | ECHOCTL | ICANON | IEXTEN | ISIG);
tios.c_iflag &= ~(BRKINT | INLCR | ICRNL | INPCK | ISTRIP | IXON | IXOFF);
tios.c_cflag &= ~(CSIZE | PARENB | CLOCAL);
tios.c_cflag |= (CS8 | HUPCL); // <---HERE, 8 data bits
#ifndef OCRNL
#define OCRNL 0
#endif
tios.c_oflag &= ~(OPOST | ONLCR | OCRNL);
if (tcsetattr (slave_fd, TCSANOW, &tios) >= 0)
return 0;
}
return -1;
}
As my terminal uses 7 data bits and even parity the eight bit was being interpreted as the parity. breaking the text in the chars that should had a '1' as parity bit. And that exactly matches what I saw in the screen, not all the chars were broken, some were ok and others were just a blank square, so the chars that should had a '0' parity bit were shown ok and the ones that should had a '1' were shown as a "transmission error".
stty saneor other config commands?use_ptymay have something to do with the problem. Seeman 5 sudoerswhere it describesuse_pty. Note regardless if it says the default isonoroff(I believe the default changed fromofftoonaround 1.9.14), your actual/etc/sudoersmay specifyDefaults use_ptyxorDefaults !use_ptyeven out of the box.use_ptyresults in what you have observed, so I won't add an answer. I won't mind if you post an answer. There is no need to mention my input, keep the answer technical. (2) Read this: How does theuse_ptysudoers option prevent a persistence attack?.