Changeset 9811aab in rtems
- Timestamp:
- 10/15/08 17:38:12 (14 years ago)
- Branches:
- 4.9
- Children:
- 283a60d
- Parents:
- c08349a
- Location:
- cpukit
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/ChangeLog
rc08349a r9811aab 1 2008-10-15 Joel Sherrill <joel.sherrill@OARcorp.com> 2 3 PR 1331/networking 4 * libmisc/shell/shell.c, telnetd/check_passwd.c, telnetd/telnetd.c, 5 telnetd/telnetd.h: Improve comments and explanation of options to 6 rtems_telnetd_initialize. Add extra newline to login sequence from 7 shell. 8 1 9 2008-10-14 Tim Cussins <timcussins@eml.cc> 2 10 -
cpukit/libmisc/shell/shell.c
rc08349a r9811aab 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"); … … 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"); -
cpukit/telnetd/check_passwd.c
rc08349a r9811aab 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) ) -
cpukit/telnetd/telnetd.c
rc08349a r9811aab 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; … … 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) { … … 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); … … 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 … … 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 { … … 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 } -
cpukit/telnetd/telnetd.h
rc08349a r9811aab 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
Note: See TracChangeset
for help on using the changeset viewer.