Skip to content

Commit

Permalink
Format with clang-format with options in .clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
thanegill committed Aug 3, 2015
1 parent 1bb57c3 commit ecc209e
Show file tree
Hide file tree
Showing 80 changed files with 23,995 additions and 24,489 deletions.
62 changes: 62 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Option definitions here:
# http://clang.llvm.org/docs/ClangFormatStyleOptions.html
AccessModifierOffset: 0
AlignAfterOpenBracket: false
AlignConsecutiveAssignments: false
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: false
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Linux
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 0
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IndentCaseLabels: false
IndentFunctionDeclarationAfterType: false
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
Language: Cpp
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
UseTab: Never
189 changes: 95 additions & 94 deletions src/Auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// INCLUDES

#ifdef HAVE_CONFIG_H
#include "dgconfig.h"
#include "dgconfig.h"
#endif
#include "Auth.hpp"
#include "OptionContainer.hpp"
Expand Down Expand Up @@ -36,142 +36,143 @@ extern authcreate_t ntlmcreate;

// IMPLEMENTATION

AuthPlugin::AuthPlugin(ConfigVar &definition):is_connection_based(false), needs_proxy_query(false)
AuthPlugin::AuthPlugin(ConfigVar &definition)
: is_connection_based(false), needs_proxy_query(false)
{
cv = definition;
pluginName = cv["plugname"];
cv = definition;
pluginName = cv["plugname"];
}

int AuthPlugin::init(void *args)
{
return 0;
return 0;
}

int AuthPlugin::quit()
{
return 0;
return 0;
}

String AuthPlugin::getPluginName()
{
return pluginName;
return pluginName;
}
// determine what filter group the given username is in
// return -1 when user not found
int AuthPlugin::determineGroup(std::string &user, int &fg)
{
if (user.length() < 1 || user == "-") {
return DGAUTH_NOMATCH;
}
String u(user);
u.toLower(); // since the filtergroupslist is read in in lowercase, we should do this.
user = u.toCharArray(); // also pass back to ConnectionHandler, so appears lowercase in logs
String ue(u);
ue += "=";

char *i = o.filter_groups_list.findStartsWithPartial(ue.toCharArray());

if (i == NULL) {
if (user.length() < 1 || user == "-") {
return DGAUTH_NOMATCH;
}
String u(user);
u.toLower(); // since the filtergroupslist is read in in lowercase, we should do this.
user = u.toCharArray(); // also pass back to ConnectionHandler, so appears lowercase in logs
String ue(u);
ue += "=";

char *i = o.filter_groups_list.findStartsWithPartial(ue.toCharArray());

if (i == NULL) {
#ifdef DGDEBUG
std::cout << "User not in filter groups list: " << ue << std::endl;
std::cout << "User not in filter groups list: " << ue << std::endl;
#endif
return DGAUTH_NOUSER;
}
return DGAUTH_NOUSER;
}
#ifdef DGDEBUG
std::cout << "User found: " << i << std::endl;
#endif
ue = i;
if (ue.before("=") == u) {
ue = ue.after("=filter");
int l = ue.length();
if (l < 1 || l > 2) {
return DGAUTH_NOUSER;
}
fg = ue.toInteger();
if (fg > o.numfg) {
return DGAUTH_NOUSER;
}
if (fg > 0) {
fg--;
}
return DGAUTH_OK;
}
return DGAUTH_NOUSER;
std::cout << "User found: " << i << std::endl;
#endif
ue = i;
if (ue.before("=") == u) {
ue = ue.after("=filter");
int l = ue.length();
if (l < 1 || l > 2) {
return DGAUTH_NOUSER;
}
fg = ue.toInteger();
if (fg > o.numfg) {
return DGAUTH_NOUSER;
}
if (fg > 0) {
fg--;
}
return DGAUTH_OK;
}
return DGAUTH_NOUSER;
}

