#1433 Issue closed: In recovery system /etc/motd results weird user experience for rear_shell

Labels: cleanup, fixed / solved / done, minor bug

jsmeix opened issue at 2017-07-28 11:36:

While working on a git branch for implementing UserInput
in layout/prepare/default/300_map_disks.sh
cf. https://github.com/rear/rear/issues/1431
I noticed in the recovery system:

RESCUE e205:~ # rear recover
...
Device sda has size 22548578304, 21474836480 expected
Switching to manual disk layout configuration.
Original disk /dev/sda does not exist in the target system.
Choose an appropriate replacement for /dev/sda
1) /dev/sda
2) /dev/sdb
3) Do not map /dev/sda
4) Use Relax-and-Recover shell and return back to here
(default 1 timeout 300 seconds)
4

Welcome to Relax-and-Recover. Run "rear recover" to restore your system !

rear> rear recover
ERROR: You cannot run rear from within the Relax-and-Recover shell !
rear>

The reason is /etc/motd in the recovery system
that results the misleading message for rear_shell.

I think the easiest way is to remove /etc/motd
from the recovery system when running "rear recover"
because I think that /etc/motd message is only needed
in the recovery system until the user launched "rear recover".
Alternatively when running "rear recover" the /etc/motd
content could be replaced by something better.

schlomo commented at 2017-07-28 11:38:

The /etc/motd is also shown from the logins so I prefer to keep it. Can we find a way to better isolate rear_shell from the system?

jsmeix commented at 2017-07-28 11:55:

A bit "hackish" but simple workaround could be
to move /etc/motd away in the rear_shell function
and restore it afterwards.
Next week I will play around and see...

jsmeix commented at 2017-07-28 11:57:

Hmmm...
while "rear recover" is running a /etc/motd message

Run "rear recover" to restore your system !

never ever makes sense so while "rear recover" is running
that message should really not be in /etc/motd.

schlomo commented at 2017-07-28 11:58:

That is right. I think the message is printed in '/etc/profile' which would be an easy place to fix (check if running inside rear and don't print).

But yes, feel free to change the implementation. Main goal is to give users a message after they log in, both locally and remote via SSH.

jsmeix commented at 2017-07-28 12:06:

Probably a simple static

Welcome to Relax-and-Recover.

message could be sufficient in all cases?

Perhaps plus hostname and IP address like

Welcome to Relax-and-Recover on $HOSTAME (192.168.100.1)

(if that is possible).

Perhaps it is even better when users who may have accidentally
logged in at a ReaR recovery system and don't know what that
thingy is about shouldn't get told to blindly run "rear recover"?

schlomo commented at 2017-07-28 13:56:

I disagree. I think that systems should always tell you the next obvious thing to do, so I would like to keep the hint about how to start the actual recovery. I am sure that this saves us a lot of GitHub issues :-)

jsmeix commented at 2017-07-31 14:30:

I also disagree.

I think that

Run "rear recover" to restore your system !

only makes sense as long as 'rear recover' was not started.

Assume one logs in from remote onto a ReaR recovery system
where 'rear recover' is currently running, then a plain

Welcome to Relax-and-Recover.

should be right.

Also as soon as 'rear recover' was run once (even when it was
aborted somewhere in the middle) the message

Run "rear recover" to restore your system !

is basically always wrong.

Either 'rear recover' had finished and another run could
damage the already restored system
or
'rear recover' had failed or was aborted and then
only the user who had run it before can know what to do
but others should never blindly just run 'rear recover' again.

Therefore from my current point of view it is best when
at the beginning of 'rear recover' /etc/motd gets replaced
by something like the simple

Welcome to Relax-and-Recover.

jsmeix commented at 2017-07-31 14:58:

For me https://github.com/rear/rear/pull/1436
seems to work o.k.but I cannot imagine all possible use-cases.

FWIW:
The rear_shell function in lib/linux-functions.sh calls

... bash --noprofile ...

but for me /etc/profile in the recovery system is read
regardless of the '--noprofile' option and in contrast to
what "man bash" reads (or as far as I can understand that).

jsmeix commented at 2017-08-01 07:31:

With https://github.com/rear/rear/pull/1436 merged
this issue should be sufficiently avoided
regardless that https://github.com/rear/rear/pull/1436
is probably not yet a final proper solution, cf.
https://github.com/rear/rear/pull/1436#pullrequestreview-53260207


[Export of Github issue for rear/rear.]