Bit of history first: where I work, some developers/shareholders have brought their intellectual property together to form the company. IP still remains theirs alone, individually, as well as the source code.

In addition, we have also had some problems with industrial espionage from 3rd parties a few years back. All of this had led some of those developers/company owners to come up with unorthodox measures to ensure that, even if stolen, our binaries cannot be used.

Current problem: we're renting a supercomputer to do some hard number crunching in order to meet a deadline. Trouble is, the executable in case has a static dependency to a text file buried deep inside our network directory structure.

Why not just recompile without this 'dependency'? Because the developer in question is currently currently away on a personal trip, and isn't expected to return in order to recompile this code before our deadline is met.



Error output:

forrtl: No such file or directory
forrtl: severe (29): file not found, unit 1, file /foo/bar/.xyz
Image              PC                Routine            Line        Source             
number_crunch         000000000048B933  Unknown               Unknown  Unknown
number_crunch         0000000000499ADB  Unknown               Unknown  Unknown
number_crunch         0000000000445941  Unknown               Unknown  Unknown
number_crunch         0000000000403BFE  Unknown               Unknown  Unknown
libc.so.6             00002AAAAB6C10BD  Unknown               Unknown  Unknown
number_crunch         0000000000403B09  Unknown               Unknown  Unknown

Contents of run.sh:

#SBATCH --nodes=10
#SBATCH --job-name=number_crunch
#SBATCH --cpus-per-task=8

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/share/intel/ics2013/composer_xe_2013_sp1.2.144/compiler/lib/intel64/
module load glibc


What I need: some way to trick the binary into acknowleding the /foo/bar/.xyz structure, without having root powers.

Is this possible? I know that alias does not allow for slashes in the alias name, and ln requires that I have permission to write on /.

  • 1
    Have you got fakeroot available to you? Can you get the system administrators to install it for you? – roaima Apr 9 at 17:17
  • @roaima unfortunately, no. System's quite closed in terms of installation requests. Also, I didn't know of fakeroot before. I'll look it up for the future. For the meantime, Alex came up with a nice solution. Thanks, though! – victorantunes Apr 9 at 18:09

What about patching your binary in-place? strings yourbinary | grep -F /foo/bar/.xyz should print out /foo/bar/.xyz. If /foo/bar/.xyz is sufficiently unique in the strings, you could do:

sed -i "s_/foo/bar/\.xyz_/control/.xyz_g" yourbinary

where /control/ is a directory you have control over. The replacement string's length (in number of bytes) must be equal to the original string's length. If the replacement string is shorter, you may be able to pad it with null bytes: sed -i "_/foo/bar/.xyz_/contr/xyz\x00\x00\x00_g" yourbinary (o, l, and . were removed for null bytes), but the success of this may depend on whether or not there are hardcoded dependencies on the length of /foo/bar/.xyz. Alternatively, you can make the path longer by adding some / characters (/tmp/////.xyz).

If the replacement string is longer, you're probably out of luck for this style of in-place patching. However, you may be able to combine this with a symlink solution if necessary, where /control/xyz is a path of suitable length but it points to a longer path where the real file resides.

If you have the expertise and you need more control over which instances of the string are replaced, you can do this with a hex editor instead of sed.

I would test this change before doing anything important with it.

  • Whoa, I had no idea you could do that! It worked, thanks! – victorantunes Apr 9 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.