summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2012-10-20 16:56:51 +0200
committerFlorian Bruhin <git@the-compiler.org>2012-10-20 16:56:51 +0200
commitb88d2e2260d2648e5b24c070dc1eaecd34898b52 (patch)
tree535646dd703ff6aa0b382fd32b9fed998ab6f9ab
parentd29116cd9bdf64791d5b9efadb3b7e4d0f363f58 (diff)
downloadsgp-b88d2e2260d2648e5b24c070dc1eaecd34898b52.tar.gz
sgp-b88d2e2260d2648e5b24c070dc1eaecd34898b52.zip
change from DWB to standalone
-rwxr-xr-xsgp.py43
1 files changed, 4 insertions, 39 deletions
diff --git a/sgp.py b/sgp.py
index 915821e..5003cb1 100755
--- a/sgp.py
+++ b/sgp.py
@@ -16,7 +16,6 @@
# You should have received a copy of the GNU General Public License
# along with spg.py If not, see <http://www.gnu.org/licenses/>.
-
import hashlib
import base64
import re
@@ -247,25 +246,6 @@ def url_to_domain(domain):
domain = '.'.join(domain)
return(domain)
-def minify_javascript(password):
- js = ('''
- (function() {
- var s = "",
- F = document.forms,
- j, f, i;
- for (j = 0; j < F.length; ++j) {
- f = F[j];
- for (i = 0; i < f.length; ++i) {
- if (f[i].type.toLowerCase() == "password") f[i].value = "''' +
- password + '''";
- }
- }
- })();
- ''')
- js = "document.activeElement.value = '" + password + "'"
- js = js.strip().replace('\n', ' ')
- return(js)
-
def sha256hash(masterpassword):
verify_hash = hashlib.sha256(masterpassword.encode('UTF-8')).hexdigest()
return(verify_hash)
@@ -291,17 +271,6 @@ def call_zenity(*args):
out = out.decode('UTF-8').rstrip('\n')
return(out)
-def output_dwb(masterpassword):
- url = os.environ['DWB_URI']
- password = sgp(url, masterpassword)
- out = "js " + minify_javascript(password)
- if 'DWB_FIFO' in os.environ:
- out += '\n'
- with open(os.environ['DWB_FIFO'], 'w') as outfile:
- outfile.write(out)
- else:
- print(out)
-
def output_console(masterpassword):
verify_salt = base64.b64encode(os.urandom(48)).decode('UTF-8')
masterpassword = verify_salt + masterpassword
@@ -318,19 +287,15 @@ def output_console(masterpassword):
print("}")
def main():
- if 'DISPLAY' not in os.environ:
- raise OSError("DISPLAY is not set!")
masterpassword = call_zenity('password')
verification = verify_masterpassword(masterpassword)
if verification == False:
call_zenity('error', 'text=Wrong password!')
- # Calling this from DWB
- if 'DWB_URI' in os.environ:
- print("Calling output_dwb")
- output_dwb(masterpassword)
- # Calling from the console
- else:
+ if '--setup' in sys.argv:
output_console(masterpassword)
+ else:
+ url = call_zenity('entry')
+ print(sgp(url, masterpassword) + '\n')
if __name__ == '__main__':
main()