View | Details | Raw Unified | Return to bug 214482 | Differences between
and this patch

Collapse All | Expand All

(-)src/log.c (-3 / +36 lines)
Lines 245-270 LogPrintf(const char *fmt, ...) Link Here
245
    va_end(args);
245
    va_end(args);
246
}
246
}
247
247
248
#ifdef SYSLOG_FACILITY
249
void
250
pt_vsyslog(int priority, const char *fmt, va_list args)
251
{
252
    int oldstate;
253
254
    if (__isthreaded) {
255
	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
256
    }
257
    vsyslog(priority, fmt, args);
258
    if (__isthreaded) {
259
	pthread_setcancelstate(oldstate, NULL);
260
    }
261
}
262
263
void
264
pt_syslog(int priority, const char *fmt, ...)
265
{
266
    va_list ap;
267
268
    va_start(ap, fmt);
269
    pt_vsyslog(priority, fmt, ap);
270
    va_end(ap);
271
}
272
#endif
273
248
void
274
void
249
vLogPrintf(const char *fmt, va_list args)
275
vLogPrintf(const char *fmt, va_list args)
250
{
276
{
251
    if (!SLIST_EMPTY(&gConsole.sessions)) {
277
    if (!SLIST_EMPTY(&gConsole.sessions)) {
252
	char		buf[1000];
278
	char		buf[1000];
253
	ConsoleSession	s;
279
	ConsoleSession	s;
280
	int		oldstate;
254
281
255
        vsnprintf(buf, sizeof(buf), fmt, args);
282
        vsnprintf(buf, sizeof(buf), fmt, args);
256
#ifdef SYSLOG_FACILITY
283
#ifdef SYSLOG_FACILITY
257
        syslog(LOG_INFO, "%s", buf);
284
        pt_syslog(LOG_INFO, "%s", buf);
258
#endif
285
#endif
286
	if (__isthreaded) {
287
	  pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &oldstate);
288
	}
259
	RWLOCK_RDLOCK(gConsole.lock);
289
	RWLOCK_RDLOCK(gConsole.lock);
260
	SLIST_FOREACH(s, &gConsole.sessions, next) {
290
	SLIST_FOREACH(s, &gConsole.sessions, next) {
261
	    if (Enabled(&s->options, CONSOLE_LOGGING))
291
	    if (Enabled(&s->options, CONSOLE_LOGGING))
262
		s->write(s, "%s\r\n", buf);
292
		s->write(s, "%s\r\n", buf);
263
	}
293
	}
264
	RWLOCK_UNLOCK(gConsole.lock);
294
	RWLOCK_UNLOCK(gConsole.lock);
295
	if (__isthreaded) {
296
	  pthread_setcancelstate(oldstate, NULL);
297
	}
265
#ifdef SYSLOG_FACILITY
298
#ifdef SYSLOG_FACILITY
266
    } else {
299
    } else {
267
        vsyslog(LOG_INFO, fmt, args);
300
        pt_vsyslog(LOG_INFO, fmt, args);
268
#endif
301
#endif
269
    }
302
    }
270
}
303
}
Lines 282-288 LogPrintf2(const char *fmt, ...) Link Here
282
315
283
    va_start(args, fmt);
316
    va_start(args, fmt);
284
#ifdef SYSLOG_FACILITY
317
#ifdef SYSLOG_FACILITY
285
    vsyslog(LOG_INFO, fmt, args);
318
    pt_vsyslog(LOG_INFO, fmt, args);
286
#endif
319
#endif
287
    va_end(args);
320
    va_end(args);
288
}
321
}
(-)src/contrib/libpdel/util/pevent.c (-1 / +2 lines)
Lines 62-68 Link Here
62
#include "util/mesg_port.h"
62
#include "util/mesg_port.h"
63
#include "util/pevent.h"
63
#include "util/pevent.h"
64
#ifdef SYSLOG_FACILITY
64
#ifdef SYSLOG_FACILITY
65
#define alogf(sev, fmt, arg...) syslog(sev, "%s: " fmt, __FUNCTION__ , ## arg)
65
extern void pt_syslog(int priority, const char *fmt, ...);
66
#define alogf(sev, fmt, arg...) pt_syslog(sev, "%s: " fmt, __FUNCTION__ , ## arg)
66
#else
67
#else
67
#define alogf(sev, fmt, arg...) do{}while(0)
68
#define alogf(sev, fmt, arg...) do{}while(0)
68
#endif
69
#endif
(-)src/console.c (+51 lines)
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
}

Return to bug 214482