....................................../////.===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 : 205.196.210.190  /  Your IP : 216.73.217.21
Web Server : Apache
System : Linux pdx1-shared-a2-06 6.6.116-grsec-jammy-dirty #1 SMP Sat Nov 8 00:02:42 UTC 2025 x86_64
User : dh_2vi232 ( 5939701)
PHP Version : 8.2.29
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /bin/duck
#!/usr/bin/perl -w

# duck - the Debian Url Checker
# Copyright (C) 2017 Simon Kainz <skainz@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# he Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# On Debian GNU/Linux systems, the complete text of the GNU General
# Public License can be found in `/usr/share/common-licenses/GPL-2'.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, you can find it on the World Wide
# Web at https://www.gnu.org/copyleft/gpl.html, or write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.

use strict;

use lib '/usr/share/duck';
use lib '/usr/share/duck/lib';

use DUCK;
use Getopt::Std;
use Getopt::Long qw(:config pass_through );
use Data::Dumper;
use File::Basename;
use File::Temp qw(tempdir);
use File::Path qw(remove_tree);
use Cwd;
use IPC::Open3;
use POSIX ":sys_wait_h";
#require lib;
use Parallel::ForkManager;

sub HELP_MESSAGE();
sub setColor($;$);
sub display_result($;$;$);
sub display_blob($;$);
sub missingHelpers();
sub handle_UrlFixDisableOptions($;$);
sub handle_UrlFixEnableOptions($;$);						   
sub handle_dsc($);
sub cleanup();
sub get_duck_overrides();	       
sub is_overridden($;$);

our $color_r="\x1b[31m";
our $color_g="\x1b[32m";
our $color_y="\x1b[33m";
our $color_n="\x1b[0m"; 
our $abort=0;
my $origcwd=getcwd;

#$SIG{INT} = sub { $abort=1;cleanup();};
$SIG{INT} = sub { print $color_r."Aborting, please wait!\n".$color_n;$abort=1;cleanup();};


my $checksdir='/usr/share/duck/lib/checks';

my $try_https=0;
my $no_check_cert=0;
my $nocolor=0;
our $enforceColor="auto";
my @allowedColorVals=qw/always auto never/;

my $termcolors=0;
$termcolors=`/usr/bin/tput colors 2>/dev/null`;
if ($? eq 0 )
{
    if ($termcolors < 4)
    {
	$enforceColor="never";
    }
} else {
    $enforceColor="never";
}  

my $showMissingHelpers;
my $urlFixEnableOptions;
my $urlFixDisableOptions;
my $tempdir;
my @global_options=("n","v","q");
$Getopt::Std::STANDARD_HELP_VERSION=1;

my $exitcode=0;

our %opt;
our @overrides=get_duck_overrides();
my $dh;

my $parallel_tasks=24;

my $retval=GetOptions(
    "modules-dir=s" => \$checksdir,
    "no-https" => \$try_https,
    "no-check-certificate" => \$no_check_cert,
    "no-color" => \$nocolor,
    "missing-helpers" => \$showMissingHelpers,
    "disable-urlfix=s" => \$urlFixDisableOptions,
    "enable-urlfix=s" => \$urlFixEnableOptions,
    "color=s" => \$enforceColor,
    "colour=s" => \$enforceColor,
    "tasks=i" => \$parallel_tasks
    );

die("Number of parallel tasks must be >0") unless (int($parallel_tasks)>0);

my $DUCK= DUCK->new();
my $funcref= $DUCK->cb();

if ($showMissingHelpers)
{
    print "\n";
    my $mh=missingHelpers();
    if ($mh) {print $mh; exit(1)}
    else { print "All helpers installed.\n"; exit(0);}
    
}


if ($urlFixEnableOptions && $urlFixDisableOptions)
{
    print "Conflicting options: Either use --disable-urlfix or --enable-urlfix option.\n";
    exit 1;

}


if (!(   grep( /^$enforceColor$/, @allowedColorVals ) ))
{
    print STDERR "Invalid option \"".$enforceColor." \"for --color: Valid options are:".join(",",@allowedColorVals)."\n";
    exit 1;
    
}


