Skip to content

Commit

Permalink
coverity: #1425758
Browse files Browse the repository at this point in the history
Time of check time of use

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Jun 15, 2018
1 parent efdb491 commit f4ea735
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/lxc/conf.c
Expand Up @@ -924,25 +924,17 @@ static int lxc_setup_ttys(struct lxc_conf *conf)
/* If we populated /dev, then we need to create
* /dev/ttyN
*/
ret = access(path, F_OK);
if (ret < 0) {
ret = creat(path, 0660);
if (ret < 0) {
SYSERROR("Failed to create \"%s\"", path);
/* this isn't fatal, continue */
} else {
close(ret);
}
}
ret = mknod(path, S_IFREG | 0000, 0);
if (ret < 0) /* this isn't fatal, continue */
ERROR("%s - Failed to create \"%s\"", strerror(errno), path);

ret = mount(tty->name, path, "none", MS_BIND, 0);
if (ret < 0) {
SYSERROR("Failed to mount '%s'->'%s'", tty->name, path);
continue;
}

DEBUG("Bind mounted \"%s\" onto \"%s\"", tty->name,
path);
DEBUG("Bind mounted \"%s\" onto \"%s\"", tty->name, path);
}

if (!append_ttyname(&conf->ttys.tty_names, tty->name)) {
Expand Down

0 comments on commit f4ea735

Please sign in to comment.