Commands entered in 'mail' does not show

I have one machine, running up to date FreeBSD 10.2-release:
Code:
root@trap# freebsd-version -ku
10.2-RELEASE-p7
10.2-RELEASE-p8
root@trap# uname -a
FreeBSD trap.kg4.no 10.2-RELEASE-p7 FreeBSD 10.2-RELEASE-p7 #0: Mon Nov  2 14:19:39 UTC 2015 
root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
It has been updated with freebsd-update.
It has a strange problem - when I start the mail(1) program, commands I enter does not echo. The commands work, but the command character does not show. Example:
Code:
root@trap# mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/mail/root": 2 messages 2 new
>N  1 root@trap.kg4.no  Wed Dec 16 03:01 318/25129 "trap.kg4.no daily security "
N  2 root@trap.kg4.no  Wed Dec 16 03:01  66/2208  "trap.kg4.no daily run outpu"
&
let me try 'h' (header):
Code:
& >N  1 root@trap.kg4.no  Wed Dec 16 03:01 318/25129 "trap.kg4.no daily security "
N  2 root@trap.kg4.no  Wed Dec 16 03:01  66/2208  "trap.kg4.no daily run outpu"
&
Ok, try '?' (help):
Code:
&  Mail  Commands
t <message list>     type messages
n         goto and type next message
e <message list>     edit messages
f <message list>     give head lines of messages
d <message list>     delete messages
s <message list> file     append messages to file
u <message list>     undelete messages
R <message list>     reply to message senders
r <message list>     reply to message senders and all recipients
pre <message list>     make messages go back to /var/mail
m <user list>       mail to specific users
q         quit, saving unresolved messages in mbox
x         quit, do not remove system mailbox
h         print out active message headers
!         shell escape
cd [directory]       chdir to directory or home if none given

A <message list> consists of integers, ranges of same, or user names separated
by spaces.  If omitted, Mail uses the last message typed.

A <user list> consists of user names or aliases separated by spaces.
Aliases are defined in .mailrc in your home directory.
&
I access this machine the same way as I do all the other machines; via ssh from a shell on my FreeBSD workstation. It is only this machine who has this problem.
AFAICT the environment is the same as on my other machines:
Code:
root@trap# env
PAGER=more
LANG=en_US.ISO8859-1
MAIL=/var/mail/root
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/root/bin
ENV=/root/.shrc
PWD=/root
TERM=xterm
EXINIT=set showmode
USER=root
HOME=/root
SHELL=/bin/sh
BLOCKSIZE=K
Has anyone seen this bug, or have an idea where I should look for a possible error?
 
There's awfully lot of mysterious csh-related stuff going on.....

What happens with, say, plain cat ? Is there character-by-character echo while typing the lines ?

Juha
 
There's awfully lot of mysterious csh-related stuff going on.....
Not sure what you are thinking of here, but that reminds me; all of my machines (including this one) have changed root's shell from csh to sh (# chsh -s /bin/sh).

What happens with, say, plain cat ? Is there character-by-character echo while typing the lines ?
It is early; would you please give me an example of which cat command you are thinking of? I haven't got my morning coffee yet, the wheels inside runs slow..
Anyway, a bit more testing reveals that it is shell-related
Code:
root@trap# csh
root@trap:~ # mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/mail/root": 6 messages 6 new
>N  1 root@trap.kg4.no  Wed Dec 16 03:01 318/25129 "trap.kg4.no daily security "
 N  2 root@trap.kg4.no  Wed Dec 16 03:01  66/2208  "trap.kg4.no daily run outpu"
 N  3 root@trap.kg4.no  Thu Dec 17 03:01 277/20536 "trap.kg4.no daily security "
 N  4 root@trap.kg4.no  Thu Dec 17 03:01  66/2208  "trap.kg4.no daily run outpu"
 N  5 root@trap.kg4.no  Fri Dec 18 03:01 289/23289 "trap.kg4.no daily security "
 N  6 root@trap.kg4.no  Fri Dec 18 03:01  66/2208  "trap.kg4.no daily run outpu"
