changeset 1048:c4f666fc3a7e

ngx_open_file(name, access, create) > ngx_open_file(name, mode, create, access)
author Igor Sysoev <igor@sysoev.ru>
date Thu, 18 Jan 2007 20:15:09 +0000
parents ea6f43a88208
children 8865ca5ff560
files src/core/ngx_conf_file.c src/core/ngx_cycle.c src/core/ngx_log.c src/http/modules/ngx_http_auth_basic_module.c src/http/modules/ngx_http_flv_module.c src/http/modules/ngx_http_index_module.c src/http/modules/ngx_http_static_module.c src/os/unix/ngx_files.h src/os/win32/ngx_files.h
diffstat 9 files changed, 20 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -76,7 +76,7 @@ ngx_conf_parse(ngx_conf_t *cf, ngx_str_t
 
         /* open configuration file */
 
-        fd = ngx_open_file(filename->data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
+        fd = ngx_open_file(filename->data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
         if (fd == NGX_INVALID_FILE) {
             ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
                                ngx_open_file_n " \"%s\" failed",
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -312,7 +312,8 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
         }
 
         file[i].fd = ngx_open_file(file[i].name.data, NGX_FILE_RDWR,
-                                   NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
+                                   NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND,
+                                   NGX_FILE_DEFAULT_ACCESS);
 
         ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0,
                        "log: %p %d \"%s\"",
@@ -849,7 +850,8 @@ ngx_create_pidfile(ngx_str_t *name, ngx_
     trunc = ngx_test_config ? 0 : NGX_FILE_TRUNCATE;
 
     file.fd = ngx_open_file(file.name.data, NGX_FILE_RDWR,
-                            NGX_FILE_CREATE_OR_OPEN|trunc);
+                            NGX_FILE_CREATE_OR_OPEN|trunc,
+                            NGX_FILE_DEFAULT_ACCESS);
 
     if (file.fd == NGX_INVALID_FILE) {
         ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
@@ -959,7 +961,8 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx
         }
 
         fd = ngx_open_file(file[i].name.data, NGX_FILE_RDWR,
-                           NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
+                           NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND,
+                           NGX_FILE_DEFAULT_ACCESS);
 
         ngx_log_debug3(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
                        "reopen file \"%s\", old:%d new:%d",
--- a/src/core/ngx_log.c
+++ b/src/core/ngx_log.c
@@ -209,7 +209,7 @@ ngx_log_init(void)
     ngx_stderr_fileno = GetStdHandle(STD_ERROR_HANDLE);
 
     ngx_stderr.fd = ngx_open_file(NGX_ERROR_LOG_PATH, NGX_FILE_RDWR,
-                                  NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND);
+                                  NGX_FILE_CREATE_OR_OPEN|NGX_FILE_APPEND, 0);
 
     if (ngx_stderr.fd == NGX_INVALID_FILE) {
         ngx_message_box("nginx", MB_OK, ngx_errno,
--- a/src/http/modules/ngx_http_auth_basic_module.c
+++ b/src/http/modules/ngx_http_auth_basic_module.c
@@ -133,7 +133,7 @@ ngx_http_auth_basic_handler(ngx_http_req
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
 
-    fd = ngx_open_file(alcf->user_file.data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
+    fd = ngx_open_file(alcf->user_file.data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
 
     if (fd == NGX_INVALID_FILE) {
         ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
--- a/src/http/modules/ngx_http_flv_module.c
+++ b/src/http/modules/ngx_http_flv_module.c
@@ -109,7 +109,7 @@ ngx_http_flv_handler(ngx_http_request_t 
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
 
-    fd = ngx_open_file(path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
+    fd = ngx_open_file(path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
 
     if (fd == NGX_INVALID_FILE) {
         err = ngx_errno;
--- a/src/http/modules/ngx_http_index_module.c
+++ b/src/http/modules/ngx_http_index_module.c
@@ -245,7 +245,7 @@ ngx_http_index_handler(ngx_http_request_
             return NGX_HTTP_INTERNAL_SERVER_ERROR;
         }
 
-        fd = ngx_open_file(ctx->path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
+        fd = ngx_open_file(ctx->path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
 
         if (fd == (ngx_fd_t) NGX_AGAIN) {
             ctx->current = i;
--- a/src/http/modules/ngx_http_static_module.c
+++ b/src/http/modules/ngx_http_static_module.c
@@ -126,7 +126,7 @@ ngx_http_static_handler(ngx_http_request
         return NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
 
-    fd = ngx_open_file(path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN);
+    fd = ngx_open_file(path.data, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
 
     if (fd == NGX_INVALID_FILE) {
         err = ngx_errno;
--- a/src/os/unix/ngx_files.h
+++ b/src/os/unix/ngx_files.h
@@ -17,8 +17,8 @@
 
 
 
-#define ngx_open_file(name, access, create)                                 \
-    open((const char *) name, access|create, 0644)
+#define ngx_open_file(name, mode, create, access)                            \
+    open((const char *) name, mode|create, access)
 #define ngx_open_file_n          "open()"
 
 #define NGX_FILE_RDONLY          O_RDONLY
@@ -28,6 +28,8 @@
 #define NGX_FILE_TRUNCATE        O_TRUNC
 #define NGX_FILE_APPEND          O_APPEND
 
+#define NGX_FILE_DEFAULT_ACCESS  0644
+
 
 #define ngx_close_file           close
 #define ngx_close_file_n         "close()"
--- a/src/os/win32/ngx_files.h
+++ b/src/os/win32/ngx_files.h
@@ -28,8 +28,8 @@
 
 
 
-#define ngx_open_file(name, access, create)                                  \
-    CreateFile((const char *) name, access,                                  \
+#define ngx_open_file(name, mode, create, access)                            \
+    CreateFile((const char *) name, mode,                                    \
                FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,           \
                NULL, create, FILE_FLAG_BACKUP_SEMANTICS, NULL)
 /*
@@ -43,6 +43,8 @@
 #define NGX_FILE_OPEN               OPEN_EXISTING
 #define NGX_FILE_APPEND             0
 
+#define NGX_FILE_DEFAULT_ACCESS     0
+
 
 ngx_int_t ngx_file_append_mode(ngx_fd_t fd);
 #define ngx_file_append_mode_n      "SetFilePointer()"