]> granicus.if.org Git - shadow/blob - man/shadow.3.xml
* libmisc/find_new_uid.c, libmisc/find_new_gid.c: Add missing
[shadow] / man / shadow.3.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3    Copyright (c) 1989 - 1993, Julianne Frances Haugh
4    Copyright (c) 2007 - 2008, Nicolas François
5    All rights reserved.
6   
7    Redistribution and use in source and binary forms, with or without
8    modification, are permitted provided that the following conditions
9    are met:
10    1. Redistributions of source code must retain the above copyright
11       notice, this list of conditions and the following disclaimer.
12    2. Redistributions in binary form must reproduce the above copyright
13       notice, this list of conditions and the following disclaimer in the
14       documentation and/or other materials provided with the distribution.
15    3. The name of the copyright holders or contributors may not be used to
16       endorse or promote products derived from this software without
17       specific prior written permission.
18   
19    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22    PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
23    HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 -->
31 <refentry id='shadow.3'>
32   <!--  $Id$ -->
33   <refmeta>
34     <refentrytitle>shadow</refentrytitle>
35     <manvolnum>3</manvolnum>
36     <refmiscinfo class="sectdesc">Library Calls</refmiscinfo>
37   </refmeta>
38   <refnamediv id='name'>
39     <refname>shadow</refname>
40     <refname>getspnam</refname>
41     <refpurpose>encrypted password file routines</refpurpose>
42   </refnamediv>
43
44   <refsect1 id='syntax'>
45     <title>SYNTAX</title>
46     <para>
47       <emphasis>#include &lt;shadow.h&gt;</emphasis>
48     </para>
49
50     <para>
51       <emphasis>struct spwd *getspent();</emphasis>
52     </para>
53
54     <para>
55       <emphasis>struct spwd *getspnam(char</emphasis> <emphasis
56       remap='I'>*name</emphasis><emphasis>);</emphasis>
57     </para>
58
59     <para>
60       <emphasis>void setspent();</emphasis>
61     </para>
62
63     <para>
64       <emphasis>void endspent();</emphasis>
65     </para>
66
67     <para>
68       <emphasis>struct spwd *fgetspent(FILE</emphasis> <emphasis
69       remap='I'>*fp</emphasis><emphasis>);</emphasis>
70     </para>
71
72     <para>
73       <emphasis>struct spwd *sgetspent(char</emphasis> <emphasis
74       remap='I'>*cp</emphasis><emphasis>);</emphasis>
75     </para>
76
77     <para>
78       <emphasis>int putspent(struct spwd</emphasis> <emphasis
79       remap='I'>*p,</emphasis> <emphasis>FILE</emphasis> <emphasis
80       remap='I'>*fp</emphasis><emphasis>);</emphasis>
81     </para>
82
83     <para>
84       <emphasis>int lckpwdf();</emphasis>
85     </para>
86
87     <para>
88       <emphasis>int ulckpwdf();</emphasis>
89     </para>
90   </refsect1>
91
92   <refsect1 id='description'>
93     <title>DESCRIPTION</title>
94     <para>
95       <emphasis remap='I'>shadow</emphasis> manipulates the contents of the
96       shadow password file, <filename>/etc/shadow</filename>. The structure
97       in the <emphasis remap='I'>#include</emphasis> file is:
98     </para>
99     <programlisting>struct spwd {
100       char              *sp_namp; /* user login name */
101       char              *sp_pwdp; /* encrypted password */
102       long int          sp_lstchg; /* last password change */
103       long int          sp_min; /* days until change allowed. */
104       long int          sp_max; /* days before change required */
105       long int          sp_warn; /* days warning for expiration */
106       long int          sp_inact; /* days before account inactive */
107       long int          sp_expire; /* date when account expires */
108       unsigned long int sp_flag; /* reserved for future use */
109 }
110     </programlisting>
111     <para>The meanings of each field are:</para>
112     <itemizedlist mark='bullet'>
113       <listitem>
114         <para>sp_namp - pointer to null-terminated user name</para>
115       </listitem>
116       <listitem>
117         <para>sp_pwdp - pointer to null-terminated password</para>
118       </listitem>
119       <listitem>
120         <para>sp_lstchg - days since Jan 1, 1970 password was last changed</para>
121       </listitem>
122       <listitem>
123         <para>sp_min - days before which password may not be changed</para>
124       </listitem>
125       <listitem>
126         <para>sp_max - days after which password must be changed</para>
127       </listitem>
128       <listitem>
129          <para>sp_warn - days before password is to expire that user is warned of
130            pending password expiration
131          </para>
132       </listitem>
133       <listitem>
134         <para>sp_inact - days after password expires that account is considered
135           inactive and disabled
136         </para>
137       </listitem>
138       <listitem>
139         <para>sp_expire - days since Jan 1, 1970 when account will be disabled</para>
140       </listitem>
141       <listitem>
142         <para>sp_flag - reserved for future use</para>
143       </listitem>
144     </itemizedlist>
145
146   </refsect1>
147
148   <refsect1 id='description2'>
149     <title>DESCRIPTION</title>
150     <para>
151       <emphasis>getspent</emphasis>, <emphasis>getspname</emphasis>,
152       <emphasis>fgetspent</emphasis>, and <emphasis>sgetspent</emphasis>
153       each return a pointer to a <emphasis>struct spwd</emphasis>.
154       <emphasis>getspent</emphasis> returns the next entry from the file,
155       and <emphasis>fgetspent</emphasis> returns the next entry from the
156       given stream, which is assumed to be a file of the proper format.
157       <emphasis>sgetspent</emphasis> returns a pointer to a <emphasis>struct
158       spwd</emphasis> using the provided string as input.
159       <emphasis>getspnam</emphasis> searches from the current position in
160       the file for an entry matching <emphasis>name</emphasis>.
161     </para>
162
163     <para>
164       <emphasis>setspent</emphasis> and <emphasis>endspent</emphasis> may be
165       used to begin and end, respectively, access to the shadow password
166       file.
167     </para>
168     
169     <para>
170       The <emphasis>lckpwdf</emphasis> and <emphasis>ulckpwdf</emphasis>
171       routines should be used to insure exclusive access to the
172       <filename>/etc/shadow</filename> file.  <emphasis>lckpwdf</emphasis>
173       attempts to acquire a lock using <emphasis>pw_lock</emphasis> for up
174       to 15 seconds. It continues by attempting to acquire a second lock
175       using <emphasis>spw_lock</emphasis> for the remainder of the initial
176       15 seconds. Should either attempt fail after a total of 15 seconds,
177       <emphasis>lckpwdf</emphasis> returns -1. When both locks are acquired
178       0 is returned.
179     </para>
180   </refsect1>
181
182   <refsect1 id='diagnostics'>
183     <title>DIAGNOSTICS</title>
184     <para>
185       Routines return NULL if no more entries are available or if an error
186       occurs during processing. Routines which have <emphasis>int</emphasis>
187       as the return value return 0 for success and
188       -1 for failure.
189     </para>
190   </refsect1>
191
192   <refsect1 id='caveats'>
193     <title>CAVEATS</title>
194     <para>
195       These routines may only be used by the superuser as access to the
196       shadow password file is restricted.
197     </para>
198   </refsect1>
199
200   <refsect1 id='files'>
201     <title>FILES</title>
202     <variablelist>
203       <varlistentry>
204         <term><filename>/etc/shadow</filename></term>
205         <listitem>
206           <para>Secure user account information.</para>
207         </listitem>
208       </varlistentry>
209     </variablelist>
210   </refsect1>
211
212   <refsect1 id='see_also'>
213     <title>SEE ALSO</title>
214     <para>
215       <citerefentry>
216         <refentrytitle>getpwent</refentrytitle><manvolnum>3</manvolnum>
217       </citerefentry>,
218       <citerefentry>
219         <refentrytitle>shadow</refentrytitle><manvolnum>5</manvolnum>
220       </citerefentry>.
221     </para>
222   </refsect1>
223 </refentry>