This file is indexed.

/usr/bin/wmk is in wml 2.0.12ds1-7.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
#!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
    if $running_under_some_shell;
##
##  WMk -- Website META Language Make
##  
##  Copyright (c) 1996-2001 Ralf S. Engelschall.
##  Copyright (c) 1999-2001 Denis Barbier.
##  
##  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
##  the 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.
##  
##  You should have received a copy of the GNU General Public License
##  along with this program; if not, write to
##  
##      Free Software Foundation, Inc.
##      59 Temple Place - Suite 330
##      Boston, MA  02111-1307, USA
##  
##  Notice, that ``free software'' addresses the fact that this program
##  is __distributed__ under the term of the GNU General Public License
##  and because of this, it can be redistributed and modified under the
##  conditions of this license, but the software remains __copyrighted__
##  by the author. Don't intermix this with the general meaning of 
##  Public Domain software or such a derivated distribution label.
##  
##  The author reserves the right to distribute following releases of
##  this program under different conditions or license agreements.
##

require 5.003;

BEGIN { $^W = 0; } # get rid of nasty warnings

$VERSION = "2.0.12 (16-Apr-2008)";

use lib "/usr/lib/wml/perl/lib";
use lib "/usr/lib/wml/perl/lib/x86_64-linux-gnu-thread-multi";

use Term::Cap;
use Getopt::Long 2.13;
use Cwd;
use File::Find;

##
##  INIT
##

if ($ENV{'PATH'} !~ m|/usr/bin|) {
    $ENV{'PATH'} = '/usr/bin:'.$ENV{'PATH'};
}

$WML = $ENV{'WML'} || '/usr/bin/wml';

eval "\$term = Tgetent Term::Cap { TERM => undef, OSPEED => 9600 }";
if ($@) {
    $bold = '';
    $norm = '';
}
else {
    $bold = $term->Tputs('md', 1, undef);
    $norm = $term->Tputs('me', 1, undef);
}

##
##  PROCESS ARGUMENT LINE
##

sub usage {
    my ($progname) = @_;
    my ($o);

    print STDERR "Usage: $progname [options] [path ...]\n";
    print STDERR "\n";
    print STDERR "Operation Options (WMk intern):\n";
    print STDERR "  -a, --all               run for all files recursively\n";
    print STDERR "  -A, --accept=WILDMAT    accept files via shell wildcard matching\n";
    print STDERR "  -F, --forget=WILDMAT    forget files which were previously accepted\n";
    print STDERR "  -o, --outputfile=PATH   specify the output file(s)\n";
    print STDERR "  -x, --exec-prolog=PATH  execute a prolog program in local context\n";
    print STDERR "  -X, --exec-epilog=PATH  execute a epilog program in local context\n";
    print STDERR "  -f, --force             force outpout generation\n";
    print STDERR "  -n, --nop               no operation (nop) mode\n";
    print STDERR "  -r, --norcfile          no .wmkrc and .wmlrc files are read\n";
    print STDERR "\n";
    $o = `$WML --help 2>&1`;
    $o =~ s|^.+?\n\n||s;
    $o =~ s|^.+?--noshebang.+?\n||m;
    $o =~ s|^.+?--norcfile.+?\n||m;
    $o =~ s|^.+?--outputfile.+?\n||m;
    print STDERR $o;
    exit(1);
}

sub ProcessOptions {
    $Getopt::Long::bundling = 1;
    $Getopt::Long::getopt_compat = 0;
    local $SIG{'__WARN__'} = sub {
        print STDERR "WMk:Error: $_[0]";
    };
    if (not Getopt::Long::GetOptions(
            "a|all",
            "A|accept=s@",
            "F|forget=s@",
            "x|exec-prolog=s@",
            "X|exec-epilog=s@",
            "f|force",
            "n|nop",
            "r|norcfile",
            "I|include=s@", 
            "i|includefile=s@", 
            "D|define=s@",
            "O|optimize=i",
            "o|outputfile=s@",
            "P|prologue=s@",
            "E|epilogue=s@",
            "t|settime",
            "p|pass=s@",
            "W|passoption=s@",
            "M|depend:s",
            "s|safe",
            "v|verbose:i",
            "q|quiet",
            "z|mp4h",
            "V|version:i",
            "h|help"
    )) {
        print STDERR "Try `$0 --help' for more information.\n";
        exit(0);
    }
    &usage($0) if ($opt_h);
}

