derick          Sun Mar  5 18:57:54 2006 UTC

  Modified files:              (Branch: PHP_5_1)
    /php-src    NEWS configure.in 
    /TSRM       tsrm_virtual_cwd.c tsrm_virtual_cwd.h 
    /php-src/ext/standard       basic_functions.c filestat.c php_filestat.h 
  Log:
  - Added lchown() and lchgrp() to change user/group ownership of symlinks.
  
  
http://cvs.php.net/viewcvs.cgi/php-src/NEWS?r1=1.2027.2.442&r2=1.2027.2.443&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.442 php-src/NEWS:1.2027.2.443
--- php-src/NEWS:1.2027.2.442   Sun Mar  5 17:56:16 2006
+++ php-src/NEWS        Sun Mar  5 18:57:53 2006
@@ -30,6 +30,8 @@
     on error.
 - Changed get_headers() to retrieve headers also from non-200 responses. (Ilia)
 - Changed get_headers() to use the default context. (Ilia)
+- Added lchown() and lchgrp() to change user/group ownership of symlinks.
+  (Derick)
 - Added support for exif date format in strtotime(). (Derick)
 - Added a check for special characters in the session name. (Ilia)
 - Added "consumed" stream filter. (Marcus)
http://cvs.php.net/viewcvs.cgi/php-src/configure.in?r1=1.579.2.37&r2=1.579.2.38&diff_format=u
Index: php-src/configure.in
diff -u php-src/configure.in:1.579.2.37 php-src/configure.in:1.579.2.38
--- php-src/configure.in:1.579.2.37     Thu Feb 16 22:49:13 2006
+++ php-src/configure.in        Sun Mar  5 18:57:53 2006
@@ -1,4 +1,4 @@
- ## $Id: configure.in,v 1.579.2.37 2006/02/16 22:49:13 wez Exp $ -*- autoconf 
-*-
+ ## $Id: configure.in,v 1.579.2.38 2006/03/05 18:57:53 derick Exp $ -*- 
autoconf -*-
 dnl ## Process this file with autoconf to produce a configure script.
 
 divert(1)
@@ -483,6 +483,7 @@
 link \
 localtime_r \
 lockf \
+lchown \
 lrand48 \
 memcpy \
 memmove \
http://cvs.php.net/viewcvs.cgi/TSRM/tsrm_virtual_cwd.c?r1=1.74.2.8&r2=1.74.2.9&diff_format=u
Index: TSRM/tsrm_virtual_cwd.c
diff -u TSRM/tsrm_virtual_cwd.c:1.74.2.8 TSRM/tsrm_virtual_cwd.c:1.74.2.9
--- TSRM/tsrm_virtual_cwd.c:1.74.2.8    Wed Feb  8 20:50:03 2006
+++ TSRM/tsrm_virtual_cwd.c     Sun Mar  5 18:57:54 2006
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: tsrm_virtual_cwd.c,v 1.74.2.8 2006/02/08 20:50:03 tony2001 Exp $ */
+/* $Id: tsrm_virtual_cwd.c,v 1.74.2.9 2006/03/05 18:57:54 derick Exp $ */
 
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -765,7 +765,7 @@
 }
 
 #if !defined(TSRM_WIN32) && !defined(NETWARE)
-CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group 
TSRMLS_DC)
+CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int 
link TSRMLS_DC)
 {
        cwd_state new_state;
        int ret;
@@ -773,7 +773,15 @@
        CWD_STATE_COPY(&new_state, &CWDG(cwd));
        virtual_file_ex(&new_state, filename, NULL, 0);
 
-       ret = chown(new_state.cwd, owner, group);
+       if (link) {
+#if HAVE_LCHOWN
+               ret = lchown(new_state.cwd, owner, group);
+#else
+               ret = -1;
+#endif
+       } else {
+               ret = chown(new_state.cwd, owner, group);
+       }
 
        CWD_STATE_FREE(&new_state);
        return ret;
http://cvs.php.net/viewcvs.cgi/TSRM/tsrm_virtual_cwd.h?r1=1.48.2.3&r2=1.48.2.4&diff_format=u
Index: TSRM/tsrm_virtual_cwd.h
diff -u TSRM/tsrm_virtual_cwd.h:1.48.2.3 TSRM/tsrm_virtual_cwd.h:1.48.2.4
--- TSRM/tsrm_virtual_cwd.h:1.48.2.3    Wed Feb  8 20:50:03 2006
+++ TSRM/tsrm_virtual_cwd.h     Sun Mar  5 18:57:54 2006
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: tsrm_virtual_cwd.h,v 1.48.2.3 2006/02/08 20:50:03 tony2001 Exp $ */
+/* $Id: tsrm_virtual_cwd.h,v 1.48.2.4 2006/03/05 18:57:54 derick Exp $ */
 
 #ifndef VIRTUAL_CWD_H
 #define VIRTUAL_CWD_H
@@ -175,7 +175,7 @@
 #endif
 CWD_API int virtual_chmod(const char *filename, mode_t mode TSRMLS_DC);
 #if !defined(TSRM_WIN32) && !defined(NETWARE)
-CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group 
TSRMLS_DC);
+CWD_API int virtual_chown(const char *filename, uid_t owner, gid_t group, int 
link TSRMLS_DC);
 #endif
 
 CWD_API int virtual_file_ex(cwd_state *state, const char *path, 
verify_path_func verify_path, int use_realpath);
@@ -242,7 +242,8 @@
 #endif
 #define VCWD_CHMOD(path, mode) virtual_chmod(path, mode TSRMLS_CC)
 #if !defined(TSRM_WIN32) && !defined(NETWARE)
-#define VCWD_CHOWN(path, owner, group) virtual_chown(path, owner, group 
TSRMLS_CC)
+#define VCWD_CHOWN(path, owner, group) virtual_chown(path, owner, group, 0 
TSRMLS_CC)
+#define VCWD_LCHOWN(path, owner, group) virtual_chown(path, owner, group, 1 
TSRMLS_CC)
 #endif
 
 #else
@@ -285,6 +286,7 @@
 #define VCWD_CHMOD(path, mode) chmod(path, mode)
 #if !defined(TSRM_WIN32) && !defined(NETWARE)
 #define VCWD_CHOWN(path, owner, group) chown(path, owner, group)
+#define VCWD_LCHOWN(path, owner, group) lchown(path, owner, group)
 #endif
 
 #endif
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/basic_functions.c?r1=1.725.2.24&r2=1.725.2.25&diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.725.2.24 
php-src/ext/standard/basic_functions.c:1.725.2.25
--- php-src/ext/standard/basic_functions.c:1.725.2.24   Thu Feb 23 03:51:46 2006
+++ php-src/ext/standard/basic_functions.c      Sun Mar  5 18:57:54 2006
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.725.2.24 2006/02/23 03:51:46 bfrance Exp $ */
+/* $Id: basic_functions.c,v 1.725.2.25 2006/03/05 18:57:54 derick Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -698,8 +698,6 @@
 #endif
 #if HAVE_LCHOWN
        PHP_FE(lchown,                                                          
                                                        NULL)
-#endif
-#if HAVE_LCHOWN
        PHP_FE(lchgrp,                                                          
                                                        NULL)
 #endif
        PHP_FE(chmod,                                                           
                                                        NULL)
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/filestat.c?r1=1.136.2.3&r2=1.136.2.4&diff_format=u
Index: php-src/ext/standard/filestat.c
diff -u php-src/ext/standard/filestat.c:1.136.2.3 
php-src/ext/standard/filestat.c:1.136.2.4
--- php-src/ext/standard/filestat.c:1.136.2.3   Sun Jan  1 12:50:14 2006
+++ php-src/ext/standard/filestat.c     Sun Mar  5 18:57:54 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: filestat.c,v 1.136.2.3 2006/01/01 12:50:14 sniper Exp $ */
+/* $Id: filestat.c,v 1.136.2.4 2006/03/05 18:57:54 derick Exp $ */
 
 #include "php.h"
 #include "safe_mode.h"
@@ -323,12 +323,9 @@
 }
 /* }}} */
 
-/* {{{ proto bool chgrp(string filename, mixed group)
-   Change file group */
-#ifndef NETWARE
-PHP_FUNCTION(chgrp)
+
+static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp)
 {
-#if !defined(WINDOWS)
        zval **filename, **group;
        gid_t gid;
        struct group *gr=NULL;
@@ -360,25 +357,48 @@
                RETURN_FALSE;
        }
 
