conf: adapt to lxc-user-nic usage

- lxc-user-nic gains the subcommands {create,delete} - dup2() STDERR_FILENO as well so that we can show helpful messages in our logs on failure - initialize output buffer so that we don't print garbage Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent f703d990
......@@ -3277,8 +3277,8 @@ static int unpriv_assign_nic(const char *lxcpath, char *lxcname,
pid_t child;
int bytes, pipefd[2];
char *token, *saveptr = NULL;
char buffer[MAX_BUFFER_SIZE];
char netdev_link[IFNAMSIZ + 1];
char buffer[MAX_BUFFER_SIZE] = {0};
if (netdev->type != LXC_NET_VETH) {
ERROR("nic type %d not support for unprivileged use",
......@@ -3308,6 +3308,8 @@ static int unpriv_assign_nic(const char *lxcpath, char *lxcname,
/* Redirect stdout to write-end of the pipe. */
ret = dup2(pipefd[1], STDOUT_FILENO);
if (ret >= 0)
ret = dup2(pipefd[1], STDERR_FILENO);
close(pipefd[1]); /* Close the write-end of the pipe. */
if (ret < 0) {
SYSERROR("Failed to dup2() to redirect stdout to pipe file descriptor.");
......@@ -3351,7 +3353,8 @@ static int unpriv_assign_nic(const char *lxcpath, char *lxcname,
buffer[bytes - 1] = '\0';
if (wait_for_pid(child) != 0) {
TRACE("lxc-user-nic failed to configure requested network");
ERROR("lxc-user-nic failed to configure requested network: %s",
buffer[0] != '\0' ? buffer : "(null)");
close(pipefd[0]);
return -1;
}
......
......@@ -940,7 +940,7 @@ int main(int argc, char *argv[])
{
int fd, n, pid, ret;
char *me;
char *cnic = NULL, *nicname = NULL, *vethname = NULL;
char *cnic = NULL, *nicname = NULL;
struct alloted_s *alloted = NULL;
struct user_nic_args args;
......
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