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