/* * calls the given function for each valid indirect entry. Returns True if * the local host exists on any of the lists, else False */ int forEachMatchingIndirectHost(ARRAY8Ptr clientAddress, ARRAY8Ptr clientPort, CARD16 connectionType, ChooserFunc function, char *closure) { AclEntry *e; int haveLocalhost = False; e = matchAclEntry(clientAddress, connectionType, False); if (e && !(e->flags & a_notAllowed)) { if (e->flags & a_useChooser) { ARRAY8Ptr choice; choice = indirectChoice(clientAddress, clientPort, connectionType); if (!choice || XdmcpARRAY8Equal(getLocalAddress(), choice)) /* If nothing was chosen yet, we want to pop up the chooser. * If we were chosen, we want to pop up the greeter. */ haveLocalhost = True; else /* If something else was chosen, we forward the query to * the chosen host. */ (*function)(connectionType, choice, closure); } else /* Just forward the query to each listed host. */ scanHostlist(e->hosts, e->nhosts, clientAddress, connectionType, function, closure, False, &haveLocalhost); } return haveLocalhost; }
static int indirectAlias ( char *alias, ARRAY8Ptr clientAddress, CARD16 connectionType, ChooserFunc function, char *closure, int depth, int broadcast) { DisplayEntry *d; int haveLocalhost = 0; if (depth == MAX_DEPTH) return 0; for (d = database; d; d = d->next) { if (d->type != DISPLAY_ALIAS || !patternMatch (alias, d->entry.aliasName)) continue; if (scanHostlist (d->hosts, clientAddress, connectionType, function, closure, depth + 1, broadcast)) { haveLocalhost = 1; } } return haveLocalhost; }
int ForEachMatchingIndirectHost ( ARRAY8Ptr clientAddress, CARD16 connectionType, ChooserFunc function, char *closure) { int haveLocalhost = 0; DisplayEntry *d; char *clientName = NULL; for (d = database; d; d = d->next) { switch (d->type) { case DISPLAY_ALIAS: case DISPLAY_LISTEN: continue; case DISPLAY_PATTERN: if (!clientName) clientName = NetworkAddressToHostname (connectionType, clientAddress); if (!patternMatch (clientName, d->entry.displayPattern)) continue; break; case DISPLAY_ADDRESS: if (d->entry.displayAddress.connectionType != connectionType || !XdmcpARRAY8Equal (&d->entry.displayAddress.clientAddress, clientAddress)) { continue; } break; } if (!d->hosts) continue; if (d->notAllowed) break; if (d->chooser) { ARRAY8Ptr choice; choice = IndirectChoice (clientAddress, connectionType); if (!choice || XdmcpARRAY8Equal (getLocalAddress(), choice)) haveLocalhost = 1; else (*function) (connectionType, choice, closure); } else if (scanHostlist (d->hosts, clientAddress, connectionType, function, closure, 0, FALSE)) { haveLocalhost = 1; } break; } free (clientName); return haveLocalhost; }
void forEachChooserHost(ARRAY8Ptr clientAddress, CARD16 connectionType, ChooserFunc function, char *closure) { AclEntry *e; e = matchAclEntry(clientAddress, connectionType, False); if (e && !(e->flags & a_notAllowed) && (e->flags & a_useChooser)) scanHostlist(e->hosts, e->nhosts, clientAddress, connectionType, function, closure, True, 0); }
void ForEachChooserHost ( ARRAY8Ptr clientAddress, CARD16 connectionType, ChooserFunc function, char *closure) { int haveLocalhost = 0; DisplayEntry *d; char *clientName = NULL; for (d = database; d; d = d->next) { switch (d->type) { case DISPLAY_ALIAS: continue; case DISPLAY_PATTERN: if (!clientName) clientName = NetworkAddressToHostname (connectionType, clientAddress); if (!patternMatch (clientName, d->entry.displayPattern)) continue; break; case DISPLAY_ADDRESS: if (d->entry.displayAddress.connectionType != connectionType || !XdmcpARRAY8Equal (&d->entry.displayAddress.clientAddress, clientAddress)) { continue; } break; } if (!d->hosts) continue; if (d->notAllowed) break; if (!d->chooser) break; if (scanHostlist (d->hosts, clientAddress, connectionType, function, closure, 0, TRUE)) { haveLocalhost = 1; } break; } if (clientName) free (clientName); if (haveLocalhost) (*function) (connectionType, getLocalAddress(), closure); }
static void scanHostlist(int fh, int nh, ARRAY8Ptr clientAddress, CARD16 connectionType, ChooserFunc function, char *closure, int broadcast, int *haveLocalhost) { HostEntry *h; AliasEntry *a; int na; for (h = accData->hostList + fh; nh; nh--, h++) { switch (h->type) { case HOST_ALIAS: for (a = accData->aliasList, na = accData->nAliases; na; na--, a++) if (patternMatch(a->name, h->entry.aliasPattern)) /* XXX originally swapped, no wildcards in alias name matching */ scanHostlist(a->hosts, a->nhosts, clientAddress, connectionType, function, closure, broadcast, haveLocalhost); break; case HOST_ADDRESS: if (haveLocalhost && XdmcpARRAY8Equal(getLocalAddress(), &h->entry.displayAddress.hostAddress)) *haveLocalhost = True; else if (function) (*function)(connectionType, &h->entry.displayAddress.hostAddress, closure); break; case HOST_BROADCAST: if (broadcast && function) (*function)(FamilyBroadcast, 0, closure); break; default: break; } } }