#!/bin/sh

if [ -z "$RPM_BUILD_ROOT" ]; then
	printf '%s\n' "No build root defined" >&2
	exit 1
fi

if [ ! -d "$RPM_BUILD_ROOT" ]; then
	printf '%s\n' "Invalid build root" >&2
	exit 1
fi

configs=$(find $RPM_BUILD_ROOT/etc/pam.d/ -type f ! -type l 2> /dev/null)
if [ -n "$configs" ]; then
	printf '%s\n' "Fixing pam.d config files..."
	sed -r 's,/(usr/)?(lib|lib64)/security/,,g' $configs
	printf '%s\n' "...done"
fi
