refactor: build workaround from string
This commit is contained in:
parent
c31acece3e
commit
e8e1624ea1
2 changed files with 11 additions and 25 deletions
|
|
@ -79,9 +79,9 @@ int howdy_error(int status, function<int(int, const char *)> conv_function) {
|
||||||
break;
|
break;
|
||||||
// Otherwise, we can't describe what happened but it wasn't successful
|
// Otherwise, we can't describe what happened but it wasn't successful
|
||||||
default:
|
default:
|
||||||
conv_function(PAM_ERROR_MSG, string(dgettext("pam", "Unknown error:") +
|
conv_function(
|
||||||
to_string(status))
|
PAM_ERROR_MSG,
|
||||||
.c_str());
|
string(dgettext("pam", "Unknown error: ") + status).c_str());
|
||||||
syslog(LOG_INFO, "Failure, unknown error %d", status);
|
syslog(LOG_INFO, "Failure, unknown error %d", status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +153,8 @@ int identify(pam_handle_t *pamh, int flags, int argc, const char **argv,
|
||||||
// Open the system log so we can write to it
|
// Open the system log so we can write to it
|
||||||
openlog("pam_howdy", 0, LOG_AUTHPRIV);
|
openlog("pam_howdy", 0, LOG_AUTHPRIV);
|
||||||
|
|
||||||
string workaround = reader.GetString("core", "workaround", "input");
|
Workaround workaround =
|
||||||
|
get_workaround(reader.GetString("core", "workaround", "input"));
|
||||||
|
|
||||||
// In this case, we are not asking for the password
|
// In this case, we are not asking for the password
|
||||||
if (workaround == Workaround::Off && auth_tok) {
|
if (workaround == Workaround::Off && auth_tok) {
|
||||||
|
|
|
||||||
|
|
@ -8,29 +8,14 @@ enum class Type { Unset, Howdy, Pam };
|
||||||
|
|
||||||
enum class Workaround { Off, Input, Native };
|
enum class Workaround { Off, Input, Native };
|
||||||
|
|
||||||
inline bool operator==(const std::string &l, const Workaround &r) {
|
inline Workaround get_workaround(std::string workaround) {
|
||||||
switch (r) {
|
if (workaround == "input")
|
||||||
case Workaround::Off:
|
return Workaround::Input;
|
||||||
return (l == "off");
|
|
||||||
case Workaround::Input:
|
|
||||||
return (l == "input");
|
|
||||||
case Workaround::Native:
|
|
||||||
return (l == "native");
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool operator==(const Workaround &l, const std::string &r) {
|
if (workaround == "native")
|
||||||
return operator==(r, l);
|
return Workaround::Native;
|
||||||
}
|
|
||||||
|
|
||||||
inline bool operator!=(const std::string &l, const Workaround &r) {
|
return Workaround::Off;
|
||||||
return !operator==(l, r);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool operator!=(const Workaround &l, const std::string &r) {
|
|
||||||
return operator!=(r, l);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // MAIN_H_
|
#endif // MAIN_H_
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue