Lines 186-197
ConsoleStat(Context ctx, int ac, char *a
Link Here
|
186 |
ConsoleSession s; |
186 |
ConsoleSession s; |
187 |
ConsoleSession cs = ctx->cs; |
187 |
ConsoleSession cs = ctx->cs; |
188 |
char addrstr[INET6_ADDRSTRLEN]; |
188 |
char addrstr[INET6_ADDRSTRLEN]; |
|
|
189 |
int oldstate; |
189 |
|
190 |
|
190 |
Printf("Configuration:\r\n"); |
191 |
Printf("Configuration:\r\n"); |
191 |
Printf("\tState : %s\r\n", c->fd ? "OPENED" : "CLOSED"); |
192 |
Printf("\tState : %s\r\n", c->fd ? "OPENED" : "CLOSED"); |
192 |
Printf("\tIP-Address : %s\r\n", u_addrtoa(&c->addr,addrstr,sizeof(addrstr))); |
193 |
Printf("\tIP-Address : %s\r\n", u_addrtoa(&c->addr,addrstr,sizeof(addrstr))); |
193 |
Printf("\tPort : %d\r\n", c->port); |
194 |
Printf("\tPort : %d\r\n", c->port); |
194 |
|
195 |
|
|
|
196 |
if (__isthreaded) { |
197 |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); |
198 |
} |
199 |
|
195 |
RWLOCK_RDLOCK(c->lock); |
200 |
RWLOCK_RDLOCK(c->lock); |
196 |
Printf("Active sessions:\r\n"); |
201 |
Printf("Active sessions:\r\n"); |
197 |
SLIST_FOREACH(s, &c->sessions, next) { |
202 |
SLIST_FOREACH(s, &c->sessions, next) { |
Lines 199-204
ConsoleStat(Context ctx, int ac, char *a
Link Here
|
199 |
s->user.username, u_addrtoa(&s->peer_addr,addrstr,sizeof(addrstr))); |
204 |
s->user.username, u_addrtoa(&s->peer_addr,addrstr,sizeof(addrstr))); |
200 |
} |
205 |
} |
201 |
RWLOCK_UNLOCK(c->lock); |
206 |
RWLOCK_UNLOCK(c->lock); |
|
|
207 |
if (__isthreaded) { |
208 |
pthread_setcancelstate(oldstate, NULL); |
209 |
} |
202 |
|
210 |
|
203 |
Printf("Global options:\r\n"); |
211 |
Printf("Global options:\r\n"); |
204 |
OptStat(ctx, &c->options, gConfList); |
212 |
OptStat(ctx, &c->options, gConfList); |
Lines 225-230
ConsoleConnect(int type, void *cookie)
Link Here
|
225 |
"\xFF\xFD\x01"; /* DO echo */ |
233 |
"\xFF\xFD\x01"; /* DO echo */ |
226 |
char addrstr[INET6_ADDRSTRLEN]; |
234 |
char addrstr[INET6_ADDRSTRLEN]; |
227 |
struct sockaddr_storage ss; |
235 |
struct sockaddr_storage ss; |
|
|
236 |
int oldstate; |
228 |
|
237 |
|
229 |
Log(LG_CONSOLE, ("CONSOLE: Connect")); |
238 |
Log(LG_CONSOLE, ("CONSOLE: Connect")); |
230 |
cs = Malloc(MB_CONS, sizeof(*cs)); |
239 |
cs = Malloc(MB_CONS, sizeof(*cs)); |
Lines 249-257
ConsoleConnect(int type, void *cookie)
Link Here
|
249 |
cs->state = STATE_USERNAME; |
258 |
cs->state = STATE_USERNAME; |
250 |
} |
259 |
} |
251 |
cs->context.cs = cs; |
260 |
cs->context.cs = cs; |
|
|
261 |
if (__isthreaded) { |
262 |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); |
263 |
} |
252 |
RWLOCK_WRLOCK(c->lock); |
264 |
RWLOCK_WRLOCK(c->lock); |
253 |
SLIST_INSERT_HEAD(&c->sessions, cs, next); |
265 |
SLIST_INSERT_HEAD(&c->sessions, cs, next); |
254 |
RWLOCK_UNLOCK(c->lock); |
266 |
RWLOCK_UNLOCK(c->lock); |
|
|
267 |
if (__isthreaded) { |
268 |
pthread_setcancelstate(oldstate, NULL); |
269 |
} |
255 |
Log(LG_CONSOLE, ("CONSOLE: Allocated new console session %p from %s", |
270 |
Log(LG_CONSOLE, ("CONSOLE: Allocated new console session %p from %s", |
256 |
cs, u_addrtoa(&cs->peer_addr,addrstr,sizeof(addrstr)))); |
271 |
cs, u_addrtoa(&cs->peer_addr,addrstr,sizeof(addrstr)))); |
257 |
cs->write(cs, "Multi-link PPP daemon for FreeBSD\r\n\r\n"); |
272 |
cs->write(cs, "Multi-link PPP daemon for FreeBSD\r\n\r\n"); |
Lines 277-282
StdConsoleConnect(Console c)
Link Here
|
277 |
{ |
292 |
{ |
278 |
ConsoleSession cs; |
293 |
ConsoleSession cs; |
279 |
struct termios settings; |
294 |
struct termios settings; |
|
|
295 |
int oldstate; |
280 |
|
296 |
|
281 |
cs = Malloc(MB_CONS, sizeof(*cs)); |
297 |
cs = Malloc(MB_CONS, sizeof(*cs)); |
282 |
|
298 |
|
Lines 317-325
StdConsoleConnect(Console c)
Link Here
|
317 |
cs->context.cs = cs; |
333 |
cs->context.cs = cs; |
318 |
strcpy(cs->user.username, "root"); |
334 |
strcpy(cs->user.username, "root"); |
319 |
cs->context.priv = 2; |
335 |
cs->context.priv = 2; |
|
|
336 |
if (__isthreaded) { |
337 |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); |
338 |
} |
320 |
RWLOCK_WRLOCK(c->lock); |
339 |
RWLOCK_WRLOCK(c->lock); |
321 |
SLIST_INSERT_HEAD(&c->sessions, cs, next); |
340 |
SLIST_INSERT_HEAD(&c->sessions, cs, next); |
322 |
RWLOCK_UNLOCK(c->lock); |
341 |
RWLOCK_UNLOCK(c->lock); |
|
|
342 |
if (__isthreaded) { |
343 |
pthread_setcancelstate(oldstate, NULL); |
344 |
} |
323 |
|
345 |
|
324 |
EventRegister(&cs->readEvent, EVENT_READ, cs->fd, |
346 |
EventRegister(&cs->readEvent, EVENT_READ, cs->fd, |
325 |
EVENT_RECURRING, ConsoleSessionReadEvent, cs); |
347 |
EVENT_RECURRING, ConsoleSessionReadEvent, cs); |
Lines 339-348
StdConsoleConnect(Console c)
Link Here
|
339 |
static void |
361 |
static void |
340 |
ConsoleSessionClose(ConsoleSession cs) |
362 |
ConsoleSessionClose(ConsoleSession cs) |
341 |
{ |
363 |
{ |
|
|
364 |
int oldstate; |
365 |
|
342 |
cs->write(cs, "Console closed.\r\n"); |
366 |
cs->write(cs, "Console closed.\r\n"); |
|
|
367 |
if (__isthreaded) { |
368 |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); |
369 |
} |
343 |
RWLOCK_WRLOCK(cs->console->lock); |
370 |
RWLOCK_WRLOCK(cs->console->lock); |
344 |
SLIST_REMOVE(&cs->console->sessions, cs, console_session, next); |
371 |
SLIST_REMOVE(&cs->console->sessions, cs, console_session, next); |
345 |
RWLOCK_UNLOCK(cs->console->lock); |
372 |
RWLOCK_UNLOCK(cs->console->lock); |
|
|
373 |
if (__isthreaded) { |
374 |
pthread_setcancelstate(oldstate, NULL); |
375 |
} |
346 |
EventUnRegister(&cs->readEvent); |
376 |
EventUnRegister(&cs->readEvent); |
347 |
close(cs->fd); |
377 |
close(cs->fd); |
348 |
Freee(cs); |
378 |
Freee(cs); |
Lines 564-573
notfound:
Link Here
|
564 |
break; |
594 |
break; |
565 |
} else if (cs->state == STATE_PASSWORD) { |
595 |
} else if (cs->state == STATE_PASSWORD) { |
566 |
ConsoleUser u; |
596 |
ConsoleUser u; |
|
|
597 |
int oldstate; |
567 |
|
598 |
|
|
|
599 |
if (__isthreaded) { |
600 |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); |
601 |
} |
568 |
RWLOCK_RDLOCK(gUsersLock); |
602 |
RWLOCK_RDLOCK(gUsersLock); |
569 |
u = ghash_get(gUsers, &cs->user); |
603 |
u = ghash_get(gUsers, &cs->user); |
570 |
RWLOCK_UNLOCK(gUsersLock); |
604 |
RWLOCK_UNLOCK(gUsersLock); |
|
|
605 |
if (__isthreaded) { |
606 |
pthread_setcancelstate(oldstate, NULL); |
607 |
} |
571 |
|
608 |
|
572 |
if (!u) |
609 |
if (!u) |
573 |
goto failed; |
610 |
goto failed; |
Lines 868-873
int
Link Here
|
868 |
UserCommand(Context ctx, int ac, char *av[], void *arg) |
905 |
UserCommand(Context ctx, int ac, char *av[], void *arg) |
869 |
{ |
906 |
{ |
870 |
ConsoleUser u; |
907 |
ConsoleUser u; |
|
|
908 |
int oldstate; |
871 |
|
909 |
|
872 |
if (ac < 2 || ac > 3) |
910 |
if (ac < 2 || ac > 3) |
873 |
return(-1); |
911 |
return(-1); |
Lines 887-895
UserCommand(Context ctx, int ac, char *a
Link Here
|
887 |
return (-1); |
925 |
return (-1); |
888 |
} |
926 |
} |
889 |
} |
927 |
} |
|
|
928 |
if (__isthreaded) { |
929 |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); |
930 |
} |
890 |
RWLOCK_WRLOCK(gUsersLock); |
931 |
RWLOCK_WRLOCK(gUsersLock); |
891 |
ghash_put(gUsers, u); |
932 |
ghash_put(gUsers, u); |
892 |
RWLOCK_UNLOCK(gUsersLock); |
933 |
RWLOCK_UNLOCK(gUsersLock); |
|
|
934 |
if (__isthreaded) { |
935 |
pthread_setcancelstate(oldstate, NULL); |
936 |
} |
893 |
|
937 |
|
894 |
return (0); |
938 |
return (0); |
895 |
} |
939 |
} |
Lines 903-910
UserStat(Context ctx, int ac, char *av[]
Link Here
|
903 |
{ |
947 |
{ |
904 |
struct ghash_walk walk; |
948 |
struct ghash_walk walk; |
905 |
ConsoleUser u; |
949 |
ConsoleUser u; |
|
|
950 |
int oldstate; |
906 |
|
951 |
|
907 |
Printf("Configured users:\r\n"); |
952 |
Printf("Configured users:\r\n"); |
|
|
953 |
if (__isthreaded) { |
954 |
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate); |
955 |
} |
908 |
RWLOCK_RDLOCK(gUsersLock); |
956 |
RWLOCK_RDLOCK(gUsersLock); |
909 |
ghash_walk_init(gUsers, &walk); |
957 |
ghash_walk_init(gUsers, &walk); |
910 |
while ((u = ghash_walk_next(gUsers, &walk)) != NULL) { |
958 |
while ((u = ghash_walk_next(gUsers, &walk)) != NULL) { |
Lines 912-917
UserStat(Context ctx, int ac, char *av[]
Link Here
|
912 |
((u->priv == 2)?"admin":((u->priv == 1)?"operator":"user"))); |
960 |
((u->priv == 2)?"admin":((u->priv == 1)?"operator":"user"))); |
913 |
} |
961 |
} |
914 |
RWLOCK_UNLOCK(gUsersLock); |
962 |
RWLOCK_UNLOCK(gUsersLock); |
|
|
963 |
if (__isthreaded) { |
964 |
pthread_setcancelstate(oldstate, NULL); |
965 |
} |
915 |
|
966 |
|
916 |
return 0; |
967 |
return 0; |
917 |
} |
968 |
} |