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