-rw-r--r-- | core/opie-login/passworddialogimpl.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/opie-login/passworddialogimpl.cpp b/core/opie-login/passworddialogimpl.cpp index d9132e2..3c1b474 100644 --- a/core/opie-login/passworddialogimpl.cpp +++ b/core/opie-login/passworddialogimpl.cpp | |||
@@ -143,49 +143,53 @@ void PasswordDialogImpl::writePassword() { | |||
143 | * Now crypt the password so we can write it later | 143 | * Now crypt the password so we can write it later |
144 | */ | 144 | */ |
145 | char* password = ::crypt( m_pass->text().latin1(), crypt_make_salt() ); | 145 | char* password = ::crypt( m_pass->text().latin1(), crypt_make_salt() ); |
146 | 146 | ||
147 | if ( !password ) | 147 | if ( !password ) |
148 | return error( tr("Password not legal" ), | 148 | return error( tr("Password not legal" ), |
149 | tr("<qt>The entered password is not a valid password." | 149 | tr("<qt>The entered password is not a valid password." |
150 | "Please try entering a valid password.</qt>" ) ); | 150 | "Please try entering a valid password.</qt>" ) ); |
151 | 151 | ||
152 | /* rewind and rewrite the password file */ | 152 | /* rewind and rewrite the password file */ |
153 | ::setpwent(); | 153 | ::setpwent(); |
154 | 154 | ||
155 | FILE* file = ::fopen( "/etc/passwd.new", "w" ); | 155 | FILE* file = ::fopen( "/etc/passwd.new", "w" ); |
156 | struct passwd* pass; | 156 | struct passwd* pass; |
157 | while ( (pass = ::getpwent()) != 0l ) { | 157 | while ( (pass = ::getpwent()) != 0l ) { |
158 | /* no shadow password support */ | 158 | /* no shadow password support */ |
159 | if ( pass->pw_uid == 0 ) | 159 | if ( pass->pw_uid == 0 ) |
160 | pass->pw_passwd = password; | 160 | pass->pw_passwd = password; |
161 | 161 | ||
162 | ::putpwent( pass, file ); | 162 | ::putpwent( pass, file ); |
163 | } | 163 | } |
164 | 164 | ||
165 | ::fclose( file ); | 165 | ::fclose( file ); |
166 | ::endpwent(); | 166 | ::endpwent(); |
167 | ::rename("/etc/passwd.new","/etc/passwd" ); | 167 | if (::rename("/etc/passwd.new","/etc/passwd" ) == -1) |
168 | return error( tr("Rename /etc/passwd failed"), | ||
169 | tr("<qt>Renaming /etc/passwd.new to /etc/passwd failed." | ||
170 | "Please check your /etc/passed file, your /etc directory " | ||
171 | "or your filesystem.</qt>") ); | ||
168 | 172 | ||
169 | /* should be done now */ | 173 | /* should be done now */ |
170 | #ifdef OPIE_LOGIN_SHADOW_PW | 174 | #ifdef OPIE_LOGIN_SHADOW_PW |
171 | #error "Can't write Shadow Passwords fixme" | 175 | #error "Can't write Shadow Passwords fixme" |
172 | #endif | 176 | #endif |
173 | } | 177 | } |
174 | 178 | ||
175 | /** | 179 | /** |
176 | * Raise an error. Delete input and set the focus after showing | 180 | * Raise an error. Delete input and set the focus after showing |
177 | * the error to the user | 181 | * the error to the user |
178 | */ | 182 | */ |
179 | void PasswordDialogImpl::error( const QString& caption, const QString& text ) { | 183 | void PasswordDialogImpl::error( const QString& caption, const QString& text ) { |
180 | m_isSet = false; | 184 | m_isSet = false; |
181 | QMessageBox::critical(this,caption, text, | 185 | QMessageBox::critical(this,caption, text, |
182 | QMessageBox::Ok, QMessageBox::NoButton ); | 186 | QMessageBox::Ok, QMessageBox::NoButton ); |
183 | 187 | ||
184 | m_pass->setText(""); | 188 | m_pass->setText(""); |
185 | m_pass->setFocus(); | 189 | m_pass->setFocus(); |
186 | 190 | ||
187 | m_confirm->setText(""); | 191 | m_confirm->setText(""); |
188 | } | 192 | } |
189 | 193 | ||
190 | void PasswordDialogImpl::slotToggleEcho( bool b ) { | 194 | void PasswordDialogImpl::slotToggleEcho( bool b ) { |
191 | m_pass-> setEchoMode( b ? QLineEdit::Normal : QLineEdit::Password ); | 195 | m_pass-> setEchoMode( b ? QLineEdit::Normal : QLineEdit::Password ); |