Skip to content
Tcl Source Code Artifact [89a42b588b]
Login

Artifact [89a42b588b]

Artifact 89a42b588b97950b6807dacc7e016f881a500f3d:

Ticket change [89a42b588b] - Ticket [1193497fffffffff|1193497fff] <i>file writable lies for certain XP directories</i> status still Open with 4 other changes by jfg118 on 2005-10-21 06:08:44.
D 2005-10-21T06:08:44
J icomment Logged\sIn:\sYES\s\nuser_id=1266631\n\nBelow\sis\sa\spatch\sgenerated\sagainst\sthe\sTcl\s8.4.11\ssource.\nThe\sspecific\sfile\sis\swin/tclWinFile.c\srev\s1.44.2.12\s.\s\sThe\npatch\simplements\sand\s"NativeIsWritable"\sfunction.\s\sThe\nfunction\sneeds\sto\shave\sthe\swide\schar\simplementation\sadded.\nThe\sonly\scall\swhich\sneeds\sto\sbe\supdated\sis\sthe\nGetFileSecurity\sfunction\swhich\sneeds\san\sentry\sin\sthe\ntclWinProcs\sdefnition.\s\sThe\spatch\sfalls\sback\sto\sthe\sold\nimplementation\sfor\swide\schar\spaths.\s\n\n<\s\s\s\s\sif\s((mode\s&\sW_OK)\s&&\s(attr\s&\sFILE_ATTRIBUTE_READONLY))\s{\n---\n>\s\s\s\s\sif\s((mode\s&\sW_OK)\s&&\s!NativeIsWritable(nativePath))\s{\n1365a1367,1442\n>\s\s*\sNativeIsWritable\s--\n>\s\s*\n>\s\s*Determines\sif\sa\spath\sis\swritable.\s\sOn\swindows\sthis\s\n>\s\s*requires\smore\sthan\sa\ssimple\sread\sonly\sflag\scheck\sfor\ndirectories\n>\s\s*\s\s\s\s\s\sbecause\swindows\suses\sthis\sas\sa\sflag\sto\scustomize\nthe\sfolder\n>\s\s*\s\s\s\s\s\soptions.\s\sBUG\s1193497\n>\s\s*\n>\s\s*\sResults:\n>\s\s*1\s=\swritable,\s0\s=\snot.\n>\s\s*\n>\s\n*----------------------------------------------------------------------\n>\s\s*/\n>\sstatic\sint\n>\sNativeIsWritable(nativePath)\n>\s\s\s\s\sCONST\sTCHAR\s*nativePath;\n>\s{\n>\s\s\schar\spsd_buf[1024],\s*psd_ptr\s=\spsd_buf,\s*psd_alloc\s=\s0;\n>\s\s\sDWORD\ssd_rlen;\n>\s\s\sHANDLE\shToken\s=\sNULL;\n>\s\s\sint\sretVal\s=\s0;\n>\s\n>\s\s\sif\s(tclWinProcs->useWide)\s{\n>\s\s\s\s\s/*\snot\simplemented\s\s--\sfall\sback\sto\sold\simplementation\s*/\n>\s\s\s\s\sreturn\n((*tclWinProcs->getFileAttributesProc)(nativePath)\s&\nFILE_ATTRIBUTE_READONLY)\s?\s0\s:\s1;\n>\s\s\s}\n>\s\n>\s\s\sif\s(!GetFileSecurity(nativePath,\n>\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sOWNER_SECURITY_INFORMATION\n>\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\sGROUP_SECURITY_INFORMATION\n>\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\sDACL_SECURITY_INFORMATION,\n>\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\spsd_buf,\ssizeof(psd_buf),\s&sd_rlen))\s{\n>\s\s\s\s\sreturn\s0;\s/*\sFailed\s...\s*/\n>\s\s\s}\n>\s\s\sif\s(sizeof(psd_buf)\s<\ssd_rlen)\s{\n>\s\s\s\s\sDWORD\spsd_alloc_rlen;\n>\s\s\s\s\spsd_alloc\s=\s(char\s*)ckalloc(sd_rlen);\n>\s\s\s\s\sif\s(!GetFileSecurity(nativePath,\n>\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sOWNER_SECURITY_INFORMATION\n>\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\sGROUP_SECURITY_INFORMATION\n>\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s|\sDACL_SECURITY_INFORMATION,\n>\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\spsd_alloc,\ssd_rlen,\s&psd_alloc_rlen)\n>\s\s\s\s\s\s\s\s\s||\ssd_rlen\s\s<\spsd_alloc_rlen)\s{\n>\s\s\s\s\s\s\sckfree(psd_alloc);\n>\s\s\s\s\s\s\sreturn\s0;\s/*\sFailed\s....\s*/\n>\s\s\s\s\s}\n>\s\s\s\s\spsd_ptr\s=\spsd_alloc;\n>\s\s\s\s\ssd_rlen\s=\spsd_alloc_rlen;\n>\s\s\s}\n>\s\s\sif\s(\sOpenProcessToken\s(\sGetCurrentProcess\s(\s),\nTOKEN_DUPLICATE,\s&hToken\s)\s)\s{\n>\s\s\s\s\sHANDLE\shIToken\s=\sNULL;\n>\s\s\s\s\sBOOL\sstatus\s=\sDuplicateToken\s(hToken,\nSecurityIdentification,\s&hIToken);\n>\s\s\s\s\sCloseHandle\s(hToken);\n>\s\s\s\s\s\n>\s\s\s\s\sif\s(status)\s{\n>\s\s\s\s\s\s\sGENERIC_MAPPING\smapping\s=\s{\sFILE_GENERIC_READ,\n>\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sFILE_GENERIC_WRITE,\n>\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sFILE_GENERIC_EXECUTE,\n>\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sFILE_ALL_ACCESS\s};\n>\s\s\s\s\s\s\schar\spbuf[sizeof\s(PRIVILEGE_SET)\s+\s3\s*\ssizeof\n(LUID_AND_ATTRIBUTES)];\n>\s\s\s\s\s\s\sDWORD\splength\s=\ssizeof(pbuf),\sgranted;\s\n>\s\s\s\s\s\s\sretVal\s=\sAccessCheck\s(psd_ptr,\shIToken,\nFILE_WRITE_DATA,\s&mapping,\n>\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s(PPRIVILEGE_SET)\spbuf,\n&plength,\s&granted,\s&status)\s?\s1\s:\s0;\n>\s\s\s\s\s\s\s\n>\s\s\s\s\s\s\sCloseHandle(hIToken);\n>\s\s\s\s\s}\n>\s\s\s}\n>\s\n>\s\s\sif\s(psd_alloc)\n>\s\s\s\s\sckfree(psd_alloc);\n>\s\n>\s\s\sreturn\sretVal;\n>\s}\n>\s/*\n>\s\n*----------------------------------------------------------------------\n>\s\s*\n\n
J login jfg118
J mimetype text/plain
J username jfg118
K 1193497fffffffffffffffffffffffffffffffff
U jfg118
Z 4706db86296c706586d701fc391dcbd0