]> granicus.if.org Git - php/commitdiff
add flags to suppress the verbosity
authorAnatol Belski <ab@php.net>
Thu, 9 Jun 2016 11:39:19 +0000 (13:39 +0200)
committerAnatol Belski <ab@php.net>
Thu, 9 Jun 2016 15:19:40 +0000 (17:19 +0200)
main/php_open_temporary_file.c
main/php_open_temporary_file.h

index ee752b98ff6096a0b2dd3ca380b9ec2982aeface..caddf1b390cab4d3846ae77347ce2effbec994a7 100644 (file)
@@ -19,6 +19,7 @@
 /* $Id$ */
 
 #include "php.h"
+#include "php_open_temporary_file.h"
 
 #include <errno.h>
 #include <sys/types.h>
@@ -249,7 +250,7 @@ PHPAPI const char* php_get_temporary_directory(void)
  * This function should do its best to return a file pointer to a newly created
  * unique file, on every platform.
  */
-PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, zend_string **opened_path_p, zend_bool open_basedir_check)
+PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, zend_string **opened_path_p, uint32_t flags)
 {
        int fd;
        const char *temp_dir;
@@ -265,7 +266,7 @@ PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, zend_strin
 def_tmp:
                temp_dir = php_get_temporary_directory();
 
-               if (temp_dir && *temp_dir != '\0' && (!open_basedir_check || !php_check_open_basedir(temp_dir))) {
+               if (temp_dir && *temp_dir != '\0' && (!(flags & PHP_TMP_FILE_OPEN_BASEDIR_CHECK) || !php_check_open_basedir(temp_dir))) {
                        return php_do_open_temporary_file(temp_dir, pfx, opened_path_p);
                } else {
                        return -1;
@@ -276,7 +277,9 @@ def_tmp:
        fd = php_do_open_temporary_file(dir, pfx, opened_path_p);
        if (fd == -1) {
                /* Use default temporary directory. */
-               php_error_docref(NULL, E_NOTICE, "file created in the system's temporary directory");
+               if (!(flags & PHP_TMP_FILE_SILENT)) {
+                       php_error_docref(NULL, E_NOTICE, "file created in the system's temporary directory");
+               }
                goto def_tmp;
        }
        return fd;
index fa8649aa70d0f1827de7972ff854f7e00184e9cb..f82f577c75ce62ad7582fc09fa49222086590e7e 100644 (file)
 #ifndef PHP_OPEN_TEMPORARY_FILE_H
 #define PHP_OPEN_TEMPORARY_FILE_H
 
+#define PHP_TMP_FILE_OPEN_BASEDIR_CHECK (1<<0)
+#define PHP_TMP_FILE_SILENT (1<<1)
+
 BEGIN_EXTERN_C()
 PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, zend_string **opened_path_p);
-PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, zend_string **opened_path_p, zend_bool open_basedir_check);
+PHPAPI int php_open_temporary_fd_ex(const char *dir, const char *pfx, zend_string **opened_path_p, uint32_t flags);
 PHPAPI int php_open_temporary_fd(const char *dir, const char *pfx, zend_string **opened_path_p);
 PHPAPI const char *php_get_temporary_directory(void);
 END_EXTERN_C()