1 /* $RCSfile: usersub.c,v $$Revision: 4.1 $$Date: 92/08/07 18:28:45 $
3 * This file contains stubs for routines that the user may define to
4 * set up glue routines for C libraries or to decrypt encrypted scripts
8 * Revision 4.1 92/08/07 18:28:45 lwall
10 * Revision 4.0.1.2 92/06/08 16:04:24 lwall
11 * patch20: removed implicit int declarations on functions
13 * Revision 4.0.1.1 91/11/11 16:47:17 lwall
14 * patch19: deleted some unused functions from usersub.c
16 * Revision 4.0 91/03/20 01:55:56 lwall
31 * The following is supplied by John Macdonald as a means of decrypting
32 * and executing (presumably proprietary) scripts that have been encrypted
33 * by a (presumably secret) method. The idea is that you supply your own
34 * routine in place of cryptfilter (which is purposefully a very weak
35 * encryption). If an encrypted script is detected, a process is forked
36 * off to run the cryptfilter routine as input to perl.
48 #include "cryptlocal.h"
50 #else /* ndef CRYPTLOCAL */
52 #define CRYPT_MAGIC_1 0xfb
53 #define CRYPT_MAGIC_2 0xf1
61 while( (ch = getc( fil )) != EOF ) {
62 putchar( (ch ^ 0x80) );
66 #endif /* CRYPTLOCAL */
69 static FILE *lastpipefile;
79 my_pfiopen(fil,func) /* open a pipe to function call for input */
88 croak("Can't get pipe for decrypt");
91 /* make sure that the child doesn't get anything extra */
95 while ((pipepid = fork()) < 0) {
96 if (errno != EAGAIN) {
100 croak("Can't fork for decrypt");
118 sv = *av_fetch(fdpid,p[0],TRUE);
119 sv->sv_u.sv_useful = pipepid;
120 return fdopen(p[0], "r");
128 /* cheat on stdio if possible */
129 if (rsfp->_cnt > 0 && (*rsfp->_ptr & 0xff) != CRYPT_MAGIC_1)
133 if (ch == CRYPT_MAGIC_1) {
134 if (getc(rsfp) == CRYPT_MAGIC_2) {
135 if( perldb ) croak("can't debug an encrypted script");
136 rsfp = my_pfiopen( rsfp, cryptfilter );
137 preprocess = 1; /* force call to pclose when done */
140 croak( "bad encryption run_format" );
147 #endif /* CRYPTSCRIPT */