author | zecke <zecke> | 2002-09-06 20:55:41 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-06 20:55:41 (UTC) |
commit | 15992c5f9b24eaf8df6f90d1993c85d73827b98f (patch) (unidiff) | |
tree | fdcf85ca5ac482c87b7d8822069d3be3833f3e05 | |
parent | c9f7e21a3897b4a02c6eb460286eacbfafbba06f (diff) | |
download | opie-15992c5f9b24eaf8df6f90d1993c85d73827b98f.zip opie-15992c5f9b24eaf8df6f90d1993c85d73827b98f.tar.gz opie-15992c5f9b24eaf8df6f90d1993c85d73827b98f.tar.bz2 |
Backward and forward compability...
-rw-r--r-- | core/launcher/transferserver.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index 28b7b49..9d18b7b 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp | |||
@@ -127,99 +127,105 @@ int SyncAuthentication::isAuthorized(QHostAddress peeraddress) | |||
127 | 127 | ||
128 | bool SyncAuthentication::checkUser( const QString& user ) | 128 | bool SyncAuthentication::checkUser( const QString& user ) |
129 | { | 129 | { |
130 | if ( user.isEmpty() ) return FALSE; | 130 | if ( user.isEmpty() ) return FALSE; |
131 | QString euser = loginName(); | 131 | QString euser = loginName(); |
132 | return user == euser; | 132 | return user == euser; |
133 | } | 133 | } |
134 | 134 | ||
135 | bool SyncAuthentication::checkPassword( const QString& password ) | 135 | bool SyncAuthentication::checkPassword( const QString& password ) |
136 | { | 136 | { |
137 | #ifdef ALLOW_UNIX_USER_FTP | 137 | #ifdef ALLOW_UNIX_USER_FTP |
138 | // First, check system password... | 138 | // First, check system password... |
139 | 139 | ||
140 | struct passwd *pw = 0; | 140 | struct passwd *pw = 0; |
141 | struct spwd *spw = 0; | 141 | struct spwd *spw = 0; |
142 | 142 | ||
143 | pw = getpwuid( geteuid() ); | 143 | pw = getpwuid( geteuid() ); |
144 | spw = getspnam( pw->pw_name ); | 144 | spw = getspnam( pw->pw_name ); |
145 | 145 | ||
146 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); | 146 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); |
147 | if ( cpwd == "x" && spw ) | 147 | if ( cpwd == "x" && spw ) |
148 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); | 148 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); |
149 | 149 | ||
150 | // Note: some systems use more than crypt for passwords. | 150 | // Note: some systems use more than crypt for passwords. |
151 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); | 151 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); |
152 | if ( cpwd == cpassword ) | 152 | if ( cpwd == cpassword ) |
153 | return TRUE; | 153 | return TRUE; |
154 | #endif | 154 | #endif |
155 | 155 | ||
156 | static int lastdenial=0; | 156 | static int lastdenial=0; |
157 | static int denials=0; | 157 | static int denials=0; |
158 | int now = time(0); | 158 | int now = time(0); |
159 | 159 | ||
160 | // Detect old Qtopia Desktop (no password) | 160 | // Detect old Qtopia Desktop (no password) |
161 | if ( password.isEmpty() ) { | 161 | if ( password.isEmpty() ) { |
162 | if ( denials < 1 || now > lastdenial+600 ) { | 162 | if ( denials < 1 || now > lastdenial+600 ) { |
163 | QMessageBox::warning( 0,tr("Sync Connection"), | 163 | QMessageBox::warning( 0,tr("Sync Connection"), |
164 | tr("<p>An unauthorized system is requesting access to this device." | 164 | tr("<p>An unauthorized system is requesting access to this device." |
165 | "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " | 165 | "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " |
166 | "please upgrade."), | 166 | "please upgrade."), |
167 | tr("Deny") ); | 167 | tr("Deny") ); |
168 | denials++; | 168 | denials++; |
169 | lastdenial=now; | 169 | lastdenial=now; |
170 | } | 170 | } |
171 | return FALSE; | 171 | return FALSE; |
172 | } | 172 | } |
173 | 173 | ||
174 | // Second, check sync password... | 174 | // Second, check sync password... |
175 | if ( password.left(6) == "rootme" ) { | 175 | QString pass = password.left(6); |
176 | // fuckin TT gave us the wrong sync password. | 176 | /* old QtopiaDesktops are sending |
177 | // what a dumbassed password is rootme anyway. | 177 | * rootme newer versions got a Qtopia |
178 | * prefixed. Qtopia prefix will suceed | ||
179 | * until the sync software syncs up | ||
180 | * FIXME | ||
181 | */ | ||
182 | if ( pass == "rootme" || pass == "Qtopia") { | ||
183 | |||
178 | QString cpassword = QString::fromLocal8Bit( crypt( password.mid(8).local8Bit(), "qp" ) ); | 184 | QString cpassword = QString::fromLocal8Bit( crypt( password.mid(8).local8Bit(), "qp" ) ); |
179 | Config cfg("Security"); | 185 | Config cfg("Security"); |
180 | cfg.setGroup("Sync"); | 186 | cfg.setGroup("Sync"); |
181 | QString pwds = cfg.readEntry("Passwords"); | 187 | QString pwds = cfg.readEntry("Passwords"); |
182 | if ( QStringList::split(QChar(' '),pwds).contains(cpassword) ) | 188 | if ( QStringList::split(QChar(' '),pwds).contains(cpassword) ) |
183 | return TRUE; | 189 | return TRUE; |
184 | 190 | ||
185 | // Unrecognized system. Be careful... | 191 | // Unrecognized system. Be careful... |
186 | 192 | ||
187 | if ( (denials > 2 && now < lastdenial+600) | 193 | if ( (denials > 2 && now < lastdenial+600) |
188 | || QMessageBox::warning(0,tr("Sync Connection"), | 194 | || QMessageBox::warning(0,tr("Sync Connection"), |
189 | tr("<p>An unrecognized system is requesting access to this device." | 195 | tr("<p>An unrecognized system is requesting access to this device." |
190 | "<p>If you have just initiated a Sync for the first time, this is normal."), | 196 | "<p>If you have just initiated a Sync for the first time, this is normal."), |
191 | tr("Allow"),tr("Deny"))==1 ) | 197 | tr("Allow"),tr("Deny"))==1 ) |
192 | { | 198 | { |
193 | denials++; | 199 | denials++; |
194 | lastdenial=now; | 200 | lastdenial=now; |
195 | return FALSE; | 201 | return FALSE; |
196 | } else { | 202 | } else { |
197 | denials=0; | 203 | denials=0; |
198 | cfg.writeEntry("Passwords",pwds+" "+cpassword); | 204 | cfg.writeEntry("Passwords",pwds+" "+cpassword); |
199 | return TRUE; | 205 | return TRUE; |
200 | } | 206 | } |
201 | } | 207 | } |
202 | 208 | ||
203 | return FALSE; | 209 | return FALSE; |
204 | } | 210 | } |
205 | 211 | ||
206 | ServerPI::ServerPI( int socket, QObject *parent , const char* name ) | 212 | ServerPI::ServerPI( int socket, QObject *parent , const char* name ) |
207 | : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ) | 213 | : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ) |
208 | { | 214 | { |
209 | state = Connected; | 215 | state = Connected; |
210 | 216 | ||
211 | setSocket( socket ); | 217 | setSocket( socket ); |
212 | 218 | ||
213 | peerport = peerPort(); | 219 | peerport = peerPort(); |
214 | peeraddress = peerAddress(); | 220 | peeraddress = peerAddress(); |
215 | 221 | ||
216 | #ifndef INSECURE | 222 | #ifndef INSECURE |
217 | if ( !SyncAuthentication::isAuthorized(peeraddress) ) { | 223 | if ( !SyncAuthentication::isAuthorized(peeraddress) ) { |
218 | state = Forbidden; | 224 | state = Forbidden; |
219 | startTimer( 0 ); | 225 | startTimer( 0 ); |
220 | } else | 226 | } else |
221 | #endif | 227 | #endif |
222 | { | 228 | { |
223 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); | 229 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); |
224 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); | 230 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); |
225 | 231 | ||