intel / ipmctl

BSD 3-Clause "New" or "Revised" License
183 stars 62 forks source link

"ipmctl version" returns "Initialization failed. No PMem modules in the system." as a non-root user #172

Closed sscargal closed 2 years ago

sscargal commented 3 years ago

Issue

A non-root user running ipmctl version gets the following error:

Initialization failed. No PMem modules in the system.

A version command should not require root. The expected output is the version string:

Intel(R) Optane(TM) Persistent Memory Command Line Interface Version 02.00.00.3871

It works as sudo or root

$ sudo ipmctl version
Intel(R) Optane(TM) Persistent Memory Command Line Interface Version 02.00.00.3871

ipmctl previously fixed this issue, so this appears to be a regression. Commit cc23fb179333a737701bba0c95b7bae2e40dbd81 added the option for non-root users to execute the version command. The current master branch shows the following:

DcpmemPkg/cli/CommandParser.c

  /* more detailed error */
  if (EFI_ERROR(rc))
  {
#ifdef OS_BUILD
    if (g_basic_commands) {
      // This should be updated when there are other comamnds a non-root user can run
#ifdef _MSC_VER
      Print(L"Sorry, the ipmctl command you have attempted to execute requires admin privileges.\n");
#else //_MSC_VER
      Print(L"Sorry, the ipmctl command you have attempted to execute requires root privileges.\n");
#endif //_MSC_VER
    } else {
#endif //OS_BUILD
      SetSyntaxError(CatSPrint(NULL, CLI_PARSER_ERR_VERB_EXPECTED, pInput->ppTokens[*pStart]));
#ifdef OS_BUILD
    }
#endif
  }

ipmctl help works as a non-root user.

ipmctl version now performs some sanity checks that do require root, see DcpmPkg/cli/NvmDimmCli.c#L1096. Perhaps these sanity checks can be skipped for non-root users.

StevenPontsler commented 3 years ago

I'll see about having someone look into it.

pohly commented 3 years ago

I ran into this issue when trying to determine whether I had built the right version number into a binary. I was invoking ipmctl version on a machine without any PMem, something that I would expect to work.

pohly commented 3 years ago

In my case I was building v02.00.00.3878.

sscargal commented 3 years ago

I used Ubuntu 20.04 when filing this issue. I recently tried on CentOS 7.9 with ipmctl 02.00.00.3833 and didn't see the issue

$ cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)

$ id
uid=1001(ipmctluser) gid=1001(ipmctluser) groups=1001(ipmctluser) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

$ ipmctl version
Intel(R) Optane(TM) Persistent Memory Command Line Interface Version 02.00.00.3833