1#!/usr/bin/perl
2# 17.11.1999, Sampo Kellomaki <sampo@iki.fi>
3#
4# Open a file descriptor, fork, write password to fd from parent.
5# The password will be read from the fd by the child because -$fd was
6# passed as password.
7#
8# This method has the advantage that password is never trivially visible
9# using ps(1). Never-the-less, remember that root is always root.
10#
11# See also: `man perlipc' and `man perlfunc' for description of pipe.
12
13$password = shift;
14
15pipe R,W or die $!;
16
17if (fork) {
18    # Father comes here
19
20    close R;
21    print W $password;
22    close W;
23    exit;
24}
25
26close W;
27$fd = fileno(R);
28warn "The password file descriptor is $fd.\n";
29
30### Redirect stdin and stdout
31
32open STDIN, "README" or die;
33open STDOUT, ">dist.sig" or die;
34
35exec('./smime', '-ds', 'dist-id.pem', '-'.$fd);
36
37#EOF
38