user_mgmt: Fix for user privilege race condition

The ipmid and netipmid processes cache IPMI user data in a shared file.
The current implementation has coherency and consistency problems:

Coherence: If a user account is created and immediately enabled with
IPMI commands, the updated data may not be propagated to netipmid. This
condition can last indefinitely, so the cache is not coherent. The
problem is caused by a lock that doesn't work and allows both processes
to register signal handlers that write to the file.

Consistency: This cache scheme does not have a strict (or linearizable)
consistency model. The ipmid and netipmid processes have an inconsistent
view of the user database until changes propagate to netipmid. Cache
file reads are controlled by mtime comparisons with a one-second
granularity.

So mitigated the second problem by using the full 10ms resolution of
mtime. Now a new user is ready to use much faster than a client can
submit two commands.

Mitigating the second (consistency) problem does not fix the first
problem. It might hide it, but the result will still depend on
non-deterministic timing of DBus signals and mtime granularity.

To fix the coherency problem, changed sigHndlrLock to use a different
file that isn't closed after each operation. Closing a POSIX file lock
releases the lock.

Tested:
1. Verified using IPMI commands by creating multiple users continuously.
Successfully created all users and able to perform RMCPP with that user.

Command: ipmitool user set name <used id> <username>
Response:               //User created successfully
Command: ipmitool user set password <used id> <password>
Response: Set User Password command successful <user name>
Command: ipmitool channel setaccess <channel#> <user id> link=on ipmi=on
         callin=on privilege=4
Response: Set User Access (channel<number > id <user id>) successful.
Command: ipmitool raw 0x6 0x43 0x9<channel #> <user id> 0x4 0x0
                                      // Set User Access Command
Response:                //Success
Command: ipmitool user enable <user id>
Response:                //Success
Command: ipmitool -H <BMC IP> -U <user name> -P <password> -C 17 -I
         lanplus raw 0x06 0x01
Response: <device ID>           //Success

Signed-off-by: Luke Phillips <lucas.phillips@intel.com>
Signed-off-by: Jayaprakash Mutyala <mutyalax.jayaprakash@intel.com>
Change-Id: If5ede3b0f97a2ba2b33cf358a9aaaf93d765d359
2 files changed