Example #1
0
void object_set_collector(Object *obj, collector_t *c) {
  locker_start1(obj);
  if (obj->collector != c) {
    if (c != NULL) {
      counter_inc_ref(c->count);
    }
    if (obj->collector != NULL) {
      counter_dec_ref(obj->collector->count);
    }
    obj->collector = c;
  }
  locker_end();
}
Example #2
0
static void object_del(Object *obj) {
  locker_start1(&obj->lock);
  object_set_collector(obj, NULL);
  assert(hashtable_size(obj->links) == 0);  // make *sure* there are no links
  hashtable_destroy(obj->links);
  obj->magic = 0;
  if (obj->dtor != NULL) {
    obj->dtor(obj->data);
  }
  locker_end();
  free(obj);  // free the memory
  acid_collect_count++;
}
Example #3
0
int main(int argc, char **argv)
{
  locker_context context;

  if (argc != 2)
    {
      fprintf(stderr, "Usage: atconvert filename\n");
      exit(1);
    }

  if (getuid() != 0)
    {
      fprintf(stderr, "You must be root to run this program.\n");
      exit(1);
    }

  if (locker_init(&context, 0, NULL, NULL))
    exit(1);
  locker_convert_attachtab(context, argv[1]);
  locker_end(context);

  return 0;
}
Example #4
0
int fsid_main(int argc, char **argv)
{
  locker_context context;
  int mode = FSID_WHATEVER, op = LOCKER_AUTH_AUTHENTICATE;
  struct hostent *h;
  int status, estatus = 0, opt, gotname = 0;
  uid_t uid = getuid();

  if (locker_init(&context, uid, NULL, NULL))
    exit(1);

  while (optind < argc)
    {
      while ((opt = attach_getopt(argc, argv, fsid_options)) != -1)
	{
	  switch (opt)
	    {
	    case 'a':
	      if (op == LOCKER_AUTH_PURGE ||
		  op == LOCKER_AUTH_PURGEUSER)
		{
		  locker_iterate_attachtab(context, NULL, NULL,
					   fsid_attachent, &op);
		}
	      else
		{
		  char *cells;

		  locker_iterate_attachtab(context, locker_check_owner, &uid,
					   fsid_attachent, &op);
		  cells = getenv("FSID_EXTRA_CELLS");
		  if (cells)
		    fsid_auth_to_cells(context, cells, op);
		}
	      gotname++;
	      break;

	    case 'c':
	      mode = FSID_CELL;
	      break;

	    case 'f':
	      mode = FSID_FILESYSTEM;
	      break;

	    case 'h':
	      mode = FSID_HOST;
	      break;

	    case 'm':
	      op = LOCKER_AUTH_AUTHENTICATE;
	      break;

	    case 'p':
	      op = LOCKER_AUTH_PURGE;
	      break;

	    case 'q':
	      verbose = 0;
	      break;

	    case 'r':
	      op = LOCKER_AUTH_PURGEUSER;
	      break;

	    case 'u':
	      op = LOCKER_AUTH_UNAUTHENTICATE;
	      break;

	    case 'v':
	      verbose = 1;
	      break;

	    case 'd':
	    case 'U':
	      fprintf(stderr, "%s: The '%c' flag is no longer supported.\n",
		      whoami, opt);
	      break;

	    default:
	      usage();
	    }
	}

      while (optind < argc && argv[optind][0] != '-')
	{
	  gotname++;
	  switch (mode)
	    {
	    case FSID_WHATEVER:
	    case FSID_HOST:
	      h = gethostbyname(argv[optind]);
	      if (h)
		{
		  status = locker_auth_to_host(context, whoami,
					       argv[optind], op);
		  if (status != LOCKER_SUCCESS)
		    estatus = 2;
		  break;
		}
	      else if (mode == FSID_HOST)
		{
		  fprintf(stderr, "%s: Could not resolve hostname \"%s\".\n",
			  whoami, argv[optind]);
		  estatus = 2;
		}
	      /* else if (mode == FSID_WHATEVER), fall through */

	    case FSID_FILESYSTEM:
	      status = locker_auth(context, argv[optind], op);
	      if (status != LOCKER_SUCCESS)
		estatus = 2;
	      break;

	    case FSID_CELL:
	      status = locker_auth_to_cell(context, whoami, argv[optind], op);
	      if (status != LOCKER_SUCCESS)
		estatus = 2;
	      break;
	    }

	  if (verbose && status == LOCKER_SUCCESS)
	    printf("%s: %s %s\n", whoami, argv[optind], opped(op));

	  optind++;
	}
    }

  if (!gotname)
    usage();
  locker_end(context);
  exit(estatus);
}