sub error {
    my ($str) = @_;
    print STDERR "** WMK:Error: $str\n";
    exit(1);
}

#   save argument line
@ARGVLINE = @ARGV;

#   WMk options
$opt_a = 0;
@opt_A = ('*.wml');
@opt_F = ();
@opt_o = ();
@opt_x = ();
@opt_X = ();
$opt_f = 0;
$opt_r = 0;
$opt_n = 0;

#   WML options are read from the command line
@opt_I = ();
@opt_i = ();
@opt_D = ();
$opt_O = '';
@opt_P = ();
@opt_E = ();
$opt_t = 0;
@opt_p = ();
@opt_W = ();
$opt_M = '-';
$opt_s = 0;
$opt_v = -1;
$opt_q = 0;
$opt_h = 0;
$opt_V = -1;
$opt_z = 0;

&ProcessOptions();

#   fix the version level
if ($opt_V == 0) {
    $opt_V = 1; # Getopt::Long sets 0 if -V only
}
if ($opt_V == -1) {
    $opt_V = 0; # we operate with 0 for not set
}
if ($opt_V) {
    system("$WML -V$opt_V");
    exit(0);
}

#   If the -M was the last option and the user forgot
#   to put `--' to end options, we adjust it.
if ($opt_M !~ m%^(-|[MD]*)$% && $#ARGV == -1) {
    push(@ARGV,$opt_M);
    $opt_M = '';
}

##
##   CREATE WML COMMAND
##

