Load security device from a bash script?

Discussion of general topics about Mozilla Firefox
Post Reply
fieldy
Posts: 2
Joined: May 23rd, 2011, 9:07 am

Load security device from a bash script?

Post by fieldy »

I'm hoping someone will want to get their teeth into this, if not, if i find an answer, as always i will update this post.

Within Firefox 3.6 (and older versions) It is possible to load a security device such as a token Edit -> Preferences -> Advanced -> Encryption -> Security Devices

This allows you to load a smartcard or token and use this as the authentication device for websites and services such as Citrix.

I understand i can be done using the GUI, and i also know that the results of the action seem to be held in secmod.db however can anyone point me in a way of doing this from either bash or perl on a Linux System.

I have potentially 1000 users who may or may not need this done, and need a way of doing it from a command line script remotely...

Also generally speaking, where is a good place to fet command line information like this
lithopsian
Posts: 3664
Joined: September 15th, 2010, 9:03 am

Re: Load security device from a bash script?

Post by lithopsian »

I don't know how you would implement this particular function, but it sounds like something you might be able to do using the -chrome command line option. Basically this allows you to directly run code within Firefox from the command line, and then you could exit back to the command line if you wanted.
fieldy
Posts: 2
Joined: May 23rd, 2011, 9:07 am

Re: Load security device from a bash script?

Post by fieldy »

Its a good start.. Found some interesting links.

I found the following XUL files

chrome://pippki/content/device_manager.xul AD Tools->Options->Advanced->Manage Security Devices
chrome://pippki/content/load_device.xul A Tools->Options->Advanced->Manage Security Devices->Load
chrome://pippki/content/choosetoken.xul A "Please choose a token" prompt

Does anyone know how i edit these XUL files?
morat
Posts: 6437
Joined: February 3rd, 2009, 6:29 pm

Re: Load security device from a bash script?

Post by morat »

Try the following code in the error console after editing the name and path string.

Code: Select all

var name = "";
var path = "";
try {
  var PKCS11 = Components.classes["@mozilla.org/security/pkcs11;1"].
    getService(Components.interfaces.nsIPKCS11);
  PKCS11.addModule(name, path, 0, 0);
} catch(e) {
  var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
    getService(Components.interfaces.nsIWindowMediator);
  var win = wm.getMostRecentWindow("navigator:browser");
  if (e.result == Components.results.NS_ERROR_ILLEGAL_VALUE) {
    alert(win.srGetStrBundle("chrome://pipnss/locale/pipnss.properties").
      GetStringFromName("AddModuleDup"));
  } else {
    alert(win.srGetStrBundle("chrome://pipnss/locale/pipnss.properties").
      GetStringFromName("AddModuleFailure"));
  }
}

http://mxr.mozilla.org/mozilla2.0/sourc ... PKCS11.idl

If it works, then you could use the code to hack the unfocus extension.
https://addons.mozilla.org/en-US/firefox/addon/unfocus/

The unfocus extension is based on the sample code on the following page.
https://developer.mozilla.org/en/Chrome/Command_Line

BTW,

You need to use the Remote XUL Manager to use the -chrome command line option with Fx 4.
https://addons.mozilla.org/en-US/firefo ... l-manager/
Post Reply