[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Savannah-cvs] [SCM] Savane-cleanup framework branch, master, updated. c
From: |
Jonathan Gonzalez V. |
Subject: |
[Savannah-cvs] [SCM] Savane-cleanup framework branch, master, updated. cade4791a8109e106e84c8b60a044b1c63ca59b5 |
Date: |
Sat, 19 Sep 2009 23:17:15 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Savane-cleanup framework".
The branch, master has been updated
via cade4791a8109e106e84c8b60a044b1c63ca59b5 (commit)
via 256ec5f9e944813f7c82b9a4f36ff84f2a9c01f0 (commit)
via 1a736430af6b8981b90b5f77a8465b9c8b76504a (commit)
via 6f25521bbfde7236972c0496045ed4f1703e4b99 (commit)
via 4d283a7d7203465827ae932a3a521fa8e273835d (commit)
via 8713e8a1c6d06780359f81c4fb5f3455144b30da (commit)
from bbeaa707f18eaba9996a076bccc32c1bd5144e82 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/savane-cleanup/framework.git/commit/?id=cade4791a8109e106e84c8b60a044b1c63ca59b5
commit cade4791a8109e106e84c8b60a044b1c63ca59b5
Author: Jonathan Gonzalez V <address@hidden>
Date: Sat Sep 19 18:13:03 2009 -0400
Added the action to update the gpg key. There's a way to verify the key?
diff --git a/src/savane/my/views.py b/src/savane/my/views.py
index 3058471..c4df4ee 100644
--- a/src/savane/my/views.py
+++ b/src/savane/my/views.py
@@ -147,13 +147,16 @@ def sv_ssh_gpg( request ):
error_msg = 'Cannot added the public key'
elif action == 'update_gpg':
- pass
+ if 'gpg_key' in request.POST:
+ gpg_key = request.POST['gpg_key']
+ eu.gpg_key = gpg_key
+ success_msg = 'GPG Key stored.'
+
+ if eu.gpg_key != '':
+ gpg_data = dict({'action':'update_gpg', 'gpg_key':eu.gpg_key})
+ form_gpg = GPGForm( gpg_data )
else:
- if eu.gpg_key != '':
- gpg_data = dict({'action':'update_gpg', 'gpg_key':eu.gpg_key})
- form_gpg = GPGForm( gpg_data )
- else:
- form_gpg = GPGForm()
+ form_gpg = GPGForm()
keys = eu.sshkey_set.all()
if keys is not None:
http://git.savannah.gnu.org/cgit/savane-cleanup/framework.git/commit/?id=256ec5f9e944813f7c82b9a4f36ff84f2a9c01f0
commit 256ec5f9e944813f7c82b9a4f36ff84f2a9c01f0
Author: Jonathan Gonzalez V <address@hidden>
Date: Sat Sep 19 17:59:30 2009 -0400
Changed SSHForm to use savane.utils.ssh_key_fingerprint to check for a
valid value in the fields
diff --git a/src/savane/my/views.py b/src/savane/my/views.py
index f121952..3058471 100644
--- a/src/savane/my/views.py
+++ b/src/savane/my/views.py
@@ -204,19 +204,9 @@ class SSHForm( forms.Form ):
def clean_key( self ):
ssh_key = self.cleaned_data['key']
- if ssh_key is None or len(ssh_key) == 0:
- return ssh_key
-
- file_name = '/tmp/%d' % random.randint(0, int(time.time()))
-
- tmp_file = open( file_name, 'wb+' )
- tmp_file.write( ssh_key )
- tmp_file.close()
-
- cmd = 'ssh-keygen -l -f %s' % file_name
- pipe = Popen( cmd, shell=True, stdout=PIPE).stdout
- res = re.search("not a public key file", pipe.readline())
- if res is not None:
+ try:
+ ssh_key_fingerprint( ssh_key )
+ except:
raise forms.ValidationError( "The uploaded string is not a public
key file" )
return ssh_key
@@ -227,18 +217,13 @@ class SSHForm( forms.Form ):
if ssh_key_file is None:
return ssh_key_file
- file_name = '/tmp/%d' % random.randint(0, int(time.time()))
-
- tmp_file = open( file_name, 'wb+' )
+ ssh_key = str()
for chunk in ssh_key_file.chunks():
- tmp_file.write(chunk)
- tmp_file.close()
-
- cmd = 'ssh-keygen -l -f %s' % file_name
- pipe = Popen( cmd, shell=True, stdout=PIPE).stdout
- res = re.search("not a public key file", pipe.readline())
+ ssh_key = ssh_key + chunk
- if res is not None:
+ try:
+ ssh_key_fingerprint( ssh_key )
+ except:
raise forms.ValidationError( "The uploaded file is not a public
key file" )
return ssh_key_file
http://git.savannah.gnu.org/cgit/savane-cleanup/framework.git/commit/?id=1a736430af6b8981b90b5f77a8465b9c8b76504a
commit 1a736430af6b8981b90b5f77a8465b9c8b76504a
Author: Jonathan Gonzalez V <address@hidden>
Date: Sat Sep 19 17:51:07 2009 -0400
Use ssh_key_fingerprint from savane.utils to show the fingerprint on the
ssh keys lists
diff --git a/src/savane/my/views.py b/src/savane/my/views.py
index 0ee78b6..f121952 100644
--- a/src/savane/my/views.py
+++ b/src/savane/my/views.py
@@ -24,6 +24,7 @@ from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from django import forms
from savane.svmain.models import ExtendedUser, SshKey
+from savane.utils import *
import random
import time
@@ -158,11 +159,7 @@ def sv_ssh_gpg( request ):
if keys is not None:
ssh_keys = dict()
for key in keys:
- key_len = len(key.ssh_key)
- head_key = key.ssh_key[0:20]
- tail_key = key.ssh_key[key_len-20:key_len]
- ssh_keys[key.pk] = head_key+'[...stripped..]'+tail_key
-
+ ssh_keys[key.pk] = ssh_key_fingerprint( key.ssh_key )
return render_to_response('my/ssh_gpg.html',
http://git.savannah.gnu.org/cgit/savane-cleanup/framework.git/commit/?id=6f25521bbfde7236972c0496045ed4f1703e4b99
commit 6f25521bbfde7236972c0496045ed4f1703e4b99
Author: Jonathan Gonzalez V <address@hidden>
Date: Sat Sep 19 17:50:30 2009 -0400
Fix ssh_key_fingerprint to remove the created file and return the proper
fingerprint
diff --git a/src/savane/utils/__init__.py b/src/savane/utils/__init__.py
index 85b69e5..cfacc20 100644
--- a/src/savane/utils/__init__.py
+++ b/src/savane/utils/__init__.py
@@ -17,6 +17,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
+import random
+import time
+import re
from subprocess import Popen, PIPE
def ssh_key_fingerprint( ssh_key ):
@@ -31,9 +34,14 @@ def ssh_key_fingerprint( ssh_key ):
cmd = 'ssh-keygen -l -f %s' % file_name
pipe = Popen( cmd, shell=True, stdout=PIPE).stdout
- res = re.search("not a public key file", pipe.readline())
+ ssh_fp = pipe.readline()
+
+ cmd = 'rm %s' % file_name
+ piep = Popen( cmd, shell=True, stdout=PIPE)
+
+ res = re.search("not a public key file", ssh_fp)
if res is not None:
- raise forms.ValidationError( "The uploaded string is not a public key
file" )
+ raise 'Not a public key'
- return ssh_key
+ return ssh_fp
http://git.savannah.gnu.org/cgit/savane-cleanup/framework.git/commit/?id=4d283a7d7203465827ae932a3a521fa8e273835d
commit 4d283a7d7203465827ae932a3a521fa8e273835d
Author: Jonathan Gonzalez V <address@hidden>
Date: Sat Sep 19 14:00:13 2009 -0400
Extract the old ssh keys from the svmain_sshkey table
diff --git a/src/savane/backend/migrate_sshkeys.py
b/src/savane/backend/migrate_sshkeys.py
index 04f46f4..53ce1f1 100644
--- a/src/savane/backend/migrate_sshkeys.py
+++ b/src/savane/backend/migrate_sshkeys.py
@@ -21,22 +21,19 @@
from savane.svmain.models import ExtendedUser, SshKey
-sv_users = ExtendedUser.objects.all().exclude(authorized_keys='')
+sv_users = ExtendedUser.objects.all()
for sv_user in sv_users:
- keys = (sv_user.authorized_keys or '').split('###')
- sv_user.sshkey_set.all().delete()
- remove = False
- for key in keys:
- if len(key) > 0:
- try:
- ssh_key = SshKey(ssh_key=key)
- sv_user.sshkey_set.add(ssh_key)
- remove = True
- except:
- print "User: %s Failed" % sv_user.username
-
- if remove:
- sv_user.authorized_keys = ''
- sv_user.save()
+ keys = sv_user.sshkey_set.all()
+ if keys is not None and len( keys ) == 1:
+ keys = (keys[0].ssh_key or '').split('###')
+ sv_user.sshkey_set.all().delete()
+ for key in keys:
+ if len(key) > 0:
+ try:
+ ssh_key = SshKey(ssh_key=key)
+ sv_user.sshkey_set.add(ssh_key)
+ remove = True
+ except:
+ print "User: %s Failed" % sv_user.username
http://git.savannah.gnu.org/cgit/savane-cleanup/framework.git/commit/?id=8713e8a1c6d06780359f81c4fb5f3455144b30da
commit 8713e8a1c6d06780359f81c4fb5f3455144b30da
Author: Jonathan Gonzalez V <address@hidden>
Date: Sat Sep 19 13:58:32 2009 -0400
Migrate the old authorized_keys cols to one row in svmain_sshkey
diff --git a/migrate_old_savane.sql b/migrate_old_savane.sql
index 52c595c..36de7fa 100644
--- a/migrate_old_savane.sql
+++ b/migrate_old_savane.sql
@@ -70,6 +70,16 @@ INSERT INTO svmain_extendeduser
FROM savane_old.user
WHERE savane_old.user.user_id != 100;
+-- Import the ssh into the new model, the python code should care about make
+-- the proper migration after a login or with a python code
+TRUNCATE svmain_sshkey;
+INSERT INTO svmain_sshkey
+ (user_id, ssh_key)
+ SELECT user_id, authorized_keys
+ FROM savane_old.user
+ WHERE authorized_keys != ''
+ and savane_old.user.user_id != 100;
+
-- Import group configurations
-- type_id -> id
TRUNCATE svmain_groupconfiguration;
-----------------------------------------------------------------------
Summary of changes:
migrate_old_savane.sql | 10 ++++++
src/savane/backend/migrate_sshkeys.py | 29 ++++++++----------
src/savane/my/views.py | 53 ++++++++++++---------------------
src/savane/utils/__init__.py | 14 +++++++--
4 files changed, 53 insertions(+), 53 deletions(-)
hooks/post-receive
--
Savane-cleanup framework
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Savannah-cvs] [SCM] Savane-cleanup framework branch, master, updated. cade4791a8109e106e84c8b60a044b1c63ca59b5,
Jonathan Gonzalez V. <=