Don't try to handle Unix sockets starting with a '\0' as if they were files, since they represent abstract sockets.
As we're using the "pretty" name generated by ngx_sock_ntop(), which translates the '\0' into '@', test for '@'. Co-developed-by: Andrew Clayton <a.clay...@f5.com> Signed-off-by: Andrew Clayton <a.clay...@f5.com> Signed-off-by: Alejandro Colomar <alx.manpa...@gmail.com> Cc: Bjornar Ness <bjornar.n...@gmail.com> --- src/core/ngx_connection.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c index fe729a78..1d041704 100644 --- a/src/core/ngx_connection.c +++ b/src/core/ngx_connection.c @@ -633,17 +633,19 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle) u_char *name; name = ls[i].addr_text.data + sizeof("unix:") - 1; - mode = (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); + if (name[0] != '@') { + mode = (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); - if (chmod((char *) name, mode) == -1) { - ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, - "chmod() \"%s\" failed", name); - } - - if (ngx_test_config) { - if (ngx_delete_file(name) == NGX_FILE_ERROR) { + if (chmod((char *) name, mode) == -1) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, - ngx_delete_file_n " %s failed", name); + "chmod() \"%s\" failed", name); + } + + if (ngx_test_config) { + if (ngx_delete_file(name) == NGX_FILE_ERROR) { + ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, + ngx_delete_file_n " %s failed", name); + } } } } @@ -1078,9 +1080,11 @@ ngx_close_listening_sockets(ngx_cycle_t *cycle) { u_char *name = ls[i].addr_text.data + sizeof("unix:") - 1; - if (ngx_delete_file(name) == NGX_FILE_ERROR) { - ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno, - ngx_delete_file_n " %s failed", name); + if (name[0] != '@') { + if (ngx_delete_file(name) == NGX_FILE_ERROR) { + ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno, + ngx_delete_file_n " %s failed", name); + } } } -- 2.37.2 _______________________________________________ nginx-devel mailing list -- nginx-devel@nginx.org To unsubscribe send an email to nginx-devel-le...@nginx.org