derick Wed Jan 4 12:22:23 2006 UTC
Modified files:
/php-src 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 the lchown() and lchgrp() functions which change permissions and group
permissions on symbolic links.
#- We'll also add this to PHP 5.1.3? or PHP 5.2, so I didn't add it to NEWS.
http://cvs.php.net/viewcvs.cgi/php-src/configure.in?r1=1.598&r2=1.599&diff_format=u
Index: php-src/configure.in
diff -u php-src/configure.in:1.598 php-src/configure.in:1.599
--- php-src/configure.in:1.598 Mon Dec 12 12:20:45 2005
+++ php-src/configure.in Wed Jan 4 12:22:23 2006
@@ -1,4 +1,4 @@
- ## $Id: configure.in,v 1.598 2005/12/12 12:20:45 sniper Exp $ -*- autoconf -*-
+ ## $Id: configure.in,v 1.599 2006/01/04 12:22:23 derick Exp $ -*- autoconf -*-
dnl ## Process this file with autoconf to produce a configure script.
divert(1)
@@ -482,6 +482,7 @@
link \
localtime_r \
lockf \
+lchown \
lrand48 \
memcpy \
memmove \
http://cvs.php.net/viewcvs.cgi/TSRM/tsrm_virtual_cwd.c?r1=1.78&r2=1.79&diff_format=u
Index: TSRM/tsrm_virtual_cwd.c
diff -u TSRM/tsrm_virtual_cwd.c:1.78 TSRM/tsrm_virtual_cwd.c:1.79
--- TSRM/tsrm_virtual_cwd.c:1.78 Sun Jan 1 13:09:48 2006
+++ TSRM/tsrm_virtual_cwd.c Wed Jan 4 12:22:23 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: tsrm_virtual_cwd.c,v 1.78 2006/01/01 13:09:48 sniper Exp $ */
+/* $Id: tsrm_virtual_cwd.c,v 1.79 2006/01/04 12:22:23 derick Exp $ */
#include <sys/types.h>
#include <sys/stat.h>
@@ -777,7 +777,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;
@@ -785,7 +785,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.49&r2=1.50&diff_format=u
Index: TSRM/tsrm_virtual_cwd.h
diff -u TSRM/tsrm_virtual_cwd.h:1.49 TSRM/tsrm_virtual_cwd.h:1.50
--- TSRM/tsrm_virtual_cwd.h:1.49 Sun Jan 1 13:09:48 2006
+++ TSRM/tsrm_virtual_cwd.h Wed Jan 4 12:22:23 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: tsrm_virtual_cwd.h,v 1.49 2006/01/01 13:09:48 sniper Exp $ */
+/* $Id: tsrm_virtual_cwd.h,v 1.50 2006/01/04 12:22:23 derick Exp $ */
#ifndef VIRTUAL_CWD_H
#define VIRTUAL_CWD_H
@@ -190,7 +190,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);
@@ -262,7 +262,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
@@ -305,6 +306,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.744&r2=1.745&diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.744
php-src/ext/standard/basic_functions.c:1.745
--- php-src/ext/standard/basic_functions.c:1.744 Sun Jan 1 13:09:54 2006
+++ php-src/ext/standard/basic_functions.c Wed Jan 4 12:22:23 2006
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.744 2006/01/01 13:09:54 sniper Exp $ */
+/* $Id: basic_functions.c,v 1.745 2006/01/04 12:22:23 derick Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -696,6 +696,12 @@
PHP_FE(chown,
NULL)
PHP_FE(chgrp,
NULL)
#endif
+#if HAVE_LCHOWN
+ PHP_FE(lchown,
NULL)
+#endif
+#if HAVE_LCHOWN
+ PHP_FE(lchgrp,
NULL)
+#endif
PHP_FE(chmod,
NULL)
#if HAVE_UTIME
PHP_FE(touch,
NULL)
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/filestat.c?r1=1.140&r2=1.141&diff_format=u
Index: php-src/ext/standard/filestat.c
diff -u php-src/ext/standard/filestat.c:1.140
php-src/ext/standard/filestat.c:1.141
--- php-src/ext/standard/filestat.c:1.140 Sun Jan 1 13:09:55 2006
+++ php-src/ext/standard/filestat.c Wed Jan 4 12:22:23 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: filestat.c,v 1.140 2006/01/01 13:09:55 sniper Exp $ */
+/* $Id: filestat.c,v 1.141 2006/01/04 12:22:23 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.26&r2=1.27&diff_format=u
Index: php-src/ext/standard/php_filestat.h
diff -u php-src/ext/standard/php_filestat.h:1.26
php-src/ext/standard/php_filestat.h:1.27
--- php-src/ext/standard/php_filestat.h:1.26 Sun Jan 1 13:09:55 2006
+++ php-src/ext/standard/php_filestat.h Wed Jan 4 12:22:23 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_filestat.h,v 1.26 2006/01/01 13:09:55 sniper Exp $ */
+/* $Id: php_filestat.h,v 1.27 2006/01/04 12:22:23 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