1. Home
  2. User Management
  3. How do I restrict access of certain modules to specific users?

How do I restrict access of certain modules to specific users?

Contents

Background

We often receive the following question from customers:

I have software with limited licenses that I only want certain users to have access to. How do I make sure only those users can load the modules for that software?

This article explains how to accomplish this.

Steps

1. Place the module or modules in question in a different directory from the other modules.

  • For example, you can move the information for a module to /cm/shared/secret.

2. Modify the /etc/profile.d/modules.sh script to have logic that looks for a specific user ID, and if the ID matches, it appends the “secret” directory to the MODULEPATH_TMP variable. 

  • In this example /cm/shared/secret was used, and we are searching for the user cmtest.
    • You can specify any path that is generally available to users.
    • You can specify any user string.
  • The beginning of that script has an additional if statement nested in the if statement that matches non-root users:
    if [ "$ENABLE_LMOD" == "0" ];then 
      if [ `id -u` -ne 0 ]; then 
        MODULEPATH_TMP=/cm/local/modulefiles:/cm/shared/modulefiles 
        PATH_TMP=/sbin:/usr/sbin:/cm/local/apps/environment-modules/4.0.0/bin 
        if [ $USER == 'cmtest' ] ; then 
          MODULEPATH_TMP=$MODULEPATH_TMP:/cm/shared/secret 
        fi 
      else 
    ... 

3. When logging in as the cmtest user, we can see the module in /cm/shared/secret when running module avail.

4. If you want those modules loaded by default for the user, you can modify their .bashrc, loading the module when they log in.

 

Updated on September 8, 2025

Related Articles

Leave a Comment