summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanice Chang <Janice.Chang@Sun.COM>2010-05-28 13:47:12 -0400
committerJanice Chang <Janice.Chang@Sun.COM>2010-05-28 13:47:12 -0400
commitd019449136cec9f203f106de418421095790e4e2 (patch)
tree2095dac7e741836d731dc7b09135ed267013d539
parentc94adbf911e89a6f97faa6b966bc20f795e2f959 (diff)
downloadillumos-joyent-d019449136cec9f203f106de418421095790e4e2.tar.gz
6944258 Investigate alternatives to ZFS_FORCE
6943484 Deal with poorly input dataset names 6935904 Hardcode limit on number of backup sets (DMP_NAME)
-rw-r--r--usr/src/cmd/ndmpadm/ndmpadm_main.c6
-rw-r--r--usr/src/cmd/ndmpd/include/ndmpd_prop.h4
-rw-r--r--usr/src/cmd/ndmpd/ndmp.xml4
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd_prop.c4
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd_zfs.c67
5 files changed, 69 insertions, 16 deletions
diff --git a/usr/src/cmd/ndmpadm/ndmpadm_main.c b/usr/src/cmd/ndmpadm/ndmpadm_main.c
index 4a5dbdb4fd..098ca1ce81 100644
--- a/usr/src/cmd/ndmpadm/ndmpadm_main.c
+++ b/usr/src/cmd/ndmpadm/ndmpadm_main.c
@@ -1,6 +1,5 @@
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -104,7 +103,8 @@ static char *prop_table[] = {
"tcp-port",
"backup-quarantine",
"restore-quarantine",
- "overwrite-quarantine"
+ "overwrite-quarantine",
+ "zfs-force-override"
};
#define NDMPADM_NPROP (sizeof (prop_table) / sizeof (prop_table[0]))
diff --git a/usr/src/cmd/ndmpd/include/ndmpd_prop.h b/usr/src/cmd/ndmpd/include/ndmpd_prop.h
index c2c89ab1d9..c7f7b108b0 100644
--- a/usr/src/cmd/ndmpd/include/ndmpd_prop.h
+++ b/usr/src/cmd/ndmpd/include/ndmpd_prop.h
@@ -1,6 +1,5 @@
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -113,6 +112,7 @@ typedef enum {
NDMP_BACKUP_QTN,
NDMP_RESTORE_QTN,
NDMP_OVERWRITE_QTN,
+ NDMP_ZFS_FORCE_OVERRIDE,
NDMP_MAXALL
} ndmpd_cfg_id_t;
diff --git a/usr/src/cmd/ndmpd/ndmp.xml b/usr/src/cmd/ndmpd/ndmp.xml
index 08bd642ce7..ce401d03d0 100644
--- a/usr/src/cmd/ndmpd/ndmp.xml
+++ b/usr/src/cmd/ndmpd/ndmp.xml
@@ -1,8 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<!--
-Copyright 2008 Sun Microsystems, Inc. All rights reserved.
-Use is subject to license terms.
+Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
NOTE: This service manifest is not editable; its contents will
be overwritten by package or patch operations, including
@@ -137,6 +136,7 @@ POSSIBILITY OF SUCH DAMAGE.
<propval name='mover-recordsize' type='integer' value='60' />
<propval name='restore-wildcard-enable' type='boolean' value='false' />
<propval name='tcp-port' type='integer' value='10000' />
+ <propval name='zfs-force-override' type='astring' value='off' />
<propval name='value_authorization' type='astring'
value='solaris.smf.value.ndmp' />
</property_group>
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_prop.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_prop.c
index bff6e77073..47ed20ec30 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_prop.c
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_prop.c
@@ -1,6 +1,5 @@
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
*/
/*
@@ -89,6 +88,7 @@ ndmpd_cfg_param_t ndmpd_cfg_table[] =
{"backup-quarantine", "", 0, NDMP_CF_NOTINIT},
{"restore-quarantine", "", 0, NDMP_CF_NOTINIT},
{"overwrite-quarantine", "", 0, NDMP_CF_NOTINIT},
+ {"zfs-force-override", "", 0, NDMP_CF_NOTINIT},
};
/*
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_zfs.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_zfs.c
index 4c12778ad1..4296810c8a 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_zfs.c
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_zfs.c
@@ -144,9 +144,12 @@ static int ndmpd_zfs_backup(ndmpd_zfs_args_t *);
*
* 0.0.n/0.bob.p
* 0.0.u/1.bob.p/0.jane.d
+ *
+ * Note: NDMPD_ZFS_SUBPROP_MAX is calculated based on ZFS_MAXPROPLEN
*/
#define NDMPD_ZFS_PROP_INCR "com.sun.ndmp:incr"
+#define NDMPD_ZFS_SUBPROP_MAX 28
/*
* NDMPD_ZFS_LOG_ZERR
@@ -858,6 +861,8 @@ ndmpd_zfs_restore_recv_write(ndmpd_zfs_args_t *ndmpd_zfs_args)
flags.nomount = B_TRUE;
+ NDMP_LOG(LOG_DEBUG, "nz_zfs_force: %d\n", ndmpd_zfs_args->nz_zfs_force);
+
if (ndmpd_zfs_args->nz_zfs_force)
flags.force = B_TRUE;
@@ -1241,6 +1246,8 @@ ndmpd_zfs_backup_getpath(ndmpd_zfs_args_t *ndmpd_zfs_args, char *zpath,
ndmpd_zfs_args->nz_snapname[0] = '\0';
}
+ (void) trim_whitespace(ndmpd_zfs_args->nz_dataset);
+
return (0);
}
@@ -1442,10 +1449,45 @@ ndmpd_zfs_getenv_zfs_mode(ndmpd_zfs_args_t *ndmpd_zfs_args)
return (0);
}
+/*
+ * ndmpd_zfs_getenv_zfs_force()
+ *
+ * If SMF property zfs-force-override is set to "yes" or "no", this
+ * value will override any value of NDMP environment variable ZFS_FORCE
+ * as set by the DMA admin (or override the default of 'n', if ZFS_FORCE
+ * is not set). By default, zfs-force-override is "off", which means it
+ * will not override ZFS_FORCE.
+ */
+
static int
ndmpd_zfs_getenv_zfs_force(ndmpd_zfs_args_t *ndmpd_zfs_args)
{
char *envp_force;
+ char *override;
+
+ override = ndmpd_get_prop(NDMP_ZFS_FORCE_OVERRIDE);
+
+ if (strcasecmp(override, "yes") == 0) {
+ ndmpd_zfs_args->nz_zfs_force = B_TRUE;
+ NDMP_LOG(LOG_NOTICE,
+ "SMF property zfs-force-override set to 'yes', "
+ "overriding ZFS_FORCE");
+ return (0);
+ }
+
+ if (strcasecmp(override, "no") == 0) {
+ ndmpd_zfs_args->nz_zfs_force = B_FALSE;
+ NDMP_LOG(LOG_NOTICE,
+ "SMF property zfs-force-override set to 'no', "
+ "overriding ZFS_FORCE");
+ return (0);
+ }
+
+ if (strcasecmp(override, "off") != 0) {
+ ndmpd_zfs_dma_log(ndmpd_zfs_args, NDMP_LOG_ERROR,
+ "SMF property zfs-force-override set to invalid value of "
+ "'%s'; treating it as 'off'.", override);
+ }
envp_force = MOD_GETENV(ndmpd_zfs_params, "ZFS_FORCE");
@@ -1663,7 +1705,7 @@ ndmpd_zfs_snapshot_prepare(ndmpd_zfs_args_t *ndmpd_zfs_args)
* ndmpd_zfs_snapshot_cleanup()
*
* If UPDATE = y, find the old snapshot (if any) corresponding to
- * {LEVEL, DMPNAME, ZFS_MODE}. If it was ndmpd-generated,
+ * {LEVEL, DMP_NAME, ZFS_MODE}. If it was ndmpd-generated,
* remove the snapshot. Otherwise, update its NDMPD_ZFS_PROP_INCR
* property to remove {L, D, Z}.
*
@@ -1991,7 +2033,7 @@ ndmpd_zfs_snapshot_prop_get(zfs_handle_t *zhp, char *propstr)
* ndmpd_zfs_snapshot_prop_add()
*
* Update snapshot's NDMPD_ZFS_PROP_INCR property with
- * the current LEVEL, DMPNAME, and ZFSMODE values
+ * the current LEVEL, DMP_NAME, and ZFS_MODE values
* (add property if it doesn't exist)
*/
@@ -2052,6 +2094,8 @@ ndmpd_zfs_snapshot_prop_create(ndmpd_zfs_args_t *ndmpd_zfs_args,
char *propstr, boolean_t *set)
{
char subprop[ZFS_MAXPROPLEN];
+ char *p = propstr;
+ int slash_count = 0;
*set = B_TRUE;
@@ -2074,14 +2118,23 @@ ndmpd_zfs_snapshot_prop_create(ndmpd_zfs_args_t *ndmpd_zfs_args,
return (0);
}
- if ((strlen(propstr) + strlen(subprop) + 2) >= ZFS_MAXPROPLEN) {
- NDMP_LOG(LOG_ERR, "snapshot %s: user property "
- "%s would overflow; cannot complete operation",
+ while (*p) {
+ if (*(p++) == '/')
+ slash_count++;
+ }
+
+ if (slash_count >= NDMPD_ZFS_SUBPROP_MAX) {
+ ndmpd_zfs_dma_log(ndmpd_zfs_args, NDMP_LOG_ERROR,
+ "snapshot %s: user property %s limit of %d subprops "
+ "reached; cannot complete operation",
ndmpd_zfs_args->nz_snapname,
- NDMPD_ZFS_PROP_INCR);
+ NDMPD_ZFS_PROP_INCR,
+ NDMPD_ZFS_SUBPROP_MAX);
return (-1);
}
+ assert((strlen(propstr) + strlen(subprop) + 2) < ZFS_MAXPROPLEN);
+
(void) strlcat(propstr, "/", ZFS_MAXPROPLEN);
(void) strlcat(propstr, subprop, ZFS_MAXPROPLEN);
@@ -2331,6 +2384,6 @@ ndmpd_zfs_dma_log(ndmpd_zfs_args_t *ndmpd_zfs_args, ndmp_log_type log_type,
if ((log_type) == NDMP_LOG_ERROR) {
NDMP_LOG(LOG_ERR, buf);
} else {
- NDMP_LOG(LOG_INFO, buf);
+ NDMP_LOG(LOG_NOTICE, buf);
}
}