<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
 <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 <META NAME="GENERATOR" CONTENT="lfparser_2.16">
 <META NAME="LFCATEGORY" CONTENT="System Administration">
<!-- this is used be a number of tools:
 =LF=AUTHOR: Fr&eacute;d&eacute;ric Raynal
 =LF=CAT___: System Administration
 =LF=TITLE_: Yellow Pages, part 1
 =LF=NUMBER: 148
 =LF=ANAME_: article148.shtml
 -->
 <TITLE>lf148, System Administration: Yellow Pages, part 1</TITLE>
<!-- stylesheet added by lfparser: --> 
<style type="text/css">
<!--
 td.top {font-family: Arial,Geneva,Verdana,Helvetica,sans-serif; font-size:12 }
 pre { font-familiy:monospace,Courier }
 p.cl { color:#EE9500 }
 a.nodec { text-decoration:none }
 p.trans { font-size:8pt; text-align:right }
 p.clbox { width:50%; alignment:center; background-color:#FFD700; border-style:none; border-width:medium; border-color:#FFD700; padding:0.5cm ;  text-align:center }
 p.foot { background-color:#AAAAAA; color:#FFFFFF; border-style:none; border-width:medium; border-color:#AAAAAA; padding:0.5cm ; margin-top:0.1cm; margin-right:1cm; margin-left:1cm; text-align:center }
-->
</style>
 
</HEAD>
<BODY bgcolor="#ffffff" text="#000000">
 <!-- this is generated html code. NEVER use this file for your
 translation work. Instead get the file with the same article number
 and .meta.shtml in its name. Translate this meta file and then
 use lfparser program to generate the final article -->
 <!-- lfparser can be obtained from http://main.linuxfocus.org/~guido/dev/lfparser.html -->

<!-- 2pdaIgnoreStart -->

<!-- start navegation bar -->
 <!-- top navegation bar -->
 <TABLE cellspacing="0" cellpadding="0" border="0" align="center" width="90%">
   <TR bgcolor="#2e2292">
     <TD class="top"><TABLE cellspacing="0" cellpadding="0" border="0" width=
       "100%">
         <TR><TD width="144"><IMG src="../../common/images/logolftop.gif"
           alt="[LinuxFocus-icon]" width="350" height="45" align="left" 
           border="0"></TD>

           <TD class="top">
             <TABLE width="100%">
               <TR align="right">
                 <TD class="top"><A class="nodec" href="../index.shtml"><FONT color=
                 "#DDDDDD">Home</FONT></A> &nbsp;|&nbsp; <A class=
                 "nodec" href="../map.html"><FONT color=
                 "#DDDDDD">Map</FONT></A> &nbsp;|&nbsp; <A class=
                 "nodec" href="../indice.html"><FONT color=
                 "#DDDDDD">Index</FONT></A> &nbsp;|&nbsp; <A class="nodec" href="../Search/index.html"><FONT color=
                 "#DDDDDD">Search</FONT></A> </TD>
               </TR>

               <TR align="right">
                 <TD class="top">
                   <HR width="100%" noshade size="1">
                 </TD>
               </TR>
             </TABLE>
           </TD>
         </TR>
       </TABLE>
     </TD>
   </TR>
 </TABLE>
 <!-- end top navegation bar -->
 <!-- blue bar -->
 <TABLE cellspacing="0" cellpadding="0" border="0" align="center"
 width="90%">
   <TR bgcolor="#00ffff">
     <TD><IMG src="../../common/images/transpix.gif" width="1" height=
     "2" alt=""></TD>
   </TR>
 </TABLE>
 <!-- end blue bar -->
 <!-- bottom navegation bar -->
 <TABLE cellspacing="0" cellpadding="0" border="0" align="center"
 width="94%">
   <TR bgcolor="#000000">
     <TD>
       <TABLE cellspacing="0" cellpadding="1" border="0" width=
       "100%">
         <TR align="center">
           <TD class="top"><A class="nodec" href="../News/index.html"><FONT color=
           "#FFFFFF">News</FONT></A> </TD>
           <TD><FONT color="#FFFFFF">|</FONT> </TD>
           <TD><A class="nodec" href="../Archives/index.html"><FONT color=
           "#FFFFFF">Archives</FONT></A> </TD>
           <TD><FONT color="#FFFFFF">|</FONT> </TD>
           <TD><A class="nodec" href="../Links/index.html"><FONT color=
           "#FFFFFF">Links</FONT></A> </TD>
           <TD><FONT color="#FFFFFF">|</FONT> </TD>
           <TD><A class="nodec" href="../aboutus.html"><FONT color=
           "#FFFFFF">About LF</FONT></A> </TD>
           <TD>&nbsp;</TD>
         </TR>
       </TABLE>
     </TD>
   </TR>
 </TABLE>
 <!-- end bottom navegation bar -->
<!-- stop navegation bar -->

<!-- SSI_INFO -->

<!-- tr_staticssi include virtual -->
<!-- tr_staticssi exec cmd -->
<!-- addedByLfdynahead ver 1.1 --><TABLE ALIGN="right" border=0><TR><TD ALIGN="right"><FONT SIZE="-1" FACE="Arial,Helvetica">This article is available in: <A href="../../English/July2001/article148.shtml">English</a> &nbsp;<A href="../../Castellano/July2001/article148.shtml">Castellano</a> &nbsp;<A href="../../Deutsch/July2001/article148.shtml">Deutsch</a> &nbsp;<A href="../../Francais/July2001/article148.shtml">Francais</a> &nbsp;<A href="../../Nederlands/July2001/article148.shtml">Nederlands</a> &nbsp;<A href="../../Portugues/July2001/article148.shtml">Portugues</a> &nbsp;<A href="../../Russian/July2001/article148.shtml">Russian</a> &nbsp;<A href="../../Turkce/July2001/article148.shtml">Turkce</a> &nbsp;</FONT></TD></TR></TABLE><br>
 

<!-- 2pdaIgnoreStop -->

<!-- SHORT BIO ABOUT THE AUTHOR -->
<TABLE ALIGN=LEFT BORDER=0 hspace=4 vspace=4 WIDTH="30%" >
<TR>
<TD>

<!-- 2pdaIgnoreStart -->
<!-- PALM DOC -->
<TABLE BORDER=0 hspace=4 vspace=4> <TR> <TD>
<font size=1> <img src="../../common/images/2doc.gif" width=34 align=left border=0 height=22 alt="convert to palm"><a href="http://cgi.linuxfocus.org/cgi-bin/2ztxt">Convert to GutenPalm</a><br>or <a href="http://cgi.linuxfocus.org/cgi-bin/2pda">to PalmDoc</a></font>
</TD> </TR> </TABLE>
<!-- END PALM DOC -->
<!-- 2pdaIgnoreStop -->
<br>
<IMG src="../../common/images/Frederic_Raynal.png" alt=
    "[Photo of the Author]" height="147" width="126">
<BR>by  <A href="mailto:pappy&#64;users.sourceforge.net">Fr&eacute;d&eacute;ric Raynal</A>
<BR><BR>
<I>About the author:</I><BR>
<A href="mailto:pappy@users.sourceforge.net">Fr&eacute;d&eacute;ric
    Raynal</A> is writing his thesis in informatics at the <A href=
    "http://www.inria.fr">INRIA</A>. He likes to read (Tolkien as well
    as Balzac) and to listen to music (from Mozart to Philip Glass and
    from Led Zeppelin to Massive Attack over Bj&ouml;rk and Boris Vian,
    but carefully avoiding rap, techno and some other kinds of noise
    ;-)

    
<BR><i>Content</i>:
<UL>
  <LI><A HREF="#148lfindex0">Structure</A></LI>
  <LI><A HREF="#148lfindex1">The maps</A></LI>
  <LI><A HREF="http://cgi.linuxfocus.org/cgi-bin/lftalkback?anum=148&lang=en">Talkback form for this article</A></LI>
</UL>

</TD></TR></TABLE>
<!-- HEAD OF THE ARTICLE -->
<br>&nbsp;
<H2>Yellow Pages, part 1</H2>
 <IMG src="../../common/images/illustration148.gif" alt=
    "[Illustration]" hspace="10" height="90" width="100">
<!-- ABSTRACT OF THE ARTICLE -->
<P><i>Abstract</i>:
<P>

    The <I>Network Information Service</I> (NIS) keeps a database on a
    server. Every machine on the network on which an NIS client is
    running can query the server to obtain information like (login
    name, password, info about user groups, ... ). This allows for a
    centralized management of a large number of machines (especially
    when it is used together with a distributed network file system
    like NFS) since the changes to this information will be passed on
    through the server to all its clients.

    </P>
<HR size="2" noshade align="right"><BR>
<!-- BODY OF THE ARTICLE -->


    <H1>Introduction</H1>

    <P>The <I>Network Information Service</I> (NIS) was initially
    created by Sun and known as <I>Sun Yellow Pages</I> (commonly known
    simply as the <I>Yellow Pages</I> or YP). This, however, is a
    trademark of British Telecom and consequently can not be used
    without the proper permissions. These <I>Yellow Pages</I> refer to the
    ones where we look up telephone numbers.</P>

    <P>The NIS servers maintain copies of common configuration files on
    several networked machines in a database. The NIS clients address
    their requests to the servers instead of using their own
    configuration files.</P>

    <P>Let's pretend to be a user on the network who wants to change
    his password. Let's first imagine YP is not installed. This user
    will have to logon to all the machines on the network to change his
    password. If YP were installed it would be possible for him/her to
    change his password on one of the machines where a NIS client is
    running, The new password will then be tranferred to the server
    where it will be changed in the server database. After this when a user
    wants to connect to a networked machine (on which a NIS client is
    running of course ;-), the password will be compared to the one
    registered in the database of the server.</P>

    <P>There are different versions of YP but since this article is an
    introduction, we will only look at the principles of how it
    works without going into the details. We will come to the details
    later on.</P>
    glibc 2.x (libc6) supports the use of NSS (Name Switch Service)
    which determines the order in which the information has to be
    searched (see the file <FONT face=
    "Courier New,Courier">/etc/nsswitch.conf</FONT>). It maintains the
    aliases, subnets, groups, hosts, netgroups, networks, protocols,
    publickey, passwd, rpc, services and shadow maps.

    <H1>How does it work</H1>

    <A NAME="148lfindex0">&nbsp;</A>
<H2>Structure</H2>


    <P>There will be machine on the network serving as an NIS server
    for a domain. This <I>domain</I> corresponds, more or less, to the
    name of the database the server will administer. This is the key
    NIS clients use to locate the needed information on the NIS
    server. This domain name has <B>absolutely nothing</B> to do with
    the DNS domain name. There can be more than one NIS server on the
    same domain. They can each administer a different domain (on the
    NIS level), or they could administer the same domain (in this case
    there will be a <I>master</I> server and <I>slave</I> servers).</P>

    <P>The slave servers only have a copy of the master servers
    database. These servers supplement the master server when it is
    taking too long to answer the client's requests or when the master
    server goes down.</P>

    <P>The slave servers are notified of every change in the database
    by the program <FONT face="Courier New,Courier">yppush</FONT> and
    they will update there own databases to reflect exactly the state
    of the database on the server.</P>

    <P>The clients, on their side, don't need any "maintenance" since
    they are continually contacting the NIS server to lookup the
    information in its database.</P>

    <A NAME="148lfindex1">&nbsp;</A>
<H2>The maps</H2>


    <P>The YP database are in the GDBM format, taken from the ASCII
    format. They are set up during the installation of the server by
    the <FONT face="Courier New,Courier">makedbm</FONT> program.</P>

    <P>These <I>maps</I> establish correspondences between a <B>key</B>
    and its <B>value</B>. All the YP maps are based on this model. From
    the server's point of view, the contents have no meaning (well,
    besides some exceptions concerning data about the main server or
    dates). This means that, to the server, a map with passwords or
    groups etc. is nothing more than a set of key/value pairs.
    Only the YP client knows how to search these maps to find the
    information it needs.</P>

    <P>This representation of the date can be problematic. As the
    server cannot "read" the value of a key to find a second key inside
    it, it will be necessary to duplicate the data. For instance in the
    case of passwords, one might want to be able to look them up by
    using the login name or by the <I>user ID</I> or UID (a unique
    identifier for each user on the network). This will lead to an
    information redundancy, as can be seen by the presence of the <FONT
    face="Courier New,Courier">passwd.byname</FONT> and <FONT face=
    "Courier New,Courier">passwd.byuid</FONT> files. Consequently there
    will be a new map created for every key, meaning that the data has
    to be transmitted twice in case of a change.</P>

    <P> Three parameters are needed for a client to find the
    information it needs from the database :</P>

    <OL>
      <LI>the domain name : this is the name of the database on the YP
      server</LI>

      <LI>the map name</LI>

      <LI>the key name</LI>
    </OL>
    So, for a client to find the password of a user named Toto in the
    domain <FONT face="Courier New,Courier">titi</FONT>, it will read
    the file <FONT face=
    "Courier New,Courier">/var/yp/titi/passwd.byname</FONT> on the YP
    server looking for the user Toto. <BR>
    <BR>

    <P>This leads to a very flexible system, since setting up a new
    domain is reduced to the creation of the directory <FONT face=
    "Courier New,Courier">/var/yp/new_domain</FONT>, copying the <FONT
    face="Courier New,Courier">Makefile</FONT> and executing it with
    the correct options.</P>

    <H1>Remote Procedure Calls (RPC)</H1>

    <P>YP's functionality is essentially based on Remote Procedure
    Calls (RPCs) accepting requests between the server and its
    clients.</P>

    <P>The RPC portmapper (portmap) is a program that converts the RPC
    program numbers into port numbers. When an RPC is started, it will
    tell portmap which port it will use and the RPC program numbers it
    is administering. When a client wants to make an RPC request to a
    certain program number, it will first contact the portmap server to
    obtain the port number on which the program is running. After
    obtaining this port number it addresses the RPC packets to the
    corresponding port. The client/server model of YPs is nothing more
    than a particular case of client/server RPC.</P>

    <P>The file <FONT face="Courier New,Courier">yp_prot.h</FONT>
    contains the structures and the prototypes of 11 functions defining
    the RPC protocol between the clients and the YP server.</P>

    <UL>
      <LI>YPPROC_DOMAIN and YPPROC_DOMAIN_NOACK allow the clients to
      find a server for a given domain.</LI>

      <LI>The functions YPPROC_MATCH, YPPROC_FIRST, YPPROC_NEXT and
      YPPROC_ALL allow access to the maps data.</LI>

      <LI>YPPROC_XFR is called by <FONT face=
      "Courier New,Courier">yppush</FONT> to signal the slave servers
      that the map on the master server has changed and they need to
      update their copies.</LI>

      <LI>YPPROC_CLEAR cleans out the cache and the file handles. This
      function is called after updating a map, for instance after the
      <FONT face="Courier New,Courier">makedbm -c</FONT> command.</LI>

      <LI>YPPROC_MASTER, YPPROC_ORDER and YPPROC_MAPLIST allow to
      obtain special information about the maps. For instance, to
      change the password, the <FONT face=
      "Courier New,Courier">yppasswd</FONT> program makes a call to
      YPPROC_MASTER to determine the server before changing the
      password.</LI>
    </UL>

    <H1>Conclusion</H1>
    Now that we know the general principle, the next article will
    address the client side of yellow pages : how it works, how to
    configure it, the tools it uses, etc... We will also have a look at
    the tools necessary to configure our client correctly, both for the
    RPCs and for the YPs.
  




<!-- 2pdaIgnoreStart -->
<A NAME="talkback">&nbsp;</a>
<h2>Talkback form for this article</h2>
Every article has its own talkback page. On this page you can submit a comment or look at comments from other readers:
<center>
<table border="0"  CELLSPACING="2" CELLPADDING="1">
 <tr BGCOLOR="#C2C2C2"><td align=center>
  <table border="3"  CELLSPACING="2" CELLPADDING="1">
   <tr BGCOLOR="#C2C2C2"><td align=center>
    <A href="http://cgi.linuxfocus.org/cgi-bin/lftalkback?anum=148&lang=en"><b>&nbsp;talkback page&nbsp;</b></a>
   </td></tr></table>
</td></tr></table>
</center>

<HR size="2" noshade>
<!-- ARTICLE FOOT -->
<CENTER><TABLE WIDTH="95%">
<TR><TD ALIGN=CENTER BGCOLOR="#9999AA">
<A HREF="../../common/lfteam.html">Webpages maintained by the LinuxFocus Editor team</A>
<BR><FONT COLOR="#FFFFFF">&copy; Fr&eacute;d&eacute;ric Raynal, <a href="../../common/copy.html">FDL</a> <BR><a href="http://www.linuxfocus.org">LinuxFocus.org</a></FONT>
<BR><a href="http://cgi.linuxfocus.org/cgi-bin/lfcomment?lang=en&article=article148.shtml" target="_TOP">Click here to report a fault or send a comment to LinuxFocus</A><BR></TD>
<TD BGCOLOR="#9999AA"><!-- TRANSLATION INFO -->
<font size=2>Translation information:</font><TABLE>
<tr><td><font size=2>fr</font></td>
    <td><font size=2>-&gt;</font></td>
    <td><font size=2>--</font></td>
    <td><font size=2><a href="mailto:pappy&#64;users.sourceforge.net"><FONT COLOR="#FFFFFF">Fr&eacute;d&eacute;ric Raynal</FONT></a></font></td>
</tr>
<tr><td><font size=2>fr</font></td>
    <td><font size=2>-&gt;</font></td>
    <td><font size=2>en</font></td>
    <td><font size=2><a href="mailto:rainbow&#64;linuxfocus.org"><FONT COLOR="#FFFFFF">Jo Simons</FONT></a></font></td>
</tr>
<tr><td><font size=2>en</font></td>
    <td><font size=2>-&gt;</font></td>
    <td><font size=2>en</font></td>
    <td><font size=2><a href="mailto:sherm_pbody&#64;yahoo.com"><FONT COLOR="#FFFFFF">Lorne Bailey</FONT></a></font></td>
</tr>
</TABLE></TD>
</TR></TABLE></CENTER>
<p><font size=1>2001-06-29, generated by lfparser version 2.16</font></p>
<!-- 2pdaIgnoreStop -->
</BODY>
</HTML>