author | umopapisdn <umopapisdn> | 2002-10-14 21:58:41 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2002-10-14 21:58:41 (UTC) |
commit | 09ba6b7531801dde243469f05f5e5c31596cdd2d (patch) (unidiff) | |
tree | 07531378e9a05ff777dfb151276075b233bcb4d8 | |
parent | 14f450ead20011e5697bb36a4ad087cc648b439d (diff) | |
download | opie-09ba6b7531801dde243469f05f5e5c31596cdd2d.zip opie-09ba6b7531801dde243469f05f5e5c31596cdd2d.tar.gz opie-09ba6b7531801dde243469f05f5e5c31596cdd2d.tar.bz2 |
Support for a skeleton homedirectory in /etc/skel.
-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index c43b391..42a9144 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp | |||
@@ -97,34 +97,34 @@ void UserDialog::setupTab1() { | |||
97 | shellComboBox=new QComboBox(tabpage,"shell"); | 97 | shellComboBox=new QComboBox(tabpage,"shell"); |
98 | shellComboBox->setEditable(true); | 98 | shellComboBox->setEditable(true); |
99 | shellComboBox->insertItem("/bin/sh"); | 99 | shellComboBox->insertItem("/bin/sh"); |
100 | shellComboBox->insertItem("/bin/ash"); | 100 | shellComboBox->insertItem("/bin/ash"); |
101 | shellComboBox->insertItem("/bin/false"); | 101 | shellComboBox->insertItem("/bin/false"); |
102 | 102 | ||
103 | // Primary Group | 103 | // Primary Group |
104 | QLabel *groupLabel=new QLabel(tabpage,"group"); | 104 | QLabel *groupLabel=new QLabel(tabpage,"group"); |
105 | groupLabel->setText("Primary group: "); | 105 | groupLabel->setText("Primary group: "); |
106 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); | 106 | groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); |
107 | 107 | ||
108 | // Copy /etc/skel | 108 | // Copy /etc/skel |
109 | QLabel *skelLabel=new QLabel(tabpage,"skel"); | 109 | QLabel *skelLabel=new QLabel(tabpage,"skel"); |
110 | skelLabel->setText("Copy /etc/skel: "); | 110 | skelLabel->setText("Copy /etc/skel: "); |
111 | skelCheckBox=new QCheckBox(tabpage); | 111 | skelCheckBox=new QCheckBox(tabpage); |
112 | skelCheckBox->setChecked(true); | 112 | skelCheckBox->setChecked(true); |
113 | skelLabel->setDisabled(true); | 113 | //skelLabel->setDisabled(true); |
114 | skelCheckBox->setDisabled(true); | 114 | //skelCheckBox->setDisabled(true); |
115 | 115 | ||
116 | // Widget layout | 116 | // Widget layout |
117 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); | 117 | QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); |
118 | layout->addWidget(picturePushButton); | 118 | layout->addWidget(picturePushButton); |
119 | layout->addSpacing(5); | 119 | layout->addSpacing(5); |
120 | layout->addLayout(hlayout); | 120 | layout->addLayout(hlayout); |
121 | QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); | 121 | QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); |
122 | QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); | 122 | QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); |
123 | // First column, labels | 123 | // First column, labels |
124 | vlayout1->addWidget(loginLabel); | 124 | vlayout1->addWidget(loginLabel); |
125 | vlayout1->addSpacing(5); | 125 | vlayout1->addSpacing(5); |
126 | vlayout1->addWidget(uidLabel); | 126 | vlayout1->addWidget(uidLabel); |
127 | vlayout1->addSpacing(5); | 127 | vlayout1->addSpacing(5); |
128 | vlayout1->addWidget(gecosLabel); | 128 | vlayout1->addWidget(gecosLabel); |
129 | vlayout1->addSpacing(5); | 129 | vlayout1->addSpacing(5); |
130 | vlayout1->addWidget(passwordLabel); | 130 | vlayout1->addWidget(passwordLabel); |
@@ -230,32 +230,48 @@ bool UserDialog::addUser(int uid, int gid) { | |||
230 | QListViewItemIterator it( adduserDialog->groupsListView ); | 230 | QListViewItemIterator it( adduserDialog->groupsListView ); |
231 | for ( ; it.current(); ++it ) { | 231 | for ( ; it.current(); ++it ) { |
232 | temp=(QCheckListItem*)it.current(); | 232 | temp=(QCheckListItem*)it.current(); |
233 | if (temp->isOn() ) | 233 | if (temp->isOn() ) |
234 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); | 234 | accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); |
235 | } | 235 | } |
236 | // Copy image to pics/users/ | 236 | // Copy image to pics/users/ |
237 | if(!(adduserDialog->userImage.isNull())) { | 237 | if(!(adduserDialog->userImage.isNull())) { |
238 | QDir d; | 238 | QDir d; |
239 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { | 239 | if(!(d.exists("/opt/QtPalmtop/pics/users"))) { |
240 | d.mkdir("/opt/QtPalmtop/pics/users"); | 240 | d.mkdir("/opt/QtPalmtop/pics/users"); |
241 | } | 241 | } |
242 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; | 242 | QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; |
243 | // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); | 243 | // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); |
244 | adduserDialog->userImage.save(filename,"PNG"); | 244 | adduserDialog->userImage.save(filename,"PNG"); |
245 | } | 245 | } |
246 | |||
247 | // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? | ||
248 | accounts->findUser(adduserDialog->loginLineEdit->text()); | ||
249 | if(adduserDialog->skelCheckBox->isChecked()) { | ||
250 | QString command_cp; | ||
251 | QString command_chown; | ||
252 | command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); | ||
253 | system(command_cp); | ||
254 | |||
255 | command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1());// Bug in busybox, ".*" includes parent directory, does this work as a workaround? | ||
256 | system(command_cp); | ||
257 | |||
258 | command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1()); | ||
259 | system(command_chown); | ||
260 | } | ||
261 | |||
246 | return true; | 262 | return true; |
247 | } | 263 | } |
248 | 264 | ||
249 | /** | 265 | /** |
250 | * Deletes the user account. | 266 | * Deletes the user account. |
251 | * | 267 | * |
252 | * @param username User to be deleted. | 268 | * @param username User to be deleted. |
253 | * | 269 | * |
254 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. | 270 | * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. |
255 | * | 271 | * |
256 | */ | 272 | */ |
257 | bool UserDialog::delUser(const char *username) { | 273 | bool UserDialog::delUser(const char *username) { |
258 | if((accounts->findUser(username))) {// Does that user exist? | 274 | if((accounts->findUser(username))) {// Does that user exist? |
259 | if(!(accounts->delUser(username))) {// Delete the user. | 275 | if(!(accounts->delUser(username))) {// Delete the user. |
260 | QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); | 276 | QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); |
261 | } | 277 | } |