Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSSL_STORE and absolute devices #3907

Closed
wants to merge 7 commits into from

Conversation

levitte
Copy link
Member

@levitte levitte commented Jul 11, 2017

This is related to #3897

This is an attempt to solve the problem when OSSL_STORE is presented with a path that begins with a device name.

@levitte
Copy link
Member Author

levitte commented Jul 11, 2017

Note: the tests should fail on Appveyor

@levitte
Copy link
Member Author

levitte commented Jul 11, 2017

And now, with code to handle paths that start with a device name. Hopefully, Appveyor will be happier this time.

(I'll have to try this with a device called "file" somewhere...)

@levitte levitte force-pushed the store2-and-absolute-devices branch 2 times, most recently from 7c93f99 to 6022a58 Compare July 11, 2017 10:34
@levitte levitte changed the title WIP: OSSL_STORE and absolute devices OSSL_STORE and absolute devices Jul 11, 2017
@levitte
Copy link
Member Author

levitte commented Jul 11, 2017

This seems to do it, at least on Windows, so out of WIP it goes

@levitte
Copy link
Member Author

levitte commented Jul 11, 2017

I've verified it on VMS as well.

@levitte levitte force-pushed the store2-and-absolute-devices branch 3 times, most recently from 602850f to a8e7165 Compare July 13, 2017 08:07
#endif
} else {
path = uri;
if (stat(path_data[i].path, &st) < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It helps Windows if stat is redefined as _stat. See crypto/rand/randfile.c for an example. This kind of thing allows to remove dependency of the object code from compiler /M flag. I mean with stat redefined as _stat it's up to application which /M flag to use. And without it would occasionally cause link errors.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good point, will do. Thanks for the reminder

@dot-asm
Copy link
Contributor

dot-asm commented Jul 13, 2017

On side note lack of empty lines between functions (and between functions and data) sting the eye. [I was under impression that it, empty lines between functions, was in coding style...]

to_rel_file_uri really treated all files appropriately, absolute and
relative alike, and really just constructs a URI, so gets renamed to
to_file_uri

to_file_uri, on the other hand, forces the path into an absolute one,
so gets renamed to to_abs_file_uri
We haven't tested plain absolute paths without making them URIs...
… URIs

To handle paths that contain devices (for example, C:/foo/bar.pem on
Windows), try to "open" the URI using the file scheme loader first,
and failing that, check if the device is really a scheme we know.

The "file" scheme does the same kind of thing to pick out the path
part of the URI.

An exception to this special treatment is if the URI has an authority
part (something that starts with "//" directly after what looks like a
scheme).  Such URIs will never be treated as plain file paths.
…h 'file:'

These cases are performed on Linux only.  They check that files with
names starting with 'file:' can be processed as well.
If we have a local file with a name starting with 'file:', we don't
want to check if the part after 'file:' is absolute.  Instead, mark
each possibility for absolute check if needed, and perform the
absolute check later on, when checking each actual path.
@levitte levitte force-pushed the store2-and-absolute-devices branch from a8e7165 to 127914d Compare July 14, 2017 10:37
@levitte
Copy link
Member Author

levitte commented Jul 14, 2017

ping @dot-asm

path_data[path_data_n].check_absolute = 1;
#ifdef _WIN32
/* Windows file: URIs with a drive letter start with a / */
if (p[0] == '/' && p[2] == ':' && p[3] == '/') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to double-check that p[1] is 'a' to 'z'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Done, pushing in a moment

@dot-asm dot-asm added the approval: done This pull request has the required number of approvals label Jul 15, 2017
levitte added a commit that referenced this pull request Jul 15, 2017
to_rel_file_uri really treated all files appropriately, absolute and
relative alike, and really just constructs a URI, so gets renamed to
to_file_uri

to_file_uri, on the other hand, forces the path into an absolute one,
so gets renamed to to_abs_file_uri

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from #3907)
levitte added a commit that referenced this pull request Jul 15, 2017
We haven't tested plain absolute paths without making them URIs...

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from #3907)
levitte added a commit that referenced this pull request Jul 15, 2017
Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from #3907)
levitte added a commit that referenced this pull request Jul 15, 2017
… URIs

To handle paths that contain devices (for example, C:/foo/bar.pem on
Windows), try to "open" the URI using the file scheme loader first,
and failing that, check if the device is really a scheme we know.

The "file" scheme does the same kind of thing to pick out the path
part of the URI.

An exception to this special treatment is if the URI has an authority
part (something that starts with "//" directly after what looks like a
scheme).  Such URIs will never be treated as plain file paths.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from #3907)
levitte added a commit that referenced this pull request Jul 15, 2017
…h 'file:'

These cases are performed on Linux only.  They check that files with
names starting with 'file:' can be processed as well.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from #3907)
levitte added a commit that referenced this pull request Jul 15, 2017
If we have a local file with a name starting with 'file:', we don't
want to check if the part after 'file:' is absolute.  Instead, mark
each possibility for absolute check if needed, and perform the
absolute check later on, when checking each actual path.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from #3907)
levitte added a commit that referenced this pull request Jul 15, 2017
… named

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from #3907)
@levitte
Copy link
Member Author

levitte commented Jul 15, 2017

Merged. 94437ce to 1145995

@levitte levitte closed this Jul 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approval: done This pull request has the required number of approvals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants