Entradas

Mostrando entradas de junio, 2012

Permisos Unix: Los bits SUID, SGID y sticky

Hola hoy escribiré sobre más permisos, esta vez será sobre los bits Sticky, SUID y SGID. Hablaré sobre ellos porque un seguidor solicitó que escribiera más sobre permisos, en particular estos. Bit Sticky El bit Sticky lo que hace es que al ejecutar una aplicación esta resida en memoria por lo que si otro usuario (pensando en sistema multiusuario) accede a esa misma aplicación se ejecutará más rápido ya que se encuentra activo en la memoria. Entonces este permiso sirve para agilizar las ejecuciones en caso de que varios usuarios accedan a la vez a ella. Bit SUID Si aplicamos el bit SUID a una aplicación al correrlo se ejecutará con el UID del dueño del archivo aunque nosotros estemos logueados con un usuario distinto. Así que por ejemplo si necesitamos que todos los usuarios puedan utilizar fdisk sin tener que escalar a root o utilizar sudo sólo debemos aplicar este bit. Bit SGID Lo mismo que SUID pero aplica para el grupo al que pertenece la aplicación. El bit SUID para

How to install and configure suPHP

This tutorial is about how to install and configure suPHP. I know that they exist more tutorials about this but even though I'll write it because it took me a lot of time for me to make it work, and I want to explain how it finally work for me. I made this installation and configuration with Fedora 16 and httpd. What the suPHP module does is define which user and group will execute the PHP scripts. This is established inside one or more VirtualHost. This means that we can have multiple users for each one of our sites. They can even be executed by root but this is not advisable. Now let's see how to install it: It can be with yum or in case of Debian based distros with apt-get, but at least with Fedora and other similar distros I recommend to download the suPHP module from the official site. Here is the link: Now that we have downloaded the package, we untar it: tar -xzvf suphp-*.tar.gz We get inside the folder that is generated after de untaring and we configure

Instalación y configuración de suPHP

Hola hoy voy a hacer este tutorial de como instalar y configurar el módulo suPHP para Apache o httpd. La instalación la realicé en Fedora 16 con httpd. Tal vez ya muchos saben como instalarlo pero de todas formas lo escribiré ya que yo nunca antes lo había hecho y si me tomo tiempo para algo tan sencillo que es el lograr que funcionara. Lo que el módulo suPHP hace en si es definir que usuario y grupo ejecutará los scripts de PHP. Esto se define dentro de uno o varios VirtualHost. Esto quiere decir que podemos tener distintos usuarios para cada uno de nuestros sitios. Incluso pueden ejecutarse bajo root aunque no es recomendable. Ahora como se instala: Se puede con yum o en caso de distros basadas en Debian con apt-get, pero al menos en el caso de Fedora y otras distros similares recomiendo que se descargue desde la página oficial (lo digo por experiencia -.-). Aquí está el link: http://www.suphp.org/Download.html Entonces ya descargado descomprimimos el paquete con: tar -x

How to calculate permissions from umask

Umask (user mask) is a command that defines what default permissions will be established when a file is created by a determined process or user. First the basis: permissions are represented like this in Unix systems: rwx - rwx - rwx . Where r - Read w - Write x - Execute And where the first group of rwx belongs to the owner , the second to the group and the third to other users . Example: rwx - r-x - r-x In this case the permissions are: the owner has rights to read, write and execute . The group to read and execute . Other users to read and execute . So now lets see how to obtain the permissions from a umask: Example: if our umask is of 022, the default permissions for directories will be: 755 (drwx-r-x-r-x) and for files 644 (rw-r---r--). And how did we obtain this? Now lets see how. Before making any calculation: The initial permissions for directories are 777. The initial permissions for files are 666. In the next steps will see how this values are applied to obtain the default pe

How to build an IPv6 address

Imagen
An IPv6 address is composed by 8 fields of 16 bits and is represented like this: x:x:x:x:x:x:x:x Where each x is an hexadecimal value. If, in one of the fields we have zeros at the left it is not necessary to write them, also if a field has only zeros its representation can be simplified. For example: 1080:0:0:0:8:800:200C:417A Simplified will be like this: 1080::8:800:200C:417A 0:0:0:0:0:0:0:1 Simplified: ::1 Addresses are formed like this: Where: Site prefix: Composed of 48 bits. Describes the public topology that the ISP asigns. Subnet ID: Composed of 16 bits. Is assign by the user or the site administrator. The subnet ID describes the private topology, also denominated site topology. Interface ID: Composed of 64 bits. Contains the interface ID, also denominated token. The interface ID is configurated automatically using the MAC address of the interface or manually with the EUI64 format. To convert the MAC address using the EUI64 format we just have to use this sim

