VFS has certain methods to control the file system context (e.g. chdir, setUid, setGid etc), but this is not exposed on the native nodejs fs module. It is instead controlled via the process module. In order to change the context on the lower fs, one would need access to the process module and this entails some extra research as to the best way to approach this. Essentially we want to be careful about tampering with the process context.
One solution to this is to ask for these methods as an additional parameter when the user passes in upperDir and lowerDir. The new constructor for EFS could look something like this:
const efs = new EncryptedFS(
vfs, // upperDir
vfs, // upperDir context control (for chdir, setUid, setGid, etc...)
fs, // lowerDir
process // lowerDir context control (for chdir, setUid, setGid, etc...)
...
)
These context control objects have to conform to an interface to ensure that the relevant methods exist:
But if we are going to use process, then we have to ensure that EFS is notified whenever the process context is changed externally to EFS (i.e. manually by user). This could be done by creating a proxy process that acts as an observer pattern and using this in EFS instead so that EFS is notified every time the cwd/gid/uid is changed in the process context. This should also go in usage notes and operator warnings to ensure correct usage by the end user.
VFS has certain methods to control the file system context (e.g. chdir, setUid, setGid etc), but this is not exposed on the native nodejs fs module. It is instead controlled via the
process
module. In order to change the context on the lower fs, one would need access to theprocess
module and this entails some extra research as to the best way to approach this. Essentially we want to be careful about tampering with the process context.One solution to this is to ask for these methods as an additional parameter when the user passes in
upperDir
andlowerDir
. The new constructor for EFS could look something like this:These context control objects have to conform to an interface to ensure that the relevant methods exist:
But if we are going to use
process
, then we have to ensure that EFS is notified whenever the process context is changed externally to EFS (i.e. manually by user). This could be done by creating a proxy process that acts as an observer pattern and using this in EFS instead so that EFS is notified every time the cwd/gid/uid is changed in the process context. This should also go in usage notes and operator warnings to ensure correct usage by the end user.