SWAT Blog

Posts Tagged ‘linux’

Dissecting Executable and Linking Format (ELF)

Friday, April 1st, 2011

ELF: Executable and Linking Format
ELF is a portable object file format defining the composition and organization of the object file. Kernel and binary loader looks at this format to know how to load this file and find various pieces of information like code, initialized data, dependencies on shared libraries etc.

Types of Object files

  1. Relocatable files – holds code and data suitable to link with other object files
  2. Executable files – suitable for execution
  3. Shared object files – holds code and data suitable to link with other relocatable object or shared objects
    Object files are created by the assembler and link editor, object files are binary representations of programs intended to execute directly on a processor. 

    File Format

    Object files participate in program linking (building a program) and program execution (running a program). For convenience and efficiency, the object file format provides parallel views of a file’s contents, reflecting the differing needs of these activities.

    • ELF Header: Holds the roadmap describing the file’s organization
      Sections: Holds code/instructions, data, symbol table, relocation information, etc.
    • Program header table: Holds information to create a process image.Program header table is an array of structures, each describing a segment or other information the system needs to prepare the program for execution. An object file segment contains one or more sections
    • Section Header table: Section is an area in the object file that contains information which is useful for linking: program’s code, program’s data (variables, array, string), relocation information and other. So, in each area, several information is grouped and it has a distinct meaning: code section only hold code, data section only holds initialized or non-initialized data, etc.
    • Segments: An object file segment contains one or more sections. Segements are of variuos types – loadable, dynamic, etc.

    Dissecting an ELF

    We will start with a small C program to dissect ELF.

    #include <stdio.h>
    #include <stdlib.h>
    
    int globalVariableAssigned = 10;
    int globalVariableUnassigned;
    
    int main(int argc, char **argv){
    	int localVariable = 100;
    	printf("ELF test Coden");
    	printf("globalVariableAssigned = %dn", globalVariableAssigned);
    	printf("globalVariableUnassigned = %dn", globalVariableUnassigned);
    	printf("localVariable = %dn", localVariable);
    	return EXIT_SUCCESS;
    }

    Compile the above program

    $ gcc -o elf.o elf.c

    Now we’ll use readelf to look into the object file elf.o in more detail.

    • Looking at the ELF Header
      $ readelf -h elf.o
      • ELF Header: Holds the roadmap describing the file’s organization
        Sections: Holds code/instructions, data, symbol table, relocation information, etc.
      • Program header table: Holds information to create a process image.Program header table is an array of structures, each describing a segment or other information the system needs to prepare the program for execution. An object file segment contains one or more sections
      • Section Header table: Section is an area in the object file that contains information which is useful for linking: program’s code, program’s data (variables, array, string), relocation information and other. So, in each area, several information is grouped and it has a distinct meaning: code section only hold code, data section only holds initialized or non-initialized data, etc.
      • Segments: An object file segment contains one or more sections. Segements are of variuos types – loadable, dynamic, etc.
        • The executable is created for Advanced Micro Devices X86-64 (Machine field)
        • The object is a relocatable object file (Type field)
        • The program has 25 sections
      • Looking at the ELF Header

        $ readelf -h elf.o

        Thue output is as follows on my 64 bit machine:

        ELF Header:
          Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
          Class:                             ELF64
          Data:                              2's complement, little endian
          Version:                           1 (current)
          OS/ABI:                            UNIX - System V
          ABI Version:                       0
          Type:                              REL (Relocatable file)
          Machine:                           Advanced Micro Devices X86-64
          Version:                           0x1
          Entry point address:               0x0
          Start of program headers:          0 (bytes into file)
          Start of section headers:          22296 (bytes into file)
          Flags:                             0x0
          Size of this header:               64 (bytes)
          Size of program headers:           0 (bytes)
          Number of program headers:         0
          Size of section headers:           64 (bytes)
          Number of section headers:         25
          Section header string table index: 22

        Few interesting things that the header highlights:

      • Listing sections
        Below is the stripped out version of the output listing all 25 sections:

        Section Headers:
          [Nr] Name              Type             Flags  Link  Info  Align
          [ 0]                   NULL             	   0	 0     0
          [ 1] .text             PROGBITS         AX       0     0     4
          [ 2] .rela.text        RELA                     23     1     8
          [ 3] .data             PROGBITS         WA       0     0     4
          [ 4] .bss              NOBITS           WA       0     0     4
          [ 5] .debug_abbrev     PROGBITS                  0     0     1
          [ 6] .debug_info       PROGBITS                  0     0     1
          [ 7] .rela.debug_info  RELA                     23     6     8
          [ 8] .debug_line       PROGBITS                  0     0     1
          [ 9] .rela.debug_line  RELA                     23     8     8
          [10] .debug_macinfo    PROGBITS                  0     0     1
          [11] .rodata           PROGBITS         A       0     0     8
          [12] .debug_loc        PROGBITS                  0     0     1
          [13] .debug_pubnames   PROGBITS                  0     0     1
          [14] .rela.debug_pubna RELA                     23    13     8
          [15] .debug_aranges    PROGBITS                  0     0     1
          [16] .rela.debug_arang RELA                     23    15     8
          [17] .debug_str        PROGBITS         MS       0     0     1
          [18] .comment          PROGBITS         MS       0     0     1
          [19] .note.GNU-stack   PROGBITS                  0     0     1
          [20] .eh_frame         PROGBITS          A       0     0     8
          [21] .rela.eh_frame    RELA                     23    20     8
          [22] .shstrtab         STRTAB                    0     0     1
          [23] .symtab           SYMTAB                   24    17     8
          [24] .strtab           STRTAB                    0     0     1

        Most notable are:

        • “.text” which has a “X” or executable flag against it.
          To find out what is contained in this section we can take an object dump of this section

          $ objdump -d -j .text elf.o

          And the output is indeed the machine code of main() function. see partial output below:

          0000000000000000 <main>:
             0:	55                   	push   %rbp
             1:	48 89 e5             	mov    %rsp,%rbp
             4:	48 83 ec 20          	sub    $0x20,%rsp
             8:	89 7d ec             	mov    %edi,-0x14(%rbp)
             b:	48 89 75 e0          	mov    %rsi,-0x20(%rbp)
             f:	c7 45 fc 64 00 00 00 	movl   $0x64,-0x4(%rbp)
            16:	bf 00 00 00 00       	mov    $0x0,%edi
          ...
          ...
            66:	e8 00 00 00 00       	callq  6b <main+0x6b>
            6b:	b8 00 00 00 00       	mov    $0x0,%eax
            70:	c9                   	leaveq
            71:	c3                   	retq   
        • “.data” section hold all the initialized global variables inside the program that do not live inside the stack.
          To find out what is contained in this section we can take an object dump of this section

          $ objdump -d -j .data elf.o

          And output shows one assigned variable, which actually is variable globalVariableAssigned in the test program

          Disassembly of section .data:
          
          0000000000000000 <globalVariableAssigned>:
             0:	0a 00 00 00                                         ....
        • “.bss” – BSS (Block Started by Symbol) is a section where all unitialized variables are mapped. You can find out the content of this section using objdump. I am not going to to save some formatting on the blog. :)

