Commit c073c147 by Serge Hallyn

lxc_user_nic changes

1. catch a case if allowed number of nics is 0 (as opposed to no entry), which previously would have allowed the user to sneak in one entry. 2. return false, not true, if something went heywire with creating the /sys/class/net/$nic path to open. Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
parent 241c3744
......@@ -189,7 +189,7 @@ static bool nic_exists(char *nic)
ret = snprintf(path, MAXPATHLEN, "/sys/class/net/%s", nic);
if (ret < 0 || ret >= MAXPATHLEN) // should never happen!
return true;
return false;
ret = stat(path, &sb);
if (ret != 0)
return false;
......@@ -379,6 +379,9 @@ static bool get_nic_if_avail(int fd, char *me, int pid, char *intype, char *br,
cull_entries(fd, me, intype, br);
if (allowed == 0)
return false;
fstat(fd, &sb);
len = sb.st_size;
if (len != 0) {
......@@ -393,7 +396,6 @@ static bool get_nic_if_avail(int fd, char *me, int pid, char *intype, char *br,
return false;
}
get_new_nicname(nicname, br, pid, cnic);
/* me ' ' intype ' ' br ' ' *nicname + '\n' + '\0' */
slen = strlen(me) + strlen(intype) + strlen(br) + strlen(*nicname) + 5;
......
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