Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar_network/toolkit/sugar.py
diff options
context:
space:
mode:
Diffstat (limited to 'sugar_network/toolkit/sugar.py')
-rw-r--r--sugar_network/toolkit/sugar.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/sugar_network/toolkit/sugar.py b/sugar_network/toolkit/sugar.py
index 361cb7a..4f0bac5 100644
--- a/sugar_network/toolkit/sugar.py
+++ b/sugar_network/toolkit/sugar.py
@@ -20,6 +20,7 @@ import random
import hashlib
from os.path import join, exists, dirname
+from active_toolkit.options import Option
from active_toolkit import enforce
@@ -31,6 +32,13 @@ _COLOR_GCONF = '/desktop/sugar/user/color'
_uid = None
+keyfile = Option(
+ 'path to SSH private key file to authenticate user; public key file '
+ 'should have ".pub" suffif; if ommited, use key file generated by '
+ 'Sugar Shell',
+ name='keyfile')
+
+
def logger_level():
"""Current Sugar logger level as --debug value."""
_LEVELS = {
@@ -66,11 +74,17 @@ def profile_path(*args):
return result
-def pubkey():
- pubkey_path = profile_path('owner.key.pub')
- enforce(exists(pubkey_path),
- 'Sugar session was never started, no pubkey')
+def privkey_path():
+ path = keyfile.value
+ if not path:
+ path = profile_path('owner.key')
+ enforce(exists(path),
+ 'Sugar session was never started, no privkey')
+ return path
+
+def pubkey():
+ pubkey_path = privkey_path() + '.pub'
with file(pubkey_path) as f:
for line in f.readlines():
line = line.strip()