home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / pyshared / GdmGreeter / camouflage.py < prev    next >
Encoding:
Python Source  |  2013-01-10  |  1.8 KB  |  57 lines

  1. #!/usr/bin/python
  2. #
  3. # Copyright 2012 Tails developers <tails@boum.org>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. #  it under the terms of the GNU General Public License as published by
  7. #  the Free Software Foundation, either version 3 of the License, or
  8. #  (at your option) any later version.
  9. #
  10. #  This program is distributed in the hope that it will be useful,
  11. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. #  GNU General Public License for more details.
  14. #
  15. #  You should have received a copy of the GNU General Public License
  16. #  along with this program.  If not, see <http://www.gnu.org/licenses/>
  17. #
  18. """Camouflage handling
  19.  
  20. """
  21. import os
  22. import logging
  23. import pipes
  24.  
  25. import GdmGreeter.config
  26.  
  27. class CamouflageSettings(object):
  28.     """Model storing settings related to camouflage
  29.  
  30.     """
  31.     def __init__(self):
  32.         # Which OS to impersonate
  33.         self.os = None
  34.         # XXX: this should read the content of the setting file
  35.  
  36.     @property
  37.     def os(self):
  38.         return self._os
  39.  
  40.     @os.setter
  41.     def os(self, new_os):
  42.         camouflage_settings_file = GdmGreeter.config.camouflage_settings
  43.         self._os = new_os
  44.         if new_os:
  45.             with open(camouflage_settings_file, 'w') as f:
  46.                 os.chmod(camouflage_settings_file, 0o600)
  47.                 f.write('TAILS_CAMOUFLAGE_OS=%s\n' % pipes.quote(self.os))
  48.                 logging.debug('camouflage setting written to %s',
  49.                               camouflage_settings_file)
  50.         else:
  51.             try:
  52.                 os.unlink(camouflage_settings_file)
  53.                 logging.debug('removed %s', camouflage_settings_file)
  54.             except OSError:
  55.                 # configuration file does not exist
  56.                 pass
  57.