Mailing List Archives
Authenticated access
|
|
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Condor-users] Checking if a binary file is compiled for condor
- Date: Tue, 23 Oct 2007 18:53:21 -0500
- From: Erik Paulson <epaulson@xxxxxxxxxxx>
- Subject: Re: [Condor-users] Checking if a binary file is compiled for condor
On Tue, Oct 23, 2007 at 06:36:46PM -0400, Bruno Goncalves wrote:
> Dear All,
>
> I would like to write a C/C++ program to verify if a given executable
> has been compiled with condor_compile or not. In the command line, I
> know that something like this:
>
> strings foo_condor.x | grep -m 1 condor_exec.exe | wc -l
>
> works, returning one (or zero) if the string condor_exec.exe is
> defined (or not) inside the file foo_condor.x. Is there anyway of
> detecting this inside C? For instance, how does condor check for this?
> Thanks!
>
Condor opens up the file, scans through it looking for the string
$CondorVersion:
then reads to the next '$' character.
It's not foolproof, if you submited the schedd as a std universe job it
would say it's valid. (I suppose the more worrisome example would be
forgetting universe=scheduler when submitting a DAGMan, since Condor
might still default to the std universe for jobs)
-Erik
// Look for the magic version string
// '$CondorVersion: x.y.z <date> <extra info> $' in the file.
// What we look for is a string that begins with '$CondorVersion: '
// and continues with a non-NULL character. We need to be careful
// not to match the string '$CondorVersion: \0' which this file
// includes as static data in a Condor executable.
int i = 0;
bool got_verstring = false;
const char* verprefix = "$CondorVersion: ";
int ch;
while( (ch=fgetc(fp)) != EOF ) {
if ( verprefix[i] == '\0' && ch != '\0' ) {
do {
ver[i++] = ch;
if ( ch == '$' ) {
got_verstring = true;
ver[i] = '\0';
break;
}
} while ( (i < maxlen) && ((ch=fgetc(fp)) != EOF) );
break;
}
if ( ch != verprefix[i] ) {
i = 0;
if ( ch != verprefix[0] ) {
continue;
}
}
ver[i++] = ch;
}