A resource manager is usually a privileged process, so you should be careful not to let a client coerce it into exhausting resources or compromising the system.
When you're designing your resource manager, you should consider the following:
If the resource manager is a critical process, it should keep the PROCMGR_AID_RCONSTRAINT ability (see procmgr_ability()), but it then needs to ensure that constrained clients don't use it to allocate a resource in excess of the currently defined threshold. Unless the resource manager is managing the resource itself, compliance generally means adopting the client's constraint mode when handling a request, in one of the following ways:
resmgr_attr.flags |= RESMGR_FLAG_RCM; resmgr_attach(dpp, &resmgr_attr, name, _FTYPE_ANY, 0, &connect_funcs, &io_funcs, &io_attr))
int value = 1; // 1 to constrain, 0 to remove constraint ThreadCtl(_NTO_TCTL_RCM_GET_AND_SET, &value); /* swaps current state with value */ /* Handle the request... */ ThreadCtl(_NTO_TCTL_RCM_GET_AND_SET, &value); /* restores original state */
When a resource manager runs as a constrained process or constrains one of its threads, resource allocation requests fail when there are still resources available. It should handle these failures in the same way it would handle a failure caused by complete exhaustion of resources, generally by returning an error to the client. If the resource manager can continue to process messages, it should do so, for the sake of overall system stability.
Your resource manager can create custom abilities by calling procmgr_ability_create(); a client can get identifiers for them by calling procmgr_ability_lookup(), and then call procmgr_ability() to retain them before it switches to a non-root user ID. For more information, see Creating abilities in the QNX Neutrino Programmer's Guide. When you check a client's abilities, you can include a combination of PROCMGR_AID_* abilities and custom ones.
The resource manager library creates the following custom abilities:
Ability ID | Ability name | Description |
---|---|---|
IOFUNC_ABILITYID_CHOWN | iofunc/chown (IOFUNC_ABILITY_CHOWN) | Allow the client to set the ownership of files, even if not root |
IOFUNC_ABILITYID_DUP | iofunc/dup (IOFUNC_ABILITY_DUP) | Allow the client to duplicate another process's handle |
IOFUNC_ABILITYID_EXEC | iofunc/exec (IOFUNC_ABILITY_EXEC) | Grant execute access to files and directories that the client wouldn't normally have access to |
IOFUNC_ABILITYID_READ | iofunc/read (IOFUNC_ABILITY_READ) | Allow the client to access files for reading, even if it doesn't have the required permissions |