diff options
author | Sascha Silbe <silbe@activitycentral.com> | 2012-03-26 15:10:31 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@schampijer.de> | 2012-03-26 17:52:43 (GMT) |
commit | 516517a81ecfa0d3d2524f885f30b0cf2b0052c9 (patch) | |
tree | b25f96df042615e294a0e49d31085ff140df51e2 | |
parent | 8396cacd1866ef93a239209435cb153e98537447 (diff) |
Recreate corrupted key pair (fixes SL#1568)
Recreate a corrupted key pair instead of leaving it alone and failing horribly
later.
This case was encountered two years ago (OLPC#9612 [2]) and recently again
in Nicaragua.
[1] https://bugs.sugarlabs.org/ticket/1568
[2] https://dev.laptop.org/ticket/9612
Signed-off-by: Sascha Silbe <silbe@activitycentral.com>
Signed-off-by: Daniel Drake <dsd@laptop.org>
Reviewed-by: James Cameron <quozl@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
-rw-r--r-- | src/jarabe/intro/window.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/jarabe/intro/window.py b/src/jarabe/intro/window.py index f7937b1..a6a2a29 100644 --- a/src/jarabe/intro/window.py +++ b/src/jarabe/intro/window.py @@ -15,6 +15,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import os +import os.path import logging from gettext import gettext as _ import gconf @@ -24,6 +25,7 @@ import gtk import gobject from sugar import env +from sugar import profile from sugar.graphics import style from sugar.graphics.icon import Icon from sugar.graphics.xocolor import XoColor @@ -43,16 +45,27 @@ def create_profile(name, color=None): client.set_string('/desktop/sugar/user/color', color.to_string()) client.suggest_sync() + if profile.get_pubkey() and profile.get_profile().privkey_hash: + logging.info('Valid key pair found, skipping generation.') + return + # Generate keypair import commands keypath = os.path.join(env.get_profile_path(), 'owner.key') - if not os.path.isfile(keypath): - cmd = "ssh-keygen -q -t dsa -f %s -C '' -N ''" % keypath - (s, o) = commands.getstatusoutput(cmd) - if s != 0: - logging.error('Could not generate key pair: %d %s', s, o) - else: - logging.error('Keypair exists, skip generation.') + if os.path.exists(keypath): + os.rename(keypath, keypath + '.broken') + logging.warning('Existing private key %s moved to %s.broken', + keypath, keypath) + + if os.path.exists(keypath + '.pub'): + os.rename(keypath + '.pub', keypath + '.pub.broken') + logging.warning('Existing public key %s.pub moved to %s.pub.broken', + keypath, keypath) + + cmd = "ssh-keygen -q -t dsa -f %s -C '' -N ''" % (keypath, ) + (s, o) = commands.getstatusoutput(cmd) + if s != 0: + logging.error('Could not generate key pair: %d %s', s, o) class _Page(gtk.VBox): |