Sunday, November 11, 2007

Configure STAF to run as a Windows service

There are some advantages on running STAF as a Windows service. Common reason being that the STAF functionality is available even without user logged into the system.

Configuring STAF to run as a service needs an auxiliary application, like srvany.exe. This file is part of Windows Resource Kit. Due to licensing restrictions I cannot attach the file here but it should not be big of a problem as you can download the resource kit from Microsoft for free. Do a google using the keywords "Windows Resource kit" and start from there. The filename of the installer normally is rktools.exe. Once downloaded, install the software look for srvany.exe and instsrv.exe.  You can copy this files somewhere so that you can use it other machines. See below for the steps for configuring STAF to run as a service:

1) Copy instsrv.exe and srvany.exe into C:\Windows\System32 (actually $windir\system32 ).

2) In Windows console ( Start->Run "cmd.exe"), change to directory C:\Windows\System32.

3) Install a Windows service placeholder, like:

instsrv.exe STAF C:\Windows\System32\svrany.exe

Note "STAF" here can be any string but for convenience and easy correlation we used STAF.

4) Modify this service to actually run STAFProc.exe via registry. Open HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\STAF

5) Under this subkey, add a key named as "parameters".

6) Select the new "parameters" key and add a string value named "application". It should be of type REG_SZ.

7) Change the data to "C:\STAF\bin\STAFProc.exe".

8) Close regedit.exe.

9) If we need STAF to interact with the desktop then minor adjustment is necessary. Modify the STAF service using services applet ( in Windows 2003/Windows XP it can be accessed via Start->Control Panel->Administrative Tools->Services ). Double click on STAF service ( or via context menu then Properties ), select Log on tab. Enable "Allow service to interact with desktop"

Useful links:

How To Create a User-Defined Service by Microsoft

~ts

Wednesday, November 07, 2007

Configure Ubuntu to search hostnames across domains

I am not sure if I messed up my Ubuntu system or something but it does not search hostnames within our intranet on different domains. On Windows systems, this is automatically done for you through DNS Suffix Search List which I believe is being supplied by DHCP server, not really sure. Now to get my Ubuntu machine ping other hosts on another domain we have to do two things. First we need to do this. Then configure our Ubuntu box for the search order. This can be done in two ways. GUI via System->Administration->Network, it should show something like this:

Or this can be done through the file /etc/resolv.conf. See below for an equivalent configuration.

#: nano -w /etc/resolv.conf

#<-- start here
nameserver 142.176.1.82
nameserver 142.176.1.101
nameserver 142.176.1.102
domain asia.nothing.com
search asia.nothing.com na.nothing.com

~ts

Wednesday, October 03, 2007

Manually configure networking in Debian under VBox

For some reason my Debian 4.0 box running under VBOX does not connect to the internet via NAT all the time, reason? I don't know. Anyway, I was able to get it up and running using the usual old, in the terminal configuration. First, since my first interface, eth0, is configured by default to get IP from DHCP, I have to bring it down, i.e.
#: ifdown eth0
Now, let us bring it up manually with an IP that is probably not being used by other VMs running inside VBOX in this case we will try 10.0.2.3.
#: ifconfig eth0 up 10.0.2.3 netmask 255.255.255.0
Note that by default, VBOX gateway is 10.0.2.2 or basically we can also say that this is the IP address of the host machine internally. Let us now add entry into the routing table to route traffic to the gateway.
#: route add default gw 10.0.2.2
One last change we need to make is in the file /etc/resolv.conf.
#: nano -w /etc/resolv.conf

#<-- this line is not included, search for namesever
nameserver 192.xxx.xxx.xxx
Note that the IP address that should be used for the nameserver should point to an existing DNS server. Since my host is running Windows XP Sp2, nameserver/DNS can be easily determined via the command:
C:\>ipconfig /all
As sample output would be:
C:\>ipconfig /all

Windows IP Configuration

       Host Name . . . . . . . . . . . . : machine_name
       Primary Dns Suffix  . . . . . . . : me.atmy.com
       Node Type . . . . . . . . . . . . : Hybrid
       IP Routing Enabled. . . . . . . . : No
       WINS Proxy Enabled. . . . . . . . : No
       DNS Suffix Search List. . . . . . : me.atmy.com
                                           me2.atmy.com

