#include <grp.h>
#include <stddef.h>
#include <ucred.h>
+#ifdef HAVE_IDMAP
#include <idmap.h>
#include <aclutils.h>
#include <directory.h>
+#endif /* HAVE_IDMAP */
#include <sys/dnode.h>
#include <sys/spa.h>
}
/*
- * Given a path and mask of ZFS types, return a string describing this dataset.
- * This is used when we fail to open a dataset and we cannot get an exact type.
- * We guess what the type would have been based on the path and the mask of
- * acceptable types.
- */
-static const char *
-path_to_str(const char *path, int types)
-{
- /*
- * When given a single type, always report the exact type.
- */
- if (types == ZFS_TYPE_SNAPSHOT)
- return (dgettext(TEXT_DOMAIN, "snapshot"));
- if (types == ZFS_TYPE_FILESYSTEM)
- return (dgettext(TEXT_DOMAIN, "filesystem"));
- if (types == ZFS_TYPE_VOLUME)
- return (dgettext(TEXT_DOMAIN, "volume"));
-
- /*
- * The user is requesting more than one type of dataset. If this is the
- * case, consult the path itself. If we're looking for a snapshot, and
- * a '@' is found, then report it as "snapshot". Otherwise, remove the
- * snapshot attribute and try again.
- */
- if (types & ZFS_TYPE_SNAPSHOT) {
- if (strchr(path, '@') != NULL)
- return (dgettext(TEXT_DOMAIN, "snapshot"));
- return (path_to_str(path, types & ~ZFS_TYPE_SNAPSHOT));
- }
-
- /*
- * The user has requested either filesystems or volumes.
- * We have no way of knowing a priori what type this would be, so always
- * report it as "filesystem" or "volume", our two primitive types.
- */
- if (types & ZFS_TYPE_FILESYSTEM)
- return (dgettext(TEXT_DOMAIN, "filesystem"));
-
- assert(types & ZFS_TYPE_VOLUME);
- return (dgettext(TEXT_DOMAIN, "volume"));
-}
-
-/*
* Validate a ZFS path. This is used even before trying to open the dataset, to
* provide a more meaningful error message. We call zfs_error_aux() to
* explain exactly why the name was not valid.
case ZFS_PROP_MLSLABEL:
{
+#ifdef HAVE_MLSLABEL
/*
* Verify the mlslabel string and convert to
* internal hex label string.
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
m_label_free(new_sl); /* OK if null */
goto error;
-
+#else
+ zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+ "mlslabels are unsupported"));
+ (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
+ goto error;
+#endif /* HAVE_MLSLABEL */
}
case ZFS_PROP_MOUNTPOINT:
case ZFS_PROP_MLSLABEL:
{
+#ifdef HAVE_MLSLABEL
m_label_t *new_sl = NULL;
char *ascii = NULL; /* human readable label */
(void) strlcpy(propbuf, ascii, proplen);
free(ascii);
+#else
+ (void) strlcpy(propbuf,
+ getprop_string(zhp, prop, &source), proplen);
+#endif /* HAVE_MLSLABEL */
}
break;
return (0);
}
+#ifdef HAVE_IDMAP
static int
idmap_id_to_numeric_domain_rid(uid_t id, boolean_t isuser,
char **domainp, idmap_rid_t *ridp)
idmap_get_destroy(get_hdl);
return (err);
}
+#endif /* HAVE_IDMAP */
/*
* convert the propname into parameters needed by kernel
cp = strchr(propname, '@') + 1;
if (strchr(cp, '@')) {
+#ifdef HAVE_IDMAP
/*
* It's a SID name (eg "user@domain") that needs to be
* turned into S-1-domainID-RID.
return (ENOENT);
cp = numericsid;
/* will be further decoded below */
+#else
+ return (ENOSYS);
+#endif /* HAVE_IDMAP */
}
if (strncmp(cp, "S-1-", 4) == 0) {
*ridp = gr->gr_gid;
}
} else {
+#ifdef HAVE_IDMAP
/* It's a user/group ID (eg "12345"). */
uid_t id = strtoul(cp, &end, 10);
idmap_rid_t rid;
} else {
*ridp = id;
}
+#else
+ return (ENOSYS);
+#endif /* HAVE_IDMAP */
}
ASSERT3P(numericsid, ==, NULL);
if (cmd == ZFS_SMB_ACL_RENAME) {
if (nvlist_alloc(&nvlist, NV_UNIQUE_NAME, 0) != 0) {
(void) no_memory(hdl);
- return (NULL);
+ return (-1);
}
}