Skip to content

Commit

Permalink
interfaces: the renaming in one ifconfig may be unstable
Browse files Browse the repository at this point in the history
(cherry picked from commit a7ca166)
(cherry picked from commit 713f8b8)
  • Loading branch information
fichtner committed Aug 10, 2017
1 parent cb09b14 commit 065244e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/etc/inc/interfaces.lib.inc
Expand Up @@ -72,12 +72,19 @@ function legacy_interface_flags($ifs, $flag, $report_errors=true)
}
}

function legacy_interface_rename($ifs, $name)
{
$cmd = '/sbin/ifconfig ' . escapeshellarg($ifs) . ' name ' . escapeshellarg($name);

exec($cmd . ' 2>&1', $out, $ret);
if ($ret) {
log_error('The command `' . $cmd . '\' failed to execute');
}
}

function legacy_interface_create($ifs, $name = null)
{
$cmd = '/sbin/ifconfig ' . escapeshellarg($ifs) . ' create';
if (!empty($name)) {
$cmd .= ' name ' . escapeshellarg($name);
}
$new = null;

exec($cmd . ' 2>&1', $out, $ret);
Expand All @@ -90,6 +97,11 @@ function legacy_interface_create($ifs, $name = null)
$new = $out[0];
}

if (!empty($name)) {
legacy_interface_rename($new, $name);
$new = $name;
}

return ($new);
}

Expand Down

0 comments on commit 065244e

Please sign in to comment.