Changeset 677a45b in code for icbd.c


Ignore:
Timestamp:
Apr 22, 2015, 5:28:48 PM (10 years ago)
Author:
Mike Belopuhov <mike@…>
Branches:
master
Children:
176b6ef
Parents:
5dfeb4c
Message:

Remove group passwords and introduce new tokenizer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icbd.c

    r5dfeb4c r677a45b  
    6565void icbd_dispatch(struct bufferevent *, void *);
    6666void icbd_log(struct icb_session *, int, const char *, ...);
    67 void icbd_grplist(char *);
    6867void icbd_restrict(void);
    6968void icbd_send(struct icb_session *, char *, ssize_t);
     
    7978        int ch, nsocks = 0, save_errno = 0;
    8079        int inet4 = 0, inet6 = 0;
     80        char group[ICB_MAXGRPLEN], *grplist = NULL;
     81        char *ptr = NULL;
    8182
    8283        /* init group lists before calling icb_addgroup */
     
    9899                        break;
    99100                case 'G':
    100                         icbd_grplist(optarg);
     101                        grplist = optarg;
    101102                        break;
    102103                case 'L':
     
    124125
    125126        /* add group "1" as it's a login group for most of the clients */
    126         if (icb_addgroup(NULL, "1", NULL) == NULL)
     127        if (icb_addgroup(NULL, "1") == NULL)
    127128                err(EX_UNAVAILABLE, NULL);
     129
     130        if (grplist) {
     131                while (icb_token(grplist, strlen(grplist), &ptr, group,
     132                    ICB_MAXGRPLEN, ',') > 0)
     133                        if (icb_addgroup(NULL, group) == NULL)
     134                                err(EX_UNAVAILABLE, NULL);
     135        }
    128136
    129137        if (argc == 0)
     
    492500
    493501void
    494 icbd_grplist(char *list)
    495 {
    496         char *s, *s1, *s2;
    497         int last = 0;
    498 
    499         if (!list || strlen(list) == 0)
    500                 return;
    501 
    502         /* "group1[:pass1][,group2[:pass2],...]" */
    503         s = list;
    504         s1 = s2 = NULL;
    505         while (!last && s) {
    506                 if ((s1 = strchr(s, ',')) != NULL)
    507                         *s1 = '\0';
    508                 else {
    509                         last = 1;
    510                         s1 = s;
    511                 }
    512                 if ((s2 = strchr(s, ':')) != NULL)
    513                         *s2 = '\0';
    514                 if (icb_addgroup(NULL, s, s2 ? ++s2 : NULL) == NULL)
    515                         err(EX_UNAVAILABLE, NULL);
    516                 s = ++s1;
    517                 s1 = s2 = NULL;
    518         }
    519 }
    520 
    521 void
    522502icbd_modupdate(void)
    523503{
Note: See TracChangeset for help on using the changeset viewer.