From: <cod...@go...> - 2009-04-13 21:23:31
|
Author: M0...@gm... Date: Mon Apr 13 14:14:56 2009 New Revision: 531 Modified: branches/speedy/.lang/.pot branches/speedy/.project branches/speedy/Conf2.class branches/speedy/Conf3.class branches/speedy/Conf3.form branches/speedy/MdlMain.module Log: - Designed user add window. A little more coding to do there. Modified: branches/speedy/.lang/.pot ============================================================================== --- branches/speedy/.lang/.pot (original) +++ branches/speedy/.lang/.pot Mon Apr 13 14:14:56 2009 @@ -180,27 +180,27 @@ msgid "DO NOT LEAVE THIS BLANK" msgstr "" -#: Conf2.class:56 +#: Conf2.class:58 msgid "Passwords do not match. Please enter the same password twice" msgstr "" -#: Conf2.class:62 +#: Conf2.class:64 msgid "Password was not set. See error log below" msgstr "" -#: Conf2.class:116 +#: Conf2.class:132 msgid "System Administrator Account" msgstr "" -#: Conf2.class:133 +#: Conf2.class:149 msgid "About the linux root account" msgstr "" -#: Conf2.class:165 +#: Conf2.class:181 msgid "Enter Passwrord" msgstr "" -#: Conf2.class:182 +#: Conf2.class:198 Conf3.class:311 msgid "Re-enter Password" msgstr "" @@ -221,8 +221,80 @@ msgid "to continue" msgstr "" -#: Conf3.class:70 +#: Conf3.class:76 +msgid "Select picture ID" +msgstr "" + +#: Conf3.class:78 +msgid "Select picture ID for" +msgstr "" + +#: Conf3.class:108 +msgid "You must enter a login name first." +msgstr "" + +#: Conf3.class:111 +msgid "Please select a password for" +msgstr "" + +#: Conf3.class:111 +msgid "before continuing" +msgstr "" + +#: Conf3.class:114 +msgid "You must enter the password twice for added security" +msgstr "" + +#: Conf3.class:133 +msgid "User" +msgstr "" + +#: Conf3.class:133 +msgid "already exists in the system." +msgstr "" + +#: Conf3.class:133 +msgid "Please select another user login name" +msgstr "" + +#: Conf3.class:150 +msgid "Use only lowercase letters and numbers for this field" +msgstr "" + +#: Conf3.class:212 msgid "Create User Accounts" +msgstr "" + +#: Conf3.class:262 +msgid "Login Name" +msgstr "" + +#: Conf3.class:278 +msgid "Real Name" +msgstr "" + +#: Conf3.class:294 +msgid "Enter Password" +msgstr "" + +#: Conf3.class:339 +msgid "Click here to select user Login picture" +msgstr "" + +#: Conf3.class:349 +msgid "Create User" +msgstr "" + +#: Conf3.class:366 +msgid "Import Existing User" +msgstr "" + +#: Conf3.class:382 +msgid "Clear Form" +msgstr "" + +#: Conf3.class:397 +msgid "User Rights Management" msgstr "" #: FMain.class:253 FMain0.class:253 Modified: branches/speedy/.project ============================================================================== --- branches/speedy/.project (original) +++ branches/speedy/.project Mon Apr 13 14:14:56 2009 @@ -1,7 +1,7 @@ # Gambas Project File 2.0 # Compiled with Gambas 2.12 Title=VectorLinux Installer -Startup=Conf3 +Startup=MdlStartUp Version=0.0.2 Library=gb.gtk Library=gb.form Modified: branches/speedy/Conf2.class ============================================================================== --- branches/speedy/Conf2.class (original) +++ branches/speedy/Conf2.class Mon Apr 13 14:14:56 2009 @@ -23,6 +23,7 @@ ("Most oter every-day tasks do not require administrative priviledges.") & "<br>" & "<br>" & ("For added security, use a password that is easy for you to remember, but hard for others to guess.") & "<br><br>" & ("DO NOT LEAVE THIS BLANK") END WITH + ClsGlobal.fRunningMainForm.btnext.enabled = FALSE END @@ -39,14 +40,15 @@ END PUBLIC SUB StartUp() - ClsGlobal.fRunningMainForm.btnext.enabled = Len(textbox1.Text) > 0 + ClsGlobal.fRunningMainForm.btnext.enabled = FALSE END PUBLIC SUB OnExit() - - IF compare_passwords() = FALSE THEN RETURN - + ' -== Commented for testing purposers ==- + 'IF compare_passwords() = FALSE THEN RETURN + ME.TextBox1.Clear + ME.TextBox2.Clear END PUBLIC FUNCTION compare_passwords() AS Boolean @@ -74,5 +76,19 @@ PUBLIC SUB TextBox2_KeyRelease() ClsGlobal.fRunningMainForm.btnext.enabled = textbox2.Text = textbox1.Text + +END + +PUBLIC SUB Form_Enter() + + IF Len(ME.TextBox1.Text) > 0 THEN + IF textbox2.Text = textbox1.Text THEN + ClsGlobal.fRunningMainForm.btnext.enabled = TRUE + ELSE + ClsGlobal.fRunningMainForm.btnext.enabled = FALSE + END IF + ELSE + ClsGlobal.fRunningMainForm.btnext.enabled = FALSE + END IF END Modified: branches/speedy/Conf3.class ============================================================================== --- branches/speedy/Conf3.class (original) +++ branches/speedy/Conf3.class Mon Apr 13 14:14:56 2009 @@ -25,9 +25,18 @@ .tlTxt.Text = tlTxt.Text & ("When finished, Click") & Space(1) & "\"" & ClsGlobal.fRunningMainForm.btnext.text & "\"" & Space(1) & ("to continue") END IF + .btPicSel.Picture = Picture.Load("/usr/share/apps/kdm/pics/users/default2.png") END WITH + WAIT 0.1 + 'MdlMain.Display_User_Group_Choices(ME.lbUsrGrps) END +PUBLIC FUNCTION GetNext() AS String + + RETURN "Conf4" + +END + PUBLIC SUB OnExit() @@ -35,9 +44,111 @@ END PUBLIC SUB StartUp() + DIM obj AS Object + FOR EACH obj IN lbUsrGrps.Children + obj.delete + NEXT + MdlMain.Display_User_Group_Choices(ME.lbUsrGrps) + +END + + + + +PUBLIC SUB Form_Resize() + + ME.scrlConts.Height = ME.ClientH - (ME.scrlConts.Top + 8) + ME.lbUsrGrps.Width = ME.lbUsrGrps.Parent.Width - (ME.lbUsrGrps.Left * 2) + ME.lbUsrGrps.Height = ME.lbUsrGrps.Parent.Height - (ME.lbUsrGrps.Top * 1.25) + +END + +PUBLIC SUB TextBox4_KeyPress() + + + +END + + +PUBLIC SUB btPicSel_Click() + Dialog.Path = "/usr/share/apps/kdm/pics/users" + IF NOT (txtLogin.Text) THEN + Dialog.Title = ("Select picture ID") + ELSE + Dialog.Title = ("Select picture ID for") & Space(1) & ME.txtLogin.Text + END IF + Dialog.Filter = ["*.png;*.jpg;*.jpeg", "Picture Files"] + IF Dialog.OpenFile() THEN RETURN + LAST.Picture = Picture.Load(Dialog.Path) + +END + +PUBLIC SUB Button2_Click() + DIM obj AS Object + ' clear this form + ME.txtLogin.Clear + ME.txtRealName.Clear + ME.txtPass1.Clear + ME.txtPass2.Clear + + FOR EACH obj IN ME.lbUsrGrps.Children + obj.delete + NEXT + MdlMain.Display_User_Group_Choices(ME.lbUsrGrps) + ' default the picture + ME.btPicSel.Picture = Picture.Load("/usr/share/apps/kdm/pics/users/default2.png") + +END + +PRIVATE FUNCTION Check_Text_Entry() AS Boolean + ' will return true for faulty entry, false for clear + ' tHIS FUNCTION WILL MAKE SURE EVERYTHING IS CLEAR FOR USER ACCOUNT TO BE CREATED. + IF NOT (txtLogin.Text) THEN + Balloon.Error(("You must enter a login name first."), txtLogin) + RETURN TRUE + ELSE IF NOT (txtPass1.Text) THEN + Balloon.Error(("Please select a password for") & Space(1) & txtLogin.Text & Space(1) & ("before continuing"), txtPass1) + RETURN TRUE + ELSE IF NOT (txtPass2.Text) THEN + Balloon.Error(("You must enter the password twice for added security"), txtPass2) + RETURN TRUE + END IF + RETURN FALSE +END + +PUBLIC SUB btAddUsr_Click() + + '1) Check to make sure all entries are filled in + '2) Check to see if the user does not already exist + '3) If conditions 1 & 2 are passed, then create the account. + '4) Check for errors during account creation ^^^^^^^^^^^^^ (done in step3) + + IF Check_Text_Entry() = FALSE THEN + IF MdlMain.CHECK_EXISTING_USER(Trim(ME.txtLogin.Text)) = FALSE THEN + MdlMain.CREATE_NEW_USER_ACCOUNT() ' create new account + ELSE ' user exists + Message.Error(("User") & Space(1) & "\"" & Trim(ME.txtLogin.Text) & "\"" & Space(1) & ("already exists in the system.") & "<br>" & + ("Please select another user login name")) + RETURN + STOP EVENT + END IF + END IF + END +PUBLIC SUB txtLogin_KeyPress() + + + IF Key.Text LIKE "*[a-z]*" OR Key.Text LIKE "*[0-9]*" THEN + ' legal characters + ELSE + ' illegal characters + Balloon.Info(("Use only lowercase letters and numbers for this field"), LAST) + STOP EVENT + END IF + +END Modified: branches/speedy/Conf3.form ============================================================================== --- branches/speedy/Conf3.form (original) +++ branches/speedy/Conf3.form Mon Apr 13 14:14:56 2009 @@ -1,9 +1,10 @@ # Gambas Form File 2.0 { Form Form - MoveScaled(0,0,72,48) + MoveScaled(0,0,96,55) Text = ("") Arrangement = Arrange.Row + Padding = 2 { HPanel1 HPanel MoveScaled(0,0,60,5) Expand = True @@ -18,18 +19,159 @@ } } { HBox1 HBox - MoveScaled(0,5,7,2) + MoveScaled(0,5,7,1) Expand = True } { HBox2 HBox - MoveScaled(0,7,71,12) + MoveScaled(0,6,70,12) Expand = True Padding = 2 { tlTxt TextLabel - MoveScaled(1,0,15,11) + MoveScaled(1,0,52,11) Expand = True Text = ("") - Alignment = Align.Left + Alignment = Align.TopLeft + } + } + { HBox3 HBox + MoveScaled(1,18,4,1) + Expand = True + } + { scrlConts ScrollView + MoveScaled(1,19,93,33) + Expand = True + Arrangement = Arrange.Row + Border = False + { Panel1 Panel + MoveScaled(1,1,91,35) + Expand = True + Arrangement = Arrange.Horizontal + Padding = 2 + { HPanel2 HPanel + MoveScaled(0,1,64,33) + Expand = True + { TextLabel1 TextLabel + MoveScaled(0,0,22.5,3.5) + Text = ("Login Name") + Alignment = Align.Left + } + { txtLogin TextBox + MoveScaled(16,0,37.5,3.5) + Text = ("") + } + { HBox4 HBox + MoveScaled(40,1,9,1) + Expand = True + } + { TextLabel2 TextLabel + MoveScaled(0,4,22.5,3.5) + Text = ("Real Name") + Alignment = Align.Left + } + { txtRealName TextBox + MoveScaled(16,4,37.5,3.5) + Text = ("") + } + { HBox5 HBox + MoveScaled(41,5,8,1) + Expand = True + } + { TextLabel3 TextLabel + MoveScaled(0,9,22.5,3.5) + Text = ("Enter Password") + Alignment = Align.Left + } + { txtPass1 TextBox + MoveScaled(17,9,37.5,3.5) + Text = ("") + Password = True + } + { HBox6 HBox + MoveScaled(41,11,10,1) + Expand = True + } + { TextLabel4 TextLabel + MoveScaled(0,13,22.5,3.5) + Text = ("Re-enter Password") + Alignment = Align.Left + } + { txtPass2 TextBox + MoveScaled(17,13,37.5,3.5) + Text = ("") + Password = True + } + { HBox7 HBox + MoveScaled(47,14,7,1) + Expand = True + } + { HBox9 HBox + MoveScaled(1,17,24,1) + Expand = True + } + { HBox10 HBox + MoveScaled(1,19,60,12) + Expand = True + Spacing = 4 + Padding = 2 + { btPicSel Button + MoveScaled(0,0,12,12) + ToolTip = ("Click here to select user Login picture") + Text = ("") + } + { HPanel3 HPanel + MoveScaled(13,0,30,12) + Expand = True + { btAddUsr Button + MoveScaled(1,1,25,3) + Text = ("Create User") + Picture = Picture["icon:/small/add"] + Default = True + } + { HBox12 HBox + MoveScaled(27,2,2,1) + Expand = True + } + { HBox8 HBox + MoveScaled(18,4,4,1) + Expand = True + } + { Button1 Button + MoveScaled(1,5,25,3) + Text = ("Import Existing User") + Picture = Picture["icon:/small/redo"] + } + { HBox13 HBox + MoveScaled(27,6,2,1) + Expand = True + } + { HBox11 HBox + MoveScaled(13,8,6,1) + Expand = True + } + { Button2 Button + MoveScaled(1,9,25,3) + Text = ("Clear Form") + Picture = Picture["icon:/small/clear"] + Cancel = True + } + { HBox14 HBox + MoveScaled(27,10,3,1) + Expand = True + } + } + } + } + { frmRights Frame + MoveScaled(66,0,24,34) + Text = ("User Rights Management") + { lbUsrGrps ScrollView + MoveScaled(1,3,19,27) + Arrangement = Arrange.Row + Padding = 2 + Border = False + ScrollBar = Scroll.Vertical + } + } } } } Modified: branches/speedy/MdlMain.module ============================================================================== --- branches/speedy/MdlMain.module (original) +++ branches/speedy/MdlMain.module Mon Apr 13 14:14:56 2009 @@ -15,7 +15,7 @@ ' You should have received a copy of the GNU General Public License ' along with vinstall-ng. If not, see <http://www.gnu.org/licenses/>. - +PUBLIC $objUsrGroups AS NEW Object[] PUBLIC FUNCTION FORMAT_THIS_PARTITION(sPartition AS String, sFilesystem AS String) AS Integer @@ -117,4 +117,173 @@ END +PUBLIC SUB Display_User_Group_Choices(lbCont AS Container) + + DIM cb AS CheckBox + DIM sList AS String[] = ["plugdev", "disk", "cdrom", "floppy", "lp", "scanner", "audio", "video", "games", "slocate", "adm", "sys", "wheel", "power"] + DIM sDesc AS String[] = ["User can un/mount pendrives", "User can un/mount removable HD", "User can access CD/CDW/DVD devices", "User can access floppy disks", "User can access printers", "User can access scanners", "User can access audio devices", "User can access video devices", "User can play restricted games", "User can use the system\'s locate database", "Restricted System Administrator", "Unlimited system administrator", "elite users", "User can shut the system down"] + + + DIM i AS Integer + + FOR i = 0 TO sList.Max + cb = NEW CheckBox(lbCont) AS "GroupBoxes" + WITH cb + .Text = sList[i] + .Height = 28 + .ToolTip = sDesc[i] + IF i <= 9 OR i = 13 THEN + .Value = TRUE + ELSE + .Value = FALSE + END IF + .Expand = TRUE + END WITH + $objUsrGroups.Add(cb) + NEXT +END + +PUBLIC FUNCTION CHECK_EXISTING_USER(sName AS String) AS Boolean + + DIM sDump AS String + + SHELL "grep ^\"" & sName & "\" /mnt/target/etc/group" TO sDump + sDump = Trim(sDump) + IF Len(sDump) > 0 THEN + RETURN TRUE + END IF + RETURN FALSE + + +END + + +PUBLIC FUNCTION CREATE_NEW_USER_ACCOUNT() AS Integer + + ' will return + ' 0 = operation successful + ' 1 = operation failed + + ' PUBLIC SUB Button1_Click() + ' DIM sCAPS AS String + ' DIM sCHAR AS String + ' DIM sLogE AS String + ' DIM sPicdir AS String = ClsGlobal.sTargetMnt &/ "usr/share/apps/kdm/pics/users/" + ' DIM sGroups AS String '= '"plugdev,disk,cdrom,floppy,lp,scanner,audio,video,games" + ' DIM cb AS CheckBox + ' DIM tl AS TextLabel + ' 'DIM tly AS Integer + ' + ' MdlCore.WARN_STATUS(("Creating user account ... Please wait")) + ' + ' ' increment the number of user accounts created + ' INC MdlUsrAdd.iUsrAccts + ' + ' 'Message("Ateempting to create user now") + ' + ' IF ME.tbUsername.Text = "" THEN + ' Balloon.Error(("Enter the login name that this user will user to login to this system."), ME.tbUsername) + ' 'Message(("Enter the login name that this user will use to login to this system.")) + ' RETURN + ' STOP EVENT + ' ELSE + ' 'SHELL "echo " & ME.tbUsername.Text & "| grep -e \'[A-Z]\'" TO sCAPS + ' IF ME.tbUsername.text LIKE "*[A-Z]*" THEN + ' 'IF ME.tbUsername.textNOT LIKE "*[a-z0-9_-]*" THEN + ' Balloon.Error(("Login name field contains illegal characters. Please use only lowercase letters and numbers"), ME.tbUsername) + ' 'Message.Error(("Login name field contains illegal characters. Please use only lowercase letters and numbers")) + ' RETURN + ' STOP EVENT + ' 'ELSE IF ME.tbUsernameNOT LIKE "*[a-z0-9_-]*" THEN + ' + ' + ' END IF + ' + ' SHELL "echo " & ME.tbUsername.Text & "| grep -e \'[^a-z0-9_-]\'" TO sCHAR + ' 'SHELL "grep -e ^" & ME.tbUsername.Text & Space(1) & ClsGlobal.sTargetMnt &/ "etc/passwd" TO sLogE + ' SHELL "grep -e ^" & ME.tbUsername.Text & ": " & clsglobal.sTargetMnt &/ "etc" &/ "passwd" TO sLogE + ' + ' IF sCHAR <> "" THEN + ' Message(("Username contains illegal characters")) + ' RETURN + ' ELSE IF sLogE <> "" THEN + ' Message(("User account for") & Space(1) & ME.tbUsername.Text & Space(1) & ("already exists")) + ' RETURN + ' ELSE + ' IF ME.tbPasswd1.Text = "" THEN + ' Message(("Enter a password for") & Space(1) & ME.tbUsername.text) + ' RETURN + ' ELSE + ' IF ME.tbPasswd1.Text = ME.tbPasswd2.Text THEN + ' + ' 'COMPILE LIST OF GROUPS THIS USER WILL BELONG TO + ' FOR EACH cb IN MdlUsrAdd.objGrps + ' IF cb.Value = TRUE THEN + ' sGroups = sGroups & "," & cb.Text + ' END IF + ' NEXT + ' sGroups = Right(sGroups, Len(sGroups) - 1) + ' 'Message(sGroups) + ' + ' SHELL "chroot /mnt/target /usr/sbin/groupdel " & ME.tbUsername.Text WAIT '& " &> /dev/null" WAIT + ' PRINT "Creating new user group" + ' SHELL "chroot /mnt/target /usr/sbin/groupadd " & "-g" & Space(1) & iUID & Space(1) & ME.tbUsername.Text WAIT '& " &> /dev/null" WAIT + ' + ' 'Message("chroot /mnt/target /usr/sbin/useradd -m -s /bin/bash -u " & iUID & " -g " & ME.tbUsername.Text & " -G " & sGroups & ME.tbUsername.Text) + ' + ' 'SHELL "chroot /mnt/target /usr/sbin/useradd -m -s /bin/bash -u " & iUID & " -g " & ME.tbUsername.Text & " -G " & sGroups & Space(1) & ME.tbUsername.Text WAIT + ' PRINT "Creating new user account" + ' SHELL "chroot /mnt/target /usr/sbin/useradd -m -c " & "\'" & ME.tbRealname.text & "\'" & " -g " & ME.tbUsername.text & + ' " -p " & ME.tbPasswd1.text & " -u " & iUID & " -G " & "\'users," & sGroups & "\' -s /bin/bash " & ME.tbUsername.Text WAIT + ' ' sDocmd = "useradd -m -c " & "\'" & sname & "\'" & " -g " & slogin & " -p " & ME.txtpass1.Text & + ' '" -G " & "\'" & sgrparse & "\' " & slogin + ' + ' 'Message("chroot /mnt/target /sbin/passwdx " & ME.tbUsername.Text & Space(1) & ME.tbPasswd1.Text) + ' SHELL "chroot /mnt/target /sbin/passwdx " & ME.tbUsername.Text & Space(1) & ME.tbPasswd1.Text WAIT + ' 'IF IsDir(sPicdir) THEN + ' IF bUsePic.Value = TRUE THEN + ' + ' 'this next line is for kdm + ' SHELL "cd " & sPicdir & "; ln -s " & Replace(tbPicPath.Text, ClsGlobal.sTargetMnt, "") & Space(1) & tbUsername.Text & ".face.icon" WAIT + ' 'the next lines are for gdm + ' 'PRINT tbPicPath.Text + ' 'SHELL "cp " & Replace(tbPicPath.Text, ClsGlobal.sTargetMnt, "") & Space(1) & ClsGlobal.sTargetMnt &/ "home/" & tbUsername.Text & "/.face" WAIT + ' 'COPY Trim(tbPicPath.Text) TO clsglobal.sTargetMnt &/ "home" &/ tbUsername.text &/ ".face" + ' EXEC ["cp", Trim(tbPicPath.Text), clsglobal.sTargetMnt &/ "home" &/ tbUsername.Text &/ ".face"] WAIT + ' SHELL "chmod 644 " & ClsGlobal.sTargetMnt &/ "home/" & tbUsername.Text & "/.face" WAIT + ' SHELL "chroot " & ClsGlobal.sTargetMnt & " chown " & tbUsername.Text & Space(1) &/ "home/" & tbUsername.Text & "/.face" WAIT + ' SHELL "chroot " & ClsGlobal.sTargetMnt & " chgrp " & tbUsername.Text & Space(1) &/ "home/" & tbUsername.Text & "/.face" WAIT + ' ENDIF + ' 'Message(("User account for") & Space(1) & ME.tbUsername.Text & Space(1) & ("was created.")) + ' ' easy way to create the account here + ' tl = NEW TextLabel(ME.LstUsers) + ' WITH tl + ' .Text = ME.tbUsername.Text + ' .Height = 21 + ' .Width = MdlObjSizer.get_object_width(.Text) + ' .ToolTip = ME.tbRealname.Text + ' .Move(4, tly) + ' END WITH + ' tly = tly + tl.Height + 2 + ' btClrFrm_Click() ' clear the form + ' INC iUID + ' ELSE + ' Message(("Passwords do not match")) + ' Balloon.Info(("Enter the same password twice"), ME.tbPasswd1) + ' ME.tbPasswd1.Clear + ' ME.tbPasswd2.Clear + ' RETURN + ' STOP EVENT + ' ENDIF + ' ENDIF + ' ENDIF + ' ENDIF + ' + ' ME.LstUsers.Visible = TRUE + ' ME.pbUsrPic.Visible = FALSE + ' MdlCore.warn_status_off() + ' END + + +END |