home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / whisperback / config.py < prev   
Encoding:
Python Source  |  2013-01-06  |  5.4 KB  |  174 lines

  1. # -*- coding: UTF-8 -*-
  2. #
  3. # Tails configuration file for Whisperback
  4. # ==========================================
  5. #
  6. # This is a python script that will be read at startup. Any python
  7. # syntax is valid.
  8.  
  9. # IMPORTS
  10.  
  11. # Custom imports
  12. import os
  13. import subprocess
  14. import random
  15. import locale
  16. import gettext
  17.  
  18. # DOCUMENTATION
  19.  
  20. def __get_localised_doc_link():
  21.     """Return the link to the localised documentation
  22.  
  23.     @returns  the link to the localised documentation if available, or to the
  24.             english version
  25.     """
  26.  
  27.     # Try to get the list of supported languages codes supported by the
  28.     # documentation according to the $TAILS_WIKI_SUPPORTED_LANGUAGES
  29.     # environnement variable. If unset, fallback to `en`
  30.     try:
  31.         wiki_supported_languages = os.environ["TAILS_WIKI_SUPPORTED_LANGUAGES"].split(' ')
  32.     except KeyError:
  33.         wiki_supported_languages = ['en']
  34.  
  35.     # locale.getlocale returns a tuple (language code, encoding)
  36.     # the language is the two first character of the RFC 1766 "language code"
  37.     system_language_code = locale.getdefaultlocale()[0]
  38.     if system_language_code:
  39.         system_language = system_language_code[0:2]
  40.     else:
  41.         system_language = None
  42.  
  43.     # Get the language code of the localised documentation if available, or
  44.     # fallback to `en`
  45.     if system_language in wiki_supported_languages:
  46.         localised_doc_language = system_language
  47.     else:
  48.         localised_doc_language = 'en'
  49.  
  50.     return ("file:///usr/share/doc/tails/website/doc/first_steps/bug_reporting." +
  51.         localised_doc_language +
  52.         ".html")
  53.  
  54. def _(string):
  55.     try:
  56.         string = gettext.translation("amnesia", "/usr/share/locale").lgettext(string)
  57.     except IOError:
  58.         pass
  59.     finally:
  60.         return string
  61.  
  62. # The right panel help (HTML string)
  63. html_help = _(
  64. """<h1>Help us fix your bug!</h1>
  65. <p>Read <a href="%s">our bug reporting instructions</a>.</p>
  66. <p><strong>Do not include more personal information than
  67. needed!</strong></p>
  68. <h2>About giving us an email address</h2>
  69. <p>If you don't mind disclosing some bits of your identity
  70. to Tails developers, you can provide an email address to
  71. let us ask more details about the bug. Additionally entering
  72. a public PGP key enables us to encrypt such future
  73. communication.</p>
  74. <p>Anyone who can see this reply will probably infer you are
  75. a Tails user. Time to wonder how much you trust your
  76. Internet and mailbox providers?</p>
  77. """) % __get_localised_doc_link()
  78.  
  79. # ENCRYPTION
  80. #
  81. # This section defines encryption parameters
  82.  
  83. # The path to the OpenPGP keyring to use. If None, use OpenPGP default
  84. # keyring.
  85. gnupg_keyring = "/usr/share/keyrings/tails-keyring.gpg"
  86.  
  87. # RECIPIENT
  88. #
  89. # This section defines the recepient parameters
  90.  
  91. # The address of the recipient
  92. to_address = "tails@boum.org"
  93.  
  94. # The fingerprint of the recipient's GPG key 
  95. to_fingerprint = "09F6BC8FEEC9D8EE005DBAA41D2975EDF93E735F"
  96.  
  97. # SENDER
  98. #
  99. # This section defines the sender parameters
  100.  
  101. # The address of the sender
  102. from_address = "devnull@tails.boum.org"
  103.  
  104. # SMTP
  105. #
  106. # This section defines the SMTP server parameters
  107. #
  108. # The SMTP server to use to send the mail
  109. smtp_host = "4mvq3pnvid3awjln.onion"
  110. # The port to connect to on that SMTP server
  111. smtp_port = 25
  112. # The path to a file containing the certificate to trust
  113. # This can be either a CA certificate used to sign the SMTP server
  114. # certificate or the certificate of the SMTP server itself
  115. smtp_tlscafile = "/etc/whisperback/4mvq3pnvid3awjln.onion.pem"
  116.  
  117. # MESSAGE
  118. #
  119. # This section defines the message parameters
  120.  
  121. # The subject of the email to be sent
  122. # Please take into account that this will not be encrypted
  123. mail_subject = "Bug report: %x" % random.randrange(16**32)
  124.  
  125. # A callback function to get information to prepend to the mail
  126. # (this information will be encrypted). This is useful to add
  127. # software version.
  128. # It should not take any parameter, and should return a string to be
  129. # preprended to the email
  130. def mail_prepended_info():
  131.     """Returns the version of the running amnesia system
  132.     
  133.     @return The output of tails-version, if any, or an english string 
  134.             explaining the error
  135.     """
  136.   
  137.     try:
  138.       amnesia_version_process = subprocess.Popen ("tails-version", 
  139.                                                  stdout=subprocess.PIPE)
  140.       amnesia_version_process.wait()
  141.       amnesia_version = amnesia_version_process.stdout.read()
  142.     except OSError:
  143.       amnesia_version = "tails-version command not found"
  144.     except subprocess.CalledProcessError:
  145.       amnesia_version = "tails-version returned an error"
  146.     
  147.     return "Tails-Version: %s\n" % amnesia_version
  148.  
  149. # A callback function to get information to append to the email
  150. # (this information will be encrypted). This is useful to add
  151. # configuration files usebul for debugging.
  152. # It should not take any parameter, and should return a string to be
  153. # appended to the email
  154. def mail_appended_info():
  155.     """Returns debugging informations on the running amnesia system
  156.     
  157.     @return a long string containing debugging informations
  158.     """
  159.     debugging_info = ""
  160.  
  161.     try:
  162.         process = subprocess.Popen (["sudo", "/usr/local/sbin/tails-debugging-info"], 
  163.                                     stdout=subprocess.PIPE)
  164.         for line in process.stdout:
  165.             debugging_info += line
  166.         process.wait()
  167.     except OSError:
  168.         debugging_info += "sudo command not found\n"
  169.     except subprocess.CalledProcessError:
  170.         debugging_info += "debugging command returned an error\n"
  171.     return debugging_info
  172.