Skip to content

Commit 9407d35

Browse files
committed
revert unix-sock-make-chmod-chown
This change doesn't work for unix sockets, revert it.
1 parent da9c0cc commit 9407d35

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

lib/core-net/network.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -440,18 +440,10 @@ lws_socket_bind(struct lws_vhost *vhost, struct lws *wsi,
440440
}
441441
}
442442
if (iface && iface[0] != '@' && uid && gid) {
443-
int fdu = open(iface, O_RDWR);
444-
445-
if (fdu < 0) {
446-
lwsl_wsi_err(wsi, "failed to open %s", iface);
447-
448-
return LWS_ITOSA_NOT_EXIST;
449-
}
450-
if (fchown(fdu, uid, gid)) {
443+
if (chown(iface, uid, gid)) {
451444
lwsl_wsi_err(wsi, "failed to set %s perms %u:%u",
452445
iface, (unsigned int)uid,
453446
(unsigned int)gid);
454-
close(fdu);
455447

456448
return LWS_ITOSA_NOT_EXIST;
457449
}
@@ -460,15 +452,11 @@ lws_socket_bind(struct lws_vhost *vhost, struct lws *wsi,
460452
(unsigned int)uid,
461453
(unsigned int)gid);
462454

463-
if (fchmod(fdu, 0660)) { /* lgtm [cpp/toctou-race-condition] */
455+
if (chmod(iface, 0660)) { /* lgtm [cpp/toctou-race-condition] */
464456
lwsl_wsi_err(wsi, "0600 mode on %s fail", iface);
465457

466-
close(fdu);
467-
468458
return LWS_ITOSA_NOT_EXIST;
469459
}
470-
471-
close(fdu);
472460
}
473461
}
474462
#endif

0 commit comments

Comments
 (0)