1#!/usr/bin/perl -w 2 3# Sample password prompt program. Demonstration of how to interface with 4# encfs's --extpass option. Note that encfs's extpass interface was chosen to 5# work with existing password prompt programs, like ssh-askpass. 6# 7# The external password program is expected to somehow prompt for the password 8# and return the password on stdout. Encfs also provides some extra 9# information which is stored in environment variables. 10# 11# Quick Start: The only necessary part of this script for encfs operation is 12# the final part which prints the password to stdout. 13# 14# Encfs records some environment variables with useful information: 15# "encfs_root" holds a path to the raw encrypted data. 16# "encfs_stdout" holds a file descriptor number which will display data to 17# standard output (because standard output is used for the password). 18# "encfs_stderr" holds a file descriptor number which for standard error.. 19 20use strict; 21use IO::Handle; 22 23# find out where we can send data to display to the user (assuming encfs was 24# started in a terminal!) 25my $realOut = $ENV{"encfs_stdout"} || fileno(STDOUT); 26#my $realErr = $ENV{"encfs_stderr"} || fileno(STDERR); 27#my $rootDir = $ENV{"encfs_root"} || "[unknown]"; 28#system("xmessage realOut=$realOut, err=$realErr"); 29 30# for grins, show all encfs related environment variables to encfs's standard 31# output 32my $io = new IO::Handle; 33if($io->fdopen($realOut, "w")) 34{ 35 while (my ($key,$value) = each %ENV) 36 { 37 $io->print("$key=$value\n") if($key=~/encfs/); 38 } 39} 40$io->close(); 41 42## XXX XXX - This is the only part necessary for encfs to be happy. 43# the functional part -- print the encfs password to stdout 44print "test\n"; 45 46