bstinson / centos / t_functional

Forked from centos/t_functional 4 years ago
Clone

Blame tests/p_shadow-utils/42-pwunconv_tests

Athmane Madjoudj 536354
#!/bin/bash
Athmane Madjoudj 536354
# Author: Iain Douglas <centos@1n6.org.uk>
Athmane Madjoudj 536354
Athmane Madjoudj 536354
echo "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/pwunconv".
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/pwunconv ]] && cp /var/tmp/pwunconv/* /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/pwunconv || { t_Log "FAIL: Unable to create directory to save  source files in "; exit $FAIL; }
Athmane Madjoudj 536354
cp /etc/passwd /etc/shadow /var/tmp/pwunconv || { t_Log "FAIL: Unable to save source files"; exit $FAIL; }
Athmane Madjoudj 536354
trap cleanup EXIT
Athmane Madjoudj 536354
echo "Running pwunconv"
Athmane Madjoudj 536354
pwunconv
Athmane Madjoudj 536354
t_CheckExitStatus $?
Athmane Madjoudj 536354