ssh: unify code style amongst ssh tests

You can use ie. diff/vimdiff to easily verify the effect of this change.

Signed-off-by: Jiri Jaburek <jjaburek@redhat.com>
Acked-by: Jan Stancek <jstancek@redhat.com>
ssh: remove unused ssh_set_passwd script

This script is not used anywhere in the suite. Furthermore,
the same functionality is already provided by passwd(1) itself:

  echo "my secret pass" | passwd --stdin myusername

Signed-off-by: Jiri Jaburek <jjaburek@redhat.com>
Acked-by: Jan Stancek <jstancek@redhat.com>
ssh: properly create/remove user home dir, if possible

(this change is identical across ssh01, ssh02, ssh03)

The main motivation is that "mkdir /home/userdir" is not sufficient
to ensure that a user can access that directory. mkdir does not account
for security labels (ie. SELinux), umask of the calling shell and
possibly other variables.
This change fixes the following error, which can be triggered in some
RHEL configurations using SELinux MLS policy:

  Could not chdir to home directory /home/ssh_usr3: Permission denied
  bash: /home/ssh_usr3/.bashrc: Permission denied

and even though ssh01 and ssh02 tests PASS successfully, they would not
reveal a possible TFAIL (user is able to login) due to the chdir/bash
fails shown above - both tests would falsely PASS in a scenario where
ssh login was successful, matching ssh-unrelated "Permission denied".
This is not yet fixed.

The mkdir of home dir was actually happening in tst_setup, a quick fix
(workaround) - instead of this slightly more invasive rewrite - could
therefore be as simple as doing `rm -Rf' directly on /home/$TEST_USER
and not setting TCtmp, letting useradd -m create the homedir.

The do_cleanup trap has been moved up to perform userdel in case
something in do_setup fails.

Signed-off-by: Jiri Jaburek <jjaburek@redhat.com>
Acked-by: Jan Stancek <jstancek@redhat.com>
ssh: try to prevent invalid PASS when remote cmd fails

This change does not guarantee elimination of false PASS results,
but it makes them somewhat less likely to occur by matching sshd-like
Permission denied line. The regexp doesn't use ^ or $ or any kind of
more precise matching due to numerous problems with `expect' handling
the more complicated regexp strings across versions.

Signed-off-by: Jiri Jaburek <jjaburek@redhat.com>
Acked-by: Jan Stancek <jstancek@redhat.com>
ssh: don't use crypt-based pre-encrypted passwords

This change makes the ssh tests use passwd --stdin instead of
the -p argument to useradd, enabling the test to use the system-default
encryption algorithm defined in login.defs (ENCRYPT_METHOD), ensuring
greater compatibility.

Furthermore, the original hashes were wrong, at least for ssh01 and 02,
  'now_this_is_a_good_ltp_test_password' + salt '42' = 42lB8bQmUez4U
  'eal' + salt '42' = 42VmxaOByKwlA

The incorrect usage of now_this_is_a_good_ltp_test_password as PASSWD
with 42VmxaOByKwlA as ENCRYPTED_PASSWD in ssh0[12] dates back to 2004,
meaning those tests couldn't have failed (by a successful login) since
then (at least).

Signed-off-by: Jiri Jaburek <jjaburek@redhat.com>
Acked-by: Jan Stancek <jstancek@redhat.com>