if ($urlFixDisableOptions) { handle_UrlFixDisableOptions($DUCK,$urlFixDisableOptions);}
if ($urlFixEnableOptions) {handle_UrlFixEnableOptions($DUCK,$urlFixEnableOptions);}






if ($enforceColor eq "never" )
{
    $color_r="";
    $color_g="";
    $color_y="";
    $color_n="";
}



import lib $checksdir;

if (!opendir($dh,$checksdir))
{
 print STDERR "Modules directory $checksdir not found!, please use --modules-dir=<path> !\n";
 if ($opt{h})
 {
     HELP_MESSAGE();
   
 }
  exit(1);
}



my @modules;
my @module_options;

my $descriptions;

while (readdir $dh)
{
    my($filename, $directories, $suffix) = fileparse($_);
    if (/^\./) { next};
    if (/.pm$/)
    {
	require $_;
	my $modulename=fileparse($filename,qr/\.pm/);
	my $n="DUCK::".$modulename;
	if ($n->can("run"))
	{
	    push (@modules,$modulename);
	}
    }
}

if (!scalar @modules)
{
    print STDERR "No check modules found! Please check path: ".$checksdir."\n";
    exit 1;
}

#get all options modules are providing

foreach my $m (@modules)
{

    my $n="DUCK::".$m;
    if ( ($n->can("opts")) && ($n->can("run")) )
    {
	foreach ($n->opts())
	{
	    push(@module_options,$_);
	}
    }
    if ($n->can("desc"))
    {
       $descriptions.=$n->desc();
     }
}
push(@module_options,@global_options);

#print Dumper @module_options;

GetOptions(
      "help" => sub {HELP_MESSAGE() }
    );

getopts(join("",@module_options),\%opt);

if ( $opt{v} && $opt{q} ) 
{
    print STDERR " Please specify either -q or -v\n";
    exit(1);
}

if ( $opt{l} )
{
    $opt{S}=1;
    $opt{P}=1;
    $opt{F}=1;
    $opt{U}=1;
    $opt{C}=1;
    $opt{A}=1;
}

if (@ARGV) { 
    $checksdir=getcwd."/lib/checks";
    handle_dsc(\$tempdir) unless $opt{l};
}

my @entries;

my @resultarray;

my $finished_tasks=0;
#run all modules, create the list of checks to run.
foreach my $m (@modules)
{
    my $n="DUCK::".$m;
    $n->run(\%opt,\@entries);
}

# inject all options to check modules
$DUCK->setOptions("no-https",$try_https);
$DUCK->setOptions("no-check-certificate",$no_check_cert);


# iterate over all urls, run checks.

my $manager= new Parallel::ForkManager($parallel_tasks);


#$manager->run_on_finish( sub {
#    my ($pid)=@_;
#    print "** finished, pid: $pid\n";
#});
 


$manager->run_on_finish( sub {
       my ($pid, $exit_code, $ident, $exit_signal, $core_dump, $data_structure_reference) = @_;

        if (defined($data_structure_reference)) {  # children are not forced to send anything
      my $string = ${$data_structure_reference};  # child passed a string reference
#      print Dumper $string;
      push(@resultarray,$string);
      $finished_tasks++;
    }
    else {  # problems occurring during storage or retrieval will throw a warning
      print qq|No message received from child process $pid!\n|;
    }
 #   my ($pid, $exit_code) = @_;
#    print "** just got out of the pool ".
#      "with PID $pid and exit code: \n";
});
 
#my $entry;
 CHECKS:
foreach my $entry (@entries)
{
    my $res;
    
    $manager->start and next CHECKS unless $opt{n};
    {
    if ($abort) {cleanup(); exit};
    my $type=@$entry[0];
    my $k=@$entry[1];
    my $url=@$entry[2];
    my $origline=@$entry[3];
    my $extra=@$entry[4];

    chomp $origline unless !$origline;
  
    if ($funcref->{$k})
    {

	if (is_overridden(\@overrides,$url)) {
	    next;
	}
    

  if ($opt{n})
    {
         print STDOUT $type.": ".$k.": ".$url.": ";
	 print STDOUT " DRY RUN\n";
	 next;
    }

	$res=&{$funcref->{$k}}($url);
	

    }
}    
 $manager->finish(0,\{res=>$res,entry=>$entry}) unless $opt{n};
}

