Skip to content

Commit

Permalink
Don't insist on getting a DBus address via env
Browse files Browse the repository at this point in the history
It doesn't seem to be actually used anywhere in the code? The daemon
code already does the sensible thing and just uses library functions to
say "connect to system bus". The only use case for such a setup I could
see would be testing, but there's no test harness that makes use of
this.

Change-Id: I1098fdc33980e2f065a09bd9c0b698b5f5977d53
  • Loading branch information
fajs committed Oct 18, 2023
1 parent 411a739 commit 99b6a73
Showing 1 changed file with 7 additions and 28 deletions.
35 changes: 7 additions & 28 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
* capability.
*
* Usage:
* - SAVE mode: DBUS_SESSION_BUS_ADDRESS=<dbus address> conntrack_migrator 2 <dbus_helper_id> <num_ip_addresses> <space separated ip address list>
* - LOAD mode: DBUS_SESSION_BUS_ADDRESS=<dbus address> conntrack_migrator 1 <dbus_helper_id>
* - SAVE mode: conntrack_migrator 2 <dbus_helper_id> <num_ip_addresses> <space separated ip address list>
* - LOAD mode: conntrack_migrator 1 <dbus_helper_id>
*
* eg:
* - SAVE mode: DBUS_SESSION_BUS_ADDRESS=unix:abstract=/abc,guid=def conntrack_migrator 2 helper1 2 1.1.1.1 2.2.2.2
* - LOAD mode: DBUS_SESSION_BUS_ADDRESS=unix:abstract=/abc,guid=def conntrack_migrator 1 helper1
* - SAVE mode: conntrack_migrator 2 helper1 2 1.1.1.1 2.2.2.2
* - LOAD mode: conntrack_migrator 1 helper1
*/

#define _GNU_SOURCE
Expand Down Expand Up @@ -334,8 +334,6 @@ dmain(int argc, char *argv[])
set_log_level(lmct_conf.log_lvl);

LOG(INFO, "%s: Starting in mode %s", __func__, mode_to_string[mode]);
LOG(INFO, "%s: dbus address %s", __func__,
getenv("DBUS_SYSTEM_BUS_ADDRESS"));
LOG(INFO, "%s: helper id: %s", __func__, helper_id);
LOG(INFO, "%s: Maximum CT entries migratable: %d", __func__,
lmct_conf.max_entries_to_migrate);
Expand Down Expand Up @@ -392,12 +390,9 @@ err_usage(void)
{
errx(EXIT_FAILURE,
"Usage:\n"
"SAVE mode: DBUS_SYSTEM_BUS_ADDRESS=<dbus address> "
"conntrack_migrator 2 <dbus_helper_id> <num_ip_addresses> "
"SAVE mode: conntrack_migrator 2 <dbus_helper_id> <num_ip_addresses> "
"<space separated ip address list>\n"
"LOAD mode: DBUS_SYSTEM_BUS_ADDRESS=<dbus address> "
"conntrack_migrator 1 <dbus_helper_id>\n"
"NOTE: DBUS_SYSTEM_BUS_ADDRESS env variable should be set.\n");
"LOAD mode: conntrack_migrator 1 <dbus_helper_id>\n");
}

/**
Expand All @@ -415,19 +410,6 @@ check_mode(int mode)
}
}

/**
* Checks if the DBUS_SYSTEM_BUS_ADDRESS env variable is set.
*/
static void
check_dbus_address_env(void)
{
const char *dbus_address = getenv("DBUS_SYSTEM_BUS_ADDRESS");
if (dbus_address == NULL || strcmp(dbus_address, "") == 0) {
errx(EXIT_FAILURE, "DBUS_SYSTEM_BUS_ADDRESS environment variable not "
"set\n");
}
}

/**
* Performs checks on args when started in save mode.
*
Expand Down Expand Up @@ -464,8 +446,7 @@ check_save_mode_args(int argc, char *argv[])
*
* Checks performed:
* 1. Mode is vaild
* 2. DBUS_SYSTEM_BUS_ADDRESS env is set
* 3. SAVE mode has proper arguments
* 2. SAVE mode has proper arguments
*
* Args:
* @argc num of arguemnts
Expand All @@ -480,8 +461,6 @@ check_args(int argc, char *argv[])
err_usage();
}

check_dbus_address_env();

mode = atoi(argv[MODE_ARG_INDEX]);
check_mode(mode);

Expand Down

0 comments on commit 99b6a73

Please sign in to comment.