Next Welcome to my ~/bin 89

Brief digression: printlp

        #!/usr/bin/suidperl
        use Fcntl 'O_WRONLY';
        my $printer = shift;
        exit 1 unless defined $printer;
        exit 2 unless $printer =~ m{^/dev/lp[a-zA-Z.0-9-]*\z};
        exit 3 unless -c $printer;
        my $group =  getgrgid((stat _)[5]);
        exit 4 unless $group eq 'lp';
        untaint($printer);
        sysopen PRINTER, $printer, O_WRONLY or exit 5;
        my($br, $buf);
        while ($br = read STDIN, $buf, 8192) {
          print PRINTER $buf;
        }
        exit 6 unless defined $br;
        close PRINTER or exit 7;
        exit 0;
        sub untaint {
          $_[0] =~ /(.*)/;
          $_[0] = $1;
        }


Next Menu Copyright © 2005 M. J. Dominus