source: postlfs/security/sudo.xml

trunk
Last change on this file was 133eab2, checked in by Bruce Dubbs <bdubbs@…>, 2 months ago

Initial LFS 12.1 tags

  • Property mode set to 100644
File size: 13.2 KB
RevLine 
[ab4fdfc]1<?xml version="1.0" encoding="UTF-8"?>
[6732c094]2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
[cf341b4]4 <!ENTITY % general-entities SYSTEM "../../general.ent">
5 %general-entities;
6
[c6b192c]7 <!ENTITY sudo-download-http "https://www.sudo.ws/dist/sudo-&sudo-version;.tar.gz">
[e1e58be]8 <!ENTITY sudo-download-ftp " ">
[a6b9afb6]9 <!ENTITY sudo-md5sum "4166279cb188ecb6641c7a2ba5f68270">
[750cb3d]10 <!ENTITY sudo-size "5.1 MB">
[a6b9afb6]11 <!ENTITY sudo-buildsize "53 MB (add 18 MB for tests)">
[da7274f]12 <!ENTITY sudo-time "0.2 SBU (with parallelism=4; add 0.1 SBU for tests)">
[cf341b4]13]>
14
[bcd2922]15<sect1 id="sudo" xreflabel="Sudo-&sudo-version;">
[cf341b4]16 <?dbhtml filename="sudo.html"?>
17
18
19 <title>Sudo-&sudo-version;</title>
20
21 <indexterm zone="sudo">
[bcd2922]22 <primary sortas="a-Sudo">Sudo</primary>
[cf341b4]23 </indexterm>
24
25 <sect2 role="package">
26 <title>Introduction to Sudo</title>
27
[bcd2922]28 <para>
29 The <application>Sudo</application> package allows a system administrator
30 to give certain users (or groups of users) the ability to run
31 some (or all) commands as
32 <systemitem class="username">root</systemitem> or another user while
33 logging the commands and arguments.
34 </para>
[cf341b4]35
[133eab2]36 &lfs121_checked;
[a8d3d55a]37
[cf341b4]38 <bridgehead renderas="sect3">Package Information</bridgehead>
39 <itemizedlist spacing="compact">
40 <listitem>
[bcd2922]41 <para>
42 Download (HTTP): <ulink url="&sudo-download-http;"/>
43 </para>
[cf341b4]44 </listitem>
45 <listitem>
[bcd2922]46 <para>
47 Download (FTP): <ulink url="&sudo-download-ftp;"/>
48 </para>
[cf341b4]49 </listitem>
50 <listitem>
[bcd2922]51 <para>
52 Download MD5 sum: &sudo-md5sum;
53 </para>
[cf341b4]54 </listitem>
55 <listitem>
[bcd2922]56 <para>
57 Download size: &sudo-size;
58 </para>
[cf341b4]59 </listitem>
60 <listitem>
[bcd2922]61 <para>
62 Estimated disk space required: &sudo-buildsize;
63 </para>
[cf341b4]64 </listitem>
65 <listitem>
[bcd2922]66 <para>
67 Estimated build time: &sudo-time;
68 </para>
[cf341b4]69 </listitem>
70 </itemizedlist>
71
72 <bridgehead renderas="sect3">Sudo Dependencies</bridgehead>
73
74 <bridgehead renderas="sect4">Optional</bridgehead>
[bcd2922]75 <para role="optional">
76 <xref linkend="linux-pam"/>,
77 <xref linkend="mitkrb"/>,
78 <xref linkend="openldap"/>,
[6b4f8529]79 <xref linkend="server-mail"/> (that provides a
80 <command>sendmail</command> command),
[5183155]81 <ulink url="https://www.openafs.org/">AFS</ulink>,
[7b8bec72]82<!-- It seems dead for decades, nowhere to download source code
[cd29bc9]83 <ulink url="https://www.fwtk.org/">FWTK</ulink>, and
[7b8bec72]84-->
[5183155]85 <ulink url="https://github.com/linux-audit/audit-userspace">libaudit</ulink>,
86 <ulink url="&sourceforge-dl;/opie/">Opie</ulink>, and
87 <ulink url="https://sssd.io/">Sssd</ulink>
[bcd2922]88 </para>
[b35e86b2]89
[cf341b4]90 </sect2>
91
92 <sect2 role="installation">
93 <title>Installation of Sudo</title>
94
[bcd2922]95 <para>
[6e5d584]96 Install <application>Sudo</application> by running the following commands:
[bcd2922]97 </para>
[cf341b4]98
[b9d56ad4]99<screen><userinput>./configure --prefix=/usr \
[edaee95]100 --libexecdir=/usr/lib \
[1a657ca]101 --with-secure-path \
[b9d56ad4]102 --with-env-editor \
103 --docdir=/usr/share/doc/sudo-&sudo-version; \
[9dabcf3]104 --with-passprompt="[sudo] password for %p: " &amp;&amp;
[cf341b4]105make</userinput></screen>
106
[bcd2922]107 <para>
[5183155]108 To test the results, issue:
109 <!-- line breaks in command tags confuse jhalfs -->
110 <command>env LC_ALL=C make check |&amp; tee make-check.log</command>.
111 Check the results with <command>grep failed make-check.log</command>.
[bcd2922]112 </para>
[21755bc]113
[bcd2922]114 <para>
115 Now, as the <systemitem class="username">root</systemitem> user:
116 </para>
[cf341b4]117
[0a22f18]118<!-- for a DESTDIR install as normal user, use
119 "make install INSTALL_OWNER= DESTDIR=<destdir>"-->
[5183155]120<screen role="root"><userinput>make install</userinput></screen>
[cf341b4]121
122 </sect2>
123
124 <sect2 role="commands">
125 <title>Command Explanations</title>
126
[663b79c2]127 <para>
[edaee95]128 <parameter>--libexecdir=/usr/lib</parameter>: This switch controls where
[663b79c2]129 private programs are installed. Everything in that directory is a library, so
130 they belong under <filename class="directory">/usr/lib</filename> instead of
131 <filename class="directory">/usr/libexec</filename>.
[8466229]132 </para>
133
134 <para>
135 <parameter>--with-secure-path</parameter>: This switch transparently adds
136 <filename class="directory">/sbin</filename> and <filename
137 class="directory">/usr/sbin</filename> directories to the
138 <envar>PATH</envar> environment variable.
[663b79c2]139 </para>
140
[bcd2922]141 <para>
[f3d174f]142 <parameter>--with-env-editor</parameter>: This switch enables use of the
[bcd2922]143 environment variable EDITOR for <command>visudo</command>.
144 </para>
[8890b85f]145
[f3d174f]146 <para>
[ecea644]147 <parameter>--with-passprompt</parameter>: This switch sets the password prompt.
[7f99ddf]148 The <parameter>%p</parameter> will be expanded to the name of the user whose password is being requested.
[f3d174f]149 </para>
150
[14c71e0]151 <para>
[f586237]152 <option>--without-pam</option>: This switch avoids building
153 <application>Linux-PAM</application> support when
154 <application>Linux-PAM</application> is installed on the system.
[14c71e0]155 </para>
[5183155]156
157 <para>
158 <option>--with-all-insults</option>: This switch includes all the
159 sudo insult sets. Insults are printed if the user types a bad
160 password, and if enabled in <filename>/etc/sudoers</filename>. Use
161 <option>--with-insults</option> to have them enabled by default.
162 Various sets of insults can be selected with some other switches.
163 </para>
[b9d56ad4]164
[33d90fe]165 <note>
[bcd2922]166 <para>
167 There are many options to <application>sudo</application>'s
168 <command>configure</command> command. Check the
169 <command>configure --help</command> output for a complete list.
170 </para>
[33d90fe]171 </note>
[5183155]172 <!-- Seems to be fixed
[2809c8c]173 <para>
[f586237]174 <command>ln -sfv libsudo_util...</command>: Works around a bug in the
[2809c8c]175 installation process, which links to the previously installed
176 version (if there is one) instead of the new one.
177 </para>
[5183155]178 -->
[cf341b4]179 </sect2>
180
181 <sect2 role="configuration">
182 <title>Configuring Sudo</title>
183
184 <sect3 id="sudo-config">
185 <title>Config File</title>
186
[7a47afc]187 <para>
188 <filename>/etc/sudoers</filename>
189 </para>
[cf341b4]190
191 <indexterm zone="sudo sudo-config">
192 <primary sortas="e-etc-sudoers">/etc/sudoers</primary>
193 </indexterm>
194
195 </sect3>
196
197 <sect3>
198 <title>Configuration Information</title>
199
[bcd2922]200 <para>
201 The <filename>sudoers</filename> file can be quite complicated. It
202 is composed of two types of entries: aliases (basically variables) and
203 user specifications (which specify who may run what). The installation
[b4c31a6]204 installs a default configuration that has no privileges installed for
205 any user.
[bcd2922]206 </para>
[bccbdaea]207
[a5b9f1e]208 <para>
[c513d6e6]209 A couple of common configuration changes are to set the path for the
[77b64bd]210 super user and to allow members of the wheel group to execute all
[5031e90]211 commands after providing their own credentials. Use the following
[7826062]212 commands to create the <filename>/etc/sudoers.d/00-sudo</filename>
[77b64bd]213 configuration file as the
214 <systemitem class="username">root</systemitem> user:
[a5b9f1e]215 </para>
216
[193bdf3]217<screen role="root"><userinput>cat &gt; /etc/sudoers.d/00-sudo &lt;&lt; "EOF"
[2f4e6181]218<literal>Defaults secure_path="/usr/sbin:/usr/bin"
[77b64bd]219%wheel ALL=(ALL) ALL</literal>
220EOF</userinput></screen>
[8558044]221
[193bdf3]222 <note>
223 <para>
224 In very simple installations where there is only one user, it
225 may be easier to just edit the <filename>/etc/sudoers</filename>
226 file directly. In that case, the <varname>secure_path</varname>
227 entry may not be needed and using <command>sudo -E ...</command> can
[7a9a7b26]228 import the non-privileged user's full environment into the
[193bdf3]229 privileged session.
230 </para>
[7a9a7b26]231
[193bdf3]232 <para>
[7a9a7b26]233 The files in the <filename class="directory">/etc/sudoers.d</filename>
234 directory are parsed in sorted lexical order. Be careful that entries
[193bdf3]235 in an added file do not overwrite previous entries.
236 </para>
237 </note>
238
[bcd2922]239 <para>
240 For details, see <command>man sudoers</command>.
241 </para>
[cf341b4]242
[3c0f868f]243 <note>
[bcd2922]244 <para>
245 The <application>Sudo</application> developers highly recommend
246 using the <command>visudo</command> program to edit the
247 <filename>sudoers</filename> file. This will provide basic sanity
[b4c31a6]248 checking like syntax parsing and file permission to avoid some
249 possible mistakes that could lead to a vulnerable configuration.
[bcd2922]250 </para>
[3c0f868f]251 </note>
252
[bcd2922]253 <para>
[14c71e0]254 If <application>PAM</application> is installed on the system,
255 <application>Sudo</application> is built with
[b4c31a6]256 <application>PAM</application> support. In that case, issue the
257 following command as the <systemitem class="username">root</systemitem>
258 user to create the <application>PAM</application> configuration file:
[bcd2922]259 </para>
[8890b85f]260
[add8d4f]261<screen role="root"><userinput>cat &gt; /etc/pam.d/sudo &lt;&lt; "EOF"
262<literal># Begin /etc/pam.d/sudo
[b3a4f60]263
264# include the default auth settings
265auth include system-auth
266
267# include the default account settings
268account include system-account
269
270# Set default environment variables for the service user
271session required pam_env.so
272
273# include system session defaults
274session include system-session
275
[add8d4f]276# End /etc/pam.d/sudo</literal>
[b3a4f60]277EOF
278chmod 644 /etc/pam.d/sudo</userinput></screen>
[fd7e0ed6]279
[cf341b4]280 </sect3>
281
282 </sect2>
283
284 <sect2 role="content">
285 <title>Contents</title>
286
287 <segmentedlist>
288 <segtitle>Installed Programs</segtitle>
[9d53187]289 <segtitle>Installed Libraries</segtitle>
[cf341b4]290 <segtitle>Installed Directories</segtitle>
291
292 <seglistitem>
[bcd2922]293 <seg>
[a82b5f44]294 cvtsudoers, sudo, sudo_logsrvd, sudo_sendlog,
295 sudoedit (symlink), sudoreplay, and visudo
[bcd2922]296 </seg>
297 <seg>
[a82b5f44]298 <!-- [pierre, September 25, 2020] except libsudo_util, the other
299 shared objects in /usr/lib/sudo look more like modules than
300 libraries. Leaving them now, and updating the list, but I think
301 they should not be listed. -->
[5183155]302 audit_json.so, group_file.so, libsudo_util.so,
303 sudoers.so, sudo_intercept.so, sudo_noexec.so, and system_group.so
[bcd2922]304 </seg>
305 <seg>
[7a47afc]306 /etc/sudoers.d,
[b378aa0]307 /usr/lib/sudo,
[06915b3]308 /usr/share/doc/sudo-&sudo-version;, and
[a82b5f44]309 /var/lib/sudo
[bcd2922]310 </seg>
[cf341b4]311 </seglistitem>
312 </segmentedlist>
313
314 <variablelist>
315 <bridgehead renderas="sect3">Short Descriptions</bridgehead>
316 <?dbfo list-presentation="list"?>
317 <?dbhtml list-presentation="table"?>
318
[d7bbb40]319 <varlistentry id="cvtsudoers">
320 <term><command>cvtsudoers</command></term>
321 <listitem>
322 <para>
[4c24eb0a]323 converts between sudoers file formats
[d7bbb40]324 </para>
325 <indexterm zone="sudo cvtsudoers">
326 <primary sortas="b-cvtsudoers">cvtsudoers</primary>
327 </indexterm>
328 </listitem>
329 </varlistentry>
330
[cf341b4]331 <varlistentry id="sudo_prog">
332 <term><command>sudo</command></term>
333 <listitem>
[bcd2922]334 <para>
335 executes a command as another user as permitted by
[4c24eb0a]336 the <filename>/etc/sudoers</filename> configuration file
[cf341b4]337 </para>
338 <indexterm zone="sudo sudo">
339 <primary sortas="b-sudo">sudo</primary>
340 </indexterm>
341 </listitem>
342 </varlistentry>
343
[a82b5f44]344 <varlistentry id="sudo_logsrvd">
345 <term><command>sudo_logsrvd</command></term>
346 <listitem>
347 <para>
[4c24eb0a]348 is a sudo event and I/O log server
[a82b5f44]349 </para>
350 <indexterm zone="sudo sudo_logsrvd">
351 <primary sortas="b-sudo_logsrvd">sudo_logsrvd</primary>
352 </indexterm>
353 </listitem>
354 </varlistentry>
355
356 <varlistentry id="sudo_sendlog">
357 <term><command>sudo_sendlog</command></term>
358 <listitem>
359 <para>
[4c24eb0a]360 sends sudo I/O logs to the log server
[a82b5f44]361 </para>
362 <indexterm zone="sudo sudo_sendlog">
363 <primary sortas="b-sudo_sendlog">sudo_sendlog</primary>
364 </indexterm>
365 </listitem>
366 </varlistentry>
367
[cf341b4]368 <varlistentry id="sudoedit">
369 <term><command>sudoedit</command></term>
370 <listitem>
[bcd2922]371 <para>
[a1e0f76]372 is a symlink to <command>sudo</command> that implies the
[4c24eb0a]373 <option>-e</option> option to invoke an editor as another user
[bcd2922]374 </para>
[cf341b4]375 <indexterm zone="sudo sudoedit">
376 <primary sortas="b-sudoedit">sudoedit</primary>
377 </indexterm>
378 </listitem>
379 </varlistentry>
380
[72d90b67]381 <varlistentry id="sudoreplay">
382 <term><command>sudoreplay</command></term>
[3c0f868f]383 <listitem>
[bcd2922]384 <para>
[72d90b67]385 is used to play back or list the output
[4c24eb0a]386 logs created by <command>sudo</command>
[bcd2922]387 </para>
[72d90b67]388 <indexterm zone="sudo sudoreplay">
389 <primary sortas="b-sudoreplay">sudoreplay</primary>
[3c0f868f]390 </indexterm>
391 </listitem>
392 </varlistentry>
393
[72d90b67]394 <varlistentry id="visudo">
395 <term><command>visudo</command></term>
[61b8305]396 <listitem>
[bcd2922]397 <para>
[72d90b67]398 allows for safer editing of the <filename>sudoers</filename>
[4c24eb0a]399 file
[bcd2922]400 </para>
[72d90b67]401 <indexterm zone="sudo visudo">
402 <primary sortas="b-visudo">visudo</primary>
[61b8305]403 </indexterm>
404 </listitem>
405 </varlistentry>
[3c0f868f]406
[cf341b4]407 </variablelist>
408
409 </sect2>
410
411</sect1>
Note: See TracBrowser for help on using the repository browser.