Author: soliton
Date: Tue Sep  2 12:09:44 2008
New Revision: 29188

URL: http://svn.gna.org/viewcvs/wesnoth?rev=29188&view=rev
Log:
* give the socket an invalid username to ensure it is unique
* restrict shut_down and restart commands to use via the socket only
* update the command help for unprivileged users

Modified:
    trunk/src/server/server.cpp

Modified: trunk/src/server/server.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/server/server.cpp?rev=29188&r1=29187&r2=29188&view=diff
==============================================================================
--- trunk/src/server/server.cpp (original)
+++ trunk/src/server/server.cpp Tue Sep  2 12:09:44 2008
@@ -611,7 +611,7 @@
                        // Process commands from the server socket/fifo
                        std::string admin_cmd;
                        if (input_.read_line(admin_cmd)) {
-                               process_command(admin_cmd, "socket");
+                               process_command(admin_cmd, "*socket*");
                        }
 
                        time_t now = time(NULL); 
@@ -1111,7 +1111,7 @@
        const simple_wml::string_span& command(query["type"]);
        std::ostringstream response;
        const std::string& help_msg = "Available commands are: help, metrics,"
-                       " motd, status, wml.";
+                       " motd, netstats [all], status, wml.";
        if (admins_.count(sock) != 0) {
                LOG_SERVER << "Admin Command:" << "\ttype: " << command
                        << "\tIP: "<< network::ip_address(sock) 
@@ -1163,8 +1163,9 @@
        const std::string& help_msg = "Available commands are: ban(s) [<mask>] 
[<time>] <reason>,"
                        "kick <mask>, k(ick)ban [<mask>] [<time>] <reason>, 
help, metrics, netstats,"
                        " (lobby)msg <message>, motd [<message>], status 
[<mask>],"
-                       " unban <ipmask>, shut_down [now], restart";
-       if (command == "shut_down") {
+                       " unban <ipmask>";
+       // Shutdown and restart commands can only be issued via the socket.
+       if (command == "shut_down" && issuer_name == "*socket*") {
                if (parameters == "now") {
                        throw network::error("shut down");
                } else {
@@ -1178,7 +1179,7 @@
 
 #ifndef _WIN32  // Not sure if this works on windows
                // TODO: check if this works in windows.
-       } else if (command == "restart") {
+       } else if (command == "restart" && issuer_name == "*socket*") {
                if (restart_command.empty()) {
                        out << "No restart_command configured! Not restarting.";
                } else {


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to