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.5 2001/12/14 20:00:48 dawes Exp $ */
40
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 char *defsource = "(stdin)";
58
static void usage (void)
60
static char *prefixmsg[] = {
62
"where options include:",
63
" -f authfilename name of authority file to use",
64
" -v turn on extra messages",
65
" -q turn off extra messages",
66
" -i ignore locks on authority file",
67
" -b break locks on authority file",
69
"and commands have the following syntax:",
72
static char *suffixmsg[] = {
73
"A dash may be used with the \"merge\" and \"source\" to read from the",
74
"standard input. Commands beginning with \"n\" use numeric format.",
79
fprintf (stderr, "usage: %s [-options ...] [command arg ...]\n",
81
for (msg = prefixmsg; *msg; msg++) {
82
fprintf (stderr, "%s\n", *msg);
84
print_help (stderr, " "); /* match prefix indentation */
85
fprintf (stderr, "\n");
86
for (msg = suffixmsg; *msg; msg++) {
87
fprintf (stderr, "%s\n", *msg);
94
* The main routine - parses command line and calls action procedures
97
main (int argc, char *argv[])
100
char *sourcename = defsource;
101
char **arglist = defcmds;
102
int nargs = ndefcmds;
105
ProgramName = argv[0];
107
for (i = 1; i < argc; i++) {
113
for (flag = (arg + 1); *flag; flag++) {
115
case 'f': /* -f authfilename */
116
if (++i >= argc) usage ();
117
authfilename = argv[i];
136
sourcename = "(argv)";
139
if (verbose == -1) verbose = 0;
144
if (verbose == -1) { /* set default, don't junk stdout */
145
verbose = (isatty(fileno(stdout)) != 0);
149
authfilename = IceAuthFileName (); /* static name, do not free */
152
"%s: unable to generate an authority file name\n",
157
if (auth_initialize (authfilename) != 0) {
158
/* error message printed in auth_initialize */
162
status = process_command (sourcename, 1, nargs, arglist);
164
(void) auth_finalize ();
165
exit ((status != 0) ? 1 : 0);