URL Override - including sections of URL

eric1024
2014-05-09
2014-05-10
  • eric1024
    eric1024
    2014-05-09

    Is there a way to override a section of a URL?
    Example, I have a database with URLs in the following format:
    cmd://"{ENV_PROGRAMFILES_X86}\PuTTY\putty.exe" {USERNAME}@{s:Server}
    The problem is that on some computers I have putty installed on the D: drive, but normally it's on the C: drive. I want to be able to set an app-specific (not tied to the database, but set in the app configuration file) override to replace cmd://"{ENV_PROGRAMFILES_X86}\PuTTy\putty.exe" with cmd://"D:\PuTTY\putty.exe".
    Is this possible?
    I know I could change all of my URLs to be use a specific override (putty://) and then create an override on each computer, but I'd rather not have to create app specific overrides for every computer. Much cleaner to just fix the exceptions.

    Thanks!

     
  • Paul
    Paul
    2014-05-09

    As you can use environment variables all you need to do is set one at machine start up to suit your requirements. e.g. set "PuTTY=D:\", then use "%PuTTY%" in the URL.

    You could also run PuTTY from a batch file and let it determine the path, with the variables passed to the batch file.

    cheers, Paul

     
    Last edit: Paul 2014-05-09
  • eric1024
    eric1024
    2014-05-09

    The problem with that is that I would then need to add this to all computers, instead of just one. Also, this is for multiple users, so I wouldn't be able to do that on each of their machines.

    I did manage to put together a solution that seems like it would work, but the URL overrides don't behave like I would expect.

    I set the URL to putty://{USERNAME}@{s:Server} and then set the Override URL of the entry itself to: cmd://"{ENV_PROGRAMFILES_X86}\PuTTy\putty.exe" {URL:RMVSCM}
    This lets it work normally for the computers where putty is in that location.

    I then created an app-specific URL Override in the app options for "putty" and set the override to: cmd://"D:\PuTTy\putty.exe" {URL:RMVSCM} and expected that this one would override the one specified in the entry, but it doesn't. Seems that the override specified on the entry takes precedence, is that true?

     
  • Paul
    Paul
    2014-05-09

    You need to set the PuTTY scheme override in the global override: http://keepass.info/help/base/autourl.html#override
    Now set the URL to putty://{USERNAME}@{s:Server}
    No need to set a local override.

    cheers, Paul

     
  • eric1024
    eric1024
    2014-05-09

    But the global override is specific to that instance of the KeePass app. If I open the DB on another computer with a fresh install of KeePass, those URLs won't work unless I create the override on that computer too. I'm trying to avoid going back to each computer that uses the DB and setting up overrides. That's why I was trying to set the local override on the entry itself, so that one could open the DB on any computer where putty is installed in the default location ({ENV_PROGRAMFILES_X86}\PuTTy\putty.exe) and the URLs will work. Then on the one or two computers where putty is in a different location (which I can't change), I can just setup a global override for the putty scheme on that computer to point to the correct location.
    Is it possible to change it so that the "global" (specific to the installation and not the database) override takes precedence over the override set on the specific database entry? That seems like the logical way to have them work, unless I'm missing something.

     
  • wellread1
    wellread1
    2014-05-09

    Is it possible to change it so that the "global" (specific to the installation and not the database) override takes precedence over the override set on the specific database entry?

    No, global and custom overrides are always specific to the Workspace (e.g. Windows user account or KeePass installation) not the database. The Global override overrides everything so it is rarely useful.

    If a custom override or an environment variable (e.g. %PATH% or %PUTTY%) is not useful to you, then your simplest solution is to create separate KeePass entries containing the specific URLs. You can Duplicate the entry with field references (Edit>Duplicate Entry>Check 'Replace user names and passwords with field references') so that only one entry contains the actual username and password.

    Users will soon learn which entry works for them, especially if you use a Descriptive entry title.

     
    Last edit: wellread1 2014-05-09
    • eric1024
      eric1024
      2014-05-09

      I understand that the global/custom overrides are specific to the Workspace, that's why it would be useful in this case, because it's just one or two workspaces that need something different. I wasn't talking about the global (Override all URLs), I meant the custom "URL Scheme Overrides". That is what I would like to use, but unfortunately it doesn't take precedence over the "Override URL" set in the database entry itself. I think that it should work the way I'm describing, but maybe there's some other reason that the entry-specific override takes precedence? If so, maybe I'll submit a feature request to add an option next to the entry-specific override to allow the workspace specific override to take precedence.

      With the number of entries that I would need to do this for, having that many duplicates would just get confusing and seems unnecessary.

       
      • wellread1
        wellread1
        2014-05-09

        So as I understand your situation, a solution that uses custom Workspace URL overrides alone is not appealing because you have a large number of KeePass installations and would need to configure the URL override appropriate to each installation individually.

        Have you considered creating enforced config files that contain just the Workspace URL override setting? You would just need to copy the keepass.config.enforce.xml containing the appropriate override into each KeePass program directory.


        I think that it should work the way I'm describing, but maybe there's some other reason that the entry-specific override takes precedence? If so, maybe I'll submit a feature request to add an option next to the entry-specific override to allow the workspace specific override to take precedence.

        I don't think this suggestion is very workable. Currently the entry-specific override, overrides the existing Workspace URL handler regardless of its origin (default, custom or global). If the option refers to the current workspace URL handler then 'allow the workspace specific override to take precedence' means 'never use the entry-specific override'. I don't believe that is your intent. I think the behavior you are looking for is "allow a custom URL override to take precedence only if one exists, otherwise use the entry-specific override". While this behavior may be useful, the setting is difficult to understand.

         
        Last edit: wellread1 2014-05-09
  • wellread1
    wellread1
    2014-05-09

    Where is the '"Override URL" set in the database entry itself'?

    Do you mean 'cmd://'? This is the prefix to tell KeePass that the line you entered is a command line, 'cmd://' can't be defined differently (overridden).


    Ah! I just found the "entry-specific override"

     
    Last edit: wellread1 2014-05-09
  • eric1024
    eric1024
    2014-05-09

    No, I don't mean the "cmd://".
    In the database entry, on the Properties tab. There's an "Override URL (e.g. to use a specific browser)" box.

    As I said above, if I set the URL to
    putty://{USERNAME}@{s:Server}
    and then set the Override URL of the entry itself to:
    cmd://"{ENV_PROGRAMFILES_X86}\PuTTy\putty.exe" {URL:RMVSCM}
    this works perfectly. The entry-specific override launches putty from the standard "Program Files" location and includes the command line arguments (which it got from {URL:RMVSCM}).

    I then wanted to create a Workspace-specific scheme override (called putty) just on the one or two computers which need it, which would override the putty:// url in the entry. I set that new scheme override to:
    cmd://"D:\PuTTy\putty.exe" {URL:RMVSCM}

    This does work, so long as I don't have that entry-specific override in place. With the entry-specific override in place, it continues to try to launch putty from the "Program Files" location instead of using the scheme override and using the D: drive location.
    But I need both in place in order for the url to function on all computers.
    I expected the workspace-specific scheme override to "override" the entry, but it seems that is not the case.

     
  • steelej
    steelej
    2014-05-09

    I have use two alternative schema overrides for accessing a different application. One worked on a 32 bit machine, the other on a 64 bit machine. I know there is now an environment variable available (which was added when I first had the problem) but the method worked and I have nit bothered to change it.

    This enable the KeePass configuration to be identical on all my mahines but allowed the to select the correct path in the override depenidng on the individual local machine.

    This might do the job for you.

    See the screen shot of my custom overrides

    In each of my entries I call it using

    teamviewer:// -i "{USERNAME}" -P "{PASSWORD}"

    in my URL field

     
    • eric1024
      eric1024
      2014-05-09

      Yes, that would work, but I'm trying to avoid having to go to each user's machine and change/add scheme overrides. I want the database to work "out of the box" on a fresh install of KeePass without any additional configuration (for computers which have putty installed in the default location). I'm trying to only have to make changes to the exceptions.

       
  • Paul
    Paul
    2014-05-10

    The only way I can see to do it is with a batch file that is installed with KeePass.

    cheers, Paul