[lxc-devel] [PATCH 1/1] don't skip setting network properties in unpriv case
Stéphane Graber
stgraber at ubuntu.com
Tue Feb 18 04:39:34 UTC 2014
On Mon, Feb 17, 2014 at 10:33:20PM -0600, Serge Hallyn wrote:
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>
Yay, my last unprivileged LXC bug bites the dust!
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
> ---
> src/lxc/conf.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/src/lxc/conf.c b/src/lxc/conf.c
> index 8529a43..d40e3e0 100644
> --- a/src/lxc/conf.c
> +++ b/src/lxc/conf.c
> @@ -2374,16 +2374,19 @@ static int setup_netdev(struct lxc_netdev *netdev)
> return -1;
> }
> }
> - return 0;
> + if (netdev->type != LXC_NET_VETH)
> + return 0;
> + netdev->ifindex = if_nametoindex(netdev->name);
> }
>
> /* get the new ifindex in case of physical netdev */
> - if (netdev->type == LXC_NET_PHYS)
> + if (netdev->type == LXC_NET_PHYS) {
> if (!(netdev->ifindex = if_nametoindex(netdev->link))) {
> ERROR("failed to get ifindex for %s",
> netdev->link);
> return -1;
> }
> + }
>
> /* retrieve the name of the interface */
> if (!if_indextoname(netdev->ifindex, current_ifname)) {
> @@ -2398,11 +2401,13 @@ static int setup_netdev(struct lxc_netdev *netdev)
> netdev->link : "eth%d";
>
> /* rename the interface name */
> - err = lxc_netdev_rename_by_name(ifname, netdev->name);
> - if (err) {
> - ERROR("failed to rename %s->%s : %s", ifname, netdev->name,
> - strerror(-err));
> - return -1;
> + if (strcmp(ifname, netdev->name) != 0) {
> + err = lxc_netdev_rename_by_name(ifname, netdev->name);
> + if (err) {
> + ERROR("failed to rename %s->%s : %s", ifname, netdev->name,
> + strerror(-err));
> + return -1;
> + }
> }
>
> /* Re-read the name of the interface because its name has changed
> --
> 1.9.rc1
>
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140217/3fcc7bbf/attachment.pgp>
More information about the lxc-devel
mailing list