pondělí 29. září 2014

Apache httpd 2.4.6 hangs not servicing HTTPS

A lot of pain ... till solution found
# Apparently this fixes an issue with Apache 2.4.6 on Windows hanging
# when serving requests from Internet Explorer 10/11.
# see http://stijndewitt.wordpress.com/2014/01/10/apache-hangs-ie11/
AcceptFilter http none
AcceptFilter https none



neděle 7. září 2014

... Google Authenticator or Doogee DG800 strange error

After purchasing new chinese Android phone I needed to install Google Authenticator. But had no luck. The application worked fine but ... generated codes did not work. I tried other phones and came to a strange conclusion. The other Doogee DG800 I had show she same codes. Bud all other Android phones shown different codes. For sure all the phones shared the same secret.  The strange thing was the codes were different in some digits only. Typical difference looked like this 605678 - 604356.

As the authenticator codes are derived using hash function (RFC 6238 - TOTP), in case of an error there should be completely different results.

Fortunately - authenticator is an open source software. I cloned the repository and built my own version for debugging.

And here is the source of difference. During the computation a piece of a hash value is taken, converted to integer and then divided by a power of 10 and the remainder is the code:

int code =  truncatedHas % (int)Math.pow(10, codeLength);

On the problematic phone the result of power computation was this:
 Math.pow(10, codeLength): 999999,99999999

After cast to integer the result was 999999.

This is the answer - wrong result from system runtime library because the Math.pow function computes doubles which can be not so precise.

It is rare but it happens.

I'm going to  send a patch which does not uses double computation.

UPDATE: Issue was discussed at Stack Overflow. The main cause is a bug in the phone platform library.

úterý 26. srpna 2014

... firefox 30+ disabled NTLMv1 over insecure connection

NTLMv1 is known to be insecure but if you need it new setting was introduced:
network.negotiate-auth.allow-insecure-ntlm-v1 - defaults to false and NTLMv1 auth request is silently ignored when sent over HTTP. Set it to true to force NTLMv1authentication prompt.

Disclaimer: NTLMv1 over HTTP is considered insecure - you should know what are you doing

pátek 22. srpna 2014

... nssm - non sucking service manager

Seems really usable - new to me.
Why I like it ... it is able to start any command as a service and has several options for service shutdown (Send Ctrl-C, send WM_CLOSE,kill process)

http://nssm.cc/usage


úterý 20. května 2014

Chrome native messaging on windows

Problem:
When developing extension using native messaging you need to develop so called native messaging host - exe which is registered with chrome and  spawned by chrome when requested by the extension.
Chrome uses pipes to communicate with the host. The pipe is connected to stdin/stdout descriptors in the host process.
There is a drawback on windows - default stdin mode is TEXT. But in this mode once 0x1A is passed through, the C library closes the pipe and the host is terminated because 0x1A id end of file marker.

Solution:
Before reading attempt from the pipe set the mode to binary (defaults to text) using following code snippet:

_setmode( _fileno( stdin ), _O_BINARY )

Reference: http://msdn.microsoft.com/cs-cz/library/tw4k6df8.aspx

čtvrtek 10. dubna 2014

Convert SSH public key to a form for .authorized_hosts

Evary time i need this command it takes me minutes to retrieve the right form from my memory. Let's take a note :)

ssh-keygen -i -f pem -f ~/.ssh/id_rsa.pub

neděle 23. března 2014

Error 'LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt - Solved

No Visual Studio 2012 installed just SP1 of Visual Studio 2010.

Found this (no solution, but direction): http://stackoverflow.com/questions/10888391/error-link-fatal-error-lnk1123-failure-during-conversion-to-coff-file-inval

But it did not help.

Found this(almost solusion): http://social.msdn.microsoft.com/Forums/vstudio/en-US/d10adba0-e082-494a-bb16-2bfc039faa80/vs2012-rc-installation-breaks-vs2010-c-projects?forum=vssetup

It pointed me to the root cause - bad version od cvtres.exe which depends on missing msvcr100_clr0400.dll.

Solution: downloaded http://www.dll-files.com/dllindex/dll-files.shtml?msvcr100_clr0400

I downloaded the right version (32bit) of the file and stored it next to cvtres.exe and BINGO!!! compiling with no error.

Sahme on MS ... and shame on MS problem resolution culture. Searching the root cause is seldom seen. Uninstall/Reinstall is the only advice in most of dicussions.
 

 

