Diffstat (limited to 'core/settings/security/security.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/settings/security/security.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/core/settings/security/security.cpp b/core/settings/security/security.cpp index c4726b3..00ea105 100644 --- a/core/settings/security/security.cpp +++ b/core/settings/security/security.cpp | |||
@@ -90,64 +90,68 @@ | |||
90 | } | 90 | } |
91 | 91 | ||
92 | Security::~Security() | 92 | Security::~Security() |
93 | { | 93 | { |
94 | } | 94 | } |
95 | 95 | ||
96 | 96 | ||
97 | void Security::updateGUI() | 97 | void Security::updateGUI() |
98 | { | 98 | { |
99 | bool empty = passcode.isEmpty(); | 99 | bool empty = passcode.isEmpty(); |
100 | 100 | ||
101 | changepasscode->setText( empty ? tr("Set passcode" ) | 101 | changepasscode->setText( empty ? tr("Set passcode" ) |
102 | : tr("Change passcode" ) ); | 102 | : tr("Change passcode" ) ); |
103 | passcode_poweron->setEnabled( !empty ); | 103 | passcode_poweron->setEnabled( !empty ); |
104 | clearpasscode->setEnabled( !empty ); | 104 | clearpasscode->setEnabled( !empty ); |
105 | 105 | ||
106 | autologinToggle->setChecked(autoLogin); | 106 | autologinToggle->setChecked(autoLogin); |
107 | userlist->setEnabled(autoLogin); | 107 | userlist->setEnabled(autoLogin); |
108 | 108 | ||
109 | } | 109 | } |
110 | 110 | ||
111 | 111 | ||
112 | void Security::show() | 112 | void Security::show() |
113 | { | 113 | { |
114 | valid=FALSE; | 114 | //valid=FALSE; |
115 | setEnabled(FALSE); | 115 | setEnabled(FALSE); |
116 | SecurityBase::show(); | 116 | SecurityBase::show(); |
117 | if ( passcode.isEmpty() ) { | 117 | if ( passcode.isEmpty() ) { |
118 | // could insist... | 118 | // could insist... |
119 | //changePassCode(); | 119 | //changePassCode(); |
120 | //if ( passcode.isEmpty() ) | 120 | //if ( passcode.isEmpty() ) |
121 | //reject(); | 121 | //reject(); |
122 | } else { | 122 | } else { |
123 | QString pc = enterPassCode(tr("Enter passcode")); | 123 | |
124 | if ( pc != passcode ) { | 124 | if (!valid) // security passcode was not asked yet, so ask now |
125 | QMessageBox::critical(this, tr("Passcode incorrect"), | 125 | { |
126 | tr("The passcode entered is incorrect.\nAccess denied")); | 126 | QString pc = enterPassCode(tr("Enter passcode")); |
127 | reject(); | 127 | if ( pc != passcode ) { |
128 | return; | 128 | QMessageBox::critical(this, tr("Passcode incorrect"), |
129 | } | 129 | tr("The passcode entered is incorrect.\nAccess denied")); |
130 | reject(); | ||
131 | return; | ||
132 | } | ||
133 | } | ||
130 | } | 134 | } |
131 | setEnabled(TRUE); | 135 | setEnabled(TRUE); |
132 | valid=TRUE; | 136 | valid=TRUE; |
133 | } | 137 | } |
134 | 138 | ||
135 | void Security::accept() | 139 | void Security::accept() |
136 | { | 140 | { |
137 | applySecurity(); | 141 | applySecurity(); |
138 | QDialog::accept(); | 142 | QDialog::accept(); |
139 | QCopEnvelope env("QPE/System", "securityChanged()" ); | 143 | QCopEnvelope env("QPE/System", "securityChanged()" ); |
140 | } | 144 | } |
141 | 145 | ||
142 | void Security::done(int r) | 146 | void Security::done(int r) |
143 | { | 147 | { |
144 | QDialog::done(r); | 148 | QDialog::done(r); |
145 | close(); | 149 | close(); |
146 | } | 150 | } |
147 | 151 | ||
148 | void Security::selectNet(int auth_peer,int auth_peer_bits) | 152 | void Security::selectNet(int auth_peer,int auth_peer_bits) |
149 | { | 153 | { |
150 | QString sn; | 154 | QString sn; |
151 | if ( auth_peer_bits == 0 && auth_peer == 0 ) { | 155 | if ( auth_peer_bits == 0 && auth_peer == 0 ) { |
152 | sn = tr("Any"); | 156 | sn = tr("Any"); |
153 | } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { | 157 | } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { |
@@ -192,97 +196,104 @@ void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) | |||
192 | 196 | ||
193 | void Security::loadUsers ( void ) | 197 | void Security::loadUsers ( void ) |
194 | { | 198 | { |
195 | QFile passwd("/etc/passwd"); | 199 | QFile passwd("/etc/passwd"); |
196 | if ( passwd.open(IO_ReadOnly) ) { | 200 | if ( passwd.open(IO_ReadOnly) ) { |
197 | QTextStream t( &passwd ); | 201 | QTextStream t( &passwd ); |
198 | QString s; | 202 | QString s; |
199 | QStringList account; | 203 | QStringList account; |
200 | while ( !t.eof() ) { | 204 | while ( !t.eof() ) { |
201 | account = QStringList::split(':',t.readLine()); | 205 | account = QStringList::split(':',t.readLine()); |
202 | 206 | ||
203 | // Hide disabled accounts | 207 | // Hide disabled accounts |
204 | if (*account.at(1)!="*") { | 208 | if (*account.at(1)!="*") { |
205 | 209 | ||
206 | userlist->insertItem(*account.at(0)); | 210 | userlist->insertItem(*account.at(0)); |
207 | // Highlight this item if it is set to autologinToggle | 211 | // Highlight this item if it is set to autologinToggle |
208 | if ( *account.at(0) == autoLoginName) | 212 | if ( *account.at(0) == autoLoginName) |
209 | userlist->setCurrentItem(userlist->count()-1); | 213 | userlist->setCurrentItem(userlist->count()-1); |
210 | } | 214 | } |
211 | } | 215 | } |
212 | passwd.close(); | 216 | passwd.close(); |
213 | } | 217 | } |
214 | 218 | ||
215 | } | 219 | } |
220 | |||
216 | void Security::toggleAutoLogin(bool val) | 221 | void Security::toggleAutoLogin(bool val) |
217 | { | 222 | { |
218 | autoLogin=val; | 223 | autoLogin=val; |
219 | userlist->setEnabled(val); | 224 | userlist->setEnabled(val); |
220 | if (!autoLogin) | 225 | if (!autoLogin) |
221 | autoLoginName=userlist->currentText(); | 226 | autoLoginName=userlist->currentText(); |
222 | } | 227 | } |
228 | |||
229 | |||
230 | |||
231 | |||
223 | void Security::setSyncNet(const QString& sn) | 232 | void Security::setSyncNet(const QString& sn) |
224 | { | 233 | { |
225 | int auth_peer,auth_peer_bits; | 234 | int auth_peer,auth_peer_bits; |
226 | parseNet(sn,auth_peer,auth_peer_bits); | 235 | parseNet(sn,auth_peer,auth_peer_bits); |
227 | selectNet(auth_peer,auth_peer_bits); | 236 | selectNet(auth_peer,auth_peer_bits); |
228 | } | 237 | } |
229 | 238 | ||
230 | void Security::applySecurity() | 239 | void Security::applySecurity() |
231 | { | 240 | { |
232 | if ( valid ) { | 241 | if ( valid ) { |
242 | <<<<<<< security.cpp | ||
233 | Config cfg("Security"); | 243 | Config cfg("Security"); |
234 | cfg.setGroup("Passcode"); | 244 | cfg.setGroup("Passcode"); |
235 | cfg.writeEntry("passcode",passcode); | 245 | cfg.writeEntry("passcode",passcode); |
236 | cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked()); | 246 | cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked()); |
237 | cfg.setGroup("Sync"); | 247 | cfg.setGroup("Sync"); |
238 | int auth_peer=0; | 248 | int auth_peer=0; |
239 | int auth_peer_bits; | 249 | int auth_peer_bits; |
240 | QString sn = syncnet->currentText(); | 250 | QString sn = syncnet->currentText(); |
241 | parseNet(sn,auth_peer,auth_peer_bits); | 251 | parseNet(sn,auth_peer,auth_peer_bits); |
242 | cfg.writeEntry("auth_peer",auth_peer); | 252 | cfg.writeEntry("auth_peer",auth_peer); |
243 | cfg.writeEntry("auth_peer_bits",auth_peer_bits); | 253 | cfg.writeEntry("auth_peer_bits",auth_peer_bits); |
244 | /* | 254 | /* |
245 | cfg.setGroup("Remote"); | 255 | cfg.setGroup("Remote"); |
246 | if ( telnetAvailable() ) | 256 | if ( telnetAvailable() ) |
247 | cfg.writeEntry("allow_telnet",telnet->isChecked()); | 257 | cfg.writeEntry("allow_telnet",telnet->isChecked()); |
248 | if ( sshAvailable() ) | 258 | if ( sshAvailable() ) |
249 | cfg.writeEntry("allow_ssh",ssh->isChecked()); | 259 | cfg.writeEntry("allow_ssh",ssh->isChecked()); |
250 | // ### write ssh/telnet sys config files | 260 | // ### write ssh/telnet sys config files |
251 | */ | 261 | */ |
252 | 262 | ||
253 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; | 263 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; |
254 | Config loginCfg(configFile,Config::File); | 264 | Config loginCfg(configFile,Config::File); |
255 | loginCfg.setGroup("General"); | 265 | loginCfg.setGroup("General"); |
256 | 266 | ||
257 | if (autoLogin) { | 267 | if (autoLogin) { |
258 | loginCfg.writeEntry("AutoLogin",autoLoginName); | 268 | loginCfg.writeEntry("AutoLogin",autoLoginName); |
259 | } else { | 269 | } else { |
260 | loginCfg.removeEntry("AutoLogin"); | 270 | loginCfg.removeEntry("AutoLogin"); |
261 | } | 271 | } |
262 | 272 | ||
263 | cfg.setGroup("SyncMode"); | 273 | cfg.setGroup("SyncMode"); |
264 | cfg.writeEntry("Mode", syncModeCombo->currentItem()+1 ); | 274 | cfg.writeEntry("Mode", syncModeCombo->currentItem()+1 ); |
275 | |||
265 | } | 276 | } |
266 | } | 277 | } |
267 | 278 | ||
268 | void Security::changeLoginName( int idx ) | 279 | void Security::changeLoginName( int idx ) |
269 | { | 280 | { |
270 | autoLoginName = userlist->text(idx);; | 281 | autoLoginName = userlist->text(idx);; |
271 | updateGUI(); | 282 | updateGUI(); |
272 | } | 283 | } |
273 | 284 | ||
274 | void Security::changePassCode() | 285 | void Security::changePassCode() |
275 | { | 286 | { |
276 | QString new1; | 287 | QString new1; |
277 | QString new2; | 288 | QString new2; |
278 | 289 | ||
279 | do { | 290 | do { |
280 | new1 = enterPassCode(tr("Enter new passcode")); | 291 | new1 = enterPassCode(tr("Enter new passcode")); |
281 | if ( new1.isNull() ) | 292 | if ( new1.isNull() ) |
282 | return; | 293 | return; |
283 | new2 = enterPassCode(tr("Re-enter new passcode")); | 294 | new2 = enterPassCode(tr("Re-enter new passcode")); |
284 | if ( new2.isNull() ) | 295 | if ( new2.isNull() ) |
285 | return; | 296 | return; |
286 | } while (new1 != new2); | 297 | } while (new1 != new2); |
287 | 298 | ||
288 | passcode = new1; | 299 | passcode = new1; |