Ticket #1331: pr1331-cpukit.diff
File pr1331-cpukit.diff, 7.7 KB (added by Joel Sherrill, on 10/15/08 at 16:34:35) |
---|
-
libmisc/shell/shell.c
? telnetd/.telnetd.c.swp ? telnetd/a.out RCS file: /usr1/CVS/rtems/cpukit/libmisc/shell/shell.c,v retrieving revision 1.37 diff -u -r1.37 shell.c
460 460 461 461 if (stat("/etc/issue",&buf)) { 462 462 rtems_shell_write_file("/etc/issue", 463 "\n" 463 464 "Welcome to @V\\n" 464 465 "Login into @S\\n"); 465 466 } 466 467 467 468 if (stat("/etc/issue.net",&buf)) { 468 469 rtems_shell_write_file("/etc/issue.net", 470 "\n" 469 471 "Welcome to %v\n" 470 472 "running on %m\n"); 471 473 } -
telnetd/check_passwd.c
RCS file: /usr1/CVS/rtems/cpukit/telnetd/check_passwd.c,v retrieving revision 1.1 diff -u -r1.1 check_passwd.c
78 78 #endif 79 79 int check_passwd(char *peername) 80 80 { 81 char *pw;82 intrval = -1, tmp, retries;83 struct termios t,told;84 intrestore_flags = 0;85 char buf[30], cryptbuf[21];86 char salt[3];81 char *pw; 82 int rval = -1, tmp, retries; 83 struct termios t,told; 84 int restore_flags = 0; 85 char buf[30], cryptbuf[21]; 86 char salt[3]; 87 87 88 88 if ( !(pw=getenv("TELNETD_PASSWD")) || 0 == strlen(pw) ) 89 89 #ifdef TELNETD_DEFAULT_PASSWD -
telnetd/telnetd.c
RCS file: /usr1/CVS/rtems/cpukit/telnetd/telnetd.c,v retrieving revision 1.12 diff -u -r1.12 telnetd.c
85 85 ); 86 86 87 87 /***********************************************************/ 88 rtems_id telnetd_task_id =0;89 uint32_t telnetd_stack_size =32000;90 rtems_task_priority telnetd_task_priority =0;91 int telnetd_dont_spawn =0;92 void (*telnetd_shell)(char *, void*) =0;93 void *telnetd_shell_arg =0;88 rtems_id telnetd_task_id = 0; 89 uint32_t telnetd_stack_size = 32000; 90 rtems_task_priority telnetd_task_priority = 0; 91 bool telnetd_remain_on_caller_stdio = false; 92 void (*telnetd_shell)(char *, void*) = 0; 93 void *telnetd_shell_arg = NULL; 94 94 void * (*telnetd_spawn_task)( 95 const char *, unsigned, unsigned, void (*)(void*), void *) = telnetd_dflt_spawn; 96 97 static char *grab_a_Connection(int des_socket, uni_sa *srv, char *peername, int sz) 95 const char *, 96 unsigned, 97 unsigned, 98 void (*)(void*), 99 void *) = telnetd_dflt_spawn; 100 101 static char *grab_a_Connection( 102 int des_socket, 103 uni_sa *srv, 104 char *peername, 105 int sz 106 ) 98 107 { 99 108 char *rval = 0; 100 109 #if 0 … … 190 199 char peername[16]; 191 200 int i=1; 192 201 int size_adr; 193 struct shell_args *arg ;202 struct shell_args *arg = NULL; 194 203 195 204 if ((des_socket=socket(PF_INET,SOCK_STREAM,0))<0) { 196 205 perror("telnetd:socket"); … … 205 214 size_adr=sizeof(srv.sin); 206 215 if ((bind(des_socket,&srv.sa,size_adr))<0) { 207 216 perror("telnetd:bind"); 208 217 close(des_socket); 209 218 telnetd_task_id=0; 210 219 rtems_task_delete(RTEMS_SELF); 211 220 }; … … 220 229 * was started from the console anyways.. 221 230 */ 222 231 do { 223 devname = grab_a_Connection(des_socket, &srv, peername, sizeof(peername)); 224 225 if ( !devname ) { 226 /* if something went wrong, sleep for some time */ 227 sleep(10); 228 continue; 229 } 230 if ( telnetd_dont_spawn ) { 231 if ( !telnetd_askForPassword || (0 == check_passwd(peername)) ) 232 telnetd_shell(devname, telnetd_shell_arg); 232 if ( telnetd_remain_on_caller_stdio ) { 233 char device_name[32]; 234 ttyname_r( 1, device_name, sizeof(device_name) ); 235 if ( !telnetd_askForPassword || (0 == check_passwd(arg->peername)) ) 236 telnetd_shell(device_name, telnetd_shell_arg); 233 237 } else { 238 devname = grab_a_Connection(des_socket, &srv, peername, sizeof(peername)); 239 240 if ( !devname ) { 241 /* if something went wrong, sleep for some time */ 242 sleep(10); 243 continue; 244 } 245 234 246 arg = malloc( sizeof(*arg) ); 235 247 236 248 arg->devname = devname; … … 288 300 int rtems_telnetd_initialize( 289 301 void (*cmd)(char *, void *), 290 302 void *arg, 291 int dontSpawn,303 bool remainOnCallerSTDIO, 292 304 size_t stack, 293 305 rtems_task_priority priority, 294 intaskForPassword306 bool askForPassword 295 307 ) 296 308 { 297 309 rtems_status_code sc; … … 328 340 } 329 341 if ( priority < 2 ) 330 342 priority = 100; 331 telnetd_task_priority = priority;332 telnetd_ dont_spawn = dontSpawn;343 telnetd_task_priority = priority; 344 telnetd_remain_on_caller_stdio = remainOnCallerSTDIO; 333 345 334 346 sc = initialize_telnetd(); 335 347 if (sc != RTEMS_SUCCESSFUL) return sc; 336 348 337 printf("rtems_telnetd() started with stacksize=%u,priority=%d\n", 338 (unsigned)telnetd_stack_size,(int)telnetd_task_priority); 349 if ( !telnetd_remain_on_caller_stdio ) 350 fprintf(stderr, "rtems_telnetd() started with stacksize=%u,priority=%d\n", 351 (unsigned)telnetd_stack_size,(int)telnetd_task_priority); 339 352 return 0; 340 353 } 341 354 -
telnetd/telnetd.h
RCS file: /usr1/CVS/rtems/cpukit/telnetd/telnetd.h,v retrieving revision 1.7 diff -u -r1.7 telnetd.h
17 17 extern "C" { 18 18 #endif 19 19 20 /* 21 * Initializethe telnetd subsystem.20 /** 21 * This method initializes the telnetd subsystem. 22 22 * 23 * cmd - function which is the "shell" telnetd invokes 24 * arg - context pointer to cmd 25 * dontSpawn - TRUE if telnetd takes over this task. 26 * FALSE to create another task for the shell. 27 * stack - stack size of spawned task 28 * priority - initial priority of spawned task 29 * askForPassword - TRUE if telnetd asks for password 30 * FALSE to invoke "cmd" with no password check. 31 * This may be OK if "cmd" includes its own check. 23 * @param[in] cmd is the function which is the "shell" telnetd invokes 24 * @param[in] arg is the context pointer to cmd 25 * @param[in] remainOnCallerSTDIO is set to TRUE if telnetd takes over the 26 * standard in, out and error associated with task. In this case, 27 * it will be NOT be listening on any sockets. When this parameters 28 * is FALSE the telnetd will create other tasks for the shell 29 * which listen on sockets. 30 * @param[in] stack is stack size of spawned task. 31 * @param[in] priority is the initial priority of spawned task(s). If 32 * this parameter is less than 2, then the default priority of 100 is used. 33 * @param[in] askForPassword is set to TRUE if telnetd is to ask for a 34 * password. This is set to FALSE to invoke "cmd" with no password check. 35 * This may be OK if "cmd" includes its own check and indeed the RTEMS Shell 36 * uses a login with a user name and password so this is the usual case. 32 37 */ 33 38 int rtems_telnetd_initialize( 34 39 void (*cmd)(char *, void *), 35 40 void *arg, 36 int dontSpawn,41 bool remainOnCallerSTDIO, 37 42 size_t stack, 38 43 rtems_task_priority priority, 39 intaskForPassword44 bool askForPassword 40 45 ); 41 46 42 47 #ifdef __cplusplus