diff --git a/headers/private/screen_saver/ScreenSaverSettings.h b/headers/private/screen_saver/ScreenSaverSettings.h index 78257ccd6b..65464c12a5 100644 --- a/headers/private/screen_saver/ScreenSaverSettings.h +++ b/headers/private/screen_saver/ScreenSaverSettings.h @@ -56,9 +56,9 @@ public: bigtime_t PasswordTime() const { return fPasswordTime; } const char* Password() { return fPassword.String(); } const char* LockMethod() { return fLockMethod.String(); } - bool IsNetworkPassword() - { return strcmp(fLockMethod.String(), "custom") - != 0; } + bool UseSystemPassword() + { return strcmp(fLockMethod.String(), "system") + == 0; } const char* ModuleName() { return fModuleName.String(); } status_t GetModuleState(const char* name, @@ -84,7 +84,7 @@ public: { fPasswordTime = time; } void SetPassword(const char* password) { fPassword = password; } - // Cannot set network password from here. + // Cannot set system password from here. void SetLockMethod(const char* method) { fLockMethod = method; } void SetModuleName(const char* name) diff --git a/src/bin/screen_blanker/ScreenBlanker.cpp b/src/bin/screen_blanker/ScreenBlanker.cpp index 87d387a9ec..5af0f312c3 100644 --- a/src/bin/screen_blanker/ScreenBlanker.cpp +++ b/src/bin/screen_blanker/ScreenBlanker.cpp @@ -224,7 +224,9 @@ ScreenBlanker::MessageReceived(BMessage* message) switch (message->what) { case kMsgUnlock: { - if (strcmp(fSettings.Password(), crypt(fPasswordWindow->Password(), + // if the user has no password then just exit on any input + if (fSettings.Password()[0] != '\0' + && strcmp(fSettings.Password(), crypt(fPasswordWindow->Password(), fSettings.Password())) != 0) { beep(); fPasswordWindow->SetPassword(""); diff --git a/src/kits/screensaver/ScreenSaverSettings.cpp b/src/kits/screensaver/ScreenSaverSettings.cpp index 73175cd6e9..2658393da6 100644 --- a/src/kits/screensaver/ScreenSaverSettings.cpp +++ b/src/kits/screensaver/ScreenSaverSettings.cpp @@ -14,6 +14,8 @@ #include "ScreenSaverSettings.h" +#include +#include #include #include @@ -87,8 +89,20 @@ ScreenSaverSettings::Load() if (fSettings.FindString("modulename", &string) == B_OK) fModuleName = string; - if (IsNetworkPassword()) { - // TODO: this does not work yet + if (!UseSystemPassword()) + return true; + + char* username = getlogin(); + if (username == NULL) + return true; + + struct spwd *shadowpwd = getspnam(username); + if (shadowpwd != NULL) { + fPassword = shadowpwd->sp_pwdp; + } else { + struct passwd *pwd = getpwnam(username); + if (pwd != NULL) + fPassword = pwd->pw_passwd; } return true; @@ -160,7 +174,7 @@ ScreenSaverSettings::Message() if (fSettings.ReplaceString("lockmethod", fLockMethod) != B_OK) fSettings.AddString("lockmethod", fLockMethod); - const char* password = IsNetworkPassword() ? "" : fPassword.String(); + const char* password = UseSystemPassword() ? "" : fPassword.String(); if (fSettings.ReplaceString("lockpassword", password) != B_OK) fSettings.AddString("lockpassword", password); diff --git a/src/preferences/screensaver/PasswordWindow.cpp b/src/preferences/screensaver/PasswordWindow.cpp index 54e32093b6..af3befcf7b 100644 --- a/src/preferences/screensaver/PasswordWindow.cpp +++ b/src/preferences/screensaver/PasswordWindow.cpp @@ -60,13 +60,13 @@ PasswordWindow::_Setup() topView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR); topView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED)); - BBox* networkBox = new BBox("networkBox"); - networkBox->SetBorder(B_NO_BORDER); + BBox* systemBox = new BBox("systemBox"); + systemBox->SetBorder(B_NO_BORDER); - fUseNetwork = new BRadioButton("useNetwork", - B_TRANSLATE("Use network password"), + fUseSystem = new BRadioButton("useSystem", + B_TRANSLATE("Use system password"), new BMessage(kMsgPasswordTypeChanged)); - networkBox->SetLabel(fUseNetwork); + systemBox->SetLabel(fUseSystem); BBox* customBox = new BBox("customBox"); @@ -114,7 +114,7 @@ PasswordWindow::_Setup() BLayoutBuilder::Group<>(topView, B_VERTICAL, 0) .SetInsets(B_USE_DEFAULT_SPACING) - .Add(networkBox) + .Add(systemBox) .Add(customBox) .AddStrut(B_USE_DEFAULT_SPACING) .AddGroup(B_HORIZONTAL) @@ -134,14 +134,14 @@ PasswordWindow::_Setup() void PasswordWindow::Update() { - if (fSettings.IsNetworkPassword()) - fUseNetwork->SetValue(B_CONTROL_ON); + if (fSettings.UseSystemPassword()) + fUseSystem->SetValue(B_CONTROL_ON); else fUseCustom->SetValue(B_CONTROL_ON); - bool useNetPassword = (fUseCustom->Value() > 0); - fConfirmControl->SetEnabled(useNetPassword); - fPasswordControl->SetEnabled(useNetPassword); + bool useSysPassword = (fUseCustom->Value() > 0); + fConfirmControl->SetEnabled(useSysPassword); + fPasswordControl->SetEnabled(useSysPassword); } @@ -150,7 +150,7 @@ PasswordWindow::MessageReceived(BMessage* message) { switch (message->what) { case kMsgDone: - fSettings.SetLockMethod(fUseCustom->Value() ? "custom" : "network"); + fSettings.SetLockMethod(fUseCustom->Value() ? "custom" : "system"); if (fUseCustom->Value()) { if (strcmp(fPasswordControl->Text(), fConfirmControl->Text()) != 0) { @@ -178,7 +178,7 @@ PasswordWindow::MessageReceived(BMessage* message) break; case kMsgPasswordTypeChanged: - fSettings.SetLockMethod(fUseCustom->Value() > 0 ? "custom" : "network"); + fSettings.SetLockMethod(fUseCustom->Value() > 0 ? "custom" : "system"); Update(); break; diff --git a/src/preferences/screensaver/PasswordWindow.h b/src/preferences/screensaver/PasswordWindow.h index eee262113e..5427723455 100644 --- a/src/preferences/screensaver/PasswordWindow.h +++ b/src/preferences/screensaver/PasswordWindow.h @@ -31,7 +31,7 @@ private: void _Setup(); BRadioButton* fUseCustom; - BRadioButton* fUseNetwork; + BRadioButton* fUseSystem; BTextControl* fConfirmControl; BTextControl* fPasswordControl;