int kmain(int argc, char* argv[], uint32_t table) { int exit_num = 0; unsigned *old_instr1 = 0, *old_instr2 = 0; unsigned *old_instr_irq_1 = 0, *old_instr_irq_2 = 0; app_startup(); /* bss is valid after this point */ global_data = table; //install the swi custom handler install_handler((unsigned int*)0x8, (int)swi_handler, old_instr1, old_instr2); //install the irq custom handler install_handler((unsigned int*)0x18, (int)irq_handler, old_instr_irq_1, old_instr_irq_2); //initiate the interrupt and timer 0 init_interrupt(); init_timer0(); //load user program exit_num = load_user(argc, argv); //restore the swi system handler restore_handler((unsigned int*)0x8, old_instr1, old_instr2); //restore the irq system handler restore_handler((unsigned int*)0x18, old_instr_irq_1, old_instr_irq_2); return exit_num; }
void Process(){ int current_process_SEG = process_SEG; int i; for( i = start_process_num; i <= process_num; i++){ current_process_SEG = i*0x0800; init_pcb( i, current_process_SEG); } load_user( 1, 0x0800); __asm__(" pop %cx"); load_user( 2, 0x1000); __asm__(" pop %cx"); load_user( 3, 0x1800); __asm__(" pop %cx"); load_user( 4, 0x2000); __asm__(" pop %cx"); load_user( 5, 0x2800); //wait key __asm__(" pop %cx"); load_user( 6, 0x3000); //father __asm__("pop %cx"); // 4000- sub stack w_is_r = 0; isProcessRun=1; // enter user process mode }
void rt_pvd_udb::load_systemgroup( SystemList *systemgroup) { procom_obj item; pwr_sClass_SystemGroupReg *body; char sname[120]; char *s; body = (pwr_sClass_SystemGroupReg *) calloc( 1, sizeof(pwr_sClass_SystemGroupReg)); item.body = body; gu->get_system_name( systemgroup, sname); if (( s = strrchr( sname, '.'))) strcpy( item.name, s+1); else strcpy( item.name, sname); gu->get_system_data( sname, &body->Attributes, &item.oix, body->Description); item.oix++; if ( next_oix <= item.oix) next_oix = item.oix + 1; item.cid = pwr_cClass_SystemGroupReg; item.fthoix = menu_stack[menu_cnt - 1]; item.bwsoix = m_list[item.fthoix].lchoix; if ( item.bwsoix) m_list[item.bwsoix].fwsoix = item.oix; if ( m_list[item.fthoix].fchoix == 0) m_list[item.fthoix].fchoix = item.oix; m_list[item.fthoix].lchoix = item.oix; item.body_size = sizeof(pwr_sClass_SystemGroupReg); menu_stack[menu_cnt] = item.oix; menu_cnt++; if ( m_list.size() <= item.oix + 1) m_list.resize( item.oix + 1); m_list[item.oix] = item; UserList *user = systemgroup->first_user(); while ( user) { load_user( user, systemgroup); user = user->next_user(); } SystemList *sg = systemgroup->first_system(); while ( sg) { load_systemgroup( sg); sg = sg->next_system(); } menu_cnt--; }
/* * Função que carregaga o conteudo do arquivo usuarios.text e das listas de usuarios para * a memoria. */ int load_users() { struct user_t *ptr; FILE *fp; if ( ( fp = fopen( USER_DATA_FILENAME, "r" ) ) == NULL ) { return -1; } else { ptr = alloc_memory_user(); while ( fread( ptr, sizeof( struct user_t ), 1, fp ) ) { load_user( ptr ); } fclose( fp ); } return 1; }
int SystemList::load(std::ifstream& fp) { int type; int end_found = 0; char dummy[40]; for (;;) { fp >> type; switch (type) { case user_eData_SystemName: fp.get(); fp.getline(name, sizeof(name)); break; case user_eData_SystemLevel: fp >> level; break; case user_eData_SystemAttributes: fp >> attributes; break; case user_eData_SystemId: fp >> id; break; case user_eData_SystemDescription: fp.get(); fp.getline(description, sizeof(description)); break; case user_eData_User: load_user(fp); break; case user_eData_System: load_system(fp); break; case user_eData_End: end_found = 1; break; default: std::cout << "System:open syntax error\n"; fp.getline(dummy, sizeof(dummy)); } if (end_found) break; } return 1; }
int main() { int i, j, k, loc, ch1, ch2; char tch; load_books(); load_user(); for(;;) { printf("\n1 - creeate new account\n2 - login\n3 - exit\nenter ur choice\n"); fflush(stdin); scanf("%d", &ch1); switch(ch1) { case 1: create(); break; case 2: loc = login(); if(loc == -1) break; else { printf("\n1 - issue book\n2 - deposit book\n3 - update information\n4 - exit\nenter ur choice: "); scanf("%d",&ch2); fflush(stdin); for(;;) switch(ch2) { case 1: issue(loc); break; case 2: deposit(loc); break; case 3:update(loc); break; case 4: break; default: printf("error in choice....retry\n"); } } break; case 3: exit(0); default: printf("\nerror in choice....retry\n"); } } write_books(); }
int load_access_of_user(int user_num,struct u_parameters *user,int portnum) { struct user_data tempdata; int loop; time_t now; lock_dos(73); time(&now); unlock_dos(); if (load_user(user_num,&tempdata)) {log_error("* tried to load user in access loader"); return 1;} for(loop=0;loop<10;loop++) { user->privs[loop]=tempdata.privs[loop]; } user->priority=tempdata.priority; if (tempdata.time==0) user->time=tempdata.time; else { if (tempdata.time<=((now-line_status[portnum].time_online)/60)) user->time=(unsigned int)((long int)(now-line_status[portnum].time_online)/60)+1; else user->time=tempdata.time; } user->added_time=tempdata.added_time; for(loop=0;loop<4;loop++) user->staple[loop]=tempdata.staple[loop]; /* NEED TO RECALC time_sec AND time_warning_sec */ calc_time_for_node(portnum); /* NEED TO set handle line to be changed */ line_status[portnum].handlelinechanged = ALL_BITS_SET; sync_status[portnum].handlelinechanged_at_tick = dans_counter; return 0; /* SUCCESSFUL */ }
int main() { string username; string password; string command; string subcommand; string temp_path; char t; load_user(); init(); save(); while (1) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN); cout << "welcome to system" << endl; cout << "please login" << endl; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED); while (1) { username = ""; password = ""; cout << "username:"******"password:"******"username or password error" << endl; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED); } } system("cls"); getline(cin, command); while (1) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE); cout << username; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED); cout << "@filesystem "; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE); if (path.size() == 1) cout << "/"; else { for (auto p : path) { if (p == 0) continue; cout << "/" << catalog[p].info.name; } } SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED); cout << endl << ">"; getline(cin, command); stringstream command_stream(command); command_stream >> subcommand; if (subcommand == "") { } else if (subcommand == "cd") { change_path(command); } else if (subcommand == "ls") { show_folder(command); } else if (subcommand == "create") { create(command); } else if (subcommand == "mkdir") { create_folder(command); } else if (subcommand == "delete") { delete_file(command); } else if (subcommand == "edit") { edit(command); } else if (subcommand == "search") { search_file(command); } else if (subcommand == "open") { open_file(command); } else if (subcommand == "close") { close_file(command); } else if (subcommand == "cp") { copy(command); } else if (subcommand == "mv") { move(command); } else if (subcommand == "bs"){ backstage(); } else if (subcommand == "l"){ l(); } else if (subcommand == "info"){ info(); } else if (subcommand == "format") { char c; cout << "Are you sure you want to format the disk?(y/N)"; c = _getch(); if (c == 'n' || c == 'N' || c == '\r') { cout << c << endl; continue; } else if (c == 'y' || c == 'Y') { remove("disk.txt"); remove("diskdata.txt"); init(); cout << c << "\nformat complete" << endl; } } else if (subcommand == "useradd") { add_user(command); } else if (subcommand == "userdelete") { delete_user(command); } else if (subcommand == "passwd") { change_password(command); } else if (subcommand == "clear") { system("cls"); } else if (subcommand == "exit") { system("cls"); break; } else { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED); cout << "command not found" << endl; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED); } cout << endl; save(); command = ""; subcommand = ""; } } }
void copyover_recover(void) { DESC_DATA *d; FILE *fp; char name[100]; char host[STRING]; char board[100]; char user[100]; int desc; bool fOld; log_string("Copyover: Copyover recovery initiated."); if (!(fp = fopen(COPYOVER_FILE, "r"))) { bbs_bug("Copyover_recover: Could not open to read %s", COPYOVER_FILE); exit(1); } unlink(COPYOVER_FILE); for (;;) { fscanf(fp, "%d %s %s %s %s\n", &desc, board, name, user, host); if (desc == -1) break; if (!write_to_desc(desc, "", 0)) { close(desc); continue; } d = new_desc(); d->descr = desc; if (d->host) free_string(d->host); d->host = str_dup(host); if (d->ident) free_string(d->ident); d->ident = str_dup(user); d->next = desc_list; desc_list = d; d->login = CON_REBOOT_RECOVER; fOld = load_user(d, name); if (!fOld) { write_to_desc( desc, "\n\rSomehow, your user was lost in the reboot, sorry.\n\r", 0); close_socket(d); } else { if (!d->user->pBoard) d->user->pBoard = board_lookup("lobby", FALSE); d->user->next = user_list; user_list = d->user; d->login = CON_LOGIN; USR(d)->logon = current_time; USR(d)->pBoard = board_lookup(board, FALSE); save_user(USR(d)); } } system_info("Reboot recover complete"); log_string("Copyover: Done."); fclose(fp); return; }
static void process_crontab(const char *uname, const char *fname, const char *tabname, struct stat *statbuf, cron_db *new_db, cron_db *old_db) { struct passwd *pw = NULL; int crontab_fd = OK - 1; mode_t eqmode = 0400, badmode = 0; user *u; if (fname == NULL) { /* * SYSCRONTAB: * set fname to something for logging purposes. * Allow it to become readable by group and others, but * not writable. */ fname = "*system*"; eqmode = 0; badmode = 022; } else if ((pw = getpwnam(uname)) == NULL) { /* file doesn't have a user in passwd file. */ log_it(fname, getpid(), "ORPHAN", "no passwd entry"); goto next_crontab; } if ((crontab_fd = open(tabname, O_RDONLY|O_NONBLOCK|O_NOFOLLOW, 0)) < OK) { /* crontab not accessible? */ log_it(fname, getpid(), "CAN'T OPEN", tabname); goto next_crontab; } if (fstat(crontab_fd, statbuf) < OK) { log_it(fname, getpid(), "FSTAT FAILED", tabname); goto next_crontab; } if (!S_ISREG(statbuf->st_mode)) { log_it(fname, getpid(), "NOT REGULAR", tabname); goto next_crontab; } if ((eqmode && (statbuf->st_mode & 07577) != eqmode) || (badmode && (statbuf->st_mode & badmode) != 0)) { log_it(fname, getpid(), "BAD FILE MODE", tabname); goto next_crontab; } if (statbuf->st_uid != ROOT_UID && (pw == NULL || statbuf->st_uid != pw->pw_uid || strcmp(uname, pw->pw_name) != 0)) { log_it(fname, getpid(), "WRONG FILE OWNER", tabname); goto next_crontab; } if (statbuf->st_nlink != 1) { log_it(fname, getpid(), "BAD LINK COUNT", tabname); goto next_crontab; } Debug(DLOAD, ("\t%s:", fname)); u = find_user(old_db, fname); if (u != NULL) { /* if crontab has not changed since we last read it * in, then we can just use our existing entry. */ if (u->mtime == statbuf->st_mtime) { Debug(DLOAD, (" [no change, using old data]")); unlink_user(old_db, u); link_user(new_db, u); goto next_crontab; } /* before we fall through to the code that will reload * the user, let's deallocate and unlink the user in * the old database. This is more a point of memory * efficiency than anything else, since all leftover * users will be deleted from the old database when * we finish with the crontab... */ Debug(DLOAD, (" [delete old data]")); unlink_user(old_db, u); free_user(u); log_it(fname, getpid(), "RELOAD", tabname); } u = load_user(crontab_fd, pw, fname); if (u != NULL) { u->mtime = statbuf->st_mtime; link_user(new_db, u); } next_crontab: if (crontab_fd >= OK) { Debug(DLOAD, (" [done]\n")); (void)close(crontab_fd); } }
void auth (int fd){ char *id, *type, *username, *password, *stored_password, *resource, *digest; char buf[BUFFER]; id = xmlget(client[fd].buffer, "iq..id"); type = xmlget(client[fd].buffer, "iq..type"); username = xmlget(client[fd].buffer, "iq.query.username.."); password = xmlget(client[fd].buffer, "iq.query.password.."); resource = xmlget(client[fd].buffer, "iq.query.resource.."); digest = xmlget(client[fd].buffer, "iq.query.digest.."); printf("username >%s< password >%s< digest >%s< resource >%s< \n", username, password, digest, resource); /* if user is already logged in, refuse new connection */ /* else if user doesn't exist, send back an unathorized message */ /* load user data*/ /* else if password doesn't match send back an unauthorized message */ /* else log user in */ if (isloggedin(username)){ /* user is already logged in */ sprintf(buf,"<iq id='%d' type='error'><query xmlns='jabber:iq:auth'><username>%s</username><resource>%s</resource><digest/><error code='401'>Unauthorized</error></iq>\n", id, username, resource); write(fd, buf, strlen(buf)); free (username); free (resource); } else { /* load user data */ client[fd].data=load_user(username); if (!strcmp(client[fd].data, "")){ /* user does not exist */ sprintf(buf,"<iq id='%d' type='error'><query xmlns='jabber:iq:auth'><username>%s</username><resource>%s</resource><digest/><error code='401'>Unauthorized</error></iq>\n", id, username, resource); write(fd, buf, strlen(buf)); free (username); free (resource); free(client[fd].data); client[fd].data=NULL; } else { stored_password=xmlget(client[fd].data, "xml.auth.password.."); if (!strcmp(password, stored_password)) { /* password good */ client[fd].state = CHAT; client[fd].name = username; client[fd].resource = resource; /* return accept to client */ sprintf(buf,"<iq id='%s' type='result'/>", id); write(fd, buf, strlen(buf)); } else { /* password failed */ sprintf(buf,"<iq id='%d' type='error'><query xmlns='jabber:iq:auth'><username>%s</username><resource>%s</resource><digest/><error code='401'>Unauthorized</error></iq>\n", id, username, resource); write(fd, buf, strlen(buf)); free (username); free (resource); free(client[fd].data); client[fd].data=NULL; } free(stored_password); } } free (id); free (type); free (password); free (digest); /* <<< <iq id='3' type='set'><query xmlns='jabber:iq:auth'><username>jabber</username><resource>Gabber</resource><digest>f4d6efcadbf398e1bf78f0fec9d07feac09c3e0b</digest></query></iq> >>> <iq id='3' type='error'><query xmlns='jabber:iq:auth'><username>jabber</username><resource>Gabber</resource><digest sid='3A62E006'>f4d6efcadbf398e1bf78f0fec9d07feac09c3e0b</digest></query><error code='401'>Unauthorized</error></iq> >>> <iq id='3' type='result'/> */ }
void register_x (int fd) { char buf[BUFFER]; char *id, *type, *username, *password, *stored_password, *resource, *digest; id = xmlget(client[fd].buffer, "iq..id"); type = xmlget(client[fd].buffer, "iq..type"); username = xmlget(client[fd].buffer, "iq.query.username.."); password = xmlget(client[fd].buffer, "iq.query.password.."); resource = xmlget(client[fd].buffer, "iq.query.resource.."); digest = xmlget(client[fd].buffer, "iq.query.digest.."); printf("username >%s< password >%s< digest >%s< resource >%s< \n", username, password, digest, resource); /* if the user already exists, error, unathorized */ /* else create user, save user, return error code */ /* load user data */ client[fd].data=load_user(username); if (!strcmp(client[fd].data,"")) { /* user doesn't exist */ /* setup the userdata */ /* save user */ save_user(username, client[fd].data); /* send back a success message */ sprintf(buf,"<iq id='%s' type='result'/>", id); write(fd, buf, strlen(buf)); } else { /* user exists */ /* send back an error */ sprintf(buf,"<iq id='%d' type='error'><query xmlns='jabber:iq:auth'><username>%s</username><resource>%s</resource><digest/><error code='401'>Unauthorized</error></iq>\n", id, username, resource); write(fd, buf, strlen(buf)); } /* free everything, don't store any data until we get a good authentication */ free (client[fd].data); free (id); free (type); free (password); free (username); free (digest); /* <<< <iq id='2' type='set'><query xmlns='jabber:iq:register'><username>jabber</username><resource>Gabber</resource><password>1234</password></query></iq> >>> <iq id='2' type='error'><query xmlns='jabber:iq:register'><username>jabber</username><resource>Gabber</resource><digest sid='3A62E006'>f4d6efcadbf398e1bf78f0fec9d07feac09c3e0b</digest></query><error code='401'>Unauthorized</error></iq> >>> <iq id='2' type='result'/> */ }