Haven't tried it, but this might be what you are looking for.
http://www.postfix.org/SMTPD_POLICY_README.html#advanced
check_policy_service { inet:host:port,
timeout=10s, default_action=DUNNO
policy_context=submission }
...
From the SMTPD_POLICY_README:
The "policy_context" attribute provides a way to pass information that
is not available via other attributes (Postfix version 3.1 and later).
I notice when using SMTPD_DELAY_REJECT=yes and calling a
CHECK_POLICY_SERVICE inside SMTPD_HELO_RESTRICTIONS it will report
"protocol_state = RCPT", same as when you call the policy service from
inside SMTPD_RECIPIENT_RESTRICTIONS.
Is there a way to pass a value from the CHECK_POLICY_SERVICE line (or
any other method), to know which restriction section the policy service
is being ran inside of?
Could you give us a bit more details about what are you trying to do? :)
Cheers,
K.