Ethernet adapter VMware Network Adapter VMnet8:

       Connection-specific DNS Suffix  . :
       Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for
VMnet8
       Physical Address. . . . . . . . . : 00-50-56-C0-00-08
       Dhcp Enabled. . . . . . . . . . . : No
       IP Address. . . . . . . . . . . . : 192.168.33.1
       Subnet Mask . . . . . . . . . . . : 255.255.255.0
       Default Gateway . . . . . . . . . :

Ethernet adapter VMware Network Adapter VMnet1:

       Connection-specific DNS Suffix  . :
       Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for
VMnet1
       Physical Address. . . . . . . . . : 00-50-56-C0-00-01
       Dhcp Enabled. . . . . . . . . . . : No
       IP Address. . . . . . . . . . . . : 192.168.106.1
       Subnet Mask . . . . . . . . . . . : 255.255.255.0
       Default Gateway . . . . . . . . . :

Ethernet adapter Wireless Network Connection:

       Media State . . . . . . . . . . . : Media disconnected
       Description . . . . . . . . . . . : Intel(R) PRO/Wireless 2200BG Network
Connection
       Physical Address. . . . . . . . . : 00-13-CE-F0-BD-CB

Ethernet adapter Network Bridge (Network Bridge):

       Media State . . . . . . . . . . . : Media disconnected
       Description . . . . . . . . . . . : MAC Bridge Miniport
       Physical Address. . . . . . . . . : 02-FF-EC-C1-2E-3C

PPP adapter HUAWEI3G.Globe - 3G with HSDPA:

       Connection-specific DNS Suffix  . :
       Description . . . . . . . . . . . : WAN (PPP/SLIP) Interface
       Physical Address. . . . . . . . . : 00-53-45-00-00-00
       Dhcp Enabled. . . . . . . . . . . : No
       IP Address. . . . . . . . . . . . : 10.60.136.220
       Subnet Mask . . . . . . . . . . . : 255.255.255.255
       Default Gateway . . . . . . . . . : 10.60.136.220
       DNS Servers . . . . . . . . . . . : 192.40.100.30
                                           203.177.255.10
       NetBIOS over Tcpip. . . . . . . . : Disabled

C:\>
In the sample above we have two DNS servers, 192.40.100.30 and 203.177.255.10. So you might have a nameserver entry of both or just one of them. ~ts

Thursday, September 20, 2007

How to get Linux box ping a Windows machine via netbios/wins

Name resolution in Linux is controlled by System Databases and Name Switch Configuration file which is located in /etc/nsswitch.conf, at least for my Debian based system. Note this is only true I think with libc5 and newer with NYS support and the GNU C Library 2.x (libc.so.6). The most import section to get a Linux to ping a Windows machine is the hosts statement.
# ~: nano /etc/nsswitch.conf

# <----- several lines before this one
hosts: files dns wins

What this says is that the gethostbyname and similar functions will first check the local database (/etc/hosts). If the name cannot be found then do use dns and finally wins.

But for wins lookup to work, winbind needs to be installed. Winbind provides 3 major functions for integrating with Windows network. But we are not really using anyone of those 3 major functions but rather we need the functionality provided by /lib/libnss_wins.so library. So to get this file installed, do:

#: apt-get install winbind
And as a side note, I have to reboot the machine to get this to work. There might be some service that I need to restart but which I don't know. Related links:

For a Ubuntu box, use the following link:

http://ubuntuforums.org/showthread.php?t=88206

~ts

Tuesday, September 18, 2007

Creating Windows icon using GIMP

Windows application icons normally used in an application is a multi-page icon. One is 16x16 at 4bpp and 32x32 that can be set as high as 32bpp. Creating an icon in GIMP is a easy a creating a new graphics document. Set the background to transparent and size to 32x32. On the first layer, add 16x16 and on the second layer add 32x32 picture. Save the file as .ico and select 4bpp for 16x16 image and 32bpp for 32x32. That should be it and off you go, you know have a nice looking Windows icon.

Hello world assembly on x86 Linux

Hello world assembly on x86 Linux Save code below as hello.asm global _start section .data message: db 'hello, world!', 10 secti...