I think this will perform badly if the cache_loc isn't set somewhere. It also 
seems strange to append /cache/ to the end of the string -- if it is configured 
for /run/apparmor_cache it'll expand to /run/apparmor_cache/cache. I think, if 
specified, it should be the exact directory used.

Thanks!
-----Original Message-----
From: John Johansen <[email protected]>
Sender: [email protected]
Date: Fri,  6 Jan 2012 09:34:08 
To: <[email protected]>
Subject: [apparmor] [PATCH 1/2] Add an option to allow setting the cache's
        location.

Currently the cache location is fixed and links are needed to move it.
Add an option that can be set in the apparmor_parser.conf file so distros
can locate the cache where ever makes sense for them.

Signed-off-by: John Johansen <[email protected]>
---
 parser/parser_main.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/parser/parser_main.c b/parser/parser_main.c
index 721582d..1aef616 100644
--- a/parser/parser_main.c
+++ b/parser/parser_main.c
@@ -76,6 +76,7 @@ struct timespec mru_tstamp;
 
 char *match_string = NULL;
 char *flags_string = NULL;
+char *cacheloc = NULL;
 
 /* per-profile settings */
 int force_complain = 0;
@@ -106,6 +107,7 @@ struct option long_options[] = {
        {"skip-read-cache",     0, 0, 'T'},
        {"write-cache",         0, 0, 'W'},
        {"show-cache",          0, 0, 'k'},
+       {"cache-loc",           1, 0, 'L'},
        {"debug",               0, 0, 'd'},
        {"dump",                1, 0, 'D'},
        {"Dump",                1, 0, 'D'},
@@ -147,6 +149,7 @@ static void display_usage(char *command)
               "-K, --skip-cache        Do not attempt to load or save cached 
profiles\n"
               "-T, --skip-read-cache   Do not attempt to load cached 
profiles\n"
               "-W, --write-cache       Save cached profile (force with -T)\n"
+              "-L, --cache-loc n       Set the location of the profile cache\n"
               "-q, --quiet             Don't emit warnings\n"
               "-v, --verbose           Show profile names as they load\n"
               "-Q, --skip-kernel-load  Do everything except loading into 
kernel\n"
@@ -522,6 +525,9 @@ static int process_arg(int c, char *optarg)
        case 'T':
                skip_read_cache = 1;
                break;
+       case 'L':
+               cacheloc = strdup(optarg);
+               break;
        case 'Q':
                kernel_load = 0;
                break;
@@ -928,7 +934,7 @@ int process_profile(int option, char *profilename)
         */
        if ((profilename && option != OPTION_REMOVE) && !force_complain &&
            !skip_cache) {
-               if (asprintf(&cachename, "%s/%s/%s", basedir, "cache", 
basename)<0) {
+               if (asprintf(&cachename, "%s/%s/%s", cacheloc, "cache", 
basename)<0) {
                        perror("asprintf");
                        exit(1);
                }
-- 
1.7.7.3


-- 
AppArmor mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor
-- 
AppArmor mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/apparmor

Reply via email to