summaryrefslogtreecommitdiff
path: root/noncore/settings
authorumopapisdn <umopapisdn>2002-09-28 06:36:30 (UTC)
committer umopapisdn <umopapisdn>2002-09-28 06:36:30 (UTC)
commit8a95ca149ff5eedc9215bb012c8d7d09cdcaf96c (patch) (unidiff)
tree50aed468fa8888266c589ce47131d0acaf7f82b7 /noncore/settings
parent996c0d02d16c185acc3190baa5b4a1fc934e730c (diff)
downloadopie-8a95ca149ff5eedc9215bb012c8d7d09cdcaf96c.zip
opie-8a95ca149ff5eedc9215bb012c8d7d09cdcaf96c.tar.gz
opie-8a95ca149ff5eedc9215bb012c8d7d09cdcaf96c.tar.bz2
Now actually makes the homedirectories owned by the user they belong to. :)
Diffstat (limited to 'noncore/settings') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/usermanager/passwd.cpp5
-rw-r--r--noncore/settings/usermanager/userdialog.cpp10
-rw-r--r--noncore/settings/usermanager/userdialog.h2
-rw-r--r--noncore/settings/usermanager/usermanager.pro2
4 files changed, 15 insertions, 4 deletions
diff --git a/noncore/settings/usermanager/passwd.cpp b/noncore/settings/usermanager/passwd.cpp
index 310cef8..5063661 100644
--- a/noncore/settings/usermanager/passwd.cpp
+++ b/noncore/settings/usermanager/passwd.cpp
@@ -2,24 +2,25 @@
2 * * 2 * *
3 * This program is free software; you can redistribute it and/or modify * 3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by * 4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or * 5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. * 6 * (at your option) any later version. *
7 * * 7 * *
8 ***************************************************************************/ 8 ***************************************************************************/
9 9
10#include "passwd.h" 10#include "passwd.h"
11 11
12// Needed for crypt_make_salt(); 12// Needed for crypt_make_salt();
13#include <sys/types.h> 13#include <sys/types.h>
14#include <sys/stat.h>
14#include <unistd.h> 15#include <unistd.h>
15#include <time.h> 16#include <time.h>
16 17
17Passwd::Passwd() { 18Passwd::Passwd() {
18} 19}
19 20
20Passwd::~Passwd() { 21Passwd::~Passwd() {
21} 22}
22 23
23// This function is taken from 'busybox'. 24// This function is taken from 'busybox'.
24int Passwd::i64c(int i) 25int Passwd::i64c(int i)
25{ 26{
@@ -130,34 +131,36 @@ bool Passwd::searchUser(QRegExp &userRegExp) {
130} 131}
131 132
132bool Passwd::findUser(const char *username) { 133bool Passwd::findUser(const char *username) {
133 QRegExp userRegExp(QString("^%1\\:").arg(username)); 134 QRegExp userRegExp(QString("^%1\\:").arg(username));
134 return searchUser(userRegExp); 135 return searchUser(userRegExp);
135} 136}
136 137
137bool Passwd::findUser(int uid) { 138bool Passwd::findUser(int uid) {
138 QRegExp userRegExp(QString(":%1\\:").arg(uid)); 139 QRegExp userRegExp(QString(":%1\\:").arg(uid));
139 return searchUser(userRegExp); 140 return searchUser(userRegExp);
140} 141}
141 142
142bool Passwd::addUser(QString pw_name, QString pw_passwd, int pw_uid, int pw_gid, QString pw_gecos,QString pw_dir, QString pw_shell, bool createGroup=true) { 143bool Passwd::addUser(QString pw_name, QString pw_passwd, int pw_uid, int pw_gid, QString pw_gecos,QString pw_dir, QString pw_shell, bool createGroup) {
143 QString tempString; 144 QString tempString;
144 if((createGroup) && (!(findGroup(pw_gid)))) addGroup(pw_name,pw_gid); 145 if((createGroup) && (!(findGroup(pw_gid)))) addGroup(pw_name,pw_gid);
145 pw_passwd = crypt(pw_passwd, crypt_make_salt()); 146 pw_passwd = crypt(pw_passwd, crypt_make_salt());
146 tempString=pw_name+":"+pw_passwd+":"+QString::number(pw_uid)+":"+QString::number(pw_gid)+":"+pw_gecos+":"+pw_dir+":"+pw_shell; 147 tempString=pw_name+":"+pw_passwd+":"+QString::number(pw_uid)+":"+QString::number(pw_gid)+":"+pw_gecos+":"+pw_dir+":"+pw_shell;
147 passwdStringList.append(tempString); 148 passwdStringList.append(tempString);
148 // Make home dir. 149 // Make home dir.
149 QDir d; 150 QDir d;
150 if(!(d.exists(pw_dir))) { 151 if(!(d.exists(pw_dir))) {
151 d.mkdir(pw_dir); 152 d.mkdir(pw_dir);
153 chown(pw_dir,pw_uid,pw_gid);
154 chmod(pw_dir,S_IRUSR|S_IWUSR|S_IXUSR);
152 } 155 }
153 return 1; 156 return 1;
154} 157}
155 158
156bool Passwd::updateUser(QString login) { 159bool Passwd::updateUser(QString login) {
157 QRegExp userRegExp(QString("^%1\\:").arg(login)); 160 QRegExp userRegExp(QString("^%1\\:").arg(login));
158 for(QStringList::Iterator it=passwdStringList.begin(); it!=passwdStringList.end(); ++it) { 161 for(QStringList::Iterator it=passwdStringList.begin(); it!=passwdStringList.end(); ++it) {
159 if(userRegExp.find((*it),0)!=-1) { 162 if(userRegExp.find((*it),0)!=-1) {
160 *it=QString(pw_name+":"+pw_passwd+":"+QString::number(pw_uid)+":"+QString::number(pw_gid)+":"+pw_gecos+":"+pw_dir+":"+pw_shell); 163 *it=QString(pw_name+":"+pw_passwd+":"+QString::number(pw_uid)+":"+QString::number(pw_gid)+":"+pw_gecos+":"+pw_dir+":"+pw_shell);
161 return true; 164 return true;
162 } 165 }
163 } 166 }
diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp
index f31775d..6940a3b 100644
--- a/noncore/settings/usermanager/userdialog.cpp
+++ b/noncore/settings/usermanager/userdialog.cpp
@@ -28,25 +28,26 @@
28 * 28 *
29 */ 29 */
30UserDialog::UserDialog(QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) { 30UserDialog::UserDialog(QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) {
31 QVBoxLayout *layout = new QVBoxLayout(this); 31 QVBoxLayout *layout = new QVBoxLayout(this);
32 myTabWidget=new QTabWidget(this,"User Tab Widget"); 32 myTabWidget=new QTabWidget(this,"User Tab Widget");
33 layout->addWidget(myTabWidget); 33 layout->addWidget(myTabWidget);
34 setupTab1(); 34 setupTab1();
35 setupTab2(); 35 setupTab2();
36 36
37 // And also fill the listview & the combobox with all available groups. 37 // And also fill the listview & the combobox with all available groups.
38 for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) { 38 for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) {
39 accounts->splitGroupEntry(*it); 39 accounts->splitGroupEntry(*it);
40 new QListViewItem(groupsListView,accounts->gr_name); 40 //new QListViewItem(groupsListView,accounts->gr_name);
41 new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox);
41 groupComboBox->insertItem(accounts->gr_name); 42 groupComboBox->insertItem(accounts->gr_name);
42 } 43 }
43 44
44 showMaximized(); 45 showMaximized();
45} 46}
46 47
47/** 48/**
48 * Empty destructor. 49 * Empty destructor.
49 * 50 *
50 */ 51 */
51UserDialog::~UserDialog() { 52UserDialog::~UserDialog() {
52} 53}
@@ -146,24 +147,25 @@ void UserDialog::setupTab1() {
146 * 147 *
147 */ 148 */
148void UserDialog::setupTab2() { 149void UserDialog::setupTab2() {
149 QWidget *tabpage = new QWidget(myTabWidget,"page2"); 150 QWidget *tabpage = new QWidget(myTabWidget,"page2");
150 QVBoxLayout *layout = new QVBoxLayout(tabpage); 151 QVBoxLayout *layout = new QVBoxLayout(tabpage);
151 layout->setMargin(5); 152 layout->setMargin(5);
152 153
153 // Additional groups 154 // Additional groups
154 groupsListView=new QListView(tabpage,"groups"); 155 groupsListView=new QListView(tabpage,"groups");
155 groupsListView->addColumn("Additional groups"); 156 groupsListView->addColumn("Additional groups");
156 groupsListView->setColumnWidthMode(0,QListView::Maximum); 157 groupsListView->setColumnWidthMode(0,QListView::Maximum);
157 groupsListView->setMultiSelection(true); 158 groupsListView->setMultiSelection(true);
159 groupsListView->setAllColumnsShowFocus(false);
158 160
159 layout->addSpacing(5); 161 layout->addSpacing(5);
160 // Grouplist 162 // Grouplist
161 layout->addWidget(groupsListView); 163 layout->addWidget(groupsListView);
162 164
163 myTabWidget->addTab(tabpage,"User Groups"); 165 myTabWidget->addTab(tabpage,"User Groups");
164} 166}
165 167
166/** 168/**
167 * Static function that creates the userinfo dialog. 169 * Static function that creates the userinfo dialog.
168 * The user will be prompted to add a user. 170 * The user will be prompted to add a user.
169 * 171 *
@@ -306,14 +308,18 @@ void UserDialog::accept() {
306 if(loginLineEdit->text().isEmpty()) { 308 if(loginLineEdit->text().isEmpty()) {
307 QMessageBox::information(0,"Empty Login","Please enter a login."); 309 QMessageBox::information(0,"Empty Login","Please enter a login.");
308 return; 310 return;
309 } 311 }
310 QDialog::accept(); 312 QDialog::accept();
311} 313}
312 314
313/** 315/**
314 * This slot is called when the usericon is clicked, this loads (should) the iconselector. 316 * This slot is called when the usericon is clicked, this loads (should) the iconselector.
315 * 317 *
316 */ 318 */
317void UserDialog::clickedPicture() { 319void UserDialog::clickedPicture() {
318 QMessageBox::information(0,"Sorry!","Icon selection not yet implemented.\nComming real soon now! (tm)"); 320 QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED,"/opt/QtPalmtop/pics");
321 // OFileDialog *fd=new OFileDialog("Select Icon",this, OFileSelector::OPEN, OFileSelector::EXTENDED,"/");
322 //fd->showMaximized();
323 //fd->exec();
324 QMessageBox::information(0,"Sorry!","Icon selection not yet implemented.\nComming real soon now! (tm)\n"+filename);
319} 325}
diff --git a/noncore/settings/usermanager/userdialog.h b/noncore/settings/usermanager/userdialog.h
index b44de9e..df54269 100644
--- a/noncore/settings/usermanager/userdialog.h
+++ b/noncore/settings/usermanager/userdialog.h
@@ -9,24 +9,26 @@
9#ifndef USERDIALOG_H 9#ifndef USERDIALOG_H
10#define USERDIALOG_H 10#define USERDIALOG_H
11 11
12#include <qdialog.h> 12#include <qdialog.h>
13#include <qlineedit.h> 13#include <qlineedit.h>
14#include <qcombobox.h> 14#include <qcombobox.h>
15#include <qlistview.h> 15#include <qlistview.h>
16#include <qtabwidget.h> 16#include <qtabwidget.h>
17#include <qpushbutton.h> 17#include <qpushbutton.h>
18 18
19#include <qpe/resource.h> 19#include <qpe/resource.h>
20 20
21#include <opie/ofiledialog.h>
22
21class UserDialog : public QDialog 23class UserDialog : public QDialog
22{ 24{
23 Q_OBJECT 25 Q_OBJECT
24private: 26private:
25 QTabWidget *myTabWidget; 27 QTabWidget *myTabWidget;
26 QPushButton *picturePushButton; 28 QPushButton *picturePushButton;
27 QLineEdit *loginLineEdit; 29 QLineEdit *loginLineEdit;
28 QLineEdit *uidLineEdit; 30 QLineEdit *uidLineEdit;
29 QLineEdit *gecosLineEdit; 31 QLineEdit *gecosLineEdit;
30 QLineEdit *passwordLineEdit; 32 QLineEdit *passwordLineEdit;
31 QComboBox *shellComboBox; 33 QComboBox *shellComboBox;
32 QComboBox *groupComboBox; 34 QComboBox *groupComboBox;
diff --git a/noncore/settings/usermanager/usermanager.pro b/noncore/settings/usermanager/usermanager.pro
index fc45f93..2f3212f 100644
--- a/noncore/settings/usermanager/usermanager.pro
+++ b/noncore/settings/usermanager/usermanager.pro
@@ -1,10 +1,10 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 #CONFIG = qt warn_on debug 2 #CONFIG = qt warn_on debug
3 CONFIG = qt warn_on release 3 CONFIG = qt warn_on release
4 HEADERS = usermanager.h userdialog.h groupdialog.h passwd.h 4 HEADERS = usermanager.h userdialog.h groupdialog.h passwd.h
5 SOURCES = usermanager.cpp userdialog.cpp groupdialog.cpp passwd.h main.cpp 5 SOURCES = usermanager.cpp userdialog.cpp groupdialog.cpp passwd.h main.cpp
6 INCLUDEPATH+= $(OPIEDIR)/include 6 INCLUDEPATH+= $(OPIEDIR)/include
7 DEPENDPATH+= $(OPIEDIR)/include 7 DEPENDPATH+= $(OPIEDIR)/include
8LIBS += -lqpe -lcrypt 8LIBS += -lqpe -lopie -lcrypt
9 TARGET = usermanager 9 TARGET = usermanager
10DESTDIR = $(OPIEDIR)/bin 10DESTDIR = $(OPIEDIR)/bin