Linux kernel development and debugging using Eclipse CDT

Friday, February 11th, 2011

This blog entry is inspired by Takis blog . This entry can be seen as the revised version of Takis blog entry with consideration to latest Eclipse and Linux Kernel versions.

Prerequisites

The steps below would work on Debian, Ubuntu and Mint Linux. I have used Linux Mint.

You need latest version of Eclipse IDE for C/C++ Developers (I have used Helios). You can download from http://www.eclipse.org/downloads/

For rest of this guide you’d need several packages that you can install using following command


apt-get install git-core kernel-package fakeroot build-essential libncurses5 libncurses5-dev qemu kvm crash kexec-tools makedumpfile kernel-wedge libelf-dev asciidoc binutils-dev debootstrap genext2fs e2fsprogs

STEP 1: Get the Kernel source using git.

Run following command to clone the kernel source into your home folder:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git ~/linux-2.6

STEP 2: Create a build directory

Create build directory in /mnt directory as its the best place to keep any mountable file system.

mkdir -p /mnt/build/linux-2.6

STEP 3: Configure kernel

First run make oldconfig, which will read the defaults from an existing .config and rewrite necessary links and files.

cd ~/linux-2.6
yes "" | make oldconfig

Now make changes to default configure to enable debugging options using menuconfig. You can also use xconfig if you’re using X.

make menuconfig O=/mnt/build/linux-2.6

Select “Kernel hacking” menu


Enable “Compile the kernel with debug info”


Enable “Compile the kernel with frame pointers”

STEP 4: Disable automatic build in Eclipse

Open Eclipse with CDT plugin

Kernel code is huge and we wouldn’t want to enable automatic building after every change.  Go to “Window->Preferences” menu, Select “General->Workspace” and deselect “Build automatically” checkbox

STEP 5: Add kernel project in Eclipse

Create a new project. Go to  File->New->Project then select C Project.

Click Next

Enter project name – I have used linux2.6

Uncheck “Use Default Location” and select the linux source directory (~/linux2.6 in my case)

Select “Empty Project” under “Makefile project” as Project Type

Select Linux GCC as Toolchain

Click Next

Keep default values in Select Configurations window

Click Finish

Now eclipse will import the kernel source into the project and index it. This will take a while. Once complete all progress bars will disappear and the UI will look similar to below:

STEP 6: Configure build properties in Eclipse

Right click on Project and click on “Properties” from context menu.

Select “C/C++ Build” in properties window.

Uncheck “Use default build command”

Set build command as – make  O=/mnt/build/linux-2.6

Set build directory as – /mnt/build/linux-2.6

Now the project is ready to build. Go to the menu-bar select “Project->Build all”.

If all goes well then after some time the Linux kernel build will be completed.

STEP 7: Configure debug settings in Eclipse

Right click on Project. Click on “Debug As ..” >> “Debug Configurations”

Double Click on “C/C++ Attach to Application”

Select vmlinux binary (in my case /mnt/build/linux-2.6/vmlinux) in C/C++ Application field on Main tab

Click on Debugger tab

Select GDB Server in Debugger option under main tab

Click on Connection tab

Select TCP in Connection “Type” field

Enter localhost in “Host name or IP address” field

Enter 1234 in “Port Number” field

STEP 8: Prepare a root filesystem for testing kernel

You’d need a root filesystem in order to boot and test the kernel. I prefer not using filesystem of my host machine. Here is a recipe to build a basic 8GB root file system


cd /mnt
sudo debootstrap sid sid

echo -e "rootnroot" | chroot sid passwd
echo -e "auto loniface lo inet loopbacknauto eth0niface eth0 inet dhcp" > sid/etc/network/interfaces
ln -sf vimrc sid/etc/vimrc.tiny
rm -f sid/etc/udev/rules.d/70-persistent-net.rules
echo atul > sid/etc/hostname
echo cgroup /mnt/cgroup cgroup defaults >> sid/etc/fstab
mkdir -p sid/mnt/cgroup

BLOCKS=$(((1024*$(du -m -s sid | awk '{print $1}')*12)/10))
genext2fs -z -d sid -b $BLOCKS -i 1024 sid.ext3
resize2fs sid.ext3 8G
tune2fs -j -c 0 -i 0 sid.ext3
rm -rf sid

Notice I have setup root password as “root”

STEP 9: Run QEMU to launch the kernel build

Use following command to startup QEMU


qemu -no-kvm -s -S  -kernel /mnt/build/linux-2.6/arch/x86/boot/bzImage -hda /mnt/sid.ext3 -append "root=/dev/sda"

In case you’re using 64 bit host the use following command


qemu-system-x86_64 -no-kvm -s -S  -kernel /mnt/build/linux-2.6/arch/x86/boot/bzImage -hda /mnt/sid.ext3 -append "root=/dev/sda"

At this point you’ll see a blank QEMU terminal window. The “-s” option is a shorthand for -gdb tcp::1234, i.e. open a gdbserver on TCP port
1234. The “-S” option stops the CPU to start at startup. Now QEMU is waiting for kernel to start in debug mode
STEP 10: Start Kernel in Debug mode
From the menu bar in Eclipse click on debug icon
Then click on Linux2.6 Default debug configuration to run from the drop down list.
Launching might take a while, you can see the progress a the bottom right progress bar

Once the application is ready to launch it will prompt you to open the debugging perspective. Click on Yes.

Now the Eclipse perspective will change form development to Debug

Click “Run > Step over” or press the “F6″ key to execute the kernel code line by line and examine what’s happening.
Or click “Run > Resume” or press the “F8″ key to execute the kernel code without breaks.

You can find several articles on CDT at http://www.eclipse.org/cdt/documentation.php

UPDATED:
Here is the updated URL to Taki’s blog – http://issaris.org/blog/2007/12/14/debugging-the-linux-kernel-using-eclipsecdt-and-qemu/

Step By Step configuration of DNS server

Tuesday, December 28th, 2010

Note:- Before Start
Set ip-address manually (I use 172.17.0.250)
Set hostname FQDN (I use server.pdc.home)
No need to install caching-nameserver if you are using fedora 9 to 14.

The Installation has been performed on the following Linux OS.

Server: Fedora 6 to 14, rhel 5.0, to 5.5 & Centos 5.0, to 5.5.

Note: Please be careful about the firewall and selinux policies before continuing with the configuration. Disable the Firewall & Selinux or create rules.

1. Installation of DNS Server.

[root@linux8 ~]# yum install bind* caching-nameserver*

2.Make sure that the host names are set properly

[root@linux8 ~]# vi /etc/hosts

127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
172.17.0.250 server.pdc.home server #(ip address & fqdn)

[root@linux8 ~]# vi /etc/sysconfig/network

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=server.pdc.home

[root@linux8 ~]# hostname server.pdc.home

3. DNS resolve entry

[root@linux8 ~]# vi /etc/resolv.conf

search server.pdc.home
nameserver 172.17.0.250

4. Do the following configuration to setup DNS properly.
(a)

[root@linux8 ~]# vi /etc/named.conf

options {
directory “/var/named”;
dump-file “/var/named/data/cache_dump.db”;
statistics-file “/var/named/data/named_stats.txt”;
memstatistics-file “/var/named/data/named_mem_stats.txt”;
query-source port 53;
};
zone “pdc.home” IN {
type master;
file “pdc.home.forward”;
allow-update { none; };
};

zone “0.17.172.in-addr.arpa” IN {
type master;
file “pdc.home.reverse”;
allow-update { none; };
};

(b) Create the zone file in the proper location and also create a reverse zone file.

[root@linux8 ~]# cd  /var/named
[root@linux8 ~]# cp  localhost.zone  pdc.home.forward
[root@linux8 ~]# cp  named.local  pdc.home.reverse
[root@linux8 ~]# vi  pdc.home.forward

