~darkmuggle-deactivatedaccount/ubuntu/quantal/grub2/fix-872244

« back to all changes in this revision

Viewing changes to grub-core/kern/dl.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2011-05-17 23:59:10 UTC
  • mto: (17.3.55 sid)
  • mto: This revision was merged to the branch mainline in revision 122.
  • Revision ID: james.westby@ubuntu.com-20110517235910-ma8u889vyjdfro27
Tags: upstream-1.99
ImportĀ upstreamĀ versionĀ 1.99

Show diffs side-by-side

added added

removed removed

Lines of Context:
373
373
    (mod->init) (mod);
374
374
}
375
375
 
 
376
/* Me, Vladimir Serbinenko, hereby I add this module check as per new
 
377
   GNU module policy. Note that this license check is informative only.
 
378
   Modules have to be licensed under GPLv3 or GPLv3+ (optionally
 
379
   multi-licensed under other licences as well) independently of the
 
380
   presence of this check and solely by linking (module loading in GRUB
 
381
   constitutes linking) and GRUB core being licensed under GPLv3+.
 
382
   Be sure to understand your license obligations.
 
383
*/
 
384
static grub_err_t
 
385
grub_dl_check_license (Elf_Ehdr *e)
 
386
{
 
387
  Elf_Shdr *s;
 
388
  const char *str;
 
389
  unsigned i;
 
390
 
 
391
  s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shstrndx * e->e_shentsize);
 
392
  str = (char *) e + s->sh_offset;
 
393
 
 
394
  for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
 
395
       i < e->e_shnum;
 
396
       i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
 
397
    if (grub_strcmp (str + s->sh_name, ".module_license") == 0)
 
398
      {
 
399
        if (grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3") == 0
 
400
            || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv3+") == 0
 
401
            || grub_strcmp ((char *) e + s->sh_offset, "LICENSE=GPLv2+") == 0)
 
402
          return GRUB_ERR_NONE;
 
403
      }
 
404
 
 
405
  return grub_error (GRUB_ERR_BAD_MODULE, "incompatible license");
 
406
}
 
407
 
376
408
static grub_err_t
377
409
grub_dl_resolve_name (grub_dl_t mod, Elf_Ehdr *e)
378
410
{
519
551
  mod->ref_count = 1;
520
552
 
521
553
  grub_dprintf ("modules", "relocating to %p\n", mod);
522
 
  if (grub_dl_resolve_name (mod, e)
 
554
  /* Me, Vladimir Serbinenko, hereby I add this module check as per new
 
555
     GNU module policy. Note that this license check is informative only.
 
556
     Modules have to be licensed under GPLv3 or GPLv3+ (optionally
 
557
     multi-licensed under other licences as well) independently of the
 
558
     presence of this check and solely by linking (module loading in GRUB
 
559
     constitutes linking) and GRUB core being licensed under GPLv3+.
 
560
     Be sure to understand your license obligations.
 
561
  */
 
562
  if (grub_dl_check_license (e)
 
563
      || grub_dl_resolve_name (mod, e)
523
564
      || grub_dl_resolve_dependencies (mod, e)
524
565
      || grub_dl_load_segments (mod, e)
525
566
      || grub_dl_resolve_symbols (mod, e)
585
626
      return 0;
586
627
    }
587
628
 
588
 
  mod->ref_count = 0;
 
629
  mod->ref_count--;
589
630
  return mod;
590
631
}
591
632
 
642
683
    {
643
684
      depn = dep->next;
644
685
 
645
 
      if (! grub_dl_unref (dep->mod))
646
 
        grub_dl_unload (dep->mod);
 
686
      grub_dl_unload (dep->mod);
647
687
 
648
688
      grub_free (dep);
649
689
    }