~mathiaz/apparmor/ubuntu-mathiaz

« back to all changes in this revision

Viewing changes to parser/parser_regex.c

  • Committer: Mathias Gug
  • Date: 2008-02-04 18:57:00 UTC
  • mfrom: (885.1.5 apparmor)
  • Revision ID: mathiaz@ubuntu.com-20080204185700-wwlyq0ksssxclv8w
Merge  ubuntu branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: parser_regex.c 565 2007-04-11 09:12:51Z jrjohansen $ */
 
1
/* $Id: parser_regex.c 1042 2007-11-29 18:06:53Z jrjohansen $ */
2
2
 
3
3
/*
4
4
 *   Copyright (c) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
482
482
static int process_dfa_entry(aare_ruleset_t *dfarules, struct cod_entry *entry)
483
483
{
484
484
        char tbuf[PATH_MAX + 3];        /* +3 for ^, $ and \0 */
485
 
        int ret = TRUE;
486
485
        pattern_t ptype;
487
486
 
488
487
        if (!entry)             /* shouldn't happen */
497
496
        /* ix implies m but the apparmor module does not add m bit to
498
497
         * dfa states like it does for pcre
499
498
         */
500
 
        if (entry->mode & AA_EXEC_INHERIT)
501
 
                entry->mode |= AA_EXEC_MMAP;
 
499
        if (((entry->mode >> AA_OTHER_SHIFT) & AA_EXEC_MODIFIERS) ==
 
500
            AA_EXEC_INHERIT)
 
501
                entry->mode |= AA_EXEC_MMAP << AA_OTHER_SHIFT;
 
502
        if (((entry->mode >> AA_USER_SHIFT) & AA_EXEC_MODIFIERS) ==
 
503
            AA_EXEC_INHERIT)
 
504
                entry->mode |= AA_EXEC_MMAP << AA_USER_SHIFT;
 
505
 
502
506
        if (!aare_add_rule(dfarules, tbuf, entry->mode))
503
 
                ret = FALSE;
504
 
 
505
 
        return ret;
 
507
                return FALSE;
 
508
        if (entry->mode & (AA_LINK_BITS)) {
 
509
                /* add the pair rule */
 
510
                char lbuf[PATH_MAX + 8];
 
511
                int perms = AA_LINK_BITS & entry->mode;
 
512
                if (entry->link_name) {
 
513
                        sprintf(lbuf, "%s//%s", entry->name, entry->link_name);
 
514
                } else {
 
515
                        perms |= LINK_TO_LINK_SUBSET(perms);
 
516
                        sprintf(lbuf, "%s///**", entry->name);
 
517
                }
 
518
                ptype = convert_aaregex_to_pcre(lbuf, 0, tbuf, PATH_MAX + 8);
 
519
                if (ptype == ePatternInvalid)
 
520
                        return FALSE;
 
521
                if (!aare_add_rule(dfarules, tbuf, perms))
 
522
                        return FALSE;
 
523
/*              if (!aare_add_vec_rule(dfarules, perms,
 
524
                                       tbuf, "/**", NULL))
 
525
                        return FALSE;
 
526
*/
 
527
        }
 
528
        if (entry->mode & AA_CHANGE_PROFILE) {
 
529
                char lbuf[2*PATH_MAX + 8];
 
530
                if (entry->namespace)
 
531
                        sprintf(lbuf, "%s//%s", entry->namespace, entry->name);
 
532
                else
 
533
                        sprintf(lbuf, "%s", entry->name);
 
534
                ptype = convert_aaregex_to_pcre(lbuf, 0, tbuf, 2*PATH_MAX + 8);
 
535
                if (ptype == ePatternInvalid)
 
536
                        return FALSE;
 
537
                if (!aare_add_rule(dfarules, tbuf, AA_CHANGE_PROFILE))
 
538
                        return FALSE;
 
539
        }
 
540
        return TRUE;
506
541
}
507
542
 
508
543
int post_process_entries(struct codomain *cod)