Skip to content

Commit

Permalink
Remove remote connection part from the admin.c
Browse files Browse the repository at this point in the history
  • Loading branch information
palak-chaturvedi committed Apr 3, 2024
1 parent 080beec commit c6535f6
Showing 1 changed file with 4 additions and 49 deletions.
53 changes: 4 additions & 49 deletions src/admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ main(int argc, char** argv)
struct main_configuration* config = NULL;
int ret;
size_t size;
bool remote_connection = false;
char* logfile = NULL;

while (1)
{
Expand Down Expand Up @@ -267,12 +265,6 @@ main(int argc, char** argv)
errx(1, "Using the root account is not allowed");
}

// and she cannot use "local" and "remote" connections at the same time
if (configuration_path != NULL && remote_connection)
{
errx(1, "Use either -c or -h/-p to define endpoint");
}

if (argc <= 1)
{
usage();
Expand All @@ -297,53 +289,16 @@ main(int argc, char** argv)
{
errx(1, "Too many sections in the configuration file <%s>", configuration_path);
}

if (logfile)
{
config = (struct main_configuration*)shmem;

config->common.log_type = PGAGROAL_LOGGING_TYPE_FILE;
memset(&config->common.log_path[0], 0, MISC_LENGTH);
memcpy(&config->common.log_path[0], logfile, MIN(MISC_LENGTH - 1, strlen(logfile)));
}

if (pgagroal_start_logging())
{
errx(1, "Cannot start the logging subsystem");
}

config = (struct main_configuration*)shmem;
}
else
{
ret = pgagroal_read_configuration(shmem, PGAGROAL_DEFAULT_CONF_FILE, false);
if (ret != PGAGROAL_CONFIGURATION_STATUS_OK)
{
if (!remote_connection)
{
errx(1, "Host (-h) and port (-p) must be specified to connect to the remote host");
}
}
else
{
configuration_path = PGAGROAL_DEFAULT_CONF_FILE;

if (logfile)
{
config = (struct main_configuration*)shmem;

config->common.log_type = PGAGROAL_LOGGING_TYPE_FILE;
memset(&config->common.log_path[0], 0, MISC_LENGTH);
memcpy(&config->common.log_path[0], logfile, MIN(MISC_LENGTH - 1, strlen(logfile)));
}

if (pgagroal_start_logging())
{
errx(1, "Cannot start the logging subsystem");
}

config = (struct main_configuration*)shmem;
if(ret == PGAGROAL_CONFIGURATION_STATUS_FILE_NOT_FOUND){
errx(1, "Configuration file not found");
}
config = (struct main_configuration*)shmem;

}

if (!parse_command(argc, argv, optind, &parsed, command_table, command_count))
Expand Down

0 comments on commit c6535f6

Please sign in to comment.