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