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