& x
root@trap:~ #
So if I start csh first, it works.
Code:
root@trap:~ # exit
exit
root@trap# mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/mail/root": 6 messages 6 new
>N  1 root@trap.kg4.no  Wed Dec 16 03:01 318/25129 "trap.kg4.no daily security "
 N  2 root@trap.kg4.no  Wed Dec 16 03:01  66/2208  "trap.kg4.no daily run outpu"
 N  3 root@trap.kg4.no  Thu Dec 17 03:01 277/20536 "trap.kg4.no daily security "
 N  4 root@trap.kg4.no  Thu Dec 17 03:01  66/2208  "trap.kg4.no daily run outpu"
 N  5 root@trap.kg4.no  Fri Dec 18 03:01 289/23289 "trap.kg4.no daily security "
 N  6 root@trap.kg4.no  Fri Dec 18 03:01  66/2208  "trap.kg4.no daily run outpu"
& x
root@trap#
and it works even after I exit csh.
exit from the user and a new su
Code:
root@trap# exit
tingo@trap$ su -
Password:
 TERMxterm
root@trap# mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/mail/root": 6 messages 6 new
>N  1 root@trap.kg4.no  Wed Dec 16 03:01 318/25129 "trap.kg4.no daily security "
 N  2 root@trap.kg4.no  Wed Dec 16 03:01  66/2208  "trap.kg4.no daily run outpu"
 N  3 root@trap.kg4.no  Thu Dec 17 03:01 277/20536 "trap.kg4.no daily security "
 N  4 root@trap.kg4.no  Thu Dec 17 03:01  66/2208  "trap.kg4.no daily run outpu"
 N  5 root@trap.kg4.no  Fri Dec 18 03:01 289/23289 "trap.kg4.no daily security "
 N  6 root@trap.kg4.no  Fri Dec 18 03:01  66/2208  "trap.kg4.no daily run outpu"
& x
root@trap#
that works too. However, if I exit the ssh connection and start over again, the problem remains:
Code:
root@trap# mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/mail/root": 6 messages 6 new
>N  1 root@trap.kg4.no  Wed Dec 16 03:01 318/25129 "trap.kg4.no daily security "
 N  2 root@trap.kg4.no  Wed Dec 16 03:01  66/2208  "trap.kg4.no daily run outpu"
 N  3 root@trap.kg4.no  Thu Dec 17 03:01 277/20536 "trap.kg4.no daily security "
 N  4 root@trap.kg4.no  Thu Dec 17 03:01  66/2208  "trap.kg4.no daily run outpu"
 N  5 root@trap.kg4.no  Fri Dec 18 03:01 289/23289 "trap.kg4.no daily security "
 N  6 root@trap.kg4.no  Fri Dec 18 03:01  66/2208  "trap.kg4.no daily run outpu"
& root@trap#
 
Ahh, I assumed csh from the root prompt. Also assumed that this might be related to the csh ^C problem elsewhere.

