<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>C on Karpoke - Just Another Blog</title><link>http://karpoke.ignaciocano.com/tags/c/</link><description>Recent content in C on Karpoke - Just Another Blog</description><generator>Hugo -- 0.159.0</generator><language>es</language><lastBuildDate>Tue, 01 Nov 2016 15:09:00 +0100</lastBuildDate><atom:link href="http://karpoke.ignaciocano.com/tags/c/index.xml" rel="self" type="application/rss+xml"/><item><title>Linux containers in 500 lines of code</title><link>http://karpoke.ignaciocano.com/2016/11/01/linux-containers-in-500-lines-of-code/</link><pubDate>Tue, 01 Nov 2016 15:09:00 +0100</pubDate><guid>http://karpoke.ignaciocano.com/2016/11/01/linux-containers-in-500-lines-of-code/</guid><description>&lt;p&gt;Relatd:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I’ve used Linux containers directly and indirectly for years, but I wanted
to become more familiar with them. So I wrote some code. This used to be 500
lines of code, I swear, but I’ve revised it some since publishing; I’ve
ended up with about 70 lines more.&lt;/p&gt;
&lt;p&gt;I wanted specifically to find a minimal set of restrictions to run untrusted
code. This isn’t how you should approach containers on anything with any
exposure: you should restrict everything you can. But I think it’s important
to know which permissions are categorically unsafe!&lt;/p&gt;</description></item><item><title>Limitando el número de procesos por usuario</title><link>http://karpoke.ignaciocano.com/2011/08/01/limitando-el-numero-de-procesos-por-usuario/</link><pubDate>Mon, 01 Aug 2011 19:23:00 +0100</pubDate><guid>http://karpoke.ignaciocano.com/2011/08/01/limitando-el-numero-de-procesos-por-usuario/</guid><description>&lt;p&gt;Mediante el comando &lt;code&gt;ulimit&lt;/code&gt; podemos consultar y controlar el valor de los
recursos disponibles para la consola y los &lt;a href="http://karpoke.ignaciocano.com/2010/12/16/mejora-del-rendimiento-interactivo-agrupando-tareas-por-terminal/"&gt;procesos que puedan ser iniciados
desde ella&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Las diferentes opciones que acepta este comando son:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;-a All current limits are reported
-b The maximum socket buffer size
-c The maximum size of core files created
-d The maximum size of a process’s data segment
-e The maximum scheduling priority (&amp;#34;nice&amp;#34;)
-f The maximum size of files written by the shell and its children
-i The maximum number of pending signals
-l The maximum size that may be locked into memory
-m The maximum resident set size (many systems do not honor this limit)
-n The maximum number of open file descriptors (most systems do not allow this value to be set)
-p The pipe size in 512-byte blocks (this may not be set)
-q The maximum number of bytes in POSIX message queues
-r The maximum real-time scheduling priority
-s The maximum stack size
-t The maximum amount of cpu time in seconds
-u The maximum number of processes available to a single user
-v The maximum amount of virtual memory available to the shell and, on some systems, to its children
-x The maximum number of file locks
-T The maximum number of threads
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Para consultar todos los valores asignados actualmente:&lt;/p&gt;</description></item><item><title>Endianness</title><link>http://karpoke.ignaciocano.com/2011/07/30/endianness/</link><pubDate>Sat, 30 Jul 2011 17:34:00 +0100</pubDate><guid>http://karpoke.ignaciocano.com/2011/07/30/endianness/</guid><description>&lt;p&gt;&amp;ldquo;&lt;a href="http://secure.wikimedia.org/wikipedia/es/wiki/Endianness"&gt;Endianicidad&lt;/a&gt;&amp;rdquo; designa el formato en el que se almacenan los datos
de más de un byte en un ordenador. El sistema &lt;em&gt;big-endian&lt;/em&gt; adoptado por
Motorola entre otros, consiste en representar los bytes en el orden
&amp;ldquo;natural&amp;rdquo;, así el valor hexadecimal 0x4A3B2C1D se codificaría en memoria
en la secuencia {4A, 3B, 2C, 1D}. En el sistema &lt;em&gt;little-endian&lt;/em&gt; adoptado
por Intel, entre otros, el mismo valor se codificaría como {1D, 2C, 3B,
4A}, de manera que de este modo se hace más intuitivo el acceso a datos,
porque se efectúa fácilmente de manera incremental de menos relevante a
más relevante (siempre se opera con incrementos de contador en la
memoria).&lt;/p&gt;</description></item><item><title>¿Un keylogger en Ubuntu?</title><link>http://karpoke.ignaciocano.com/2011/07/22/un-keylogger-en-ubuntu/</link><pubDate>Fri, 22 Jul 2011 04:35:00 +0100</pubDate><guid>http://karpoke.ignaciocano.com/2011/07/22/un-keylogger-en-ubuntu/</guid><description>&lt;p&gt;El comando &lt;code&gt;xinput&lt;/code&gt; permite configurar y probar dispositivos de entrada
para las XWindow. Podemos obtener un listado de los dispositivos de
entrada:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;$ xinput list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ SynPS/2 Synaptics TouchPad id=15 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Power Button id=8 [slave keyboard (3)]
↳ Sleep Button id=9 [slave keyboard (3)]
↳ Laptop_Integrated_Webcam_2M id=10 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=11 [slave keyboard (3)]
↳ Dell WMI hotkeys id=13 [slave keyboard (3)]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;También podemos obtener más información de algún dispositivo en
concreto, por ejemplo, del teclado, cuyo identificador, en mi caso, es
el 11:&lt;/p&gt;</description></item><item><title>inception</title><link>http://karpoke.ignaciocano.com/2011/03/14/inception/</link><pubDate>Mon, 14 Mar 2011 13:35:00 +0100</pubDate><guid>http://karpoke.ignaciocano.com/2011/03/14/inception/</guid><description>&lt;p&gt;&lt;em&gt;&lt;a href="http://github.com/karthick18/inception"&gt;Inception&lt;/a&gt;&lt;/em&gt; en C:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;$ git clone https://github.com/karthick18/inception.git
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;img alt="inception" loading="lazy" src="http://karpoke.ignaciocano.com/images/inception-300x203.png"&gt;&lt;/p&gt;</description></item><item><title>ls sin ls</title><link>http://karpoke.ignaciocano.com/2011/03/12/ls-sin-ls/</link><pubDate>Sat, 12 Mar 2011 13:11:00 +0100</pubDate><guid>http://karpoke.ignaciocano.com/2011/03/12/ls-sin-ls/</guid><description>&lt;p&gt;En bash:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;$ for i in *; do echo $i; done
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;img alt="ls" loading="lazy" src="http://karpoke.ignaciocano.com/images/ls-300x232.jpg"&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Fuente: &lt;a href="http://nfosolutions.com/"&gt;nfosolutions.com&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;En &lt;a href="http://snippets.dzone.com/posts/show/2735"&gt;C&lt;/a&gt;:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/*
*
* Esempio che scansiona una cartella stampando a video i file in essa
* contenuti.
*/
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt;#include
#include
#include
#include
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt;int main(int argc, char *argv[])
{
DIR *dir;
struct dirent *drent;
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt; if(argc &amp;lt; 2)
{
fprintf(stderr, &amp;#34;%s \n&amp;#34;, argv[0]);
return EXIT_FAILURE;
}
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt; if((dir = opendir(argv[1])) == NULL)
{
fprintf(stderr, &amp;#34;Errore opendir()\n&amp;#34;);
return EXIT_FAILURE;
}
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt; while((drent = readdir(dir)) != NULL)
{
fprintf(stdout, &amp;#34;--&amp;gt; %s\n&amp;#34;, drent-&amp;gt;d_name);
}
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt; if(closedir(dir) &amp;lt; 0)
{
fprintf(stderr, &amp;#34;Errore closedir()\n&amp;#34;);
return EXIT_FAILURE;
}
}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;En Python:&lt;/p&gt;</description></item><item><title>setuid y setgid</title><link>http://karpoke.ignaciocano.com/2011/02/28/setuid-y-setgid/</link><pubDate>Mon, 28 Feb 2011 14:33:00 +0100</pubDate><guid>http://karpoke.ignaciocano.com/2011/02/28/setuid-y-setgid/</guid><description>&lt;p&gt;&lt;code&gt;setuid&lt;/code&gt; y &lt;code&gt;setgid&lt;/code&gt; son unos permisos especiales, también llamados los
&lt;em&gt;sticky bits&lt;/em&gt;, que se les pueden asignar a los programas ejecutables
para que se ejecuten con los permisos del propietario y no del usuario
que los ejecuta. Esto sirve para, por ejemplo, que cualquier usuario
ejecute el comando &lt;code&gt;ping&lt;/code&gt; aunque éste necesite privilegios de
administrador, que es el propietario. En GNU/Linux, y en Unix, estos
bits se ignoran cuando se aplican a directorios.&lt;/p&gt;</description></item></channel></rss>