BVB Source Codes

blueprint Show files.py Source code

Return Download blueprint: download files.py Source code - Download blueprint Source code - Type:.py
  1. """
  2. Search for configuration files to include in the blueprint.
  3. """
  4.  
  5. import base64
  6. from collections import defaultdict
  7. import errno
  8. import glob
  9. import grp
  10. import hashlib
  11. import logging
  12. import os.path
  13. import pwd
  14. import re
  15. import stat
  16. import subprocess
  17.  
  18. from blueprint import util
  19.  
  20.  
  21. # An extra list of pathnames and MD5 sums that will be checked after no
  22. # match is found in `dpkg`(1)'s list.  If a pathname is given as the value
  23. # then that file's contents will be hashed.
  24. #
  25. # Many of these files are distributed with packages and copied from
  26. # `/usr/share` in the `postinst` program.
  27. #
  28. # XXX Update `blueprintignore`(5) if you make changes here.
  29. MD5SUMS = {'/etc/adduser.conf': ['/usr/share/adduser/adduser.conf'],
  30.            '/etc/apparmor.d/tunables/home.d/ubuntu':
  31.                ['2a88811f7b763daa96c20b20269294a4'],
  32.            '/etc/apt/apt.conf.d/00CDMountPoint':
  33.                ['cb46a4e03f8c592ee9f56c948c14ea4e'],
  34.            '/etc/apt/apt.conf.d/00trustcdrom':
  35.                ['a8df82e6e6774f817b500ee10202a968'],
  36.            '/etc/chatscripts/provider': ['/usr/share/ppp/provider.chatscript'],
  37.            '/etc/default/console-setup':
  38.                ['0fb6cec686d0410993bdf17192bee7d6',
  39.                 'b684fd43b74ac60c6bdafafda8236ed3',
  40.                 '/usr/share/console-setup/console-setup'],
  41.            '/etc/default/grub': ['ee9df6805efb2a7d1ba3f8016754a119',
  42.                                  'ad9283019e54cedfc1f58bcc5e615dce'],
  43.            '/etc/default/irqbalance': ['7e10d364b9f72b11d7bf7bd1cfaeb0ff'],
  44.            '/etc/default/keyboard': ['06d66484edaa2fbf89aa0c1ec4989857'],
  45.            '/etc/default/locale': ['164aba1ef1298affaa58761647f2ceba',
  46.                                    '7c32189e775ac93487aa4a01dffbbf76'],
  47.            '/etc/default/rcS': ['/usr/share/initscripts/default.rcS'],
  48.            '/etc/environment': ['44ad415fac749e0c39d6302a751db3f2'],
  49.            '/etc/hosts.allow': ['8c44735847c4f69fb9e1f0d7a32e94c1'],
  50.            '/etc/hosts.deny': ['92a0a19db9dc99488f00ac9e7b28eb3d'],
  51.            '/etc/initramfs-tools/modules':
  52.                ['/usr/share/initramfs-tools/modules'],
  53.            '/etc/inputrc': ['/usr/share/readline/inputrc'],
  54.            '/etc/iscsi/iscsid.conf': ['6c6fd718faae84a4ab1b276e78fea471'],
  55.            '/etc/kernel-img.conf': ['f1ed9c3e91816337aa7351bdf558a442'],
  56.            '/etc/ld.so.conf': ['4317c6de8564b68d628c21efa96b37e4'],
  57.            '/etc/ld.so.conf.d/nosegneg.conf':
  58.                ['3c6eccf8f1c6c90eaf3eb486cc8af8a3'],
  59.            '/etc/networks': ['/usr/share/base-files/networks'],
  60.            '/etc/nsswitch.conf': ['/usr/share/base-files/nsswitch.conf'],
  61.            '/etc/pam.d/common-account': ['9d50c7dda6ba8b6a8422fd4453722324'],
  62.            '/etc/pam.d/common-auth': ['a326c972f4f3d20e5f9e1b06eef4d620'],
  63.            '/etc/pam.d/common-password': ['9f2fbf01b1a36a017b16ea62c7ff4c22'],
  64.            '/etc/pam.d/common-session': ['e2b72dd3efb2d6b29698f944d8723ab1'],
  65.            '/etc/pam.d/common-session-noninteractive':
  66.                ['508d44b6daafbc3d6bd587e357a6ff5b'],
  67.            '/etc/pam.d/fingerprint-auth-ac':
  68.                ['d851f318a16c32ed12f5b1cd55e99281'],
  69.            '/etc/pam.d/fingerprint-auth': ['d851f318a16c32ed12f5b1cd55e99281'],
  70.            '/etc/pam.d/password-auth-ac': ['e8aee610b8f5de9b6a6cdba8a33a4833'],
  71.            '/etc/pam.d/password-auth': ['e8aee610b8f5de9b6a6cdba8a33a4833'],
  72.            '/etc/pam.d/smartcard-auth-ac':
  73.                ['dfa6696dc19391b065c45b9525d3ae55'],
  74.            '/etc/pam.d/smartcard-auth': ['dfa6696dc19391b065c45b9525d3ae55'],
  75.            '/etc/pam.d/system-auth-ac': ['e8aee610b8f5de9b6a6cdba8a33a4833'],
  76.            '/etc/pam.d/system-auth': ['e8aee610b8f5de9b6a6cdba8a33a4833'],
  77.            '/etc/ppp/chap-secrets': ['faac59e116399eadbb37644de6494cc4'],
  78.            '/etc/ppp/pap-secrets': ['698c4d412deedc43dde8641f84e8b2fd'],
  79.            '/etc/ppp/peers/provider': ['/usr/share/ppp/provider.peer'],
  80.            '/etc/profile': ['/usr/share/base-files/profile'],
  81.            '/etc/python/debian_config': ['7f4739eb8858d231601a5ed144099ac8'],
  82.            '/etc/rc.local': ['10fd9f051accb6fd1f753f2d48371890'],
  83.            '/etc/rsyslog.d/50-default.conf':
  84.                 ['/usr/share/rsyslog/50-default.conf'],
  85.            '/etc/security/opasswd': ['d41d8cd98f00b204e9800998ecf8427e'],
  86.            '/etc/selinux/restorecond.conf':
  87.                ['b5b371cb8c7b33e17bdd0d327fa69b60'],
  88.            '/etc/selinux/targeted/modules/semanage.trans.LOCK':
  89.                ['d41d8cd98f00b204e9800998ecf8427e'],
  90.            '/etc/selinux/targeted/modules/active/file_contexts.template':
  91.                ['bfa4d9e76d88c7dc49ee34ac6f4c3925'],
  92.            '/etc/selinux/targeted/modules/active/file_contexts':
  93.                ['1622b57a3b85db3112c5f71238c68d3e'],
  94.            '/etc/selinux/targeted/modules/active/users_extra':
  95.                ['daab665152753da1bf92ca0b2af82999'],
  96.            '/etc/selinux/targeted/modules/active/base.pp':
  97.                ['6540e8e1a9566721e70953a3cb946de4'],
  98.            '/etc/selinux/targeted/modules/active/modules/fetchmail.pp':
  99.                ['0b0c7845f10170a76b9bd4213634cb43'],
  100.            '/etc/selinux/targeted/modules/active/modules/usbmuxd.pp':
  101.                ['72a039c5108de78060651833a073dcd1'],
  102.            '/etc/selinux/targeted/modules/active/modules/pulseaudio.pp':
  103.                ['d9c4f1abf8397d7967bb3014391f7b61'],
  104.            '/etc/selinux/targeted/modules/active/modules/screen.pp':
  105.                ['c343b6c4df512b3ef435f06ed6cfd8b4'],
  106.            '/etc/selinux/targeted/modules/active/modules/cipe.pp':
  107.                ['4ea2d39babaab8e83e29d13d7a83e8da'],
  108.            '/etc/selinux/targeted/modules/active/modules/rpcbind.pp':
  109.                ['48cdaa5a31d75f95690106eeaaf855e3'],
  110.            '/etc/selinux/targeted/modules/active/modules/nut.pp':
  111.                ['d8c81e82747c85d6788acc9d91178772'],
  112.            '/etc/selinux/targeted/modules/active/modules/mozilla.pp':
  113.                ['405329d98580ef56f9e525a66adf7dc5'],
  114.            '/etc/selinux/targeted/modules/active/modules/openvpn.pp':
  115.                ['110fe4c59b7d7124a7d33fda1f31428a'],
  116.            '/etc/selinux/targeted/modules/active/modules/denyhosts.pp':
  117.                ['d12dba0c7eea142c16abd1e0424dfda4'],
  118.            '/etc/selinux/targeted/modules/active/modules/rhcs.pp':
  119.                ['e7a6bf514011f39f277d401cd3d3186a'],
  120.            '/etc/selinux/targeted/modules/active/modules/radius.pp':
  121.                ['a7380d93d0ac922364bc1eda85af80bf'],
  122.            '/etc/selinux/targeted/modules/active/modules/policykit.pp':
  123.                ['1828a7a89c5c7a9cd0bd1b04b379e2c0'],
  124.            '/etc/selinux/targeted/modules/active/modules/varnishd.pp':
  125.                ['260ef0797e6178de4edeeeca741e2374'],
  126.            '/etc/selinux/targeted/modules/active/modules/bugzilla.pp':
  127.                ['c70402a459add46214ee370039398931'],
  128.            '/etc/selinux/targeted/modules/active/modules/java.pp':
  129.                ['ac691d90e755a9a929c1c8095d721899'],
  130.            '/etc/selinux/targeted/modules/active/modules/courier.pp':
  131.                ['d6eb2ef77d755fd49d61e48383867ccb'],
  132.            '/etc/selinux/targeted/modules/active/modules/userhelper.pp':
  133.                ['787e5ca0ee1c9e744e9116837d73c2b9'],
  134.            '/etc/selinux/targeted/modules/active/modules/sssd.pp':
  135.                ['aeb11626d9f34af08e9cd50b1b5751c7'],
  136.            '/etc/selinux/targeted/modules/active/modules/munin.pp':
  137.                ['db2927d889a3dfbe439eb67dfdcba61d'],
  138.            '/etc/selinux/targeted/modules/active/modules/ppp.pp':
  139.                ['7c6f91f4aae1c13a3d2a159a4c9b8553'],
  140.            '/etc/selinux/targeted/modules/active/modules/xfs.pp':
  141.                ['6b3be69f181f28e89bfcffa032097dcb'],
  142.            '/etc/selinux/targeted/modules/active/modules/consolekit.pp':
  143.                ['ef682e07a732448a12f2e93da946d655'],
  144.            '/etc/selinux/targeted/modules/active/modules/telnet.pp':
  145.                ['43fd78d022e499bcb6392da33ed6e28d'],
  146.            '/etc/selinux/targeted/modules/active/modules/nagios.pp':
  147.                ['9c9e482867dce0aa325884a50a023a83'],
  148.            '/etc/selinux/targeted/modules/active/modules/sysstat.pp':
  149.                ['0fc4e6b3472ce5e8cfd0f3e785809552'],
  150.            '/etc/selinux/targeted/modules/active/modules/tor.pp':
  151.                ['2c926e3c5b79879ed992b72406544394'],
  152.            '/etc/selinux/targeted/modules/active/modules/qpidd.pp':
  153.                ['959d4763313e80d8a75bc009094ea085'],
  154.            '/etc/selinux/targeted/modules/active/modules/radvd.pp':
  155.                ['a7636d3df0f431ad421170150e8a9d2e'],
  156.            '/etc/selinux/targeted/modules/active/modules/aiccu.pp':
  157.                ['c0eafc1357cd0c07be4034c1a27ada98'],
  158.            '/etc/selinux/targeted/modules/active/modules/tgtd.pp':
  159.                ['55da30386834e60a10b4bab582a1b689'],
  160.            '/etc/selinux/targeted/modules/active/modules/sectoolm.pp':
  161.                ['6f8fba8d448da09f85a03622de295ba9'],
  162.            '/etc/selinux/targeted/modules/active/modules/unconfineduser.pp':
  163.                ['0bc2f6faf3b38a657c4928ec7b611d7a'],
  164.            '/etc/selinux/targeted/modules/active/modules/sambagui.pp':
  165.                ['31a5121c80a6114b25db4984bdf8d999'],
  166.            '/etc/selinux/targeted/modules/active/modules/mpd.pp':
  167.                ['cdabce7844a227a81c2334dec0c49e9b'],
  168.            '/etc/selinux/targeted/modules/active/modules/hddtemp.pp':
  169.                ['76d85610a7e198c82406d850ccd935e1'],
  170.            '/etc/selinux/targeted/modules/active/modules/clamav.pp':
  171.                ['f8f5b60e3f5b176810ea0666b989f63d'],
  172.            '/etc/selinux/targeted/modules/active/modules/tvtime.pp':
  173.                ['886dc0a6e9ebcbb6787909851e7c209f'],
  174.            '/etc/selinux/targeted/modules/active/modules/cgroup.pp':
  175.                ['9e1cd610b6fde0e9b42cabd7f994db46'],
  176.            '/etc/selinux/targeted/modules/active/modules/rshd.pp':
  177.                ['e39cec5e9ade8a619ecb91b85a351408'],
  178.            '/etc/selinux/targeted/modules/active/modules/roundup.pp':
  179.                ['133b9b3b2f70422953851e18d6c24276'],
  180.            '/etc/selinux/targeted/modules/active/modules/virt.pp':
  181.                ['9ae34fca60c651c10298797c1260ced0'],
  182.            '/etc/selinux/targeted/modules/active/modules/asterisk.pp':
  183.                ['f823fdcb2c6df4ddde374c9edb11ef26'],
  184.            '/etc/selinux/targeted/modules/active/modules/livecd.pp':
  185.                ['8972e6ef04f490b8915e7983392b96ce'],
  186.            '/etc/selinux/targeted/modules/active/modules/netlabel.pp':
  187.                ['91fc83e5798bd271742823cbb78c17ff'],
  188.            '/etc/selinux/targeted/modules/active/modules/qemu.pp':
  189.                ['e561673d5f9e5c19bcae84c1641fa4a7'],
  190.            '/etc/selinux/targeted/modules/active/modules/unconfined.pp':
  191.                ['3acd5dceb6b7a71c32919c29ef920785'],
  192.            '/etc/selinux/targeted/modules/active/modules/postgresql.pp':
  193.                ['3ecc9f2c7b911fa37d8ab6cc1c6b0ea7'],
  194.            '/etc/selinux/targeted/modules/active/modules/apache.pp':
  195.                ['c0089e4472399e9bc5237b1e0485ac39'],
  196.            '/etc/selinux/targeted/modules/active/modules/abrt.pp':
  197.                ['09e212789d19f41595d7952499236a0c'],
  198.            '/etc/selinux/targeted/modules/active/modules/rsync.pp':
  199.                ['e2567e8716c116ea6324c77652c97137'],
  200.            '/etc/selinux/targeted/modules/active/modules/git.pp':
  201.                ['7904fd9fbae924be5377ccd51036248e'],
  202.            '/etc/selinux/targeted/modules/active/modules/amanda.pp':
  203.                ['594eddbbe3b4530e79702fc6a882010e'],
  204.            '/etc/selinux/targeted/modules/active/modules/cvs.pp':
  205.                ['62cf7b7d58f507cc9f507a6c303c8020'],
  206.            '/etc/selinux/targeted/modules/active/modules/chronyd.pp':
  207.                ['a4ff3e36070d461771230c4019b23440'],
  208.            '/etc/selinux/targeted/modules/active/modules/gpm.pp':
  209.                ['ed3f26e774be81c2cbaaa87dcfe7ae2d'],
  210.            '/etc/selinux/targeted/modules/active/modules/modemmanager.pp':
  211.                ['840d4da9f32a264436f1b22d4d4a0b2a'],
  212.            '/etc/selinux/targeted/modules/active/modules/podsleuth.pp':
  213.                ['67e659e9554bc35631ee829b5dc71647'],
  214.            '/etc/selinux/targeted/modules/active/modules/publicfile.pp':
  215.                ['0f092d92c326444dc9cee78472c56655'],
  216.            '/etc/selinux/targeted/modules/active/modules/postfix.pp':
  217.                ['a00647ad811c22810c76c1162a97e74b'],
  218.            '/etc/selinux/targeted/modules/active/modules/exim.pp':
  219.                ['8c3cd1fbd8f68e80ac7707f243ac1911'],
  220.            '/etc/selinux/targeted/modules/active/modules/telepathy.pp':
  221.                ['9b32f699beb6f9c563f06f6b6d76732c'],
  222.            '/etc/selinux/targeted/modules/active/modules/amtu.pp':
  223.                ['1b87c9fef219244f80b1f8f57a2ce7ea'],
  224.            '/etc/selinux/targeted/modules/active/modules/bitlbee.pp':
  225.                ['cf0973c8fff61577cf330bb74ef75eed'],
  226.            '/etc/selinux/targeted/modules/active/modules/memcached.pp':
  227.                ['0146491b4ab9fbd2854a7e7fb2092168'],
  228.            '/etc/selinux/targeted/modules/active/modules/sandbox.pp':
  229.                ['82502d6d11b83370d1a77343f20d669f'],
  230.            '/etc/selinux/targeted/modules/active/modules/dictd.pp':
  231.                ['6119d37987ea968e90a39d96866e5805'],
  232.            '/etc/selinux/targeted/modules/active/modules/pingd.pp':
  233.                ['16c40af7785c8fa9d40789284ce8fbb9'],
  234.            '/etc/selinux/targeted/modules/active/modules/milter.pp':
  235.                ['acaec7d2ee341e97ac5e345b55f6c7ae'],
  236.            '/etc/selinux/targeted/modules/active/modules/snort.pp':
  237.                ['25f360aa5dec254a8fc18262bbe40510'],
  238.            '/etc/selinux/targeted/modules/active/modules/cups.pp':
  239.                ['5323d417895d5ab508048e2bc45367bf'],
  240.            '/etc/selinux/targeted/modules/active/modules/rdisc.pp':
  241.                ['5bed79cb1f4d5a2b822d6f8dbf53fe97'],
  242.            '/etc/selinux/targeted/modules/active/modules/rlogin.pp':
  243.                ['6f88cc86985b4bc79d4b1afbffb1a732'],
  244.            '/etc/selinux/targeted/modules/active/modules/openct.pp':
  245.                ['884f078f5d12f7b1c75cf011a94746e1'],
  246.            '/etc/selinux/targeted/modules/active/modules/dbskk.pp':
  247.                ['caa93f24bfeede892fd97c59ee8b61da'],
  248.            '/etc/selinux/targeted/modules/active/modules/bluetooth.pp':
  249.                ['ce4f1b34168c537b611783033316760e'],
  250.            '/etc/selinux/targeted/modules/active/modules/gpsd.pp':
  251.                ['dd15485b8c6e5aeac018ddbe0948464c'],
  252.            '/etc/selinux/targeted/modules/active/modules/tuned.pp':
  253.                ['5fc9de20402245e4a1a19c5b31101d06'],
  254.            '/etc/selinux/targeted/modules/active/modules/piranha.pp':
  255.                ['fcedf8588c027633bedb76b598b7586f'],
  256.            '/etc/selinux/targeted/modules/active/modules/vhostmd.pp':
  257.                ['0ca7152ed8a0ae393051876fe89ed657'],
  258.            '/etc/selinux/targeted/modules/active/modules/corosync.pp':
  259.                ['20518dface3d23d7408dd56a51c8e6e1'],
  260.            '/etc/selinux/targeted/modules/active/modules/clogd.pp':
  261.                ['533994a32ecf847a3162675e171c847c'],
  262.            '/etc/selinux/targeted/modules/active/modules/samba.pp':
  263.                ['c7cd9b91a5ba4f0744e3f55a800f2831'],
  264.            '/etc/selinux/targeted/modules/active/modules/howl.pp':
  265.                ['fef7dd76a97921c3e5e0e66fbac15091'],
  266.            '/etc/selinux/targeted/modules/active/modules/shutdown.pp':
  267.                ['55f36d9820dcd19c66729d446d3ce6b2'],
  268.            '/etc/selinux/targeted/modules/active/modules/oddjob.pp':
  269.                ['54d59b40e7bc0dc0dee3882e6c0ce9f3'],
  270.            '/etc/selinux/targeted/modules/active/modules/pcscd.pp':
  271.                ['e728f332850dfcb5637c4e8f220af2fc'],
  272.            '/etc/selinux/targeted/modules/active/modules/canna.pp':
  273.                ['de4f1a3ada6f9813da36febc31d2a282'],
  274.            '/etc/selinux/targeted/modules/active/modules/arpwatch.pp':
  275.                ['0ddc328fa054f363a035ba44ec116514'],
  276.            '/etc/selinux/targeted/modules/active/modules/seunshare.pp':
  277.                ['64844bbf79ee23e087a5741918f3a7ad'],
  278.            '/etc/selinux/targeted/modules/active/modules/rhgb.pp':
  279.                ['c9630cc5830fcb4b775985c5740f5a71'],
  280.            '/etc/selinux/targeted/modules/active/modules/prelude.pp':
  281.                ['2b85511c571c19751bb79b288267661c'],
  282.            '/etc/selinux/targeted/modules/active/modules/portmap.pp':
  283.                ['231abe579c0370f49cac533c6057792b'],
  284.            '/etc/selinux/targeted/modules/active/modules/logadm.pp':
  285.                ['980b1345ef8944a90b6efdff0c8b3278'],
  286.            '/etc/selinux/targeted/modules/active/modules/ptchown.pp':
  287.                ['987fc8a6ff50ef7eed0edc79f91b1ec5'],
  288.            '/etc/selinux/targeted/modules/active/modules/vmware.pp':
  289.                ['8cf31ec8abd75f2a6c56857146caf5a1'],
  290.            '/etc/selinux/targeted/modules/active/modules/portreserve.pp':
  291.                ['0354f017b429dead8de0d143f7950fcc'],
  292.            '/etc/selinux/targeted/modules/active/modules/awstats.pp':
  293.                ['c081d3168b28765182bb4ec937b4c0b1'],
  294.            '/etc/selinux/targeted/modules/active/modules/tmpreaper.pp':
  295.                ['ac0173dd09a54a87fdcb42d3a5e29442'],
  296.            '/etc/selinux/targeted/modules/active/modules/postgrey.pp':
  297.                ['68013352c07570ac38587df9fb7e88ee'],
  298.            '/etc/selinux/targeted/modules/active/modules/tftp.pp':
  299.                ['a47fb7872bfb06d80c8eef969d91e6f9'],
  300.            '/etc/selinux/targeted/modules/active/modules/rgmanager.pp':
  301.                ['1cee78e1ff3f64c4d013ce7b820e534b'],
  302.            '/etc/selinux/targeted/modules/active/modules/aisexec.pp':
  303.                ['95e70fd35e9cb8284488d6bf970815b7'],
  304.            '/etc/selinux/targeted/modules/active/modules/xguest.pp':
  305.                ['d8df4b61df93008cd594f98c852d4cba'],
  306.            '/etc/selinux/targeted/modules/active/modules/cobbler.pp':
  307.                ['6978d8b37b1da384130db5c5c2144175'],
  308.            '/etc/selinux/targeted/modules/active/modules/mysql.pp':
  309.                ['d147af479531042f13e70d72bd58a0e9'],
  310.            '/etc/selinux/targeted/modules/active/modules/amavis.pp':
  311.                ['7fc17b2f47c1d8226a9003df1ef67bb5'],
  312.            '/etc/selinux/targeted/modules/active/modules/fprintd.pp':
  313.                ['d58f18b496f69a74ece1f1b1b9432405'],
  314.            '/etc/selinux/targeted/modules/active/modules/nis.pp':
  315.                ['d696b167de5817226298306c79761fa2'],
  316.            '/etc/selinux/targeted/modules/active/modules/squid.pp':
  317.                ['3f9e075e79ec5aa59609a7ccebce0afe'],
  318.            '/etc/selinux/targeted/modules/active/modules/smokeping.pp':
  319.                ['98b83cac4488d7dd18c479b62dd3cf15'],
  320.            '/etc/selinux/targeted/modules/active/modules/ktalk.pp':
  321.                ['afe14e94861782679305c91da05e7d5e'],
  322.            '/etc/selinux/targeted/modules/active/modules/certwatch.pp':
  323.                ['bf13c9a642ded8354ba26d5462ddd60c'],
  324.            '/etc/selinux/targeted/modules/active/modules/games.pp':
  325.                ['3bcd17c07699d58bd436896e75a24520'],
  326.            '/etc/selinux/targeted/modules/active/modules/zabbix.pp':
  327.                ['5445ccfec7040ff1ccf3abf4de2e9a3c'],
  328.            '/etc/selinux/targeted/modules/active/modules/rwho.pp':
  329.                ['710e29c8e621de6af9ca74869624b9f0'],
  330.            '/etc/selinux/targeted/modules/active/modules/w3c.pp':
  331.                ['aea6b9518cb3fa904cc7ee82239b07c2'],
  332.            '/etc/selinux/targeted/modules/active/modules/cyphesis.pp':
  333.                ['dccb3f009cd56c5f8856861047d7f2ff'],
  334.            '/etc/selinux/targeted/modules/active/modules/kismet.pp':
  335.                ['f2d984e007275d35dd03a2d59ade507e'],
  336.            '/etc/selinux/targeted/modules/active/modules/zosremote.pp':
  337.                ['77a2681c4b1c3c001faeca9874b58ecf'],
  338.            '/etc/selinux/targeted/modules/active/modules/pads.pp':
  339.                ['76b7413009a202e228ee08c5511f3f42'],
  340.            '/etc/selinux/targeted/modules/active/modules/avahi.pp':
  341.                ['b59670ba623aba37ab8f0f1f1127893a'],
  342.            '/etc/selinux/targeted/modules/active/modules/apcupsd.pp':
  343.                ['81fae28232730a49b7660797ef4354c3'],
  344.            '/etc/selinux/targeted/modules/active/modules/usernetctl.pp':
  345.                ['22850457002a48041d885c0d74fbd934'],
  346.            '/etc/selinux/targeted/modules/active/modules/finger.pp':
  347.                ['5dd6b44358bbfabfdc4f546e1ed34370'],
  348.            '/etc/selinux/targeted/modules/active/modules/dhcp.pp':
  349.                ['7e63b07b64848a017eec5d5f6b88f22e'],
  350.            '/etc/selinux/targeted/modules/active/modules/xen.pp':
  351.                ['67086e8e94bdaab8247ac4d2e23162d1'],
  352.            '/etc/selinux/targeted/modules/active/modules/plymouthd.pp':
  353.                ['1916027e7c9f28430fa2ac30334e8964'],
  354.            '/etc/selinux/targeted/modules/active/modules/uucp.pp':
  355.                ['5bec7a345a314a37b4a2227bdfa926f1'],
  356.            '/etc/selinux/targeted/modules/active/modules/daemontools.pp':
  357.                ['aad7633adfc8b04e863b481deebaf14a'],
  358.            '/etc/selinux/targeted/modules/active/modules/kdumpgui.pp':
  359.                ['66e08b4187623fa1c535972a35ec058c'],
  360.            '/etc/selinux/targeted/modules/active/modules/privoxy.pp':
  361.                ['f13c986051659fa900786ea54a59ceae'],
  362.            '/etc/selinux/targeted/modules/active/modules/unprivuser.pp':
  363.                ['a0d128b495a6ea5da72c849ac63c5848'],
  364.            '/etc/selinux/targeted/modules/active/modules/ada.pp':
  365.                ['a75fd52c873e2c9326ad87f7515a664f'],
  366.            '/etc/selinux/targeted/modules/active/modules/lircd.pp':
  367.                ['3cc5cc5b24d40416f9d630a80005d33b'],
  368.            '/etc/selinux/targeted/modules/active/modules/openoffice.pp':
  369.                ['522c3ee13bc37cbe9903d00f0cbccd1d'],
  370.            '/etc/selinux/targeted/modules/active/modules/puppet.pp':
  371.                ['9da4c553f40f3dea876171e672168044'],
  372.            '/etc/selinux/targeted/modules/active/modules/wine.pp':
  373.                ['31c470eabd98c5a5dbc66ba52ad64de0'],
  374.            '/etc/selinux/targeted/modules/active/modules/ulogd.pp':
  375.                ['065551ea63de34a7257ecec152f61552'],
  376.            '/etc/selinux/targeted/modules/active/modules/mplayer.pp':
  377.                ['f889dbfa3d9ef071d8e569def835a2f3'],
  378.            '/etc/selinux/targeted/modules/active/modules/ftp.pp':
  379.                ['75a9f3563903eb8126ffbcc9277e1d8c'],
  380.            '/etc/selinux/targeted/modules/active/modules/gnome.pp':
  381.                ['b859e2d45123f60ff27a90cdb0f40e1b'],
  382.            '/etc/selinux/targeted/modules/active/modules/ethereal.pp':
  383.                ['8963c6b80025b27850f0cdf565e5bd54'],
  384.            '/etc/selinux/targeted/modules/active/modules/iscsi.pp':
  385.                ['7786cb4a84889010751b4d89c72a2956'],
  386.            '/etc/selinux/targeted/modules/active/modules/chrome.pp':
  387.                ['cb44c1c7b13cc04c07c4e787a259b63f'],
  388.            '/etc/selinux/targeted/modules/active/modules/guest.pp':
  389.                ['308d614589af73e39a22e5c741e9eecb'],
  390.            '/etc/selinux/targeted/modules/active/modules/inn.pp':
  391.                ['8d60592dcd3bf4d2fa97f0fefa9374ca'],
  392.            '/etc/selinux/targeted/modules/active/modules/gitosis.pp':
  393.                ['21c79a711157224bebba0a2cccbe8881'],
  394.            '/etc/selinux/targeted/modules/active/modules/ksmtuned.pp':
  395.                ['8f985e777c206d2bde3fc2ac6a28cd24'],
  396.            '/etc/selinux/targeted/modules/active/modules/sosreport.pp':
  397.                ['9b4780d27555e94335f80a0bb2ab4f14'],
  398.            '/etc/selinux/targeted/modules/active/modules/ipsec.pp':
  399.                ['68cacb8c78796957fb4a181390033b16'],
  400.            '/etc/selinux/targeted/modules/active/modules/comsat.pp':
  401.                ['1cecb3f5cbe24251017908e14838ee2a'],
  402.            '/etc/selinux/targeted/modules/active/modules/gpg.pp':
  403.                ['75358ddabb045e91010d80f1ab68307a'],
  404.            '/etc/selinux/targeted/modules/active/modules/gnomeclock.pp':
  405.                ['a4e74df48faab3af8f4df0fa16c65c7e'],
  406.            '/etc/selinux/targeted/modules/active/modules/sasl.pp':
  407.                ['5ba9be813a7dd4236fc2d37bc17c5052'],
  408.            '/etc/selinux/targeted/modules/active/modules/vpn.pp':
  409.                ['32ae00c287432ae5ad4f8affbc9e44fe'],
  410.            '/etc/selinux/targeted/modules/active/modules/accountsd.pp':
  411.                ['308057b48c6d70a45e5a603dbe625c2d'],
  412.            '/etc/selinux/targeted/modules/active/modules/devicekit.pp':
  413.                ['1f5a8f12ebeebfed2cfeb3ee4648dd13'],
  414.            '/etc/selinux/targeted/modules/active/modules/psad.pp':
  415.                ['b02f11705249c93735f019f5b97fdf7b'],
  416.            '/etc/selinux/targeted/modules/active/modules/mono.pp':
  417.                ['8bba1cc6826e8300c140f9c393ad07e9'],
  418.            '/etc/selinux/targeted/modules/active/modules/cachefilesd.pp':
  419.                ['82b93ba87b5920ecc8a7388f4cf8ea43'],
  420.            '/etc/selinux/targeted/modules/active/modules/usbmodules.pp':
  421.                ['20c3a57da3c1311a75a63f1c6ae91bf3'],
  422.            '/etc/selinux/targeted/modules/active/modules/certmonger.pp':
  423.                ['b9fe8ba6abc5204cd8eec546f5614ff5'],
  424.            '/etc/selinux/targeted/modules/active/modules/pegasus.pp':
  425.                ['bb0ec4379c28b196d1794d7310111d98'],
  426.            '/etc/selinux/targeted/modules/active/modules/ntop.pp':
  427.                ['99b46fe44ccf3c4e045dbc73d2a88f59'],
  428.            '/etc/selinux/targeted/modules/active/modules/zebra.pp':
  429.                ['12adcaae458d18f650578ce25e10521a'],
  430.            '/etc/selinux/targeted/modules/active/modules/soundserver.pp':
  431.                ['583abd9ccef70279bff856516974d471'],
  432.            '/etc/selinux/targeted/modules/active/modules/stunnel.pp':
  433.                ['2693ac1bf08287565c3b4e58d0f9ea55'],
  434.            '/etc/selinux/targeted/modules/active/modules/ldap.pp':
  435.                ['039baf0976f316c3f209a5661174a72e'],
  436.            '/etc/selinux/targeted/modules/active/modules/fail2ban.pp':
  437.                ['ce13513c427ff140bf988b01bd52e886'],
  438.            '/etc/selinux/targeted/modules/active/modules/spamassassin.pp':
  439.                ['e02232992676b0e1279c54bfeea290e3'],
  440.            '/etc/selinux/targeted/modules/active/modules/procmail.pp':
  441.                ['d5c58e90fac452a1a6d68cc496e7f1ae'],
  442.            '/etc/selinux/targeted/modules/active/modules/afs.pp':
  443.                ['6e7a4bf08dc7fa5a0f97577b913267ad'],
  444.            '/etc/selinux/targeted/modules/active/modules/ricci.pp':
  445.                ['8b1d44245be204907c82c3580a43901d'],
  446.            '/etc/selinux/targeted/modules/active/modules/qmail.pp':
  447.                ['ea08eb2172c275598d4f85c9b78182cd'],
  448.            '/etc/selinux/targeted/modules/active/modules/ccs.pp':
  449.                ['cad223d57f431e2f88a1d1542c2ac504'],
  450.            '/etc/selinux/targeted/modules/active/modules/audioentropy.pp':
  451.                ['19f6fd5e3ee2a3726a952631e993a133'],
  452.            '/etc/selinux/targeted/modules/active/modules/ncftool.pp':
  453.                ['c15f4833a21e9c8cd1237ee568aadcf3'],
  454.            '/etc/selinux/targeted/modules/active/modules/nx.pp':
  455.                ['3677983206101cfcd2182e180ef3876b'],
  456.            '/etc/selinux/targeted/modules/active/modules/rtkit.pp':
  457.                ['0eaae15f4c12522270b26769487a06e0'],
  458.            '/etc/selinux/targeted/modules/active/modules/ntp.pp':
  459.                ['141339ee3372e07d32575c6777c8e466'],
  460.            '/etc/selinux/targeted/modules/active/modules/likewise.pp':
  461.                ['b5f0d18f8b601e102fd9728fbb309692'],
  462.            '/etc/selinux/targeted/modules/active/modules/aide.pp':
  463.                ['69600bc8a529f8128666a563c7409929'],
  464.            '/etc/selinux/targeted/modules/active/modules/nslcd.pp':
  465.                ['5c87b1c80bdd8bbf60c33ef51a765a93'],
  466.            '/etc/selinux/targeted/modules/active/modules/slocate.pp':
  467.                ['fdea88c374382f3d652a1ac529fbd189'],
  468.            '/etc/selinux/targeted/modules/active/modules/execmem.pp':
  469.                ['44cc2d117e3bf1a33d4e3516aaa7339d'],
  470.            '/etc/selinux/targeted/modules/active/modules/cpufreqselector.pp':
  471.                ['7da9c9690dc4f076148ef35c3644af13'],
  472.            '/etc/selinux/targeted/modules/active/modules/cmirrord.pp':
  473.                ['084b532fa5ccd6775c483d757bcd0920'],
  474.            '/etc/selinux/targeted/modules/active/modules/bind.pp':
  475.                ['5560f5706c8c8e83d8a2ac03a85b93fb'],
  476.            '/etc/selinux/targeted/modules/active/modules/uml.pp':
  477.                ['a0841bc9ffca619fe5d44c557b70d258'],
  478.            '/etc/selinux/targeted/modules/active/modules/staff.pp':
  479.                ['bdf16ee0fa0721770aa31c52e45227c3'],
  480.            '/etc/selinux/targeted/modules/active/modules/certmaster.pp':
  481.                ['bc589a4f0dd49a05d52b9ffda7bdd149'],
  482.            '/etc/selinux/targeted/modules/active/modules/webalizer.pp':
  483.                ['c99ccad469be3c901ede9da9a87e44b2'],
  484.            '/etc/selinux/targeted/modules/active/modules/hal.pp':
  485.                ['c75783ec2dd49d437a242e0c69c31c96'],
  486.            '/etc/selinux/targeted/modules/active/modules/kdump.pp':
  487.                ['d731820c7b5bb711566ea23970106b7a'],
  488.            '/etc/selinux/targeted/modules/active/modules/firewallgui.pp':
  489.                ['ee3522a0072989ed08f70b03f7fd69d9'],
  490.            '/etc/selinux/targeted/modules/active/modules/tcpd.pp':
  491.                ['b1f7db819812da14c4e836a9d9e79980'],
  492.            '/etc/selinux/targeted/modules/active/modules/mailman.pp':
  493.                ['4116cbe11d943a076dd06cea91993745'],
  494.            '/etc/selinux/targeted/modules/active/modules/smartmon.pp':
  495.                ['45d6440b436d8ac3f042e80c392dd672'],
  496.            '/etc/selinux/targeted/modules/active/modules/smoltclient.pp':
  497.                ['dcfd6ecd62ee7191abda39315ec6ef1b'],
  498.            '/etc/selinux/targeted/modules/active/modules/kerberos.pp':
  499.                ['936533081cfbe28eb9145fde86edb4f8'],
  500.            '/etc/selinux/targeted/modules/active/modules/lockdev.pp':
  501.                ['e2da620d3272f296dd90bff8b921d203'],
  502.            '/etc/selinux/targeted/modules/active/modules/automount.pp':
  503.                ['a06d3d617c6d8c29e29ce3fb0db48c9c'],
  504.            '/etc/selinux/targeted/modules/active/modules/webadm.pp':
  505.                ['4ac9b2f95f8d8218ec93f001995fd8ba'],
  506.            '/etc/selinux/targeted/modules/active/modules/pyzor.pp':
  507.                ['c2b00c08d77d7d5a8588dd82c489e354'],
  508.            '/etc/selinux/targeted/modules/active/modules/rssh.pp':
  509.                ['aacef6c826e9d699e84a1dd564b68105'],
  510.            '/etc/selinux/targeted/modules/active/modules/nsplugin.pp':
  511.                ['0c90d308f5e956900150eb6ed84b0b54'],
  512.            '/etc/selinux/targeted/modules/active/modules/lpd.pp':
  513.                ['5bf17a46aa2d3e2ecc0daffcf092054e'],
  514.            '/etc/selinux/targeted/modules/active/modules/dcc.pp':
  515.                ['84749af337d72ba6bbbe54b013c6c62c'],
  516.            '/etc/selinux/targeted/modules/active/modules/irc.pp':
  517.                ['42897f214251c7ca9bc04379c4abff5e'],
  518.            '/etc/selinux/targeted/modules/active/modules/icecast.pp':
  519.                ['962c81fc8ef5fd49c925a2249d229d1d'],
  520.            '/etc/selinux/targeted/modules/active/modules/dnsmasq.pp':
  521.                ['ec4a8a50eb5806e450d97a77cbe8a8b4'],
  522.            '/etc/selinux/targeted/modules/active/modules/jabber.pp':
  523.                ['5a528d52f7337d44bfc867333f2b1921'],
  524.            '/etc/selinux/targeted/modules/active/modules/remotelogin.pp':
  525.                ['68c22a0bc6e4d5031153cf10d75ba76a'],
  526.            '/etc/selinux/targeted/modules/active/modules/boinc.pp':
  527.                ['a70386e9ffdaccd04cbb565e6fe5c822'],
  528.            '/etc/selinux/targeted/modules/active/modules/mrtg.pp':
  529.                ['7e6f395e72768d350d259c15d22a1cbb'],
  530.            '/etc/selinux/targeted/modules/active/modules/snmp.pp':
  531.                ['fc5166e3066504601037054874fe0487'],
  532.            '/etc/selinux/targeted/modules/active/modules/cyrus.pp':
  533.                ['d2e792bf111ce4a6ffdb87fe11d89d16'],
  534.            '/etc/selinux/targeted/modules/active/modules/dovecot.pp':
  535.                ['b716de8b77f0dfeb9212d5cf36bddfa1'],
  536.            '/etc/selinux/targeted/modules/active/modules/cdrecord.pp':
  537.                ['24c0325480e2f1d6cf1ce31c25d5f10a'],
  538.            '/etc/selinux/targeted/modules/active/modules/calamaris.pp':
  539.                ['c7ec43f01369524db32249fb755f4e7f'],
  540.            '/etc/selinux/targeted/modules/active/modules/kerneloops.pp':
  541.                ['2493d3308dfcd34e94308af9d5c888c3'],
  542.            '/etc/selinux/targeted/modules/active/modules/razor.pp':
  543.                ['06425e50a31f14cec090c30e05fb9827'],
  544.            '/etc/selinux/targeted/modules/active/netfilter_contexts':
  545.                ['d41d8cd98f00b204e9800998ecf8427e'],
  546.            '/etc/selinux/targeted/modules/active/seusers.final':
  547.                ['fdf1cdf1d373e4583ca759617a1d2af3'],
  548.            '/etc/selinux/targeted/modules/active/file_contexts.homedirs':
  549.                ['d7c4747704e9021ec2e16c7139fedfd9'],
  550.            '/etc/selinux/targeted/modules/active/commit_num':
  551.                ['c08cc266624f6409b01432dac9576ab0'],
  552.            '/etc/selinux/targeted/modules/active/policy.kern':
  553.                ['5398a60f820803049b5bb7d90dd6196b'],
  554.            '/etc/selinux/targeted/modules/active/homedir_template':
  555.                ['682a31c8036aaf9cf969093d7162960a'],
  556.            '/etc/selinux/targeted/modules/semanage.read.LOCK':
  557.                ['d41d8cd98f00b204e9800998ecf8427e'],
  558.            '/etc/selinux/targeted/contexts/failsafe_context':
  559.                ['940b12538b676287b3c33e68426898ac'],
  560.            '/etc/selinux/targeted/contexts/virtual_domain_context':
  561.                ['1e28f1b8e58e56a64c852bd77f57d121'],
  562.            '/etc/selinux/targeted/contexts/removable_context':
  563.                ['e56a6b14d2bed27405d2066af463df9f'],
  564.            '/etc/selinux/targeted/contexts/netfilter_contexts':
  565.                ['d41d8cd98f00b204e9800998ecf8427e'],
  566.            '/etc/selinux/targeted/contexts/userhelper_context':
  567.                ['53441d64f9bc6337e3aac33f05d0954c'],
  568.            '/etc/selinux/targeted/contexts/virtual_image_context':
  569.                ['b21a69d3423d2e085d5195e25922eaa1'],
  570.            '/etc/selinux/targeted/contexts/securetty_types':
  571.                ['ee2445f940ed1b33e778a921cde8ad9e'],
  572.            '/etc/selinux/targeted/contexts/default_type':
  573.                ['d0f63fea19ee82e5f65bdbb1de899c5d'],
  574.            '/etc/selinux/targeted/contexts/dbus_contexts':
  575.                ['b1c42884fa5bdbde53d64cff469374fd'],
  576.            '/etc/selinux/targeted/contexts/files/file_contexts':
  577.                ['1622b57a3b85db3112c5f71238c68d3e'],
  578.            '/etc/selinux/targeted/contexts/files/file_contexts.homedirs':
  579.                ['d7c4747704e9021ec2e16c7139fedfd9'],
  580.            '/etc/selinux/targeted/contexts/files/media':
  581.                ['3c867677892c0a15dc0b9e9811cc2c49'],
  582.            '/etc/selinux/targeted/contexts/initrc_context':
  583.                ['99866a62735a38b2bf839233c1a1689d'],
  584.            '/etc/selinux/targeted/contexts/x_contexts':
  585.                ['9dde3f5e3ddac42b9e99a4613c972b97'],
  586.            '/etc/selinux/targeted/contexts/customizable_types':
  587.                ['68be87281cf3d40cb2c4606cd2b1ea2b'],
  588.            '/etc/selinux/targeted/contexts/users/xguest_u':
  589.                ['e26010a418df86902332c57434370246'],
  590.            '/etc/selinux/targeted/contexts/users/unconfined_u':
  591.                ['ee88bed48d9601ff2b11f68f97d361ac'],
  592.            '/etc/selinux/targeted/contexts/users/staff_u':
  593.                ['f3412f7cbf441078a9de40fcaab93254'],
  594.            '/etc/selinux/targeted/contexts/users/root':
  595.                ['328e08341d1ff9296573dd43c355e283'],
  596.            '/etc/selinux/targeted/contexts/users/user_u':
  597.                ['2fe911f440282fda0590cd99540da579'],
  598.            '/etc/selinux/targeted/contexts/users/guest_u':
  599.                ['61e7e7e7403b2eac30e312342e66e4cd'],
  600.            '/etc/selinux/targeted/contexts/default_contexts':
  601.                ['0888c75fc814058bb3c01ef58f7a1f47'],
  602.            '/etc/selinux/targeted/policy/policy.24':
  603.                ['5398a60f820803049b5bb7d90dd6196b'],
  604.            '/etc/selinux/targeted/setrans.conf':
  605.                ['ae70362b6fa2af117bd6e293ce232069'],
  606.            '/etc/selinux/targeted/seusers':
  607.                ['fdf1cdf1d373e4583ca759617a1d2af3'],
  608.            '/etc/selinux/config': ['91081ef6d958e79795d0255d7c374a56'],
  609.            '/etc/selinux/restorecond_user.conf':
  610.                ['4e1b5b5e38c660f87d5a4f7d3a998c29'],
  611.            '/etc/selinux/semanage.conf': ['f33b524aef1a4df2a3d0eecdda041a5c'],
  612.            '/etc/sgml/xml-core.cat': ['bcd454c9bf55a3816a134f9766f5928f'],
  613.            '/etc/shells': ['0e85c87e09d716ecb03624ccff511760'],
  614.            '/etc/ssh/sshd_config': ['e24f749808133a27d94fda84a89bb27b',
  615.                                     '8caefdd9e251b7cc1baa37874149a870',
  616.                                     '874fafed9e745b14e5fa8ae71b82427d'],
  617.            '/etc/sudoers': ['02f74ccbec48997f402a063a172abb48'],
  618.            '/etc/ufw/after.rules': ['/usr/share/ufw/after.rules'],
  619.            '/etc/ufw/after6.rules': ['/usr/share/ufw/after6.rules'],
  620.            '/etc/ufw/before.rules': ['/usr/share/ufw/before.rules'],
  621.            '/etc/ufw/before6.rules': ['/usr/share/ufw/before6.rules'],
  622.            '/etc/ufw/ufw.conf': ['/usr/share/ufw/ufw.conf']}
  623.  
  624. for pathname, overrides in MD5SUMS.iteritems():
  625.     for i in range(len(overrides)):
  626.         if '/' != overrides[i][0]:
  627.             continue
  628.         try:
  629.             overrides[i] = hashlib.md5(open(overrides[i]).read()).hexdigest()
  630.         except IOError:
  631.             pass
  632.  
  633.  
  634. def files(b, r):
  635.     logging.info('searching for configuration files')
  636.  
  637.     # Visit every file in `/etc` except those on the exclusion list above.
  638.     for dirpath, dirnames, filenames in os.walk('/etc'):
  639.  
  640.         # Determine if this entire directory should be ignored by default.
  641.         ignored = r.ignore_file(dirpath)
  642.  
  643.         # Collect up the full pathname to each file, `lstat` them all, and
  644.         # note which ones will probably be ignored.
  645.         files = []
  646.         for filename in filenames:
  647.             pathname = os.path.join(dirpath, filename)
  648.             try:
  649.                 files.append((pathname,
  650.                               os.lstat(pathname),
  651.                               r.ignore_file(pathname, ignored)))
  652.             except OSError as e:
  653.                 logging.warning('{0} caused {1} - try running as root'.
  654.                                 format(pathname, errno.errorcode[e.errno]))
  655.  
  656.         # Track the ctime of each file in this directory.  Weed out false
  657.         # positives by ignoring files with common ctimes.
  658.         ctimes = defaultdict(lambda: 0)
  659.  
  660.         # Map the ctimes of each directory entry that isn't being ignored.
  661.         for pathname, s, ignored in files:
  662.             if not ignored:
  663.                 ctimes[s.st_ctime] += 1
  664.         for dirname in dirnames:
  665.             try:
  666.                 ctimes[os.lstat(os.path.join(dirpath, dirname)).st_ctime] += 1
  667.             except OSError:
  668.                 pass
  669.  
  670.         for pathname, s, ignored in files:
  671.  
  672.             # Always ignore block special files, character special files,
  673.             # pipes, and sockets.  They end up looking like deadlocks.
  674.             if stat.S_ISBLK(s.st_mode) \
  675.             or stat.S_ISCHR(s.st_mode) \
  676.             or stat.S_ISFIFO(s.st_mode) \
  677.             or stat.S_ISSOCK(s.st_mode):
  678.                 continue
  679.  
  680.             # Make sure this pathname will actually be able to be included
  681.             # in the blueprint.  This is a bit of a cop-out since the file
  682.             # could be important but at least it's not a crashing bug.
  683.             try:
  684.                 pathname = unicode(pathname)
  685.             except UnicodeDecodeError:
  686.                 logging.warning('{0} not UTF-8 - skipping it'.
  687.                                 format(repr(pathname)[1:-1]))
  688.                 continue
  689.  
  690.             # Ignore ignored files and files that share their ctime with other
  691.             # files in the directory.  This is a very strong indication that
  692.             # the file is original to the system and should be ignored.
  693.             if ignored \
  694.             or 1 < ctimes[s.st_ctime] and r.ignore_file(pathname, True):
  695.                 continue
  696.  
  697.             # Check for a Mustache template and an optional shell script
  698.             # that templatize this file.
  699.             try:
  700.                 template = open(
  701.                     '{0}.blueprint-template.mustache'.format(pathname)).read()
  702.             except IOError:
  703.                 template = None
  704.             try:
  705.                 data = open(
  706.                     '{0}.blueprint-template.sh'.format(pathname)).read()
  707.             except IOError:
  708.                 data = None
  709.  
  710.             # The content is used even for symbolic links to determine whether
  711.             # it has changed from the packaged version.
  712.             try:
  713.                 content = open(pathname).read()
  714.             except IOError:
  715.                 #logging.warning('{0} not readable'.format(pathname))
  716.                 continue
  717.  
  718.             # Ignore files that are unchanged from their packaged version.
  719.             if _unchanged(pathname, content, r):
  720.                 continue
  721.  
  722.             # Resolve the rest of the file's metadata from the
  723.             # `/etc/passwd` and `/etc/group` databases.
  724.             try:
  725.                 pw = pwd.getpwuid(s.st_uid)
  726.                 owner = pw.pw_name
  727.             except KeyError:
  728.                 owner = s.st_uid
  729.             try:
  730.                 gr = grp.getgrgid(s.st_gid)
  731.                 group = gr.gr_name
  732.             except KeyError:
  733.                 group = s.st_gid
  734.             mode = '{0:o}'.format(s.st_mode)
  735.  
  736.             # A symbolic link's content is the link target.
  737.             if stat.S_ISLNK(s.st_mode):
  738.                 content = os.readlink(pathname)
  739.  
  740.                 # Ignore symbolic links providing backwards compatibility
  741.                 # between SystemV init and Upstart.
  742.                 if '/lib/init/upstart-job' == content:
  743.                     continue
  744.  
  745.                 # Ignore symbolic links into the Debian alternatives system.
  746.                 # These are almost certainly managed by packages.
  747.                 if content.startswith('/etc/alternatives/'):
  748.                     continue
  749.  
  750.                 b.add_file(pathname,
  751.                            content=content,
  752.                            encoding='plain',
  753.                            group=group,
  754.                            mode=mode,
  755.                            owner=owner)
  756.  
  757.             # A regular file is stored as plain text only if it is valid
  758.             # UTF-8, which is required for JSON serialization.
  759.             else:
  760.                 kwargs = dict(group=group,
  761.                               mode=mode,
  762.                               owner=owner)
  763.                 try:
  764.                     if template:
  765.                         if data:
  766.                             kwargs['data'] = data.decode('utf_8')
  767.                         kwargs['template'] = template.decode('utf_8')
  768.                     else:
  769.                         kwargs['content'] = content.decode('utf_8')
  770.                     kwargs['encoding'] = 'plain'
  771.                 except UnicodeDecodeError:
  772.                     if template:
  773.                         if data:
  774.                             kwargs['data'] = base64.b64encode(data)
  775.                         kwargs['template'] = base64.b64encode(template)
  776.                     else:
  777.                         kwargs['content'] = base64.b64encode(content)
  778.                     kwargs['encoding'] = 'base64'
  779.                 b.add_file(pathname, **kwargs)
  780.  
  781.             # If this file is a service init script or config , create a
  782.             # service resource.
  783.             try:
  784.                 manager, service = util.parse_service(pathname)
  785.                 if not r.ignore_service(manager, service):
  786.                     b.add_service(manager, service)
  787.                     b.add_service_package(manager,
  788.                                           service,
  789.                                           'apt',
  790.                                           *_dpkg_query_S(pathname))
  791.                     b.add_service_package(manager,
  792.                                           service,
  793.                                           'yum',
  794.                                           *_rpm_qf(pathname))
  795.             except ValueError:
  796.                 pass
  797.  
  798.  
  799. def _dpkg_query_S(pathname):
  800.     """
  801.    Return a list of package names that contain `pathname` or `[]`.  This
  802.    really can be a list thanks to `dpkg-divert`(1).
  803.    """
  804.  
  805.     # Cache the pathname-to-package mapping.
  806.     if not hasattr(_dpkg_query_S, '_cache'):
  807.         _dpkg_query_S._cache = defaultdict(set)
  808.         cache_ref = _dpkg_query_S._cache
  809.         for listname in glob.iglob('/var/lib/dpkg/info/*.list'):
  810.             package = os.path.splitext(os.path.basename(listname))[0]
  811.             for line in open(listname):
  812.                 cache_ref[line.rstrip()].add(package)
  813.  
  814.     # Return the list of packages that contain this file, if any.
  815.     if pathname in _dpkg_query_S._cache:
  816.         return list(_dpkg_query_S._cache[pathname])
  817.  
  818.     # If `pathname` isn't in a package but is a symbolic link, see if the
  819.     # symbolic link is in a package.  `postinst` programs commonly display
  820.     # this pattern.
  821.     try:
  822.         return _dpkg_query_S(os.readlink(pathname))
  823.     except OSError:
  824.         pass
  825.  
  826.     return []
  827.  
  828.  
  829. def _dpkg_md5sum(package, pathname):
  830.     """
  831.    Find the MD5 sum of the packaged version of pathname or `None` if the
  832.    `pathname` does not come from a Debian package.
  833.    """
  834.  
  835.     # Cache any MD5 sums stored in the status file.  These are typically
  836.     # conffiles and the like.
  837.     if not hasattr(_dpkg_md5sum, '_status_cache'):
  838.         _dpkg_md5sum._status_cache = {}
  839.         cache_ref = _dpkg_md5sum._status_cache
  840.         try:
  841.             pattern = re.compile(r'^ (\S+) ([0-9a-f]{32})')
  842.             for line in open('/var/lib/dpkg/status'):
  843.                 match = pattern.match(line)
  844.                 if not match:
  845.                     continue
  846.                 cache_ref[match.group(1)] = match.group(2)
  847.         except IOError:
  848.             pass
  849.  
  850.     # Return this file's MD5 sum, if it can be found.
  851.     try:
  852.         return _dpkg_md5sum._status_cache[pathname]
  853.     except KeyError:
  854.         pass
  855.  
  856.     # Cache the MD5 sums for files in this package.
  857.     if not hasattr(_dpkg_md5sum, '_cache'):
  858.         _dpkg_md5sum._cache = defaultdict(dict)
  859.     if package not in _dpkg_md5sum._cache:
  860.         cache_ref = _dpkg_md5sum._cache[package]
  861.         try:
  862.             for line in open('/var/lib/dpkg/info/{0}.md5sums'.format(package)):
  863.                 md5sum, rel_pathname = line.split(None, 1)
  864.                 cache_ref['/{0}'.format(rel_pathname.rstrip())] = md5sum
  865.         except IOError:
  866.             pass
  867.  
  868.     # Return this file's MD5 sum, if it can be found.
  869.     try:
  870.         return _dpkg_md5sum._cache[package][pathname]
  871.     except KeyError:
  872.         pass
  873.  
  874.     return None
  875.  
  876.  
  877. def _rpm_qf(pathname):
  878.     """
  879.    Return a list of package names that contain `pathname` or `[]`.  RPM
  880.    might not actually support a single pathname being claimed by more
  881.    than one package but `dpkg` does so the interface is maintained.
  882.    """
  883.     try:
  884.         p = subprocess.Popen(['rpm', '--qf=%{NAME}', '-qf', pathname],
  885.                              close_fds=True,
  886.                              stdout=subprocess.PIPE,
  887.                              stderr=subprocess.PIPE)
  888.     except OSError:
  889.         return []
  890.     stdout, stderr = p.communicate()
  891.     if 0 != p.returncode:
  892.         return []
  893.     return [stdout]
  894.  
  895.  
  896. def _rpm_md5sum(pathname):
  897.     """
  898.    Find the MD5 sum of the packaged version of pathname or `None` if the
  899.    `pathname` does not come from an RPM.
  900.    """
  901.  
  902.     if not hasattr(_rpm_md5sum, '_cache'):
  903.         _rpm_md5sum._cache = {}
  904.         symlinks = []
  905.         try:
  906.             p = subprocess.Popen(['rpm', '-qa', '--dump'],
  907.                                  close_fds=True,
  908.                                  stdout=subprocess.PIPE,
  909.                                  stderr=subprocess.PIPE)
  910.             pattern = re.compile(r'^(/etc/\S+) \d+ \d+ ([0-9a-f]+) ' # No ,
  911.                                   '(0\d+) \S+ \S+ \d \d \d (\S+)$')
  912.             for line in p.stdout:
  913.                 match = pattern.match(line)
  914.                 if match is None:
  915.                     continue
  916.                 if '0120777' == match.group(3):
  917.                     symlinks.append((match.group(1), match.group(4)))
  918.                 else:
  919.                     _rpm_md5sum._cache[match.group(1)] = match.group(2)
  920.  
  921.             # Find the MD5 sum of the targets of any symbolic links, even
  922.             # if the target is outside of /etc.
  923.             pattern = re.compile(r'^(/\S+) \d+ \d+ ([0-9a-f]+) ' # No ,
  924.                                   '(0\d+) \S+ \S+ \d \d \d (\S+)$')
  925.             for pathname, target in symlinks:
  926.                 if '/' != target[0]:
  927.                     target = os.path.normpath(os.path.join(
  928.                         os.path.dirname(pathname), target))
  929.                 if target in _rpm_md5sum._cache:
  930.                     _rpm_md5sum._cache[pathname] = _rpm_md5sum._cache[target]
  931.                 else:
  932.                     p = subprocess.Popen(['rpm', '-qf', '--dump', target],
  933.                                          close_fds=True,
  934.                                          stdout=subprocess.PIPE,
  935.                                          stderr=subprocess.PIPE)
  936.                     for line in p.stdout:
  937.                         match = pattern.match(line)
  938.                         if match is not None and target == match.group(1):
  939.                             _rpm_md5sum._cache[pathname] = match.group(2)
  940.  
  941.         except OSError:
  942.             pass
  943.  
  944.     return _rpm_md5sum._cache.get(pathname, None)
  945.  
  946. def _unchanged(pathname, content, r):
  947.     """
  948.    Return `True` if a file is unchanged from its packaged version.
  949.    """
  950.  
  951.     # Ignore files that are from the `base-files` package (which
  952.     # doesn't include MD5 sums for every file for some reason).
  953.     apt_packages = _dpkg_query_S(pathname)
  954.     if 'base-files' in apt_packages:
  955.         return True
  956.  
  957.     # Ignore files that are unchanged from their packaged version,
  958.     # or match in MD5SUMS.
  959.     md5sums = MD5SUMS.get(pathname, [])
  960.     md5sums.extend([_dpkg_md5sum(package, pathname)
  961.                     for package in apt_packages])
  962.     md5sum = _rpm_md5sum(pathname)
  963.     if md5sum is not None:
  964.         md5sums.append(md5sum)
  965.     if (hashlib.md5(content).hexdigest() in md5sums \
  966.         or 64 in [len(md5sum or '') for md5sum in md5sums] \
  967.            and hashlib.sha256(content).hexdigest() in md5sums) \
  968.        and r.ignore_file(pathname, True):
  969.         return True
  970.  
  971.     return False
  972.  
downloadfiles.py Source code - Download blueprint Source code
Related Source Codes/Software:
PullToRefresh - A simple iPhone TableViewController for adding the... 2017-05-12
mrjob - Run MapReduce jobs on Hadoop or Amazon Web Service... 2017-05-11
wax - Wax is now being maintained by alibaba ... 2017-05-11
ledisdb - a high performance NoSQL powered by Go ... 2017-05-11
d3-cloud - Create word clouds in JavaScript. ... 2017-05-11
MTStatusBarOverlay - A custom iOS status bar overlay seen in Apps like ... 2017-05-12
www.html5rocks.com - ....a top-notch resource for web developer 2017-05-12
hologram - A markdown based documentation system for style gu... 2017-05-12
isso - a Disqus alternative https:... 2017-05-12
python3-cookbook - "The Python Cookbook" 3 rd Edition Translatio 2017-05-12
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top