-rw-r--r-- | core/settings/security/security.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/settings/security/security.cpp b/core/settings/security/security.cpp index 00ea105..42a39c2 100644 --- a/core/settings/security/security.cpp +++ b/core/settings/security/security.cpp | |||
@@ -146,180 +146,180 @@ void Security::accept() | |||
146 | void Security::done(int r) | 146 | void Security::done(int r) |
147 | { | 147 | { |
148 | QDialog::done(r); | 148 | QDialog::done(r); |
149 | close(); | 149 | close(); |
150 | } | 150 | } |
151 | 151 | ||
152 | void Security::selectNet(int auth_peer,int auth_peer_bits) | 152 | void Security::selectNet(int auth_peer,int auth_peer_bits) |
153 | { | 153 | { |
154 | QString sn; | 154 | QString sn; |
155 | if ( auth_peer_bits == 0 && auth_peer == 0 ) { | 155 | if ( auth_peer_bits == 0 && auth_peer == 0 ) { |
156 | sn = tr("Any"); | 156 | sn = tr("Any"); |
157 | } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { | 157 | } else if ( auth_peer_bits == 32 && auth_peer == 0 ) { |
158 | sn = tr("None"); | 158 | sn = tr("None"); |
159 | } else { | 159 | } else { |
160 | sn = | 160 | sn = |
161 | QString::number((auth_peer>>24)&0xff) + "." | 161 | QString::number((auth_peer>>24)&0xff) + "." |
162 | + QString::number((auth_peer>>16)&0xff) + "." | 162 | + QString::number((auth_peer>>16)&0xff) + "." |
163 | + QString::number((auth_peer>>8)&0xff) + "." | 163 | + QString::number((auth_peer>>8)&0xff) + "." |
164 | + QString::number((auth_peer>>0)&0xff) + "/" | 164 | + QString::number((auth_peer>>0)&0xff) + "/" |
165 | + QString::number(auth_peer_bits); | 165 | + QString::number(auth_peer_bits); |
166 | } | 166 | } |
167 | for (int i=0; i<syncnet->count(); i++) { | 167 | for (int i=0; i<syncnet->count(); i++) { |
168 | if ( syncnet->text(i).left(sn.length()) == sn ) { | 168 | if ( syncnet->text(i).left(sn.length()) == sn ) { |
169 | syncnet->setCurrentItem(i); | 169 | syncnet->setCurrentItem(i); |
170 | return; | 170 | return; |
171 | } | 171 | } |
172 | } | 172 | } |
173 | qDebug("No match for \"%s\"",sn.latin1()); | 173 | qDebug("No match for \"%s\"",sn.latin1()); |
174 | } | 174 | } |
175 | 175 | ||
176 | void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) | 176 | void Security::parseNet(const QString& sn,int& auth_peer,int& auth_peer_bits) |
177 | { | 177 | { |
178 | auth_peer=0; | 178 | auth_peer=0; |
179 | if ( sn == tr("Any") ) { | 179 | if ( sn == tr("Any") ) { |
180 | auth_peer = 0; | 180 | auth_peer = 0; |
181 | auth_peer_bits = 0; | 181 | auth_peer_bits = 0; |
182 | } else if ( sn == tr("None") ) { | 182 | } else if ( sn == tr("None") ) { |
183 | auth_peer = 0; | 183 | auth_peer = 0; |
184 | auth_peer_bits = 32; | 184 | auth_peer_bits = 32; |
185 | } else { | 185 | } else { |
186 | int x=0; | 186 | int x=0; |
187 | for (int i=0; i<4; i++) { | 187 | for (int i=0; i<4; i++) { |
188 | int nx = sn.find(QChar(i==3 ? '/' : '.'),x); | 188 | int nx = sn.find(QChar(i==3 ? '/' : '.'),x); |
189 | auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt(); | 189 | auth_peer = (auth_peer<<8)|sn.mid(x,nx-x).toInt(); |
190 | x = nx+1; | 190 | x = nx+1; |
191 | } | 191 | } |
192 | uint n = (uint)sn.find(' ',x)-x; | 192 | uint n = (uint)sn.find(' ',x)-x; |
193 | auth_peer_bits = sn.mid(x,n).toInt(); | 193 | auth_peer_bits = sn.mid(x,n).toInt(); |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | void Security::loadUsers ( void ) | 197 | void Security::loadUsers ( void ) |
198 | { | 198 | { |
199 | QFile passwd("/etc/passwd"); | 199 | QFile passwd("/etc/passwd"); |
200 | if ( passwd.open(IO_ReadOnly) ) { | 200 | if ( passwd.open(IO_ReadOnly) ) { |
201 | QTextStream t( &passwd ); | 201 | QTextStream t( &passwd ); |
202 | QString s; | 202 | QString s; |
203 | QStringList account; | 203 | QStringList account; |
204 | while ( !t.eof() ) { | 204 | while ( !t.eof() ) { |
205 | account = QStringList::split(':',t.readLine()); | 205 | account = QStringList::split(':',t.readLine()); |
206 | 206 | ||
207 | // Hide disabled accounts | 207 | // Hide disabled accounts |
208 | if (*account.at(1)!="*") { | 208 | if (*account.at(1)!="*") { |
209 | 209 | ||
210 | userlist->insertItem(*account.at(0)); | 210 | userlist->insertItem(*account.at(0)); |
211 | // Highlight this item if it is set to autologinToggle | 211 | // Highlight this item if it is set to autologinToggle |
212 | if ( *account.at(0) == autoLoginName) | 212 | if ( *account.at(0) == autoLoginName) |
213 | userlist->setCurrentItem(userlist->count()-1); | 213 | userlist->setCurrentItem(userlist->count()-1); |
214 | } | 214 | } |
215 | } | 215 | } |
216 | passwd.close(); | 216 | passwd.close(); |
217 | } | 217 | } |
218 | 218 | ||
219 | } | 219 | } |
220 | 220 | ||
221 | void Security::toggleAutoLogin(bool val) | 221 | void Security::toggleAutoLogin(bool val) |
222 | { | 222 | { |
223 | autoLogin=val; | 223 | autoLogin=val; |
224 | userlist->setEnabled(val); | 224 | userlist->setEnabled(val); |
225 | if (!autoLogin) | 225 | if (!autoLogin) |
226 | autoLoginName=userlist->currentText(); | 226 | autoLoginName=userlist->currentText(); |
227 | } | 227 | } |
228 | 228 | ||
229 | 229 | ||
230 | 230 | ||
231 | 231 | ||
232 | void Security::setSyncNet(const QString& sn) | 232 | void Security::setSyncNet(const QString& sn) |
233 | { | 233 | { |
234 | int auth_peer,auth_peer_bits; | 234 | int auth_peer,auth_peer_bits; |
235 | parseNet(sn,auth_peer,auth_peer_bits); | 235 | parseNet(sn,auth_peer,auth_peer_bits); |
236 | selectNet(auth_peer,auth_peer_bits); | 236 | selectNet(auth_peer,auth_peer_bits); |
237 | } | 237 | } |
238 | 238 | ||
239 | void Security::applySecurity() | 239 | void Security::applySecurity() |
240 | { | 240 | { |
241 | if ( valid ) { | 241 | if ( valid ) { |
242 | <<<<<<< security.cpp | 242 | |
243 | Config cfg("Security"); | 243 | Config cfg("Security"); |
244 | cfg.setGroup("Passcode"); | 244 | cfg.setGroup("Passcode"); |
245 | cfg.writeEntry("passcode",passcode); | 245 | cfg.writeEntry("passcode",passcode); |
246 | cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked()); | 246 | cfg.writeEntry("passcode_poweron",passcode_poweron->isChecked()); |
247 | cfg.setGroup("Sync"); | 247 | cfg.setGroup("Sync"); |
248 | int auth_peer=0; | 248 | int auth_peer=0; |
249 | int auth_peer_bits; | 249 | int auth_peer_bits; |
250 | QString sn = syncnet->currentText(); | 250 | QString sn = syncnet->currentText(); |
251 | parseNet(sn,auth_peer,auth_peer_bits); | 251 | parseNet(sn,auth_peer,auth_peer_bits); |
252 | cfg.writeEntry("auth_peer",auth_peer); | 252 | cfg.writeEntry("auth_peer",auth_peer); |
253 | cfg.writeEntry("auth_peer_bits",auth_peer_bits); | 253 | cfg.writeEntry("auth_peer_bits",auth_peer_bits); |
254 | /* | 254 | /* |
255 | cfg.setGroup("Remote"); | 255 | cfg.setGroup("Remote"); |
256 | if ( telnetAvailable() ) | 256 | if ( telnetAvailable() ) |
257 | cfg.writeEntry("allow_telnet",telnet->isChecked()); | 257 | cfg.writeEntry("allow_telnet",telnet->isChecked()); |
258 | if ( sshAvailable() ) | 258 | if ( sshAvailable() ) |
259 | cfg.writeEntry("allow_ssh",ssh->isChecked()); | 259 | cfg.writeEntry("allow_ssh",ssh->isChecked()); |
260 | // ### write ssh/telnet sys config files | 260 | // ### write ssh/telnet sys config files |
261 | */ | 261 | */ |
262 | 262 | ||
263 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; | 263 | QString configFile = QPEApplication::qpeDir() + "/etc/opie-login.conf"; |
264 | Config loginCfg(configFile,Config::File); | 264 | Config loginCfg(configFile,Config::File); |
265 | loginCfg.setGroup("General"); | 265 | loginCfg.setGroup("General"); |
266 | 266 | ||
267 | if (autoLogin) { | 267 | if (autoLogin) { |
268 | loginCfg.writeEntry("AutoLogin",autoLoginName); | 268 | loginCfg.writeEntry("AutoLogin",autoLoginName); |
269 | } else { | 269 | } else { |
270 | loginCfg.removeEntry("AutoLogin"); | 270 | loginCfg.removeEntry("AutoLogin"); |
271 | } | 271 | } |
272 | 272 | ||
273 | cfg.setGroup("SyncMode"); | 273 | cfg.setGroup("SyncMode"); |
274 | cfg.writeEntry("Mode", syncModeCombo->currentItem()+1 ); | 274 | cfg.writeEntry("Mode", syncModeCombo->currentItem()+1 ); |
275 | 275 | ||
276 | } | 276 | } |
277 | } | 277 | } |
278 | 278 | ||
279 | void Security::changeLoginName( int idx ) | 279 | void Security::changeLoginName( int idx ) |
280 | { | 280 | { |
281 | autoLoginName = userlist->text(idx);; | 281 | autoLoginName = userlist->text(idx);; |
282 | updateGUI(); | 282 | updateGUI(); |
283 | } | 283 | } |
284 | 284 | ||
285 | void Security::changePassCode() | 285 | void Security::changePassCode() |
286 | { | 286 | { |
287 | QString new1; | 287 | QString new1; |
288 | QString new2; | 288 | QString new2; |
289 | 289 | ||
290 | do { | 290 | do { |
291 | new1 = enterPassCode(tr("Enter new passcode")); | 291 | new1 = enterPassCode(tr("Enter new passcode")); |
292 | if ( new1.isNull() ) | 292 | if ( new1.isNull() ) |
293 | return; | 293 | return; |
294 | new2 = enterPassCode(tr("Re-enter new passcode")); | 294 | new2 = enterPassCode(tr("Re-enter new passcode")); |
295 | if ( new2.isNull() ) | 295 | if ( new2.isNull() ) |
296 | return; | 296 | return; |
297 | } while (new1 != new2); | 297 | } while (new1 != new2); |
298 | 298 | ||
299 | passcode = new1; | 299 | passcode = new1; |
300 | updateGUI(); | 300 | updateGUI(); |
301 | } | 301 | } |
302 | 302 | ||
303 | void Security::clearPassCode() | 303 | void Security::clearPassCode() |
304 | { | 304 | { |
305 | passcode = QString::null; | 305 | passcode = QString::null; |
306 | updateGUI(); | 306 | updateGUI(); |
307 | } | 307 | } |
308 | 308 | ||
309 | 309 | ||
310 | QString Security::enterPassCode(const QString& prompt) | 310 | QString Security::enterPassCode(const QString& prompt) |
311 | { | 311 | { |
312 | return Password::getPassword(prompt); | 312 | return Password::getPassword(prompt); |
313 | } | 313 | } |
314 | 314 | ||
315 | bool Security::telnetAvailable() const | 315 | bool Security::telnetAvailable() const |
316 | { | 316 | { |
317 | // ### not implemented | 317 | // ### not implemented |
318 | return FALSE; | 318 | return FALSE; |
319 | } | 319 | } |
320 | 320 | ||
321 | bool Security::sshAvailable() const | 321 | bool Security::sshAvailable() const |
322 | { | 322 | { |
323 | // ### not implemented | 323 | // ### not implemented |
324 | return FALSE; | 324 | return FALSE; |
325 | } | 325 | } |