vfs_ceph: add user_id smb.conf parameter
authorDavid Disseldorp <ddiss@samba.org>
Wed, 8 Feb 2017 16:26:14 +0000 (17:26 +0100)
committerDavid Disseldorp <ddiss@samba.org>
Wed, 15 Feb 2017 16:04:15 +0000 (17:04 +0100)
The "ceph: user_id" parameter can be specified in smb.conf to explicitly
set the Ceph client ID used when creating the mount handle.

Signed-off-by: David Disseldorp <ddiss@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
source3/modules/vfs_ceph.c

index 5cdb37236736c4309c5b892c451def0d0180316a..b74c2143e9143c3f7b5d55454adddf8bf2260efa 100644 (file)
@@ -85,8 +85,9 @@ static int cephwrap_connect(struct vfs_handle_struct *handle,  const char *servi
 {
        int ret;
        char buf[256];
-
-       const char * conf_file;
+       int snum = SNUM(handle->conn);
+       const char *conf_file;
+       const char *user_id;
 
        if (cmount) {
                handle->data = cmount; /* We have been here before */
@@ -94,28 +95,24 @@ static int cephwrap_connect(struct vfs_handle_struct *handle,  const char *servi
                return 0;
        }
 
-       conf_file = lp_parm_const_string(SNUM(handle->conn), "ceph", "config_file", NULL);
+       /* if config_file and/or user_id are NULL, ceph will use defaults */
+       conf_file = lp_parm_const_string(snum, "ceph", "config_file", NULL);
+       user_id = lp_parm_const_string(snum, "ceph", "user_id", NULL);
 
-       DBG_DEBUG( "[CEPH] calling: ceph_create\n" );
-       ret = ceph_create(&cmount, NULL);
-       if (ret)
+       DBG_DEBUG("[CEPH] calling: ceph_create\n");
+       ret = ceph_create(&cmount, user_id);
+       if (ret) {
                goto err_out;
-
-       if (conf_file) {
-               /* Override the config file */
-               DBG_DEBUG( "[CEPH] calling: ceph_conf_read_file\n" );
-               ret = ceph_conf_read_file(cmount, conf_file);
-       } else {
-
-               DBG_DEBUG( "[CEPH] calling: ceph_conf_read_file with %s\n", conf_file);
-               ret = ceph_conf_read_file(cmount, NULL);
        }
 
+       DBG_DEBUG("[CEPH] calling: ceph_conf_read_file with %s\n",
+                 (conf_file == NULL ? "default path" : conf_file));
+       ret = ceph_conf_read_file(cmount, conf_file);
        if (ret) {
                goto err_cm_release;
        }
 
-       DBG_DEBUG( "[CEPH] calling: ceph_conf_get\n" );
+       DBG_DEBUG("[CEPH] calling: ceph_conf_get\n");
        ret = ceph_conf_get(cmount, "log file", buf, sizeof(buf));
        if (ret < 0) {
                goto err_cm_release;