int dump_numeric(register FILE *fp, register Xauth *auth) { fprintf (fp, "%04x", auth->family); /* unsigned short */ fprintf (fp, " %04x ", auth->address_length); /* short */ fprintfhex (fp, auth->address_length, auth->address); fprintf (fp, " %04x ", auth->number_length); /* short */ fprintfhex (fp, auth->number_length, auth->number); fprintf (fp, " %04x ", auth->name_length); /* short */ fprintfhex (fp, auth->name_length, auth->name); fprintf (fp, " %04x ", auth->data_length); /* short */ fprintfhex (fp, auth->data_length, auth->data); putc ('\n', fp); return 1; }
/* ARGSUSED */ static int dump_entry(const char *inputfilename, int lineno, Xauth *auth, char *data) { struct _list_data *ld = (struct _list_data *) data; FILE *fp = ld->fp; if (ld->numeric) { dump_numeric (fp, auth); } else { const char *dpyname = NULL; switch (auth->family) { case FamilyLocal: fwrite (auth->address, sizeof (char), auth->address_length, fp); fprintf (fp, "/unix"); break; case FamilyInternet: #if defined(IPv6) && defined(AF_INET6) case FamilyInternet6: #endif case FamilyDECnet: dpyname = get_hostname (auth); if (dpyname) { fprintf (fp, "%s", dpyname); break; } /* else fall through to default */ default: fprintf (fp, "#%04x#", auth->family); fprintfhex (fp, auth->address_length, auth->address); putc ('#', fp); } putc (':', fp); fwrite (auth->number, sizeof (char), auth->number_length, fp); putc (' ', fp); putc (' ', fp); fwrite (auth->name, sizeof (char), auth->name_length, fp); putc (' ', fp); putc (' ', fp); if (!strncmp(auth->name, SECURERPC, auth->name_length) || !strncmp(auth->name, K5AUTH, auth->name_length)) fwrite (auth->data, sizeof (char), auth->data_length, fp); else fprintfhex (fp, auth->data_length, auth->data); putc ('\n', fp); } return 0; }
static void ice_auth_add (FILE *setup_fp, FILE *cleanup_fp, char *protocol, IceListenObj ice_listener) { IceAuthDataEntry entry; entry.protocol_name = protocol; entry.network_id = IceGetListenConnectionString (ice_listener); entry.auth_name = "MIT-MAGIC-COOKIE-1"; entry.auth_data = IceGenerateMagicCookie (16); entry.auth_data_length = 16; IceSetPaAuthData (1, &entry); fprintf (setup_fp, "add %s \"\" %s MIT-MAGIC-COOKIE-1 ", protocol, entry.network_id); fprintfhex (setup_fp, 16, entry.auth_data); fprintf (setup_fp, "\n"); fprintf (cleanup_fp, "remove protoname=%s protodata=\"\" netid=%s authname=MIT-MAGIC-COOKIE-1\n", protocol, entry.network_id); free (entry.network_id); free (entry.auth_data); }
/* * We use temporary files which contain commands to add/remove entries from * the .ICEauthority file. */ static void write_iceauth (FILE *addfp, FILE *removefp, IceAuthDataEntry *entry) { fprintf (addfp, "add %s \"\" %s %s ", entry->protocol_name, entry->network_id, entry->auth_name); fprintfhex (addfp, entry->auth_data_length, entry->auth_data); fprintf (addfp, "\n"); fprintf (removefp, "remove protoname=%s protodata=\"\" netid=%s authname=%s\n", entry->protocol_name, entry->network_id, entry->auth_name); }