ENH: systemCall: added allowSystemOperations checking. Added to argList.

This commit is contained in:
mattijs 2011-02-21 16:45:17 +00:00
parent 0ffe4c0fd9
commit fcfca9106c
3 changed files with 41 additions and 6 deletions

View File

@ -131,7 +131,7 @@ bool Foam::codeStreamTools::copyFilesContents(const fileName& dir) const
<< "because of security issues. If you trust the code you can"
<< " enable this" << endl
<< "facility be adding to the InfoSwitches setting in the system"
<< " controlDict" << endl
<< " controlDict:" << endl
<< endl
<< " allowSystemOperations 1" << endl
<< endl

View File

@ -32,6 +32,7 @@ License
#include "JobInfo.H"
#include "labelList.H"
#include "regIOobject.H"
#include "codeStreamTools.H"
#include <cctype>
@ -787,6 +788,16 @@ Foam::argList::argList
regIOobject::fileModificationChecking
]
<< endl;
Info<< "allowSystemOperations : ";
if (codeStreamTools::allowSystemOperations)
{
Info<< "Allowing user-supplied system call operations" << endl;
}
else
{
Info<< "Disallowing user-supplied system call operations" << endl;
}
}
if (Pstream::master() && bannerEnabled)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,8 +24,8 @@ License
\*---------------------------------------------------------------------------*/
#include "systemCall.H"
#include "dictionary.H"
#include "Time.H"
#include "codeStreamTools.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -71,6 +71,30 @@ void Foam::systemCall::read(const dictionary& dict)
<< "no executeCalls, endCalls or writeCalls defined."
<< endl;
}
else if (!codeStreamTools::allowSystemOperations)
{
FatalErrorIn
(
"systemCall::read(const dictionary&)"
) << "Executing user-supplied system calls is not"
<< " enabled by default" << endl
<< "because of security issues. If you trust the case you can"
<< " enable this" << endl
<< "facility be adding to the InfoSwitches setting in the system"
<< " controlDict:" << endl
<< endl
<< " allowSystemOperations 1" << endl
<< endl
<< "The system controlDict is either" << endl
<< endl
<< " ~/.OpenFOAM/$WM_PROJECT_VERSION/controlDict" << endl
<< endl
<< "or" << endl
<< endl
<< " $WM_PROJECT_DIR/etc/controlDict" << endl
<< endl
<< exit(FatalError);
}
}
@ -78,7 +102,7 @@ void Foam::systemCall::execute()
{
forAll(executeCalls_, callI)
{
::system(executeCalls_[callI].c_str());
Foam::system(executeCalls_[callI].c_str());
}
}
@ -87,7 +111,7 @@ void Foam::systemCall::end()
{
forAll(endCalls_, callI)
{
::system(endCalls_[callI].c_str());
Foam::system(endCalls_[callI].c_str());
}
}
@ -96,7 +120,7 @@ void Foam::systemCall::write()
{
forAll(writeCalls_, callI)
{
::system(writeCalls_[callI].c_str());
Foam::system(writeCalls_[callI].c_str());
}
}