neděle 8. září 2013

... chromcast like experience on smart tv

No dongle is needed to experience chromcast on SmartTV. In my case LG brand. The youtube app on the TV sucks. It's slow realllyyy sllooow. It's hard to use using only the tv remote. It's hard to use even using much better smart phone remote.       Now ... it is easy to send the youtube video from smart phone youtube app to she big screed of the smart tv.

Try it if you can!

pondělí 19. srpna 2013

... čajnafoun

... dorazil balík z dx.com obsahující telefon N6300. Cena podle kurzu Paypal 3814Kč ($184.60). Po připočtení služby České pošty v rámci celního řízení (180Kč, ale v balíku toho bylo víc, takže do ceny telefonu promítnuto jen částečně) a vyměřeného cla a DPH je reálná nákupní cena 4780Kč.

Telefon dorazil se dvěma kryty - jeden klasický "tenký" - jen zadní kryt. Druhý je pro "tlustší" variantu s větší baterkou a zkládá se ze zadního krytu a z přiklápěčího krytu displeje.

Telefon dorazil se dvěma bateriemi - jedna 1800mAh pro použití s "tenkým" krytem a druhá 2500mAh pro použití s "tlustším" krytem.

Balení dále obsahuje sluchátka, čínský nabíjecí adaptér, USB kabel a již nalepený screen protector.

UPDATE: Nevýhoda čajnafounu se ukázala díky mé nešikovnosti. A teď se nesmějte, protože to bude smutný příběh. Čajnafoun mi spadl do polevky. Fakt. A konektorem napred. A od te doby ... spise nefunguje, nez funguje. Takze jsem musel rychle hledat nahradu. A našel jsem téměř shodně vybavený trochu menší Gigabyte Aku A1. A při nákupu mi nabídli pojistku proti pohromám za 500Kč příplatek. A protože jsem stejnou pojistku využil nedávno u telefonu dětí, kývnul jsem na ni. V případě pádu do polévky by mi ho opravili za drobnou spoluúčast.

čtvrtek 8. srpna 2013

Installing GlusterFS 3.4 on Fedora 19

I was trying to install GlusterFS on Fedora 19. There were some problems which I describe here.

At first ... disable SeLinux on every Gluster node by changing /etc/selinux/config and set entry SELINUX=disabled

Packages of GlusterFS are part of Fedora 19 repository. Installation is easy.
I used following command:

sudo yum install glusterfs glusterfs-api glusterfs-fuse \
   glusterfs-server glusterfs-geo-replication 

After the packages are installed glusterd service is started. To connect the cluster nodes following command need to be issued:

sudo gluster peer probe the-other-node-ip 

But the command failed:

peer probe: failed: Probe returned with unknown errno 10

After some research using resources mentioned bellow I found the source of the problem (as usually): the firewall. Fedora 19 (and 18 already) includes firewalld.

Thing twice before changing your firewall settings. As I use virtualization and host only networking, I moved my host-only interface to the trusted zone:

sudo firewall-cmd --permanent --zone=trusted --add-interface=p7p1
sudo firewall-cmd --permanent --zone=trusted --change-interface=p7p1
sudo systemctl restart firewalld.service

To verify interface move submit:
 
sudo firewall-cmd --zone=public --list-all
sudo firewall-cmd --zone=trusted --list-all



References:

středa 7. srpna 2013

Psycho v letním kině

Dnešní promítání Psycho v letním kině mělo neopakovatelnou atmosféru. Ve chvílích, kdy film graduje se zvedl vítr přicházející bouřky .... ve scéně s Normanovou matkou ve sklepě se plátno divoce vlnilo ve větru a umocňovalo tak atmosféru filmu. Těsně před koncem plátno poryvům větru neodolalo a padlo. Úplně poslední scény s detailním záběrem do tváře Normana jsme sledovali na stěně domu daleko za původním plátnem a obličej byl tudíž obří .... nádhera.

neděle 4. srpna 2013

Convert Windows 7 Professional SP1 image from VMWare Workstation 8 to VirtualBox

I tried to  convert Windows 7 Professional SP1 running as guest in VMWare Workstation 8 to Oracle VirtualBox. The suggested scenario is to use ovftool from VMWare distribution to create OVF machine and VMDK disk image.

