--- /dev/null
+This plugin is licensed under the Creative Commons
+Attribution-NonCommercial-ShareAlike 3.0 Unported
+License. To view a copy of this license, visit
+http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative
+Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
+
+Alternatively, this plugin may be distributed and executed on hardware which
+is licensed by Dream Multimedia GmbH.
+
+This plugin is NOT free software. It is open source, you are allowed to
+modify it (if you keep the license), but it may not be commercially
+distributed other than under the conditions noted above.
+
+Some Icons used are taken from NX10 icons by Mazenl77
+(http://www.iconspedia.com/pack/nx10-1-6/)
+licensed under Creative Commons Attribution 3.0 Unported
+http://creativecommons.org/licenses/by/3.0/
+Some others from HydroPro v2 icons by Ben Fleming
+(http://www.iconspedia.com/pack/hydropro-v2-624/)
+licensed under Creative Commons Attribution 2.5 Australia
+http://creativecommons.org/licenses/by/2.5/au/
\ No newline at end of file
--- /dev/null
+from enigma import eConsoleAppContainer
+
+from Screens.Screen import Screen
+from Screens.MessageBox import MessageBox
+
+from Screens.Setup import SetupSummary
+from Components.ConfigList import ConfigList
+from Components.config import config, getConfigListEntry, ConfigSelection, ConfigSubsection, ConfigText
+
+from Components.ActionMap import ActionMap
+from Components.Label import Label
+from Components.Pixmap import Pixmap
+from Components.Sources.StaticText import StaticText
+from Components.Sources.List import List
+from Plugins.Plugin import PluginDescriptor
+
+import string
+import sys
+import time
+from random import Random
+
+title=_("Change Root Password")
+
+class ChangePasswdScreen(Screen):
+ skin = """
+ <screen position="110,145" size="490,260" title="%s" >
+ <widget name="passwd" position="10,10" size="470,200" scrollbarMode="showOnDemand" />
+ <ePixmap pixmap="skin_default/div-h.png" position="10,205" size="470,2" transparent="1" alphatest="on" />
+ <ePixmap pixmap="skin_default/buttons/red.png" position="10,210" size="150,40" alphatest="on" />
+ <ePixmap pixmap="skin_default/buttons/green.png" position="170,210" size="150,40" alphatest="on" />
+ <ePixmap pixmap="skin_default/buttons/yellow.png" position="330,210" size="150,40" alphatest="on" />
+ <widget source="key_red" render="Label" position="10,210" zPosition="1" size="150,40" font="Regular;19" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
+ <widget source="key_green" render="Label" position="170,210" zPosition="1" size="150,40" font="Regular;19" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
+ <widget source="key_yellow" render="Label" position="330,210" zPosition="1" size="150,40" font="Regular;19" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
+ </screen>""" % _("Change Root Password")
+
+ def __init__(self, session, args = 0):
+ Screen.__init__(self, session)
+ self.skin = ChangePasswdScreen.skin
+
+ self.user="root"
+ self.output_line = ""
+
+ self.password=self.GeneratePassword()
+ self.list = []
+ self.list.append(getConfigListEntry(_('Enter new Password'), ConfigText(default = self.password, fixed_size = False)))
+
+ self["passwd"] = ConfigList(self.list)
+ self["key_red"] = StaticText(_("Cancel"))
+ self["key_green"] = StaticText(_("Set Password"))
+ self["key_yellow"] = StaticText(_("new Random"))
+
+ self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
+ {
+ "green": self.SetPasswd,
+ "red": self.close,
+ "yellow": self.buildList,
+ "cancel": self.close
+ }, -1)
+
+ def buildList(self):
+ self.password=self.GeneratePassword()
+ self.list = []
+ self.list.append(getConfigListEntry(_('Enter new Password'), ConfigText(default = self.password, fixed_size = False)))
+ self["passwd"].setList(self.list)
+
+ def GeneratePassword(self):
+ passwdChars = string.letters + string.digits
+# passwdChars = string.letters + string.digits + '~!@#$%^&*-_=+?' # use for more security :)
+ passwdLength = 8
+ return ''.join(Random().sample(passwdChars, passwdLength))
+
+ def SetPasswd(self):
+ print "Changing password for %s to %s" % (self.user,self.password)
+ self.container = eConsoleAppContainer()
+ self.container.appClosed.append(self.runFinished)
+ self.container.dataAvail.append(self.dataAvail)
+ retval = self.container.execute("passwd %s" % self.user)
+ if retval==0:
+ self.session.open(MessageBox, _("Sucessfully changed password for root user to:\n%s " % self.password), MessageBox.TYPE_INFO)
+ else:
+ self.session.open(MessageBox, _("Unable to change/reset password for root user"), MessageBox.TYPE_ERROR)
+
+ def dataAvail(self,data):
+ self.output_line += data
+ while True:
+ i = self.output_line.find('\n')
+ if i == -1:
+ break
+ self.processOutputLine(self.output_line[:i+1])
+ self.output_line = self.output_line[i+1:]
+
+ def processOutputLine(self,line):
+ if line.find('password: '):
+ self.container.write("%s\n"%self.password)
+
+ def runFinished(self,retval):
+ del self.container.dataAvail[:]
+ del self.container.appClosed[:]
+ del self.container
+ self.close()
+
+def startChange(menuid):
+ if menuid != "system":
+ return [ ]
+ return [(title, main, "change_root_passwd", 50)]
+
+def main(session, **kwargs):
+ session.open(ChangePasswdScreen)
+
+def Plugins(**kwargs):
+ return PluginDescriptor(
+ name=title,
+ description=_("Change or reset the root password of your dreambox"),
+ where = [PluginDescriptor.WHERE_MENU], fnc = startChange)
+
\ No newline at end of file