-       ret = VCWD_CHOWN(Z_STRVAL_PP(filename), -1, gid);
+       if (do_lchgrp) {
+               ret = VCWD_LCHOWN(Z_STRVAL_PP(filename), -1, gid);
+       } else {
+               ret = VCWD_CHOWN(Z_STRVAL_PP(filename), -1, gid);
+       }
        if (ret == -1) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
strerror(errno));
                RETURN_FALSE;
        }
        RETURN_TRUE;
+}
+
+#ifndef NETWARE
+/* {{{ proto bool chgrp(string filename, mixed group)
+   Change file group */
+PHP_FUNCTION(chgrp)
+{
+#if !defined(WINDOWS)
+       php_do_chgrp(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
 #else
        RETURN_FALSE;
 #endif
 }
+/* }}} */
+
+/* {{{ proto bool lchgrp(string filename, mixed group)
+   Change symlink group */
+#if HAVE_LCHOWN
+PHP_FUNCTION(lchgrp)
+{
+# if !defined(WINDOWS)
+       php_do_chgrp(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+# else
+       RETURN_FALSE;
+# endif
+}
 #endif
 /* }}} */
+#endif
 
-/* {{{ proto bool chown (string filename, mixed user)
-   Change file owner */
-#ifndef NETWARE
-PHP_FUNCTION(chown)
+static void php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown)
 {
-#if !defined(WINDOWS)
        zval **filename, **user;
        int ret;
        uid_t uid;
@@ -410,16 +430,46 @@
                RETURN_FALSE;
        }
 
-       ret = VCWD_CHOWN(Z_STRVAL_PP(filename), uid, -1);
+       if (do_lchown) {
+               ret = VCWD_LCHOWN(Z_STRVAL_PP(filename), uid, -1);
+       } else {
+               ret = VCWD_CHOWN(Z_STRVAL_PP(filename), uid, -1);
+       }
        if (ret == -1) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", 
strerror(errno));
                RETURN_FALSE;
        }
+}
+
+#ifndef NETWARE
+/* {{{ proto bool chown (string filename, mixed user)
+   Change file owner */
+PHP_FUNCTION(chown)
+{
+#if !defined(WINDOWS)
+       RETVAL_TRUE;
+       php_do_chown(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+#else
+       RETURN_FALSE;
 #endif
-       RETURN_TRUE;
+}
+/* }}} */
+
+/* {{{ proto bool chown (string filename, mixed user)
+   Change file owner */
+#if HAVE_LCHOWN
+PHP_FUNCTION(lchown)
+{
+# if !defined(WINDOWS)
+       RETVAL_TRUE;
+       php_do_chown(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+# else
+       RETURN_FALSE;
+# endif
 }
 #endif
 /* }}} */
+#endif
 
 /* {{{ proto bool chmod(string filename, int mode)
    Change file mode */
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/php_filestat.h?r1=1.24.2.2&r2=1.24.2.3&diff_format=u
Index: php-src/ext/standard/php_filestat.h
diff -u php-src/ext/standard/php_filestat.h:1.24.2.2 
php-src/ext/standard/php_filestat.h:1.24.2.3
--- php-src/ext/standard/php_filestat.h:1.24.2.2        Sun Jan  1 12:50:15 2006
+++ php-src/ext/standard/php_filestat.h Sun Mar  5 18:57:54 2006
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: php_filestat.h,v 1.24.2.2 2006/01/01 12:50:15 sniper Exp $ */
+/* $Id: php_filestat.h,v 1.24.2.3 2006/03/05 18:57:54 derick Exp $ */
 
 #ifndef PHP_FILESTAT_H
 #define PHP_FILESTAT_H
@@ -47,9 +47,18 @@
 PHP_FUNCTION(disk_free_space);
 PHP_FUNCTION(chown);
 PHP_FUNCTION(chgrp);
+#if HAVE_LCHOWN
+PHP_FUNCTION(lchown);
+#endif
+#if HAVE_LCHOWN
+PHP_FUNCTION(lchgrp);
+#endif
 PHP_FUNCTION(chmod);
 #if HAVE_UTIME
 PHP_FUNCTION(touch);
+# if HAVE_LTOUCH
+PHP_FUNCTION(ltouch);
+# endif
 #endif
 PHP_FUNCTION(clearstatcache);
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to