author | zecke <zecke> | 2005-03-02 19:42:04 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-03-02 19:42:04 (UTC) |
commit | a349b5d092c392aba28c6fbd99221559c33bc5e1 (patch) (unidiff) | |
tree | 56a809f42d20c6f2fe7a60f243dd1aebca359b39 | |
parent | 9f3e0913c7b01c1e14f907e756999b9d9bf9ceef (diff) | |
download | opie-a349b5d092c392aba28c6fbd99221559c33bc5e1.zip opie-a349b5d092c392aba28c6fbd99221559c33bc5e1.tar.gz opie-a349b5d092c392aba28c6fbd99221559c33bc5e1.tar.bz2 |
Close the Filedescriptor for the QCopBridge and Transferserver on exit
-rw-r--r-- | core/launcher/qcopbridge.cpp | 4 | ||||
-rw-r--r-- | core/launcher/transferserver.cpp | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp index e339dc7..64eb096 100644 --- a/core/launcher/qcopbridge.cpp +++ b/core/launcher/qcopbridge.cpp | |||
@@ -1,161 +1,163 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
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 | 20 | ||
21 | #include "qcopbridge.h" | 21 | #include "qcopbridge.h" |
22 | #include "transferserver.h" | 22 | #include "transferserver.h" |
23 | 23 | ||
24 | /* OPIE */ | 24 | /* OPIE */ |
25 | #include <opie2/odebug.h> | 25 | #include <opie2/odebug.h> |
26 | #include <opie2/oglobal.h> | 26 | #include <opie2/oglobal.h> |
27 | #ifdef Q_WS_QWS | 27 | #ifdef Q_WS_QWS |
28 | #include <qtopia/qcopenvelope_qws.h> | 28 | #include <qtopia/qcopenvelope_qws.h> |
29 | #endif | 29 | #endif |
30 | #include <qtopia/qpeapplication.h> | 30 | #include <qtopia/qpeapplication.h> |
31 | #include <qtopia/version.h> | 31 | #include <qtopia/version.h> |
32 | using namespace Opie::Core; | 32 | using namespace Opie::Core; |
33 | 33 | ||
34 | /* QT */ | 34 | /* QT */ |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qtimer.h> | 36 | #include <qtimer.h> |
37 | #ifdef Q_WS_QWS | 37 | #ifdef Q_WS_QWS |
38 | #include <qcopchannel_qws.h> | 38 | #include <qcopchannel_qws.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | /* STD */ | 41 | /* STD */ |
42 | #ifndef _XOPEN_SOURCE | 42 | #ifndef _XOPEN_SOURCE |
43 | #define _XOPEN_SOURCE | 43 | #define _XOPEN_SOURCE |
44 | #endif | 44 | #endif |
45 | #ifndef Q_OS_WIN32 | 45 | #ifndef Q_OS_WIN32 |
46 | #include <pwd.h> | 46 | #include <pwd.h> |
47 | #include <unistd.h> | 47 | #include <unistd.h> |
48 | #include <fcntl.h> | ||
48 | #include <sys/types.h> | 49 | #include <sys/types.h> |
49 | #endif | 50 | #endif |
50 | 51 | ||
51 | #if defined(_OS_LINUX_) | 52 | #if defined(_OS_LINUX_) |
52 | #include <shadow.h> | 53 | #include <shadow.h> |
53 | #endif | 54 | #endif |
54 | 55 | ||
55 | const int block_size = 51200; | 56 | const int block_size = 51200; |
56 | 57 | ||
57 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent, | 58 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent, |
58 | const char* name ) | 59 | const char* name ) |
59 | : QServerSocket( port, 1, parent, name ), | 60 | : QServerSocket( port, 1, parent, name ), |
60 | desktopChannel( 0 ), | 61 | desktopChannel( 0 ), |
61 | cardChannel( 0 ) | 62 | cardChannel( 0 ) |
62 | { | 63 | { |
63 | if ( !ok() ) | 64 | if ( !ok() ) |
64 | owarn << "Failed to bind to port " << port << "" << oendl; | 65 | owarn << "Failed to bind to port " << port << "" << oendl; |
65 | else { | 66 | else { |
67 | ::fcntl( socket(), F_SETFD, FD_CLOEXEC ); | ||
66 | #ifndef QT_NO_COP | 68 | #ifndef QT_NO_COP |
67 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); | 69 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); |
68 | connect( desktopChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 70 | connect( desktopChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
69 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); | 71 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); |
70 | cardChannel = new QCopChannel( "QPE/Card", this ); | 72 | cardChannel = new QCopChannel( "QPE/Card", this ); |
71 | connect( cardChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 73 | connect( cardChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
72 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); | 74 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); |
73 | #endif | 75 | #endif |
74 | } | 76 | } |
75 | sendSync = FALSE; | 77 | sendSync = FALSE; |
76 | openConnections.setAutoDelete( TRUE ); | 78 | openConnections.setAutoDelete( TRUE ); |
77 | authorizeConnections(); | 79 | authorizeConnections(); |
78 | } | 80 | } |
79 | 81 | ||
80 | QCopBridge::~QCopBridge() | 82 | QCopBridge::~QCopBridge() |
81 | { | 83 | { |
82 | #ifndef QT_NO_COP | 84 | #ifndef QT_NO_COP |
83 | delete desktopChannel; | 85 | delete desktopChannel; |
84 | #endif | 86 | #endif |
85 | } | 87 | } |
86 | 88 | ||
87 | void QCopBridge::authorizeConnections() | 89 | void QCopBridge::authorizeConnections() |
88 | { | 90 | { |
89 | Config cfg("Security"); | 91 | Config cfg("Security"); |
90 | cfg.setGroup("SyncMode"); | 92 | cfg.setGroup("SyncMode"); |
91 | m_mode = Mode(cfg.readNumEntry("Mode", Sharp )); | 93 | m_mode = Mode(cfg.readNumEntry("Mode", Sharp )); |
92 | QListIterator<QCopBridgePI> it(openConnections); | 94 | QListIterator<QCopBridgePI> it(openConnections); |
93 | while ( it.current() ) { | 95 | while ( it.current() ) { |
94 | if ( !it.current()->verifyAuthorised() ) { | 96 | if ( !it.current()->verifyAuthorised() ) { |
95 | disconnect ( it.current(), SIGNAL( connectionClosed(QCopBridgePI*) ), this, SLOT( closed(QCopBridgePI*) ) ); | 97 | disconnect ( it.current(), SIGNAL( connectionClosed(QCopBridgePI*) ), this, SLOT( closed(QCopBridgePI*) ) ); |
96 | openConnections.removeRef( it.current() ); | 98 | openConnections.removeRef( it.current() ); |
97 | } else | 99 | } else |
98 | ++it; | 100 | ++it; |
99 | } | 101 | } |
100 | } | 102 | } |
101 | 103 | ||
102 | void QCopBridge::newConnection( int socket ) | 104 | void QCopBridge::newConnection( int socket ) |
103 | { | 105 | { |
104 | QCopBridgePI *pi = new QCopBridgePI( socket, this ); | 106 | QCopBridgePI *pi = new QCopBridgePI( socket, this ); |
105 | openConnections.append( pi ); | 107 | openConnections.append( pi ); |
106 | connect ( pi, SIGNAL( connectionClosed(QCopBridgePI*) ), this, SLOT( closed(QCopBridgePI*) ) ); | 108 | connect ( pi, SIGNAL( connectionClosed(QCopBridgePI*) ), this, SLOT( closed(QCopBridgePI*) ) ); |
107 | 109 | ||
108 | /* ### libqtopia merge FIXME */ | 110 | /* ### libqtopia merge FIXME */ |
109 | #if 0 | 111 | #if 0 |
110 | QPEApplication::setTempScreenSaverMode( QPEApplication::DisableSuspend ); | 112 | QPEApplication::setTempScreenSaverMode( QPEApplication::DisableSuspend ); |
111 | #endif | 113 | #endif |
112 | #ifndef QT_NO_COP | 114 | #ifndef QT_NO_COP |
113 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | 115 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; |
114 | #endif | 116 | #endif |
115 | 117 | ||
116 | if ( sendSync ) { | 118 | if ( sendSync ) { |
117 | pi ->startSync(); | 119 | pi ->startSync(); |
118 | sendSync = FALSE; | 120 | sendSync = FALSE; |
119 | } | 121 | } |
120 | } | 122 | } |
121 | 123 | ||
122 | void QCopBridge::closed( QCopBridgePI *pi ) | 124 | void QCopBridge::closed( QCopBridgePI *pi ) |
123 | { | 125 | { |
124 | emit connectionClosed( pi->peerAddress() ); | 126 | emit connectionClosed( pi->peerAddress() ); |
125 | openConnections.removeRef( pi ); | 127 | openConnections.removeRef( pi ); |
126 | if ( openConnections.count() == 0 ) { | 128 | if ( openConnections.count() == 0 ) { |
127 | /* ### FIXME libqtopia merge */ | 129 | /* ### FIXME libqtopia merge */ |
128 | #if 0 | 130 | #if 0 |
129 | QPEApplication::setTempScreenSaverMode( QPEApplication::Enable ); | 131 | QPEApplication::setTempScreenSaverMode( QPEApplication::Enable ); |
130 | #endif | 132 | #endif |
131 | #ifndef QT_NO_COP | 133 | #ifndef QT_NO_COP |
132 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 134 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
133 | #endif | 135 | #endif |
134 | } | 136 | } |
135 | } | 137 | } |
136 | 138 | ||
137 | void QCopBridge::closeOpenConnections() | 139 | void QCopBridge::closeOpenConnections() |
138 | { | 140 | { |
139 | QCopBridgePI *pi; | 141 | QCopBridgePI *pi; |
140 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) | 142 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) |
141 | pi->close(); | 143 | pi->close(); |
142 | } | 144 | } |
143 | 145 | ||
144 | 146 | ||
145 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &data ) | 147 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &data ) |
146 | { | 148 | { |
147 | if ( command == "startSync()" ) { | 149 | if ( command == "startSync()" ) { |
148 | // we need to buffer it a bit | 150 | // we need to buffer it a bit |
149 | sendSync = TRUE; | 151 | sendSync = TRUE; |
150 | startTimer( 20000 ); | 152 | startTimer( 20000 ); |
151 | } | 153 | } |
152 | 154 | ||
153 | if ( m_mode & Qtopia1_7 ) { | 155 | if ( m_mode & Qtopia1_7 ) { |
154 | // send the command to all open connections | 156 | // send the command to all open connections |
155 | QCopBridgePI *pi; | 157 | QCopBridgePI *pi; |
156 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { | 158 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { |
157 | pi->sendDesktopMessage( command, data ); | 159 | pi->sendDesktopMessage( command, data ); |
158 | } | 160 | } |
159 | } | 161 | } |
160 | if ( ( m_mode & Sharp ) || (m_mode & IntelliSync) ) | 162 | if ( ( m_mode & Sharp ) || (m_mode & IntelliSync) ) |
161 | sendDesktopMessageOld( command, data ); | 163 | sendDesktopMessageOld( command, data ); |
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index 2b2e435..a219c0f 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp | |||
@@ -1,154 +1,157 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
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 | #include "transferserver.h" | 20 | #include "transferserver.h" |
21 | 21 | ||
22 | /* OPIE */ | 22 | /* OPIE */ |
23 | #include <opie2/odebug.h> | 23 | #include <opie2/odebug.h> |
24 | #include <opie2/oglobal.h> | 24 | #include <opie2/oglobal.h> |
25 | #include <qtopia/qprocess.h> | 25 | #include <qtopia/qprocess.h> |
26 | #include <qtopia/process.h> | 26 | #include <qtopia/process.h> |
27 | #include <qtopia/private/contact.h> | 27 | #include <qtopia/private/contact.h> |
28 | #include <qtopia/version.h> | 28 | #include <qtopia/version.h> |
29 | #ifdef Q_WS_QWS | 29 | #ifdef Q_WS_QWS |
30 | #include <qtopia/qcopenvelope_qws.h> | 30 | #include <qtopia/qcopenvelope_qws.h> |
31 | #endif | 31 | #endif |
32 | using namespace Opie::Core; | 32 | using namespace Opie::Core; |
33 | 33 | ||
34 | /* QT */ | 34 | /* QT */ |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | 37 | ||
38 | /* STD */ | 38 | /* STD */ |
39 | #include <pwd.h> | 39 | #include <pwd.h> |
40 | #include <sys/types.h> | 40 | #include <sys/types.h> |
41 | #include <unistd.h> | 41 | #include <unistd.h> |
42 | #include <fcntl.h> | ||
42 | #include <stdlib.h> | 43 | #include <stdlib.h> |
43 | #include <time.h> | 44 | #include <time.h> |
44 | 45 | ||
45 | #ifndef Q_OS_MACX | 46 | #ifndef Q_OS_MACX |
46 | #include <shadow.h> | 47 | #include <shadow.h> |
47 | #include <crypt.h> | 48 | #include <crypt.h> |
48 | #endif /* Q_OS_MACX */ | 49 | #endif /* Q_OS_MACX */ |
49 | 50 | ||
50 | const int block_size = 51200; | 51 | const int block_size = 51200; |
51 | 52 | ||
52 | TransferServer::TransferServer( Q_UINT16 port, QObject *parent, | 53 | TransferServer::TransferServer( Q_UINT16 port, QObject *parent, |
53 | const char* name) | 54 | const char* name) |
54 | : QServerSocket( port, 1, parent, name ) | 55 | : QServerSocket( port, 1, parent, name ) |
55 | { | 56 | { |
56 | connections.setAutoDelete( TRUE ); | 57 | connections.setAutoDelete( TRUE ); |
57 | if ( !ok() ) | 58 | if ( !ok() ) |
58 | owarn << "Failed to bind to port " << port << "" << oendl; | 59 | owarn << "Failed to bind to port " << port << "" << oendl; |
60 | else | ||
61 | ::fcntl( socket(), F_SETFD, FD_CLOEXEC ); | ||
59 | } | 62 | } |
60 | 63 | ||
61 | void TransferServer::authorizeConnections() | 64 | void TransferServer::authorizeConnections() |
62 | { | 65 | { |
63 | QListIterator<ServerPI> it(connections); | 66 | QListIterator<ServerPI> it(connections); |
64 | while ( it.current() ) { | 67 | while ( it.current() ) { |
65 | if ( !it.current()->verifyAuthorised() ) { | 68 | if ( !it.current()->verifyAuthorised() ) { |
66 | disconnect( it.current(), SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); | 69 | disconnect( it.current(), SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); |
67 | connections.removeRef( it.current() ); | 70 | connections.removeRef( it.current() ); |
68 | } else | 71 | } else |
69 | ++it; | 72 | ++it; |
70 | } | 73 | } |
71 | } | 74 | } |
72 | 75 | ||
73 | void TransferServer::closed(ServerPI *item) | 76 | void TransferServer::closed(ServerPI *item) |
74 | { | 77 | { |
75 | connections.removeRef(item); | 78 | connections.removeRef(item); |
76 | } | 79 | } |
77 | 80 | ||
78 | TransferServer::~TransferServer() | 81 | TransferServer::~TransferServer() |
79 | { | 82 | { |
80 | } | 83 | } |
81 | 84 | ||
82 | void TransferServer::newConnection( int socket ) | 85 | void TransferServer::newConnection( int socket ) |
83 | { | 86 | { |
84 | ServerPI *ptr = new ServerPI( socket, this ); | 87 | ServerPI *ptr = new ServerPI( socket, this ); |
85 | connect( ptr, SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); | 88 | connect( ptr, SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); |
86 | connections.append( ptr ); | 89 | connections.append( ptr ); |
87 | } | 90 | } |
88 | 91 | ||
89 | QString SyncAuthentication::serverId() | 92 | QString SyncAuthentication::serverId() |
90 | { | 93 | { |
91 | Config cfg("Security"); | 94 | Config cfg("Security"); |
92 | cfg.setGroup("Sync"); | 95 | cfg.setGroup("Sync"); |
93 | QString r = cfg.readEntry("serverid"); | 96 | QString r = cfg.readEntry("serverid"); |
94 | 97 | ||
95 | if ( r.isEmpty() ) { | 98 | if ( r.isEmpty() ) { |
96 | r = OGlobal::generateUuid(); | 99 | r = OGlobal::generateUuid(); |
97 | cfg.writeEntry("serverid", r ); | 100 | cfg.writeEntry("serverid", r ); |
98 | } | 101 | } |
99 | return r; | 102 | return r; |
100 | } | 103 | } |
101 | 104 | ||
102 | QString SyncAuthentication::ownerName() | 105 | QString SyncAuthentication::ownerName() |
103 | { | 106 | { |
104 | QString vfilename = Global::applicationFileName("addressbook", | 107 | QString vfilename = Global::applicationFileName("addressbook", |
105 | "businesscard.vcf"); | 108 | "businesscard.vcf"); |
106 | if (QFile::exists(vfilename)) { | 109 | if (QFile::exists(vfilename)) { |
107 | Contact c; | 110 | Contact c; |
108 | c = Contact::readVCard( vfilename )[0]; | 111 | c = Contact::readVCard( vfilename )[0]; |
109 | return c.fullName(); | 112 | return c.fullName(); |
110 | } | 113 | } |
111 | 114 | ||
112 | return QString::null; | 115 | return QString::null; |
113 | } | 116 | } |
114 | 117 | ||
115 | QString SyncAuthentication::loginName() | 118 | QString SyncAuthentication::loginName() |
116 | { | 119 | { |
117 | struct passwd *pw = 0L; | 120 | struct passwd *pw = 0L; |
118 | #ifndef Q_OS_WIN32 | 121 | #ifndef Q_OS_WIN32 |
119 | pw = getpwuid( geteuid() ); | 122 | pw = getpwuid( geteuid() ); |
120 | return QString::fromLocal8Bit( pw->pw_name ); | 123 | return QString::fromLocal8Bit( pw->pw_name ); |
121 | #else | 124 | #else |
122 | //### revise | 125 | //### revise |
123 | return QString(); | 126 | return QString(); |
124 | #endif | 127 | #endif |
125 | } | 128 | } |
126 | 129 | ||
127 | int SyncAuthentication::isAuthorized(QHostAddress peeraddress) | 130 | int SyncAuthentication::isAuthorized(QHostAddress peeraddress) |
128 | { | 131 | { |
129 | Config cfg("Security"); | 132 | Config cfg("Security"); |
130 | cfg.setGroup("Sync"); | 133 | cfg.setGroup("Sync"); |
131 | // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); | 134 | // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); |
132 | uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100); | 135 | uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100); |
133 | 136 | ||
134 | // QHostAddress allowed; | 137 | // QHostAddress allowed; |
135 | // allowed.setAddress(allowedstr); | 138 | // allowed.setAddress(allowedstr); |
136 | // uint auth_peer = allowed.ip4Addr(); | 139 | // uint auth_peer = allowed.ip4Addr(); |
137 | uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24); | 140 | uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24); |
138 | uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined | 141 | uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined |
139 | ? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits)); | 142 | ? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits)); |
140 | 143 | ||
141 | return (peeraddress.ip4Addr() & mask) == auth_peer; | 144 | return (peeraddress.ip4Addr() & mask) == auth_peer; |
142 | } | 145 | } |
143 | 146 | ||
144 | bool SyncAuthentication::checkUser( const QString& user ) | 147 | bool SyncAuthentication::checkUser( const QString& user ) |
145 | { | 148 | { |
146 | if ( user.isEmpty() ) return FALSE; | 149 | if ( user.isEmpty() ) return FALSE; |
147 | QString euser = loginName(); | 150 | QString euser = loginName(); |
148 | return user == euser; | 151 | return user == euser; |
149 | } | 152 | } |
150 | 153 | ||
151 | bool SyncAuthentication::checkPassword( const QString& password ) | 154 | bool SyncAuthentication::checkPassword( const QString& password ) |
152 | { | 155 | { |
153 | #ifdef ALLOW_UNIX_USER_FTP | 156 | #ifdef ALLOW_UNIX_USER_FTP |
154 | // First, check system password... | 157 | // First, check system password... |