Cesar’s Vanilla Blog

White and creamy wtf

How to fake success

I have finally approached the point where I can sign a directory (I’m still a kilometre off from signing an extension, and a galaxy away from being done). I got manifest.mf and zigbert.sf/zigbert.rsa to be created inside a META-INF directory.

Now before a celebration can take place, I have a confession to make. I cheated.

The problem I have, and that I will continue to have is that the functions I need aren’t in a library. They are used once, and have been placed inside a C file, and designed in such a way to make it difficult for it to be reused. So one way to get at them is to take the object files and link them with my library. Which turns out is a fantastic idea, and would save me a lot of valuable time.
Or so I thought. Later I find out that the main program (signtool.c) contains global variables that are being used by the very function I need. If I call the function directly, it blows up in a humiliating stacktrace.

What else is there to do? I wasn’t even sure if I was going in the right direction with this. There was one quick.. but unpleasant.. solution. Take signtool.o, and link it in with my library.

And that’s what I did.

I now call the function main(), and pass it arguments.

This process is identical to taking nsIProcess and calling the signtool from javascript. Which would have avoided doing any XPCOM work. But fuck, where’s the fun in that?

The solution of taking signtool.o and linking it with my library was not the most desirable solution to the problem (the way I see it). However, right now I am looking for any result to keep my spirits up.

Combining all the time and energy spent so far on Notary, it begs the question of whether I am taking a complicated solution to a simple problem.

I had another problem yesterday where it was failing to find a function that I was statically linking it (an undefined reference error). After quadruple checking the function signature, I wondered if a library wasn’t being linked that was being used by the function I needed, which could have been causing it (that’s a ridiculous theory once you think about it). So I began linking libraries, until I ran out of libraries and still had my problem. I later found out that I was trying to link C/C++ object files without ‘extern “C” {}’. I was beginning to suspect that I would have to copy+paste the function to my own files just to use it (which was stupid, I’ll admit).

The solution was simple, but I think sometimes it is human nature to take the complicated approach because we see it as a complicated problem. But all complicated problems are really a series of simple problems.


June 14, 2007 - Posted by | Uncategorized

1 Comment »

  1. Cesar, I don’t yet fully understand what your notary application is about, but I really think in this domain you would get useful help by posting in news://mozilla.dev.tech.crypto when you have any question. For exemple, Dave Townsend is currently starting to get useful feedback about how to sign add-on updates.

    Comment by jmdesp | June 15, 2007 | Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: