~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/auth_file/auth_file.cc

  • Committer: Brian Aker
  • Date: 2010-11-06 15:43:10 UTC
  • mfrom: (1908.1.1 merge)
  • Revision ID: brian@tangent.org-20101106154310-g1jpjzwbc53pfc4f
Filesort encapsulation, plus modification to copy contructor

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include <iostream>
26
26
 
27
27
#include <boost/program_options.hpp>
28
 
#include <boost/filesystem.hpp>
29
28
 
30
29
#include "drizzled/configmake.h"
31
30
#include "drizzled/plugin/authentication.h"
35
34
#include "drizzled/module/option_map.h"
36
35
 
37
36
namespace po= boost::program_options;
38
 
namespace fs= boost::filesystem;
39
 
 
40
37
using namespace std;
41
38
using namespace drizzled;
42
39
 
43
40
namespace auth_file
44
41
{
45
42
 
46
 
static const fs::path DEFAULT_USERS_FILE= SYSCONFDIR "/drizzle.users";
 
43
static const char DEFAULT_USERS_FILE[]= SYSCONFDIR "/drizzle.users";
47
44
 
48
45
class AuthFile: public plugin::Authentication
49
46
{
50
 
  const fs::path users_file;
 
47
  const std::string users_file;
51
48
 
52
49
public:
53
50
 
54
 
  AuthFile(string name_arg, fs::path users_file_arg);
 
51
  AuthFile(string name_arg, string users_file_arg);
55
52
 
56
53
  /**
57
54
   * Retrieve the last error encountered in the class.
96
93
  map<string, string> users;
97
94
};
98
95
 
99
 
AuthFile::AuthFile(string name_arg, fs::path users_file_arg):
 
96
AuthFile::AuthFile(string name_arg, string users_file_arg):
100
97
  plugin::Authentication(name_arg),
101
98
  users_file(users_file_arg),
102
99
  error(),
111
108
 
112
109
bool AuthFile::loadFile(void)
113
110
{
114
 
  ifstream file(users_file.string().c_str());
 
111
  ifstream file(users_file.c_str());
115
112
 
116
113
  if (!file.is_open())
117
114
  {
118
115
    error = "Could not open users file: ";
119
 
    error += users_file.string();
 
116
    error += users_file;
120
117
    return false;
121
118
  }
122
119
 
220
217
{
221
218
  const module::option_map &vm= context.getOptions();
222
219
 
223
 
  AuthFile *auth_file = new AuthFile("auth_file", fs::path(vm["users"].as<string>()));
 
220
  AuthFile *auth_file = new AuthFile("auth_file", vm["users"].as<string>());
224
221
  if (!auth_file->loadFile())
225
222
  {
226
223
    errmsg_printf(ERRMSG_LVL_ERROR, _("Could not load auth file: %s\n"),
238
235
static void init_options(drizzled::module::option_context &context)
239
236
{
240
237
  context("users", 
241
 
          po::value<string>()->default_value(DEFAULT_USERS_FILE.string()),
 
238
          po::value<string>()->default_value(DEFAULT_USERS_FILE),
242
239
          N_("File to load for usernames and passwords"));
243
240
}
244
241