summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2022-08-23 23:18:05 +0200
committerAlejandro Colomar <alx.manpages@gmail.com>2022-08-23 23:20:27 +0200
commitf8897c0a08fe0a904fe8a38013f8fd94c0052792 (patch)
tree485923b69705df9d53b43e51812b97afd51968ff
parente4960f6a8cc4ec7d8b57694d4c92b7e1ff4d3917 (diff)
Don't try to chmod(2) abstract Unix domain sockets.abs
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.clayton@f5.com> Signed-off-by: Andrew Clayton <a.clayton@f5.com> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Cc: Bjornar Ness <bjornar.ness@gmail.com>
-rw-r--r--src/core/ngx_connection.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index fe729a78a..1d0417047 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);
+ }
}
}