Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Saturday, January 17, 2015

Rewriting Mono's certmgr

While trying to run ASP.NET 5 on Mono, I was using certmgr from Mono security tools to import some certificates for NuGet. I was dissatisfied with this tool due to the following reasons:

  • I was unable to list existing certificates, as you need to supply the store name. You have to specify one of the 5 possible store names (My, AddressBook, CA, Trust, Disallowed). Do I need to say there's NO MENTION of these names in certmgr documentation? I was unable to find that list somewhere in the web either. The most reliable way is to get it from the code.
  • It crashes almost every time when incorrect parameters are supplied. Not that it's fatal; it's just aesthetically unpleasant for me to see something like
    Unhandled Exception:
    System.IndexOutOfRangeException: Array index is out of range.
      at Mono.Tools.CertificateManager.Main (System.String[] args) [0x00000] in :0 
    [ERROR] FATAL UNHANDLED EXCEPTION: System.IndexOutOfRangeException: Array index is out of range.
      at Mono.Tools.CertificateManager.Main (System.String[] args) [0x00000] in :0
    
    
  • Code is rather sloppy, with suboptimal variable naming, unused variables, etc. My favorite part is extremely strict certificate validation:
    static bool CertificateValidation (SSCX.X509Certificate certificate, int[] certificateErrors)
    {
        // the main reason to download it is that it's not trusted
        return true;
        // OTOH we ask user confirmation before adding certificates into the stores
    }
    
I think that's enough reasons to fork it. Why not send a pull request? First of all, I think it's wrong to bundle the tool with Mono. It's an independent tool, it should be possible to update it without touching the Mono core.

So my plan is as follows:

  • Refactor certmgr to run standalone (done)
  • Set up continuous integration (done)
  • Fix existing bugs (in progress)
  • Write unit/integration tests
  • Make tool more user-friendly (e.g. display certificates from all stores by default?)
  • Implement some new features?

That's where could use some input from other people. If you have some ideas or want to contribute code - please open issues/requests on project's page on GitHub.

Thursday, April 10, 2014

Programming Pocketbook - jumpstart script

As you may know, it's possible to build apps for some older Pocketbook models, that run Linux. There are 2 SDKs for that, that I'm aware of - official and unofficial one, the latter being much more popular. Unfortunately that SDK comes with no templates. So to start development from scratch, you have to manually create a bunch of file yourself, like the makefile and the source code file, which is not fine in the XXI century. To automate the process, I created this small shell script, which creates them for you, using a name you specify:
#!/bin/bash

echo "Input project name:"

read proj_name

mkdir $proj_name
mk_file_name=$proj_name".mk"
c_file_name=$proj_name".c"
master_makefile_name="Makefile"

cd $proj_name
echo "SOURCES += "$proj_name".c" > $mk_file_name

echo "OUT = "$proj_name > $master_makefile_name
echo "include /usr/local/pocketbook/common.mk" >> $master_makefile_name

echo -e "#include \"inkview.h\"\n\nint main(int argc, char **argv)\n{\nreturn 0;\n}" > $c_file_name
Hope it hepls you too.

Saturday, March 1, 2014

Changing desktop icon fonts in xfce

You may have noticed, that desktop icon fonts that are by default in Linux Mint xfce/Xubuntu distros are awful. It’s just plain black, which means that putting any dark wallpaper will render your icon labels unreadable.
Seriously, guys! Desktop font should be light gray with a dark gray shadow, as it is in LM Mate, LM Gnome, Windows or any other OS. Usability designers have discovered this long ago, just copy this solution as many have done before you.
Fortunately, I googled up this xfce forum thread, where guy is adviced how to change the desktop fonts in xfce.
The only difference is that you have to edit the .gtkrc-xfce file, not .gtkrc-2.0, as the latter contains only include ".gtkrc-xfce" line.
So,you may copy-paste the code below to your ~/.gtkrc-xfce and relog with the current user so that changes are applied.
style "xfdesktop-icon-view" {
    XfdesktopIconView::label-alpha = 0
    XfdesktopIconView::shadow-x-offset = 1
    XfdesktopIconView::shadow-y-offset = 1
    XfdesktopIconView::shadow-color = "#101010"
    XfdesktopIconView::selected-shadow-x-offset = 1
    XfdesktopIconView::selected-shadow-y-offset = 1
    XfdesktopIconView::selected-shadow-color = "#101010"
 
    fg[NORMAL] = "#fefefe"
    fg[SELECTED] = "#fefefe"
    fg[ACTIVE] = "#fefefe"
}
widget_class "*XfdesktopIconView*" style "xfdesktop-icon-view"
If you want to change font as well, for example to ‘Verdana’, just add font_name="Verdana" line somewhere within the braces.
P.S. I think this is quite a good example of why the Linux desktop lags behind the Windows and OSX.