This patch prevents overwriting socket files by running two instances with
the same name.
Reported-by: Osier Yang <jyang@redhat.com>
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
sprintf(full_name, "%s", kvm__get_dir());
mkdir(full_name, 0777);
sprintf(full_name, "%s/%s.sock", kvm__get_dir(), kvm->name);
+ if (access(full_name, F_OK) == 0)
+ die("Socket file %s already exist", full_name);
+
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0)
return s;