Browse Source

Allow "localhost" as authority in file:// scheme

When using the file:// scheme, we should accept an authority
part which refers to the local machine. It has no use (since we
do not support file:// URIs pointing to other hosts), but it is
consistent with what the user accustomed to file:// URIs might
expect.
develop
Damien Goutte-Gattat 5 years ago
parent
commit
609ab3c187
  1. 8
      src/scheme-file.c

8
src/scheme-file.c

@ -20,6 +20,8 @@
#include <config.h>
#endif
#include <string.h>
#include "scheme-file.h"
#include "scheme-module.h"
#include "util.h"
@ -36,6 +38,9 @@ gfsec_scheme_file_get_file(gfsec_scheme_t scheme,
if ( scheme != GFSEC_SCHEME_FILE )
return GFSEC_SCHEME_STATUS_UNSUPPORTED_SCHEME;
if ( authority && strcmp(authority, "localhost") != 0 )
return GFSEC_SCHEME_STATUS_ERROR;
if ( (*buffer = read_file(path, len, GFSEC_SECRET_MAX_SIZE)) ) {
return GFSEC_SCHEME_STATUS_SUCCESS;
}
@ -55,6 +60,9 @@ gfsec_scheme_file_put_file(gfsec_scheme_t scheme,
if ( scheme != GFSEC_SCHEME_FILE )
return GFSEC_SCHEME_STATUS_UNSUPPORTED_SCHEME;
if ( authority && *authority && strcmp(authority, "localhost") != 0 )
return GFSEC_SCHEME_STATUS_ERROR;
if ( write_file(path, buffer, len) != -1 )
return GFSEC_SCHEME_STATUS_SUCCESS;
else

Loading…
Cancel
Save