Remove the configuration options 'file_motd' and 'file_rules'. Use mod_welcome instead.
This commit is contained in:
parent
88dd1341d2
commit
2a190859bd
|
@ -898,20 +898,6 @@ static int command_userpass(struct command_base* cbase, struct hub_user* user, s
|
|||
return command_status(cbase, user, cmd, cbuf_create_const("Not implemented!"));
|
||||
}
|
||||
|
||||
static int command_rules(struct command_base* cbase, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
if (!hub_send_rules(cbase->hub, user))
|
||||
return command_status(cbase, user, cmd, cbuf_create_const("no rules defined."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int command_motd(struct command_base* cbase, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
if (!hub_send_motd(cbase->hub, user))
|
||||
return command_status(cbase, user, cmd, cbuf_create_const("no motd defined."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CRASH_DEBUG
|
||||
static int command_crash(struct command_base* cbase, struct hub_user* user, struct hub_command* cmd)
|
||||
{
|
||||
|
@ -965,12 +951,10 @@ void commands_builtin_add(struct command_base* cbase)
|
|||
ADD_COMMAND("history", 7, "?N",auth_cred_guest, command_history, "Show the last chat messages." );
|
||||
ADD_COMMAND("kick", 4, "n", auth_cred_operator, command_kick, "Kick a user" );
|
||||
ADD_COMMAND("log", 3, "", auth_cred_operator, command_log, "Display log" );
|
||||
ADD_COMMAND("motd", 4, "", auth_cred_guest, command_motd, "Show the message of the day" );
|
||||
ADD_COMMAND("mute", 4, "n", auth_cred_operator, command_mute, "Mute user" );
|
||||
ADD_COMMAND("myip", 4, "", auth_cred_guest, command_myip, "Show your own IP." );
|
||||
ADD_COMMAND("register", 8, "p", auth_cred_guest, command_register, "Register your username." );
|
||||
ADD_COMMAND("reload", 6, "", auth_cred_admin, command_reload, "Reload configuration files." );
|
||||
ADD_COMMAND("rules", 5, "", auth_cred_guest, command_rules, "Show the hub rules" );
|
||||
ADD_COMMAND("password", 8, "p", auth_cred_user, command_password, "Change your own password." );
|
||||
ADD_COMMAND("shutdown", 8, "", auth_cred_admin, command_shutdown_hub, "Shutdown hub." );
|
||||
ADD_COMMAND("stats", 5, "", auth_cred_super, command_stats, "Show hub statistics." );
|
||||
|
|
|
@ -453,24 +453,6 @@
|
|||
<since>0.3.0</since>
|
||||
</option>
|
||||
|
||||
<option name="file_motd" type="file" default="">
|
||||
<short>File containing the 'message of the day</short>
|
||||
<description><![CDATA[
|
||||
This can be specified as a message of the day file. If a valid file is given here it's content will be sent to all users after they have logged in to the hub. If the file is missing or empty this configuration entry will be ignored.
|
||||
]]></description>
|
||||
<since>0.1.3</since>
|
||||
<example><![CDATA[
|
||||
<p>
|
||||
Unix users: <br />
|
||||
file_acl = "/etc/uhub/motd.txt"
|
||||
</p>
|
||||
<p>
|
||||
Windows users: <br />
|
||||
file_acl = "c:\uhub\motd.txt"
|
||||
</p>
|
||||
]]></example>
|
||||
</option>
|
||||
|
||||
<option name="file_acl" type="file" default="">
|
||||
<short>File containing access control lists</short>
|
||||
<description><![CDATA[
|
||||
|
@ -491,25 +473,6 @@
|
|||
]]></example>
|
||||
</option>
|
||||
|
||||
<option name="file_rules" type="file" default="">
|
||||
<short>File containing hub rules</short>
|
||||
<description><![CDATA[
|
||||
This is a text file that is displayed on login as an extended message of the day.
|
||||
In addition the contents of the file is displayed when a user uses the "!rules" command.
|
||||
]]></description>
|
||||
<since>0.3.0</since>
|
||||
<example><![CDATA[
|
||||
<p>
|
||||
Unix users: <br />
|
||||
file_acl = "/etc/uhub/rules.txt"
|
||||
</p>
|
||||
<p>
|
||||
Windows users: <br />
|
||||
file_acl = "c:\uhub\rules.txt"
|
||||
</p>
|
||||
]]></example>
|
||||
</option>
|
||||
|
||||
<option name="file_plugins" type="file" default="">
|
||||
<short>Plugin configuration file</short>
|
||||
<description><![CDATA[
|
||||
|
|
|
@ -46,9 +46,7 @@ void config_defaults(struct hub_config* config)
|
|||
config->tls_require_redirect_addr = hub_strdup("");
|
||||
config->tls_certificate = hub_strdup("");
|
||||
config->tls_private_key = hub_strdup("");
|
||||
config->file_motd = hub_strdup("");
|
||||
config->file_acl = hub_strdup("");
|
||||
config->file_rules = hub_strdup("");
|
||||
config->file_plugins = hub_strdup("");
|
||||
config->msg_hub_full = hub_strdup("Hub is full");
|
||||
config->msg_hub_disabled = hub_strdup("Hub is disabled");
|
||||
|
@ -538,16 +536,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(key, "file_motd"))
|
||||
{
|
||||
if (!apply_string(key, data, &config->file_motd, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(key, "file_acl"))
|
||||
{
|
||||
if (!apply_string(key, data, &config->file_acl, (char*) ""))
|
||||
|
@ -558,16 +546,6 @@ static int apply_config(struct hub_config* config, char* key, char* data, int li
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(key, "file_rules"))
|
||||
{
|
||||
if (!apply_string(key, data, &config->file_rules, (char*) ""))
|
||||
{
|
||||
LOG_ERROR("Configuration parse error on line %d", line_count);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(key, "file_plugins"))
|
||||
{
|
||||
if (!apply_string(key, data, &config->file_plugins, (char*) ""))
|
||||
|
@ -961,12 +939,8 @@ void free_config(struct hub_config* config)
|
|||
|
||||
hub_free(config->tls_private_key);
|
||||
|
||||
hub_free(config->file_motd);
|
||||
|
||||
hub_free(config->file_acl);
|
||||
|
||||
hub_free(config->file_rules);
|
||||
|
||||
hub_free(config->file_plugins);
|
||||
|
||||
hub_free(config->msg_hub_full);
|
||||
|
@ -1177,15 +1151,9 @@ void dump_config(struct hub_config* config, int ignore_defaults)
|
|||
if (!ignore_defaults || strcmp(config->tls_private_key, "") != 0)
|
||||
fprintf(stdout, "tls_private_key = \"%s\"\n", config->tls_private_key);
|
||||
|
||||
if (!ignore_defaults || strcmp(config->file_motd, "") != 0)
|
||||
fprintf(stdout, "file_motd = \"%s\"\n", config->file_motd);
|
||||
|
||||
if (!ignore_defaults || strcmp(config->file_acl, "") != 0)
|
||||
fprintf(stdout, "file_acl = \"%s\"\n", config->file_acl);
|
||||
|
||||
if (!ignore_defaults || strcmp(config->file_rules, "") != 0)
|
||||
fprintf(stdout, "file_rules = \"%s\"\n", config->file_rules);
|
||||
|
||||
if (!ignore_defaults || strcmp(config->file_plugins, "") != 0)
|
||||
fprintf(stdout, "file_plugins = \"%s\"\n", config->file_plugins);
|
||||
|
||||
|
|
|
@ -46,9 +46,7 @@ struct hub_config
|
|||
char* tls_require_redirect_addr; /*<<< A redirect address in case a client connects using "adc://" when "adcs://" is required. (default: ) */
|
||||
char* tls_certificate; /*<<< Certificate file (default: ) */
|
||||
char* tls_private_key; /*<<< Private key file (default: ) */
|
||||
char* file_motd; /*<<< File containing the 'message of the day (default: ) */
|
||||
char* file_acl; /*<<< File containing access control lists (default: ) */
|
||||
char* file_rules; /*<<< File containing hub rules (default: ) */
|
||||
char* file_plugins; /*<<< Plugin configuration file (default: ) */
|
||||
char* msg_hub_full; /*<<< "Hub is full" */
|
||||
char* msg_hub_disabled; /*<<< "Hub is disabled" */
|
||||
|
|
|
@ -478,27 +478,6 @@ void hub_send_handshake(struct hub_info* hub, struct hub_user* u)
|
|||
}
|
||||
}
|
||||
|
||||
int hub_send_motd(struct hub_info* hub, struct hub_user* u)
|
||||
{
|
||||
if (hub->command_motd)
|
||||
{
|
||||
route_to_user(hub, u, hub->command_motd);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hub_send_rules(struct hub_info* hub, struct hub_user* u)
|
||||
{
|
||||
if (hub->command_rules)
|
||||
{
|
||||
route_to_user(hub, u, hub->command_rules);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void hub_send_password_challenge(struct hub_info* hub, struct hub_user* u)
|
||||
{
|
||||
struct adc_message* igpa;
|
||||
|
@ -905,8 +884,6 @@ void hub_plugins_unload(struct hub_info* hub)
|
|||
|
||||
void hub_set_variables(struct hub_info* hub, struct acl_handle* acl)
|
||||
{
|
||||
int fd, ret;
|
||||
char buf[MAX_RECV_BUF];
|
||||
char* tmp;
|
||||
char* server = adc_msg_escape(PRODUCT_STRING); /* FIXME: OOM */
|
||||
|
||||
|
@ -926,39 +903,6 @@ void hub_set_variables(struct hub_info* hub, struct acl_handle* acl)
|
|||
hub_free(tmp);
|
||||
}
|
||||
|
||||
/* (Re-)read the message of the day */
|
||||
hub->command_motd = 0;
|
||||
fd = (hub->config->file_motd && *hub->config->file_motd) ? open(hub->config->file_motd, 0) : -1;
|
||||
if (fd != -1)
|
||||
{
|
||||
ret = read(fd, buf, MAX_RECV_BUF);
|
||||
if (ret > 0)
|
||||
{
|
||||
buf[ret] = 0;
|
||||
tmp = adc_msg_escape(buf);
|
||||
hub->command_motd = adc_msg_construct(ADC_CMD_IMSG, 6 + strlen(tmp));
|
||||
adc_msg_add_argument(hub->command_motd, tmp);
|
||||
hub_free(tmp);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
hub->command_rules = 0;
|
||||
fd = (hub->config->file_rules && *hub->config->file_rules) ? open(hub->config->file_rules, 0) : -1;
|
||||
if (fd != -1)
|
||||
{
|
||||
ret = read(fd, buf, MAX_RECV_BUF);
|
||||
if (ret > 0)
|
||||
{
|
||||
buf[ret] = 0;
|
||||
tmp = adc_msg_escape(buf);
|
||||
hub->command_rules = adc_msg_construct(ADC_CMD_IMSG, 6 + strlen(tmp));
|
||||
adc_msg_add_argument(hub->command_rules, tmp);
|
||||
hub_free(tmp);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
hub->command_support = adc_msg_construct(ADC_CMD_ISUP, 6 + strlen(ADC_PROTO_SUPPORT));
|
||||
if (hub->command_support)
|
||||
{
|
||||
|
@ -994,13 +938,6 @@ void hub_free_variables(struct hub_info* hub)
|
|||
|
||||
adc_msg_free(hub->command_info);
|
||||
adc_msg_free(hub->command_banner);
|
||||
|
||||
if (hub->command_motd)
|
||||
adc_msg_free(hub->command_motd);
|
||||
|
||||
if (hub->command_rules)
|
||||
adc_msg_free(hub->command_rules);
|
||||
|
||||
adc_msg_free(hub->command_support);
|
||||
}
|
||||
|
||||
|
|
|
@ -103,8 +103,6 @@ struct hub_info
|
|||
struct acl_handle* acl;
|
||||
struct adc_message* command_info; /* The hub's INF command */
|
||||
struct adc_message* command_support; /* The hub's SUP command */
|
||||
struct adc_message* command_motd; /* The message of the day */
|
||||
struct adc_message* command_rules; /* The hub rules */
|
||||
struct adc_message* command_banner; /* The default welcome message */
|
||||
time_t tm_started;
|
||||
int status;
|
||||
|
@ -205,19 +203,6 @@ extern void hub_send_hubinfo(struct hub_info* hub, struct hub_user* u);
|
|||
*/
|
||||
extern void hub_send_handshake(struct hub_info* hub, struct hub_user* u);
|
||||
|
||||
/**
|
||||
* Send a welcome message containing the message of the day to
|
||||
* one particular user. This can be sent in any point in time.
|
||||
* @return 1 if the motd were sent.
|
||||
*/
|
||||
extern int hub_send_motd(struct hub_info* hub, struct hub_user* u);
|
||||
|
||||
/**
|
||||
* Send the rules if configured.
|
||||
* @return 1 if the rules were sent.
|
||||
*/
|
||||
extern int hub_send_rules(struct hub_info* hub, struct hub_user* u);
|
||||
|
||||
/**
|
||||
* Send a password challenge to a user.
|
||||
* This is only used if the user tries to access the hub using a
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "uhub.h"
|
||||
#include "plugin_api/handle.h"
|
||||
|
||||
/* Send MOTD, do logging etc */
|
||||
/* Notify plugins, etc */
|
||||
void on_login_success(struct hub_info* hub, struct hub_user* u)
|
||||
{
|
||||
/* Send user list of all existing users */
|
||||
|
@ -31,19 +31,11 @@ void on_login_success(struct hub_info* hub, struct hub_user* u)
|
|||
user_set_state(u, state_normal);
|
||||
uman_add(hub, u);
|
||||
|
||||
plugin_log_user_login_success(hub, u);
|
||||
|
||||
/* Announce new user to all connected users */
|
||||
if (user_is_logged_in(u))
|
||||
route_info_message(hub, u);
|
||||
|
||||
/* Send message of the day (if any) */
|
||||
if (user_is_logged_in(u)) /* Previous send() can fail! */
|
||||
hub_send_motd(hub, u);
|
||||
|
||||
/* Send message of the day (if any) */
|
||||
if (user_is_logged_in(u)) /* Previous send() can fail! */
|
||||
hub_send_rules(hub, u);
|
||||
plugin_log_user_login_success(hub, u);
|
||||
|
||||
/* reset timeout */
|
||||
net_con_clear_timeout(u->connection);
|
||||
|
|
Loading…
Reference in New Issue