summaryrefslogtreecommitdiff
path: root/core
Side-by-side diff
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.pro2
-rw-r--r--core/launcher/opie-taskbar.control2
-rw-r--r--core/launcher/transferserver.cpp59
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
@@ -96,13 +96,13 @@ 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 \
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
@@ -22,17 +22,21 @@
#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>
@@ -73,21 +77,52 @@ 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()
{
@@ -112,13 +147,13 @@ QString SyncAuthentication::loginName()
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));
@@ -170,20 +205,20 @@ bool SyncAuthentication::checkPassword( const QString& password )
}
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;
@@ -221,17 +256,17 @@ ServerPI::ServerPI( int socket, QObject *parent , const char* name )
#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;
@@ -624,13 +659,13 @@ void ServerPI::process( const QString& message )
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" );
}
@@ -1174,13 +1209,13 @@ void ServerDTP::readyRead()
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() );
}
@@ -1257,13 +1292,13 @@ void ServerDTP::sendGzipFile( const QString &fn,
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()
{
@@ -1303,13 +1338,13 @@ void ServerDTP::retrieveFile( const QString fn )
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() ) );
}