2
* $Xorg: iceauth.c,v 1.4 2001/02/09 02:05:31 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
* Original Author of "xauth" : Jim Fulton, MIT X Consortium
30
* Modified into "iceauth" : Ralph Mor, X Consortium
32
/* $XFree86: xc/programs/iceauth/iceauth.c,v 1.4 2001/01/17 23:44:54 dawes Exp $ */
40
const char *ProgramName; /* argv[0], set at top of main() */
41
int verbose = -1; /* print certain messages */
42
Bool ignore_locks = False; /* for error recovery */
43
Bool break_locks = False; /* for error recovery */
49
static char *authfilename = NULL; /* filename of cookie file */
50
static char *defcmds[] = { "source", "-", NULL }; /* default command */
51
static int ndefcmds = 2;
52
static const char *defsource = "(stdin)";
58
static void usage (void)
60
static const char prefixmsg[] =
62
"where options include:\n"
63
" -f authfilename name of authority file to use\n"
64
" -v turn on extra messages\n"
65
" -q turn off extra messages\n"
66
" -i ignore locks on authority file\n"
67
" -b break locks on authority file\n"
69
"and commands have the following syntax:\n";
70
static const char suffixmsg[] =
71
"A dash may be used with the \"merge\" and \"source\" to read from the\n"
72
"standard input. Commands beginning with \"n\" use numeric format.\n";
74
fprintf (stderr, "usage: %s [-options ...] [command arg ...]\n",
76
fprintf (stderr, "%s\n", prefixmsg);
77
print_help (stderr, " "); /* match prefix indentation */
78
fprintf (stderr, "\n%s\n", suffixmsg);
84
* The main routine - parses command line and calls action procedures
87
main (int argc, char *argv[])
90
const char *sourcename = defsource;
91
char **arglist = defcmds;
95
ProgramName = argv[0];
97
for (i = 1; i < argc; i++) {
103
for (flag = (arg + 1); *flag; flag++) {
105
case 'f': /* -f authfilename */
106
if (++i >= argc) usage ();
107
authfilename = argv[i];
126
sourcename = "(argv)";
129
if (verbose == -1) verbose = 0;
134
if (verbose == -1) { /* set default, don't junk stdout */
135
verbose = (isatty(fileno(stdout)) != 0);
139
authfilename = IceAuthFileName (); /* static name, do not free */
142
"%s: unable to generate an authority file name\n",
147
if (auth_initialize (authfilename) != 0) {
148
/* error message printed in auth_initialize */
152
status = process_command (sourcename, 1, nargs, arglist);
154
(void) auth_finalize ();
155
exit ((status != 0) ? 1 : 0);