2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Author : Maxim Mamontov <faust@stargazer.dp.ua>
24 #include "stg/module_settings.h"
25 #include "stg/logger.h"
37 #include <sys/select.h>
38 #include <sys/types.h>
47 class RADIUS : public STG::Auth {
52 void SetUsers(STG::Users* u) { m_users = u; }
53 void SetStore(STG::Store* s) { m_store = s; }
54 void SetStgSettings(const STG::Settings*) {}
55 void SetSettings(const STG::ModuleSettings& s) { m_settings = s; }
60 int Reload(const STG::ModuleSettings & /*ms*/) { return 0; }
61 bool IsRunning() { return m_running; }
63 const std::string& GetStrError() const { return m_error; }
64 std::string GetVersion() const { return "RADIUS data access plugin v. 2.0"; }
65 uint16_t GetStartPosition() const { return 30; }
66 uint16_t GetStopPosition() const { return 30; }
68 int SendMessage(const STG::Message&, uint32_t) const { return 0; }
70 void authorize(const STG::User& user);
71 void unauthorize(const std::string& login, const std::string& reason);
74 RADIUS(const RADIUS & rvalue);
75 RADIUS & operator=(const RADIUS & rvalue);
77 static void* run(void*);
80 int createUNIX() const;
81 int createTCP() const;
84 void buildFDSet(fd_set & fds) const;
86 void handleEvents(const fd_set & fds);
87 void acceptConnection();
91 mutable std::string m_error;
94 STG::ModuleSettings m_settings;
100 const STG::Store* m_store;
103 std::deque<STG::Conn*> m_conns;
104 std::set<std::string> m_logins;
108 STG::PluginLogger m_logger;