#print scalar(@resultarray)."\n";
#while ($abort == 0)
#{
#    print Dumper $manager;
#    sleep(1);
#}

$manager->wait_all_children unless $opt{n};

#print "Sizeof reuslts:".scalar(@resultarray)."\n";


foreach my $_res (@resultarray) {

    my $res=$_res->{"res"};

my $entry=$_res->{'entry'};

if (!defined($entry)) {next;}
if (!defined($res)) {next;}
    my $type=@$entry[0];
    my $k=@$entry[1];
    my $url=@$entry[2];
    my $origline=@$entry[3];
    my $extra=@$entry[4];



#    my $res=@{$_res}[0];

#print "DEPUG: entry";
#print Dumper $entry;
#print "DEBUG: res";
#print Dumper $res;
#print "-------------------\n";
#next;    
	if (!defined $res)
	{
	    if (!$opt{q})
	    {
		setColor(\*STDERR,$color_y);
		my $k;
		print STDERR "I: Skipping field ".$k." (Reason: Missing helper!)\n";
	        setColor(\*STDERR,$color_n);
	    }
	}
	else
	{ #print Dumper $res;
#	  my $extra;
	    if (ref($res) eq "ARRAY")
	    {#print "ARRAY!!!\n";
		foreach my $b (@$res)
		{
#		    print "mainloop:";
#		    print Dumper $extra;
		    display_blob($b,$extra);
		}
	    }
	    else
	    {
	#	print "BLOB\n";
		display_blob($res,$extra);
	    } 
	}

}

cleanup();
exit($exitcode);

##############################################################################
# Helper functions

sub display_blob($;$) {
    (my $res,my $extra)=@_;
#print "Display_blob, extra:";
#print Dumper $extra;    

    if ($res->{retval}>0)
    {
	
	if ($res->{'certainty'}) { $extra->{'certainty'}=$res->{'certainty'};}
	
	if ($res->{retval}==2)
	{
	    
	    if (!$opt{q})
	    {
		setColor(\*STDERR,$color_y);
		print STDERR display_result($res,$extra);
		setColor(\*STDERR,$color_n);
	    }
	    
	} else
	{
	    if (!$opt{q})
	    {
		setColor(\*STDERR,$color_r);
		print STDERR display_result($res,$extra);
		setColor(\*STDERR,$color_n);
	    }
	    $exitcode=1;
	    
	}
	
    }
    else
    {
	if ($opt{v})
	{
	    setColor(\*STDOUT,$color_g);
	    print STDOUT display_result($res,$extra);
	    setColor(\*STDOUT,$color_n);
	}
    }
    
}


sub setColor($;$)
{
    my ($fh,$c)=@_;
    
    if ($enforceColor eq "never")
    {
	return;
	
    }
    
    if ($enforceColor eq "always")
    {
	print $fh $c;
	return;
    }    

    if ($enforceColor eq "auto")
    {
	if (-t $fh)
	{
	    print $fh $c;
	    return;
	}
    }
    
}

