comparison svr-chansession.c @ 1459:06d52bcb8094

Pointer parameter could be declared as pointing to const
author Francois Perrad <francois.perrad@gadz.org>
date Sat, 19 Aug 2017 17:16:13 +0200
parents 79225928bf59
children 58a74cb829b8
comparison
equal deleted inserted replaced
1458:bdd3802c8ac6 1459:06d52bcb8094
41 /* Handles sessions (either shells or programs) requested by the client */ 41 /* Handles sessions (either shells or programs) requested by the client */
42 42
43 static int sessioncommand(struct Channel *channel, struct ChanSess *chansess, 43 static int sessioncommand(struct Channel *channel, struct ChanSess *chansess,
44 int iscmd, int issubsys); 44 int iscmd, int issubsys);
45 static int sessionpty(struct ChanSess * chansess); 45 static int sessionpty(struct ChanSess * chansess);
46 static int sessionsignal(struct ChanSess *chansess); 46 static int sessionsignal(const struct ChanSess *chansess);
47 static int noptycommand(struct Channel *channel, struct ChanSess *chansess); 47 static int noptycommand(struct Channel *channel, struct ChanSess *chansess);
48 static int ptycommand(struct Channel *channel, struct ChanSess *chansess); 48 static int ptycommand(struct Channel *channel, struct ChanSess *chansess);
49 static int sessionwinchange(struct ChanSess *chansess); 49 static int sessionwinchange(const struct ChanSess *chansess);
50 static void execchild(void *user_data_chansess); 50 static void execchild(void *user_data_chansess);
51 static void addchildpid(struct ChanSess *chansess, pid_t pid); 51 static void addchildpid(struct ChanSess *chansess, pid_t pid);
52 static void sesssigchild_handler(int val); 52 static void sesssigchild_handler(int val);
53 static void closechansess(struct Channel *channel); 53 static void closechansess(struct Channel *channel);
54 static int newchansess(struct Channel *channel); 54 static int newchansess(struct Channel *channel);
55 static void chansessionrequest(struct Channel *channel); 55 static void chansessionrequest(struct Channel *channel);
56 static int sesscheckclose(struct Channel *channel); 56 static int sesscheckclose(const struct Channel *channel);
57 57
58 static void send_exitsignalstatus(struct Channel *channel); 58 static void send_exitsignalstatus(const struct Channel *channel);
59 static void send_msg_chansess_exitstatus(struct Channel * channel, 59 static void send_msg_chansess_exitstatus(const struct Channel * channel,
60 struct ChanSess * chansess); 60 const struct ChanSess * chansess);
61 static void send_msg_chansess_exitsignal(struct Channel * channel, 61 static void send_msg_chansess_exitsignal(const struct Channel * channel,
62 struct ChanSess * chansess); 62 const struct ChanSess * chansess);
63 static void get_termmodes(struct ChanSess *chansess); 63 static void get_termmodes(const struct ChanSess *chansess);
64 64
65 const struct ChanType svrchansess = { 65 const struct ChanType svrchansess = {
66 0, /* sepfds */ 66 0, /* sepfds */
67 "session", /* name */ 67 "session", /* name */
68 newchansess, /* inithandler */ 68 newchansess, /* inithandler */
72 }; 72 };
73 73
74 /* required to clear environment */ 74 /* required to clear environment */
75 extern char** environ; 75 extern char** environ;
76 76
77 static int sesscheckclose(struct Channel *channel) { 77 static int sesscheckclose(const struct Channel *channel) {
78 struct ChanSess *chansess = (struct ChanSess*)channel->typedata; 78 struct ChanSess *chansess = (struct ChanSess*)channel->typedata;
79 TRACE(("sesscheckclose, pid is %d", chansess->exit.exitpid)) 79 TRACE(("sesscheckclose, pid is %d", chansess->exit.exitpid))
80 return chansess->exit.exitpid != -1; 80 return chansess->exit.exitpid != -1;
81 } 81 }
82 82
157 157
158 errno = saved_errno; 158 errno = saved_errno;
159 } 159 }
160 160
161 /* send the exit status or the signal causing termination for a session */ 161 /* send the exit status or the signal causing termination for a session */
162 static void send_exitsignalstatus(struct Channel *channel) { 162 static void send_exitsignalstatus(const struct Channel *channel) {
163 163
164 struct ChanSess *chansess = (struct ChanSess*)channel->typedata; 164 struct ChanSess *chansess = (struct ChanSess*)channel->typedata;
165 165
166 if (chansess->exit.exitpid >= 0) { 166 if (chansess->exit.exitpid >= 0) {
167 if (chansess->exit.exitsignal > 0) { 167 if (chansess->exit.exitsignal > 0) {
171 } 171 }
172 } 172 }
173 } 173 }
174 174
175 /* send the exitstatus to the client */ 175 /* send the exitstatus to the client */
176 static void send_msg_chansess_exitstatus(struct Channel * channel, 176 static void send_msg_chansess_exitstatus(const struct Channel * channel,
177 struct ChanSess * chansess) { 177 const struct ChanSess * chansess) {
178 178
179 dropbear_assert(chansess->exit.exitpid != -1); 179 dropbear_assert(chansess->exit.exitpid != -1);
180 dropbear_assert(chansess->exit.exitsignal == -1); 180 dropbear_assert(chansess->exit.exitsignal == -1);
181 181
182 CHECKCLEARTOWRITE(); 182 CHECKCLEARTOWRITE();
190 encrypt_packet(); 190 encrypt_packet();
191 191
192 } 192 }
193 193
194 /* send the signal causing the exit to the client */ 194 /* send the signal causing the exit to the client */
195 static void send_msg_chansess_exitsignal(struct Channel * channel, 195 static void send_msg_chansess_exitsignal(const struct Channel * channel,
196 struct ChanSess * chansess) { 196 const struct ChanSess * chansess) {
197 197
198 int i; 198 int i;
199 char* signame = NULL; 199 char* signame = NULL;
200 dropbear_assert(chansess->exit.exitpid != -1); 200 dropbear_assert(chansess->exit.exitpid != -1);
201 dropbear_assert(chansess->exit.exitsignal > 0); 201 dropbear_assert(chansess->exit.exitsignal > 0);
271 return 0; 271 return 0;
272 272
273 } 273 }
274 274
275 static struct logininfo* 275 static struct logininfo*
276 chansess_login_alloc(struct ChanSess *chansess) { 276 chansess_login_alloc(const struct ChanSess *chansess) {
277 struct logininfo * li; 277 struct logininfo * li;
278 li = login_alloc_entry(chansess->pid, ses.authstate.username, 278 li = login_alloc_entry(chansess->pid, ses.authstate.username,
279 svr_ses.remotehost, chansess->tty); 279 svr_ses.remotehost, chansess->tty);
280 return li; 280 return li;
281 } 281 }
401 TRACE(("leave chansessionrequest")) 401 TRACE(("leave chansessionrequest"))
402 } 402 }
403 403
404 404
405 /* Send a signal to a session's process as requested by the client*/ 405 /* Send a signal to a session's process as requested by the client*/
406 static int sessionsignal(struct ChanSess *chansess) { 406 static int sessionsignal(const struct ChanSess *chansess) {
407 407
408 int sig = 0; 408 int sig = 0;
409 char* signame = NULL; 409 char* signame = NULL;
410 int i; 410 int i;
411 411
439 return DROPBEAR_SUCCESS; 439 return DROPBEAR_SUCCESS;
440 } 440 }
441 441
442 /* Let the process know that the window size has changed, as notified from the 442 /* Let the process know that the window size has changed, as notified from the
443 * client. Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ 443 * client. Returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
444 static int sessionwinchange(struct ChanSess *chansess) { 444 static int sessionwinchange(const struct ChanSess *chansess) {
445 445
446 int termc, termr, termw, termh; 446 int termc, termr, termw, termh;
447 447
448 if (chansess->master < 0) { 448 if (chansess->master < 0) {
449 /* haven't got a pty yet */ 449 /* haven't got a pty yet */
458 pty_change_window_size(chansess->master, termr, termc, termw, termh); 458 pty_change_window_size(chansess->master, termr, termc, termw, termh);
459 459
460 return DROPBEAR_SUCCESS; 460 return DROPBEAR_SUCCESS;
461 } 461 }
462 462
463 static void get_termmodes(struct ChanSess *chansess) { 463 static void get_termmodes(const struct ChanSess *chansess) {
464 464
465 struct termios termio; 465 struct termios termio;
466 unsigned char opcode; 466 unsigned char opcode;
467 unsigned int value; 467 unsigned int value;
468 const struct TermCode * termcode; 468 const struct TermCode * termcode;