Fix key reloading core dumps. Change advice on keys.
[become] / manual / become.texi
1 \input texinfo @c -*-texinfo-*-
2 @c
3 @c $Id: become.texi,v 1.6 2003/10/26 11:57:46 mdw Exp $
4 @c
5 @c Documentation for `become'
6 @c
7 @c (c) 1998 EBI
8 @c
9
10 @c ----- Revision history ---------------------------------------------------
11 @c
12 @c $Log: become.texi,v $
13 @c Revision 1.6 2003/10/26 11:57:46 mdw
14 @c Fix key reloading core dumps. Change advice on keys.
15 @c
16 @c Revision 1.5 2003/10/12 00:14:49 mdw
17 @c Major overhaul. Now uses DSA signatures rather than the bogus symmetric
18 @c encrypt-and-hope thing. Integrated with mLib and Catacomb.
19 @c
20 @c Revision 1.4 1998/04/23 13:16:14 mdw
21 @c Include `texinice' to produce decent printed output. Add documentation
22 @c for new `bcquery' program. Various fixes, including spelling mistakes,
23 @c and some factual inaccuracies.
24 @c
25 @c Revision 1.3 1998/01/20 14:37:43 mdw
26 @c Fix typo. Short form of `--preserve' should be `-e', not `-p'.
27 @c
28 @c Revision 1.2 1998/01/12 16:41:31 mdw
29 @c Tidying for new release versions. Fix copyright date.
30 @c
31 @c Revision 1.1 1997/09/18 11:16:34 mdw
32 @c Brand new Texinfo manual, with wider scope than the original LaTeX one.
33 @c
34
35 @c ----- Standard boilerplate -----------------------------------------------
36
37 @c %**start of header
38 @setfilename become.info
39 @settitle Become
40 @setchapternewpage odd
41 @footnotestyle end
42 @paragraphindent 0
43 @iftex
44 @input texinice.tex
45 @afourpaper
46 @c @parindent=0pt
47 @end iftex
48 @c %**end of header
49
50 @c ----- Useful macros ------------------------------------------------------
51
52 @set version 1.3
53
54 @c ----- Copyright matters --------------------------------------------------
55
56 @c --- The `Info' version ---
57
58 @ifinfo
59
60 This file documents Become version @value{version}.
61
62 Copyright (c) 1998 European Bioinformatics Institute.
63
64 Permission is granted to make and distribute verbatim copies of this
65 manual provided the copyright notice and this permission notice are
66 preserved on all copies.
67
68 @ignore
69 Permission is granted to process this file through TeX and print the
70 results, provided the printed document carries a copying permission
71 notice identical to this one except for the removal of this paragraph
72 (this paragraph not being relevant to the printed manual).
73
74 @end ignore
75 Permission is granted to copy and distribute modified versions of this
76 manual under the conditions for verbatim copying, provided also that the
77 sections entitled `Copying' and `GNU General Public License' are
78 included exactly as in the original, and provided that the entire
79 resulting derived work is distributed under the terms of a permission
80 notice identical to this one.
81
82 Permission is granted to copy and distribute translations of this manual
83 into another language, under the above conditions for modified versions,
84 except that this permission notice may be stated in a translation
85 approved by the European Bioinformatics Institute.
86
87 @end ifinfo
88
89 @c --- Printed title page ---
90
91 @titlepage
92
93 @title The Become program
94 @subtitle Become version @value{version}
95 @author Mark Wooding @email{mdw@@ebi.ac.uk}
96 @page
97
98 @vskip 0pt plus 1filll
99
100 Copyright @copyright{} 1998 European Bioinformatics Institute.
101
102 Permission is granted to make and distribute verbatim copies of this
103 manual provided the copyright notice and this permission notice are
104 preserved on all copies.
105
106 Permission is granted to copy and distribute modified versions of this
107 manual under the conditions for verbatim copying, provided also that the
108 sections entitled `Copying' and `GNU General Public License' are
109 included exactly as in the original, and provided that the entire
110 resulting derived work is distributed under the terms of a permission
111 notice identical to this one.
112
113 Permission is granted to copy and distribute translations of this manual
114 into another language, under the above conditions for modified versions,
115 except that this permission notice may be stated in a translation
116 approved by the European Bioinformatics Institute.
117
118 @end titlepage
119
120
121 @c --------------------------------------------------------------------------
122 @ifinfo
123 @node Top, Copying, (dir), (dir)
124 @top Become
125
126
127 Become is a system for managing shared accounts. It allows users to
128 `become' other users in order to do useful work. It can be managed on a
129 central server (or a small number of central servers), or it can run
130 standalone.
131
132 This file documents Become version @value{version}.
133
134 @end ifinfo
135
136 @menu
137 * Copying:: Your rights to distribute and modify
138 * Introduction:: A brief introduction to Become
139 * Becoming someone else:: How to become somebody else
140 * Administering Become:: How to maintain Become
141 * Invoking Become:: Reference to Become's command line options
142
143 @detailmenu
144 --- The Detailed Node Listing ---
145
146 Becoming someone else
147
148 * Terminology:: Some important terms defined
149 * Environment:: Login styles and environment variables
150 * Group permissions:: How Become handles group permissions
151 * X authority:: Problems with X authority files
152 * Running commands:: Running commands other than a shell
153
154 How Become sets up the environment
155
156 * New environment variables:: Become adds some useful environment variables
157 * Login styles:: Choose how Become sets the environment
158 * Tweaking the environment:: Altering individual environment variables
159 * Removed variables:: Some environment variables aren't passed on
160
161 Login styles
162
163 * The preserve style:: Preserve the current environment
164 * The set-user style:: Set user-specific variables (like @code{su})
165 * The login style:: Clear the environment (like @code{login})
166
167 How Become handles groups
168
169 * Primary group selection:: Setting the new primary group
170 * Subsidiary groups:: Setting subsidiary group memberships
171
172 Considerations for X authority
173
174 * The user-group method:: A fairly secure way of handling X authority
175 * Using xauth:: A less secure method, which might be easier
176
177 Become administration
178
179 * Configuration files:: Overview of Become's configuration files
180 * Standalone or networked:: The two main types of Become installations
181 * The configuration file:: How to define who's allowed to do what
182 * Networked configuration:: Considerations for networked installations
183
184 The configuration file
185
186 * Requests and rules:: How the configuration file works
187 * Basic syntax:: Quick overview of Become's syntax
188 * Classes:: Defining classes of things
189 * Predefined classes:: Become predefines some (maybe) useful classes
190 * Allow statements:: Allow users to become other users
191 * Other statements:: Some other useful statements
192 * Example configuration file:: An example, showing a few features.
193 * Checking and querying:: Checking and querying configuration files
194 * Complete grammar:: Complete grammar for Become config files
195
196 Checking and querying the configuration file
197
198 * Verifying config files:: Checking a configuration file is correct
199 * Querying config files:: Asking questions about privileges
200 * Output formats:: Different ways of formatting output
201 * Restricting output:: Being selective about what gets output
202 * bcquery reference:: Complete command line reference
203
204 Networked configuration
205
206 * Choosing servers:: Which servers Become tries to talk to
207 * Setting up keys:: How to generate keys for Become
208 * Issuing a new key:: How to issue new keys without disruption
209
210 Invoking Become
211
212 * Becoming another user:: Options for becoming another user
213 * Starting Become daemons:: Options for starting Become daemons
214 * Debugging options:: Options to use when Become goes wrong
215
216 @end detailmenu
217 @end menu
218
219 @c --------------------------------------------------------------------------
220 @node Copying, Introduction, Top, Top
221 @unnumbered The GNU General Public License
222
223 @include gpl.texi
224
225
226 @c --------------------------------------------------------------------------
227 @node Introduction, Becoming someone else, Copying, Top
228 @unnumbered Introduction
229
230
231 It's often useful to be able to share accounts between a number of
232 users. For example, a group maintaining an externally visible service
233 need to be able to start and kill the server process. Giving such a
234 shared account a password is a fairly bad plan: such passwords tend not
235 to get changed very often, and they have a habit of spreading beyond the
236 group of legitimate users.
237
238 The Become program presented here offers a solution to the problems of
239 shared accounts. It allows the system administrator to define which
240 users are allowed access to which accounts, on which hosts, and to
241 execute which commands. Such shared accounts can then, in general, have
242 their passwords removed.
243
244 This coincidentally has another advantage: when `becoming' to a shared
245 account, a user can retain her@footnote{Or his. I'll choose one or the
246 other fairly randomly throughout this manual.} own environment, which
247 she's carefully crafted and honed over the years, rather then being
248 presented with some lowest-common-denominator setup which probably
249 doesn't even use the right shell.
250
251 The configuration file for Become can either be distributed to all the
252 various hosts in a network or a few carefully set up and secure servers
253 (@pxref{Standalone or networked}).
254
255
256 @c --------------------------------------------------------------------------
257 @node Becoming someone else, Administering Become, Introduction, Top
258 @chapter Becoming someone else
259
260
261 The simplest way to become someone else is to say
262
263 @example
264 become @var{user}
265 @end example
266
267 @noindent
268 Become will check to see whether you're allowed to become @var{user}. If you
269 are, it starts a shell process with the user-id set to @var{user}. Any
270 commands you type are executed with the privileges of @var{user}.
271
272 The full invocation is slightly more complicated:
273
274 @example
275 become [@var{option}@dots{}] [@var{env-var}@dots{}] @var{user} [@var{command} [@var{arg}@dots{}]]
276 @end example
277
278 Actually, the @var{option}s, @var{env-var}s and @var{user} can be in any
279 order -- the important point is that all of them appear before the
280 @var{command}, if there is one.
281
282 @menu
283 * Terminology:: Some important terms defined
284 * Environment:: Login styles and environment variables
285 * Group permissions:: How Become handles group permissions
286 * X authority:: Problems with X authority files
287 * Running commands:: Running commands other than a shell
288 @end menu
289
290
291
292 @node Terminology, Environment, Becoming someone else, Becoming someone else
293 @section Terminology
294
295 The following terms get used quite a bit in the following text:
296
297 @table @asis
298 @item request
299 An invocation of Become, asking permission to become another user.
300
301 @item old user
302 The (real) user id of the process which invoked Become; usually, this will be
303 your normal user id.
304
305 @item target user
306 The user whom you want to become, named in a request.
307 @end table
308
309
310
311 @node Environment, Group permissions, Terminology, Becoming someone else
312 @section How Become sets up the environment
313
314 There are thorny problems with handling the user's environment. It seems
315 that (the author's initial assessment notwithstanding) there is no single
316 best way of handling environment variables. As a result, Become can do just
317 about everything you might want it to. This gets slightly complicated.
318 Don't worry: it's not as hard as all that.
319
320 @menu
321 * New environment variables:: Become adds some useful environment variables
322 * Login styles:: Choose how Become sets the environment
323 * Tweaking the environment:: Altering individual environment variables
324 * Removed variables:: Some environment variables aren't passed on
325 @end menu
326
327
328 @node New environment variables, Login styles, Environment, Environment
329 @subsection Environment variables created by Become
330
331 To help you (and, more importantly, your startup scripts) keep track of who
332 you are, and who you were originally, Become adds some variables to the
333 environment of any processes it starts.
334
335 @table @code
336 @item BECOME_USER
337 The name of the target user (i.e., the user you are now). It might be useful
338 to test this value in shell startup scripts, for example.
339
340 @item BECOME_HOME
341 The home directory of the target user. It can be handy to read startup and
342 other configuration files from here.
343
344 @item BECOME_OLD_USER
345 The name of the user who invoked Become.
346
347 @item BECOME_OLD_HOME
348 The home directory of the `old' user.
349
350 @item BECOME_ORIGINAL_USER
351 This is intended to be the name you logged in with. If it's unset, Become
352 sets it to be the same as @code{BECOME_OLD_USER}; otherwise it leaves it
353 unchanged.
354
355 @item BECOME_ORIGINAL_HOME
356 This is intended to be the home directory you logged in with. If it's unset,
357 Become sets it to be the same as @code{BECOME_OLD_HOME}; otherwise, it leaves
358 it unchanged.
359 @end table
360
361 Don't even think about relying on these variables as a form of
362 authentication. It won't work. They're provided only to help organise
363 startup scripts.
364
365
366
367 @node Login styles, Tweaking the environment, New environment variables, Environment
368 @subsection Login styles
369
370 Originally, Become always tried to preserve your environment. There's a
371 rational explanation for this approach, which is given in the description of
372 the `preserve' style below. Unfortunately, not everyone liked this
373 approach. As a result, there's now a collection of different login styles.
374
375 Login styles are selected by giving command line arguments:
376
377 @table @code
378 @item -e
379 @itemx --preserve
380 The original style: try to preserve the existing user's environment as much
381 as possible.
382
383 @item -s
384 @itemx --set-user
385 Set some user-specific variables, like @code{USER} and @code{HOME} to reflect
386 the target user rather than the old user. All other variables are preserved.
387
388 @item -l
389 @itemx --login
390 Attempts to make the `become' process as much like a real login as possible.
391 All variables not explicitly preserved are deleted, and a new environment is
392 built, reflecting the target user.
393 @end table
394
395 The various styles, and the reasons behind them, are described below.
396
397 @menu
398 * The preserve style:: Preserve the current environment
399 * The set-user style:: Set user-specific variables (like @code{su})
400 * The login style:: Clear the environment (like @code{login})
401 @end menu
402
403
404 @node The preserve style, The set-user style, Login styles, Login styles
405 @subsubsection The `preserve' login style
406
407 You've spent many hours (days? weeks, even?) customising and honing your
408 startup files, learning how to use your shell, and tweaking your favourite
409 text editor until it's just the way you like it. So there can be few things
410 more annoying than logging into a shared account to find out that the shell's
411 wrong, your editor startup files are ignored, and nothing works quite the way
412 you'd like it to. Typically you can't change this without annoying the other
413 users: the result is a horrible compromise which dissatisfies everyone
414 equally.
415
416 The `preserve' style lets you take your standard environment with you when
417 you become someone else. It tries hard not to modify any environment
418 variables.
419
420 Become starts your standard shell. If you have an environment variable
421 @code{SHELL} defined, than this is executed. Otherwise, the shell specified
422 in your entry in the password file is used. (You must have permission to
423 execute whatever shell is chosen as the target user, or you'll just be given
424 an error message.)
425
426 Most programs look at environment variables in preference to looking up
427 entries in the password database; e.g., they tend to use @code{USER} or
428 @code{LOGNAME} for the user name, and @code{HOME} for your home directory.
429 As a result, most programs will continue to find their configuration files in
430 your home directory. Also, systems like RCS will use your real name, rather
431 than the name of the user that you have become.
432
433 To make best use of this login style, you may need to adjust your login
434 scripts to notice when @code{BECOME_USER} is someone else, and read in
435 appropriate definitions. For example, a `bash' user might say something like
436 this in her @file{.bashrc}:
437
438 @example
439 if [ -n "$BECOME_HOME" ]; then . $BECOME_HOME/.bashrc
440 @end example
441
442 @noindent
443 Similarly, a C shell user (either `tcsh' or `csh') might say something like
444
445 @example
446 if ($?BECOME_HOME) source $@{BECOME_HOME@}/.cshrc
447 @end example
448
449 (Note that plain Bourne shell users have a slight problem, because the Bourne
450 shell only reads configuration things on a login, not when a normal
451 interactive shell is started.)
452
453
454 @node The set-user style, The login style, The preserve style, Login styles
455 @subsubsection The `set-user' login style
456
457 The author sees the main use of Become as allowing a user to acquire the
458 privileges associated with a shared account without all the problems which
459 shared accounts usually cause. To the author's way of thinking, one of the
460 main problems is that your environment gets replaced by something alien and
461 wrong. People disagree with me over this point, and for this reason the
462 `set-user' style exists.
463
464 The objective of `set-user' style is to behave similarly to the standard
465 @code{su} command. Unless they've been preserved explicitly (@pxref{Tweaking
466 the environment}), `set-user' mode sets the following environment variables:
467
468 @table @code
469 @item USER
470 @itemx LOGNAME
471 The name of the target user.
472
473 @item HOME
474 The home directory of the target user.
475
476 @item SHELL
477 The target user's default shell
478 @end table
479
480 The result of this is that the shell will read the target user's
481 configuration files and present you with the environment set up there.
482
483 I can't think of this style as being anything other than a migration aid
484 while users are getting used to the freedom offered by the `preserve' style.
485
486
487 @node The login style, , The set-user style, Login styles
488 @subsubsection The `login' login style
489
490 The `login' style causes Become to attempt to emulate a full login. Become
491 will empty the environment of almost variables which aren't explicitly
492 preserved (@pxref{Tweaking the environment}). However, the following
493 variables are retained:
494
495 @itemize @bullet
496 @item
497 TERM
498 @item
499 DISPLAY
500 @item
501 TZ
502 @end itemize
503
504 @noindent
505 It will set the following variables:
506
507 @table @code
508 @item USER
509 @itemx LOGNAME
510 The name of the target user.
511
512 @item HOME
513 The home directory of the target user.
514
515 @item SHELL
516 The target user's default shell
517
518 @item MAIL
519 An educated guess at where the target user's mailbox is.
520 @end table
521
522 By default, it runs the target user's shell, informing it that this is a
523 login by setting the first character of @code{argv[0]} to @samp{-}.
524
525 Become makes no entries in the @file{utmp} and @file{wtmp} files.
526
527
528
529 @node Tweaking the environment, Removed variables, Login styles, Environment
530 @subsection Tweaking individual environment variables
531
532 Become's login styles provide a sort of course-grained control over the
533 environment. Sometimes the control isn't fine enough. Become lets you tweak
534 individual variables: you can set, delete, or preserve named variables from
535 modification.
536
537 There are three different things you can do with environment variables:
538
539 @itemize @bullet
540 @item
541 Set a variable called @var{var} to a value @var{value}, by saying
542
543 @example
544 @var{var}=@var{value}
545 @end example
546
547 @noindent
548 The variable is preserved from automatic deletion by the login-style rules.
549
550 @item
551 Delete a variable called @var{var} from the environment, by saying
552
553 @example
554 @var{var}-
555 @end example
556
557 @item
558 Preserve a variable @var{var} from being deleted or modified by Become's
559 login-style rules, but not change its value, by saying
560
561 @example
562 @var{var}!
563 @end example
564 @end itemize
565
566 Just to try and make this slightly more sensible, here's an example. Suppose
567 I want my @code{XAUTHORITY} variable to be set when I become user `fred':
568
569 @example
570 become XAUTHORITY=$HOME/.Xauthority fred
571 @end example
572
573 @noindent
574 should do the job nicely. Similarly, if I want to log in as `bob', but don't
575 want my @code{EDITOR} variable to change:
576
577 @example
578 become --login EDITOR! bob
579 @end example
580
581 @noindent
582 (Of course, in this example, I'm at the mercy of Bob's shell init files as to
583 whether his choice of editor overrides mine.)
584
585
586
587 @node Removed variables, , Tweaking the environment, Environment
588 @subsection Variables removed from the environment
589
590 Some variables are removed from the environment which Become passes to a
591 program for security reasons:
592
593 @table @code
594 @item LD_*
595 @itemx SHLIB_PATH
596 @itemx LIBPATH
597 @itemx _RLD_*
598 These variables are used on various systems as a search path for shared
599 libraries. Clearly, by manipulating these search paths, an attacker could
600 replace a standard shared library with one of his own.
601
602 @item IFS
603 The shell input field separator. Modifying this variable radically alters
604 the way shells parse their inputs. (In particular, consider the case where
605 @code{IFS} contains @samp{/}.)
606
607 @item ENV
608 @itemx BASH_ENV
609 Used by some shells: it contains the name of a file to read on every shell
610 invocation.
611
612 @item KRB_CONF
613 @ignore
614 I'm not really sure what's going on here, so I'll just have to bluff my way
615 through. I think that the following is more-or-less accurate, having browsed
616 a small amount of Kerberos-related documentation.
617 @end ignore
618 Contains the name of a Kerberos configuration file. By manipulating this
619 variable, an attacker could persuade a program to believe the wrong
620 authentication server.
621 @end table
622
623 Also note that the @code{PATH} variable is modified: any items which aren't
624 absolute pathnames are removed from the path. This check may become stricter
625 in future, although getting the balance between security and convenience is
626 particularly hard here.
627
628
629
630 @node Group permissions, X authority, Environment, Becoming someone else
631 @section How Become handles groups
632
633 As well as handling changes of user id, Become also changes group ids.
634 The exact changes Become makes are under user control.
635
636 @menu
637 * Primary group selection:: Setting the new primary group
638 * Subsidiary groups:: Setting subsidiary group memberships
639 @end menu
640
641
642 @node Primary group selection, Subsidiary groups, Group permissions, Group permissions
643 @subsection Choosing a new primary group
644
645 By default, the primary group is chosen according to the login style
646 (@pxref{Login styles}): the `preserve' style retains the current primary
647 group, while `set-user' and `login' styles choose the target's primary group.
648
649 You can override Become's default choice using the @code{--group} (@code{-g}
650 for short) option:
651
652 @example
653 become --group=@var{group} @dots{}
654 @end example
655
656 The chosen @var{group} may be either a group name or a numeric gid. The
657 group must be one of the following:
658
659 @itemize @bullet
660 @item
661 Your current primary group.
662 @item
663 One of your current subsidiary groups.
664 @item
665 The target user's primary group.
666 @item
667 One of the target user's subsidiary groups.
668 @end itemize
669
670 Become will raise an error if this isn't the case.
671
672
673 @node Subsidiary groups, , Primary group selection, Group permissions
674 @subsection Handling subsidiary group memberships
675
676 Subsidiary group memberships are a powerful tool for managing permissions
677 under Unix. Traditionally, they tend to be tied to particular users. Become
678 tries to be sightly more intelligent about group memberships.
679
680 Become has a concept of @dfn{group style}, analogous to login style
681 (@pxref{Login styles}). The styles are selected by giving command line
682 arguments:
683
684 @table @code
685 @item -k
686 @itemx --keep-groups
687 Retain the existing group memberships; don't add any new groups.
688
689 @item -m
690 @itemx --merge-groups
691 Merge group memberships of the target user with the exiting memberships.
692
693 @item -r
694 @itemx --replace-groups
695 Replace the existing group memberships with the target user's memberships.
696 @end table
697
698 Again, the defaults are dependent on the chosen login style. Both `preserve'
699 and `set-user' merge group memberships; the `login' style replaces the set of
700 groups.
701
702 Note that you can do perverse things like replace all the subsidiary groups
703 but retain your primary group (using the @code{--group} option;
704 @pxref{Primary group selection}) if you like: Become won't try to stop you.
705
706
707
708 @node X authority, Running commands, Group permissions, Becoming someone else
709 @section Considerations for X authority
710
711 Other users can't read your @file{.Xauthority} file, if you have one. This
712 is as it should be: anyone who can read it can connect to your X server and
713 read or generate events. However, once you've become another user, you can't
714 open any X windows; this can be annoying if your favourite editor is X-based.
715
716 There are two basic approaches. Either you can send the shared account a
717 copy of your display's magic cookie, or you can retain permission to read the
718 cookie file.
719
720 Be aware that allowing a shared account to connect to your X display is a
721 security risk.
722
723 @menu
724 * The user-group method:: A fairly secure way of handling X authority
725 * Using xauth:: A less secure method, which might be easier
726 @end menu
727
728
729 @node The user-group method, Using xauth, X authority, X authority
730 @subsection The user-group method for handling X authority
731
732 This method is secure only if your site uses the `user-group' system. In
733 this system, each user is allocated a group containing only that user.
734 Usually this is made the user's default primary group, although that's not
735 necessary here.
736
737 When you start a new X session, ensure that your cookie file is owned by you
738 and your private group. Change the file's permissions so that it's group
739 readable. Finally, ensure that your private group is retained when you
740 become someone else (@pxref{Group permissions}), and that the
741 @code{XAUTHORITY} variable is set correctly.
742
743 Note that Unix's security mechanisms aren't designed to prevent processes
744 owned by the same user from interfering with each other. This method does
745 not provide complete security.
746
747 The following Bourne shell code in a @file{.xinitrc} should do most of the
748 work:
749
750 @example
751 XAUTHORITY="$HOME/.Xauthority"
752 export XAUTHORITY
753 chgrp mygroup $XAUTHORITY
754 chmod 640 $XAUTHORITY
755 @end example
756
757 @noindent
758 In a C shell, this becomes
759
760 @example
761 setenv XAUTHORITY $@{HOME@}/.Xauthority
762 chgrp mygroup $XAUTHORITY
763 chmod 640 $XAUTHORITY
764 @end example
765
766 The @code{XAUTHORITY} file is preserved by both the `preserve' and `set-user'
767 login styles, so this isn't a problem. You can now become other users, and
768 your X permissions will follow you around correctly.
769
770 It's probably worth noting that the @code{xauth} program annoyingly resets
771 the permissions on the cookie file every time it writes to it. This will be
772 particularly irritating if you use @code{ssh}'s X forwarding capabilities,
773 because every @code{ssh} connection will reset the permissions. You can deal
774 with this problem by putting a line
775
776 @example
777 chmod 640 $@{XAUTHORITY-$HOME/.Xauthority@} 2>/dev/null
778 @end example
779
780 @noindent
781 in your @file{.bashrc} or @file{.profile} (for Bourne-like shell users) or
782
783 @example
784 if ($?XAUTHORITY) then
785 chmod 640 $XAUTHORITY >&/dev/null
786 else
787 chmod 640 $@{HOME@}/.Xauthority >&/dev/null
788 endif
789 @end example
790
791 @noindent
792 in @file{.cshrc} for C shell users.
793
794
795 @node Using xauth, , The user-group method, X authority
796 @subsection The @code{xauth} method for handling X authority
797
798 This method sends your X cookie to the shared account. It's therefore
799 intrinsically dangerous: you must be able to trust the other users of the
800 shared account not to take undue advantage of this situation.
801
802 The following (Bourne) shell snippet illustrates how you might send an
803 authorisation cookie to the shared account, to allow it to connect to your
804 display:
805
806 @example
807 if test -n "$BECOME_HOME"; then
808 XAUTHORITY="$BECOME_HOME/.Xauthority"; export XAUTHORITY
809 elif test -n "$DISPLAY" && test -z "done_xauth_cookie"; then
810 case "$DISPLAY" in
811 :0.0) display=`hostname`:0.0 ;;
812 *) display="$DISPLAY" ;;
813 esac
814 xauth extract - $display | \
815 become someone -c 'xauth -f $BECOME_HOME/.Xauthority merge -'
816 done_xauth_cookie=yes; export done_xauth_cookie
817 fi
818 @end example
819
820 The equivalent C shell code is
821
822 @example
823 if ($?BECOME_HOME) then
824 setenv XAUTHORITY "$@{BECOME_HOME@}/.Xauthority
825 else if ($?DISPLAY && ! $?done_xauth_cookie) then
826 if ($DISPLAY == :0.0) then
827 set display="`hostname`:0.0"
828 else
829 set display="$DISPLAY"
830 endif
831 xauth extract - $display | \
832 become someone -c 'xauth -f $BECOME_HOME/.Xauthority merge -'
833 endif
834 @end example
835
836 It works as follows:
837
838 @itemize @bullet
839 @item
840 If the variable @code{BECOME_HOME} is set, then we're probably really someone
841 else, so point to the shared account's authority file.
842
843 @item
844 Otherwise, check to see whether we have a display, and the authorisation has
845 not already been sent. If this is so, resolve a local display name into a
846 remote one (just in case) and then send it to the shared account.
847 @end itemize
848
849
850
851 @node Running commands, , X authority, Becoming someone else
852 @section Executing specific commands
853
854 As well as starting shells, Become can run single commands. This can be
855 useful in two ways:
856
857 @itemize @bullet
858 @item
859 It enables Become to be used in scripts.
860
861 @item
862 It allows access to shared accounts to be controlled on the basis of the
863 command to be run.
864 @end itemize
865
866 To run a command as another user, say:
867
868 @example
869 become @var{user} @var{command} [@var{argument}@dots{}]
870 @end example
871
872 If the request is granted, Become runs @var{command}, passing it any
873 arguments following the command name. Become doesn't run a shell, so there's
874 no extra escaping which needs to be done.
875
876 If you really want to run a shell command as another user, you can use the
877 @code{-c} option:
878
879 @example
880 become @var{user} -c @var{shell-command}
881 @end example
882
883 This is exactly equivalent to
884
885 @example
886 become @var{user} /bin/sh -c @var{shell-command}
887 @end example
888
889 in every way. In particular, you must have permission to run @file{/bin/sh}
890 as @var{user} for it to work: Become doesn't attempt to interpret the shell
891 command in any way. Also note that Become always uses the Bourne shell,
892 regardless of your current shell preference, or @var{user}'s default shell.
893 (This is done to provide a stable programming interface which works
894 irrespective of changes to the shared account's configuration.)
895
896
897 @c --------------------------------------------------------------------------
898 @node Administering Become, Invoking Become, Becoming someone else, Top
899 @chapter Become administration
900
901
902 This chapter will explain how Become is administrated and maintained.
903
904 @menu
905 * Configuration files:: Overview of Become's configuration files
906 * Standalone or networked:: The two main types of Become installations
907 * The configuration file:: How to define who's allowed to do what
908 * Networked configuration:: Considerations for networked installations
909 @end menu
910
911
912
913 @node Configuration files, Standalone or networked, Administering Become, Administering Become
914 @section Configuration files
915
916 Become keeps its configuration and administrative files in a directory
917 usually named @file{/etc/become}, although this can be changed with the
918 @code{--with-etcdir} option to the configuration script when you build
919 Become.
920
921 Not all of the files are needed on all machines.
922
923 @table @file
924 @item become.conf
925 The main configuration file, containing a description of which users are
926 allowed to become which other users, where, and what they're allowed to run
927 when they get there. Only needed on servers or standalone machines.
928
929 @item become.server
930 A list of servers to contact. Only needed on client machines.
931
932 @item become.key
933 The signing key to use when sending requests to servers. Needed on servers,
934 but not on standalone machines.
935
936 @item become.pubkey
937 The verification keys to use when checking server responses. Needed on
938 clients, but not on standalone machines.
939
940 @item become.pid
941 The process id of the server. Created automatically by Become's server when
942 in starts up.
943 @end table
944
945
946 @node Standalone or networked, The configuration file, Configuration files, Administering Become
947 @section Installation types
948
949
950 Become can be installed in two different ways, depending on how you want to
951 administer it:
952
953 @itemize @bullet
954 @item
955 In a @dfn{standalone} installation, each Become request is dealt with
956 locally: the program reads the configuration file, and decides whether it
957 should grant or deny permission.
958
959 Standalone installations don't depend on servers being available, or even on
960 the existence of a network. They're useful for small sites, or sites with a
961 small number of users. The disadvantages are that reading the configuration
962 file takes a while, so the program doesn't feel as responsive as it should,
963 and ensuring that all the hosts' configuration files are synchronised becomes
964 difficult when you have lots of machines.
965
966 @item
967 In a @dfn{network} installation, any Become requests are sent on to a
968 collection of servers. The servers analyse the request and send a reply back
969 which either authorises or forbids access.
970
971 A networked installation clearly depends on the servers' reliability. The
972 client reacts only to the first reply it receives, so as long as there is one
973 server running, everything should continue as normal.
974
975 A networked installation is useful when you have a large number of client
976 machines, particularly ones which may not be awake all the time. The full
977 configuration file only needs to be installed on a small number of servers;
978 the clients require only a list of server machines to contact, and an
979 encryption key to use.
980 @end itemize
981
982
983
984 @node The configuration file, Networked configuration, Standalone or networked, Administering Become
985 @section The configuration file
986
987 The main configuration file, usually called @file{/etc/become/become.conf},
988 contains all the rules which Become uses to decide whether to grant or deny
989 requests. It may also contain additional information for the benefit of
990 Become daemons, if you're using a networked installation.
991
992 @menu
993 * Requests and rules:: How the configuration file works
994 * Basic syntax:: Quick overview of Become's syntax
995 * Classes:: Defining classes of things
996 * Predefined classes:: Become predefines some (maybe) useful classes
997 * Allow statements:: Allow users to become other users
998 * Other statements:: Some other useful statements
999 * Example configuration file:: An example, showing a few features.
1000 * Checking and querying:: Checking and querying configuration files
1001 * Complete grammar:: Complete grammar for Become config files
1002 @end menu
1003
1004
1005 @node Requests and rules, Basic syntax, The configuration file, The configuration file
1006 @subsection Requests and rules
1007
1008 Become looks at four pieces of information when it's analysing a request:
1009
1010 @itemize @bullet
1011 @item
1012 the user's current identity;
1013 @item
1014 the identity the user wishes to assume;
1015 @item
1016 the host which generated the request; and
1017 @item
1018 the command the user wishes to run.
1019 @end itemize
1020
1021 Each of these pieces of information is looked at when Become decides whether
1022 to honour a request.
1023
1024 The configuration file's main purpose is to describe the conditions under
1025 which Become should honour a request. These conditions are described by a
1026 number of @emph{rules}. A rule consists of two lists of users (called `from'
1027 and `to'), a list of hosts, and a list of commands. A rule matches a request
1028 if:
1029
1030 @itemize @bullet
1031 @item
1032 the user's current identity is in the rule's `from' list;
1033 @item
1034 the target user's identity is in the rule's `to' list;
1035 @item
1036 the host is in the rule's host list; and
1037 @item
1038 the command to be run is in the rule's command list.
1039 @end itemize
1040
1041 A request is honoured if there is a rule which matches the request.
1042
1043
1044 @node Basic syntax, Classes, Requests and rules, The configuration file
1045 @subsection Basic configuration file syntax
1046
1047 The configuration file consists of a sequence of statements, each terminated
1048 by a semicolon.
1049
1050 Comments begin with a @samp{#} character, and continue to the end of the
1051 line. This is the only time newlines behave specially: newlines behave just
1052 like any other whitespace characters within statements.
1053
1054 Strings are enclosed in double-quote characters (@samp{"}). Within a string,
1055 a backslash causes the following character to be treated literally, whatever
1056 it may be (including quotes, backslashes and newlines).
1057
1058 Names begin with an alphabetic character or an underscore, and consist of
1059 letters, digits and underscores.
1060
1061
1062 @node Classes, Predefined classes, Basic syntax, The configuration file
1063 @subsection Classes
1064
1065 A @dfn{class} in Become is a set of users, hosts or commands. You can define
1066 and name your own classes using statements of the form:
1067
1068 @example
1069 user @var{name} = @var{class-expr} ;
1070 command @var{name} = @var{class-expr} ;
1071 host @var{name} = @var{class-expr} ;
1072 @end example
1073
1074 A @var{class-expr} is an expression defining a class. You can build a
1075 complex class out of simple classes using the operators (in ascending
1076 precedence order) @samp{,}, @samp{-}, @samp{|} and @samp{&}, which represent
1077 the set options `union', `subtraction', `union' (again!), and `intersection'.
1078 Subexpressions can be parenthesised to override the default precedence.
1079 Once a class name has been defined, as shown above, it can be used in
1080 subsequent class expressions.
1081
1082 A single user may be designated by either a user name (in quotes) or an
1083 integer uid. Commands and hosts may be designated by quoted strings which
1084 may contain wildcards. Host strings are matched against both numeric (dotted
1085 quad) IP addresses and the reverse-resolved hostname. Command strings are
1086 matched against the absolute pathname of the command the user wants to
1087 execute.
1088
1089
1090
1091 @node Predefined classes, Allow statements, Classes, The configuration file
1092 @subsection Predefined classes
1093
1094 In an attempt to make life a bit easier, Become creates a collection of
1095 predefined classes.
1096
1097 The standard classes @code{all} and @code{none} match anything and nothing
1098 respectively. The @code{all} class is useful in some contexts: it gives you
1099 a way of saying `everything except@dots{}', for example:
1100
1101 @example
1102 user MUNDANES = all - SYSHACKS;
1103 @end example
1104
1105 @noindent
1106 The @code{none} class is provided because it's needed internally anyway and
1107 someone might come up with a use for it.
1108
1109 Become also defines some other classes:
1110
1111 @itemize @bullet
1112 @item
1113 For each username @var{user}, Become adds a class called @samp{@var{user}}
1114 which matches just that user.
1115
1116 @item
1117 For each group name @var{group}, Become creates a class called
1118 @samp{@var{group}} which matches any user who is a member of that group.
1119
1120 @item For each netgroup @var{netgroup}, Become creates two classes:
1121 @samp{u_@var{netgroup}} which matches any user listed in the netgroup, and
1122 @samp{h_@var{netgroup}} which matches any host listed in the netgroup.
1123 @end itemize
1124
1125 If a name is used for both a user @emph{and} a group, then corresponding
1126 class ends up containing the user together with all of the group members.
1127 For this reason, it's probably better to use the predefined classes for
1128 groups rather than individual users -- use quoted user names for individual
1129 users.
1130
1131 Note that users and groups are read using the standard @code{get*ent} calls
1132 @emph{and} directly from the NIS server (if there is one). The idea here is
1133 that a Become server can be run on a machine which allows restricted logins.
1134 It still needs to know about all the users known to the outside world.
1135
1136 Netgroups are read only from the NIS servers. In particular, although GNU
1137 systems allow netgroup databases to be stored in local files, Become won't
1138 read them because there's no defined interface for enumerating netgroups.
1139
1140
1141 @node Allow statements, Other statements, Predefined classes, The configuration file
1142 @subsection Allow statements
1143
1144 The @code{allow} statement defines the rules Become uses when deciding
1145 whether to grant a request; see @ref{Requests and rules}.
1146
1147 @example
1148 allow [[@var{host-class}]] [@var{user-class}] -> [@var{user-class}] [ : @var{command-class}]
1149 @end example
1150
1151 (The @var{host-class} is optional, but must be enclosed in square brackets if
1152 present.)
1153
1154 The four classes in an allow statement are called, respectively, the `host',
1155 the `to-user', the `from-user' and the `command'. Any of the four classes
1156 may be omitted, and an omitted class defaults to `all'.
1157
1158 When a request is received, Become checks the fields in the request against
1159 the classes in each allow statement of the configuration file. If a
1160 statement matches, the request is granted; if there are no full matches,
1161 the request is denied.
1162
1163
1164 @node Other statements, Example configuration file, Allow statements, The configuration file
1165 @subsection Other statements
1166
1167 Two other statement types are defined. They only have an effect on Become in
1168 daemon mode:
1169
1170 @example
1171 port @var{port} ;
1172 keyfile @var{key-file} ;
1173 @end example
1174
1175 @noindent
1176 The @code{port} statement specifies the port to which the server should
1177 listen; the @var{port} may be be an integer or a quoted service name. The
1178 @code{keyfile} statement instructs Become to use the key from the file named
1179 @var{key-file}, which must be a quoted string.
1180
1181
1182 @node Example configuration file, Checking and querying, Other statements, The configuration file
1183 @subsection An example configuration file
1184
1185 @example
1186 #
1187 # become.conf
1188 #
1189 # Example configuration file
1190 #
1191
1192 allow wheel -> "root";
1193
1194 user NEWS = "fred", "jim";
1195 allow NEWS -> "news";
1196
1197 user HTTP = "jim", "bob";
1198 allow ["www.somewhere.com"]
1199 HTTP -> "httpd" : "/bin/kill", "/etc/init.d/httpd";
1200 @end example
1201
1202
1203 @node Checking and querying, Complete grammar, Example configuration file, The configuration file
1204 @subsection Checking and querying the configuration file
1205
1206 At a reasonably sized site, Become configuration files can get rather large,
1207 and becomes tricky to work out exactly who's allowed to do what and where.
1208
1209 The @code{bcquery} tool provided allows Become configuration files to be
1210 verified and queried. It can be used to ensure that a file is syntactically
1211 correct before it is deployed, or to enquire about privileges granted.
1212
1213 @menu
1214 * Verifying config files:: Checking a configuration file is correct
1215 * Querying config files:: Asking questions about privileges
1216 * Output formats:: Different ways of formatting output
1217 * Restricting output:: Being selective about what gets output
1218 * bcquery reference:: Complete command line reference
1219 @end menu
1220
1221 @node Verifying config files, Querying config files, Checking and querying, Checking and querying
1222 @subsubsection Verifying configuration files
1223
1224 A common use of @code{bcquery} is to ensure that a configuration file is
1225 actually valid. The command
1226
1227 @example
1228 bcquery [-file @var{file}] -check
1229 @end example
1230
1231 @noindent
1232 verifies that a configuration file conforms to Become's expectations. If
1233 there are any errors in @var{file}, they are reported, and @code{bcquery}
1234 will return a nonzero exit code.
1235
1236 If no @var{file} is specified, @code{bcquery} will read the configuration
1237 file which Become itself reads by default, usually
1238 @code{/etc/become/become.conf}.
1239
1240
1241 @node Querying config files, Output formats, Verifying config files, Checking and querying
1242 @subsubsection Querying configuration files
1243
1244 The @code{bcquery} program will list all rules which match a selected request
1245 pattern. For example, you can display all rules which allow a particular
1246 user to change identity, or all rules which allow people to assume root
1247 privileges on a particular host.
1248
1249 @example
1250 bcquery [-file @var{file}] @var{query}
1251 @end example
1252
1253 The following simple queries are supported:
1254
1255 @table @asis
1256 @item @code{-from} @var{user}
1257 Matches any rule containing @var{user} in its `from' list.
1258 @item @code{-to} @var{user}
1259 Matches any rule containing @var{user} in its `to' list.
1260 @item @code{-host} @var{host}
1261 Matches any rule containing @var{host} in its host list.
1262 @item @code{-command} @var{cmd}
1263 Matches any rule containing @var{cmd} in its `command' list.
1264 @end table
1265
1266 @noindent
1267 Simple queries can be combined using the following operators:
1268
1269 @table @asis
1270 @item @var{query-a} @code{-or} @var{query-b}
1271 Matches a rule matched by either @var{query-a} or @var{query-b}.
1272 @item @var{query-a} @code{-and} @var{query-b}
1273 Matches a rule matched by both @var{query-a} and @var{query-b}.
1274 @item @code{-not} @var{query}
1275 Matches a rule which is not matched by @var{query}.
1276 @item @code{(} @var{query} @code{)}
1277 Matches a rule matched by @var{query} (overrides default precedence).
1278 @end table
1279
1280 The @code{-and}, @code{-or} and @code{-not} operators may be written
1281 @code{&}, @code{|} and @code{!} respectively, if you prefer, and the
1282 @code{-and} operator is optional. These characters (and the parentheses
1283 @code{(} and @code{)}) may need to be quoted to prevent interpretation by the
1284 shell.
1285
1286 Some examples may explain what's going on:
1287
1288 @table @samp
1289 @item bcquery -from hacker
1290 Displays all rules applying to user `hacker'.
1291 @item bcquery -host somehost -to root
1292 Displays rules allowing people to become root on @code{somehost}.
1293 @end table
1294
1295
1296 @node Output formats, Restricting output, Querying config files, Checking and querying
1297 @subsubsection Output formats
1298
1299 The @code{bcquery} program has two distinct output formats: `rows' and
1300 `columns'.
1301
1302 The `columns' format is probably the simpler to understand, and certainly the
1303 easier to read. Each matching record is displayed with the lists of users,
1304 hosts and commands in columns. A query on the example configuration file
1305 (@pxref{Example configuration file}) is shown below:
1306
1307 @example
1308 FROM TO HOST COMMAND
1309
1310 frankie root ALL ALL
1311 selina
1312
1313 fred news ALL ALL
1314 jim
1315
1316 jim httpd www.somewhere.com /bin/kill
1317 bob /etc/init.d/httpd
1318 @end example
1319
1320 @noindent
1321 The `columns' format can only show simple lists. A more complex class
1322 definition will show up as @samp{<complex>} in a `columns' format listing.
1323
1324 The `rows' format is capable of displaying classes in their full generality,
1325 but is harder to parse and read. It displays each list in the form of an
1326 expression, in more or less the same syntax as a class definition
1327 (@pxref{Classes}).
1328
1329 The default behaviour is to use `columns' format where possible, or `rows'
1330 format if some of the lists are too complex to be represented in columns.
1331 You can select a format explicitly using the @code{-columns} or @code{-rows}
1332 options, which is useful if you're trying to parse the output of
1333 @code{bcquery} with a script.
1334
1335
1336 @node Restricting output, bcquery reference, Output formats, Checking and querying
1337 @subsubsection Restricting output
1338
1339 It's also possible to suppress bits of information about each matched rule.
1340 For example, you can show only the `from' list, or just the `to' and `host'
1341 lists. This is done with the @code{-output} option.
1342
1343 Each list is given a letter; the `from' list is called @samp{f}, the `to'
1344 list @samp{t}, the host list @samp{h} and the command list @samp{c}. You can
1345 select which lists are displayed by giving the corresponding letters (the
1346 order isn't important). You can also turn individual lists on or off by
1347 preceding the characters with @samp{+} or @samp{-} characters. If you start
1348 with a @samp{+} or @samp{-}, then the last-set selection (or the initial
1349 default of all-lists-enabled) is modified.
1350
1351 For example, @samp{-output ftc} shows only the `from', `to' and `command'
1352 lists. This could be written @samp{-output -h} too, to turn the hosts list
1353 off.
1354
1355 This option is mainly useful with the `columns' output format (@pxref{Output
1356 formats}) to save scripts having to select columns out themselves.
1357
1358
1359 @node bcquery reference, , Restricting output, Checking and querying
1360 @subsubsection @code{bcquery} options summary
1361
1362 @example
1363 bcquery [@var{option}@dots{}] [@var{query}]
1364 @end example
1365
1366 The @var{option}s available are:
1367
1368 @table @asis
1369 @item @code{-help}
1370 Displays a summary of the available options, and exits.
1371
1372 @item @code{-file} @var{file}
1373 Read @var{file}, rather than the compiled-in default (usually
1374 @file{/etc/become/become.conf}).
1375
1376 @item @code{-dump}
1377 Don't read a configuration file. Instead, display the query tree parsed from
1378 the command line. This is a debugging feature.
1379
1380 @item @code{-check}
1381 Don't attempt to output any rules. Instead, just check the configuration
1382 file for validity.
1383
1384 @item @code{-output} @var{spec}
1385 Selects which columns are to be displayed for each matching rule.
1386 For full details, see @ref{Restricting output}.
1387
1388 @item @code{-columns}
1389 @itemx @code{-rows}
1390 Forces `columns' or `rows' output format. @xref{Output formats}.
1391
1392 @item @code{-nohead}
1393 Suppress the header line at the top of the output in `columns' mode. Makes
1394 the output more amenable to automatic processing (but harder to read).
1395
1396 @item @code{-from} @var{user}
1397 @itemx @code{-to} @var{user}
1398 @itemx @code{-host} @var{hostname}
1399 @itemx @code{-command} @var{cmd}
1400 Simple queries for selecting rules. @xref{Querying config files}.
1401
1402 @item @code{-and}
1403 @itemx @code{-or}
1404 @itemx @code{-not}
1405 Operators for combining queries into something useful. @xref{Querying config
1406 files}.
1407 @end table
1408
1409
1410 @node Complete grammar, , Checking and querying, The configuration file
1411 @subsection Complete grammar for configuration files
1412
1413 @format
1414 @var{file} ::= @var{file} @var{statement}
1415
1416 @var{statement} ::= @var{class-def}
1417 | @var{allow-spec}
1418 | @var{port-spec}
1419 | @var{key-spec}
1420
1421 @var{class-def} ::= @samp{user} @var{name} = @var{class-expr} @samp{;}
1422 | @samp{command} @var{name} = @var{class-expr} @samp{;}
1423 | @samp{host} @var{name} = @var{class-expr} @samp{;}
1424
1425 @var{allow-spec} ::= @samp{allow} @var{opt-host-spec} @var{opt-user-spec}
1426 @samp{->} @var{opt-user-spec} @var{opt-command-spec} @samp{;}
1427
1428 @var{opt-host-spec} ::= @samp{[} @var{class-expr} @samp{]}
1429 | @var{empty}
1430
1431 @var{opt-user-spec} ::= @var{class-expr}
1432 | @var{empty}
1433
1434 @var{opt-command-spec} ::= @samp{:} @var{class-expr}
1435 | @var{empty}
1436
1437 @var{port-spec} ::= @samp{port} @var{integer} @samp{;}
1438 | @samp{port} @var{string} @samp{;}
1439
1440 @var{key-spec} ::= @samp{keyfile} @var{string} @samp{;}
1441
1442 @var{class-expr} ::= @var{class-diff-expr}
1443 | @var{class-expr} @samp{,} @var{class-diff-expr}
1444
1445 @var{class-diff-expr} ::= @var{class-isect-expr}
1446 | @var{class-diff-expr} @samp{-} @var{class-union-expr}
1447
1448 @var{class-union-expr} ::= @var{class-isect-expr}
1449 | @var{class-union-expr} @samp{|} @var{class-isect-expr}
1450
1451 @var{class-isect-expr} ::= @var{class-primary}
1452 | @var{class-isect-expr} @samp{&} @var{class-primary}
1453
1454 @var{class-primary} ::= @samp{(} @var{class-expr} @samp{)}
1455 | @var{string}
1456 | @var{integer}
1457
1458 @var{integer} ::= one or more digits (@samp{0}--@samp{9})
1459
1460 @var{name} ::= an alphabetic character or underscore, followed by zero or
1461 more alphanumeric characters or underscores
1462
1463 @var{string} ::= @samp{"} @var{string-chars} @samp{"}
1464
1465 @var{string-chars} ::= @var{string-chars} @var{string-char}
1466 | @var{empty}
1467
1468 @var{string-char} ::= a @samp{\} followed by any character
1469 | any character other than @samp{"}, @samp{\} or newline
1470
1471 @var{empty} ::=
1472 @end format
1473
1474
1475
1476 @node Networked configuration, , The configuration file, Administering Become
1477 @section Networked configuration
1478
1479 If you're planning to use Become in a standalone way, you can skip this
1480 section.
1481
1482 @menu
1483 * Choosing servers:: Which servers Become tries to talk to
1484 * Setting up keys:: How to generate keys for Become
1485 * Issuing a new key:: How to issue new keys without disruption
1486 @end menu
1487
1488
1489 @node Choosing servers, Setting up keys, Networked configuration, Networked configuration
1490 @subsection Choosing servers
1491
1492 Become notices that it's meant to send requests to a server if it finds a
1493 @file{become.server} file. This file contains entries of the form
1494
1495 @example
1496 @var{host} [: @var{port}]
1497 @end example
1498
1499 If the @var{port} is omitted, Become chooses a port by looking at the
1500 services database for a service which matches the name by which Become was
1501 invoked: normally this will be @samp{become}.
1502
1503 Become sends a request to all of the servers and believes the first valid
1504 reply it receives. Since servers ignore requests they believe to be invalid,
1505 this enables you to change Become's key without disrupting service
1506 (@pxref{Issuing a new key}).
1507
1508 If you're using NIS, you should try to ensure that Become servers runs only
1509 on NIS servers; the NIS master is probably a good choice.
1510
1511 Become isn't particularly processor-intensive, and doesn't seem to require
1512 very much memory.
1513
1514
1515 @node Setting up keys, Issuing a new key, Choosing servers, Networked configuration
1516 @subsection Setting up keys
1517
1518 Communication between Become clients and the server is encrypted to ensure
1519 that it's not feasible to gain unauthorised privilege by subverting the
1520 network. Become uses the DSA algorithm to ensure authenticity of replies.
1521
1522 Each client machine, and the server, must have a copy of the same key. The
1523 key is usually stored in @file{/etc/become/become.key}. Become's keys are
1524 128 bits long.
1525
1526 The key file can be generated using Catacomb's @code{key} program. The
1527 commands
1528
1529 @example
1530 key -k /etc/become/become.key add -adsa -e"now + 1 year" become-dsa
1531 key -k /etc/become/become.key extract -f -secret /etc/become/become.pubkey
1532 @end example
1533
1534 @noindent
1535 will generate a suitable DSA key, and extract the public part. You should
1536 install the public key on all of your client computers, writable only by
1537 root. The private key should be only on the server, and readable or writable
1538 only by root.
1539
1540 If you have multiple servers, they can all have different private keys.
1541 You'll need to put all of the public keys in the
1542 @file{/etc/become/become.pubkey} file.
1543
1544
1545 @node Issuing a new key, , Setting up keys, Networked configuration
1546 @subsection Issuing a new key
1547
1548 When you're sending out a new key, you run a risk of disrupting service. The
1549 server reads a new key; the clients still have the old one.
1550
1551 We used to recommend running two servers. Now, however, you can generate the
1552 new key, install the new public key on the clients in addition to the old
1553 one, and then install the new private key on the server. The clients try all
1554 valid public keys when attempting to authenticate a response, so this
1555 approach will work.
1556
1557
1558 @c --------------------------------------------------------------------------
1559 @node Invoking Become, , Administering Become, Top
1560 @chapter Invoking Become
1561
1562
1563 This chapter provides an exhaustive description of Become's command line
1564 options, organised in a reference-manual sort of way.
1565
1566 @menu
1567 * Becoming another user:: Options for becoming another user
1568 * Starting Become daemons:: Options for starting Become daemons
1569 * Debugging options:: Options to use when Become goes wrong
1570 @end menu
1571
1572
1573
1574 @node Becoming another user, Starting Become daemons, Invoking Become, Invoking Become
1575 @section Becoming another user
1576
1577 @subsection Synopsis
1578
1579 @example
1580 become [@var{option}@dots{}] [@var{env-var}@dots{}] @var{user} [@var{command} [@var{argument}@dots{}]]
1581 @end example
1582
1583 Actually, you can put the @var{option}s, @var{env-var}s and @var{user} in any
1584 order you like; the important thing is that all of them appear before the
1585 command, if any.
1586
1587
1588 @subsection Usage
1589
1590 The @var{option}s appropriate for this mode are as follows:
1591
1592 @table @code
1593 @item -h
1594 @itemx --help
1595 Display a (fairly verbose) help message describing the various command line
1596 options and exits successfully.
1597
1598 @item -u
1599 @itemx --usage
1600 Display a terse summary of the command line options and exits successfully.
1601
1602 @item -v
1603 @itemx
1604 Display's Become's version number and exits successfully.
1605
1606 @item -e
1607 @item --preserve-environment
1608 Selects the `preserve' login style (@pxref{The preserve style}). All
1609 environment variables are preserved. The default command is the current
1610 user's own shell. The default primary group becomes the current primary
1611 group; the default group style is set to `merge'.
1612
1613 @item -s
1614 @itemx --su
1615 @itemx --set-user
1616 Selects the `set-user' login style (@pxref{The set-user style}). Most
1617 environment variables are preserved, but @code{USER}, @code{LOGNAME},
1618 @code{HOME} and other user-specific variables are altered to reflect the
1619 target user's configuration. The default command is the target user's shell.
1620 The default primary group becomes the target user's primary group; the
1621 default group style is set to `merge'.
1622
1623 @item -l
1624 @itemx --login
1625 Selects the `login' login style (@pxref{The login style}). The environment
1626 is cleared and rebuilt, in a similar way to the behaviour of @code{login}.
1627 The default command is the target user's shell. The default primary group
1628 becomes the target user's primary group; the default group style is set to
1629 `replace'.
1630
1631 @item -g @var{group}
1632 @itemx --group=@var{group}
1633 Selects @var{group} as the primary group; it may be either a group name or a
1634 numeric group id. Note that @var{group} must be the primary group or
1635 a subsidiary group of either the current user or the target user.
1636
1637 @item -k
1638 @itemx --keep-groups
1639 Selects the `keep' group style (@pxref{Subsidiary groups}). The current set
1640 of subsidiary group memberships are passed on unchanged.
1641
1642 @item -m
1643 @itemx --merge-groups
1644 Selects the `merge' group style (@pxref{Subsidiary groups}). The current set
1645 of subsidiary group memberships are merged with the subsidiary groups of the
1646 target user.
1647
1648 @item -r
1649 @itemx --replace-groups
1650 Selects the `replace' group style (@pxref{Subsidiary groups}). The target
1651 user's subsidiary group memberships are passed on; the current subsidiary
1652 groups are discarded.
1653
1654 @item -c @var{shell-cmd}
1655 @itemx --command=@var{shell-cmd}
1656 Sets the @var{command} and @var{argument}s to invoke
1657 @code{/bin/sh -c @var{shell-cmd}}; i.e., to execute a Bourne shell command
1658 instead of just @code{exec}ing a program. Note that permissions are checked
1659 for executing the Bourne shell @code{/bin/sh}; the contents of the
1660 @var{shell-cmd} are not inspected.
1661 @end table
1662
1663 The @var{env-var} arguments fine-tune the environment passed to the command.
1664 Each @var{env-var} setting must be one of the following:
1665
1666 @table @code
1667 @item @var{var}=@var{value}
1668 Assign the variable named @var{var} the value @var{value}. Protect the
1669 variable @var{var} from modifications by the login style.
1670
1671 @item @var{var}!
1672 Protect the variable @var{var} from modifications by the login style, but
1673 don't change its value.
1674
1675 @item @var{var}-
1676 Remove the variable @var{var} from the environment; do not pass it on.
1677 @end table
1678
1679 The @var{user} specifies the user as whom the @var{command} should be
1680 executed (i.e., the @dfn{target user}). It may be a user name or a numeric
1681 user id.
1682
1683 The @var{command} specifies a command to execute. If @var{command} does not
1684 contain a path, it is looked for using the current @code{PATH} environment
1685 variable. The resulting pathname is canonified if necessary, to produce an
1686 absolute pathname. Note that symbolic links are @emph{not} resolved -- this
1687 prevents an attack whereby a user could invoke a program, passing it an
1688 unusual @code{argv[0]} which might cause unusual behaviour.
1689
1690 The @var{command} name is used both as the command to execute and passed to
1691 the command as @code{argv[0]}. It is not possible to specify an alternative
1692 value to be passed as @code{argv[0]}. Subsequent arguments, if supplied, are
1693 passed as @code{argv[1]} upwards.
1694
1695 If no @var{command} is given, a shell is invoked; the particulars of the
1696 shell are determined by the login style (see above).
1697
1698 The @var{command} is executed as follows:
1699
1700 @itemize @bullet
1701 @item
1702 The subsidiary groups are chosen as determined by the group style.
1703 @item
1704 The real and effective gids are set.
1705 @item
1706 The real and effective uids are set.
1707 @item
1708 The @var{command} is called using the standard @code{execve} system call.
1709 @end itemize
1710
1711
1712
1713 @node Starting Become daemons, Debugging options, Becoming another user, Invoking Become
1714 @section Starting Become daemons
1715
1716 @subsection Synopsis
1717
1718 @example
1719 become --daemon [@var{option}@dots{}]
1720 @end example
1721
1722
1723 @subsection Usage
1724
1725 The following options are appropriate to this mode:
1726
1727 @table @code
1728 @item -h
1729 @itemx --help
1730 Display a (fairly verbose) help message describing the various command line
1731 options and exits successfully.
1732
1733 @item -u
1734 @itemx --usage
1735 Display a terse summary of the command line options and exits successfully.
1736
1737 @item -v
1738 @itemx
1739 Display's Become's version number and exits successfully.
1740
1741 @item -d
1742 @itemx --daemon
1743 Start a Become server, instead of processing a request. Become will read its
1744 command line options, read in the configuration file (and verify that it's
1745 correct) and then fork into the background to wait for incoming requests.
1746 Become relinquishes all setuid privileges (by setting all uids to the real
1747 uid) when it enters daemon mode. It is therefore only really useful to run a
1748 daemon as the superuser.
1749
1750 @item -p @var{port}
1751 @itemx --port=@var{port}
1752 Listen for requests on @var{port}. This option is overridden by the
1753 @code{port} option in the configuration file.
1754
1755 @item -f @var{file}
1756 @itemx --config-file=@var{file}
1757 Read configuration from @var{file}, instead of the default (set at
1758 compile time, usually @file{/etc/become/become.conf}).
1759 @end table
1760
1761 The syntax of the configuration file is described in @ref{The configuration
1762 file}.
1763
1764
1765 @node Debugging options, , Starting Become daemons, Invoking Become
1766 @section Debugging options
1767
1768 Some options are only useful when trying to find out why Become is
1769 misbehaving. Of course, this never happens, so here are the options which
1770 you won't need to use:
1771
1772 @table @code
1773 @item -T[@var{file}]
1774 @itemx --trace[=@var{file}]
1775 Write trace information to @var{file} (or to standard output, if no
1776 @var{file} is specified). You must be able to create the file and open it
1777 for writing.
1778
1779 @item -L[@var{feature}...]
1780 @itemx --trace-level[=@var{feature}]
1781 Selects which features Become ought to trace. Each feature is allocated a
1782 letter; simply string together the letters for the features you want to
1783 debug. The letters @samp{D} and @samp{A} stand respectively for `default'
1784 and `all' features; you can subtract from them by saying, for example,
1785 @samp{A-xyz} to select all features except @samp{x}, @samp{y} and @samp{z}.
1786 The exact list of features supported at any one time can be listed by giving
1787 the @code{--trace-level} option without an argument.
1788
1789 @item -I @var{user}
1790 @itemx --impersonate=@var{user}
1791 Pretend to be @var{user} instead of yourself when the request is checked.
1792 This option can only be used if it wasn't disabled at compile-time and if
1793 Become is not running setuid. Even so, Become will only inform you of the
1794 outcome; it will not execute any commands.
1795 @end table
1796
1797
1798
1799 @c --------------------------------------------------------------------------
1800
1801 @c --- No index yet ---
1802 @c
1803 @c @node Concept index, , Invoking Become, Top
1804 @c @unnumbered Concept index
1805 @c @printindex cp
1806 @c
1807 @contents
1808
1809 @bye
1810
1811 @c ----- That's all, folks --------------------------------------------------