X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fptlrpc%2Fnodemap_lproc.c;h=87a49a2f79e3da32d91a97240ab085ccd19097df;hb=6030d0cfb15bfa4cfd7aaee4e3c2a34746424dd2;hp=a8fc36f6fafbbab73239ce1cd7442b6aa2159297;hpb=253ccbd55ffe7fcdc405c9fcc4f72a47578920fe;p=fs%2Flustre-release.git diff --git a/lustre/ptlrpc/nodemap_lproc.c b/lustre/ptlrpc/nodemap_lproc.c index a8fc36f..87a49a2 100644 --- a/lustre/ptlrpc/nodemap_lproc.c +++ b/lustre/ptlrpc/nodemap_lproc.c @@ -22,7 +22,7 @@ /* * Copyright (C) 2013, Trustees of Indiana University * - * Copyright (c) 2014, 2015, Intel Corporation. + * Copyright (c) 2014, 2017, Intel Corporation. * * Author: Joshua Walgenbach */ @@ -241,6 +241,74 @@ out: LPROC_SEQ_FOPS(nodemap_fileset); /** + * Reads and prints the SELinux policy info for the given nodemap. + * + * \param m seq file in proc fs + * \param data unused + * \retval 0 success + */ +static int nodemap_sepol_seq_show(struct seq_file *m, void *data) +{ + struct lu_nodemap *nodemap; + int rc = 0; + + mutex_lock(&active_config_lock); + nodemap = nodemap_lookup(m->private); + mutex_unlock(&active_config_lock); + if (IS_ERR(nodemap)) { + rc = PTR_ERR(nodemap); + CERROR("cannot find nodemap '%s': rc = %d\n", + (char *)m->private, rc); + return rc; + } + + seq_printf(m, "%s\n", nodemap_get_sepol(nodemap)); + nodemap_putref(nodemap); + return rc; +} + +/** + * Set SELinux policy info on a nodemap. + * + * \param[in] file proc file + * \param[in] buffer string, "" + * \param[in] count \a buffer length + * \param[in] off unused + * \retval \a count on success + * \retval negative number on error + */ +static ssize_t +nodemap_sepol_seq_write(struct file *file, + const char __user *buffer, + size_t count, loff_t *off) +{ + struct seq_file *m = file->private_data; + char sepol[LUSTRE_NODEMAP_SEPOL_LENGTH + 1]; + int rc = 0; + + CLASSERT(sizeof(sepol) == sizeof(((struct lu_nodemap *)0)->nm_sepol)); + + if (count > 0) { + if (count >= sizeof(sepol)) + GOTO(out, rc = -ENAMETOOLONG); + + if (copy_from_user(sepol, buffer, count)) + GOTO(out, rc = -EFAULT); + + sepol[count] = '\0'; + + rc = nodemap_set_sepol(m->private, sepol); + } + +out: + if (rc != 0) + return rc; + + return count; +} +LPROC_SEQ_FOPS(nodemap_sepol); + +/** * Reads and prints the exports attached to the given nodemap. * * \param m seq file in proc fs, stores nodemap @@ -541,6 +609,33 @@ static int nodemap_deny_unknown_seq_show(struct seq_file *m, void *data) return 0; } +/** + * Reads and prints the audit_mode flag for the given nodemap. + * + * \param m seq file in proc fs + * \param data unused + * \retval 0 success + */ +static int nodemap_audit_mode_seq_show(struct seq_file *m, void *data) +{ + struct lu_nodemap *nodemap; + int rc; + + mutex_lock(&active_config_lock); + nodemap = nodemap_lookup(m->private); + mutex_unlock(&active_config_lock); + if (IS_ERR(nodemap)) { + rc = PTR_ERR(nodemap); + CERROR("cannot find nodemap '%s': rc = %d\n", + (char *)m->private, rc); + return rc; + } + + seq_printf(m, "%d\n", (int)nodemap->nmf_enable_audit); + nodemap_putref(nodemap); + return 0; +} + #ifdef NODEMAP_PROC_DEBUG /** * Helper functions to set nodemap flags. @@ -823,11 +918,11 @@ static int parse_nids(char *rangestr, lnet_nid_t nids[2]) &nidlist) <= 0) return -EINVAL; - if (!cfs_nidrange_is_contiguous(&nidlist)) - return -EINVAL; + rc = cfs_nidrange_find_min_max(&nidlist, nidstr[0], nidstr[1], + LNET_NIDSTR_SIZE); + if (rc < 0) + return rc; - cfs_nidrange_find_min_max(&nidlist, nidstr[0], nidstr[1], - LNET_NIDSTR_SIZE); snprintf(nidrange_str, sizeof(nidrange_str), "%s:%s", nidstr[0], nidstr[1]); @@ -1147,6 +1242,7 @@ LPROC_SEQ_FOPS_RO(nodemap_squash_gid); LPROC_SEQ_FOPS_RO(nodemap_deny_unknown); LPROC_SEQ_FOPS_RO(nodemap_map_mode); +LPROC_SEQ_FOPS_RO(nodemap_audit_mode); const struct file_operations nodemap_ranges_fops = { .open = nodemap_ranges_open, @@ -1191,6 +1287,10 @@ static struct lprocfs_vars lprocfs_nodemap_vars[] = { .fops = &nodemap_map_mode_fops, }, { + .name = "audit_mode", + .fops = &nodemap_audit_mode_fops, + }, + { .name = "squash_uid", .fops = &nodemap_squash_uid_fops, }, @@ -1207,6 +1307,10 @@ static struct lprocfs_vars lprocfs_nodemap_vars[] = { .fops = &nodemap_fileset_fops, }, { + .name = "sepol", + .fops = &nodemap_sepol_fops, + }, + { .name = "exports", .fops = &nodemap_exports_fops, }, @@ -1249,6 +1353,10 @@ static struct lprocfs_vars lprocfs_default_nodemap_vars[] = { .fops = &nodemap_exports_fops, }, { + .name = "audit_mode", + .fops = &nodemap_audit_mode_fops, + }, + { NULL } };