$TTL 86400
@ IN SOA server.pdc.home. root.server.pdc.home. (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum

IN NS server.pdc.home.
IN A 127.0.0.1
server IN A 172.17.0.250

[root@linux8 ~]# vi pdc.home.reverse

$TTL 86400
@ IN SOA server.pdc.home. root.server.pdc.home. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS server.pdc.home.
250 IN PTR server.pdc.home.

(c) Restart the named service

[root@linux8 ~]# service named  restart
[root@linux8 ~]# chkconfig named on      #for permanent service on
[root@linux8 ~]# bind-chroot-admin -d
[root@linux8 ~]# bind-chroot-admin -e    #for binding with chroot Security

The DNS Server is ready now, it’s time to test.

[root@linux8 ~]# dig server.pdc.home

Answer Should look like below:

; <> DiG 9.3.4-P1 <> server.pdc.home
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 33213
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;server.pdc.home. IN A

;; ANSWER SECTION:
server.pdc.home. 86400 IN A 172.17.0.250

;; AUTHORITY SECTION:
pdc.home. 86400 IN NS server.pdc.home.

;; Query time: 0 msec
;; SERVER: 172.17.0.250#53(172.17.0.250)
;; WHEN: Mon Mar 9 13:39:47 2009
;; MSG SIZE rcvd: 63

[root@linux8 ~]# dig  -x 172.17.0.250

Answer Should look like below:

; <> DiG 9.3.4-P1 <> -x 172.17.0.250
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34497
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;250.0.17.172.in-addr.arpa. IN PTR

;; ANSWER SECTION:
250.0.17.172.in-addr.arpa. 86400 IN PTR server.pdc.home.

;; AUTHORITY SECTION:
0.17.172.in-addr.arpa. 86400 IN NS server.pdc.home.

;; ADDITIONAL SECTION:
server.pdc.home. 86400 IN A 172.17.0.250

;; Query time: 0 msec
;; SERVER: 172.17.0.250#53(172.17.0.250)
;; WHEN: Mon Mar 9 13:41:37 2009
;; MSG SIZE rcvd: 103

Move a Subversion Repository from One Remote Server to Another

Tuesday, December 28th, 2010

The servers were in remote locations and all I had was ssh access.

Step One: Back up your old repository
This is done with the svnadmin command.

svnadmin dump /srv/svn/repository_name &gt; reponame.dmp

Step Two: Create the new Repository on new svn server
This is same as creating a new project on your svn server

svnadmin create /srv/svn/repository_name

Step Three: Transfer the old Repository dump on your new svn server
You can do this by any way you want. I choose scp.

scp reponame.dmp root@remote-server:/opt/new_repo_name

Last Step: Import your old repository into the new one

root@server:~#cd /opt
root@server:/opt#svnadmin load /srv/svn/new_repository_name &lt; reponame.dmp

It’s very simple. My .dmp file was about 2GB so it took hours to transfer. But if you have physical access to the servers this could be a few minutes job.

Redmine installation on Ubuntu 10.04

Friday, December 10th, 2010

STEP 1: Install Ruby, build essentials, openssl, postgress and subversion

apt-get install wget build-essential ruby1.8 ruby1.8-dev irb1.8
rdoc1.8 zlib1g-dev libopenssl-ruby1.8 libzlib-ruby libssl-dev
libpq-dev postgresql subversion

STEP 2: Make symbolic links to the installed Ruby:

ln -s /usr/bin/ruby1.8 /usr/bin/ruby
ln -s /usr/bin/irb1.8 /usr/bin/irb

STEP 3: Download and install rubygems

wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
tar -xf rubygems*.tgz
cd rubygems*
ruby setup.rb
ln -s /usr/bin/gem1.8 /usr/bin/gem

STEP 4: Install other required gems

gem install -v=1.0.1 rack
gem install fastthread
gem install -v=2.3.5 rails
gem install postgres

STEP 5: Install Passenger and Nginx

cd /opt
wget http://rubyforge.org/frs/download.php/71376/passenger-2.2.15.tar.gz
tar xzvf passenger*.gz

STEP 6: Run the Phusion Passenger installer for Nginx:

cd passenger*/bin
./passenger-install-nginx-module

It will ask you few configuration things for nginx installation
Press Enter
Press 1
Press Enter

STEP 7: Configure Nginx

Nginx is now installed in /opt/nginx, but we need a way of controlling it. Create a file called #/etc/init.d/nginx and copy the following script contents into it:

vi /etc/init.d/nginx

Paste below code into the file:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          nginx
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server
# Description:       starts nginx using start-stop-daemon
### END INIT INFO
PATH=/opt/nginx/sbin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/nginx/sbin/nginx
NAME=nginx
DESC=nginx
test -x $DAEMON || exit 0
# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
. /etc/default/nginx
fi
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile /opt/nginx/logs/$NAME.pid 
--exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /opt/nginx/logs/$NAME.pid 
--exec $DAEMON
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile 
/opt/nginx/logs/$NAME.pid --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --pidfile 
/opt/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration:"
start-stop-daemon --stop --signal HUP --quiet --pidfile /opt/nginx/logs/$NAME.pid 
--exec $DAEMON
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload|force-reload}" &gt;&amp;2
exit 1
;;
esac
exit 0

Save & exit:

Run the following command to set system startup links:

chmod +x /etc/init.d/nginx
/usr/sbin/update-rc.d -f nginx defaults

If you want to change the default port 80 to 8080 then edit

vi /opt/nginx/conf/nginx.conf
listen 127.0.0.1:8080;

STEP 8: Installing and Configuring Redmine:-

Download Redmine

mkdir -p /srv/www/redmine
cd /srv/www/redmine/
svn co http://redmine.rubyforge.org/svn/branches/1.0-stable redmine

STEP 9: Create and Configure the Database

Switch to the postgres user and start up the psql shell by issuing the following commands:

su - postgres
psql

Run these commands in the psql shell to set up the database for Redmine. Specify a strong password in place of “secret”.

CREATE ROLE redmine LOGIN ENCRYPTED PASSWORD 'secret' NOINHERIT VALID UNTIL 'infinity';
CREATE DATABASE redmine WITH ENCODING='UTF8' OWNER=redmine TEMPLATE=template0;
ALTER DATABASE "redmine" SET datestyle="ISO,MDY";
q
exit
cd redmine

