bstinson / centos / t_functional

Forked from centos/t_functional 4 years ago
Clone

Blame tests/p_shadow-utils/41-pwconv_tests

Athmane Madjoudj 536354
#!/bin/bash
Athmane Madjoudj 536354
# Author: Iain Douglas <centos@1n6.org.uk>
Athmane Madjoudj 536354
Christoph Galuschka 06c925
t_Log "Running $0"
Athmane Madjoudj 536354
echo "*****************************************************************"
Athmane Madjoudj 536354
echo "Note: The original /etc/passwd and /etc/shadow files are saved to"
Athmane Madjoudj 536354
echo "directory /var/tmp/pwconv".
Athmane Madjoudj 536354
echo "*****************************************************************"
Athmane Madjoudj 536354
Athmane Madjoudj 536354
cleanup(){
Athmane Madjoudj 536354
echo "Reverting files to original state"
Athmane Madjoudj 536354
[[ -d /var/tmp/pwconv ]] && cp /var/tmp/pwconv/* /etc 
Athmane Madjoudj 536354
t_CheckExitStatus $?
Athmane Madjoudj 536354
}
Athmane Madjoudj 536354
Athmane Madjoudj 536354
# check that /etc/passwd and /etc/shadow exist before continuing.
Athmane Madjoudj 536354
[[ -e /etc/passwd && -e /etc/shadow ]] || { t_Log "FAIL: missing source file"; exit $FAIL; }
Athmane Madjoudj 536354
Athmane Madjoudj 536354
mkdir -p /var/tmp/pwconv || { t_Log "FAIL: Unable to create directory to save  source files in "; exit $FAIL; }
Athmane Madjoudj 536354
cp /etc/passwd /etc/shadow /var/tmp/pwconv || { t_Log "FAIL: Unable to save source files"; exit $FAIL; }
Athmane Madjoudj 536354
trap cleanup EXIT
Athmane Madjoudj 536354
echo "Running pwconv"
Athmane Madjoudj 536354
pwconv
Athmane Madjoudj 536354
t_CheckExitStatus $?
Athmane Madjoudj 536354