At the VirtualBox side the scenario suggests to Import appliance. Unfortunatelly the process fails with message "Could not find a storage controller named 'SCSI Controller'."

After some research following steps lead to working Windows guest in VirtualBox based on exported VMWare image.

I created VirtualBox machine from scratch with all settings left with their default values except memory (enlarged to 1GB) and I attached existing VMDK disk image created with ovftool (see above). Windows guest boot failed in BSOD until the disk was attached using SAS controler with LsiLogic type.

neděle 7. července 2013

Convert XML to CSV example

Input CSV

 <?xml version="1.0" encoding="utf-8"?>  
 <detail id="1243">  
  <nazev>Praktický lékař pro dospělé</nazev>  
  <jmeno>MUDr. Nomen Omen</jmeno>  
  <adresa>Street 1/234, 18000 City 8</adresa>  
  <telefon>89879076</telefon>  
  <fax/>  
  <ico>8908078</ico>  
  <poradove-cislo>000</poradove-cislo>  
  <poradove-cislo-det-prac>000</poradove-cislo-det-prac>  
  <nazev-zrizovatele>Fyzická osoba</nazev-zrizovatele>  
  <druh-zz>320 Samost.ordinace prakt.lék.pro dospělé</druh-zz>  
  <email>nomen-omen@mailer.ru</email>  
  <www/>  
 </detail>  

XSLT template file - takes one parametr output-header - when true, header is output first, output is Tab separated, no escaping nor quoting is done

 <xsl:stylesheet version="1.0"  
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  
  <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>  
  <xsl:param name="output-header" value="false"/>  
  <xsl:template match="/">  
   <xsl:if test="$output-header='true'">  
    <xsl:value-of select="concat('id','&#x09;')"/>  
    <xsl:value-of select="concat('type','&#x09;')"/>  
    <xsl:value-of select="concat('nazev','&#x09;')"/>  
    <xsl:value-of select="concat('jmeno','&#x09;')"/>  
    <xsl:value-of select="concat('adresa','&#x09;')"/>  
    <xsl:value-of select="concat('telefon','&#x09;')"/>  
    <xsl:value-of select="concat('fax','&#x09;')"/>  
    <xsl:value-of select="concat('ico','&#x09;')"/>  
    <xsl:value-of select="concat('poradove-cislo','&#x09;')"/>  
    <xsl:value-of select="concat('poradove-cislo-det-prac','&#x09;')"/>  
    <xsl:value-of select="concat('nazev-zrizovatele','&#x09;')"/>  
    <xsl:value-of select="concat('druh-zz','&#x09;')"/>  
    <xsl:value-of select="concat('email','&#x09;')"/>  
    <xsl:value-of select="concat('www','')"/>  
    <xsl:text>  
 </xsl:text>  
   </xsl:if>  
   <xsl:for-each select="//detail">  
    <xsl:value-of select="concat(@id,'&#x09;')"/>  
    <xsl:value-of select="concat('detail','&#x09;')"/>  
    <xsl:value-of select="concat(nazev,'&#x09;')"/>  
    <xsl:value-of select="concat(jmeno,'&#x09;')"/>  
    <xsl:value-of select="concat(adresa,'&#x09;')"/>  
    <xsl:value-of select="concat(telefon,'&#x09;')"/>  
    <xsl:value-of select="concat(fax,'&#x09;')"/>  
    <xsl:value-of select="concat(ico,'&#x09;')"/>  
    <xsl:value-of select="concat(poradove-cislo,'&#x09;')"/>  
    <xsl:value-of select="concat(poradove-cislo-det-prac,'&#x09;')"/>  
    <xsl:value-of select="concat(nazev-zrizovatele,'&#x09;')"/>  
    <xsl:value-of select="concat(druh-zz,'&#x09;')"/>  
    <xsl:value-of select="concat(email,'&#x09;')"/>  
    <xsl:value-of select="concat(www,'')"/>  
    <xsl:text>  
 </xsl:text>  
   </xsl:for-each></xsl:template>  
 </xsl:stylesheet>  

Customization: use your own element names, template matching rule and whatever to process more complex XMLs. Keep the structure (spaces, line ends) of the  tailing <xsl:text> to get proper line ends at the right places.

pondělí 10. června 2013

Create independent distribution of certain cygwin utility