STEP 10: Create the file config/database.yml with the following contents:

cd config/
vi database.yml

paste these lines into the database.yml file

production:
adapter: postgresql
database: redmine
host: localhost
username: redmine
password: secret
encoding: utf8
schema_search_path: public

Run the following commands to complete database configuration:

chmod 600 config/database.yml
rake config/initializers/session_store.rb
RAILS_ENV=production rake db:migrate
RAILS_ENV=production rake redmine:load_default_data

STEP 11: Configure Email Service

Run commands to install exim4 and configure it for outgoing Internet email delivery. You can use Exim installation if you already have SMTP server configured that accepts unauthenticated locally sent mail, although you will still need to create Redmine’s email configuration file.

apt-get install exim4
dpkg-reconfigure exim4-config

Select “internet site” as the type of mail configuration to use.
Specify your systems’s fully qualified domain name as the system mail name.
Enter “127.0.0.1” when asked for the IP address to listen on for SMTP connections. For purposes of allowing Redmine to send mail, we only want to listen on localhost.
Enter “localhost.localdomain” and your fully qualified domain name when asked for the list of recipient domains.
Relay domains and machines should be left blank.
Specify “No” when asked about DNS queries.
When asked about maildirs versus mbox format, you may choose either. Maildirs are increasingly preferred by many modern mail tools.
Specify “No” when asked whether to split the configuration into smaller files.

Create the file config/email.yml and copy in the following contents. Be sure to replace the domain field with your fully qualified domain name.

File: config/email.yml

production:
delivery_method: :smtp
smtp_settings:
address: 127.0.0.1
port: 25
domain: redmine
authentication: :none

This completes email configuration for your Redmine installation.

STEP 12: Final Configuration and Testing:-

Create a “redmine” user to manage the installation. Run the following commands to set ownership and permissions on Redmine files, assign a strong password for Redmine user:

adduser redmine
cd /srv/www/redmine/
chown -R redmine:redmine *
cd redmine
chmod -R 755 files log tmp public/plugin_assets

#Edit the file /opt/nginx/conf/nginx.conf, setting the “user” parameter to “redmine”:

vim /opt/nginx/conf/nginx.conf
user  redmine;

Also, add a server section after the first example server as follows. If #you’re proxying to nginx from another web server, be sure to change the listen #directive to “listen 8080;” instead of the default.

server {
listen 80;
server_name  192.168.1.12;
root /srv/www/redmine/redmine/public/;
access_log /srv/www/redmine/redmine/log/access.log;
error_log /srv/www/redmine/redmine/log/error.log;
index index.html;
location / {
passenger_enabled on;
allow all;
}
}
/etc/init.d/nginx start

Redmine installation should be accessible at
http://localhost

Fix large Eclipse tabs and menu bar in Ubuntu

Sunday, June 6th, 2010

Run following command in terminal to edit .gtkrc-2.0 file in your home directory:

$ gedit ~/.gtkrc-2.0

Copy paste below in .gtkrc file and save :

style "gtkcompact" {
GtkButton::default_border={0,0,0,0}
GtkButton::default_outside_border={0,0,0,0}
GtkButtonBox::child_min_width=0
GtkButtonBox::child_min_heigth=0
GtkButtonBox::child_internal_pad_x=0
GtkButtonBox::child_internal_pad_y=0
GtkMenu::vertical-padding=1
GtkMenuBar::internal_padding=0
GtkMenuItem::horizontal_padding=4
GtkToolbar::internal-padding=0
GtkToolbar::space-size=0
GtkOptionMenu::indicator_size=0
GtkOptionMenu::indicator_spacing=0
GtkPaned::handle_size=4
GtkRange::trough_border=0
GtkRange::stepper_spacing=0
GtkScale::value_spacing=0
GtkScrolledWindow::scrollbar_spacing=0
GtkTreeView::vertical-separator=0
GtkTreeView::horizontal-separator=0
GtkTreeView::fixed-height-mode=TRUE
GtkWidget::focus_padding=0
}
class "GtkWidget" style "gtkcompact"

Restart Eclipse – tab size and menu bar height should now be fine.

I have tried this in Ubuntu 9.10 and 10.04 – should work for other distros as well.

  • © 2004-2015 Special Work & Technology Limited