Suppose I have an encrypted Makefile on hand, I want to write a Perl program to decrypt it and run make -f
with it. Is this possible without writing the decrypted Makefile back to harddisk?
-
5Can I ask it what context are you using an encrypted makefile? – Amro Oct 19 '09 at 09:51
-
Yes, I know it's rare. It's just a thought. – solotim Oct 20 '09 at 01:19
-
Can you show us the makefile so we can give you a better answer :-) – ctrl-alt-delor Feb 16 '11 at 16:18
4 Answers
Have your program write the decrypted Makefile to stdout and pipe it to make -.
See man make, the part that says:
If makefile is `-', the standard input is read.

- 644
- 5
- 18
You could try setting LD_PRELOAD when you run make
to give make
some fake fopen/fclose functions that read the makefile out of memory.
make -f <(decrypt file)
This will work on linux and some other systems. It does not rely on make supporting this functionality. It is done in the OS. See http://www.gnu.org/software/bash/manual/bashref.html#Process-Substitution
P.S. you will want to consider swap space, telling make not to swap.
Also this will not help with files included by the first.

- 7,506
- 5
- 40
- 52
You could use an encrypted file system. A shell script could launch a key agent, for the file system then the make can run retrieving and saving everything to/from the encrypted file system. I have done successfully done this with sshfs (not an encrypted file system, but an encrypted connection to a remote file system locked in a room).

- 7,506
- 5
- 40
- 52