File: template-md5sum

package info (click to toggle)
pam 1.7.0-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 7,928 kB
  • sloc: ansic: 36,046; xml: 21,666; perl: 972; sh: 834; yacc: 412; lex: 64; makefile: 56; python: 21
file content (51 lines) | stat: -rwxr-xr-x 970 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl
use IPC::Open2;


	my($template) = @ARGV;
	my $state = 0;

	open(INPUT,$template) || return '';
	my($md5sum_fd,$output_fd);
	my $pid = open2($md5sum_fd, $output_fd, 'md5sum');
	return '' if (!$pid);

	while (<INPUT>) {
		if ($state == 1) {
			if (/^# here's the fallback if no module succeeds/) {
				print $output_fd $_;
				$state++;
			}
			next;
		}
		if ($state == 3) {
			if (/^# end of pam-auth-update config/) {
				print $output_fd $_;
				$state++;
			}
			next;
		}

		print $output_fd $_;

		my ($pattern,$val);
		if ($state == 0) {
			$pattern = '^# here are the per-package modules \(the "Primary" block\)';
		} elsif ($state == 2) {
			$pattern = '^# and here are more per-package modules \(the "Additional" block\)';
		} else {
			next;
		}

		if (/$pattern/) {
			$state++;
		}
	}
	close(INPUT);
	close($output_fd);
	my $md5sum = <$md5sum_fd>;
	close($md5sum_fd);
	waitpid $pid, 0;

	$md5sum = (split(/\s+/,$md5sum))[0];
	print $md5sum;