mirror of
git://github.com/lxc/lxc
synced 2025-09-02 22:19:33 +00:00
Update the openvswitch bridge attach code
1. don't determine ovs-vsctl path at configure time, do it at runtime 2. lxc-user-nic: set a sane path to protect from unpriv users Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> Acked-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
committed by
Stéphane Graber
parent
361e0e3c08
commit
6ad22d063a
11
configure.ac
11
configure.ac
@@ -204,16 +204,6 @@ fi
|
|||||||
|
|
||||||
AM_CONDITIONAL([ENABLE_API_DOCS], [test "x$HAVE_DOXYGEN" != "x"])
|
AM_CONDITIONAL([ENABLE_API_DOCS], [test "x$HAVE_DOXYGEN" != "x"])
|
||||||
|
|
||||||
# Openvswitch
|
|
||||||
AC_PATH_PROG([OVS_CTL_PATH],[ovs-vsctl])
|
|
||||||
if test "x$OVS_CTL_PATH" != "x"; then
|
|
||||||
enable_ovs="yes"
|
|
||||||
AS_AC_EXPAND(OVS_CTL_PATH, "$OVS_CTL_PATH")
|
|
||||||
else
|
|
||||||
enable_ovs="no"
|
|
||||||
fi
|
|
||||||
AM_CONDITIONAL([HAVE_OVS], [test "x$enable_ovs" = "xyes"])
|
|
||||||
|
|
||||||
# Apparmor
|
# Apparmor
|
||||||
AC_ARG_ENABLE([apparmor],
|
AC_ARG_ENABLE([apparmor],
|
||||||
[AC_HELP_STRING([--enable-apparmor], [enable apparmor support [default=auto]])],
|
[AC_HELP_STRING([--enable-apparmor], [enable apparmor support [default=auto]])],
|
||||||
@@ -782,7 +772,6 @@ Environment:
|
|||||||
- rpath: $enable_rpath
|
- rpath: $enable_rpath
|
||||||
- GnuTLS: $enable_gnutls
|
- GnuTLS: $enable_gnutls
|
||||||
- Bash integration: $enable_bash
|
- Bash integration: $enable_bash
|
||||||
- Openvswitch: $enable_ovs
|
|
||||||
|
|
||||||
Security features:
|
Security features:
|
||||||
- Apparmor: $enable_apparmor
|
- Apparmor: $enable_apparmor
|
||||||
|
@@ -129,10 +129,6 @@ if ENABLE_APPARMOR
|
|||||||
AM_CFLAGS += -DHAVE_APPARMOR
|
AM_CFLAGS += -DHAVE_APPARMOR
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if HAVE_OVS
|
|
||||||
AM_CFLAGS += -DHAVE_OVS -DOVS_CTL_PATH=\"$(OVS_CTL_PATH)\"
|
|
||||||
endif
|
|
||||||
|
|
||||||
if ENABLE_CGMANAGER
|
if ENABLE_CGMANAGER
|
||||||
AM_CFLAGS += -DHAVE_CGMANAGER
|
AM_CFLAGS += -DHAVE_CGMANAGER
|
||||||
endif
|
endif
|
||||||
|
@@ -590,6 +590,11 @@ int main(int argc, char *argv[])
|
|||||||
char *vethname = NULL;
|
char *vethname = NULL;
|
||||||
int pid;
|
int pid;
|
||||||
|
|
||||||
|
/* set a sane path, because we are setuid-root */
|
||||||
|
if (setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 1) < 0) {
|
||||||
|
fprintf(stderr, "Failed to set PATH, exiting\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
if ((me = get_username()) == NULL) {
|
if ((me = get_username()) == NULL) {
|
||||||
fprintf(stderr, "Failed to get username\n");
|
fprintf(stderr, "Failed to get username\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@@ -1171,7 +1171,6 @@ int lxc_ipv6_dest_add(int ifindex, struct in6_addr *dest)
|
|||||||
return ip_route_dest_add(AF_INET6, ifindex, dest);
|
return ip_route_dest_add(AF_INET6, ifindex, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_OVS
|
|
||||||
static bool is_ovs_bridge(const char *bridge)
|
static bool is_ovs_bridge(const char *bridge)
|
||||||
{
|
{
|
||||||
char brdirname[22 + IFNAMSIZ + 1] = {0};
|
char brdirname[22 + IFNAMSIZ + 1] = {0};
|
||||||
@@ -1186,7 +1185,12 @@ static bool is_ovs_bridge(const char *bridge)
|
|||||||
static int attach_to_ovs_bridge(const char *bridge, const char *nic)
|
static int attach_to_ovs_bridge(const char *bridge, const char *nic)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
const char *progname;
|
char *cmd;
|
||||||
|
|
||||||
|
cmd = on_path("ovs-vsctl", NULL);
|
||||||
|
if (!cmd)
|
||||||
|
return -1;
|
||||||
|
free(cmd);
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
@@ -1194,21 +1198,11 @@ static int attach_to_ovs_bridge(const char *bridge, const char *nic)
|
|||||||
if (pid > 0)
|
if (pid > 0)
|
||||||
return wait_for_pid(pid);
|
return wait_for_pid(pid);
|
||||||
|
|
||||||
progname = strrchr(OVS_CTL_PATH, '/');
|
if (execlp("ovs-vsctl", "ovs-vsctl", "add-port", bridge, nic, NULL))
|
||||||
if (!progname) // not sane, should we just fail?
|
|
||||||
progname = OVS_CTL_PATH;
|
|
||||||
if (execl(OVS_CTL_PATH, progname, "add-port", bridge, nic, NULL))
|
|
||||||
exit(1);
|
exit(1);
|
||||||
// not reached
|
// not reached
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
static inline bool is_ovs_bridge(const char *bridge) { return false; }
|
|
||||||
static inline int attach_to_ovs_bridge(const char *bridge, const char *nic)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There is a lxc_bridge_attach, but no need of a bridge detach
|
* There is a lxc_bridge_attach, but no need of a bridge detach
|
||||||
|
Reference in New Issue
Block a user