[PC-BSD Commits] r19338 - pcbsd/current/src-sh/pc-adctl/scripts

svn at pcbsd.org svn at pcbsd.org
Tue Sep 18 20:21:15 PDT 2012


Author: johnh
Date: 2012-09-19 03:21:15 +0000 (Wed, 19 Sep 2012)
New Revision: 19338

Modified:
   pcbsd/current/src-sh/pc-adctl/scripts/pc-pam
Log:
Don't write out the same configuration to pam files multiple times.



Modified: pcbsd/current/src-sh/pc-adctl/scripts/pc-pam
===================================================================
--- pcbsd/current/src-sh/pc-adctl/scripts/pc-pam	2012-09-19 02:29:12 UTC (rev 19337)
+++ pcbsd/current/src-sh/pc-adctl/scripts/pc-pam	2012-09-19 03:21:15 UTC (rev 19338)
@@ -164,6 +164,21 @@
 	return $?
 }
 
+pam_service_configured()
+{
+	local pam_file="${1}"
+	local pam_str="${2}"
+
+	local str="$(echo "${pam_str}" | sed -E 's|^(([+\-^])?([0-9]+)?)?||')"
+
+	local facility="$(echo "${str}" | cut -f1 -d:)"
+	local control="$(echo "${str}" | cut -f2 -d:)"
+	local module="$(echo "${str}" | cut -f3 -d:)"
+
+	egrep -q "${facility}[[:space:]]+${control}[[:space:]]${module}" "${pam_file}" 2>/dev/null
+	return $?
+}
+
 do_pam_conf()
 {
 	local auth="${1}"
@@ -206,35 +221,38 @@
 
 			if in_pam_services "${s}" "${services}"
 			then
-				if pam_auth_isset "${s}" && [ -n "${auth}" ]
+				if pam_auth_isset "${s}" && [ -n "${auth}" ] && \
+					! pam_service_configured "${pam_file}" "${auth}"
 				then
 					__auth="-m "${auth}""
 					doconf=1
 				else
 					__auth=""
 				fi
-				if pam_account_isset "${s}" && [ -n "${account}" ]
+				if pam_account_isset "${s}" && [ -n "${account}" ] && \
+					! pam_service_configured "${pam_file}" "${account}"
 				then
 					__account=" -m "${account}""
 					doconf=1
 				else
 					__account=""
 				fi
-				if pam_session_isset "${s}" && [ -n "${session}" ]
+				if pam_session_isset "${s}" && [ -n "${session}" ] && \
+					! pam_service_configured "${pam_file}" "${session}"
 				then
 					__session="-m "${session}""
 					doconf=1
 				else
 					__session=""
 				fi
-				if pam_password_isset "${s}" && [ -n "${password}" ]
+				if pam_password_isset "${s}" && [ -n "${password}" ] && \
+					! pam_service_configured "${pam_file}" "${password}"
 				then
 					__password="-m "${password}""
 					doconf=1
 				else
 					__password=""
 				fi
-				
 
 				if [ "${doconf}" = "1" ]
 				then



More information about the Commits mailing list