mail, I think, does not do much terminal stuff (if you don't invoke ~e). It just does fgets(3) and expects terminal to echo. Command line editor in shell can mask a problem in terminal settings. That's the test with cat. Just cat [B]ENTER[/B] and verify an echo. mail could be innocent, and someone's turning echo off and not remembering to restore it.

/etc/gettytab is involved, maybe /etc/profile.

Juha
 
Ok, it seems like cat misbehaves too:
Code:
root@trap# cat
this is  a test

root@trap# csh
root@trap:~ # cat
this is test two
this is test two
^C
root@trap:~ #
I haven't touched /etc/gettytab. /etc/profile is the same as on all my machines:
Code:
root@trap#  more /etc/profile
# $FreeBSD: releng/10.2/etc/profile 208116 2010-05-15 17:49:56Z jilles $
#
# System-wide .profile file for sh(1).
#
# Uncomment this to give you the default 4.2 behavior, where disk
# information is shown in K-Blocks
# BLOCKSIZE=K; export BLOCKSIZE
#
# For the setting of languages and character sets please see
# login.conf(5) and in particular the charset and lang options.
# For full locales list check /usr/share/locale/*
# You should also read the setlocale(3) man page for information
# on how to achieve more precise control of locale settings.
#
# Check system messages
# msgs -q
# Allow terminal messages
# mesg y
EXINIT="set showmode"; export EXINIT
LANG="en_US.ISO8859-1"; export LANG
and root's .profile looks like this:
Code:
root@trap# more .profile
# $FreeBSD: releng/10.2/etc/root/dot.profile 199243 2009-11-13 05:54:55Z ed $
#
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:~/bin
export PATH
HOME=/root
export HOME
TERM=${TERM:-xterm}
export TERM
PAGER=more
export PAGER
export ENV=$HOME/.shrc
echo " "
echo " TERM${TERM}"
echo " "
root's .shrc is mostly aliases:
Code:
root@trap# more .shrc
set -o vi

alias l='ls -aGF'
alias ll='ls -laGF'
alias tvla='tail /var/log/auth.log'
alias tvlm='tail /var/log/messages'
alias tvlr='tail /var/log/rkhunter.log'
alias tvls='tail /var/log/security'
alias tvlml='tail /var/log/maillog'
alias pv='portversion -v'

# set prompt: ``username@hostname$ ''
PS1="`whoami`@`hostname | sed 's/\..*//'`"
case `id -u` in
  0) PS1="${PS1}# ";;
  *) PS1="${PS1}$ ";;
esac
and I use the same or similar files on all my machines.
 
Some more testing; I tried renaming /etc/profile, /root/.profile and /root/.shrc (for each file, rename it, then exit completely from the machine, ssh in, su - and test) - it didn't help, the error is still there.
 
Even more testing. This time I tested with my user.
Code:
tingo@trap$ mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/mail/tingo": 1 message 1 new
>N  1 tingo@trap.kg4.no  Fri Dec 18 21:49  20/739  "testmail"
& tingo@trap$
Yes, the error is there too. Let me just try to start and exit csh(1) and see if that changes anything:
Code:
tingo@trap$ csh
tingo@trap:~ % exit
exit
tingo@trap$ mail
Mail version 8.1 6/6/93.  Type ? for help.
"/var/mail/tingo": 1 message 1 new
>N  1 tingo@trap.kg4.no  Fri Dec 18 21:49  20/739  "testmail"
& x
tingo@trap$
Ok, so simply starting end exiting csh(1) fixes things. That's interesting.
 
csh is sloppy with her line-editor, does not keep the terminal state received from getty. login does turn off echo while reading the password, one possible culprit.

I tried sh as root's shell. 10.2-RELEASE-p10. No problem.

You could temporarily add stty -a to /etc/profile to track down the problem.
echo or -echo. If it is the minus, adding stty echo there would cure the unknown disease.

Juha

(also thinks csh should be restored)
 
Your probably already aware, but if not, it's always recommended to never ever change root's default shell.
I am aware. I also know why this recommendation exists, and what to do if something breaks because of my use of /bin/sh for the root user. That being said, this part of it (using /bin/sh as login shell for root) has not caused any breakage for me since I started using FreeBSD. Which was back when FreeBSD 3.4 was new.

Back on topic; terminal handling should work no matter what shell a user has as login shell. If not - it's a bug.
 
Exploration. Mr Columbus, that is not recommended.

Code:
while :
do
stty -f /dev/xyz | grep echo
done

That could also pinpoint the place where echo is lot, if you are somehow able to watch the flood while working on xyz :)

Juha

Edit: Mr Eriksson, actually
 
Back
Top