A full-featured desktop for older equipment. And flat-out blistering on newer hardware!
Latest release is Absolute 12.1.0 beta1
|
|
|
| |
|
Add a User
Slackware has a useradd script for this that you can run from the commandline. However,
you have to add the new user to several specific groups in order for them to use
the programs installed on the machine. It can make for quite a long commandline string you have to type in,
and you can't afford to forget a group . . .
This little script does the tedious stuff for you. The new user will have to log in with the
password you set here, and as a user they will not have access to anything in the
System Tools > Configuration menu.
Add User
Make up a username and password. It will let you know if successful. BTW: if you want to get rid of a
user, open an xterm (as root) and enter userdel name_of_user
The script is written in Python and uses wxGTK. It is called absAdduser.py.
ToDo
-
Nothing I can think of . . .
|
|
Script is below:
#!/usr/bin/env python
# absAdduser.py
import wx
import xdialog
import sys
import os
import string
import commands
import crypt
adduser_xpm = [
"16 16 134 2",
" c None",
". c #8B5B08",
"+ c #9B6A18",
"@ c #A57629",
"# c #A87A33",
"$ c #9C6708",
"% c #89590A",
"& c #7F5101",
"* c #9A6911",
"= c #B78B38",
"- c #A57C46",
"; c #70481F",
"> c #9D6909",
", c #D3B276",
"' c #9E7B4A",
") c #724400",
"! c #916417",
"~ c #A98040",
"{ c #784E23",
"] c #714920",
"^ c #976A24",
"/ c #F5E0B6",
"( c #FCE8C8",
"_ c #B19265",
": c #845B20",
"< c #8C6225",
"[ c #6F4921",
"} c #855E30",
"| c #F7D3A1",
"1 c #FFE2B3",
"2 c #FFE9C3",
"3 c #E4CBA1",
"4 c #8A602D",
"5 c #885D35",
"6 c #F5CA90",
"7 c #FFD091",
"8 c #FFD59C",
"9 c #F8D79C",
"0 c #875D32",
"a c #C39565",
"b c #FFCA88",
"c c #FFCB86",
"d c #C09260",
"e c #4F4A7F",
"f c #D7AB82",
"g c #DEB580",
"h c #554D88",
"i c #135610",
"j c #4B8949",
"k c #589554",
"l c #497858",
"m c #9A9FBF",
"n c #CFD2DD",
"o c #D2D5DD",
"p c #C3C6DB",
"q c #767AB2",
"r c #6769A7",
"s c #205921",
"t c #7EE617",
"u c #80E720",
"v c #407444",
"w c #B3ACD0",
"x c #C2BDDF",
"y c #C5C5DC",
"z c #C7CBD8",
"A c #D5D8E1",
"B c #E7E9EC",
"C c #7576B0",
"D c #18621C",
"E c #1E6223",
"F c #316D37",
"G c #7AE512",
"H c #74DE20",
"I c #317234",
"J c #44784C",
"K c #417845",
"L c #9DB4A4",
"M c #DAD8E9",
"N c #D8D8E4",
"O c #D9DBE4",
"P c #B0B3C8",
"Q c #505492",
"R c #228122",
"S c #67DC10",
"T c #67DC0D",
"U c #6FE10C",
"V c #61D613",
"W c #5FD511",
"X c #5AD210",
"Y c #136F11",
"Z c #80B279",
"` c #EEE7FA",
" . c #D8D8E5",
".. c #B9BBCF",
"+. c #999DB6",
"@. c #595D98",
"#. c #565996",
"$. c #0B750B",
"%. c #4EC804",
"&. c #68DA04",
"*. c #5DD302",
"=. c #54CF00",
"-. c #55C904",
";. c #50C904",
">. c #008500",
",. c #7AAD77",
"'. c #E0D7F5",
"). c #BFC1D7",
"!. c #ACAFC8",
"~. c #9EA2BC",
"{. c #61649C",
"]. c #60639A",
"^. c #125212",
"/. c #114F13",
"(. c #16521B",
"_. c #59CA01",
":. c #59D300",
"<. c #1C5F19",
"[. c #14442C",
"}. c #163C42",
"|. c #2A337A",
"1. c #373690",
"2. c #33348C",
"3. c #32328B",
"4. c #313189",
"5. c #2B2B86",
"6. c #125112",
"7. c #6DD504",
"8. c #82F102",
"9. c #1B610E",
"0. c #135312",
"a. c #35800E",
"b. c #3D8A0E",
"c. c #226A0C",
" . + @ # ",
" $ % & * = - ",
" ; > , ' ) ! ~ { ",
" ] ^ / ( _ : < [ ",
" } | 1 2 3 4 ",
" 5 6 7 8 9 0 ",
" a b c d ",
" e f g h ",
" i j k l m n o p q r ",
" s t u v w x y z A B C ",
" D E F G H I J K L M N O P Q ",
" R S T U V W X Y Z ` ...+.@.#.",
" $.%.&.*.=.-.;.>.,.'.).!.~.{.].",
" ^./.(._.:.<.[.}.|.1.2.3.4.5. ",
" 6.7.8.9. ",
" 0.a.b.c. "
]
class MyFrame(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx.Size(400, 300))
self.panel = wx.Panel(self)
ptX = 10
icon = wx.BitmapFromXPMData = wx.BitmapFromXPMData(adduser_xpm)
icon1=wx.EmptyIcon()
icon1.CopyFromBitmap(icon)
self.SetIcon(icon1)
self.CenterOnScreen()
fontBold = wx.Font(14, wx.DEFAULT, wx.DEFAULT, wx.FONTWEIGHT_BOLD)
fontKindaBold = wx.Font(11, wx.DEFAULT, wx.DEFAULT, wx.FONTWEIGHT_BOLD)
self.topbox = wx.BoxSizer(wx.VERTICAL)
self.vbox = wx.BoxSizer(wx.VERTICAL)
self.hbox = wx.BoxSizer(wx.HORIZONTAL)
self.bottombox = wx.BoxSizer(wx.VERTICAL)
############################# services checkboxes ################################################################################
self.txt = wx.StaticText(self.panel, -1, "Create a new user account")
self.txt.SetForegroundColour((30, 30, 60))
self.txt.SetFont(fontBold)
self.vbox.Add(self.txt, 0, wx.ALIGN_CENTER | wx.TOP, 12)
self.icon_image = wx.StaticBitmap(self.panel, -1, icon)
self.vbox.Add(self.icon_image, 0, wx.ALIGN_CENTER | wx.ALL, 4)
self.txt2 = wx.StaticText(self.panel, -1, " This is a quick and simple way to create a new user with \n \
group permissions for audio, video, cdrom, disk and floppy access")
self.vbox.Add(self.txt2, 0, wx.ALIGN_CENTER)
self.username = wx.TextCtrl(self.panel, -1, "Enter user name here", size=(240, -1))
self.vbox.Add(self.username, 0, wx.ALIGN_CENTER | wx.TOP, 16)
self.username.SetToolTip( wx.ToolTip('Characters must be letters or numbers, only.') )
self.username.SetFont(fontBold)
self.username.Bind(wx.EVT_SET_FOCUS, self.OnFocusName)
self.username.Bind(wx.EVT_CHAR, self.OnChar)
self.txtpass = wx.StaticText(self.panel, -1, "Enter Password:")
self.vbox.Add(self.txtpass, 0, wx.ALIGN_CENTER | wx.TOP, 12)
self.txtpass.SetForegroundColour((30, 30, 60))
self.txtpass.SetFont(fontKindaBold)
self.password = wx.TextCtrl(self.panel, -1, "", style=wx.TE_PASSWORD, size=(200, -1))
self.vbox.Add(self.password, 0, wx.ALIGN_CENTER)
self.password.SetToolTip( wx.ToolTip('Characters must be letters or numbers, only.') )
self.password.SetFont(fontBold)
self.password.Bind(wx.EVT_SET_FOCUS, self.OnFocusPass)
self.password.Bind(wx.EVT_CHAR, self.OnChar)
self.txtpass2 = wx.StaticText(self.panel, -1, "Repeat password:")
self.vbox.Add(self.txtpass2, 0, wx.ALIGN_CENTER | wx.TOP, 12)
self.txtpass2.SetForegroundColour((30, 30, 60))
self.txtpass2.SetFont(fontKindaBold)
self.password2 = wx.TextCtrl(self.panel, -1, "", style=wx.TE_PASSWORD, size=(200, -1))
self.vbox.Add(self.password2, 0, wx.ALIGN_CENTER)
self.password2.SetToolTip( wx.ToolTip('Characters must be letters or numbers, only.') )
self.password2.SetFont(fontBold)
self.password2.Bind(wx.EVT_SET_FOCUS, self.OnFocusPass2)
self.password2.Bind(wx.EVT_CHAR, self.OnChar)
self.btnClose = wx.Button(self.panel, -1, 'Close')
self.btnClose.SetToolTip( wx.ToolTip('Close this dialog without creating a new user account.') )
self.hbox.Add(self.btnClose, 0, wx.ALIGN_CENTER | wx.ALL, 4)
self.btnCreate = wx.Button(self.panel, -1, 'Create')
self.btnCreate.SetToolTip( wx.ToolTip('Create the user account.') )
self.btnCreate.Enable(False)
self.hbox.Add(self.btnCreate, 0, wx.ALIGN_CENTER | wx.ALL, 4)
self.Bind(wx.EVT_BUTTON, self.OnClose, id=self.btnClose.GetId())
self.Bind(wx.EVT_BUTTON, self.MakeAccount, id=self.btnCreate.GetId())
self.txt3 = wx.StaticText(self.panel, -1, " For more fine-grained control, run the \"adduser\" script in an xterm and follow the prompts. >")
self.txt3.SetForegroundColour((60, 60, 140))
self.bottombox.Add(self.txt3, 0, wx.ALL, 4)
self.topbox.Add(self.vbox, 0, wx.ALIGN_CENTER |wx.LEFT | wx.RIGHT, 2)
self.topbox.Add(self.hbox, 0, wx.ALIGN_CENTER | wx.ALL, 4)
self.topbox.Add(self.bottombox, 0, wx.ALIGN_CENTER | wx.ALL, 4)
self.panel.SetSizer(self.topbox)
self.topbox.Fit(self)
width, height = self.GetSizeTuple()
self.SetSizeHints(width, height, width, height)
self.Bind(wx.EVT_TIMER, self.TimerTime)
def OnChar(self, event):
key = event.GetKeyCode()
if key < wx.WXK_SPACE or key == wx.WXK_DELETE or key > 255:
event.Skip()
return
if chr(key) in string.letters:
event.Skip()
return
if chr(key) in string.digits:
event.Skip()
return
wx.Bell()
return
def StartTimer(self, event):
self.t1 = wx.Timer(self)
self.t1.Start(200)
def TimerTime(self, event):
if (self.password.GetValue() == "Enter password here") | \
(self.username.GetValue() == "Enter user name here") | \
(self.password.GetValue() == "") | (self.username.GetValue() == ""):
self.btnCreate.Enable(False)
else:
self.btnCreate.Enable(True)
def MakeAccount(self, evt):
if self.password.GetValue() != self.password2.GetValue():
dlg = wx.MessageDialog(self, "\nThe passwords you entered do not match,\nplease try again.", "Error", wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
self.password.SetValue("")
self.password2.SetValue("")
return
sendpass = crypt.crypt(self.password.GetValue(),"a1")
try:
if commands.getoutput('useradd -m -g users -G users,audio,video,disk,plugdev,floppy,cdrom,games -p %s %s' % (sendpass,self.username.GetValue())):
dlg = wx.MessageDialog(self, "\nSorry, for some reason the user account could not be created.", "Error", wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
return
else:
dlg = wx.MessageDialog(self, '\nThe user account has been successfully created.', "Success", wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
self.Close(True)
except:
dlg = wx.MessageDialog(self, "\nSorry, for some reason the user account could not be created.", "Error", wx.OK | wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
return
#############################################################################
def OnFocusName(self, event):
self.username.SetValue("")
self.StartTimer(None)
def OnFocusPass(self, event):
self.password.SetValue("")
def OnFocusPass2(self, event):
self.password2.SetValue("")
#############################################################################
def OnClose(self, event):
self.Close(True)
#############################################################################
#####################################################################################################################
class MyApp(wx.App):
def OnInit(self):
if not os.geteuid()==0:
sys.exit("\nOnly root can run this script\n")
frame = MyFrame(None, -1, 'Add a basic user')
frame.Show(True)
self.SetTopWindow(frame)
return True
app = MyApp(0)
app.MainLoop()
Pages created on Absolute OS
|
Graphics made/edited by the Gimp
|
|