#1019 Fix queued Wake on LAN

UMA and UPV report that Wake on LAN command (in queue mode) does not
work.

We improved WoL command, now ogServer calculates the broadcast address
of the network to which the client belongs. To calculate this address
ogServer needs the IP and the netmask of the client. We updated ogServer
to retrieve the netmask from the database in non-queue mode, but we forgot
to add this in queue mode.

This patch adds netmask retrieving to queued WoL.
master
Javier Sánchez Parra 2021-02-22 10:12:56 +01:00 committed by OpenGnSys Support Team
parent e4cb91b5f6
commit ed0d86b010
1 changed files with 28 additions and 0 deletions

View File

@ -2138,6 +2138,7 @@ void og_cmd_free(const struct og_cmd *cmd)
int i;
for (i = 0; i < params->ips_array_len; i++) {
free((void *)params->netmask_array[i]);
free((void *)params->ips_array[i]);
free((void *)params->mac_array[i]);
}
@ -2164,16 +2165,43 @@ static void og_cmd_init(struct og_cmd *cmd, enum og_rest_method method,
static int og_cmd_legacy_wol(const char *input, struct og_cmd *cmd)
{
char wol_type[2] = {};
const char *msglog;
struct og_dbi *dbi;
dbi_result result;
if (sscanf(input, "mar=%s", wol_type) != 1) {
syslog(LOG_ERR, "malformed database legacy input\n");
return -1;
}
dbi = og_dbi_open(&ogconfig.db);
if (!dbi) {
syslog(LOG_ERR, "cannot open connection database (%s:%d)\n",
__func__, __LINE__);
return -1;
}
result = dbi_conn_queryf(dbi->conn,
"SELECT mascara FROM ordenadores "
"WHERE ip = '%s'", cmd->ip);
if (!result) {
dbi_conn_error(dbi->conn, &msglog);
syslog(LOG_ERR, "failed to query database (%s:%d) %s\n",
__func__, __LINE__, msglog);
og_dbi_close(dbi);
return -1;
}
dbi_result_next_row(result);
og_cmd_init(cmd, OG_METHOD_NO_HTTP, OG_CMD_WOL, NULL);
cmd->params.netmask_array[0] = dbi_result_get_string_copy(result,
"mascara");
cmd->params.mac_array[0] = strdup(cmd->mac);
cmd->params.wol_type = strdup(wol_type);
dbi_result_free(result);
og_dbi_close(dbi);
return 0;
}