~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/authentication.cc

[patch 112/129] Merge patch for revision 1925 from InnoDB SVN:
revno: 1925
revision-id: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6169
parent: svn-v4:16c675df-0fcb-4bc9-8058-dcc011a37293:branches/zip:6163
committer: calvin
timestamp: Thu 2009-11-12 12:40:43 +0000
message:
  branches/zip: add test case for bug#46676
  
  This crash is reproducible with InnoDB plugin 1.0.4 + MySQL 5.1.37.
  But no longer reproducible after MySQL 5.1.38 (with plugin 1.0.5).
  Add test case to catch future regression.
added:
  mysql-test/innodb_bug46676.result 6169@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb_bug46676.result
  mysql-test/innodb_bug46676.test 6169@16c675df-0fcb-4bc9-8058-dcc011a37293:branches%2Fzip%2Fmysql-test%2Finnodb_bug46676.test
diff:
=== added file 'mysql-test/innodb_bug46676.result'

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
#include <vector>
28
28
 
 
29
using namespace std;
 
30
 
29
31
namespace drizzled
30
32
{
31
33
 
42
44
void plugin::Authentication::removePlugin(plugin::Authentication *auth)
43
45
{
44
46
  if (auth != NULL)
45
 
    all_authentication.erase(std::find(all_authentication.begin(),
46
 
                                       all_authentication.end(),
47
 
                                       auth));
 
47
    all_authentication.erase(find(all_authentication.begin(),
 
48
                                  all_authentication.end(),
 
49
                                  auth));
48
50
}
49
51
 
50
 
class AuthenticateBy : public std::unary_function<plugin::Authentication *, bool>
 
52
class AuthenticateBy : public unary_function<plugin::Authentication *, bool>
51
53
{
52
54
  const SecurityContext &sctx;
53
 
  const std::string &password;
 
55
  const string &password;
54
56
public:
55
 
  AuthenticateBy(const SecurityContext &sctx_arg, const std::string &password_arg) :
56
 
    std::unary_function<plugin::Authentication *, bool>(),
 
57
  AuthenticateBy(const SecurityContext &sctx_arg, const string &password_arg) :
 
58
    unary_function<plugin::Authentication *, bool>(),
57
59
    sctx(sctx_arg), password(password_arg) {}
58
60
 
59
61
  inline result_type operator()(argument_type auth)
63
65
};
64
66
 
65
67
bool plugin::Authentication::isAuthenticated(const SecurityContext &sctx,
66
 
                                             const std::string &password)
 
68
                                             const string &password)
67
69
{
68
70
  /* If we never loaded any auth plugins, just return true */
69
71
  if (all_authentication.empty())
70
72
    return true;
71
73
 
72
74
  /* Use find_if instead of foreach so that we can collect return codes */
73
 
  std::vector<plugin::Authentication *>::iterator iter=
74
 
    std::find_if(all_authentication.begin(), all_authentication.end(),
75
 
                 AuthenticateBy(sctx, password));
 
75
  vector<plugin::Authentication *>::iterator iter=
 
76
    find_if(all_authentication.begin(), all_authentication.end(),
 
77
            AuthenticateBy(sctx, password));
76
78
 
77
79
  /* We only require one plugin to return success in order to authenticate.
78
80
   * If iter is == end() here, that means that all of the plugins returned