Tag Archives: file system
Variable-Size Directories

From time to time one may receive a request from the QA in line of:

For testing purposes, I need that /opt/test/xxx directory be limited to 10 Megabytes. This directory is used by the zzz application ran as user tester.

How could the directory size be limited in Linux? Is it even possible? – these are fair questions and the answer is yes. One needs to:

  1. Use the directory as a mount point for a size-limited storage device;

  2. Use the proper mount options to allow full access to the non-root user specified;

  3. Disable Selinux (easy) or allow that particular user to access data on mount points (complicated).

Let’s start with the beginning, the storage device. There are multiple options here:

  • A simple loop device (a regular file used as a file system);

  • A logical volume (LVM), assuming the disk setup is based on this technology and there is enough free space left to accomodate the new device;

  • Attaching a new storage device (e.g. in a Cloud environment like Amazon Web Services).

Continue Reading →

Linux performance monitoring (an introduction)

1. Classification

Before getting into action, let’s split the “performance” problem in a couple of boxes, as the concept itself is quite general. First, deciding what we want to monitor (an entire system? a particular application?) – and second, deciding on what type of performance monitoring do we require (stats collection by the kernel? in-depth analysis?). Based on this particular classification, we may end up with 4 categories, each with its particular software selection:

 

Stats (Counters)

Tracing / Profiling / Debugging

 System Wide

 Per Process

NB:

  • netstat offers much more info beyond statistics on interface / protocol and may also be used to monitor individual connections.

  • dtrace and SystemTap can also trace individual applications.

Continue Reading →

Setting up a secure Linux server

There is no such thing as a completely secure server: as long as you provide public access to services running on a server, there is a risk that somebody at some point is going to try something like a privilege escalation or denial of service. What one can do is to minimize the chance of success of such attack or at least to minimize the damages.

I am not going to provide here some “high tech” security mechanisms but rather some “common sense” ones; such measures will most likely prevent speculative attackers or bots from doing their stuff. Let’s start with the first trick from the book:

1. Set up iptables

One may think: why set the firewall up? If I provide 3 services to the world and those are the only ones with listening sockets, why would I need a completely configured firewall?

The answer is: the firewall is always necessary. Having a policy of “deny all + exceptions” will render useless any rogue service that an attacker may inject through some privilege escalation attack.

On a RedHat (CentOS) system one will find the firewall configuration file as /etc/sysconfig/iptables. A typical restrictive configuration might be:

*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m multiport --dports 22,80,443 -j ACCEPT

The configuration above allows new tcp traffic (new connections) to ports 22 (ssh), 80 (http) and 443 (https), while allowing all outgoing traffic and also the responses received in relation to such traffic. It also allows icmp (ping), but denies everything else.

Continue Reading →

Previous Page