mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-10-11 09:03:40 +02:00
2017-04-03 Fred Gleason <fredg@paravelsystems.com>
* Added a 'USERS.LOCAL_AUTH' field to the database. * Added a 'USERS.PAM_SERVICE' field to the database. * Added an index on 'STATIONS.IPV4_ADDRESS' to the database. * Incremented the database version to 262. * Added 'RDUser::localAuthentication()', 'RDUser::setLocalAuthentication()', 'RDUser::pamService()' and 'RDUser::setPamService()' methods in 'lib/rduser.cpp' and 'lib/rduser.h'. * Added 'PAM Service' and 'Authenticate This User Locally' controls to the Edit User dialog in 'rdadmin/edit_user.cpp' and 'rdadmin/edit_user.h'. * Added a PAM service configuration in 'conf/rivendell.pam'.
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
/*
|
||||
* Current Database Version
|
||||
*/
|
||||
#define RD_VERSION_DATABASE 261
|
||||
#define RD_VERSION_DATABASE 262
|
||||
|
||||
|
||||
#endif // DBVERSION_H
|
||||
|
@@ -19,6 +19,7 @@
|
||||
//
|
||||
|
||||
#include <rdconf.h>
|
||||
#include <rdpam.h>
|
||||
#include <rduser.h>
|
||||
#include <rddb.h>
|
||||
#include <rdescape_string.h>
|
||||
@@ -49,19 +50,27 @@ bool RDUser::authenticated(bool webuser) const
|
||||
RDSqlQuery *q;
|
||||
QString sql;
|
||||
|
||||
sql=QString().sprintf("select LOGIN_NAME,ENABLE_WEB from USERS \
|
||||
where LOGIN_NAME=\"%s\" \
|
||||
if(localAuthentication()) {
|
||||
sql=QString().sprintf("select LOGIN_NAME,ENABLE_WEB from USERS \
|
||||
where LOGIN_NAME=\"%s\" \
|
||||
&& PASSWORD=\"%s\"",
|
||||
(const char *)RDEscapeString(user_name),
|
||||
(const char *)RDEscapeString(user_password));
|
||||
q=new RDSqlQuery(sql);
|
||||
if(q->first()) {
|
||||
bool ret=RDBool(q->value(1).toString())||
|
||||
((!RDBool(q->value(1).toString()))&&(!webuser));
|
||||
(const char *)RDEscapeString(user_name),
|
||||
(const char *)RDEscapeString(user_password));
|
||||
q=new RDSqlQuery(sql);
|
||||
if(q->first()) {
|
||||
bool ret=RDBool(q->value(1).toString())||
|
||||
((!RDBool(q->value(1).toString()))&&(!webuser));
|
||||
delete q;
|
||||
return ret;
|
||||
}
|
||||
delete q;
|
||||
}
|
||||
else {
|
||||
RDPam *pam=new RDPam(pamService());
|
||||
bool ret=pam->authenticate(user_name,user_password);
|
||||
delete pam;
|
||||
return ret;
|
||||
}
|
||||
delete q;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -100,6 +109,31 @@ void RDUser::setEnableWeb(bool state) const
|
||||
}
|
||||
|
||||
|
||||
bool RDUser::localAuthentication() const
|
||||
{
|
||||
return RDBool(RDGetSqlValue("USERS","LOGIN_NAME",user_name,"LOCAL_AUTH").
|
||||
toString());
|
||||
}
|
||||
|
||||
|
||||
void RDUser::setLocalAuthentication(bool state) const
|
||||
{
|
||||
SetRow("LOCAL_AUTH",RDYesNo(state));
|
||||
}
|
||||
|
||||
|
||||
QString RDUser::pamService() const
|
||||
{
|
||||
return RDGetSqlValue("USERS","LOGIN_NAME",user_name,"PAM_SERVICE").toString();
|
||||
}
|
||||
|
||||
|
||||
void RDUser::setPamService(const QString &str) const
|
||||
{
|
||||
SetRow("PAM_SERVICE",str);
|
||||
}
|
||||
|
||||
|
||||
QString RDUser::fullName() const
|
||||
{
|
||||
return RDGetSqlValue("USERS","LOGIN_NAME",user_name,"FULL_NAME").toString();
|
||||
|
@@ -35,6 +35,10 @@ class RDUser
|
||||
void setPassword(const QString &password);
|
||||
bool enableWeb() const;
|
||||
void setEnableWeb(bool state) const;
|
||||
bool localAuthentication() const;
|
||||
void setLocalAuthentication(bool state) const;
|
||||
QString pamService() const;
|
||||
void setPamService(const QString &str) const;
|
||||
QString fullName() const;
|
||||
void setFullName(const QString &name) const;
|
||||
QString description() const;
|
||||
|
Reference in New Issue
Block a user