initial check-in
authorMichael Alexejew <luke_s@users.schwerkraft.elitedvb.net>
Wed, 20 May 2009 12:47:01 +0000 (12:47 +0000)
committerMichael Alexejew <luke_s@users.schwerkraft.elitedvb.net>
Wed, 20 May 2009 12:47:01 +0000 (12:47 +0000)
setpasswd/CONTROL/control [new file with mode: 0755]
setpasswd/Makefile.am [new file with mode: 0755]
setpasswd/src/LICENSE [new file with mode: 0755]
setpasswd/src/Makefile.am [new file with mode: 0755]
setpasswd/src/__init__.py [new file with mode: 0755]
setpasswd/src/maintainer.info [new file with mode: 0755]
setpasswd/src/plugin.py [new file with mode: 0755]

diff --git a/setpasswd/CONTROL/control b/setpasswd/CONTROL/control
new file mode 100755 (executable)
index 0000000..7bd9343
--- /dev/null
@@ -0,0 +1,9 @@
+Package: enigma2-plugin-systemplugins-changepassword
+Version: 20090520-r0
+Description: change or reset root password on your dreambox
+Architecture: mipsel
+Section: extra
+Priority: optional
+Maintainer: Michael Alexejew <luke_s@opendreambox.org>
+Homepage: http://enigma2-plugins.schwerkraft.elitedvb.net
+Source: http://enigma2-plugins.schwerkraft.elitedvb.net/
diff --git a/setpasswd/Makefile.am b/setpasswd/Makefile.am
new file mode 100755 (executable)
index 0000000..948a117
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = src 
diff --git a/setpasswd/src/LICENSE b/setpasswd/src/LICENSE
new file mode 100755 (executable)
index 0000000..8afe30a
--- /dev/null
@@ -0,0 +1,21 @@
+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
diff --git a/setpasswd/src/Makefile.am b/setpasswd/src/Makefile.am
new file mode 100755 (executable)
index 0000000..6d7b741
--- /dev/null
@@ -0,0 +1,8 @@
+installdir = $(LIBDIR)/enigma2/python/Plugins/SystemPlugins/SetPasswd
+
+install_PYTHON = *.py
+
+install_DATA = *.info LICENSE
+
+
+
diff --git a/setpasswd/src/__init__.py b/setpasswd/src/__init__.py
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/setpasswd/src/maintainer.info b/setpasswd/src/maintainer.info
new file mode 100755 (executable)
index 0000000..2033df0
--- /dev/null
@@ -0,0 +1,2 @@
+luke_s@opendreambox.org
+change_root_passwd
diff --git a/setpasswd/src/plugin.py b/setpasswd/src/plugin.py
new file mode 100755 (executable)
index 0000000..4a21eea
--- /dev/null
@@ -0,0 +1,116 @@
+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