Bug 138841 - readPassword returns 0 although there is no password
Summary: readPassword returns 0 although there is no password
Status: RESOLVED UNMAINTAINED
Alias: None
Product: kdelibs
Classification: Unmaintained
Component: kwallet (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-15 12:56 UTC by Christoph Bartoschek
Modified: 2024-09-14 17:06 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Bartoschek 2006-12-15 12:56:03 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    SuSE RPMs

If I create the folder "Pass" in my wallet and start the following programm the return from readPassword is 0. I would expect another value because the entry does not exist yet.

#include <qstring.h>
#include <kwallet.h>
#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <iostream>

int main(int argc, char ** argv)
{
   
   
   KAboutData aboutData("pass", I18N_NOOP("Password Check"),
                         "", "", KAboutData::License_GPL,
                         "");
   
   KCmdLineArgs::init( argc, argv, &aboutData );

   KApplication app(false, false);

   QString localwallet = KWallet::Wallet::LocalWallet();
   std::cout << localwallet.latin1() << std::endl;
   
   KWallet::Wallet * wallet =  KWallet::Wallet::openWallet(localwallet);
   if (not wallet) return 1;
   
   if (not wallet->hasFolder("Pass")) {
      std::cout << "No folder" << std::endl;
      return 1;
   }
   if (not wallet->setFolder("Pass")) {
      std::cout << "Cannot change to folder" << std::endl;
       return 1;
   }
   
   QString key = "key";
   
//    if (not wallet->hasEntry(key)) {
//       std::cout << "No entry: " << key << std::endl;
//       return 1;
//    }
   
   QString password = "Dummy";
   int ret = wallet->readPassword(key, password);
   std::cerr << "Ret: " << ret << std::endl;
   if (ret == 0) {
      std::cerr << " Key: " << key.latin1() 
                << " Password: " << password.latin1()
                << std::endl;
   } else {
      return 1;
   }
     
   return 0;
}
Comment 1 George Staikos 2006-12-15 22:16:59 UTC
You will have to check hasEntry before readPassword for now.  It  
appears to be a design problem.


--
George Staikos
KDE Developer				http://www.kde.org/
Staikos Computing Services Inc.		http://www.staikos.net/
Comment 2 Christoph Cullmann 2024-09-14 17:06:35 UTC
Hi,

kdelibs (version 4 and earlier) is no longer maintained since a few years.

KDE Frameworks 5 or 6 might already have resolved this bug.

If not, please re-open against the matching framework if feasible or against the application that shows the issue.

We then can still dispatch it to the right Bugzilla product or component.

Greetings
Christoph Cullmann