Changeset af0cc3aa37cdfc89dbbf6a332d86b7cdf0b97349
- Timestamp:
- 05/24/07 17:05:28 (6 years ago)
- Author:
- iacopo <iacopo@…>
- Children:
- 6ecf068da5fba67c2aa66cbf2e358d2c24ac58f1
- Parents:
- a0262d65402e841ba795780fac249f10bda80490
- git-committer:
- iacopo <iacopo@…> (05/24/07 17:05:28)
- Message:
-
Home selection.
Check user duplicate unix/ldap.
Backup policy selection.
git-svn-id: https://labs.truelite.it/svn/octofuss/trunk@346 5a101938-5c21-0410-9b5a-a83d6f3706a9
- Location:
- lib/octofuss
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r0b74f36
|
raf0cc3a
|
|
| 187 | 187 | |
| 188 | 188 | self.selected_cluster = None |
| | 189 | |
| | 190 | #Check when cannot import some modules |
| | 191 | self.restartRequired = False |
| | 192 | |
| 189 | 193 | |
| 190 | 194 | self.model = ClusterTreeModel(self.network) |
| … |
… |
|
| 383 | 387 | |
| 384 | 388 | def install_software(self,obj,path): |
| 385 | | #try: |
| 386 | | from octofuss.packages import PackagesAdmin |
| 387 | | if len(path) is 1: |
| 388 | | s = PackagesAdmin(self.network[path[0]]) |
| 389 | | elif len(path) is 2: |
| 390 | | s = PackagesAdmin(Host(path[1])) |
| 391 | | self.change_app_content(s) |
| 392 | | #except Exception, e: |
| 393 | | # self.__error_dialog(str(e)) |
| | 389 | try: |
| | 390 | if self.restartRequired: |
| | 391 | raise Exception("You need to check some problems!") |
| | 392 | from octofuss.packages import PackagesAdmin |
| | 393 | if len(path) is 1: |
| | 394 | s = PackagesAdmin(self.network[path[0]]) |
| | 395 | elif len(path) is 2: |
| | 396 | s = PackagesAdmin(Host(path[1])) |
| | 397 | self.change_app_content(s) |
| | 398 | except Exception, e: |
| | 399 | self.restartRequired = True |
| | 400 | self.__error_dialog(str(e)) |
| 394 | 401 | |
| 395 | 402 | def add_host(self, obj,path, res): |
-
|
ra0262d6
|
raf0cc3a
|
|
| 190 | 190 | |
| 191 | 191 | def getName(self): |
| 192 | | return self.objectClass['posixAccount'].getAttribute('cn') |
| | 192 | return self.objectClass['posixAccount'].getAttribute('uid') |
| 193 | 193 | |
| 194 | 194 | def getPassword(self): |
| … |
… |
|
| 423 | 423 | list = ldap.search(filter="(uid=*)", findattr=[]) |
| 424 | 424 | |
| | 425 | #Keep track of local system users, and avoid duplicate "username" |
| | 426 | global locallist |
| | 427 | |
| 425 | 428 | objectList = {} |
| 426 | 429 | # Parsing the list and create users object |
| … |
… |
|
| 484 | 487 | if objectList.has_key(ldapuser.getName().getValue()): |
| 485 | 488 | raise UserError("Incongruous ldap tree\nDuplicate user name in ldap server: "+ldapuser.getName().getValue()) |
| | 489 | if locallist.has_key(ldapuser.getName().getValue()): |
| | 490 | print "Ldap user "+ldapuser.getName().getValue()+" already present in system users." |
| | 491 | continue |
| 486 | 492 | objectList[ldapuser.getName().getValue()]=ldapuser |
| 487 | 493 | |
| … |
… |
|
| 566 | 572 | # Second = create LDAP groups |
| 567 | 573 | ldapgrouplist = __ldap_group() |
| 568 | | #Third = create LDAP users |
| | 574 | #Third = create UNIX users |
| | 575 | locallist = __local() |
| | 576 | #Fourth = create LDAP users |
| 569 | 577 | ldaplist = __ldap_user() |
| 570 | | #Fourth = create UNIX users |
| 571 | | locallist = __local() |
| | 578 | |
| 572 | 579 | |
| 573 | 580 | |
| … |
… |
|
| 871 | 878 | |
| 872 | 879 | |
| 873 | | |
| | 880 | def createHomeDirectoryNoControl(self, dir, uid, gid): |
| | 881 | """ Create home directory with owner and group """ |
| | 882 | # Check if home already exists |
| | 883 | #It does less checks. It create the dir only if it doesn't exist. |
| | 884 | |
| | 885 | if dir: |
| | 886 | if not os.path.isdir(dir): |
| | 887 | #os.mkdir(dir) |
| | 888 | os.system("/bin/cp -a /etc/skel "+dir) |
| | 889 | os.chown(dir, int(uid), int(gid)) |
| | 890 | os.system("chown -R "+uid+"."+gid+" "+dir) |
| | 891 | os.chmod(dir,0700) |
| | 892 | |
| | 893 | else: |
| | 894 | raise UserError("Home directory "+dir+" already exists!") |
| | 895 | else: |
| | 896 | raise UserError("Directory must be not null!") |
| | 897 | |
| 874 | 898 | |
| 875 | 899 | def createHomeDirectory(self, name, uid, gid, path="/home"): |
| … |
… |
|
| 1173 | 1197 | user = self.getUser(username) |
| 1174 | 1198 | flags = user.getAttribute('sambaSamAccount','sambaAcctFlags') |
| | 1199 | |
| | 1200 | |
| 1175 | 1201 | if flags != None: |
| 1176 | 1202 | if "D" in flags.getValue(): |
| … |
… |
|
| 1449 | 1475 | # Create user directory |
| 1450 | 1476 | # __createHomeDirectory(self, name, uid, gid, path="/home/"): |
| 1451 | | self.createHomeDirectory(l.getName().getValue(), l.getUidNumber().getValue(), l.getGid().getValue()) |
| | 1477 | homePrefix = "/home/" |
| | 1478 | lenHome = len(homePrefix) |
| | 1479 | dir = l.getHome().getValue() |
| | 1480 | if dir.startswith(homePrefix) and dir[lenHome:].strip() != "": |
| | 1481 | self.createHomeDirectoryNoControl(l.getName().getValue(), l.getUidNumber().getValue(), l.getGid().getValue()) |
| | 1482 | else: |
| | 1483 | raise UserError("User created, but could not create home directory.") |
| | 1484 | |
| 1452 | 1485 | |
| 1453 | 1486 | |
| … |
… |
|
| 1745 | 1778 | raise UserError("User already exists!") |
| 1746 | 1779 | |
| 1747 | | if os.path.isdir("/home/"+l.getName().getValue()): |
| | 1780 | homePrefix = "/home/" |
| | 1781 | lenHome = len(homePrefix) |
| | 1782 | dir = l.getHome().getValue() |
| | 1783 | if dir.startswith(homePrefix) and dir[lenHome:].strip() != "": |
| | 1784 | pass |
| | 1785 | else: |
| | 1786 | raise UserError("Invalid home directory!") |
| | 1787 | if os.path.isdir(dir): |
| 1748 | 1788 | raise UserError("Directory already exist") |
| 1749 | 1789 | |
| … |
… |
|
| 1800 | 1840 | #Home directory work |
| 1801 | 1841 | #Trying to create home |
| 1802 | | self.createHomeDirectory(l.getName().getValue(),l.getUidNumber().getValue(),l.getGid().getValue()) |
| | 1842 | self.createHomeDirectoryNoControl(dir, l.getUidNumber().getValue(), l.getGid().getValue()) |
| | 1843 | |
| 1803 | 1844 | |
| 1804 | 1845 | |
| … |
… |
|
| 1901 | 1942 | |
| 1902 | 1943 | else: |
| 1903 | | raise Exception("Could not compress and delete home directory!\nTry without compress it.") |
| | 1944 | raise Exception("Could not compress and delete home directory!") |
| 1904 | 1945 | elif compress == -9: |
| 1905 | 1946 | #Rename |
-
|
r55cb0ff
|
raf0cc3a
|
|
| 28 | 28 | #backend = Backend() |
| 29 | 29 | backend = backendSingleton |
| 30 | | |
| 31 | 30 | |
| 32 | 31 | |
| … |
… |
|
| 1492 | 1491 | mainFrame = gtk.Frame(_("New User")) |
| 1493 | 1492 | vboxMain = gtk.VBox() |
| 1494 | | mainTable = gtk.Table(7,2,False) |
| | 1493 | mainTable = gtk.Table(8,2,False) |
| 1495 | 1494 | |
| 1496 | 1495 | fieldLabel = gtk.Label(_("<b><big>Base preferences</big></b>")) |
| … |
… |
|
| 1552 | 1551 | |
| 1553 | 1552 | |
| | 1553 | #Home directory selection |
| | 1554 | labelHome = gtk.Label(_("Home directory")) |
| | 1555 | al5 = gtk.Alignment(xalign=0.5) |
| | 1556 | al5.add(labelHome) |
| | 1557 | |
| | 1558 | entryHome= gtk.Entry() |
| | 1559 | |
| | 1560 | mainTable.attach(al5,0,1,5,6,xoptions=gtk.FILL,yoptions=gtk.SHRINK,ypadding=10,xpadding=30) |
| | 1561 | mainTable.attach(entryHome,1,2,5,6,yoptions=gtk.SHRINK,ypadding=10,xpadding=10) |
| | 1562 | |
| | 1563 | |
| 1554 | 1564 | # Maing group selection comboBox |
| 1555 | 1565 | groupComboLabel = gtk.Label(_("Main group")) |
| 1556 | | al5 = gtk.Alignment(xalign=0.5) |
| 1557 | | al5.add(groupComboLabel) |
| | 1566 | al6 = gtk.Alignment(xalign=0.5) |
| | 1567 | al6.add(groupComboLabel) |
| 1558 | 1568 | |
| 1559 | 1569 | groupComboBox = gtk.ComboBox() |
| … |
… |
|
| 1565 | 1575 | groupComboBox.set_active(0) |
| 1566 | 1576 | |
| 1567 | | mainTable.attach(al5,0,1,5,6,xoptions=gtk.FILL,yoptions=gtk.SHRINK,ypadding=10,xpadding=30) |
| 1568 | | mainTable.attach(groupComboBox,1,2,5,6,yoptions=gtk.SHRINK,ypadding=10,xpadding=10) |
| | 1577 | mainTable.attach(al6,0,1,6,7,xoptions=gtk.FILL,yoptions=gtk.SHRINK,ypadding=10,xpadding=30) |
| | 1578 | mainTable.attach(groupComboBox,1,2,6,7,yoptions=gtk.SHRINK,ypadding=10,xpadding=10) |
| 1569 | 1579 | |
| 1570 | 1580 | groupLabel = gtk.Label(_("<b><big>User privileges</big></b>")) |
| … |
… |
|
| 1572 | 1582 | groupLabel.set_use_markup(True) |
| 1573 | 1583 | |
| 1574 | | mainTable.attach(groupLabel,0,1,6,7,xoptions=gtk.FILL,yoptions=gtk.SHRINK,ypadding=10,xpadding=10) |
| | 1584 | mainTable.attach(groupLabel,0,1,7,8,xoptions=gtk.FILL,yoptions=gtk.SHRINK,ypadding=10,xpadding=10) |
| 1575 | 1585 | |
| 1576 | 1586 | |
| … |
… |
|
| 1644 | 1654 | v.pack_start(mainFrame) |
| 1645 | 1655 | save = gtk.Button(stock="gtk-add") |
| 1646 | | save.connect("clicked", self.__save_clicked,entryRealname,entryUsername,entryPassword,entryPasswordConferma,groupsToShow,self.__groupList, groupComboBox) |
| | 1656 | save.connect("clicked", self.__save_clicked,entryRealname,entryUsername,entryPassword,entryPasswordConferma,entryHome,groupsToShow,self.__groupList, groupComboBox) |
| 1647 | 1657 | |
| 1648 | 1658 | cancel = gtk.Button(stock="gtk-cancel") |
| … |
… |
|
| 1657 | 1667 | |
| 1658 | 1668 | |
| 1659 | | def __save_clicked(self,button, entryRealname,entryUsername,entryPassword,entryPasswordConferma,groupsToShow, groupList,groupComboBox): |
| | 1669 | def __save_clicked(self,button, entryRealname,entryUsername,entryPassword,entryPasswordConferma,entryHome,groupsToShow, groupList,groupComboBox): |
| 1660 | 1670 | """ Check fields and add the user to Ldap Server """ |
| 1661 | 1671 | global backend |
| … |
… |
|
| 1711 | 1721 | n.setAttribute("objectClass",attrObjectClass) |
| 1712 | 1722 | n.setAttribute("gidNumber", str(gid)) |
| 1713 | | n.setAttribute("homeDirectory","/home/"+entryUsername.get_text()) |
| | 1723 | #n.setAttribute("homeDirectory","/home/"+entryUsername.get_text()) |
| | 1724 | homePrefix = "/home/" |
| | 1725 | lenHome = len(homePrefix) |
| | 1726 | directoryHome = entryHome.get_text().replace(" ","") |
| | 1727 | |
| | 1728 | if not entryHome.get_text(): |
| | 1729 | n.setAttribute("homeDirectory","/home/"+entryUsername.get_text()) |
| | 1730 | elif directoryHome.startswith(homePrefix): |
| | 1731 | import string |
| | 1732 | for i in directoryHome[lenHome:]: |
| | 1733 | if i in string.ascii_letters or i in string.digits: |
| | 1734 | pass |
| | 1735 | else: |
| | 1736 | self.showDialog(_("Invalid characters in home directory field!"),gtk.MESSAGE_ERROR) |
| | 1737 | return |
| | 1738 | |
| | 1739 | |
| | 1740 | if directoryHome[lenHome:].strip() != "": |
| | 1741 | n.setAttribute("homeDirectory",directoryHome) |
| | 1742 | else: |
| | 1743 | self.showDialog(_("Home directory /home/ is not a valid path."),gtk.MESSAGE_ERROR) |
| | 1744 | return |
| | 1745 | |
| | 1746 | else: |
| | 1747 | #Display security error |
| | 1748 | self.showDialog(_("Home directory selection is permitted only under /home/"),gtk.MESSAGE_ERROR) |
| | 1749 | return |
| | 1750 | |
| | 1751 | |
| 1714 | 1752 | n.setAttribute("loginShell","/bin/sh") |
| 1715 | 1753 | |