~dbarth/click-apparmor/clean-trust-dbs

« back to all changes in this revision

Viewing changes to src/apparmor/click.py

  • Committer: Jamie Strandboge
  • Date: 2016-01-06 22:07:16 UTC
  • Revision ID: jamie@ubuntu.com-20160106220716-u3wwoor37xrv1ecd
* click-apparmor is no longer used by snappy, so remove anything snappy
  related:
  - remove aa-profile-hook and aa-profile-hook.1
  - don't ship apparmor-profile.click-hook
  - remove aa-profile autopkgtests
  - debian/control:
    + don't Recommends ubuntu-snappy-cli
    + don't Depends on ubuntu-core-security-apparmor
  - debian/click-apparmor.dirs: don't create snappy directories
  - src/apparmor/click.py:
    + don't check if snappy system
    + remove ubuntu-snappy/15.04 compat code
    + remove framework_includes_dir
    + don't ship ubuntu-core and ubuntu-personal transforms
  - Makefile: remoave any references to aa-profile-hook
* update autopkgtests for 15.10 and 16.04
* aa-clickquery: properly handle policy version detection for Ubuntu
  frameworks on 15.10 and later. NOTE: easyprof doesn't handle this correctly
  still.

Show diffs side-by-side

added added

removed removed

Lines of Context:
539
539
 
540
540
def _get_click_dir_variable():
541
541
    '''Format click databases as variable'''
542
 
    # snappy hardcodes the click databases and if we can detect if a snappy
543
 
    # system then we can hardcode them too and not require click.
544
 
    # /usr/share/doc/ubuntu-snappy is shipped by ubuntu-snappy which is only
545
 
    # available on snappy systems. This is fairly brittle but click-apparmor
546
 
    # functionality is moving into snappy itself, so this is ok for now
547
 
    if os.path.exists("/usr/bin/snappy") and \
548
 
            os.path.isdir("/usr/share/doc/ubuntu-snappy"):
549
 
        return "{%s}" % ",".join(["/apps", "/oem", "/frameworks"])
550
 
 
551
542
    import gi
552
543
    gi.require_version('Click', '0.4')
553
544
    from gi.repository import Click
634
625
        newp.policyversion = policy_version
635
626
        if 'policy_version' in profile and \
636
627
           float(profile['policy_version']) != policy_version:
637
 
            if policy_version == 15.04 and \
638
 
               'policy_vendor' in profile and \
639
 
               profile['policy_vendor'] == "ubuntu-snappy" and \
640
 
               float(profile['policy_version']) == 1.3:
641
 
                # compatibility: allow ubuntu-snappy/1.3 on 15.04 transform
642
 
                # until apps migrate
643
 
                newp.policyversion = float(profile['policy_version'])
644
 
            else:
645
 
                raise AppArmorExceptionClickInvalidPolicyVersion(
646
 
                    "Invalid policy version '%s' " %
647
 
                    profile['policy_version'] +
648
 
                    "for framework '%s'" % click_manifest.framework)
 
628
            raise AppArmorExceptionClickInvalidPolicyVersion(
 
629
                "Invalid policy version '%s' " %
 
630
                profile['policy_version'] +
 
631
                "for framework '%s'" % click_manifest.framework)
649
632
 
650
633
        newp.add_variable("APP_PKGNAME", click_manifest.app_pkgname)
651
634
        newp.add_variable("APP_APPNAME", click_manifest.app_appname)
711
694
def to_profiles(easyprof_manifest, directory, include=[], no_verify=False):
712
695
    '''Convert manifest to AppArmor profile'''
713
696
    args = []
714
 
    args.append('--include-templates-dir=%s' %
715
 
                os.path.join(framework_includes_dir, "templates"))
716
 
    args.append('--include-policy-groups-dir=%s' %
717
 
                os.path.join(framework_includes_dir, "policygroups"))
718
 
 
719
697
    (easy_opts, easy_args) = apparmor.easyprof.parse_args(args=args)
720
698
 
721
699
    profiles = apparmor.easyprof.parse_manifest(json.dumps(easyprof_manifest),
861
839
    "ubuntu-sdk-14.10": (_ubuntu_transform, 1.2),
862
840
    "ubuntu-sdk-15.04": (_ubuntu_transform, 1.3),
863
841
    "ubuntu-sdk-15.10": (_ubuntu_transform, 15.10),
864
 
    "ubuntu-core-15.04": (_ubuntu_transform, 15.04),
865
 
    "ubuntu-core-15.10": (_ubuntu_transform, 15.10),
866
 
    "ubuntu-core-16.04": (_ubuntu_transform, 16.04),
867
 
    "ubuntu-personal-15.10": (_ubuntu_transform, 15.10),
868
 
    "ubuntu-personal-16.04": (_ubuntu_transform, 16.04),
 
842
    "ubuntu-sdk-16.04": (_ubuntu_transform, 16.04),
869
843
}
870
844
 
871
 
# Define where framework policy files live
872
 
framework_includes_dir = "/var/lib/snappy/apparmor"
873
 
 
874
845
# The Ubuntu tranformation function takes a click manifest json
875
846
# structure as input and returns an aa-easyprof json manifest
876
847
defaults_profile = {