Exemple #1
0
static bool xt_geoip_mt(const struct sk_buff *skb, struct xt_action_param *par)
{
   const struct xt_geoip_match_info *info = par->matchinfo;
   const struct geoip_info *node; /* This keeps the code sexy */
   const struct iphdr *iph = ip_hdr(skb);
   u_int32_t ip, i, j;

   if (info->flags & XT_GEOIP_SRC)
      ip = ntohl(iph->saddr);
   else
      ip = ntohl(iph->daddr);

   spin_lock_bh(&geoip_lock);
   for (i = 0; i < info->count; i++) {
      if ((node = info->mem[i]) == NULL) {
         printk(KERN_ERR "xt_geoip: what the hell ?? '%c%c' isn't loaded into memory... skip it!\n",
               COUNTRY(info->cc[i]));
         
         continue;
      }

      for (j = 0; j < node->count; j++)
         if ((ip > node->subnets[j].begin) && (ip < node->subnets[j].end)) {
            spin_unlock_bh(&geoip_lock);
            return (info->flags & XT_GEOIP_INV) ? 0 : 1;
         }
   }
   
   spin_unlock_bh(&geoip_lock);
   return (info->flags & XT_GEOIP_INV) ? 1 : 0;
}
Exemple #2
0
void smartschoolTest::testSaveUser() {
  y::ldap::server Server;
  y::ldap::account & a = Server.getAccount(UID("unitTest"));
  if(!a.isNew()) {
    CPPUNIT_ASSERT(false);
  }
  a.role(ROLE(ROLE::NONE));
  a.uid(UID("unitTest"));
  a.gender(GENDER(GENDER::MALE));
  a.street(STREET("my street"));
  a.houseNumber(HOUSENUMBER(42));
  a.houseNumberAdd(HOUSENUMBER_ADD("a"));
  a.birthDay(DATE(DAY(9), MONTH(8), YEAR(1972)));
  a.wisaID(WISA_ID(111111111));
  a.password(PASSWORD("ABcd!eGf"));
  a.ssPassword("ABcd!eGf");
  a.cn(CN("unit"));
  a.sn(SN("test"));
  a.birthPlace(BIRTHPLACE("brussels"));
  a.postalCode(POSTAL_CODE("1000"));
  a.city(CITY("brussels"));
  a.country(COUNTRY("belgie"));
  a.mail(MAIL("*****@*****.**"));
  
  // role is not set!
  if(y::Smartschool().saveUser(a)) {
    CPPUNIT_ASSERT(false);
  }
  
  a.role(ROLE(ROLE::STUDENT));
  if(!y::Smartschool().saveUser(a)) {
    CPPUNIT_ASSERT(false);
  }
  
}
Exemple #3
0
static void
geoip_save(const void *ip, const struct xt_entry_match *match)
{
	const struct xt_geoip_match_info *info = (void *)match->data;
	u_int8_t i;

	if (info->flags & XT_GEOIP_INV)
		printf(" !");

	if (info->flags & XT_GEOIP_SRC)
		printf(" --source-country ");
	else
		printf(" --destination-country ");

	for (i = 0; i < info->count; i++)
		printf("%s%c%c", i ? "," : "", COUNTRY(info->cc[i]));
	printf(" ");
}
Exemple #4
0
y::ldap::account::account(y::ldap::server * server) :
  server(server),
  // var          name in ldap          type and init    is int?      
  _uidNumber     (TYPE_UIDNUMBER      , UID_NUMBER (0 )),
  _uid           (TYPE_UID            , UID        ("")),
  _dn            ("DN"                , DN         ("")),
  _cn            (TYPE_CN             , CN         ("")),
  _sn            ("sn"                , SN         ("")),
  _fullName      ("displayName"       , FULL_NAME  ("")),
  _homeDir       ("homeDirectory"     , HOMEDIR    ("")),
  _wisaID        ("wisaID"            , WISA_ID    (0 )),
  _wisaName      (TYPE_WISANAME       , WISA_NAME  ("")),
  _mail          ("mail"              , MAIL       ("")),
  _mailAlias     ("mailAlias"         , MAIL_ALIAS ("")),
  _birthDay      ("birthday"          , DATE(DAY(1), MONTH(1), YEAR(1))),
  _password      ("gMailPassword"     , PASSWORD   ("")),
  _role          ("schoolRole"        , ROLE(ROLE::NONE)),
  _groupID       ("gidNumber"         , GID_NUMBER (0 )),
  _schoolClass   ("class"             , SCHOOLCLASS("")),
  _classChange   ("classChangeDate"   , DATE(DAY(1), MONTH(1), YEAR(1))),
  _birthPlace    ("placeOfBirth"      , BIRTHPLACE ("")),
  _gender        ("gender"            , GENDER(GENDER::MALE) ),
  _adminGroup    ("adminGroupID"      , ADMINGROUP (0 )),
  _registerID    ("nationalRegisterID", REGISTER_ID("")),
  _nationality   ("nationality"       , NATION     ("")),
  _stemID        ("stemID"            , STEM_ID    (0 )),
  _schoolID      ("schoolID"          , SCHOOL_ID  (0 )),   
  _houseNumber   ("houseNumber"       , HOUSENUMBER(0 )),
  _houseNumberAdd("houseNumberAdd"    , HOUSENUMBER_ADD("")  ),
  _city          ("location"          , CITY       ("")),
  _postalCode    ("postalCode"        , POSTAL_CODE("")),
  _street        ("street"            , STREET     ("")),
  _country       ("co"                , COUNTRY    ("")),

  _new(true),
  _hasKrbName(false),
  _hasSchoolPersonClass(false),
  _importStatus(WI_NOT_ACCOUNTED),
  _flaggedForRemoval(false)
  {}
