Commit 9498ae91 authored by Adam Wujek's avatar Adam Wujek

userspace/tools/radiusvlan: add dry run mode

In dry run mode no changes to the VLAN configuration are applied.
Signed-off-by: 's avatarAdam Wujek <dev_public@wujek.eu>
parent 7ab8f90e
......@@ -489,6 +489,13 @@ In the above example, two interface were up and authorization failed for
both (as seen, @i{radclient} did @t{exit(1)}). Both interfaces
are configured in vlan 4094.
@c ==========================================================================
@node Dry-run Operation
@section Dry-run Operation
If @t{RVLAN_DRYRUN} is set to a non-empty value in the
tool's environment, no changes to the vlan configuration will be done.
@c ==========================================================================
@node Forcing Re-Authorizazion
@section Forcing Re-Authorizazion
......
......@@ -34,6 +34,7 @@
/* This is a set of global variables, that convey program status */
char *prgname; /* argv[0], for my laziness */
int verbose;
int dryrun;
int rvlan_pmask = ~0;
int rvlan_change_pending; /* wrsw_vlans must be called globally */
char *rvlan_radius_secret;
......@@ -172,7 +173,8 @@ int rvlan_change_vlan(struct rvlan_dev *dev)
sprintf(cmdstr, "/wr/bin/wrs_vlans --port %i --pvid %i "
" > /tmp/rvlan-cmd-stdout 2> /tmp/rvlan-cmd-stderr",
dev->portnr, dev->chosen_vlan);
if (system(cmdstr)) {
if (!dryrun && system(cmdstr)) {
fprintf(stderr, "%s: can't set vlan %i for %i (%s)\n",
prgname, dev->chosen_vlan, dev->portnr,
dev->name);
......@@ -810,6 +812,9 @@ int main(int argc, char **argv)
prgname = argv[0];
verbose = getenv("RVLAN_VERBOSE") != NULL;
dryrun = getenv("RVLAN_DRYRUN") != NULL;
if (dryrun)
printf("Enable dryrun\n");
setlinebuf(stdout);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment