summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/transferserver.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp
index 1d4ca40..2b2e435 100644
--- a/core/launcher/transferserver.cpp
+++ b/core/launcher/transferserver.cpp
@@ -211,49 +211,48 @@ bool SyncAuthentication::checkPassword( const QString& password )
211 QMessageBox::Warning, 211 QMessageBox::Warning,
212 QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, 212 QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton,
213 0, QString::null, TRUE, WStyle_StaysOnTop); 213 0, QString::null, TRUE, WStyle_StaysOnTop);
214 unauth.setButtonText(QMessageBox::Cancel, tr("Deny")); 214 unauth.setButtonText(QMessageBox::Cancel, tr("Deny"));
215 unauth.exec(); 215 unauth.exec();
216 216
217 denials++; 217 denials++;
218 lastdenial=now; 218 lastdenial=now;
219 } 219 }
220 return FALSE; 220 return FALSE;
221 221
222 } 222 }
223 223
224 // Second, check sync password... 224 // Second, check sync password...
225 225
226 static int lock=0; 226 static int lock=0;
227 if ( lock ) return FALSE; 227 if ( lock ) return FALSE;
228 228
229 ++lock; 229 ++lock;
230 230
231 /* 231 /*
232 * we need to support old Sync software and QtopiaDesktop 232 * we need to support old Sync software and QtopiaDesktop
233 */ 233 */
234 if ( password.left(6) == "Qtopia" || password.left(6) == "rootme" ) { 234 if ( password.left(6) == "Qtopia" || password.left(6) == "rootme" ) {
235 Config cfg( "Security" );
236 cfg.setGroup("Sync"); 235 cfg.setGroup("Sync");
237 QStringList pwds = cfg.readListEntry("Passwords",' '); 236 QStringList pwds = cfg.readListEntry("Passwords",' ');
238 for (QStringList::ConstIterator it=pwds.begin(); it!=pwds.end(); ++it) { 237 for (QStringList::ConstIterator it=pwds.begin(); it!=pwds.end(); ++it) {
239#ifndef Q_OS_WIN32 238#ifndef Q_OS_WIN32
240 QString cpassword = QString::fromLocal8Bit( 239 QString cpassword = QString::fromLocal8Bit(
241 crypt( password.mid(8).local8Bit(), (*it).left(2).latin1() ) ); 240 crypt( password.mid(8).local8Bit(), (*it).left(2).latin1() ) );
242#else 241#else
243 // ### revise 242 // ### revise
244 QString cpassword(""); 243 QString cpassword("");
245#endif 244#endif
246 if ( *it == cpassword ) { 245 if ( *it == cpassword ) {
247 lock--; 246 lock--;
248 return TRUE; 247 return TRUE;
249 } 248 }
250 } 249 }
251 250
252 // Unrecognized system. Be careful... 251 // Unrecognized system. Be careful...
253 QMessageBox unrecbox( 252 QMessageBox unrecbox(
254 tr("Sync Connection"), 253 tr("Sync Connection"),
255 tr( "<p>An unrecognized system is requesting access to this device." 254 tr( "<p>An unrecognized system is requesting access to this device."
256 "<p>If you have just initiated a Sync for the first time, this is normal."), 255 "<p>If you have just initiated a Sync for the first time, this is normal."),
257 QMessageBox::Warning, 256 QMessageBox::Warning,
258 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, 257 QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton,
259 0, QString::null, TRUE, WStyle_StaysOnTop); 258 0, QString::null, TRUE, WStyle_StaysOnTop);
@@ -360,49 +359,51 @@ bool ServerPI::verifyAuthorised()
360 359
361void ServerPI::connectionClosed() 360void ServerPI::connectionClosed()
362{ 361{
363 // odebug << "Debug: Connection closed" << oendl; 362 // odebug << "Debug: Connection closed" << oendl;
364 emit connectionClosed(this); 363 emit connectionClosed(this);
365} 364}
366 365
367void ServerPI::send( const QString& msg ) 366void ServerPI::send( const QString& msg )
368{ 367{
369 QTextStream os( this ); 368 QTextStream os( this );
370 os << msg << endl; 369 os << msg << endl;
371 //odebug << "Reply: " << msg << "" << oendl; 370 //odebug << "Reply: " << msg << "" << oendl;
372} 371}
373 372
374void ServerPI::read() 373void ServerPI::read()
375{ 374{
376 while ( canReadLine() ) 375 while ( canReadLine() )
377 process( readLine().stripWhiteSpace() ); 376 process( readLine().stripWhiteSpace() );
378} 377}
379 378
380bool ServerPI::checkReadFile( const QString& file ) 379bool ServerPI::checkReadFile( const QString& file )
381{ 380{
382 QString filename; 381 QString filename;
383 382
384 if ( file[0] != "/" ) 383 if ( file.length() == 1 && file[0] == "/" )
384 filename = file;
385 else if ( file[0] != "/" )
385 filename = directory.path() + "/" + file; 386 filename = directory.path() + "/" + file;
386 else 387 else
387 filename = file; 388 filename = file;
388 389
389 QFileInfo fi( filename ); 390 QFileInfo fi( filename );
390 return ( fi.exists() && fi.isReadable() ); 391 return ( fi.exists() && fi.isReadable() );
391} 392}
392 393
393bool ServerPI::checkWriteFile( const QString& file ) 394bool ServerPI::checkWriteFile( const QString& file )
394{ 395{
395 QString filename; 396 QString filename;
396 397
397 if ( file[0] != "/" ) 398 if ( file[0] != "/" )
398 filename = directory.path() + "/" + file; 399 filename = directory.path() + "/" + file;
399 else 400 else
400 filename = file; 401 filename = file;
401 402
402 QFileInfo fi( filename ); 403 QFileInfo fi( filename );
403 404
404 if ( fi.exists() ) 405 if ( fi.exists() )
405 if ( !QFile( filename ).remove() ) 406 if ( !QFile( filename ).remove() )
406 return FALSE; 407 return FALSE;
407 return TRUE; 408 return TRUE;
408} 409}
@@ -676,48 +677,51 @@ void ServerPI::process( const QString& message )
676 } 677 }
677 678
678 // make directory (MKD) 679 // make directory (MKD)
679 else if ( cmd == "MKD" ) { 680 else if ( cmd == "MKD" ) {
680 if ( args.isEmpty() ) { 681 if ( args.isEmpty() ) {
681 odebug << " Error: no arg" << oendl; 682 odebug << " Error: no arg" << oendl;
682 send( "500 Syntax error, command unrecognized" ); // No tr 683 send( "500 Syntax error, command unrecognized" ); // No tr
683 } 684 }
684 else { 685 else {
685 QDir dir; 686 QDir dir;
686 if ( dir.mkdir( absFilePath( args ), TRUE ) ) 687 if ( dir.mkdir( absFilePath( args ), TRUE ) )
687 send( "250 Requested file action okay, completed." ); // No tr 688 send( "250 Requested file action okay, completed." ); // No tr
688 else 689 else
689 send( "550 Requested action not taken" ); // No tr 690 send( "550 Requested action not taken" ); // No tr
690 } 691 }
691 } 692 }
692 693
693 // print working directory (PWD) 694 // print working directory (PWD)
694 else if ( cmd == "PWD" ) { 695 else if ( cmd == "PWD" ) {
695 send( "257 \"" + directory.path() +"\"" ); 696 send( "257 \"" + directory.path() +"\"" );
696 } 697 }
697 698
698 // list (LIST) 699 // list (LIST)
699 else if ( cmd == "LIST" ) { 700 else if ( cmd == "LIST" ) {
701 if ( args == "-la" )
702 args = QString::null;
703
700 if ( sendList( absFilePath( args ) ) ) 704 if ( sendList( absFilePath( args ) ) )
701 send( "150 File status okay" ); // No tr 705 send( "150 File status okay" ); // No tr
702 else 706 else
703 send( "500 Syntax error, command unrecognized" ); // No tr 707 send( "500 Syntax error, command unrecognized" ); // No tr
704 } 708 }
705 709
706 // size (SIZE) 710 // size (SIZE)
707 else if ( cmd == "SIZE" ) { 711 else if ( cmd == "SIZE" ) {
708 QString filePath = absFilePath( args ); 712 QString filePath = absFilePath( args );
709 QFileInfo fi( filePath ); 713 QFileInfo fi( filePath );
710 bool gzipfile = backupRestoreGzip( filePath ); 714 bool gzipfile = backupRestoreGzip( filePath );
711 if ( !fi.exists() && !gzipfile ) 715 if ( !fi.exists() && !gzipfile )
712 send( "500 Syntax error, command unrecognized" ); // No tr 716 send( "500 Syntax error, command unrecognized" ); // No tr
713 else { 717 else {
714 if ( !gzipfile ) 718 if ( !gzipfile )
715 send( "213 " + QString::number( fi.size() ) ); 719 send( "213 " + QString::number( fi.size() ) );
716 else { 720 else {
717 Process duproc( QString("du") ); 721 Process duproc( QString("du") );
718 duproc.addArgument("-s"); 722 duproc.addArgument("-s");
719 QString in, out; 723 QString in, out;
720 if ( !duproc.exec(in, out) ) { 724 if ( !duproc.exec(in, out) ) {
721 odebug << "du process failed; just sending back 1K" << oendl; 725 odebug << "du process failed; just sending back 1K" << oendl;
722 send( "213 1024"); 726 send( "213 1024");
723 } 727 }