-rw-r--r-- | core/launcher/qcopbridge.cpp | 2 | ||||
-rw-r--r-- | core/launcher/qcopbridge.h | 3 | ||||
-rw-r--r-- | core/launcher/transferserver.cpp | 36 |
3 files changed, 30 insertions, 11 deletions
diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp index b45f0cc..9bca360 100644 --- a/core/launcher/qcopbridge.cpp +++ b/core/launcher/qcopbridge.cpp | |||
@@ -136,65 +136,65 @@ void QCopBridge::closed( QCopBridgePI *pi ) | |||
136 | #if 0 | 136 | #if 0 |
137 | QPEApplication::setTempScreenSaverMode( QPEApplication::Enable ); | 137 | QPEApplication::setTempScreenSaverMode( QPEApplication::Enable ); |
138 | #endif | 138 | #endif |
139 | #ifndef QT_NO_COP | 139 | #ifndef QT_NO_COP |
140 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 140 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
141 | #endif | 141 | #endif |
142 | } | 142 | } |
143 | } | 143 | } |
144 | 144 | ||
145 | void QCopBridge::closeOpenConnections() | 145 | void QCopBridge::closeOpenConnections() |
146 | { | 146 | { |
147 | QCopBridgePI *pi; | 147 | QCopBridgePI *pi; |
148 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) | 148 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) |
149 | pi->close(); | 149 | pi->close(); |
150 | } | 150 | } |
151 | 151 | ||
152 | 152 | ||
153 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &data ) | 153 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &data ) |
154 | { | 154 | { |
155 | if ( command == "startSync()" ) { | 155 | if ( command == "startSync()" ) { |
156 | // we need to buffer it a bit | 156 | // we need to buffer it a bit |
157 | sendSync = TRUE; | 157 | sendSync = TRUE; |
158 | startTimer( 20000 ); | 158 | startTimer( 20000 ); |
159 | } | 159 | } |
160 | 160 | ||
161 | if ( m_mode & Qtopia1_7 ) { | 161 | if ( m_mode & Qtopia1_7 ) { |
162 | // send the command to all open connections | 162 | // send the command to all open connections |
163 | QCopBridgePI *pi; | 163 | QCopBridgePI *pi; |
164 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { | 164 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { |
165 | pi->sendDesktopMessage( command, data ); | 165 | pi->sendDesktopMessage( command, data ); |
166 | } | 166 | } |
167 | } | 167 | } |
168 | if ( m_mode & Sharp ) | 168 | if ( ( m_mode & Sharp ) || (m_mode & IntelliSync) ) |
169 | sendDesktopMessageOld( command, data ); | 169 | sendDesktopMessageOld( command, data ); |
170 | } | 170 | } |
171 | 171 | ||
172 | #ifndef OPIE_NO_OLD_SYNC_CODE | 172 | #ifndef OPIE_NO_OLD_SYNC_CODE |
173 | /* | 173 | /* |
174 | * Old compat mode | 174 | * Old compat mode |
175 | */ | 175 | */ |
176 | void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArray& args) { | 176 | void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArray& args) { |
177 | command.stripWhiteSpace(); | 177 | command.stripWhiteSpace(); |
178 | 178 | ||
179 | int paren = command.find( "(" ); | 179 | int paren = command.find( "(" ); |
180 | if ( paren <= 0 ) { | 180 | if ( paren <= 0 ) { |
181 | qDebug("DesktopMessage: bad qcop syntax"); | 181 | qDebug("DesktopMessage: bad qcop syntax"); |
182 | return; | 182 | return; |
183 | } | 183 | } |
184 | 184 | ||
185 | QString params = command.mid( paren + 1 ); | 185 | QString params = command.mid( paren + 1 ); |
186 | if ( params[params.length()-1] != ')' ) { | 186 | if ( params[params.length()-1] != ')' ) { |
187 | qDebug("DesktopMessage: bad qcop syntax"); | 187 | qDebug("DesktopMessage: bad qcop syntax"); |
188 | return; | 188 | return; |
189 | } | 189 | } |
190 | 190 | ||
191 | params.truncate( params.length()-1 ); | 191 | params.truncate( params.length()-1 ); |
192 | 192 | ||
193 | QStringList paramList = QStringList::split( ",", params ); | 193 | QStringList paramList = QStringList::split( ",", params ); |
194 | QString data; | 194 | QString data; |
195 | if ( paramList.count() ) { | 195 | if ( paramList.count() ) { |
196 | QDataStream stream( args, IO_ReadOnly ); | 196 | QDataStream stream( args, IO_ReadOnly ); |
197 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { | 197 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { |
198 | QString str; | 198 | QString str; |
199 | if ( *it == "QString" ) { | 199 | if ( *it == "QString" ) { |
200 | stream >> str; | 200 | stream >> str; |
diff --git a/core/launcher/qcopbridge.h b/core/launcher/qcopbridge.h index 9483d9d..d5988cd 100644 --- a/core/launcher/qcopbridge.h +++ b/core/launcher/qcopbridge.h | |||
@@ -8,65 +8,66 @@ | |||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef __qcopbridge_h__ | 20 | #ifndef __qcopbridge_h__ |
21 | #define __qcopbridge_h__ | 21 | #define __qcopbridge_h__ |
22 | 22 | ||
23 | #include <qtopia/global.h> | 23 | #include <qtopia/global.h> |
24 | #include <qserversocket.h> | 24 | #include <qserversocket.h> |
25 | #include <qsocket.h> | 25 | #include <qsocket.h> |
26 | #include <qdir.h> | 26 | #include <qdir.h> |
27 | #include <qfile.h> | 27 | #include <qfile.h> |
28 | #include <qbuffer.h> | 28 | #include <qbuffer.h> |
29 | 29 | ||
30 | class QFileInfo; | 30 | class QFileInfo; |
31 | class QCopBridgePI; | 31 | class QCopBridgePI; |
32 | class QCopChannel; | 32 | class QCopChannel; |
33 | class QTimer; | 33 | class QTimer; |
34 | 34 | ||
35 | class QCopBridge : public QServerSocket | 35 | class QCopBridge : public QServerSocket |
36 | { | 36 | { |
37 | Q_OBJECT | 37 | Q_OBJECT |
38 | 38 | ||
39 | public: | 39 | public: |
40 | enum Mode { Qtopia1_7= 0x01, Sharp = 0x02, Both = Qtopia1_7 | Sharp }; | 40 | /* can not or anymore :) */ |
41 | enum Mode { Qtopia1_7= 0x01, Sharp = 0x02, IntelliSync = 0x04 }; | ||
41 | QCopBridge( Q_UINT16 port, QObject *parent = 0, const char* name = 0 ); | 42 | QCopBridge( Q_UINT16 port, QObject *parent = 0, const char* name = 0 ); |
42 | virtual ~QCopBridge(); | 43 | virtual ~QCopBridge(); |
43 | 44 | ||
44 | void newConnection( int socket ); | 45 | void newConnection( int socket ); |
45 | void closeOpenConnections(); | 46 | void closeOpenConnections(); |
46 | void authorizeConnections(); | 47 | void authorizeConnections(); |
47 | 48 | ||
48 | public slots: | 49 | public slots: |
49 | void closed( QCopBridgePI *pi ); | 50 | void closed( QCopBridgePI *pi ); |
50 | void desktopMessage( const QCString &call, const QByteArray & ); | 51 | void desktopMessage( const QCString &call, const QByteArray & ); |
51 | 52 | ||
52 | signals: | 53 | signals: |
53 | void connectionClosed( const QHostAddress & ); | 54 | void connectionClosed( const QHostAddress & ); |
54 | 55 | ||
55 | protected: | 56 | protected: |
56 | void timerEvent( QTimerEvent * ); | 57 | void timerEvent( QTimerEvent * ); |
57 | void sendDesktopMessageOld( const QCString&, const QByteArray& ); | 58 | void sendDesktopMessageOld( const QCString&, const QByteArray& ); |
58 | 59 | ||
59 | private: | 60 | private: |
60 | QCopChannel *desktopChannel; | 61 | QCopChannel *desktopChannel; |
61 | QCopChannel *cardChannel; | 62 | QCopChannel *cardChannel; |
62 | QList<QCopBridgePI> openConnections; | 63 | QList<QCopBridgePI> openConnections; |
63 | bool sendSync; | 64 | bool sendSync; |
64 | Mode m_mode; | 65 | Mode m_mode; |
65 | }; | 66 | }; |
66 | 67 | ||
67 | 68 | ||
68 | class QCopBridgePI : public QSocket | 69 | class QCopBridgePI : public QSocket |
69 | { | 70 | { |
70 | Q_OBJECT | 71 | Q_OBJECT |
71 | 72 | ||
72 | enum State { Connected, Wait_USER, Wait_PASS, Ready, Forbidden }; | 73 | enum State { Connected, Wait_USER, Wait_PASS, Ready, Forbidden }; |
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index 9cb9d7a..8367a62 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp | |||
@@ -165,73 +165,91 @@ bool SyncAuthentication::checkUser( const QString& user ) | |||
165 | { | 165 | { |
166 | if ( user.isEmpty() ) return FALSE; | 166 | if ( user.isEmpty() ) return FALSE; |
167 | QString euser = loginName(); | 167 | QString euser = loginName(); |
168 | return user == euser; | 168 | return user == euser; |
169 | } | 169 | } |
170 | 170 | ||
171 | bool SyncAuthentication::checkPassword( const QString& password ) | 171 | bool SyncAuthentication::checkPassword( const QString& password ) |
172 | { | 172 | { |
173 | #ifdef ALLOW_UNIX_USER_FTP | 173 | #ifdef ALLOW_UNIX_USER_FTP |
174 | // First, check system password... | 174 | // First, check system password... |
175 | 175 | ||
176 | struct passwd *pw = 0; | 176 | struct passwd *pw = 0; |
177 | struct spwd *spw = 0; | 177 | struct spwd *spw = 0; |
178 | 178 | ||
179 | pw = getpwuid( geteuid() ); | 179 | pw = getpwuid( geteuid() ); |
180 | spw = getspnam( pw->pw_name ); | 180 | spw = getspnam( pw->pw_name ); |
181 | 181 | ||
182 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); | 182 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); |
183 | if ( cpwd == "x" && spw ) | 183 | if ( cpwd == "x" && spw ) |
184 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); | 184 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); |
185 | 185 | ||
186 | // Note: some systems use more than crypt for passwords. | 186 | // Note: some systems use more than crypt for passwords. |
187 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); | 187 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); |
188 | if ( cpwd == cpassword ) | 188 | if ( cpwd == cpassword ) |
189 | return TRUE; | 189 | return TRUE; |
190 | #endif | 190 | #endif |
191 | 191 | ||
192 | static int lastdenial=0; | 192 | static int lastdenial=0; |
193 | static int denials=0; | 193 | static int denials=0; |
194 | int now = time(0); | 194 | int now = time(0); |
195 | 195 | ||
196 | Config cfg("Security"); | 196 | Config cfg("Security"); |
197 | cfg.setGroup("Sync"); | 197 | cfg.setGroup("SyncMode"); |
198 | QString syncapp = cfg.readEntry("syncapp","Qtopia"); | 198 | int mode = cfg.readNumEntry("Mode", 0x02 ); |
199 | 199 | ||
200 | //No password needed if the user really wants it | 200 | //No pass word needed if the user really needs it |
201 | if (syncapp == "IntelliSync") { | 201 | if (mode & 0x04) { |
202 | return TRUE; | 202 | QMessageBox unauth( |
203 | } | 203 | tr("Sync Connection"), |
204 | 204 | tr("<qt><p>An unauthorized system is requesting access to this device." | |
205 | // Detect old Qtopia Desktop (no password) | 205 | "<p>You chose IntelliSync so you may I allow or deny this connection.</qt>" ), |
206 | QMessageBox::Warning, | ||
207 | QMessageBox::Ok, QMessageBox::Cancel|QMessageBox::Default, QMessageBox::NoButton, | ||
208 | 0, QString::null, TRUE, WStyle_StaysOnTop); | ||
209 | unauth.setButtonText(QMessageBox::Ok, tr("Allow" ) ); | ||
210 | unauth.setButtonText(QMessageBox::Cancel, tr("Deny")); | ||
211 | switch( unauth.exec() ) { | ||
212 | case QMessageBox::Ok: | ||
213 | return TRUE; | ||
214 | break; | ||
215 | case QMessageBox::Cancel: | ||
216 | default: | ||
217 | denials++; | ||
218 | lastdenial=now; | ||
219 | return FALSE; | ||
220 | } | ||
221 | } | ||
222 | |||
223 | // Detect old Qtopia Desktop (no password) and fail | ||
206 | if ( password.isEmpty() ) { | 224 | if ( password.isEmpty() ) { |
207 | if ( denials < 3 || now > lastdenial+600 ) { | 225 | if ( denials < 3 || now > lastdenial+600 ) { |
208 | QMessageBox unauth( | 226 | QMessageBox unauth( |
209 | tr("Sync Connection"), | 227 | tr("Sync Connection"), |
210 | tr("<p>An unauthorized system is requesting access to this device." | 228 | tr("<p>An unauthorized system is requesting access to this device." |
211 | "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " | 229 | "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " |
212 | "please upgrade or change the security setting to use IntelliSync." ), | 230 | "please upgrade or change the security setting to use IntelliSync." ), |
213 | QMessageBox::Warning, | 231 | QMessageBox::Warning, |
214 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, | 232 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, |
215 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 233 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
216 | unauth.setButtonText(QMessageBox::Cancel, tr("Deny")); | 234 | unauth.setButtonText(QMessageBox::Cancel, tr("Deny")); |
217 | unauth.exec(); | 235 | unauth.exec(); |
218 | 236 | ||
219 | denials++; | 237 | denials++; |
220 | lastdenial=now; | 238 | lastdenial=now; |
221 | } | 239 | } |
222 | return FALSE; | 240 | return FALSE; |
223 | 241 | ||
224 | } | 242 | } |
225 | 243 | ||
226 | // Second, check sync password... | 244 | // Second, check sync password... |
227 | 245 | ||
228 | static int lock=0; | 246 | static int lock=0; |
229 | if ( lock ) return FALSE; | 247 | if ( lock ) return FALSE; |
230 | 248 | ||
231 | ++lock; | 249 | ++lock; |
232 | 250 | ||
233 | /* | 251 | /* |
234 | * we need to support old Sync software and QtopiaDesktop | 252 | * we need to support old Sync software and QtopiaDesktop |
235 | */ | 253 | */ |
236 | if ( password.left(6) == "Qtopia" || password.left(6) == "rootme" ) { | 254 | if ( password.left(6) == "Qtopia" || password.left(6) == "rootme" ) { |
237 | Config cfg( "Security" ); | 255 | Config cfg( "Security" ); |