Changeset 3dba97d in code


Ignore:
Timestamp:
Mar 5, 2014, 9:41:56 PM (11 years ago)
Author:
Mike Belopuhov <mike@…>
Branches:
master
Children:
e54f151
Parents:
b28dd0e
Message:

Add a logging switch toggle and a prefix for a nicer chroot

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • icbd.8

    rb28dd0e r3dba97d  
    2727.Fl G Ar group1 Ns Op , Ns Ar ...
    2828.Oc
     29.Op Fl L Ar prefix
    2930.Op Fl M Ar modtab
    3031.Op Fl S Ar name
     
    6768.Nm
    6869to create specified groups at startup.
     70.It Fl L Ar prefix
     71Enables logging of all public messages in all groups and specifies a
     72directory inside the chroot that is owned and is writable by the
     73.Nm
     74user.
     75The server will create subdirectories matching those of the group names
     76and place log files inside one file per month.
    6977.It Fl M Ar modtab
    7078Specifies a moderator table that can be used to restrict users who
  • icbd.c

    rb28dd0e r3dba97d  
    4343#include "icbd.h"
    4444
    45 extern char *__progname;
    46 
    4745uint64_t sessionid;
    4846char modtab[ICB_MTABLEN][ICB_MAXNICKLEN];
     
    5149int  creategroups;
    5250int  foreground;
     51char logprefix[MAXPATHLEN/2];
     52int  dologging;
    5353int  verbose;
    5454
     
    8484        icb_init(&ic);
    8585
    86         while ((ch = getopt(argc, argv, "46CdG:M:S:v")) != -1)
     86        while ((ch = getopt(argc, argv, "46CdG:M:L:S:v")) != -1)
    8787                switch (ch) {
    8888                case '4':
     
    100100                case 'G':
    101101                        icbd_grplist(optarg);
     102                        break;
     103                case 'L':
     104                        strlcpy(logprefix, optarg, sizeof logprefix);
     105                        dologging++;
    102106                        break;
    103107                case 'M':
     
    301305usage(void)
    302306{
     307        extern char *__progname;
     308
    303309        (void)fprintf(stderr, "usage: %s [-46Cdv] [-G group1[,group2,...]] "
    304            "[-M modtab]\n\t[-S name] [[addr][:port] ...]\n",  __progname);
     310           "[-L prefix] [-M modtab]\n\t[-S name] [[addr][:port] ...]\n",
     311            __progname);
    305312        exit(EX_USAGE);
    306313}
  • logger.c

    rb28dd0e r3dba97d  
    6060struct event ev_tick;
    6161
     62extern char logprefix[MAXPATHLEN/2];
     63extern int dologging;
     64
    6265int
    6366logger_init(void)
     
    177180        FILE *fp = NULL;
    178181
    179         if (mkdir(group, 0755) < 0 && errno != EEXIST) {
     182        snprintf(path, sizeof path, "%s/%s", logprefix, group);
     183        if (mkdir(path, 0755) < 0 && errno != EEXIST) {
    180184                syslog(LOG_ERR, "%s: %m", group);
    181185                return (NULL);
    182186        }
    183         snprintf(path, sizeof path, "%s/%s", group, file_ts);
     187        snprintf(path, sizeof path, "%s/%s/%s", logprefix, group, file_ts);
    184188        if ((fp = fopen(path, "a")) == NULL) {
    185189                syslog(LOG_ERR, "%s: %m", path);
     
    200204        struct iovec iov[2];
    201205
     206        if (!dologging)
     207                return;
     208
    202209        strlcpy(e.group, group, ICB_MAXGRPLEN);
    203210        strlcpy(e.nick, nick, ICB_MAXNICKLEN);
Note: See TracChangeset for help on using the changeset viewer.