#endif /* ifdef _WIN32 */
-static void
-man_record_peer_info(struct management *man)
-{
- struct gc_arena gc = gc_new();
- if (man->settings.write_peer_info_file)
- {
- bool success = false;
-#ifdef HAVE_GETSOCKNAME
- if (socket_defined(man->connection.sd_cli))
- {
- struct sockaddr_in addr;
- socklen_t addrlen = sizeof(addr);
- int status;
-
- CLEAR(addr);
- status = getsockname(man->connection.sd_cli, (struct sockaddr *)&addr, &addrlen);
- if (!status && addrlen == sizeof(addr))
- {
- const in_addr_t a = ntohl(addr.sin_addr.s_addr);
- const int p = ntohs(addr.sin_port);
- FILE *fp = platform_fopen(man->settings.write_peer_info_file, "w");
- if (fp)
- {
- fprintf(fp, "%s\n%d\n", print_in_addr_t(a, 0, &gc), p);
- if (!fclose(fp))
- {
- success = true;
- }
- }
- }
- }
-#endif /* ifdef HAVE_GETSOCKNAME */
- if (!success)
- {
- msg(D_MANAGEMENT, "MANAGEMENT: failed to write peer info to file %s",
- man->settings.write_peer_info_file);
- throw_signal_soft(SIGTERM, "management-connect-failed");
- }
- }
- gc_free(&gc);
-}
-
static void
man_connection_settings_reset(struct management *man)
{
goto done;
}
- man_record_peer_info(man);
man_new_connection_post(man, "Connected to management server at");
done:
const int log_history_cache,
const int echo_buffer_size,
const int state_buffer_size,
- const char *write_peer_info_file,
const int remap_sigusr1,
const unsigned int flags)
{
ASSERT(ms->client_gid >= 0);
}
- ms->write_peer_info_file = string_alloc(write_peer_info_file, NULL);
-
#if UNIX_SOCK_SUPPORT
if (ms->flags & MF_UNIX_SOCK)
{
{
freeaddrinfo(ms->local);
}
- free(ms->write_peer_info_file);
CLEAR(*ms);
}
const int log_history_cache,
const int echo_buffer_size,
const int state_buffer_size,
- const char *write_peer_info_file,
const int remap_sigusr1,
const unsigned int flags)
{
log_history_cache,
echo_buffer_size,
state_buffer_size,
- write_peer_info_file,
remap_sigusr1,
flags);
SHOW_STR(management_user_pass);
SHOW_INT(management_log_history_cache);
SHOW_INT(management_echo_buffer_size);
- SHOW_STR(management_write_peer_info_file);
SHOW_STR(management_client_user);
SHOW_STR(management_client_group);
SHOW_INT(management_flags);
#ifdef ENABLE_MANAGEMENT
if (!options->management_addr
&& (options->management_flags
- || options->management_write_peer_info_file
|| options->management_log_history_cache != defaults.management_log_history_cache))
{
msg(M_USAGE, "--management is not specified, however one or more options which modify the behavior of --management were specified");
VERIFY_PERMISSION(OPT_P_GENERAL);
options->management_flags |= MF_UP_DOWN;
}
- else if (streq(p[0], "management-client") && !p[2])
+ else if (streq(p[0], "management-client") && !p[1])
{
VERIFY_PERMISSION(OPT_P_GENERAL);
options->management_flags |= MF_CONNECT_AS_CLIENT;
- options->management_write_peer_info_file = p[1];
}
#ifdef ENABLE_MANAGEMENT
else if (streq(p[0], "management-external-key"))