summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/transferserver.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp
index a20df2f..f9204ab 100644
--- a/core/launcher/transferserver.cpp
+++ b/core/launcher/transferserver.cpp
@@ -43,116 +43,116 @@ extern "C" {
43#include <qtextstream.h> 43#include <qtextstream.h>
44#include <qdatastream.h> 44#include <qdatastream.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46#include <qstringlist.h> 46#include <qstringlist.h>
47#include <qfileinfo.h> 47#include <qfileinfo.h>
48#include <qregexp.h> 48#include <qregexp.h>
49//#include <qpe/qcopchannel_qws.h> 49//#include <qpe/qcopchannel_qws.h>
50#include <qpe/process.h> 50#include <qpe/process.h>
51#include <qpe/global.h> 51#include <qpe/global.h>
52#include <qpe/config.h> 52#include <qpe/config.h>
53#include <qpe/contact.h> 53#include <qpe/contact.h>
54#include <qpe/quuid.h> 54#include <qpe/quuid.h>
55#include <qpe/version.h> 55#include <qpe/version.h>
56#ifdef QWS 56#ifdef QWS
57#include <qpe/qcopenvelope_qws.h> 57#include <qpe/qcopenvelope_qws.h>
58#endif 58#endif
59 59
60#include "transferserver.h" 60#include "transferserver.h"
61#include "qprocess.h" 61#include "qprocess.h"
62 62
63const int block_size = 51200; 63const int block_size = 51200;
64 64
65TransferServer::TransferServer( Q_UINT16 port, QObject *parent , 65TransferServer::TransferServer( Q_UINT16 port, QObject *parent ,
66 const char* name ) 66 const char* name )
67 : QServerSocket( port, 1, parent, name ) 67 : QServerSocket( port, 1, parent, name )
68{ 68{
69 if ( !ok() ) 69 if ( !ok() )
70 qWarning( "Failed to bind to port %d", port ); 70 qWarning( "Failed to bind to port %d", port );
71} 71}
72 72
73TransferServer::~TransferServer() 73TransferServer::~TransferServer()
74{ 74{
75 75
76} 76}
77 77
78void TransferServer::newConnection( int socket ) 78void TransferServer::newConnection( int socket )
79{ 79{
80 (void) new ServerPI( socket, this ); 80 (void) new ServerPI( socket, this );
81} 81}
82 82
83/* 83/*
84 * small class in anonymous namespace 84 * small class in anonymous namespace
85 * to generate a QUUid for us 85 * to generate a QUUid for us
86 */ 86 */
87namespace { 87namespace {
88 struct UidGen { 88 struct UidGen {
89 QString uuid(); 89 QString uuid();
90 }; 90 };
91#if defined(_OS_LINUX_) 91#if !defined(_OS_LINUX_)
92 QString UidGen::uuid() {
93 uuid_t uuid;
94 uuid_generate( uuid );
95 return QUUid( uuid ).toString();
96 }
97#else
92 /* 98 /*
93 * linux got a /proc/sys/kernel/random/uuid file 99 * linux got a /proc/sys/kernel/random/uuid file
94 * it'll generate the uuids for us 100 * it'll generate the uuids for us
95 */ 101 */
96 QString UidGen::uuid() { 102 QString UidGen::uuid() {
97 QFile file( "/proc/sys/kernel/random/uuid" ); 103 QFile file( "/proc/sys/kernel/random/uuid" );
98 if (!file.open(IO_ReadOnly ) ) 104 if (!file.open(IO_ReadOnly ) )
99 return QString::null; 105 return QString::null;
100 106
101 QTextStream stream(&file); 107 QTextStream stream(&file);
102 108
103 return "{" + stream.read().stripWhiteSpace() + "}"; 109 return "{" + stream.read().stripWhiteSpace() + "}";
104 } 110 }
105#else
106 QString UidGen::uuid() {
107 uuid_t uuid;
108 uuid_generate( uuid );
109 return QUUid( uuid ).toString();
110 }
111#endif 111#endif
112} 112}
113 113
114QString SyncAuthentication::serverId() 114QString SyncAuthentication::serverId()
115{ 115{
116 Config cfg("Security"); 116 Config cfg("Security");
117 cfg.setGroup("Sync"); 117 cfg.setGroup("Sync");
118 QString r=cfg.readEntry("serverid"); 118 QString r=cfg.readEntry("serverid");
119 if ( r.isEmpty() ) { 119 if ( r.isEmpty() ) {
120 UidGen gen; 120 UidGen gen;
121 r = gen.uuid(); 121 r = gen.uuid();
122 cfg.writeEntry("serverid", r ); 122 cfg.writeEntry("serverid", r );
123 } 123 }
124 return r; 124 return r;
125} 125}
126 126
127QString SyncAuthentication::ownerName() 127QString SyncAuthentication::ownerName()
128{ 128{
129 QString vfilename = Global::applicationFileName("addressbook", 129 QString vfilename = Global::applicationFileName("addressbook",
130 "businesscard.vcf"); 130 "businesscard.vcf");
131 if (QFile::exists(vfilename)) { 131 if (QFile::exists(vfilename)) {
132 Contact c; 132 Contact c;
133 c = Contact::readVCard( vfilename )[0]; 133 c = Contact::readVCard( vfilename )[0];
134 return c.fullName(); 134 return c.fullName();
135 } 135 }
136 136
137 return ""; 137 return "";
138} 138}
139 139
140QString SyncAuthentication::loginName() 140QString SyncAuthentication::loginName()
141{ 141{
142 struct passwd *pw; 142 struct passwd *pw;
143 pw = getpwuid( geteuid() ); 143 pw = getpwuid( geteuid() );
144 return QString::fromLocal8Bit( pw->pw_name ); 144 return QString::fromLocal8Bit( pw->pw_name );
145} 145}
146 146
147int SyncAuthentication::isAuthorized(QHostAddress peeraddress) 147int SyncAuthentication::isAuthorized(QHostAddress peeraddress)
148{ 148{
149 Config cfg("Security"); 149 Config cfg("Security");
150 cfg.setGroup("Sync"); 150 cfg.setGroup("Sync");
151// QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); 151// QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0");
152 uint auth_peer = cfg.readNumEntry("auth_peer",0xc0a80100); 152 uint auth_peer = cfg.readNumEntry("auth_peer",0xc0a80100);
153 153
154// QHostAddress allowed; 154// QHostAddress allowed;
155// allowed.setAddress(allowedstr); 155// allowed.setAddress(allowedstr);
156// uint auth_peer = allowed.ip4Addr(); 156// uint auth_peer = allowed.ip4Addr();
157 uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); 157 uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24);
158 uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined 158 uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined