- ZConfig::credentialsGlobal{File,Dir}() added (/etc/zypp/credentials.{cat,d})
authorJan Kupec <jkupec@suse.cz>
Thu, 25 Sep 2008 21:19:04 +0000 (21:19 +0000)
committerJan Kupec <jkupec@suse.cz>
Thu, 25 Sep 2008 21:19:04 +0000 (21:19 +0000)
zypp.conf
zypp/ZConfig.cc
zypp/ZConfig.h
zypp/media/CredentialManager.cc

index a712aa8..49f1c5f 100644 (file)
--- a/zypp.conf
+++ b/zypp.conf
 ## Default value: /var/log/zypp/history
 ##
 # history.logfile = /var/log/zypp/history
+
+##
+## Global credentials directory path.
+##
+## If a URL contains ?credentials=<filename> parameter, the credentials will
+## be stored and looked for in a file named <filename> in this directory.
+##
+## Valid values: absolute path to a directory
+## Default value: /var/log/zypp/history
+##
+# credentials.global.dir = /etc/zypp/credentials.d
+
+##
+## Global credentials catalog file path.
+##
+## This file contains a catalog of all known user credentials which were
+## not stored via the ?credentials=<filename> URL parameter, i.e. passed
+## in URL as username:password component, or entered by user in
+## an authentication dialog.
+##
+## Valid values: absolute path to a file
+## Default value: /etc/zypp/credentials.cat
+##
+# credentials.global.file = /etc/zypp/credentials.cat
index f9a0dc1..d5876af 100644 (file)
@@ -286,6 +286,14 @@ namespace zypp
                 {
                   history_log_path = Pathname(value);
                 }
+                else if ( entry == "credentials.global.dir" )
+                {
+                  credentials_global_dir_path = Pathname(value); 
+                }
+                else if ( entry == "credentials.global.file" )
+                {
+                  credentials_global_file_path = Pathname(value); 
+                }
               }
             }
           }
@@ -349,6 +357,8 @@ namespace zypp
     target::rpm::RpmInstFlags rpmInstallFlags;
     
     Pathname history_log_path;
+    Pathname credentials_global_dir_path;
+    Pathname credentials_global_file_path;
   };
   ///////////////////////////////////////////////////////////////////
 
@@ -569,6 +579,18 @@ namespace zypp
   }
 
 
+  Pathname ZConfig::credentialsGlobalDir() const
+  {
+    return ( _pimpl->credentials_global_dir_path.empty() ?
+        Pathname("/etc/zypp/credentials.d") : _pimpl->credentials_global_dir_path );
+  }
+
+  Pathname ZConfig::credentialsGlobalFile() const
+  {
+    return ( _pimpl->credentials_global_file_path.empty() ?
+        Pathname("/etc/zypp/credentials.cat") : _pimpl->credentials_global_file_path );
+  }
+
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////
index d23a736..110cbdf 100644 (file)
@@ -232,6 +232,16 @@ namespace zypp
        * \see http://en.opensuse.org/Libzypp/Package_History
        */
       Pathname historyLogFile() const;
+      
+      /**
+       * Defaults to /etc/zypp/credentials.d
+       */
+      Pathname credentialsGlobalDir() const;
+      
+      /**
+       * Defaults to /etc/zypp/credentials.cat
+       */
+      Pathname credentialsGlobalFile() const;
 
     public:
       class Impl;
index 1b588ff..38c5489 100644 (file)
@@ -12,6 +12,7 @@
 #include <iostream>
 #include <fstream>
 
+#include "zypp/ZConfig.h"
 #include "zypp/base/Function.h"
 #include "zypp/base/Logger.h"
 #include "zypp/base/Easy.h"
@@ -21,9 +22,7 @@
 
 #include "zypp/media/CredentialManager.h"
 
-#define CUSTOM_CREDENTIALS_FILE_DIR "/etc/zypp/credentials.d"
-#define GLOBAL_CREDENTIALS_FILE "/etc/zypp/credentials.cat" 
-#define USER_CREDENTIALS_FILE   ".zypp/credentials.cat"
+#define USER_CREDENTIALS_FILE ".zypp/credentials.cat"
 
 using namespace std;
 
@@ -42,8 +41,8 @@ namespace zypp
   //////////////////////////////////////////////////////////////////////
 
   CredManagerOptions::CredManagerOptions(const Pathname & rootdir)
-    : globalCredFilePath(rootdir / GLOBAL_CREDENTIALS_FILE)
-    , customCredFileDir(rootdir / CUSTOM_CREDENTIALS_FILE_DIR)
+    : globalCredFilePath(rootdir / ZConfig::instance().credentialsGlobalFile())
+    , customCredFileDir(rootdir / ZConfig::instance().credentialsGlobalDir())
   {
     char * homedir = getenv("HOME");
     if (homedir)