Fix bug #6017, - magic script does not work. based on a patch from monyo@samba.gr.jp.
authorJeremy Allison <jra@samba.org>
Wed, 7 Jan 2009 00:06:22 +0000 (16:06 -0800)
committerJeremy Allison <jra@samba.org>
Wed, 7 Jan 2009 00:06:22 +0000 (16:06 -0800)
Jeremy.

source/smbd/close.c

index 32231f49a303c2b4506b9b75b0544f46d0a29732..25552e37ab36eb6d5c12278f931fc67e8d3f7d82 100644 (file)
@@ -67,10 +67,20 @@ static void check_magic(struct files_struct *fsp)
                return;
        }
 
-       chmod(fsp->fsp_name,0755);
-       ret = smbrun(fsp->fsp_name,&tmp_fd);
+       /* Ensure we don't depend on user's PATH. */
+       p = talloc_asprintf(ctx, "./%s", fsp->fsp_name);
+       if (!p) {
+               TALLOC_FREE(ctx);
+               return;
+       }
+
+       if (chmod(fsp->fsp_name,0755) == -1) {
+               TALLOC_FREE(ctx);
+               return;
+       }
+       ret = smbrun(p,&tmp_fd);
        DEBUG(3,("Invoking magic command %s gave %d\n",
-               fsp->fsp_name,ret));
+               p,ret));
 
        unlink(fsp->fsp_name);
        if (ret != 0 || tmp_fd == -1) {