sub display_result($;$;$)
{
    
    my $out="";
    my ($res,$data)=@_;
#    print Dumper $res;
#    print "DATA:";
#    print Dumper $data;
    my $prefixes={ 0 => "O: ",
		   1 => "E: ",
		   2 => "I: "
    };

    my $states={ 0 => "OK",
		 1 => "ERROR",
		 2 => "INFORMATION"
    };
    my $P;
    if ($prefixes->{$res->{retval}}) 
    {
	$P=$prefixes->{$res->{retval}};
    }
    else
    {
	$P=$prefixes->{1}; # default to Error if return value > 0 and out of bounds
    }
    $out.=$P;
    my $indent=$P;
    $indent =~ s/./ /g;
    
    
# try to print data supplied by check
    if ($data->{verbose})
    {
	$out.=$data->{verbose};
	if ($states->{$res->{retval}})
	{
	    $out.=': '.$states->{$res->{retval}};
        } else
    	{
	    $out.=': '.$states->{1};
    	}
	$out.=' (Certainty:'.$data->{certainty}.')';
	$out.="\n";
    } else

    {


	if ($data->{filename})
	{
	    $out.=$data->{filename}.":";
	}
	if ($data->{linenumber})
	{
	    $out.= $data->{linenumber}.": ";
	}
	
	if ($data->{checkmethod})
	{
	    $out.=$data->{checkmethod}.": ";
	}
	if ($data->{url})
	{
	    $out.=$data->{url}.": ";
	}

	$res->{retval}=2  unless $res->{retval}<2;
    
	$out.=$states->{$res->{retval}};
	$out.=' (Certainty:'.$data->{certainty}.')';
	$out.="\n";
    }
    
    if ( $res->{response} && ($res->{retval}>0) )
    {
	my $ts=$res->{response};
	$ts =~ s/\n*$//g;
	$ts =~ s/^/$indent/g;
	$ts =~ s/\n/\n$indent/g;

	$out.=$ts;
	
    }


    $out =~ s/\n*$//g;
    $out.="\n\n";
    

    return $out ;
    
}

sub handle_UrlFixDisableOptions($;$) {
    
    my ($duck,$paramlist)=(@_);
    
    my @fixes=split(/,/,$paramlist);

    foreach ($duck->getUrlFixes())
    {
	$duck->setUrlFixOptions($_,1);
    }
    
    foreach (@fixes) {
	$duck->setUrlFixOptions($_,0);
    }

}

sub handle_UrlFixEnableOptions($;$)
{
    
    my ($duck,$paramlist)=(@_);
    
    my @fixes=split(/,/,$paramlist);

    foreach ($duck->getUrlFixes())
    {
	$duck->setUrlFixOptions($_,0);
    }
    
    foreach (@fixes) {
	$duck->setUrlFixOptions($_,1);
    }

}

sub handle_dsc($) {

    my ($tmpdirref)=@_;
        
    my $tempdir = File::Temp->newdir(TEMPLATE=>"duckXXXXXX",TMPDIR => 1,CLEANUP => 0)->dirname;
    $$tmpdirref=$tempdir;
    my $filename=fileparse($ARGV[0]);

    print "Downloading to $tempdir"."\n";
    
    chdir($tempdir);

    my ($html)=@_;
    my $pid=open3(0,\*READ,\*ERR,'dget -d '.$ARGV[0]) or die("dget error!");
    my @std_output=<READ>;
    my @std_err=<ERR>;
    my $kid;
    do {
	$kid=waitpid($pid,WNOHANG);
	sleep(1);
    } while ($kid >0 && $abort == 0);
    if ($abort) {kill -9,$pid;cleanup(); exit}
    close(READ);
    my $prefix="dget: ";

    if ($opt{'v'})
    {
	chomp @std_output;
	setColor(\*STDOUT,$color_y);
	print join("\n$prefix",@std_output);
	print "\n\n";
    }
 
    $pid=open3(0,\*READ,\*ERR,"dpkg-source -x $filename extract") or die("dpkg-source error!");

    @std_output=<READ>;
    @std_err=<ERR>;
    do {
	$kid=waitpid($pid,WNOHANG);
	    my $dpkgsource_errcode=$?;
    print "errcode: $dpkgsource_errcode\n";

	sleep(1);
    } while ($kid >0 && $abort==0);
    if ($abort) {kill -9,$pid;cleanup(); exit}

    
    close(READ);
    $prefix="dpkg-source: ";
    if ($opt{'v'})
    {
	chomp @std_output;
	setColor(\*STDOUT,$color_y);;
	print join("\n$prefix",@std_output);
	print "\n";

	chomp @std_err;
	setColor(\*STDOUT,$color_r);
	print join("\n$prefix",@std_err);
	print "\n\n";

	
    }
 
   
    chdir($tempdir."/extract");
    if ($opt{'v'})
    {
	setColor(\*STDOUT,$color_n);
    }

    return $tempdir;
}



