2
* $Xorg: xauth.c,v 1.4 2001/02/09 02:05:38 xorgcvs Exp $
4
* xauth - manipulate authorization file
7
Copyright 1989,1998 The Open Group
9
Permission to use, copy, modify, distribute, and sell this software and its
10
documentation for any purpose is hereby granted without fee, provided that
11
the above copyright notice appear in all copies and that both that
12
copyright notice and this permission notice appear in supporting
15
The above copyright notice and this permission notice shall be included in
16
all copies or substantial portions of the Software.
18
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
Except as contained in this notice, the name of The Open Group shall not be
26
used in advertising or otherwise to promote the sale, use or other dealings
27
in this Software without prior written authorization from The Open Group.
29
* Author: Jim Fulton, MIT X Consortium
31
/* $XFree86: xc/programs/xauth/xauth.c,v 1.5tsi Exp $ */
43
char *ProgramName; /* argv[0], set at top of main() */
44
int verbose = -1; /* print certain messages */
45
Bool ignore_locks = False; /* for error recovery */
46
Bool break_locks = False; /* for error recovery */
47
Bool no_name_lookups = False; /* show addresses instead of names */
53
static char *authfilename = NULL; /* filename of cookie file */
54
static char *defcmds[] = { "source", "-", NULL }; /* default command */
55
static int ndefcmds = 2;
56
static char *defsource = "(stdin)";
64
static char *prefixmsg[] = {
66
"where options include:",
67
" -f authfilename name of authority file to use",
68
" -v turn on extra messages",
69
" -q turn off extra messages",
70
" -i ignore locks on authority file",
71
" -b break locks on authority file",
73
"and commands have the following syntax:",
76
static char *suffixmsg[] = {
77
"A dash may be used with the \"merge\" and \"source\" to read from the",
78
"standard input. Commands beginning with \"n\" use numeric format.",
83
fprintf (stderr, "usage: %s [-options ...] [command arg ...]\n",
85
for (msg = prefixmsg; *msg; msg++) {
86
fprintf (stderr, "%s\n", *msg);
88
print_help (stderr, NULL, " "); /* match prefix indentation */
89
fprintf (stderr, "\n");
90
for (msg = suffixmsg; *msg; msg++) {
91
fprintf (stderr, "%s\n", *msg);
98
* The main routine - parses command line and calls action procedures
101
main(int argc, char *argv[])
104
char *sourcename = defsource;
105
char **arglist = defcmds;
106
int nargs = ndefcmds;
109
ProgramName = argv[0];
111
for (i = 1; i < argc; i++) {
117
for (flag = (arg + 1); *flag; flag++) {
119
case 'f': /* -f authfilename */
120
if (++i >= argc) usage ();
121
authfilename = argv[i];
136
no_name_lookups = True;
143
sourcename = "(argv)";
146
if (verbose == -1) verbose = 0;
151
if (verbose == -1) { /* set default, don't junk stdout */
152
verbose = (isatty(fileno(stdout)) != 0);
156
authfilename = XauFileName (); /* static name, do not free */
159
"%s: unable to generate an authority file name\n",
164
if (auth_initialize (authfilename) != 0) {
165
/* error message printed in auth_initialize */
169
status = process_command (sourcename, 1, nargs, arglist);
171
(void) auth_finalize ();
172
exit ((status != 0) ? 1 : 0);