Wednesday, April 1, 2015

Centos 7 change keyboard layout

To list all available locale:
localectl list-keymaps 
 
To set locale:
  localectl set-keyp [map name] 
 
To change the default keyboard layout for X11
  localectl set-x11-keymap [map name] 
 
To load locale keys:
  loadkeys [it,fr,us,...]
 
To persist new setting for all user add command to 
 
/etc/profile.d

Sunday, May 4, 2014

WindowBuilder supports only SmartGWT versions 2.4, 2.5. But 4.1p found

To fix this error substitute file com.google.gdt.eclipse.designer.SmartGWT_3.1.2.r43x201307151456.jar under eclipse/plugin white these (free com.google.gdt.eclipse.designer.SmartGWT_3.1.2.r43x201307151456.jar
Confirm to work with SmartGWT 4.1p + eclipse 4.3(kepler) + gwt-designer 3.1.2. Below modification code details changed on file linked
Daniele
Index: src/com/google/gdt/eclipse/designer/smart/parser/ClassLoaderValidator.java
===================================================================
src/com/google/gdt/eclipse/designer/smart/parser/ClassLoaderValidator.java (working copy)

 import org.eclipse.jdt.core.IJavaProject;
 
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
 
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;

 /**
  * {@link IClassLoaderValidator} for SmartGWT.
  * 

  * @coverage SmartGWT
  */
 public final class ClassLoaderValidator implements IClassLoaderValidator {

  private static final Pattern VERSIONS_PATTERN = Pattern.compile("^(\\d+\\.\\d+)[dp]?$");
  private static final String[] VALID_VERSIONS = {"2.4", "2.5", "3.0", "3.1", "4.0", "4.1", "5.0"};
  private static final String VALID_VERSIONS_STRING = StringUtils.join(VALID_VERSIONS, ", ");
 
   ////////////////////////////////////////////////////////////////////////////
   //

       public String runObject() throws Exception {
         Class classVersion = classLoader.loadClass("com.smartgwt.client.Version");
         String version = (String) ReflectionUtils.invokeMethod(classVersion, "getVersion()");
         Matcher matcher = VERSIONS_PATTERN.matcher(version);
         if (matcher.matches() && ArrayUtils.contains(VALID_VERSIONS, matcher.group(1))) {
           initializeSmartGWT(classLoader);
           return null;
         }

Monday, April 7, 2014

MysqlException Number Code List

When we catch exception using, for example, mysql net connector we can go deep and find out error.
We can discover error code, checking property Number of class MySqlException.



try
{
 connection.Open();
}
catch (MysqlException ex)
{
 switch (ex.Number)
                {

                    case 0:
                        return "Cannot connect to server";
                        break;

                    case 1045:
                        return "Invalid username/password, please try again";
                        break;                  

                 }
}

For a complete errors number list plaese referrer to http://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html and in the share/errmsg.txt file

Monday, March 10, 2014

Cenots set Fully Qualified Domain Name Glasshfish problem

How to configure fqdn on centos for your linux box on private lan
Remeber that domain must be always full qualified,  domain + extension  (local + .com)

Example data:
Server Name ----------------------------------- gffp01t
Static ip ----------------------------------------- 192.168.1.191
Local domain (for your lan example) ------ local.com 

1 Edit Hosts File
$ sudo vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1 gffp01t.local.com gffp01t
192.168.1.191 gffp01t.local.com gffp01t
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 
::1 gffp01t.local.com gffp01t

2 Edit network $ sudo vim  /etc/sysconfig/network HOSTNAME=gffp01t.local.com

.....
Reboot system  
.....

4 Verify
$ hostname
(output) gffp01t.local.com
$ hostname -f
(output) gffp01t.local.com

Monday, August 19, 2013

NSIS customize files based on languages

 NSIS How to get user selected language without using registry function

This is an example based on my custom needed to rename config file for my application based on language selection by user during setup 

First onInit function you must pop $LANGUAGE variable on global stack as you can retrive it later.

Function .onInit
....

....
!insertmacro MUI_LANGDLL_DISPLAY
 Pop $LANGUAGE

FunctionEnd


Then on interested section you wite your custom language files (D_MyApp..... E_MyApp.... F_MyApp...)

Section "MainSection" SEC01
  SetOutPath "$INSTDIR"
  SetOverwrite try
  SetDetailsPrint none
  SetShellVarContext all
  File "D:\projects\xxxxx\MyApp_v32_09082013\D_MyApp.exe.config"
  File "D:\projects\xxxxx\MyApp_v32_09082013\E_MyApp.exe.config"
  File "D:\projects\xxxxx\MyApp_v32_09082013\F_MyApp.exe.config"


 Here you compare $LANGUAGE with
LCID value  (see http://www.science.co.il/Language/Locale-codes.asp  for reference)

If selected language match then rename file else continue if statement

  StrCmp $LANGUAGE '1031' customGerman noDE
  customGerman:
  Rename "$INSTDIR\D_MyApp.exe.config" "$INSTDIR\MyApp.exe.config"
  goto languageSettingsDone
 
  noDE:
  StrCmp $LANGUAGE '1033' customEnglish noEN
  customEnglish:
  Rename "$INSTDIR\E_MyApp.exe.config" "$INSTDIR\MyApp.exe.config"
  goto languageSettingsDone

  noEN:
  StrCmp $LANGUAGE '1036' customFrench noFR
  customFrench:
  Rename "$INSTDIR\F_MyApp.exe.config" "$INSTDIR\MyApp.exe.config"
  goto languageSettingsDone
 
  noFR:
  goto languageSettingsDone
 
  languageSettingsDone:
....

....
....

;Contiune with other files


If this short giude has been usefull for you please leave comment

Thursday, May 9, 2013

webmin customize This web server is running in SSL mode. Try the URL


To customize webmin error message when try access to webmin login on http connection follow these few steps (this giude refer to centos 6.4 )

1 cd /usr/libexec/webmin/
2. vim miniserv.pl

3. find error string ... "This web server is running in SSL mode. Try the URL..."
4. Change it with you favorite error message string and variables
5. Save
6 service webmin restart

Done!

Now you can login to your http:\\yourdomain.ext:10000 console and see :)


Brokenpipe

Please leave a small feedback if this post has been usefull for you.

Wednesday, January 2, 2013

VSFTPD Bloccare limitare user alla home directory

Spesso quando configuriamo un daemon ftp su linux abbiamo la necessità di limitare l'accesso dei nostri utenti solamente alla rispettiva home directory.
Nel nostro caso consideriamo di usare vsftpd
In una configurazione minimale  ci troveremo nella situazione di avere un file vsftpd.conf del tipo



#--------------------------------------------------
# VSFTPD configuration file, powered by Brokenpipe
#--------------------------------------------------
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES

xferlog_enable=YES
xferlog_file=/var/log/xferlog
xferlog_std_format=YES

idle_session_timeout=600
data_connection_timeout=120

ascii_upload_enable=YES
ascii_download_enable=YES
ftpd_banner=Welcome to Ftp service. Powered by Brokenpipe

chroot_local_user=NO
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list


listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES


Ed un file chroot_list di configurazione in /etc/vsftpd/  contenente gli utenti chrooted
ad esempio

 ftptestuser

E' importante ricordare se in vsftpd.conf settiamo:

chroot_local_user=YES
chroot_list_enable=YES

significa che di default TUTTI gli user saranno chrooted AD ECCEZIONE di quelli elencati nel file chroot_list

Invece se in vsftpd settiamo:
chroot_local_user=NO
chroot_list_enable=YES

significa che di default SOLAMENTE gli user elencati nel file chroot_list saranno chrooted



500 OOPS: vsftpd: refusing to run with writable root inside chroot ()
allow_writeable_chroot=YES