<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Diógenes de un telemático</title>
	<atom:link href="http://www.sgmac.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sgmac.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 02 Sep 2010 10:00:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Shared Libraries</title>
		<link>http://www.sgmac.com/2010/09/02/shared-libraries/</link>
		<comments>http://www.sgmac.com/2010/09/02/shared-libraries/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 10:00:01 +0000</pubDate>
		<dc:creator>Sergio Galvan</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[shared]]></category>

		<guid isPermaLink="false">http://www.sgmac.com/?p=411</guid>
		<description><![CDATA[If you have your own shared libraries with the whole set of your favorite functions, probably you will have seen this common error: ./myapp: error while loading shared libraries: libtest.so: cannot open shared object file: No such file or direct Let&#8217;s take a look inside the binary: tuxedo@host:$> ldd test linux-gate.so.1 => (0xb7ef6000) libatest.so => [...]]]></description>
			<content:encoded><![CDATA[<p>If you have your own shared libraries with the whole set of your favorite functions, probably you will have seen this common error:</p>
<blockquote><p>
./myapp: error while loading shared libraries: libtest.so: cannot open shared object file: No such file or direct
</p></blockquote>
<p>Let&#8217;s take a look inside the binary:</p>
<pre>
tuxedo@host:$> ldd test
        linux-gate.so.1 =>  (0xb7ef6000)
        libatest.so => not found
        libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7d81000)
</pre>
<p>By default the system is looking for in the paths defined in the <em>/etc/ld.so.conf</em>, which recursively adds the definitions in the folder <em>/etc/ld.so.conf.d</em><br />
Here&#8217;s the quick trick: </p>
<blockquote><p>
tuxedo@host:$> export LD_LIBRARY_PATH=`pwd`
</p></blockquote>
<p>I use this whereas I&#8217;m implementing my library, after that you can put it wherever you feel like. </p>
<pre>
tuxedo@host:$> ldd test
linux-gate.so.1 =>  (0xb7f5e000)
        libtest.so => /home/tuxedo/syslib/libtest.so (0xb7f56000)
        libc.so.6 => /lib/i686/cmov/libc.so.6 (0xb7de3000)
        /lib/ld-linux.so.2 (0xb7f5f000)
</pre>
<p>Now the executable will work. I&#8217;ll retake this issue, I have some interesting things to tell about shared libraries. Happy coding!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgmac.com/2010/09/02/shared-libraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xrandr extends your monitor</title>
		<link>http://www.sgmac.com/2010/08/20/xrandr/</link>
		<comments>http://www.sgmac.com/2010/08/20/xrandr/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 09:18:02 +0000</pubDate>
		<dc:creator>Sergio Galvan</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[monitor]]></category>
		<category><![CDATA[xrandr]]></category>

		<guid isPermaLink="false">http://www.sgmac.com/?p=147</guid>
		<description><![CDATA[Long time ago if you wanted to have your laptop and an external monitor working together you had to use Xinerama, lucky me, that has changed. First of all, we need to install xrandr; # aptitude install x11-server-utils If you executes xrandr, it will show you the outputs you have available: $ xrandr VGA connected [...]]]></description>
			<content:encoded><![CDATA[<p>Long time ago if you wanted to have your laptop and an external monitor working together you had to  use  Xinerama, lucky me, that has changed. First of all, we need to install <em>xrandr</em>;</p>
<pre>
 # aptitude install <strong> x11-server-utils</strong>
</pre>
<p>If you executes <em>xrandr</em>, it will show you the outputs you have available:</p>
<blockquote><p>
$ xrandr VGA connected (normal left inverted right)<br />
   1280&#215;960       60.0<br />
   1280&#215;800       60.0<br />
   1152&#215;768       54.8<br />
   800&#215;600        56.2<br />
   640&#215;480        59.9<br />
LVDS connected 1280&#215;800+0+0 (normal left inverted right) 0mm x 0mm<br />
   1280&#215;800       59.9*+   60.0<br />
   1280&#215;768       60.0<br />
   1152&#215;768       54.8<br />
   1024&#215;768       85.0     75.0     70.1     60.0<br />
   832&#215;624        74.6<br />
   800&#215;600        85.1     72.2     75.0     60.3     56.2<br />
   640&#215;480        85.0     72.8     75.0     59.9<br />
   720&#215;400        85.0<br />
   640&#215;400        85.1<br />
   640&#215;350        85.1
</p></blockquote>
<p>To get all this working, a section  must be added into <i> /etc/X11/xorg.conf</i> file</p>
<blockquote><p>
Section &#8220;Screen&#8221;<br />
        Identifier      &#8220;Default Screen&#8221;<br />
        Monitor         &#8220;Configured Monitor&#8221;<br />
        DefaultDepth    24<br />
        <strong>SubSection &#8220;Display&#8221;<br />
                Modes &#8220;1280&#215;1024&#8243; &#8220;1280&#215;800&#8243;<br />
                Virtual 2560  1024<br />
        EndSubSection</strong><br />
EndSection
</p></blockquote>
<p><b> Using xrandr </b></p>
<p>Let&#8217;s to try out our configuration:</p>
<pre>
$ xrandr --output VGA --mode 1280x1024 --left-of LVDS
</pre>
<p>In fact, that is the line we need to put in our little script:</p>
<pre>
$~ vi .kde/Autostart/dual.sh
</pre>
<p>Henceforth we can work with an extended desktop, and increase our productivity. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgmac.com/2010/08/20/xrandr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sudo + LDAP (II)</title>
		<link>http://www.sgmac.com/2010/08/17/sudo-ldap-ii/</link>
		<comments>http://www.sgmac.com/2010/08/17/sudo-ldap-ii/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 09:06:44 +0000</pubDate>
		<dc:creator>Sergio Galvan</dc:creator>
				<category><![CDATA[Solaris]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[sudo]]></category>

		<guid isPermaLink="false">http://www.sgmac.com/?p=278</guid>
		<description><![CDATA[The second part of this article is here, so if you missed the first one, you might take a look Part One. Extending Schema LDAP support for sudo LDAP setup Setting up /etc/ldap.conf and nsswitch.conf 3. LDAP setup Let&#8217;s guess your root suffix is dc=company,dc=com , you need to append the next entry to your [...]]]></description>
			<content:encoded><![CDATA[<p>The second part of this article is here, so if you missed the first one, you might take a look <a href="http://www.sgmac.com/2010/08/01/sudo-ldap-i/"> Part One</a>.</p>
<ol>
<li> <b style="color:#5B5B5B">Extending Schema</b></li>
<li><b style="color:#5B5B5B">LDAP support for sudo</b></li>
<li><b>LDAP setup</b></li>
<li><b>Setting up <em>/etc/ldap.conf</em>  and <em>nsswitch.conf</em></b></li>
</ol>
<h3>3. LDAP setup </h3>
<p>Let&#8217;s guess your root suffix is  <em> dc=company,dc=com </em>, you need to append the next entry to your directory :</p>
<pre>
dn: ou=sudoers,dc=company,dc=com
  objectClass: top
  objectClass: organizationalunit
  description: Sudo Configuration
  ou: sudoers
</pre>
<p>Besides we will need a default profile:</p>
<pre>
dn: cn=defaults,ou=sudoers,dc=company,dc=com
  sudoOption: ignore_local_sudoers
  objectClass: top
  objectClass: sudoRole
  cn: defaults
  description: Our default options
  sudooption: log_host
  sudooption: logfile=/var/log/sudolog
  sudooption: !syslog
</pre>
<p>Perhaps you would like to get the most of sudo&#8217;s powder, take a look in its website. You can add as much profiles as you like, suppose you want to add one for system administration:</p>
<pre>
dn: cn=sysadmin,ou=sudoers,dc=company,dc=com
 objectClass: top
 objectClass: sudoRole
 cn: unix_admins
 sudoUser: tuxman
 sudoUser: darkman
 sudoUser: bill
 sudoHost: ALL
 sudoCommand: /usr/bin/ls
</pre>
<p>As far as I concern, how to configure sudo is out of this post, however together the source of sudo there is an utility, <em>sudoers2ldif</em>, a perl script that helps you to translate your sudo&#8217;s configuration file.  Next step requires to modify our profile. Probably you will have a similar profile to this one: </p>
<blockquote><p>
dn: cn=default,ou=profile,dc=company,dc=com<br />
objectClass: DUAConfigProfile<br />
defaultSearchBase: dc=company,dc=com<br />
cn: default<br />
credentialLevel: proxy<br />
defaultServerList: 192.168.76.66<br />
profileTTL: 300<br />
searchTimeLimit: 60<br />
authenticationMethod: simple<br />
serviceSearchDescriptor: passwd:cn=sudoers,dc=company,dc=com
</p></blockquote>
<p>After these modifications you must initialize your client (<em>ldapclient</em>).</p>
<h3>4. Setting up <em>/etc/ldap.conf</em>  and <em>nsswitch.conf</em></h3>
<p>It&#8217;s time to tell our client where to find sudoers file, by means of  <em>/etc/ldap.conf</em>, that looks something like this.</p>
<blockquote><p>
   uri ldap://192.168.76.66<br />
   sudoers_base ou=sudoers,dc=company,dc=com<br />
   bindpw  cn=proxyagent,ou=profile,dc=company,dc=com<br />
   binddn  password<br />
   sudoers_debug 0
</p></blockquote>
<p>You might use anonymous access, that&#8217;s your choice, just remember to check your ACI&#8217;s. Pretty interesting the option <em>sudoers_debug</em> which helps you to debug, at level 3 will show you as much information as possible. The last step, how to find our sudoers&#8217; profile,  <em>nsswitch.conf</em></p>
<pre>
  sudoers: ldap
</pre>
<p>Let&#8217;s check if is working:</p>
<pre>
tuxman@host:$> sudo ls
[sudo] password for client: 

sudo ls
LDAP Config Summary
===================
uri              ldap://192.168.76.66
ldap_version     3
sudoers_base     ou=sudoers,dc=company,dc=com
binddn           (anonymous)
bindpw           (anonymous)
ssl              (no)
===================
sudo: ldap_initialize(ld, ldap://192.168.76.66)
sudo: ldap_set_option: debug -> 0
sudo: ldap_set_option: ldap_version -> 3
sudo: ldap_sasl_bind_s() ok
sudo: found:cn=defaults,ou=sudoers,dc=company,dc=com
sudo: ldap sudoOption: 'ignore_local_sudoers'
sudo: ldap sudoOption: 'log_host'
sudo: ldap sudoOption: 'logfile=/var/log/sudolog'
sudo: ldap sudoOption: '!syslog'
sudo: ldap search '(|(sudoUser=tuxman)(sudoUser=%other)(sudoUser=ALL))'
sudo: found:cn=sysadmin,ou=sudoers,dc=company,dc=com
sudo: ldap sudoHost 'ALL' ... MATCH!
sudo: ldap sudoCommand '/usr/bin/ls' ... MATCH!
sudo: Command allowed
sudo: user_matches=1
sudo: host_matches=1
sudo: sudo_ldap_lookup(0)=0x02
tuxman@host:$> files/  sudoers2ldif.pl
</pre>
<p>At this point everything should be working. Last step, to translate our <em>sudoers</em> file.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgmac.com/2010/08/17/sudo-ldap-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiling sudo in Solaris (Sparc)</title>
		<link>http://www.sgmac.com/2010/08/11/sudo-error-libintl_dgettext-in-pam-o/</link>
		<comments>http://www.sgmac.com/2010/08/11/sudo-error-libintl_dgettext-in-pam-o/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 09:44:15 +0000</pubDate>
		<dc:creator>Sergio Galvan</dc:creator>
				<category><![CDATA[Solaris]]></category>
		<category><![CDATA[compile]]></category>
		<category><![CDATA[sudo]]></category>

		<guid isPermaLink="false">http://www.sgmac.com/?p=352</guid>
		<description><![CDATA[I&#8217;ve just had a problem trying to compile sudo in Sparc, even I had the right paths to my libraries, I couldn&#8217;t get sudo working. Here&#8217;s what I did: I realized that if I took the socket library off, (in bold) the error points me out where the library was (for socket), but not for [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just had a problem trying to compile sudo in Sparc, even I had the right paths to my libraries, I couldn&#8217;t get sudo working. Here&#8217;s what I did:</p>
<p>I realized that if I took the  socket library off,  (in bold) the error points me out where the library was (for socket), but not for the <em>intl</em> library. Somehow the path wasn&#8217;t set properly. </p>
<p>I thought could be that, so I just told the compiler where to find, instead of looking for in library paths. I directly  passed the parameters,  <strong>-L/usr/local/lib -lint</strong> (your path might be different, it depends on where you installed it) and everything worked fine. </p>
<blockquote><p>
gcc -o sudo gram.o alias.o alloc.o defaults.o error.o list.o match.o  \<br />
toke.o redblack.o zero_bytes.o sudo_auth.o pam.o  ldap.o \<br />
audit.o check.o env.o  getspwuid.o gettime.o goodpath.o \<br />
fileops.o find_path.o  interfaces.o lbuf.o logging.o parse.o pwutil.o \<br />
set_perms.o  sudo.o sudo_edit.o sudo_nss.o term.o tgetpass.o glob.o\<br />
fnmatch.o memrchr.o snprintf.o getprogname.o \<br />
 -lintl -lpam -ldl <b>-lsocket</b> -lldap   -lnsl<br />
Undefined                       first referenced<br />
 symbol                             in file<br />
socket                              interfaces.o  <b>(symbol belongs to implicit dependency /usr/lib/libsocket.so.1)</b><br />
libintl_dgettext                    pam.o<br />
ld: fatal: Symbol referencing errors. No output written to sudo<br />
collect2: ld returned 1 exit status
</p></blockquote>
<p>Now it works :=)</p>
<p><b>UPDATE:</b> I found out an option that sets another library path: <em>&#8211;with-path=/usr/local/lib</em>. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgmac.com/2010/08/11/sudo-error-libintl_dgettext-in-pam-o/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rotating backups with Ruby</title>
		<link>http://www.sgmac.com/2010/08/06/rotating-backups-with-ruby/</link>
		<comments>http://www.sgmac.com/2010/08/06/rotating-backups-with-ruby/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 20:46:51 +0000</pubDate>
		<dc:creator>Sergio Galvan</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://www.sgmac.com/?p=320</guid>
		<description><![CDATA[Today I&#8217;ve made some simple scripts to get my backups update. Two entries in our crontab will make the rest of work for us. The first one gets a backup of our database, the second rotates the files. I also add support to Syslog, because I would like to know if my script worked out. [...]]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;ve made some simple scripts to get my backups update. Two entries in our crontab will make the rest of work for us. </p>
<p>The first one gets a backup of our database, the second rotates the files. I also add support to Syslog, because I would like to know if my script worked out. </p>
<pre class="brush: bash">
#!/bin/bash
DATE=$(date +%Y-%m-%d)
mysqldump -h host userdb  database  --password=1234 | gzip &gt; \
 ${HOME}/path/files/file-${DATE}.gz
</pre>
<h3> Crontab</h3>
<p>Let&#8217;s add some entries to our crontab:</p>
<pre>
user@home:~> crontab -e
</pre>
<p>As far as I concern I would review the entries, it&#8217;s pretty easy to make some mistakes while we&#8217;re writing, besides I guess it&#8217;s a best practice.</p>
<pre>
user@home:~> crontab -l
</pre>
<p>The above command will show our entries.</p>
<pre>
# m h  dom mon dow   command
HOME=/path/user/home
PATH=PATH:/path/to/ruby

0 00 * * * ${HOME}/scripts/backup_db_blog.sh
0 00 * * * ${HOME}/scripts/rotatedb.rb
</pre>
<p>There is another thing to take into account, PATHS. Don&#8217;t forget to set them. </p>
<h3>Syslog</h3>
<p> Due to I wanted support Syslog,  I had to set it up correctly  in my  <em>/etc/syslog.conf</em></p>
<pre>
local7.*                        /var/log/backups.log
 </pre>
<p>Aside to create the above file,  you must reload syslog daemon. Afterwards, I wanted to know if that configuration would work. There is a command that will help you: </p>
<pre>
user@home:~> logger -p local7.debug "Sending a message to debug"
user@home:~> more /var/log/backups.log
Aug  6 20:31:22 home user: Sending a message to debug
</pre>
<p>The first argument <em>local7</em> is the Syslog&#8217;s FACILITY and the other one is the PRIORITY. You must adapt to your own script.<br />
Here is the script to rotate. After then days, will remove only the four oldest backups. </p>
<pre class="brush: ruby">

#!/usr/bin/env ruby
%w(syslog).each {|c| require c }

BACKUP=&#039;/path/to/backup/directory&#039;

module SyslogMsg
  Syslog.open(&quot;rotatedb&quot;, Syslog::LOG_PID | Syslog::LOG_CONS ,  Syslog::LOG_LOCAL7 )
  def send(msg=&quot;Message sent&quot;)
    Syslog.log(Syslog::LOG_DEBUG, msg)
  end
end

include SyslogMsg
files = []

Dir.entries(BACKUP).each do |e|
  if e !~ /^\./
    files &lt;&lt; e
  end
end
files.sort!

if files.length &gt; 10
  0.upto(4) do |index|
    File.delete( BACKUP + &quot;/&quot; + files[index] )
  end
  SyslogMsg::send(&quot;Backups for mysql rotated.&quot;)
end
</pre>
<p>Finally, if you get some troubles, review the above steps, check that you have the right permissions and you have reloaded your syslog configuration. If you try the <em>logger</em> command and you see the message you have just sent, everything should work out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgmac.com/2010/08/06/rotating-backups-with-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Forwarded ports and RSA key</title>
		<link>http://www.sgmac.com/2010/08/04/forwarded-ports-and-rsa-key/</link>
		<comments>http://www.sgmac.com/2010/08/04/forwarded-ports-and-rsa-key/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 17:18:49 +0000</pubDate>
		<dc:creator>Sergio Galvan</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Solaris]]></category>
		<category><![CDATA[forwarding]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://www.sgmac.com/?p=304</guid>
		<description><![CDATA[When I&#8217;m doing port forwarding I always get the same annoying message tuxman@athome:> ssh -p 3000 someuser@localhost @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key [...]]]></description>
			<content:encoded><![CDATA[<p>When I&#8217;m doing port forwarding I always get the same annoying message </p>
<pre>
tuxman@athome:> ssh -p 3000 someuser@localhost
<b>
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@</b>
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
22:ce:a2:e1:fe:cc:e6:73:cb:03:96:1e:23:3c:5b:55.
Please contact your system administrator.
Add correct host key in /home/tuxman/.ssh/known_hosts to get rid of this message.
Offending key in /home/tuxman/.ssh/known_hosts:159
RSA host key for [localhost]:4000 has changed and you have requested strict checking.
Host key verification failed.
</pre>
<p>appending some lines to  the <em>~/.ssh/config</em> file, solves the issue</p>
<blockquote><p>
Host localhost<br />
   HostKeyAlias  <em>youralias</em>
</p></blockquote>
<p>The <em>HostKeyAlias</em>  keyword allows us to define an alias and use it instead of the real name. I frequently use ssh port forwarding and I wanted to get rid of this message.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgmac.com/2010/08/04/forwarded-ports-and-rsa-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sudo + LDAP (I)</title>
		<link>http://www.sgmac.com/2010/08/01/sudo-ldap-i/</link>
		<comments>http://www.sgmac.com/2010/08/01/sudo-ldap-i/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 19:39:28 +0000</pubDate>
		<dc:creator>Sergio Galvan</dc:creator>
				<category><![CDATA[Solaris]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[sudo]]></category>

		<guid isPermaLink="false">http://www.sgmac.com/?p=235</guid>
		<description><![CDATA[Last day at work I had to get working sudo and ldap. I&#8217;m not gonna get into a discussion about if it&#8217;s worth or not to use sudo. I can just say from my own experience, if you have a large number of users and hosts, they are clearly distinguishable and you are using roles [...]]]></description>
			<content:encoded><![CDATA[<p>Last day at work I had to get working sudo and ldap. I&#8217;m not gonna get into a discussion about if it&#8217;s worth or not to use sudo. I can just say from my own experience, if you have a large number of users and hosts, they are clearly distinguishable and you are using roles (i.e: sysadmin, backup, any kind of group&#8230;) it&#8217;s totally worth.</p>
<p>Moreover, take into account you would have to update every sudo config file , definitely would be tedious, and here&#8217;s when LDAP gets in. </p>
<p>I brought into play two virtual machines, both of them running Solaris 10.  Commonly I prefer doing that before making some huge mistake in a real environment, so here&#8217;s what I did. I called <em>box0</em> to the client and <em>ldapbox</em> to the server. The rest of the post, I&#8217;ll assume you have set up a Directory Server and Native LDAP client service working fine. Summary :</p>
<ol>
<li> <b>Extending Schema</b></li>
<li><b>LDAP support for sudo</b></li>
<li><b>Structure of LDAP</b></li>
<li><b>Setting up <em>/etc/ldap.conf</em>  and <em>nsswitch.conf</em></b></li>
</ol>
<h3>1. Extending Schema</h3>
<p>This step is pretty straightforward, you only need to add the schema to your directory instance, and restart the server.  Assuming your instance might be in the default path <em>/var/opt/SUNWdsee/dsins1/config/schema/99users.ldif</em>. </p>
<blockquote><p>
attributeTypes: ( 1.3.6.1.4.1.15953.9.1.1 NAME &#8216;sudoUser&#8217; DESC &#8216;User(s) who may run sudo&#8217; EQUALITY caseExactIA5Match SUBSTR caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN &#8216;SUDO&#8217; )<br />
attributeTypes: ( 1.3.6.1.4.1.15953.9.1.2 NAME &#8216;sudoHost&#8217; DESC &#8216;Host(s) who may run sudo&#8217; EQUALITY caseExactIA5Match SUBSTR caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN &#8216;SUDO&#8217; )<br />
attributeTypes: ( 1.3.6.1.4.1.15953.9.1.3 NAME &#8216;sudoCommand&#8217; DESC &#8216;Command(s) to be executed by sudo&#8217; EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN &#8216;SUDO&#8217; )<br />
attributeTypes: ( 1.3.6.1.4.1.15953.9.1.4 NAME &#8216;sudoRunAs&#8217; DESC &#8216;User(s) impersonated by sudo&#8217; EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN &#8216;SUDO&#8217; )<br />
attributeTypes: ( 1.3.6.1.4.1.15953.9.1.5 NAME &#8216;sudoOption&#8217; DESC &#8216;Options(s) followed by sudo&#8217; EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN &#8216;SUDO&#8217; )<br />
objectClasses: ( 1.3.6.1.4.1.15953.9.2.1 NAME &#8216;sudoRole&#8217; SUP top STRUCTURAL DESC &#8216;Sudoer Entries&#8217; MUST ( cn ) MAY ( sudoUser $ sudoHost $ sudoCommand $ sudoRunAs $ sudoOption $ description ) X-ORIGIN &#8216;SUDO&#8217; )
</p></blockquote>
<p>Now you only need to restart the server.Why do I need to restart my server? The matter is, the first time you started your server, the file was read into memory, so any change you make  later will not have effect, at least you restart the instance.</p>
<h3>2. LDAP support for sudo</h3>
<p>You will need to get the source code of sudo and at least 1.7 version or upper. The reason is because earlier versions will not read <em>nsswitch.conf</em>.  I used sudo-1.7.2p7, you can get it from <a target="_blank"  href="http://www.sunfreeware.com"> Sunfreeware</a>. Of course if you want to compile you will need to solve some dependencies, here is the list, however you had better confirm  by yourself.</p>
<blockquote><p>
/&#8212;|(Sudo)<br />
	     |-* gcc-3.4.6-sol10-x86-local<br />
	     |-* libiconv-1.13.1-sol10-x86-local<br />
	     |-* libintl-3.4.0-sol10-x86-local<br />
	     |-* openssl-1.0.0a-sol10-x86-local</p>
<p> /&#8212;|( OpenLdap )<br />
	     |- * db-4.7.25.NC-sol10-x86-local<br />
	     |- * libtool-2.2.6b-sol10-x86-local<br />
	     |- * sasl-2.1.21-sol10-x86-local<br />
	     |- * openldap-2.4.22-sol10-x86-local
</p></blockquote>
<p> At this point and after installing all the dependencies we just need to compile:</p>
<pre>
./configure --with-ldap &#038;&#038; make
</pre>
<p> Those people who like tinkering with Unix tools, is time to call <em>ldd</em> and take a look into sudo.</p>
<pre>
libpam.so.1 =>   /lib/libpam.so.1
        libdl.so.1 =>    /lib/libdl.so.1
*       libldap-2.4.so.2 =>      <em><b>(/usr/local/lib/libldap-2.4.so.2)</b></em>
*       liblber-2.4.so.2 =>      <em><b>(/usr/local/lib/liblber-2.4.so.2)</b></em>
        libintl.so.8 =>  /usr/local/lib/libintl.so.8
        libsocket.so.1 =>        /lib/libsocket.so.1
        libnsl.so.1 =>   /lib/libnsl.so.1
        libc.so.1 =>     /lib/libc.so.1
        libcmd.so.1 =>   /lib/libcmd.so.1
        libresolv.so.2 =>        /usr/lib/libresolv.so.2
        libgen.so.1 =>   /usr/lib/libgen.so.1
        libsasl2.so.2 =>         /usr/local/lib/libsasl2.so.2
        libssl.so.1.0.0 =>       /usr/local/ssl/lib/libssl.so.1.0.0
        libcrypto.so.1.0.0 =>    /usr/local/ssl/lib/libcrypto.so.1.0.0
        libgcc_s.so.1 =>         /usr/local/lib/libgcc_s.so.1
        libiconv.so.2 =>         /usr/local/lib/libiconv.so.2
        libsec.so.1 =>   /usr/lib/libsec.so.1
        libmp.so.2 =>    /lib/libmp.so.2
        libmd.so.1 =>    /lib/libmd.so.1
        libscf.so.1 =>   /lib/libscf.so.1
        libavl.so.1 =>   /lib/libavl.so.1
        libdoor.so.1 =>  /lib/libdoor.so.1
        libuutil.so.1 =>         /lib/libuutil.so.1
        libm.so.2 =>     /lib/libm.so.2
</pre>
<p>If the LDAP libraries does not appear remember to add the path:</p>
<pre>
<b># crle -l -u  PATH_TO_LIBRARIES</b>
</pre>
<p>Obviously I wouldn&#8217;t like having to install OpenLdap in all my clients ( if you want to apply to more than one ), so I thought to carry just  with the libraries I needed. In a nutshell, we have just extended the schema and also enabled ldap support for sudo. The two last points for the next post. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgmac.com/2010/08/01/sudo-ldap-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Background jobs in your bash prompt</title>
		<link>http://www.sgmac.com/2010/07/30/background-jobs-in-your-bash-prompt/</link>
		<comments>http://www.sgmac.com/2010/07/30/background-jobs-in-your-bash-prompt/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 18:25:31 +0000</pubDate>
		<dc:creator>Sergio Galvan</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.sgmac.com/?p=218</guid>
		<description><![CDATA[In most cases when I&#8217;m working with the shell, I send my applications to background, mostly my emacs. Nonetheless I forget quickly, and I open too many times the same file. Due to my lack of memory I decided to make a function that shows me how many programs I have in background, here is [...]]]></description>
			<content:encoded><![CDATA[<p>In most cases when I&#8217;m working with the shell, I send my applications to background, mostly my emacs. Nonetheless I forget quickly, and I open too many times the same file.</p>
<p>Due to my lack of memory I decided to make a function that shows me how many programs I have in background, here is the function:</p>
<pre class="brush: bash">
function get_njobs {
 njobs=$(jobs | wc -l)

 if [ $njobs -gt &quot;0&quot; ];
 then
        echo $njobs |  sed -e &#039;s/\([0-9]*\)/(\1)/g&#039;
 fi
}

function prompt {

#  Shell into Emacs
 if [ $TERM != &quot;dumb&quot; ];
 then
    alias ls=&#039;ls --color=auto&#039;
    PS1=&quot;${purpple}\u@${close}${YELLOW}\h${close}:{\W}\$(get_njobs)&quot;
 else
        PS1=&quot;[\u@\h:\w]&quot;
 fi
}
</pre>
<blockquote><p>
user@host:{~} emacs &#038;<br />
user@host:{~}(1)
</p></blockquote>
<p>As you may notice, the number inside the brackets remembers me if there is some program running in background. Do not forget to add the function at the end of your  <em>bashrc</em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgmac.com/2010/07/30/background-jobs-in-your-bash-prompt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVN switch</title>
		<link>http://www.sgmac.com/2010/04/27/svn-switch/</link>
		<comments>http://www.sgmac.com/2010/04/27/svn-switch/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 08:29:12 +0000</pubDate>
		<dc:creator>Sergio Galvan</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://www.sgmac.com/?p=203</guid>
		<description><![CDATA[Last day I ran into a trouble with my subversion repositories, somebody changed the port I was using, somehow my repositories were not able of finding the original url, and here is the way how sorted it out: user@host:/myrepo/svn switch &#8211;relocate http://mysite.com/myrepo http://mysite.com:7777/myrepo Now you can do commits.]]></description>
			<content:encoded><![CDATA[<p>Last day I ran into a trouble with my subversion repositories, somebody changed the port I was using, somehow my repositories were not able of finding the original url, and here is the way how sorted it out:</p>
<blockquote><p>
user@host:/myrepo/svn switch &#8211;relocate  http://mysite.com/myrepo  http://mysite.com:7777/myrepo
</p></blockquote>
<p>Now you can do commits.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sgmac.com/2010/04/27/svn-switch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Troubleshooting Vmware Server 2</title>
		<link>http://www.sgmac.com/2010/03/16/troubleshooting-vmware-server-2/</link>
		<comments>http://www.sgmac.com/2010/03/16/troubleshooting-vmware-server-2/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 22:31:16 +0000</pubDate>
		<dc:creator>Sergio Galvan</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://www.sgmac.com/?p=178</guid>
		<description><![CDATA[This entry will explain two troubles that I found while I was using Vmware Server 2 : Initialized monitor device If you see an image like shown below,]]></description>
			<content:encoded><![CDATA[<p>This entry will explain two troubles that I found while I was using<br />
Vmware Server 2 :</p>
<ol>
<li> <b>Initialized monitor device</b>
<p>If you see an image like shown below,</p>
<p><img style="border:1.5px solid #000" src="imgs/task_failed.jpg"  </img></p>
<p>you had better check if you have &#8220;kvm&#8221; modules loaded</p>
<blockquote><p>
# lsmod | grep kvm<br />
kvm_intel              31168  0<br />
kvm                   106620  1 kvm_intel
</p></blockquote>
<p>Now yo have to unload the modules, first &#8220;kvm_intel&#8221;, if you try to unload kvm  you will not  be able due to dependency between them.<br />
At this point it turns out that you can start your virtual machine, but maybe you can not open the virtual console, so let&#8217;s go next point.</p>
<li> <b>Remote console plug-in error</b>
</li>
<p>If you are trying out to get a console and it shows up a window like this one, you only need to get an earlier version, for me worked out with Firefox 3.5.7. I even tried an upper version, but it did not work out. I guess there are some troubles<br />
with the last version of Firefox and the plugin.</p>
<p><img style="border:1.5px solid #000" src="imgs/remote_plugin_firefox36.jpg"  </img></p>
<p>That&#8217;s all, hopefully it will not take long to solve the problem.
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.sgmac.com/2010/03/16/troubleshooting-vmware-server-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->