int evtLogon(struct pgEvent *evt){ picosmUI *interface = (picosmUI *)evt->extra; char *login, *loginT, *passwd, *passwdT, *passwdSys, *salt = NULL, *rcPath; char *args[3]; struct passwd *userData; struct spwd *sUserData; loginT = pgGetString(pgGetWidget(interface->wLogin,PG_WP_TEXT)); login = (char *)malloc(strlen(loginT)); strcpy(login, loginT); passwdT = pgGetString(pgGetWidget(interface->wPasswd,PG_WP_TEXT)); passwd = (char *)malloc(strlen(passwdT)); strcpy(passwd, passwdT); if((userData = getpwnam(login)) != NULL){ if((sUserData = getspnam(login)) != NULL){ passwdSys = sUserData->sp_pwdp; }else{ passwdSys = userData->pw_passwd; } if(passwdSys[0] == '$'){ salt = (char *)malloc(13); strncpy(salt, passwdSys, 12); }else{ salt = (char *)malloc(3); strncpy(salt, passwdSys, 2); } if(!strcmp(passwdSys, (char *)crypt(passwd, salt))){ if(!fork()){ setuid(userData->pw_uid); rcPath = (char *)malloc(strlen(userData->pw_dir)+ strlen("/.picoguirc")); sprintf(rcPath, "%s/.picoguirc", userData->pw_dir); printf("%s\n", rcPath); args[0] = "/bin/sh"; args[1] = rcPath; args[2] = NULL; execve("/bin/sh", args, NULL); }else{ exit(0); } } } pgMessageDialog("Error", "Login failed!", 0); evtClear(evt); if(salt) free(salt); free(login); free(passwd); return 1; }
void clear_eis (EIS * n) { int i; for (i = 0; i < n->num_events; i++) { evtClear (&(n->events[i])); } if (n->num_events) utlFAN (n->events); memset (n, 0, sizeof (EIS)); }
int parse_eis (uint8_t * eis, EIS * p) { uint16_t section_length; uint16_t svid; uint16_t onid; uint16_t tsid; uint32_t crc; uint8_t version_number; uint8_t current_next; uint8_t section_number; uint8_t last_section_number; uint8_t segment_last_section_number; uint8_t last_table_id; SizeStack s; uint8_t *ptr; int i, j, k; if (sizeStackInit (&s, eis) || sizeStackPush (&s, MAX_SEC_SIZE)) //maximum section size return 1; if (sizeStackAdvance (&s, 1, 2)) return 1; ptr = sizeStackPtr (&s); section_length = bitsGet (ptr, 0, 4, 12); if (sizeStackAdvance (&s, 2, 1)) return 1; if (sizeStackPush (&s, section_length)) return 1; if (sizeStackAdvance (&s, 0, 11)) return 1; ptr = sizeStackPtr (&s); svid = bitsGet (ptr, 0, 0, 16); version_number = bitsGet (ptr, 2, 2, 5); current_next = bitsGet (ptr, 2, 7, 1); section_number = ptr[3]; last_section_number = ptr[4]; tsid = bitsGet (ptr, 5, 0, 16); onid = bitsGet (ptr, 7, 0, 16); segment_last_section_number = ptr[9]; last_table_id = ptr[10]; debugPri (1, "EIS: svid: %u, tsid: %u, onid: %u, slast: %u lastid: %u ver: %u, cur/nxt: %u, secnr: %u, lastnr: %u\n", svid, tsid, onid, segment_last_section_number, last_table_id, version_number, current_next, section_number, last_section_number); if (sizeStackAdvance (&s, 11, 0)) return 1; ptr = sizeStackPtr (&s); section_length -= 11 + 4; //header+crc //count number of event blocks p->num_events = 0; i = section_length; j = 0; k = 0; while (i > 0) { j += 10; k = bitsGet (ptr, j, 4, 12) + 2; //descriptor_loop_length j += k; i -= 10; i -= k; p->num_events++; } if (!p->num_events) { debugPri (1, "num_events=0\n"); p->events = NULL; return 1; } p->events = utlCalloc (p->num_events, sizeof (EVT)); if (!p->events) return 1; i = 0; while (p->num_events > i) { if (get_event (&s, &(p->events[i]))) { while (i--) { evtClear (&(p->events[i])); } utlFAN (p->events); return 1; } i++; } sizeStackPop (&s); if (sizeStackAdvance (&s, 0, 4)) { while (i--) { evtClear (&(p->events[i])); } utlFAN (p->events); debugPri (1, "bound error\n"); return 1; } ptr = sizeStackPtr (&s); crc = bitsGet (ptr, 0, 0, 32); debugPri (1, "CRC: 0x%X\n", crc); sizeStackPop (&s); p->svc_id = svid; p->onid = onid; p->tsid = tsid; p->segment_last_section_number = segment_last_section_number; p->last_table_id = last_table_id; p->type = eis[0]; p->c.version = version_number; p->c.current = current_next; p->c.section = section_number; p->c.last_section = last_section_number; return 0; }