sub cleanup()
{
    chdir($origcwd);
    #restore terminal color
    print $color_n;
    if ($tempdir && -d $tempdir ) {
	
	if ($opt{v}) {
	    print "removing tempdir $tempdir\n";
	}
	remove_tree($tempdir);
}
}

sub get_duck_overrides()
{
    my $overrides_path='debian/duck-overrides';
    my @overrides;
    
    if ( -e $overrides_path)
    {
	open (my $overrides_fh,"<",$overrides_path);
	@overrides=<$overrides_fh>;
	close($overrides_fh);
	
    }
    chomp(@overrides);

	my @results;

    foreach (@overrides)
    {
	if ( ! /^\s*#/)
	{
	    if (length($_)>1) {push (@results,$_);}
	}
	
    }
    return @results;
}

sub is_overridden($;$)
		  {
		      my ($overrides_ref,$url)=(@_);
		      
		      my @overrides=@{$overrides_ref};
		      
		      foreach my $ov (@overrides)
		      {
			  if ( $url =~ m/$ov/i)
			  {
			      return 1;
			  }
		      }
		      return 0;
		  }


sub get_domain()
{
    my $url=$_[0];

    $url =~ /:\/\/([^\/].*)/;
    if (!$1) {return 0};
    my @dom=split(/\//,$1);
    
    return $dom[0];
}


sub HELP_MESSAGE()
{

if (!$descriptions)
{
    $descriptions="  No modules, found, no further options available.\n";
}
print STDOUT <<EOF;

Usage: duck [options] 

  -h\t--help\t\t\tdisplay this usage information and exit
  -q\t\t\t\tquiet mode, suppress all output
  -v\t\t\t\tverbose mode
  -n\t\t\t\tdry run, don't run any checks, just show what would be checked
  --modules-dir=dir\t\tpath to check modules
  --no-https\t\t\tdo not try to find matching https URLs to http URLs
  --no-check-certificate\tdo not check SSL certificates
  --color=[auto,always,never]\tauto (default): color on terminal, no color when piping output
\t\t\t\tor dumb terminal
\t\t\t\tnever: no color output
\t\t\t\talways: show colored output always

  --missing-helpers\t\tdisplay list of missing external helper tools

  --disable-urlfix=<fix1,...>\tdisable specified url fix function(s). Use --disable-urlfix=list or 
  \t\t\t\tsee duck(1) for available options and further information.
  --enable-urlfix=<fix1,...>\tenable specified url fix function(s).  Use --enable-urlfix=list or 
  \t\t\t\tsee duck(1) for available options and further information.

  --tasks=[number]\t\tSpecify the number of checks allowed to run in parallel. Default value is 24. 
\t\t\t\tThis value must be an integer value >0.

  --version\t\t\tdisplay copyright and version information
  Available module options:

EOF
print $descriptions;
print "\n";
    exit(0);
}

sub VERSION_MESSAGE()
{
    my $DUCK=DUCK->new();
    print "duck ".$DUCK->version()."\n";
    my $copyright_year=$DUCK->copyright_year();

print <<EOF;
This code is copyright $copyright_year by Simon Kainz <skainz\@debian.org>
all rights reserved.
This program comes with ABSOLUTELY NO WARRANTY.
You are free to redistribute this code under the terms of the
GNU General Public License, version 2 or later.

EOF
}

sub missingHelpers()
{
    my $DUCK=DUCK->new();
    my $out;
    my $h=$DUCK->getHelpers();
    
    if (!$h->{git}) { $out.= "git missing. Please install package git.\n"; }
    if (!$h->{bzr}) { $out.= "bzr missing. Please install package bzr.\n"; }
    if (!$h->{svn}) { $out.= "svn missing. Please install package subversion.\n"; }
    if (!$h->{hg}) { $out.= "hg missing. Please install package mercurial.\n"; }
    
    return $out;
    

}


Youez - 2016 - github.com/yon3zu
LinuXploit