Diffstat (limited to 'core/launcher/transferserver.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/launcher/transferserver.cpp | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index 439e110..eea9f3a 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp | |||
@@ -172,75 +172,85 @@ bool SyncAuthentication::checkUser( const QString& user ) | |||
172 | bool SyncAuthentication::checkPassword( const QString& password ) | 172 | bool SyncAuthentication::checkPassword( const QString& password ) |
173 | { | 173 | { |
174 | #ifdef ALLOW_UNIX_USER_FTP | 174 | #ifdef ALLOW_UNIX_USER_FTP |
175 | // First, check system password... | 175 | // First, check system password... |
176 | 176 | ||
177 | struct passwd *pw = 0; | 177 | struct passwd *pw = 0; |
178 | struct spwd *spw = 0; | 178 | struct spwd *spw = 0; |
179 | 179 | ||
180 | pw = getpwuid( geteuid() ); | 180 | pw = getpwuid( geteuid() ); |
181 | spw = getspnam( pw->pw_name ); | 181 | spw = getspnam( pw->pw_name ); |
182 | 182 | ||
183 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); | 183 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); |
184 | if ( cpwd == "x" && spw ) | 184 | if ( cpwd == "x" && spw ) |
185 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); | 185 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); |
186 | 186 | ||
187 | // Note: some systems use more than crypt for passwords. | 187 | // Note: some systems use more than crypt for passwords. |
188 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); | 188 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); |
189 | if ( cpwd == cpassword ) | 189 | if ( cpwd == cpassword ) |
190 | return TRUE; | 190 | return TRUE; |
191 | #endif | 191 | #endif |
192 | 192 | ||
193 | static int lastdenial=0; | 193 | static int lastdenial=0; |
194 | static int denials=0; | 194 | static int denials=0; |
195 | int now = time(0); | 195 | int now = time(0); |
196 | 196 | ||
197 | Config cfg("Security"); | ||
198 | cfg.setGroup("Sync"); | ||
199 | QString syncapp = cfg.readEntry("syncapp","Qtopia"); | ||
200 | |||
201 | //No password needed if the user really wants it | ||
202 | if (syncapp == "IntelliSync") { | ||
203 | return TRUE; | ||
204 | } | ||
205 | |||
197 | // Detect old Qtopia Desktop (no password) | 206 | // Detect old Qtopia Desktop (no password) |
198 | if ( password.isEmpty() ) { | 207 | if ( password.isEmpty() ) { |
199 | if ( denials < 1 || now > lastdenial+600 ) { | 208 | if ( denials < 3 || now > lastdenial+600 ) { |
200 | QMessageBox unauth( | 209 | QMessageBox unauth( |
201 | tr("Sync Connection"), | 210 | tr("Sync Connection"), |
202 | tr("<p>An unauthorized system is requesting access to this device." | 211 | tr("<p>An unauthorized system is requesting access to this device." |
203 | "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " | 212 | "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " |
204 | "please upgrade."), | 213 | "please upgrade or change the security setting to use IntelliSync." ), |
205 | QMessageBox::Warning, | 214 | QMessageBox::Warning, |
206 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, | 215 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, |
207 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 216 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
208 | unauth.setButtonText(QMessageBox::Cancel, tr("Deny")); | 217 | unauth.setButtonText(QMessageBox::Cancel, tr("Deny")); |
209 | unauth.exec(); | 218 | unauth.exec(); |
210 | 219 | ||
211 | denials++; | 220 | denials++; |
212 | lastdenial=now; | 221 | lastdenial=now; |
213 | } | 222 | } |
214 | return FALSE; | 223 | return FALSE; |
215 | } | 224 | |
225 | } | ||
216 | 226 | ||
217 | // Second, check sync password... | 227 | // Second, check sync password... |
218 | 228 | ||
219 | static int lock=0; | 229 | static int lock=0; |
220 | if ( lock ) return FALSE; | 230 | if ( lock ) return FALSE; |
221 | 231 | ||
222 | ++lock; | 232 | ++lock; |
223 | 233 | ||
224 | /* | 234 | /* |
225 | * we need to support old Sync software and QtopiaDesktop | 235 | * we need to support old Sync software and QtopiaDesktop |
226 | */ | 236 | */ |
227 | if ( password.left(6) == "Qtopia" || password.left(6) == "rootme" ) { | 237 | if ( password.left(6) == "Qtopia" || password.left(6) == "rootme" ) { |
228 | Config cfg( "Security" ); | 238 | Config cfg( "Security" ); |
229 | cfg.setGroup("Sync"); | 239 | cfg.setGroup("Sync"); |
230 | QStringList pwds = cfg.readListEntry("Passwords",' '); | 240 | QStringList pwds = cfg.readListEntry("Passwords",' '); |
231 | for (QStringList::ConstIterator it=pwds.begin(); it!=pwds.end(); ++it) { | 241 | for (QStringList::ConstIterator it=pwds.begin(); it!=pwds.end(); ++it) { |
232 | #ifndef Q_OS_WIN32 | 242 | #ifndef Q_OS_WIN32 |
233 | QString cpassword = QString::fromLocal8Bit( | 243 | QString cpassword = QString::fromLocal8Bit( |
234 | crypt( password.mid(8).local8Bit(), (*it).left(2).latin1() ) ); | 244 | crypt( password.mid(8).local8Bit(), (*it).left(2).latin1() ) ); |
235 | #else | 245 | #else |
236 | // ### revise | 246 | // ### revise |
237 | QString cpassword(""); | 247 | QString cpassword(""); |
238 | #endif | 248 | #endif |
239 | if ( *it == cpassword ) { | 249 | if ( *it == cpassword ) { |
240 | lock--; | 250 | lock--; |
241 | return TRUE; | 251 | return TRUE; |
242 | } | 252 | } |
243 | } | 253 | } |
244 | 254 | ||
245 | // Unrecognized system. Be careful... | 255 | // Unrecognized system. Be careful... |
246 | QMessageBox unrecbox( | 256 | QMessageBox unrecbox( |