Skip to content

Commit

Permalink
Support custom URI schemes for the keylocation property
Browse files Browse the repository at this point in the history
Every platform has their own preferred methods for implementing URI 
schemes beyond the currently supported file scheme (e.g. 'https' on 
FreeBSD would likely use libfetch, while Linux distros and illumos
would probably use libcurl, etc). It would be helpful if libzfs can 
be extended to support additional schemes in a simple manner.

A table of (scheme, handler_function) pairs is added to libzfs_crypto.c, 
and the existing functions in libzfs_crypto.c so that when the key 
format is ZFS_KEYFORMAT_URI, the scheme from the URI string is 
extracted, and a matching handler it located in the aforementioned 
table (returning an error if no matching handler is found). The handler 
function is then invoked to retrieve the key material (in the format 
specified by the keyformat property) and the key is loaded or the 
handler can return an error to abort the key loading process.

Reviewed by: Sean Eric Fagan <sef@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Jason King <jason.king@joyent.com>
Closes #10218
  • Loading branch information
jasonbking authored Apr 28, 2020
1 parent 89a6610 commit c14ca14
Show file tree
Hide file tree
Showing 3 changed files with 360 additions and 194 deletions.
11 changes: 11 additions & 0 deletions include/libzfs_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2020 by Delphix. All rights reserved.
* Copyright (c) 2018 Datto Inc.
* Copyright 2020 Joyent, Inc.
*/

#ifndef _LIBZFS_IMPL_H
Expand All @@ -33,6 +34,7 @@
#include <sys/nvpair.h>
#include <sys/dmu.h>
#include <sys/zfs_ioctl.h>
#include <regex.h>

#include <libuutil.h>
#include <libzfs.h>
Expand Down Expand Up @@ -71,6 +73,7 @@ struct libzfs_handle {
int libzfs_pool_iter;
char libzfs_chassis_id[256];
boolean_t libzfs_prop_debug;
regex_t libzfs_urire;
};

#define ZFSSHARE_MISS 0x01 /* Didn't find entry in cache */
Expand Down Expand Up @@ -124,6 +127,14 @@ typedef enum {
SHARED_SMB = 0x4
} zfs_share_type_t;

typedef int (*zfs_uri_handler_fn_t)(struct libzfs_handle *, const char *,
const char *, zfs_keyformat_t, boolean_t, uint8_t **, size_t *);

typedef struct zfs_uri_handler {
const char *zuh_scheme;
zfs_uri_handler_fn_t zuh_handler;
} zfs_uri_handler_t;

#define CONFIG_BUF_MINSIZE 262144

int zfs_error(libzfs_handle_t *, int, const char *);
Expand Down
Loading

0 comments on commit c14ca14

Please sign in to comment.