Exemple #5
0
void y::ldap::account::clear() {
  _new = true;
  _hasKrbName = false;
  _hasSchoolPersonClass = false;
  _uidNumber     .reset(UID_NUMBER (0 ));
  _uid           .reset(UID        (""));
  _dn            .reset(DN         (""));
  _cn            .reset(CN         (""));
  _sn            .reset(SN         (""));
  _fullName      .reset(FULL_NAME  (""));
  _homeDir       .reset(HOMEDIR    (""));
  _wisaID        .reset(WISA_ID    (0 ));
  _wisaName      .reset(WISA_NAME  (""));
  _mail          .reset(MAIL       (""));
  _mailAlias     .reset(MAIL_ALIAS (""));
  _birthDay      .reset(DATE(DAY(1), MONTH(1), YEAR(1)));
  _password      .reset(PASSWORD   (""));
  _role          .reset(ROLE(ROLE::NONE));
  _groupID       .reset(GID_NUMBER (0 ));
  _schoolClass   .reset(SCHOOLCLASS(""));
  _birthPlace    .reset(BIRTHPLACE (""));
  _gender        .reset(GENDER(GENDER::MALE));
  _adminGroup    .reset(ADMINGROUP (0 ));
  _registerID    .reset(REGISTER_ID(""));
  _nationality   .reset(NATION     (""));
  _stemID        .reset(STEM_ID    (0 ));
  _schoolID      .reset(SCHOOL_ID  (0 ));
  _street        .reset(STREET     (""));  
  _houseNumber   .reset(HOUSENUMBER(0 ));
  _houseNumberAdd.reset(HOUSENUMBER_ADD(""));
  _city          .reset(CITY       (""));
  _postalCode    .reset(POSTAL_CODE(""));
  _country       .reset(COUNTRY    (""));
  _ssPassword.clear();
  _flaggedForRemoval = false;
}
Exemple #6
0
static int xt_geoip_mt_checkentry(const struct xt_mtchk_param *par)
{
   
   struct xt_geoip_match_info *info = par->matchinfo;
   struct geoip_info *node;
   u_int8_t i;

   /* FIXME:   Call a function to free userspace allocated memory.
    *          As Martin J. said; this match might eat lot of memory
    *          if commited with iptables-restore --noflush
   void (*gfree)(struct geoip_info *oldmem);
   gfree = info->fini;
   */

   /* If info->refcount isn't NULL, then
    * it means that checkentry() already
    * initialized this entry. Increase a
    * refcount to prevent destroy() of
    * this entry. */
   if (info->refcount != NULL) {
      atomic_inc((atomic_t *)info->refcount);
      return 0;
   }
   
   
   for (i = 0; i < info->count; i++) {
     
      if ((node = find_node(info->cc[i])) != NULL)
            atomic_inc((atomic_t *)&node->ref);   //increase the reference
      else
         if ((node = add_node(info->mem[i])) == NULL) {
            printk(KERN_ERR
                  "xt_geoip: unable to load '%c%c' into memory\n",
                  COUNTRY(info->cc[i]));
            return -ENOMEM;
         }

      /* Free userspace allocated memory for that country.
       * FIXME:   It's a bit odd to call this function everytime
       *          we process a country.  Would be nice to call
       *          it once after all countries've been processed.
       *          - SJ
       * *not implemented for now*
      gfree(info->mem[i]);
      */

      /* Overwrite the now-useless pointer info->mem[i] with
       * a pointer to the node's kernelspace structure.
       * This avoids searching for a node in the match() and
       * destroy() functions.
       */
      info->mem[i] = node;
   }

   /* We allocate some memory and give info->refcount a pointer
    * to this memory.  This prevents checkentry() from increasing a refcount
    * different from the one used by destroy().
    * For explanation, see http://www.mail-archive.com/[email protected]/msg00625.html
    */
   info->refcount = kmalloc(sizeof(u_int8_t), GFP_KERNEL);
   if (info->refcount == NULL) {
      printk(KERN_ERR "xt_geoip: failed to allocate `refcount' memory\n");
      return -ENOMEM;
   }
   *(info->refcount) = 1;
   
   return 0;
}