Defining Macros in AIDE


Macros are used in AIDE to define commonly used objects and objects to be used as variables throughout an AIDE configuration file. You might use an AIDE macro to define the top-level directory to be used within the configuration. You would then use this macro within selection lines, and it would be substituted like a variable in that selection line. You also might use a macro to set a variable based on certain criteria. Macros can then be used within the AIDE configuration within control structures (decisional blocks of code) to alter the configuration of AIDE based on the outcome of the control structure.

Macros are defined using the following syntax:

 @@define <macro> <definition> 

Macros can also be undefined with this syntax:

 @@undef <macro> 

Macros are used within the configuration with the following syntax:

 @@{<macro>} 

An example of using a macro in a simple way is to create a macro for a complex directory hierarchy so that you don't have to type it into the configuration file multiple times. Assume that you have a certain structure of directories on the computer that you want to define using a macro:

 @@define BASEDIR /usr/src/linux 

This macro could then be used later within the configuration of selections for AIDE:

 @@{BASEDIR}/.config R !@@{BASEDIR}/doc 

A more powerful use of macros involves changing the configuration based on some criteria. For example, macros can be used within two types of control structures, one based on whether the macro has been defined and the other based on the host from which the AIDE program is being run.

These control structures are basically if/then/else statements, and they have associated negations as well. The syntax for determining whether a macro has been defined is this:

 @@ifdef <macro> 

The negation for the @@ifdef evaluation is as shown here:

 @@ifndef <macro> 

For determining the current host, this is the syntax:

 @@ifhost <hostname> 

The negation for the @@ifhost evaluation is, as you might guess, the following:

 @@ifnhost <hostname> 

Regardless of which control structure is used, it must be closed using the statement:

 @@endif 

Multiple control structures can be grouped using an else type of structure that you would expect for an associated if statement. The syntax is simply as follows:

 @@else 

Here's an example of how each of these might be used. The first example checks to see whether the macro called SOURCE has been defined, and if not, defines it:

 @@ifndef SOURCE @@define SOURCE /usr/src @@endif 

The second example looks at the hostname of the computer from which AIDE is being run and sets a macro based on the results of that check. This might be helpful if you have differing directory structures between various hosts and you'd like to use only one common AIDE configuration file among them. Here's the second example:

 @@ifhost netserver @@define LOCALBINDIR /usr/local/sbin @@endif 

Finally, here is an example using an else statement:

 @@ifhost netserver @@define LOCALBINDIR /usr/local/sbin @@ELSE @@define LOCALBINDIR /usr/local/bin @@endif 

For all the examples, recall that you'd use these macros later within the configuration using the following syntax:

 @@{<macro>} 




Linux Firewalls
Linux Firewalls: Attack Detection and Response with iptables, psad, and fwsnort
ISBN: 1593271417
EAN: 2147483647
Year: 2005
Pages: 163
Authors: Michael Rash

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net