author | zecke <zecke> | 2002-09-06 21:35:13 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-06 21:35:13 (UTC) |
commit | e95e14f056ce6be658a4fd0d4737168431e92d88 (patch) (side-by-side diff) | |
tree | 732f0a69b2063dc6c54444486223fd99879da72c | |
parent | 5536f65e60b3c662d2da3636e617faaad02522db (diff) | |
download | opie-e95e14f056ce6be658a4fd0d4737168431e92d88.zip opie-e95e14f056ce6be658a4fd0d4737168431e92d88.tar.gz opie-e95e14f056ce6be658a4fd0d4737168431e92d88.tar.bz2 |
Remove the libuuid dependency for Linux targets...
-rw-r--r-- | core/launcher/launcher.pro | 2 | ||||
-rw-r--r-- | core/launcher/opie-taskbar.control | 2 | ||||
-rw-r--r-- | core/launcher/transferserver.cpp | 59 |
3 files changed, 49 insertions, 14 deletions
diff --git a/core/launcher/launcher.pro b/core/launcher/launcher.pro index bae5c51..5b32bc3 100644 --- a/core/launcher/launcher.pro +++ b/core/launcher/launcher.pro @@ -78,41 +78,41 @@ SOURCES = background.cpp \ ../../rsync/msg.c \ ../../rsync/netint.c \ ../../rsync/patch.c \ ../../rsync/prototab.c \ ../../rsync/readsums.c \ ../../rsync/scoop.c \ ../../rsync/search.c \ ../../rsync/stats.c \ ../../rsync/stream.c \ ../../rsync/sumset.c \ ../../rsync/trace.c \ ../../rsync/tube.c \ ../../rsync/util.c \ ../../rsync/version.c \ ../../rsync/whole.c \ ../../rsync/qrsync.cpp INTERFACES = syncdialog.ui INCLUDEPATH += ../../include DEPENDPATH += ../../include . INCLUDEPATH += ../../core/apps/calibrate DEPENDPATH += ../../core/apps/calibrate INCLUDEPATH += ../../rsync DEPENDPATH += ../../rsync TARGET = qpe -LIBS += -lqpe -lcrypt -lopie -luuid +LIBS += -lqpe -lcrypt -lopie TRANSLATIONS = ../../i18n/de/qpe.ts \ ../../i18n/en/qpe.ts \ ../../i18n/es/qpe.ts \ ../../i18n/fr/qpe.ts \ ../../i18n/hu/qpe.ts \ ../../i18n/ja/qpe.ts \ ../../i18n/ko/qpe.ts \ ../../i18n/no/qpe.ts \ ../../i18n/pl/qpe.ts \ ../../i18n/pt/qpe.ts \ ../../i18n/pt_BR/qpe.ts \ ../../i18n/sl/qpe.ts \ ../../i18n/zh_CN/qpe.ts \ ../../i18n/it/qpe.ts \ ../../i18n/zh_TW/qpe.ts diff --git a/core/launcher/opie-taskbar.control b/core/launcher/opie-taskbar.control index ce73d8b..e9338fb 100644 --- a/core/launcher/opie-taskbar.control +++ b/core/launcher/opie-taskbar.control @@ -1,9 +1,9 @@ Files: bin/qpe apps/Settings/Calibrate.desktop pics/launcher Priority: required Section: opie/system Maintainer: Project Opie <opie@handhelds.org> Architecture: arm Version: $QPE_VERSION-$SUB_VERSION.1 -Depends: qt-embedded (>=$QTE_VERSION), libuuid1 +Depends: qt-embedded (>=$QTE_VERSION) Description: Launcher for Opie The "finder" or "explorer", or whatever you want to call it. diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index 9d18b7b..a20df2f 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp @@ -4,139 +4,174 @@ ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #define _XOPEN_SOURCE #include <pwd.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> #include <time.h> #include <shadow.h> +#ifndef _OS_LINUX_ + extern "C" { #include <uuid/uuid.h> #define UUID_H_INCLUDED } +#endif // not defined linux + #if defined(_OS_LINUX_) #include <shadow.h> #endif #include <qdir.h> #include <qfile.h> #include <qtextstream.h> #include <qdatastream.h> #include <qmessagebox.h> #include <qstringlist.h> #include <qfileinfo.h> #include <qregexp.h> //#include <qpe/qcopchannel_qws.h> #include <qpe/process.h> #include <qpe/global.h> #include <qpe/config.h> #include <qpe/contact.h> #include <qpe/quuid.h> #include <qpe/version.h> #ifdef QWS #include <qpe/qcopenvelope_qws.h> #endif #include "transferserver.h" #include "qprocess.h" const int block_size = 51200; TransferServer::TransferServer( Q_UINT16 port, QObject *parent , const char* name ) : QServerSocket( port, 1, parent, name ) { if ( !ok() ) qWarning( "Failed to bind to port %d", port ); } TransferServer::~TransferServer() { } void TransferServer::newConnection( int socket ) { (void) new ServerPI( socket, this ); } +/* + * small class in anonymous namespace + * to generate a QUUid for us + */ +namespace { + struct UidGen { + QString uuid(); + }; +#if defined(_OS_LINUX_) + /* + * linux got a /proc/sys/kernel/random/uuid file + * it'll generate the uuids for us + */ + QString UidGen::uuid() { + QFile file( "/proc/sys/kernel/random/uuid" ); + if (!file.open(IO_ReadOnly ) ) + return QString::null; + + QTextStream stream(&file); + + return "{" + stream.read().stripWhiteSpace() + "}"; + } +#else + QString UidGen::uuid() { + uuid_t uuid; + uuid_generate( uuid ); + return QUUid( uuid ).toString(); + } +#endif +} + QString SyncAuthentication::serverId() { Config cfg("Security"); cfg.setGroup("Sync"); QString r=cfg.readEntry("serverid"); if ( r.isEmpty() ) { - uuid_t uuid; - uuid_generate( uuid ); - cfg.writeEntry("serverid",(r = QUuid( uuid ).toString())); + UidGen gen; + r = gen.uuid(); + cfg.writeEntry("serverid", r ); } return r; } QString SyncAuthentication::ownerName() { QString vfilename = Global::applicationFileName("addressbook", "businesscard.vcf"); if (QFile::exists(vfilename)) { Contact c; c = Contact::readVCard( vfilename )[0]; return c.fullName(); } return ""; } QString SyncAuthentication::loginName() { struct passwd *pw; pw = getpwuid( geteuid() ); return QString::fromLocal8Bit( pw->pw_name ); } int SyncAuthentication::isAuthorized(QHostAddress peeraddress) { Config cfg("Security"); cfg.setGroup("Sync"); // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); uint auth_peer = cfg.readNumEntry("auth_peer",0xc0a80100); - + // QHostAddress allowed; // allowed.setAddress(allowedstr); // uint auth_peer = allowed.ip4Addr(); uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined ? 0xffffffff : (((1<<auth_peer_bits)-1)<<(32-auth_peer_bits)); return (peeraddress.ip4Addr() & mask) == auth_peer; } bool SyncAuthentication::checkUser( const QString& user ) { if ( user.isEmpty() ) return FALSE; QString euser = loginName(); return user == euser; } bool SyncAuthentication::checkPassword( const QString& password ) { #ifdef ALLOW_UNIX_USER_FTP // First, check system password... struct passwd *pw = 0; struct spwd *spw = 0; @@ -152,104 +187,104 @@ bool SyncAuthentication::checkPassword( const QString& password ) if ( cpwd == cpassword ) return TRUE; #endif static int lastdenial=0; static int denials=0; int now = time(0); // Detect old Qtopia Desktop (no password) if ( password.isEmpty() ) { if ( denials < 1 || now > lastdenial+600 ) { QMessageBox::warning( 0,tr("Sync Connection"), tr("<p>An unauthorized system is requesting access to this device." "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " "please upgrade."), tr("Deny") ); denials++; lastdenial=now; } return FALSE; } // Second, check sync password... QString pass = password.left(6); - /* old QtopiaDesktops are sending + /* old QtopiaDesktops are sending * rootme newer versions got a Qtopia * prefixed. Qtopia prefix will suceed * until the sync software syncs up * FIXME */ if ( pass == "rootme" || pass == "Qtopia") { - + QString cpassword = QString::fromLocal8Bit( crypt( password.mid(8).local8Bit(), "qp" ) ); Config cfg("Security"); cfg.setGroup("Sync"); QString pwds = cfg.readEntry("Passwords"); if ( QStringList::split(QChar(' '),pwds).contains(cpassword) ) return TRUE; // Unrecognized system. Be careful... if ( (denials > 2 && now < lastdenial+600) || QMessageBox::warning(0,tr("Sync Connection"), tr("<p>An unrecognized system is requesting access to this device." "<p>If you have just initiated a Sync for the first time, this is normal."), tr("Allow"),tr("Deny"))==1 ) { denials++; lastdenial=now; return FALSE; } else { denials=0; cfg.writeEntry("Passwords",pwds+" "+cpassword); return TRUE; } } return FALSE; } ServerPI::ServerPI( int socket, QObject *parent , const char* name ) : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ) { state = Connected; setSocket( socket ); peerport = peerPort(); peeraddress = peerAddress(); #ifndef INSECURE if ( !SyncAuthentication::isAuthorized(peeraddress) ) { state = Forbidden; startTimer( 0 ); } else -#endif +#endif { connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); - + passiv = FALSE; for( int i = 0; i < 4; i++ ) wait[i] = FALSE; send( "220 Qtopia " QPE_VERSION " FTP Server" ); state = Wait_USER; dtp = new ServerDTP( this ); connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) ); connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) ); connect( dtp, SIGNAL( error( int ) ), SLOT( dtpError( int ) ) ); directory = QDir::currentDirPath(); static int p = 1024; while ( !serversocket || !serversocket->ok() ) { delete serversocket; serversocket = new ServerSocket( ++p, this ); } connect( serversocket, SIGNAL( newIncomming( int ) ), SLOT( newConnection( int ) ) ); } @@ -606,49 +641,49 @@ void ServerPI::process( const QString& message ) QString filePath = absFilePath( args ); QFileInfo fi( filePath ); bool gzipfile = backupRestoreGzip( filePath ); if ( !fi.exists() && !gzipfile ) send( "500 Syntax error, command unrecognized" ); else { if ( !gzipfile ) send( "213 " + QString::number( fi.size() ) ); else { Process duproc( QString("du") ); duproc.addArgument("-s"); QString in, out; if ( !duproc.exec(in, out) ) { qDebug("du process failed; just sending back 1K"); send( "213 1024"); } else { QString size = out.left( out.find("\t") ); int guess = size.toInt()/5; if ( filePath.contains("doc") ) guess *= 1000; qDebug("sending back gzip guess of %d", guess); send( "213 " + QString::number(guess) ); } - } + } } } // name list (NLST) else if ( cmd == "NLST" ) { send( "502 Command not implemented" ); } // site parameters (SITE) else if ( cmd == "SITE" ) { send( "502 Command not implemented" ); } // system (SYST) else if ( cmd == "SYST" ) { send( "215 UNIX Type: L8" ); } // status (STAT) else if ( cmd == "STAT" ) { send( "502 Command not implemented" ); } // help (HELP ) else if ( cmd == "HELP" ) { @@ -1156,49 +1191,49 @@ void ServerDTP::bytesWritten( int bytes ) // send buffer mode if ( SendBuffer == mode ) { if ( bytes_written == buf.size() ) { // qDebug( "Debug: Sending complete: %d bytes", buf.size() ); emit completed(); mode = Idle; } } } void ServerDTP::readyRead() { // retrieve file mode if ( RetrieveFile == mode ) { QCString s; s.resize( bytesAvailable() ); readBlock( s.data(), bytesAvailable() ); file.writeBlock( s.data(), s.size() ); } else if ( RetrieveGzipFile == mode ) { if ( !gzipProc->isRunning() ) gzipProc->start(); - + QByteArray s; s.resize( bytesAvailable() ); readBlock( s.data(), bytesAvailable() ); gzipProc->writeToStdin( s ); qDebug("wrote %d bytes to ungzip ", s.size() ); } // retrieve buffer mode else if ( RetrieveBuffer == mode ) { QCString s; s.resize( bytesAvailable() ); readBlock( s.data(), bytesAvailable() ); buf.writeBlock( s.data(), s.size() ); } } void ServerDTP::writeTargzBlock() { QByteArray block = gzipProc->readStdout(); writeBlock( block.data(), block.size() ); qDebug("writeTargzBlock %d", block.size()); if ( !createTargzProc->isRunning() ) { qDebug("tar and gzip done"); emit completed(); mode = Idle; @@ -1239,95 +1274,95 @@ void ServerDTP::sendFile( const QString fn ) } void ServerDTP::sendGzipFile( const QString &fn, const QStringList &archiveTargets, const QHostAddress& host, Q_UINT16 port ) { sendGzipFile( fn, archiveTargets ); connectToHost( host.toString(), port ); } void ServerDTP::sendGzipFile( const QString &fn, const QStringList &archiveTargets ) { mode = SendGzipFile; file.setName( fn ); QStringList args = "tar"; args += "-cv"; args += archiveTargets; qDebug("sendGzipFile %s", args.join(" ").latin1() ); createTargzProc->setArguments( args ); connect( createTargzProc, SIGNAL( readyReadStdout() ), SLOT( gzipTarBlock() ) ); - gzipProc->setArguments( "gzip" ); + gzipProc->setArguments( "gzip" ); connect( gzipProc, SIGNAL( readyReadStdout() ), SLOT( writeTargzBlock() ) ); } void ServerDTP::gunzipDone() { qDebug("gunzipDone"); disconnect( gzipProc, SIGNAL( processExited() ), this, SLOT( gunzipDone() ) ); retrieveTargzProc->closeStdin(); disconnect( gzipProc, SIGNAL( readyReadStdout() ), this, SLOT( tarExtractBlock() ) ); } void ServerDTP::tarExtractBlock() { qDebug("ungzipTarBlock"); if ( !retrieveTargzProc->isRunning() ) { qDebug("auto start ungzip proc"); if ( !retrieveTargzProc->start() ) qWarning(" failed to start tar -x process"); } retrieveTargzProc->writeToStdin( gzipProc->readStdout() ); } void ServerDTP::retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port ) { file.setName( fn ); mode = RetrieveFile; connectToHost( host.toString(), port ); } void ServerDTP::retrieveFile( const QString fn ) { file.setName( fn ); mode = RetrieveFile; } void ServerDTP::retrieveGzipFile( const QString &fn ) { qDebug("retrieveGzipFile %s", fn.latin1()); file.setName( fn ); mode = RetrieveGzipFile; - gzipProc->setArguments( "gunzip" ); + gzipProc->setArguments( "gunzip" ); connect( gzipProc, SIGNAL( readyReadStdout() ), SLOT( tarExtractBlock() ) ); connect( gzipProc, SIGNAL( processExited() ), SLOT( gunzipDone() ) ); } void ServerDTP::retrieveGzipFile( const QString &fn, const QHostAddress& host, Q_UINT16 port ) { retrieveGzipFile( fn ); connectToHost( host.toString(), port ); } void ServerDTP::sendByteArray( const QByteArray& array, const QHostAddress& host, Q_UINT16 port ) { buf.setBuffer( array ); mode = SendBuffer; connectToHost( host.toString(), port ); } void ServerDTP::sendByteArray( const QByteArray& array ) { buf.setBuffer( array ); mode = SendBuffer; } |