Skip to content

Commit

Permalink
Merge pull request #108 from edit4ever/sshpass
Browse files Browse the repository at this point in the history
add ssh passwd change to wizard
  • Loading branch information
MilhouseVH committed Dec 16, 2018
2 parents c0834d3 + 5342881 commit 1b9a5d1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
12 changes: 12 additions & 0 deletions language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,22 @@ msgctxt "#32209"
msgid "SSH Password"
msgstr ""

msgctxt "#32210"
msgid "The default LibreELEC SSH password is widely known, and is considered insecure.[CR][CR]Setting your own password is recommended."
msgstr ""

msgctxt "#32212"
msgid "Cancel"
msgstr ""

msgctxt "#32213"
msgid "Keep Existing"
msgstr ""

msgctxt "#32214"
msgid "Set Password"
msgstr ""

msgctxt "#32215"
msgid "Workgroup name"
msgstr ""
Expand Down
23 changes: 20 additions & 3 deletions src/resources/lib/modules/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
__scriptid__ = 'service.libreelec.settings'
__addon__ = xbmcaddon.Addon(id=__scriptid__)
_ = __addon__.getLocalizedString
xbmcDialog = xbmcgui.Dialog()

class services:

Expand Down Expand Up @@ -365,7 +366,7 @@ def load_values(self):
# hide ssh settings if Kernel Parameter is set

cmd_file = open(self.KERNEL_CMD, 'r')
cmd_args = cmd_file.read()
cmd_args = cmd_file.read().split(' ')
if 'ssh' in cmd_args:
self.struct['ssh']['settings']['ssh_autostart']['value'] = '1'
self.struct['ssh']['settings']['ssh_autostart']['hidden'] = 'true'
Expand Down Expand Up @@ -600,12 +601,14 @@ def wizard_set_ssh(self):
# ssh button does nothing if Kernel Parameter is set

cmd_file = open(self.KERNEL_CMD, 'r')
cmd_args = cmd_file.read()
cmd_args = cmd_file.read().split(' ')
if 'ssh' in cmd_args:
self.oe.notify('ssh', 'ssh enabled as boot parameter. can not disable')
cmd_file.close()
self.initialize_ssh()
self.load_values()
if self.struct['ssh']['settings']['ssh_autostart']['value'] == '1':
self.wizard_sshpasswd()
self.set_wizard_buttons()
self.oe.dbg_log('services::wizard_set_ssh', 'exit_function', 0)
except Exception, e:
Expand All @@ -625,10 +628,22 @@ def wizard_set_samba(self):
except Exception, e:
self.oe.dbg_log('services::wizard_set_samba', 'ERROR: (%s)' % repr(e))

def wizard_sshpasswd(self):
SSHresult = False
while SSHresult == False:
changeSSH = xbmcDialog.yesno(_(32209), _(32210), yeslabel=_(32213), nolabel=_(32214))
if changeSSH:
SSHresult = True
else:
changeSSHresult = self.do_sshpasswd()
if changeSSHresult:
SSHresult = True
return

def do_sshpasswd(self, **kwargs):
try:
self.oe.dbg_log('system::do_sshpasswd', 'enter_function', 0)
xbmcDialog = xbmcgui.Dialog()
SSHchange = False
newpwd = xbmcDialog.input(_(746))
if newpwd:
if newpwd == "libreelec":
Expand All @@ -648,10 +663,12 @@ def do_sshpasswd(self, **kwargs):
return
elif "Retype password" in readout3:
xbmcDialog.ok(_(32222), _(32223))
SSHchange = True
else:
xbmcDialog.ok(_(32224), _(32225))
self.oe.dbg_log('system::do_sshpasswd', 'exit_function', 0)
else:
self.oe.dbg_log('system::do_sshpasswd', 'user_cancelled', 0)
return SSHchange
except Exception, e:
self.oe.dbg_log('system::do_sshpasswd', 'ERROR: (' + repr(e) + ')')

0 comments on commit 1b9a5d1

Please sign in to comment.