In some cases you can find some cygwin utility useful for windows and you don't want or can't fully install cygwin. There is a handy utility called cygcheck which you can use to extract information about  certain cygwin executable dependencies. You can use the information to create standalone distribution directory of the utility. Following command extracts xmllint utility into /tmp/distro with all dependant DLLs.

mkdir /tmp/distro && cygcheck $(which xmllint) | \
grep cygwin |sed -e "s/^ \\+//" | \
cygpath -f - | \
while read x; do cp -v $x /tmp/distro; done


pátek 18. ledna 2013

... a way out of Windows symlink permission hell

For some reasons we needed to create symlinks on a Windows fileshare. Our environment was symlink ready (Win7 & WinServer 2008R2 & SMB2 everywhere). We started to try ... it sometimes worked sometimes not. Sometimes we received "You do not have sufficient privilege to perform this operation". Frustrating.
Finally we managed to make it working. We can now create symlinks from our server app directly in a shared folder.

Prerequisites
  • Windows 7+ and Windows Server 2008 R2 + and SMB2 enabled

Fileserver setup
  • the user willing to create symlinks must be 
    • granted "Create symbolic link" privilege (use Local Security Policy tool on the server)
    • granted modify right for the folder containing the symlink
Client setup
  • the user willing to create symlinks must be granted "Create symbolic link" privilege (use Local Security Policy tool on the client)
  • the right to  create symlinks must not originate from Administrators group -> the right must be granted directly to the user or indirectly via a security group
  • the user should not be a member of the Administrators group or the Administrators group should not bring the Create symlink permission (UAC disables the permission when it comes from the Administrators group --- UAC is EVIL)
  • depending on the link type used, the client computer must be able to resolve symlinks of certain type
    • turn symlink evaluation on using command (enables all kind of symlinks)
      • fsutil behavior set symlinkevaluation L2L:1 L2R:1 R2L:1 R2R:1 
If everything goes well you should be able to invoke following command to create directory symlink:

mklink /d \\server1\links-are-here\this-is-a-link \\server2\data-are-here\this-is-a-link-target

sobota 15. prosince 2012

... relativita v praxi

V roce 2009 zemřelo v USA 33 800 lidí při dopravních nehodách (zdroj). V průměru ~93 mrtvých denně. Málokdy si jich někdo všimne.

čtvrtek 29. listopadu 2012

Zákony pro lidi

... konečně ... asi pozdě jsem našel ...  už nějaký čas fungují http://www.zakonyprolidi.cz
je smutné, že podobnou aplikaci nevytvořila státní správa, ale komerční organizace. 

úterý 31. července 2012

... a pak že nerostou ....

Nestyďte se zaslabší zrak, a klidně si kliknětě pro plnou velikost fotky.



pátek 25. května 2012

Windows ACL hell solution

Error message "Access denied" makes me crazy. Whenever I see this message unexpectedly on windows computer I know that next few minutes/hours will be painful.

Windows access rights apparatus is overcomplicated for most uses. When advanced settings are combined with inheritance. When playing with ACLs man gets easily at the edge madness.

After several tries things are getting worse and worse. You can end up with a folder you can't do anything with. No rights left to you even if you are member of the Administrators group.

Following three steps should help in most cases (There are rare cases it will not help connected mainly to inability in taking ownership). Being administrator is the only prerequisite.

Steps to survive ACL hell:
  1. Taking the ownership - As a member of Administrators group you have all the power to own anything (any object) on a local system. And when there is another owner you can seize the object at your will. 
    • takeown /F file-or-folder 
    • you can use /R to do it recursively 
  2. Reseting rights - After membership is taken it is possible to get rid of all explicitly assigned ACLs using.
    • icacls file-or-folder /reset /T
  1. Test effective rights - using file Properties tab Security button Advanced tab Effective permissions - you can test whatever user you want and get his or here effective permissions.

Good luck!

 

čtvrtek 24. května 2012

...obětování plechovým bohům

... dnes před desátou na Jižní spojce probíhal obřad obětování plechovým bohům. V kruhu alegorických vozů s modrými blikajícími světly uprostřed rozpáleného asfaltového pruhu ležela oběť. Nehybná v paprscích zářícího slunce s nákrčníkem. U oběti v nábožné úctě v pokleku několik ceremoniářů dohlíželo na obřad. V obětišti jakoby se čas zastavil. Od obětiště se táhla dlouhá řada účastníků. Někteří ukrytí uvnitř svých plechových bohů, někteří poblíž.