HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- CRTL BUG: readlink succeeds on non-link
Operating System - OpenVMS
1829149
Members
2186
Online
109986
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2008 07:49 PM
06-24-2008 07:49 PM
CRTL BUG: readlink succeeds on non-link
It's nice that VMS v8.3 includes symbolic link support. It will be even nicer when this support is completed and complies with the standard, which, at:
http://www.opengroup.org/onlinepubs/000095399/functions/readlink.html
says that readlink will fail and set errno to EINVAL when, "The path argument names a file that is not a symbolic link." On OpenVMS Alpha v8.3 with VMS83A_ACRTL V2.0 applied, calling readlink with the name of an ordinary file (not a link) succeeds and returns the contents of the file. Ouch. This means that if I have an ordinary file whose name is "foo.tmp" and whose contents are, say, "/sys$common/sysexe/dcl.exe" and I pass "foo.tmp" to readlink and call unlink with the result, I've just tried to delete a file that I (hopefully) don't have delete access to. That's an unlikely but possible scenario, but it is commonplace to call readlink in a loop where you only stop when you hit EINVAL indicating you've arrived at the target file that is not a symbolic link.
The attached file provides a simple reproducer. It just demonstrates the problem with safe temporary files and doesn't try to do anything evil.
The obvious workaround is to create a wrapper around readlink that does the check readlink fails to do; something like:
if (!lstat(filename, &st) && !S_ISLNK(st.st_mode)) {
errno = EINVAL;
return -1;
}
... now call decc$readlink
On a related matter, the standard also says that symlink will fail with ENOENT when passed a zero-length string as the name of the symbolic link. The VMS implementation instead successfully creates a link file with a bogus name (".;1").
Someone needs to actually *read* the standards and write automated tests to verify they are followed (preferably before writing the code to be tested). As far as I can see, most of the heavy lifting on symlinks was done in RMS, so the CRTL bit shouldn't have been too bad, particularly with HP-UX and Tru64 sources to lean on.
http://www.opengroup.org/onlinepubs/000095399/functions/readlink.html
says that readlink will fail and set errno to EINVAL when, "The path argument names a file that is not a symbolic link." On OpenVMS Alpha v8.3 with VMS83A_ACRTL V2.0 applied, calling readlink with the name of an ordinary file (not a link) succeeds and returns the contents of the file. Ouch. This means that if I have an ordinary file whose name is "foo.tmp" and whose contents are, say, "/sys$common/sysexe/dcl.exe" and I pass "foo.tmp" to readlink and call unlink with the result, I've just tried to delete a file that I (hopefully) don't have delete access to. That's an unlikely but possible scenario, but it is commonplace to call readlink in a loop where you only stop when you hit EINVAL indicating you've arrived at the target file that is not a symbolic link.
The attached file provides a simple reproducer. It just demonstrates the problem with safe temporary files and doesn't try to do anything evil.
The obvious workaround is to create a wrapper around readlink that does the check readlink fails to do; something like:
if (!lstat(filename, &st) && !S_ISLNK(st.st_mode)) {
errno = EINVAL;
return -1;
}
... now call decc$readlink
On a related matter, the standard also says that symlink will fail with ENOENT when passed a zero-length string as the name of the symbolic link. The VMS implementation instead successfully creates a link file with a bogus name (".;1").
Someone needs to actually *read* the standards and write automated tests to verify they are followed (preferably before writing the code to be tested). As far as I can see, most of the heavy lifting on symlinks was done in RMS, so the CRTL bit shouldn't have been too bad, particularly with HP-UX and Tru64 sources to lean on.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2008 08:12 PM
06-24-2008 08:12 PM
Re: CRTL BUG: readlink succeeds on non-link
fwiw, symlinks kinda a 'first stab' under 8.3
Andy Goldstein did a presentation at the OpenVMS Bootcamp in May 2008 about much more complete support for both symlinks and Unix compatible file naming in OpenVMS 8.next (expected to be 8.4). This may or might not change the reported problem.
This was all implemented under a Unix Portability (UP) effort. You be able to do
. cc â ^UP^a/hello.câ /obj=â ^UP^a/hello.objâ
. TYPE /SYS$LOGIN/login.com
. CREATE/SYMLINK=â ../test2â link_to_test2
. Specify explicitly whether to operate on a link or its target with /SYMLINK=[NO]TARGET
. 'mount' a directory: $ mnt dkb100:[newtest] /mnt/dkb100
. ...
Cheers,
Hein.
Andy Goldstein did a presentation at the OpenVMS Bootcamp in May 2008 about much more complete support for both symlinks and Unix compatible file naming in OpenVMS 8.next (expected to be 8.4). This may or might not change the reported problem.
This was all implemented under a Unix Portability (UP) effort. You be able to do
. cc â ^UP^a/hello.câ /obj=â ^UP^a/hello.objâ
. TYPE /SYS$LOGIN/login.com
. CREATE/SYMLINK=â ../test2â link_to_test2
. Specify explicitly whether to operate on a link or its target with /SYMLINK=[NO]TARGET
. 'mount' a directory: $ mnt dkb100:[newtest] /mnt/dkb100
. ...
Cheers,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2008 09:50 PM
06-24-2008 09:50 PM
Re: CRTL BUG: readlink succeeds on non-link
>The VMS implementation instead successfully creates a link file with a bogus name (".;1").
That's not a bogus name. It's a perfectly legitimate file name, type and version. However I'll take your word for it that this does not comply with the standard.
That's not a bogus name. It's a perfectly legitimate file name, type and version. However I'll take your word for it that this does not comply with the standard.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2008 04:22 PM
06-25-2008 04:22 PM
Re: CRTL BUG: readlink succeeds on non-link
Hein wrote:
------
Andy Goldstein did a presentation at the OpenVMS Bootcamp in May 2008 about much more complete support for both symlinks and Unix compatible file naming in OpenVMS 8.next (expected to be 8.4). This may or might not change the reported problem.
------
Good to hear there is more on the way.
Derek wrote:
------
>The VMS implementation instead successfully creates a link file with a bogus name (".;1").
That's not a bogus name. It's a perfectly legitimate file name, type and version. However I'll take your word for it that this does not comply with the standard.
------
Right. It's not bogus from the point of view of RMS, but it is bogus from the point of view of what symlink is supposed to do with it (it's not supposed to allow a link name with zero length). When writing code to comply with any well-defined requirements (not just standards) the characteristics of failure are just as important as the characteristics of success, but I'm sure I'm preaching to the choir on that one.
------
Andy Goldstein did a presentation at the OpenVMS Bootcamp in May 2008 about much more complete support for both symlinks and Unix compatible file naming in OpenVMS 8.next (expected to be 8.4). This may or might not change the reported problem.
------
Good to hear there is more on the way.
Derek wrote:
------
>The VMS implementation instead successfully creates a link file with a bogus name (".;1").
That's not a bogus name. It's a perfectly legitimate file name, type and version. However I'll take your word for it that this does not comply with the standard.
------
Right. It's not bogus from the point of view of RMS, but it is bogus from the point of view of what symlink is supposed to do with it (it's not supposed to allow a link name with zero length). When writing code to comply with any well-defined requirements (not just standards) the characteristics of failure are just as important as the characteristics of success, but I'm sure I'm preaching to the choir on that one.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP