|
From: <cod...@go...> - 2009-04-14 16:19:26
|
Author: M0...@gm...
Date: Tue Apr 14 09:01:05 2009
New Revision: 532
Modified:
branches/speedy/.lang/.pot
branches/speedy/.lang/MdlMain.pot
branches/speedy/.project
branches/speedy/Conf3.class
branches/speedy/MdlMain.module
Log:
- Finished code for user add window.
- TODO: Import using accounts
Modified: branches/speedy/.lang/.pot
==============================================================================
--- branches/speedy/.lang/.pot (original)
+++ branches/speedy/.lang/.pot Tue Apr 14 09:01:05 2009
@@ -200,7 +200,7 @@
msgid "Enter Passwrord"
msgstr ""
-#: Conf2.class:198 Conf3.class:311
+#: Conf2.class:198 Conf3.class:324
msgid "Re-enter Password"
msgstr ""
@@ -229,71 +229,71 @@
msgid "Select picture ID for"
msgstr ""
-#: Conf3.class:108
+#: Conf3.class:109
msgid "You must enter a login name first."
msgstr ""
-#: Conf3.class:111
+#: Conf3.class:112
msgid "Please select a password for"
msgstr ""
-#: Conf3.class:111
+#: Conf3.class:112
msgid "before continuing"
msgstr ""
-#: Conf3.class:114
+#: Conf3.class:115
msgid "You must enter the password twice for added security"
msgstr ""
-#: Conf3.class:133
+#: Conf3.class:145
msgid "User"
msgstr ""
-#: Conf3.class:133
+#: Conf3.class:145
msgid "already exists in the system."
msgstr ""
-#: Conf3.class:133
+#: Conf3.class:145
msgid "Please select another user login name"
msgstr ""
-#: Conf3.class:150
+#: Conf3.class:162
msgid "Use only lowercase letters and numbers for this field"
msgstr ""
-#: Conf3.class:212
+#: Conf3.class:225
msgid "Create User Accounts"
msgstr ""
-#: Conf3.class:262
+#: Conf3.class:275
msgid "Login Name"
msgstr ""
-#: Conf3.class:278
+#: Conf3.class:291
msgid "Real Name"
msgstr ""
-#: Conf3.class:294
+#: Conf3.class:307
msgid "Enter Password"
msgstr ""
-#: Conf3.class:339
+#: Conf3.class:352
msgid "Click here to select user Login picture"
msgstr ""
-#: Conf3.class:349
+#: Conf3.class:362
msgid "Create User"
msgstr ""
-#: Conf3.class:366
+#: Conf3.class:379
msgid "Import Existing User"
msgstr ""
-#: Conf3.class:382
+#: Conf3.class:395
msgid "Clear Form"
msgstr ""
-#: Conf3.class:397
+#: Conf3.class:410
msgid "User Rights Management"
msgstr ""
@@ -389,12 +389,16 @@
msgid "Bootsector of"
msgstr ""
-#: MdlMain.module:34
+#: MdlMain.module:35
msgid "Unable to format"
msgstr ""
-#: MdlMain.module:34
+#: MdlMain.module:35
msgid "to"
+msgstr ""
+
+#: MdlMain.module:193
+msgid "Failed to create user account. See error below."
msgstr ""
#: MdlStartUp.module:42
Modified: branches/speedy/.lang/MdlMain.pot
==============================================================================
--- branches/speedy/.lang/MdlMain.pot (original)
+++ branches/speedy/.lang/MdlMain.pot Tue Apr 14 09:01:05 2009
@@ -14,11 +14,15 @@
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
-#: MdlMain.module:34
+#: MdlMain.module:35
msgid "Unable to format"
msgstr ""
-#: MdlMain.module:34
+#: MdlMain.module:35
msgid "to"
+msgstr ""
+
+#: MdlMain.module:193
+msgid "Failed to create user account. See error below."
msgstr ""
Modified: branches/speedy/.project
==============================================================================
--- branches/speedy/.project (original)
+++ branches/speedy/.project Tue Apr 14 09:01:05 2009
@@ -1,7 +1,7 @@
# Gambas Project File 2.0
# Compiled with Gambas 2.12
Title=VectorLinux Installer
-Startup=MdlStartUp
+Startup=Conf3
Version=0.0.2
Library=gb.gtk
Library=gb.form
Modified: branches/speedy/Conf3.class
==============================================================================
--- branches/speedy/Conf3.class (original)
+++ branches/speedy/Conf3.class Tue Apr 14 09:01:05 2009
@@ -97,6 +97,7 @@
MdlMain.Display_User_Group_Choices(ME.lbUsrGrps)
' default the picture
ME.btPicSel.Picture =
Picture.Load("/usr/share/apps/kdm/pics/users/default2.png")
+ Dialog.Path = ""
END
@@ -119,22 +120,35 @@
PUBLIC SUB btAddUsr_Click()
-
+ DIM sPicpath AS String
'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)
+ '-== Get the right picture path ==-
+ IF NOT (Dialog.Path) THEN
+ sPicpath = "/usr/share/apps/kdm/pics/users/default2.png"
+ ELSE
+ sPicpath = Dialog.Path
+ END IF
+
+ '-== Make sure we have valid entries before trying to create a user
account ==-
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
+ MdlMain.CREATE_NEW_USER_ACCOUNT(Trim(txtLogin.Text),
Trim(txtRealName.Text), btPicSel.Picture, Trim(txtPass2.Text)) ' 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
+ ELSE
+ RETURN
+ STOP EVENT
END IF
+ ' clear the form now
+ Button2_Click()
END
@@ -152,3 +166,4 @@
END IF
END
+
Modified: branches/speedy/MdlMain.module
==============================================================================
--- branches/speedy/MdlMain.module (original)
+++ branches/speedy/MdlMain.module Tue Apr 14 09:01:05 2009
@@ -16,6 +16,7 @@
' along with vinstall-ng. If not, see <http://www.gnu.org/licenses/>.
PUBLIC $objUsrGroups AS NEW Object[]
+PRIVATE iUID AS Integer
PUBLIC FUNCTION FORMAT_THIS_PARTITION(sPartition AS String, sFilesystem AS
String) AS Integer
@@ -158,131 +159,59 @@
END
-PUBLIC FUNCTION CREATE_NEW_USER_ACCOUNT() AS Integer
+PUBLIC FUNCTION CREATE_NEW_USER_ACCOUNT(sUsrLogIn AS String, sUsrRlName AS
String, sPicPath AS String, sPass AS String) 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
+ DIM cb AS CheckBox
+ DIM sGrpLst, sDump AS String
+
+
+ ' -= Get the list of groups this user belongs to =-
+ FOR EACH cb IN $objUsrGroups
+ IF cb.Value = TRUE THEN
+ sGrpLst = sGrpLst & Space(1) & cb.Text
+ END IF
+ NEXT
+ sGrpLst = Trim(sGrpLst)
+ sGrpLst = Replace(sGrpLst, " ", ",")
+
+
+ '-== Just to be safe, make sure the group user does not exist before
trying to create a new user ==-
+ SHELL "chroot /mnt/target /usr/sbin/groupdel " & sUsrLogIn & " >
/dev/null " WAIT
+ '-== Create new group for user ==-
+ SHELL "chroot /mnt/target /usr/sbin/groupadd -g " & (1000 + iUID) &
Space(1) & sUsrLogIn & " > /dev/null" WAIT
+ '-== Create new user account ==-
+ SHELL "chroot /mnt/target /usr/sbin/useradd -m -c \'" & sUsrRlName & "\'
-g " & sUsrLogIn &
+ " -p " & Trim(sPass) & " -u " & (1000 + iUID) & " -G \'"
& "users," & sGrpLst & "\' -s /bin/bash " &
+ Trim(sUsrLogIn) & " || echo FAILED" TO sDump
+ ' [Quick error check]
+ sDump = Trim(sDump)
+ IF InStr(sDump, "FAILED") THEN
+ Message.Error(("Failed to create user account. See error
below.") & "<br><br>" & sDump)
+ RETURN 1
+ END IF
+ ' -== Just to be sure... re-run the password to make sure it's set ==-'
+ SHELL "chroot /mnt/target /sbin/passwdx " & sUsrLogIn & Space(1) & sPass
& " >/dev/null " WAIT
+ ' -== Set the face icon ==-
+ IF sPicPath THEN
+ ' -= fix for KDM login (KDE3) =-
+ TRY LINK "/mnt/target/usr/share/apps/kdm/pics/users" &/
sUsrLogIn & ".face.icon" TO sPicPath
+' CATCH
+' SHELL "ln -s " & sPicPath & Space(1)
& "/mnt/target/usr/share/apps/kdm/pics/users" &/ sUsrLogIn &/ ".face.icon"
+ ' -= fix for GDM login =-
+ TRY COPY sPicPath TO "/mnt/target/home" &/ sUsrLogIn &/ ".face"
+ SHELL "chmod 664 /mnt/target/home" &/ sUsrLogIn &/ ".face
2>/dev/null" WAIT
+ SHELL "chroot /mnt/target /bin/chown " & sUsrLogIn & Space(1)
& "/home/" &/ sUsrLogIn &/ ".face 2> /dev/null" WAIT
+ SHELL "chroot /mnt/target /bin/chgrp " & sUsrLogIn & Space(1)
& "/home" &/ sUsrLogIn &/ ".face 2> /dev/null" WAIT
+ END IF
+
+ ' USER ACCOUNT HAS BEEN CREATED
+ '-= increase the iUID number every time this sub runs =-
+ INC iUID
+ RETURN 0
END
|