int main() { int *pp, *t; t = aliasing(&pp); if (t != (void *) 0) { free(t); } else { exit(0); } return 1; }
void copy_user_highpage(struct page *to, struct page *from, unsigned long vaddr, struct vm_area_struct *vma) { unsigned long vto, vfrom, flags, kto, kfrom, pfrom, pto; kto = ((unsigned long)page_address(to) & PAGE_MASK); kfrom = ((unsigned long)page_address(from) & PAGE_MASK); pto = page_to_phys(to); pfrom = page_to_phys(from); if (aliasing(vaddr, (unsigned long)kfrom)) cpu_dcache_wb_page((unsigned long)kfrom); if (aliasing(vaddr, (unsigned long)kto)) cpu_dcache_inval_page((unsigned long)kto); local_irq_save(flags); vto = kremap0(vaddr, pto); vfrom = kremap1(vaddr, pfrom); copy_page((void *)vto, (void *)vfrom); kunmap01(vfrom); kunmap01(vto); local_irq_restore(flags); }
int CommandAddressResolve(void *param) { BOOL handled=FALSE; int cnt=0; unsigned char buffer[1024]; /* FIXME: is this too big? */ QueueClient *client = (QueueClient *)param; handled = aliasing(client->buffer + 16, &cnt, buffer); if (!handled) { ConnWriteF(client->conn, MSG4001NO_USER"\r\n", client->buffer + 16); } else { ConnWriteF(client->conn, "%s\r\n", buffer); } return 0; }
void clear_user_highpage(struct page *page, unsigned long vaddr) { unsigned long vto, flags, kto; kto = ((unsigned long)page_address(page) & PAGE_MASK); local_irq_save(flags); if (aliasing(kto, vaddr) && kto != 0) { cpu_dcache_inval_page(kto); cpu_icache_inval_page(kto); } vto = kremap0(vaddr, page_to_phys(page)); clear_page((void *)vto); kunmap01(vto); local_irq_restore(flags); }
/* mapping types * 0: username == local * 1: username == local@domain * 2: username == domain * 3: username == auth subsystem */ BOOL aliasing(char *addr, int *cnt, unsigned char *buffer) { unsigned char *local = NULL; unsigned char *domain = NULL; int i=-1; BOOL result=FALSE; if (addr[0] == '\0') { sprintf(buffer, MSG4001NO_USER, ""); return TRUE; } /* very rudimentary way to prevent loops */ if (*cnt > 5) { strcpy(buffer, MSG4000LOOP); return TRUE; } (*cnt)++; /* first parse out the address so that i can loop over the domains */ MsgParseAddress(addr, strlen(addr), &local, &domain); if (local && !domain) { /* if i get here, then i don't have a domain. assume this is the username. the only possible * choices here are type 0 and type 3 */ if (MsgAuthFindUser(local) == 0) { sprintf(buffer, MSG1000LOCAL, local); result = TRUE; goto ExitAliasing; } else { /* the user was not found. it must be an invalid user */ sprintf(buffer, MSG4001NO_USER, local); result = TRUE; goto ExitAliasing; } } /* if i get here, i've got a domain name that i can look up in the alias system */ i = GArrayFindSorted(Conf.aliasList, domain, sizeof(struct _AliasStruct), (ArrayCompareFunc)aliasFindFunc); if (i > -1) { char new_addr[1000]; /* FIXME: seems a bit large */ AliasStruct a; new_addr[0] = '\0'; a = g_array_index(Conf.aliasList, AliasStruct, i); /* user aliases should take precedence over domain aliases. check for one of those first */ if (a.aliases && a.aliases->len && ((i = GArrayFindSorted(a.aliases, local, sizeof(struct _AliasStruct), (ArrayCompareFunc)aliasFindFunc)) > -1)) { AliasStruct b; b = g_array_index(a.aliases, AliasStruct, i); result = aliasing(b.to, cnt, buffer); } else if (a.to && a.to[0] != '\0') { /* there are no user aliasess is there a domain alias? */ snprintf(new_addr, 999, "%s@%s", local, a.to); result = aliasing(new_addr, cnt, buffer); } /* we haven't already handled the address. it must be a local address */ if (result == FALSE) { /* based off the mapping_type of the current domain (a), i need to resolve username now */ switch (a.mapping_type) { case 0: if (MsgAuthFindUser(local) == 0) { sprintf(buffer, MSG1000LOCAL, local); result = TRUE; } break; case 1: if (MsgAuthFindUser(addr) == 0) { sprintf(buffer, MSG1000LOCAL, addr); result = TRUE; } break; case 2: if (MsgAuthFindUser(domain) == 0) { sprintf(buffer, MSG1000LOCAL, domain); result = TRUE; } break; case 3: /* unhandled for now */ strcpy(buffer, MSG4000UNKNOWN_TYPE); result = TRUE; break; default: /* unhandled forever */ strcpy(buffer, MSG4000UNKNOWN_TYPE); result = TRUE; break; } } /* if we still haven't resolved the address, it is an unknown user */ if (result == FALSE) { sprintf(buffer, MSG4001NO_USER, addr); result = TRUE; } } else { /* the user must be remote */ sprintf(buffer, MSG1002REMOTE, addr); result = TRUE; goto ExitAliasing; } ExitAliasing: if (local) { MemFree(local); } if (domain) { MemFree(domain); } return result; }