Here’s a screenshot of my c:\Users\UserName
folder. Notice the “Start Menu” folder:
It is a directory junction to another folder, left behind for compatibility purposes. If I double click the folder though I get an access denied:
The actual target to which this points is accessible, but the junction itself isn’t. Every time I encounter this I think I must make a note of “why” this is so, but I forget. Today I intend to note it down once and for all.
Remember from an earlier post: there are hard links and there are soft links. The former points to the data itself, and so only work for files. The latter points to the folder/ file containing the data. Soft links are an evolution of directory junctions (there are directory junctions and volume junctions). While directory junctions make use of something called reparse points and were introduced in Windows 2000, soft links were introduced in Vista and are baked into the kernel itself. Microsoft uses directory junctions – as we saw above – to redirect some of its special folders.
The important thing with both directory junctions and soft links is that they can have their own ACLs. So while a user might have full permissions to the target folder, the directory junction or soft link itself may not grant the user permissions and so the contents cannot be accessed via the directory junction or soft link. That’s what happening here too.
First, from the command prompt note that this is a junction and that I can enter the directory junction but cannot see any files:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
C:\Users\Rakhesh>dir /a Volume in drive C is WINDOWS Volume Serial Number is FA14-803C Directory of C:\Users\Rakhesh 01/16/2015 07:04 AM <DIR> . 01/16/2015 07:04 AM <DIR> .. <snip> 10/13/2014 02:55 PM <JUNCTION> Local Settings [C:\Users\Rakhesh\AppData\Local] 11/22/2014 11:17 AM <DIR> Music 10/13/2014 02:55 PM <JUNCTION> My Documents [C:\Users\Rakhesh\Documents] <snip> 10/13/2014 02:55 PM <JUNCTION> SendTo [C:\Users\Rakhesh\AppData\Roaming\Microsoft\Windows\SendTo] 10/13/2014 02:55 PM <JUNCTION> Start Menu [C:\Users\Rakhesh\AppData\Roaming\Microsoft\Windows\Start Menu] 10/13/2014 02:55 PM <JUNCTION> Templates [C:\Users\Rakhesh\AppData\Roaming\Microsoft\Windows\Templates] 11/22/2014 11:17 AM <DIR> Videos 10 File(s) 11,018,843 bytes 27 Dir(s) 13,778,194,432 bytes free C:\Users\Rakhesh>cd "Start Menu" C:\Users\Rakhesh\Start Menu>dir Volume in drive C is WINDOWS Volume Serial Number is FA14-803C Directory of C:\Users\Rakhesh\Start Menu File Not Found |
The files exist, however, as I can directly browse the target:
1 2 3 4 5 6 7 8 9 10 11 |
C:\Users\Rakhesh>dir "c:\Users\Rakhesh\AppData\Roaming\Microsoft\Windows\Start Menu" Volume in drive C is WINDOWS Volume Serial Number is FA14-803C Directory of c:\Users\Rakhesh\AppData\Roaming\Microsoft\Windows\Start Menu 11/22/2014 11:17 AM <DIR> . 11/22/2014 11:17 AM <DIR> .. 12/12/2014 11:20 AM <DIR> Programs 0 File(s) 0 bytes 3 Dir(s) 13,778,071,552 bytes free |
Compare the ACLs of the target and directory junction and we see the problem:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
C:\Users\Rakhesh>icacls "Start Menu" Start Menu Everyone:(DENY)(S,RD) NT AUTHORITY\SYSTEM:(I)(OI)(CI)(F) BUILTIN\Administrators:(I)(OI)(CI)(F) CAIN\Rakhesh:(I)(OI)(CI)(F) Successfully processed 1 files; Failed processing 0 files C:\Users\Rakhesh>icacls "c:\Users\Rakhesh\AppData\Roaming\Microsoft\Windows\Start Menu" c:\Users\Rakhesh\AppData\Roaming\Microsoft\Windows\Start Menu NT AUTHORITY\SYSTEM:(OI)(CI)(F) BUILTIN\Administrators:(OI)(CI)(F) CAIN\Rakhesh:(OI)(CI)(F) Successfully processed 1 files; Failed processing 0 files |
(I could have used the Explorer GUI here but I prefer icacls
. In the GUI we have to dig down a bit more to see the relevant ACEs).
Notice a DENY
entry for Everyone
on the directory junction for listing the contents (RD
). That’s why I can’t list the junction contents (in Explorer double clicking results in trying to list the contents, while in Command Prompt entering a junction and listing are two separate tasks – that’s why entering the junction worked, but listing the contents failed).
What the above tells us is that only listing the junction contents is prohibited. If we know the names of some folders in there – as older software for whom this directory junction is present would know – we can go to those locations using the directory junction. Thus the following works:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
C:\Users\Rakhesh>cd "Start Menu"\Programs C:\Users\Rakhesh\Start Menu\Programs>dir Volume in drive C is WINDOWS Volume Serial Number is FA14-803C Directory of C:\Users\Rakhesh\Start Menu\Programs 12/12/2014 11:20 AM <DIR> . 12/12/2014 11:20 AM <DIR> .. 03/18/2014 11:45 AM <DIR> Accessibility 08/22/2013 12:17 PM <DIR> Accessories 11/22/2014 11:17 AM <DIR> Administrative Tools 12/30/2014 09:03 PM <DIR> Chrome Apps 03/18/2014 11:39 AM 369 Documents.lnk 12/30/2014 09:20 PM <DIR> Dropbox 10/23/2014 08:56 PM 1,549 Hibernate.lnk 08/19/2014 05:14 PM 1,445 Internet Explorer.lnk 08/22/2013 12:17 PM <DIR> Maintenance 03/18/2014 11:39 AM 369 Pictures.lnk 10/14/2014 08:18 PM <DIR> Private Internet Access 12/30/2014 09:20 PM <DIR> Startup 03/18/2014 11:45 AM <DIR> System Tools 4 File(s) 3,732 bytes 11 Dir(s) 13,786,742,784 bytes free |
There you go!