Socat lock files generated with -L and -W now have mode 644

This commit is contained in:
Gerhard Rieger 2023-01-16 01:36:37 +01:00
parent 3678757fed
commit 4565c8e6ac
2 changed files with 7 additions and 2 deletions

View file

@ -49,6 +49,11 @@ Corrections:
derived from option commonname or rom target server name. This is not derived from option commonname or rom target server name. This is not
useful with IP addresses, which Socat now checks and avoids. useful with IP addresses, which Socat now checks and avoids.
Socat options -L and -W create lock files using mkstemp(), so they had
permissions 600. There does not seem to be a good reason for this
restrictive mode. Furthermore Silla Rizzoli experienced that Minicom
ignores lock files with mode 600, so it is set to 644 now.
Features: Features:
VSOCK, VSOCK-L support options pf, socktype, prototype (currently VSOCK, VSOCK-L support options pf, socktype, prototype (currently
useless) useless)

View file

@ -51,14 +51,14 @@ int xiogetlock(const char *lockfile) {
} }
pid = Getpid(); pid = Getpid();
bytes = sprintf(pidbuf, F_pid, pid); bytes = sprintf(pidbuf, F_pid"\n", pid);
if (writefull(fd, pidbuf, bytes) < 0) { if (writefull(fd, pidbuf, bytes) < 0) {
Error4("write(%d, %p, "F_Zu"): %s", fd, pidbuf, bytes, strerror(errno)); Error4("write(%d, %p, "F_Zu"): %s", fd, pidbuf, bytes, strerror(errno));
return -1; return -1;
} }
Fchmod(fd, 0644);
Close(fd); Close(fd);
/* Chmod(lockfile, 0600); */
if (Link(s, lockfile) < 0) { if (Link(s, lockfile) < 0) {
int _errno = errno; int _errno = errno;
Error3("link(\"%s\", \"%s\"): %s", s, lockfile, strerror(errno)); Error3("link(\"%s\", \"%s\"): %s", s, lockfile, strerror(errno));