httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <...@orton.demon.co.uk>
Subject Re: [PATCH] mod_dav: APRize fs/repos.c
Date Thu, 06 Jul 2000 01:39:44 GMT
Patch attempt two attached, which differs from the previous in
initializing ap_file_t's to 0.

Incremental to that, below is a forward-port of the "maintain executable
bit" fix from mod_dav 1.0.

joe

--- repos.c	Thu Jul  6 02:26:07 2000
+++ repos.prm.c	Thu Jul  6 02:21:49 2000
@@ -276,15 +276,30 @@
     ap_pool_t * p,
     const char *src,
     const char *dst,
+    const ap_finfo_t *src_finfo,
+    const ap_finfo_t *dst_finfo,
     dav_buffer *pbuf)
 {
     dav_buffer work_buf = { 0 };
     ap_file_t *inf = NULL;
     ap_file_t *outf = NULL;
+    ap_fileperms_t perms;
 
     if (pbuf == NULL)
 	pbuf = &work_buf;
 
+    perms = src_finfo->protection;
+
+    /* chmod() the destination if the source is executable, and the
+     * destination already exists. */
+    if ((perms & APR_UEXECUTE) && (dst_finfo != NULL) && 
+	(dst_finfo->filetype != APR_NOFILE)) {
+	if (ap_setfileperms(dst, perms) == -1) {
+	    return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 0,
+				 "Could not set permissions on destination");
+	}
+    }
+
     dav_set_bufsize(p, pbuf, DAV_FS_COPY_BLOCKSIZE);
 
     if ((ap_open(&inf, src, APR_READ | APR_BINARY, APR_OS_DEFAULT, p)) 
@@ -296,7 +311,7 @@
 
     /* ### do we need to deal with the umask? */
     if ((ap_open(&outf, dst, APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BINARY,
-		 APR_OS_DEFAULT, p)) != APR_SUCCESS) {
+		 perms, p)) != APR_SUCCESS) {
 	ap_close(inf);
 
 	/* ### use something besides 500? */
@@ -454,8 +469,11 @@
     }
     else
     {
-	/* gotta copy (and delete) */
-	return dav_fs_copymove_file(is_move, p, src, dst, pbuf);
+	/* gotta copy (and delete).
+	 * We don't have the finfo of the destination *file*, 
+	 * only the destination *directory*, so pass NULL. */
+	return dav_fs_copymove_file(is_move, p, src, dst, 
+				    &src_finfo, NULL, pbuf);
     }
 
     return NULL;
@@ -947,6 +965,7 @@
     else {
 	err = dav_fs_copymove_file(ctx->is_move, ctx->pool, 
 				   srcinfo->pathname, dstinfo->pathname, 
+				   &srcinfo->finfo, &dstinfo->finfo, 
 				   &ctx->work_buf);
 	/* ### push a higher-level description? */
     }
@@ -1024,6 +1043,7 @@
     /* not a collection */
     if ((err = dav_fs_copymove_file(is_move, src->info->pool,
 				    src->info->pathname, dst->info->pathname,
+				    &src->info->finfo, &dst->info->finfo, 
 				    &work_buf)) != NULL) {
 	/* ### push a higher-level description? */
 	return err;

Mime
View raw message