Skip to content

Commit

Permalink
Merge pull request openzfs#25 from FransUrbo/fixes.crypto
Browse files Browse the repository at this point in the history
Fix key retreival, keyformat==raw and crypto info in manpage
  • Loading branch information
zfsrogue committed May 2, 2013
2 parents 8c5cd90 + 145a60c commit c3b1a62
Show file tree
Hide file tree
Showing 8 changed files with 948 additions and 16 deletions.
18 changes: 18 additions & 0 deletions config/libcurl.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
dnl #
dnl # Check for libcurl
dnl #
AC_DEFUN([ZFS_AC_CONFIG_LIBCURL], [
LIBCURL=
AC_CHECK_HEADER([curl/curl.h], [], [AC_MSG_FAILURE([
*** curl/curl.h missing, libcurl-devel package required])])
AC_CHECK_LIB([curl], [curl_easy_init], [], [AC_MSG_FAILURE([
*** curl_easy_init() missing, libcurl-devel package required])])
AC_CHECK_LIB([curl], [curl_easy_setopt], [], [AC_MSG_FAILURE([
*** curl_easy_setopt() missing, libcurl-devel package required])])
AC_SUBST([LIBCURL], ["-lcurl"])
AC_DEFINE([HAVE_LIBCURL], 1, [Define if you have libcurl])
])
1 change: 1 addition & 0 deletions config/user.m4
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [
ZFS_AC_CONFIG_USER_IOCTL
ZFS_AC_CONFIG_USER_ZLIB
ZFS_AC_CONFIG_USER_LIBUUID
ZFS_AC_CONFIG_LIBCURL
ZFS_AC_CONFIG_USER_LIBBLKID
ZFS_AC_CONFIG_USER_LIBSELINUX
ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN
Expand Down
13 changes: 7 additions & 6 deletions lib/libzfs/libzfs_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include <libgen.h>
#include <sys/fs/zfs.h>
#include <sys/zio_crypt.h>
//#include <curl/curl.h>
#include <curl/curl.h>

#include "zfs_namecheck.h"
#include "zfs_prop.h"
Expand Down Expand Up @@ -149,6 +149,7 @@ parse_locator(key_locator_t *locator, char *s, int len, char **uri)
*uri = s;
return (B_TRUE);
}
#endif

if ((len > strlen(LOC_HTTPS) &&
(strncmp(LOC_HTTPS, s, strlen(LOC_HTTPS)) == 0)) ||
Expand All @@ -158,7 +159,6 @@ parse_locator(key_locator_t *locator, char *s, int len, char **uri)
*uri = s;
return (B_TRUE);
}
#endif

return (B_FALSE);
}
Expand Down Expand Up @@ -619,6 +619,7 @@ get_pkcs11_key_value(libzfs_handle_t *hdl, zfs_cmd_t *zc,
ASSERT(errno != 0);
return (-1);
}
#endif

struct cb_arg_curl {
libzfs_handle_t *cb_hdl;
Expand All @@ -642,7 +643,6 @@ get_keydata_curl(void *ptr, size_t size, size_t nmemb, void *arg)

return (datalen);
}
#endif

static int
key_hdl_to_zc(libzfs_handle_t *hdl, zfs_handle_t *zhp, char *keysource,
Expand All @@ -660,7 +660,7 @@ key_hdl_to_zc(libzfs_handle_t *hdl, zfs_handle_t *zhp, char *keysource,
char *tmpkeydata = NULL;
size_t tmpkeydatalen = 0;
uint64_t salt;
//struct cb_arg_curl cb_curl = { 0 };
struct cb_arg_curl cb_curl = { 0 };

zc->zc_crypto.zic_clone_newkey = hdl->libzfs_crypt.zc_clone_newkey;

Expand Down Expand Up @@ -758,7 +758,6 @@ key_hdl_to_zc(libzfs_handle_t *hdl, zfs_handle_t *zhp, char *keysource,
#endif
break;
case KEY_LOCATOR_HTTPS_URI: {
#if 0
CURL *curl_hdl = curl_easy_init();
CURLcode cerr;

Expand Down Expand Up @@ -794,7 +793,6 @@ key_hdl_to_zc(libzfs_handle_t *hdl, zfs_handle_t *zhp, char *keysource,
keydatalen = cb_curl.cb_keydatalen;

curl_easy_cleanup(curl_hdl);
#endif
break;

case KEY_LOCATOR_NONE: // Avoid Warning
Expand Down Expand Up @@ -823,6 +821,9 @@ key_hdl_to_zc(libzfs_handle_t *hdl, zfs_handle_t *zhp, char *keysource,
bcopy(keydata, zc->zc_crypto.zic_keydata, keydatalen);
zc->zc_crypto.zic_keydatalen = keydatalen;
zc->zc_crypto.zic_salt = 0;

tmpkeydata = strdup(keydata);
tmpkeydatalen = keydatalen;
break;
case KEY_FORMAT_HEX:
/*
Expand Down
2 changes: 1 addition & 1 deletion man/man1/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
man_MANS = zhack.1 zpios.1 ztest.1
man_MANS = zhack.1 zpios.1 ztest.1 zfs_encrypt.1
EXTRA_DIST = $(man_MANS)

install-data-local:
Expand Down
Loading

0 comments on commit c3b1a62

Please sign in to comment.