// take in a configuration file, find the AuthPlugin class associated with the plugname variable, and return an instance
AuthPlugin* auth_plugin_load(const char *pluginConfigPath)
AuthPlugin *auth_plugin_load(const char *pluginConfigPath)
{
ConfigVar cv;

if (cv.readVar(pluginConfigPath, "=") > 0) {
if (!is_daemonised) {
std::cerr << "Unable to load plugin config: " << pluginConfigPath << std::endl;
}
syslog(LOG_ERR, "Unable to load plugin config %s", pluginConfigPath);
return NULL;
}

String plugname(cv["plugname"]);
if (plugname.length() < 1) {
if (!is_daemonised) {
std::cerr << "Unable read plugin config plugname variable: " << pluginConfigPath << std::endl;
}
syslog(LOG_ERR, "Unable read plugin config plugname variable %s", pluginConfigPath);
return NULL;
}

if (plugname == "proxy-basic") {
ConfigVar cv;

if (cv.readVar(pluginConfigPath, "=") > 0) {
if (!is_daemonised) {
std::cerr << "Unable to load plugin config: " << pluginConfigPath << std::endl;
}
syslog(LOG_ERR, "Unable to load plugin config %s", pluginConfigPath);
return NULL;
}

String plugname(cv["plugname"]);
if (plugname.length() < 1) {
if (!is_daemonised) {
std::cerr << "Unable read plugin config plugname variable: " << pluginConfigPath << std::endl;
}
syslog(LOG_ERR, "Unable read plugin config plugname variable %s", pluginConfigPath);
return NULL;
}

if (plugname == "proxy-basic") {
#ifdef DGDEBUG
std::cout << "Enabling proxy-basic auth plugin" << std::endl;
std::cout << "Enabling proxy-basic auth plugin" << std::endl;
#endif
return proxycreate(cv);
}
return proxycreate(cv);
}

if (plugname == "proxy-digest") {
if (plugname == "proxy-digest") {
#ifdef DGDEBUG
std::cout << "Enabling proxy-digest auth plugin" << std::endl;
std::cout << "Enabling proxy-digest auth plugin" << std::endl;
#endif
return digestcreate(cv);
}
return digestcreate(cv);
}

if (plugname == "ident") {
if (plugname == "ident") {
#ifdef DGDEBUG
std::cout << "Enabling ident server auth plugin" << std::endl;
std::cout << "Enabling ident server auth plugin" << std::endl;
#endif
return identcreate(cv);
}
return identcreate(cv);
}

if (plugname == "ip") {
if (plugname == "ip") {
#ifdef DGDEBUG
std::cout << "Enabling IP-based auth plugin" << std::endl;
std::cout << "Enabling IP-based auth plugin" << std::endl;
#endif
return ipcreate(cv);
}
return ipcreate(cv);
}

if (plugname == "port") {
if (plugname == "port") {
#ifdef DGDEBUG
std::cout << "Enabling port-based auth plugin" << std::endl;
std::cout << "Enabling port-based auth plugin" << std::endl;
#endif
return portcreate(cv);
}
return portcreate(cv);
}

#ifdef PRT_DNSAUTH
if (plugname == "dnsauth") {
if (plugname == "dnsauth") {
#ifdef DGDEBUG
std::cout << "Enabling DNS-based auth plugin" << std::endl;
std::cout << "Enabling DNS-based auth plugin" << std::endl;
#endif
return dnsauthcreate(cv);
}
return dnsauthcreate(cv);
}
#endif

#ifdef ENABLE_NTLM
if (plugname == "proxy-ntlm") {
if (plugname == "proxy-ntlm") {
#ifdef DGDEBUG
std::cout << "Enabling proxy-NTLM auth plugin" << std::endl;
std::cout << "Enabling proxy-NTLM auth plugin" << std::endl;
#endif
return ntlmcreate(cv);
}
return ntlmcreate(cv);
}
#endif
#ifdef __SSLMITM
// if (plugname == "ssl") {
Expand All @@ -189,9 +190,9 @@ AuthPlugin* auth_plugin_load(const char *pluginConfigPath)
// }
#endif //__SSLMITM

if (!is_daemonised) {
std::cerr << "Unable to load plugin: " << pluginConfigPath << std::endl;
}
syslog(LOG_ERR, "Unable to load plugin %s", pluginConfigPath);
return NULL;
if (!is_daemonised) {
std::cerr << "Unable to load plugin: " << pluginConfigPath << std::endl;
}
syslog(LOG_ERR, "Unable to load plugin %s", pluginConfigPath);
return NULL;
}
Loading

0 comments on commit ecc209e

Please sign in to comment.