[apparmor] RFC [Patch 0/1] Update log parsing interface

Steve Beattie steve at nxnw.org
Wed Jul 13 16:34:57 UTC 2011


On Tue, Jul 12, 2011 at 11:59:24PM -0700, John Johansen wrote:
> On 07/12/2011 08:52 PM, Steve Beattie wrote:
> >> This patch takes care of the library end of things, and should allow older
> >> versions of programs calling the library to function.  This patch doesn't
> >> currently cover the update of the tools calling the library to use the
> >> new interface, nor does it deal with swig clients breaking if a new
> >> swig interface is used.
> > 
> > I'm not convinced it's actually backwards compatible in the way
> > you think it is. IIRC, if you want to offer an old (versioned)
> > symbol available, you (in the past anyway) needed to do the same
> > sort of aliasing that's done for the old change_hat (IMMUNIX_1.0 and
> > APPARMOR_1.0) symbols. 'readelf' output on the generated .so would
> > tell you for sure.
> > 
> yes we need to provide the 1.1 parse_record and free_record, I seem to
> have dropped that part.  Instead of aliases I set them up as a fn calling
> into the aa_ version but we could just as easily setup and alias

Ah, right, the aliases bit is needed for when the function name stays
the same, but the signature of the function changes. I agree, an alias
isn't needed here.

Acked-By: Steve Beattie <sbeattie at ubuntu.com>

> Export the log parsing interface with the aa_ prefix
> 
> export the log parsing interface so that it uses the aa_ prefix, while
> retaining the old interface for backwards compatability.
> 
> Signed-off-by: John Johansen <john.johansen at canonical.com>
> 
> diff --git a/libraries/libapparmor/src/aalogparse.h b/libraries/libapparmor/src/aalogparse.h
> index c439bfb..3e913e4 100644
> --- a/libraries/libapparmor/src/aalogparse.h
> +++ b/libraries/libapparmor/src/aalogparse.h
> @@ -151,14 +151,14 @@ typedef struct
>   * @return Parsed data.
>   */
>  aa_log_record *
> -parse_record(char *str);
> +aa_parse_record(char *str);
>  
>  /**
>   * Frees all struct data.
>   * @param[in] Data to free.
>   */
>  void
> -free_record(aa_log_record *record);
> +aa_free_record(aa_log_record *record);
>  
>  #endif
>  
> diff --git a/libraries/libapparmor/src/libaalogparse.c b/libraries/libapparmor/src/libaalogparse.c
> index 5292830..b4cac72 100644
> --- a/libraries/libapparmor/src/libaalogparse.c
> +++ b/libraries/libapparmor/src/libaalogparse.c
> @@ -35,7 +35,7 @@
>  #include "parser.h"
>  
>  /* This is mostly just a wrapper around the code in grammar.y */
> -aa_log_record *parse_record(char *str)
> +aa_log_record *aa_parse_record(char *str)
>  {
>  	if (str == NULL)
>  		return NULL;
> @@ -43,7 +43,13 @@ aa_log_record *parse_record(char *str)
>  	return _parse_yacc(str);
>  }
>  
> -void free_record(aa_log_record *record)
> +/* old version of aa_parse_record */
> +aa_log_record *parse_record(char *str)
> +{
> +	return aa_parse_record(str);
> +}
> +
> +void aa_free_record(aa_log_record *record)
>  {
>  	if (record != NULL)
>  	{
> @@ -83,6 +89,11 @@ void free_record(aa_log_record *record)
>  	return;
>  }
>  
> +void free_record(aa_log_record *record)
> +{
> +	aa_free_record(record);
> +}
> +
>  /* Set all of the fields to appropriate values */
>  void _init_log_record(aa_log_record *record)
>  {
> diff --git a/libraries/libapparmor/src/libapparmor.map b/libraries/libapparmor/src/libapparmor.map
> index ebd13c9..362eaf3 100644
> --- a/libraries/libapparmor/src/libapparmor.map
> +++ b/libraries/libapparmor/src/libapparmor.map
> @@ -25,6 +25,8 @@ APPARMOR_1.1 {
>          aa_introspect_confinement;
>          parse_record;
>          free_record;
> +        aa_parse_record;
> +        aa_free_record;
>    local:
>  	*;
>  } APPARMOR_1.0;
> diff --git a/libraries/libapparmor/testsuite/test_multi.c b/libraries/libapparmor/testsuite/test_multi.c
> index 93e2d63..e1c3ec8 100644
> --- a/libraries/libapparmor/testsuite/test_multi.c
> +++ b/libraries/libapparmor/testsuite/test_multi.c
> @@ -39,7 +39,7 @@ int main(int argc, char **argv)
>  
>  	fclose(testcase);
>  
> -	test = parse_record(log_line);
> +	test = aa_parse_record(log_line);
>  
>  	if (test == NULL)
>  	{
> @@ -47,7 +47,7 @@ int main(int argc, char **argv)
>  		return(1);
>  	}
>  	ret = print_results(test);
> -	free_record(test);
> +	aa_free_record(test);
>  	return ret;
>  }

-- 
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20110713/33ea00c8/attachment.pgp>


More information about the AppArmor mailing list