Run Apache with multiple users

You can run Apache as multiple users with this module: apache2-mpm-itk. This module as I understand it is for executing one of the Apache processes as the user established in VirtualHost. So we can have multiple VirtualHost with multiple users. I have already used this module with Ubuntu and Apache2. Ubuntu installation: apt-get install apache2-mpm-itk Then we just have to add this line inside a VirtualHost (or in all the VirtualHosts we want to run with a different user than the default for Apache): <IfModule mpm_itk_module> AssignUserId User Group </IfModule> And that's all. But obviously if we want the directory established to that VirtualHost to work, it must have the right permissions for that user and group whether to run scripts or to write a file. Even it's possible to run Apache as root.

Basic Linux stuff: The passwd file

The passwd file is located at /etc, and in that file is where the username and other user data is stored when a new user is created or when it is modified. A line that represents the data of a user is written like this: rukia:x:1000:1000:Rukia:/home/rukia:/bin/bash rukia - Is the username. x - This means that the user has a password. Passwords are encrypted and saved in the shadow file. 1000 - The user ID also known as UID. 1000 - The group ID also known as GID. Rukia - This field is the complete name of the user but it also contains other data. For example, when in Ubuntu we create a new user, it asks for a lot of information like room number, telephone, etc., well all this info is saved in this field and it is known as the gecos field. /home/rukia - The home folder. /bin/bash - Is the shell that will be executed by the user when he or she logins at a terminal.

Como calcular permisos de umask

Hola, hoy voy a escribir sobre como se calculan los permisos resultantes de umask (máscara de usuario). El umask es una orden que establece que permisos por defecto se van a establecer al crear un archivo por determinado proceso o usuario. Primero lo básico: los permisos se ven de esta forma en los sistemas Unix: rwx - rwx - rwx . Donde r - Lectura w - Escritura x - Ejecución Y donde el primer grupo de rwx corresponde al dueño , el segundo al grupo y el tercero a otros usuarios . Por ejemplo: rwx - r-x - r-x   En este caso los permisos serían: el dueño tiene derecho a lectura, escritura y ejecución . El grupo a lectura y ejecución . Otros usuarios a lectura y ejecución . Entonces para calcular los permisos resultantes según la umask sería así: Por ejemplo si nuestra umask es 022, el permiso por defecto para directorios sería: 755 (drwx-r-x-r-x) y para archivos 644 (rw-r---r--). Antes de hacer los cálculos: Los permisos iniciales para directorios son 777 Los permi

Como formar una dirección IPv6

Imagen
Hola, hoy voy a explicar la representación de las direcciones IPv6 en honor a su lanzamiento esta semana. Una dirección IPv6 está compuesta por 8 campos de 16 bits y se representa de la siguiente manera: x:x:x:x:x:x:x:x Donde cada x es un valor hexadecimal. Si en uno de los campos hay ceros hacia la izquierda no es necesario escribirlos, también si un campo consta de sólo ceros se puede simplificar su escritura. Por ejemplo: 1080:0:0:0:8:800:200C:417A Simplificada sería: 1080::8:800:200C:417A 0:0:0:0:0:0:0:1 Simplificada: ::1 Las direcciones están conformadas de la siguiente forma: Donde: Prefijo de sitio: Compuesto de 48 bits. Describe la topología pública que el ISP suele asignar al sitio. ID de subred: Compuesto de 16 bits. Es asignada por el usuario o el administrador del sitio. El ID de subred describe la topología privada, denominada también topología del sitio ID de interfaz: Compuesto de 64 bits. Contiene el ID de interfaz, también denominad

Ejecutar Apache con múltiples usuarios en Ubuntu

Bueno otra vez voy a escribir algo rápido que puede ser útil. Esta vez necesitaba ejecutar Apache como root, pero es obvio que esto no es seguro, así que quería ejecutar sólo un VirtualHost bajo root. Buscando en Internet di con un blog que explicaba sobre un módulo para Apache llamado apache2-mpm-itk . Este módulo según entiendo es para ejecutar uno de los procesos de Apache como el usuario establecido en el VirtualHost. Por lo tanto podemos tener múltiples VirtualHost con múltiples usuarios. Este módulo ya lo utilicé en Ubuntu con Apache2, lo que no he logrado desfortunadamente es que me funcione en Fedora16 con httpd. Pero sigo haciendo el intento todos los días si me es posible de ver la forma de correr httpd con distintos usuarios. Existen otras opciones como suPHP y suExec pero no les he dedicado el tiempo para checarlos. Pero bueno sigamos con lo del módulo itk. Para instalarlo en Ubuntu  apt-get install apache2-mpm-itk Después sólo basta agregar lo siguiente dent