Re: [PHP-DEV] CVS update: php3 From: APIS (apis <email protected>)
Date: 08/05/98

        o On Solaris 2.5.1 I get this compile error after this
update to CVS was done .. php3 compiled OK just before this change:

gcc -g -O2 -O2 -I. -I. -I/usr/local/mysql/include/mysql
-I/usr/local/include -c php3_realpath.c -o php3_realpath.o
php3_realpath.c: In function `_php3_realpath':
php3_realpath.c:59: storage size of `filestat' isn't known
php3_realpath.c:251: `S_IFMT' undeclared (first use in this function)
php3_realpath.c:251: (Each undeclared identifier is reported only once
php3_realpath.c:251: for each function it appears in.)
php3_realpath.c:251: `S_IFDIR' undeclared (first use in this function)
make: *** [php3_realpath.o] Error 1

Harv
-nnnn-

On 5 Aug 1998, steffann wrote:

> Date: Tuesday August 4, 1998 @ 20:33
> Author: steffann
>
> Update of /repository/php3
> In directory asf:/tmp/cvs-serv24042
>
> Modified Files:
> php3_realpath.c
> Log Message:
> fopen_basedir now also works on directories.
> _php3_realpath now appends a / when the input-string points to a directory.
>
> Index: php3/php3_realpath.c
> diff -c php3/php3_realpath.c:1.2 php3/php3_realpath.c:1.3
> *** php3/php3_realpath.c:1.2 Mon Aug 3 17:12:27 1998
> --- php3/php3_realpath.c Tue Aug 4 20:33:54 1998
> ***************
> *** 41,46 ****
> --- 41,50 ----
> #define MAXSYMLINKS 32
> #endif
>
> + #ifndef S_ISDIR
> + #define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR)
> + #endif
> +
> char *_php3_realpath(char *path, char resolved_path []) {
> char path_construction[MAXPATHLEN]; /* We build the result in here */
> char *writepos; /* Position to write next char */
> ***************
> *** 51,56 ****
> --- 55,62 ----
> char buf[MAXPATHLEN]; /* Buffer for readlink */
> int linklength; /* The result from readlink */
> int linkcount = 0; /* Count symlinks to avoid loops */
> +
> + struct stat filestat; /* result from stat */
>
> /* Set the work-position to the beginning of the given path */
> strcpy(path_copy, path);
> ***************
> *** 238,243 ****
> --- 244,262 ----
> }
> *writepos = 0;
> #endif /* WIN32|WINNT */
> + }
> +
> + /* Check if the resolved path is a directory */
> + if (stat(path_construction, &filestat) != 0) return NULL;
> + if (S_ISDIR(filestat.st_mode)) {
> + /* It's a directory, append a / if needed */
> + if (*(writepos-1) != '/') {
> + /* Check for overflow */
> + if ((strlen(workpos) + 2) >= MAXPATHLEN) return NULL;
> +
> + *writepos++ = '/';
> + *writepos = 0;
> + }
> }
>
> strcpy(resolved_path, path_construction);
>
NNNN