Multi-Category Security (MCS) Plugin Programmer Guide

Overview

This document describes Slurm's MCS plugins and the API that defines them. It is intended as a resource to programmers wishing to write their own Slurm MCS plugins.

Slurm MCS plugins must conform to the Slurm Plugin API with the following specifications:

const char plugin_name[]="full text name"

A free-formatted ASCII text string that identifies the plugin.

const char plugin_type[]="major/minor"

The major type must be "mcs." The minor type can be any suitable name for the MCS. We recommend, for example :

  • account — Use user account as the category to associate jobs to.
  • none — Default. No category associated to jobs.
  • user — Use user name as the category to associate jobs to.
  • group — Use a user group as the category to associate jobs to.

const uint32_t plugin_version

If specified, identifies the version of Slurm used to build this plugin and any attempt to load the plugin from a different version of Slurm will result in an error. If not specified, then the plugin may be loaded by Slurm commands and daemons from any version, however this may result in difficult to diagnose failures due to changes in the arguments to plugin functions or changes in other Slurm functions used by the plugin.

The programmer is urged to study src/plugins/mcs/group and src/common/slurm_mcs.c for an example implementation of a Slurm MCS plugin.

API Functions

All of the following functions are required. Functions which are not implemented must be stubbed.

int init (void)

Description:
Called when the plugin is loaded, before any other functions are called. Put global initialization here.

Returns:
SLURM_SUCCESS on success, or
SLURM_ERROR on failure.

void fini (void)

Description:
Called when the plugin is removed. Clear any allocated storage here.

Returns: None.

Note: These init and fini functions are not the same as those described in the dlopen (3) system library. The C run-time system co-opts those symbols for its own initialization. The system _init() is called before the Slurm init(), and the Slurm fini() is called before the system's _fini().

int mcs_p_set_mcs_label(job_record_t *job_ptr, char *label)

Description:
Verify and set or calculate MCS_label for a job.
Called by _job_create to get the mcs_label for a job.

Arguments:
job_ptr (input/output) pointer to the slurmctld job structure. This can be used to get user_id and group_id. Assign MCS_label if possible.
label (input) pointer to requested label or NULL if not specified.

Returns:
SLURM_SUCCESS on success, or SLURM_ERROR on failure.

int mcs_p_check_mcs_label(uint32_t user_id, char *mcs_label)

Description:
For command squeue/scontrol show nodes in case of option private. Check the compatibility between MCS_label of user and MCS_label of jobs/nodes.

Arguments:
user_id, mcs_label (input).

Returns:
SLURM_SUCCESS on success, or SLURM_ERROR on failure.

Parameters

These parameters can be used in the slurm.conf to configure the plugin.

MCSPlugin
Specifies which plugin should be used.
MCSParameters
If MCSPlugin!=mcs/none, specifies options

Last modified 23 October 2019