#   escape options if not quoted but
#   when shell metachars exists
sub quotearg {
    my ($arg) = @_;
    if ($arg !~ m|^'.*'$| and $arg !~ m|^".*"$|) {
        if ($arg =~ m|[\[\]()!*?&"']|) {
            $arg =~ s|'|\\'|sg;
            $arg = "'".$arg."'";
        }
    }
    return $arg;
}

sub addquotedarg {
    my ($flag, $arg) = @_;
    return ' -'.$flag.' "'.&quotearg($arg).'"';
}

$Oq = '';
$Oq = ' -q' if ($opt_q);

$Oz = '';
$Oz = ' -z' if ($opt_z);

$Ov = '';
$Ov = ' -v' if ($opt_v == 0);
$Ov = ' -v'.$opt_v if ($opt_v > 0);

$Op = '';
foreach $a (@opt_p) { $Op .= ' -p'.$a; }

$OW = '';
foreach $a (@opt_W) { $OW .= &addquotedarg('W', $a); }

$OD = '';
foreach $a (@opt_D) { $OD .= &addquotedarg('D', $a); }

$OP = '';
foreach $a (@opt_P) { $OP .= &addquotedarg('P', $a); }

$OE = '';
foreach $a (@opt_E) { $OE .= &addquotedarg('E', $a); }

$OM = '';
$OM = " -M$opt_M" if ($opt_M ne '-');

$Ot = '';
$Ot = ' -t' if ($opt_t);

$Or = '';
$Or = ' -r' if ($opt_r);

$Os = '';
$Os = ' -s' if ($opt_s);

$OI = '';
foreach $a (@opt_I) { $OI .= &addquotedarg('I', $a); }

$Oi = '';
foreach $a (@opt_i) { $Oi .= &addquotedarg('i', $a); }

$OO = '';
$OO = ' -O'.$opt_O if ($opt_O ne '');

$wml_cmd = "$WML -n".$Oq.$Oz.$Ov.$Op.$OW.$OD.$OP.$OE.$OM.$Ot.$Os.$Or.$OI.$Oi.$OO;
$wml_ipp = "$WML -n -MM".$Oq.$Oz.$Ov.$Op.$OW.$OD.$OP.$OE.$OM.$Ot.$Os.$Or.$OI.$Oi.$OO;

$Oo = '';
foreach $a (@opt_o) { $Oo .= ' -o'.$a; }

#   store initial working directory
my $cwd = Cwd::cwd;

##  read $HOME/.wmkrc
my @pwinfo = getpwuid($<);
my $home = $pwinfo[7];
$home =~ s|/$||;
if (-f "$home/.wmkrc") {
        chdir ($home);
        &read_rcfile();
        chdir ($cwd);
}

##
##   FILESYSTEM PROCESSING
##

sub CanonPath {
    my ($path) = @_;

    $pathL = '';
    while ($path ne $pathL) {
        $pathL = $path;
        $path =~ s|//|/|g;
        $path =~ s|/\./|/|g;
        $path =~ s|/\.$|/|g;
        $path =~ s|^\./(.)|$1|g;
        $path =~ s|([^/.][^/.]*)/\.\.||;
    }
    return $path;
}

#    this variable is defined in read_rcfile
$matchF = '';

#   set the path to act on
if ($#ARGV == -1) {
    @P = ( '.' );
}
else {
    @P = @ARGV;
}
foreach $p (@P) {
    if (-d $p) {
        if ($opt_a) {
            #
            #   path is a directory and we run recursively
            #
            #   first look into .wmkrc in case -F option is found
            chdir($p);
            &read_rcfile();
            chdir($cwd);

            @dirs = ();
            sub wanted {
              -d $_ &&
              ( m#^${matchF}$# && ($File::Find::prune = 1)
                               || push (@dirs, $File::Find::name));
            }
            File::Find::find(\&wanted, $p);
            $dirC = '';
            foreach $dir (@dirs) {
                $dir =~ s|\n$||;
                chdir($dir);
                &read_rcfile() if $dir ne $p;
                @files = &determine_files();
                if ($#files > -1) {
                    #   a little bit verbosity
                    if ($dirC ne $dir) {
                        $dirC = $dir;
                        $dirtxt = &CanonPath($dir);
                        if ($dirtxt ne '.') {
                            print STDERR "${bold}[$dirtxt]${norm}\n";
                        }
                    }
                    foreach $exec (@opt_x_CUR) {
                        $rc = system($exec);
                        error("prolog failed: $exec") if $rc != 0;
                    }
                    foreach $file (@files) {
                        &process_file("$dir/$file", $dir, $file);
                    }
                    foreach $exec (@opt_X_CUR) {
                        $rc = system($exec);
                        error("epilog failed: $exec") if $rc != 0;
                    }
                }
                chdir($cwd);
            }
        }
        else {
            #
            #   path is a directory and we run locally
            #
            chdir($p);
            &read_rcfile();
            next if $p =~ m#^${matchF}$#;
            @files = &determine_files();
            foreach $exec (@opt_x_CUR) {
                $rc = system($exec);
                error("prolog failed: $exec") if $rc != 0;
            }
            foreach $file (@files) {
                &process_file("$p/$file", $p, $file);
            }
            foreach $exec (@opt_X_CUR) {
                $rc = system($exec);
                error("epilog failed: $exec") if $rc != 0;
            }
            chdir($cwd);
        }
    }
    elsif (-f $p) {
        #
        #   path is a file
        #
        next if $p =~ m#^${matchF}$#;

        my ($dir, $file) = ($p =~ m|^(.*?)([^/]+)$|);
        if ($dir) {
            chdir($dir);
            &read_rcfile();
            &process_file($p, $dir, $file);
            chdir($cwd);
        }
        else {
            &read_rcfile();
            &process_file($p, $dir, $file);
        }
    }
    else {
        error("path `$p' neither directory nor plain file");
    }
}

#   read .wmkrc files and command-line options
sub read_rcfile {
    my ($cwd, $dir, @DIR);
    @opt_A_SAV = @opt_A;
    @opt_F_SAV = @opt_F;
    @opt_x_SAV = @opt_x;
    @opt_X_SAV = @opt_X;
    @opt_o_SAV = @opt_o;
    @opt_A_CUR = @opt_A;
    @opt_F_CUR = @opt_F;
    @opt_x_CUR = @opt_x;
    @opt_X_CUR = @opt_X;
    $opt_o_CUR = '';
    if (not $opt_r) {
        ($cwd = Cwd::cwd) =~ s|/$||;
        while ($cwd) {
            push(@DIR, $cwd);
            $cwd =~ s|/[^/]+$||;
        }
        foreach $dir (reverse(@DIR)) {
            if (-f "$dir/.wmkrc") {
                open(FP, "<$dir/.wmkrc")
                        || error("Unable to load $dir/.wmkrc: $!");
                @ARGV = ();
                while (<FP>) {
                    next if (m|^\s*\n$|);
                    next if (m|^\s*#[#\s]*.*$|);
                    s|^\s+||;
                    s|\s+$||;
                    s|\$([A-Za-z_][A-Za-z0-9_]*)|$ENV{$1}|ge;
                    push(@ARGV, &split_argv($_));
                }
                close(FP) || error("Unable to close $dir/.wmkrc: $!");
                @opt_A = ();
                @opt_F = ();
                @opt_x = ();
                @opt_X = ();
                @opt_o = ();
                &ProcessOptions();
                @opt_A_CUR = (@opt_A_CUR, @opt_A);
                @opt_F_CUR = (@opt_F_CUR, @opt_F);
                @opt_x_CUR = (@opt_x_CUR, @opt_x);
                @opt_X_CUR = (@opt_X_CUR, @opt_X);
                if ($#opt_o > -1) {
                    $opt_o_CUR = '-o' . join(' -o', @opt_o);
                }
            }
        }
    }

    #   Add command-line options
    @opt_A = ();
    @opt_F = ();
    @opt_x = ();
    @opt_X = ();
    @opt_o = ();
    @ARGV  = @ARGVLINE;
    &ProcessOptions();
    @opt_A_CUR = (@opt_A_CUR, @opt_A);
    @opt_F_CUR = (@opt_F_CUR, @opt_F);
    @opt_x_CUR = (@opt_x_CUR, @opt_x);
    @opt_X_CUR = (@opt_X_CUR, @opt_X);
    if ($#opt_o > -1) {
        $opt_o_CUR = '-o' . join(' -o', @opt_o);
    }

    #    transforms filename wildcards into extended regexp
    if ($#opt_F_CUR > -1) {
        $matchF = '(' . join ('|', @opt_F_CUR) . ')';
        $matchF =~ s|\.|\\.|g;
        $matchF =~ s|\?|.|g;
        $matchF =~ s|\*|.*|g;
    }
    else {
        $matchF = '';
    }

    #   Restore values
    @opt_A = @opt_A_SAV;
    @opt_F = @opt_F_SAV;
    @opt_x = @opt_x_SAV;
    @opt_X = @opt_X_SAV;
    @opt_o = @opt_o_SAV;
}

#   determine files to act on
sub determine_files {
    my (@files, @filesA, @filesF, $fileA, $fileF, %files);

    #   determine files
    @filesA = glob(join(' ', @opt_A_CUR));
    @filesF = glob(join(' ', @opt_F_CUR));
    %files = ();
    foreach $fileA (@filesA) {
        $ok = 1;
        foreach $fileF (@filesF) {
            if ($fileA eq $fileF) {
                $ok = 0;
                last;
            }
        }
        $files{$fileA} = 1 if $ok;
    }
    @files = sort(keys(%files));

    return @files;
}

#   helper function to split argument line
#   the same way Bourne-Shell does:
#   #1: foo=bar quux   => "foo=bar", "quux"
#   #2: "foo=bar quux" => "foo=bar quux"
#   #3: foo="bar quux" => "foo=bar quux"     <-- !!
sub split_argv {
    my ($str) = @_;
    my (@argv) = ();
    my ($r) = '';

    while (1) {
        next if $str =~ s|^"([^"\\]*(?:\\.[^"\\]*)*)"(.*)$|$r .= $1, $2|e;
        next if $str =~ s|^'([^'\\]*(?:\\.[^'\\]*)*)'(.*)$|$r .= $1, $2|e;
        next if $str =~ s|^([^\s"']+)(.*)$|$r .= $1, $2|e;
        if ($str =~ m|^[\s\n]+| || $str eq '') {
            if ($r ne '') {
                push(@argv, $r);
                $r = '';
            }
            $str =~ s|^[\s\n]+||;
            last if ($str eq '');
        }
    }
    return @argv;
}

sub process_file {
    my ($path, $dir, $file) = @_;
    my ($shebang, $opts, $out);
    local (*FP);

    #   determine additional options
    $opts = $Oo;
    if ($opts eq '') {
        $opts = $opt_o_CUR;
        open(FP, "<$file") || error("Unable to load $file: $!");
        $shebang = '';
        while (1) {
            $shebang .= <FP>;
            if ($shebang =~ m|^(.*)\\\s*$|s) {
                $shebang = $1;
                next;
            }
            last;
        }
        if ($shebang =~ m|^#!wml\s+(.+\S)\s*$|is) {
           $opts = $1;
        }
        close(FP) || error("Unable to close $file: $!");
    }

    #   expand %DIR and %BASE
    my $base = $file;
    $base =~ s|\.[a-zA-Z0-9]+$||;
    $opts =~ s|%DIR|$dir|sg;
    $opts =~ s|%BASE|$base|sg;

    #   determine default output file
    if ($opts !~ m|-o|) {
        $opts .= " -o ${base}.html";
    }
    $opts =~ s|(\s*)(\S+)|' '.&quotearg($2)|sge;
    $opts =~ s|^\s+||;
    $opts =~ s|\s+$||;

    #   determine if invocation can be skipped
    if (not $opt_f) {
        my @outfiles = ();
        my $s = $opts;
        $s =~ s|-o\s*["']?(?:[^:]+:(?!:))?([^\s\@'"]+)|push(@outfiles, $1), ''|sge;
        $skipable = &skipable($file, @outfiles);
    }
    else {
        $skipable = 0;
    }
    
    if ($skipable) {
        print STDERR "$wml_cmd $opts $file  (${bold}skipped${norm})\n";
    }
    else {
        print STDERR "$wml_cmd $opts $file\n";
        if (not $opt_n) {
            $rc = system("$wml_cmd $opts $file");
            error("Error in WML (rc=$rc)") if $rc != 0;
        }
    }
}

#   is file skipable because not newer than
#   any of its output files
sub skipable {
    my ($file, @outfiles) = @_;
    my ($skipable, $outfile, $t, $dep, $incl);
    my (@IS, @OS);

    $skipable = 1;
    @IS = stat($file);
    local($/) = undef;
    open(DEP, "$wml_ipp -odummy $file |")
        || error("Unable to exec $wml_ipp: $!");
    $dep = <DEP>;
    close(DEP) || error("Unable to close exec $wml_ipp: $!");
    $dep =~ s/\\\s+/ /sg;
    if ($dep =~ m|^(.*):\s+(.*?)\s+(.*)$|) {
        foreach $incl (split(/\s+/,$3)) {
            if (-f $incl) {
                @OS = stat(_);
                if ($IS[9] < $OS[9]) { # 9=mtime
                    $IS[9] = $OS[9];
                }
            }
       } 
    }
    
    foreach $outfile (@outfiles) {
        if (-f $outfile) {
            @OS = stat(_);
            if ($IS[9] >= $OS[9]) { # 9=mtime
                $skipable = 0;
                last;
            }
        }
        else {
            $skipable = 0;
            last;
        }
    }
    return $skipable;
}


#   exit gracefully
exit(0);

##EOF##