Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to not overwrite $Global:KeePassConfigurationFile variable at module loading ? #186

Open
belotn opened this issue Sep 17, 2020 · 3 comments
Assignees
Labels

Comments

@belotn
Copy link

belotn commented Sep 17, 2020

Hello,

KeePassConfiguration.xml is a system-wide configuration file and i want that my users only use a personnal Configuration file. I saw the $Global:KeePassConfigurationFile variable, but when we set it before loading the module, the value is overwrite with default path. Is there a way to prevent this behavior ?

Regards

@jkdba
Copy link
Member

jkdba commented Oct 14, 2020

One thought would be to install the module on the scope of "CurrentUser" which would mean installing for each user on a machine. This would then install the module to their c:\users\name\documents\windowspowershell\modules path, this is also where the configuration file would be stored, making it only accessible to the logged in user.

Install-Module -Name PoShKeePass -Scope CurrentUser

@jkdba jkdba self-assigned this Oct 14, 2020
@jkdba jkdba added the question label Oct 14, 2020
@belotn
Copy link
Author

belotn commented Oct 25, 2020

I'll give a try :)

@jberezanski
Copy link

As both a sysadmin who manages the configuration of workstations in my company and a devops guy who uses KeePass, I'd like to have the module installed systemwide (so better protected and updateable administratively), but to have the configuration file stored per-user (under $Env:LocalAppData, probably) - like all applications should behave by default.

A rough sketch of the solution could look like that:

  • move the initialization code (which touches the configuration file) from the .psm1 to a function
  • make that function support passing a custom config file path - the function would store this path in a module-scoped variable
    • the function could also accept some convenience switches, enabling easy selection of default per-user and per-machine config paths
  • export that function from the module, so that the user can explicitly invoke it and pass a custom config path
  • in each public function, if the configuration file has not been initialized yet, call the initialization function with a default path
    • I'd prefer the default path to be per-user (under $Env:LocalAppData), but I understand you may be reluctant to make such a breaking change (although it would increase the security of the module)

If such design would be OK, I could work on a draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants