Example #1
0
/* Get quotas for all owners of top-level directories, optionally
 * filtered by uids.
 */
static void
dirscan(confent_t *cp, List qlist, List uids, int getusername)
{
    struct passwd *pw;
    struct dirent *dp;
    DIR *dir;
    char fqp[MAXPATHLEN];
    struct stat sb;
    quota_t q;
    char name[32];

    if (!(dir = opendir(cp->cf_rpath))) {
        fprintf(stderr, "%s: could not open %s\n", prog, cp->cf_rpath);
        exit(1);
    }
    while ((dp = readdir(dir))) {
        if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
            continue;
        snprintf(fqp, sizeof(fqp), "%s/%s", cp->cf_rpath, dp->d_name);
        if (stat(fqp, &sb) < 0)
            continue;
        if (uids && !listint_member(uids, sb.st_uid))
            continue;
        if (getusername) {
            if ((pw = getpwuid(sb.st_gid)))
                snprintf (name, sizeof(name), "%s", pw->pw_name);
            else
                snprintf (name, sizeof(name), "[%s]", dp->d_name);
            add_quota(cp, qlist, sb.st_gid, name);
        } else
            add_quota(cp, qlist, sb.st_gid, NULL);
    }
    if (closedir(dir) < 0)
        fprintf(stderr, "%s: closedir %s: %m\n", prog, cp->cf_rpath);
}
Example #2
0
static void 
link_exit(dbref player, dbref exit, dbref dest, int key)
{
    int cost, quot;

    /* Make sure we can link there */

    if ((dest != HOME) &&
	((!controls(player, dest) && !Link_ok(dest)) ||
	 !could_doit(player, dest, A_LLINK, 1, 0))) {
	notify_quiet(player, "Permission denied.");
	return;
    }
    /* Exit must be unlinked or controlled by you */

    if ((Location(exit) != NOTHING) && !controls(player, exit)) {
	notify_quiet(player, "Permission denied.");
	return;
    }
    /* If exit is unlinked and mudconf 'paranoid_exit_linking' is enabled
     * Do not allow the exit to be linked if you do not control it
     */
    if ( (mudconf.paranoid_exit_linking == 1) && !controls(player,exit) ) {
        notify_quiet(player, "Permission denied.");
	return;
    }

    /* handle costs */

    cost = mudconf.linkcost;
    quot = 0;
    if (Owner(exit) != Owner(player)) {
	cost += mudconf.opencost;
	quot += mudconf.exit_quota;
    }
    if (!canpayfees(player, player, cost, quot, TYPE_EXIT))
	return;

    /* Pay the owner for his loss */

    /* Ok, if paranoid_exit_linking is enabled the linker does NOT own exit */
    if (!(mudconf.paranoid_exit_linking)) {
       if (Owner(exit) != Owner(player)) {
	   giveto(Owner(exit), mudconf.opencost, NOTHING);
	   add_quota(Owner(exit), quot, TYPE_EXIT);
	   s_Owner(exit, Owner(player));
	   s_Flags(exit, (Flags(exit) & ~(INHERIT | WIZARD)) | HALT);
       }
    }
    /* link has been validated and paid for, do it and tell the player */

    s_Location(exit, dest);
    if (!(Quiet(player) || (key & SIDEEFFECT)) )
	notify_quiet(player, "Linked.");
}
Example #3
0
/* Get quotas for all users in the password file, optionally filtered
 * by uids list.
 */
static void
pwscan(confent_t *cp, List qlist, List uids, int getusername)
{
    struct group *gr;
    quota_t q;

    while ((gr = getgrent()) != NULL) {
        if (uids && !listint_member(uids, gr->gr_gid))
            continue;
        add_quota(cp, qlist, gr->gr_gid, getusername ? gr->gr_name : NULL);
    }
}
Example #4
0
/* Get quotas for all uid's in uids list.
 */
static void
uidscan(confent_t *cp, List qlist, List uids, int getusername)
{
    struct passwd *pw;
    ListIterator itr;
    quota_t q;
    unsigned long *up;
    int rc;
    char name[32];

    itr = list_iterator_create(uids);
    while ((up = list_next(itr))) {
        if (getusername) {
            if ((pw = getpwuid ((uid_t)*up)))
                snprintf (name, sizeof(name), "%s", pw->pw_name);
            else 
                snprintf (name, sizeof(name), "[%lu]", *up);
            add_quota(cp, qlist, pw->pw_gid, name);
        } else
            add_quota(cp, qlist, (uid_t)*up, NULL);
    }
    list_iterator_destroy(itr);
}
Example #5
0
cupsd_quota_t *				/* O - Quota data */
cupsdFindQuota(
    cupsd_printer_t *p,			/* I - Printer */
    const char      *username)		/* I - User */
{
  cupsd_quota_t	*q,			/* Quota data pointer */
		match;			/* Search data */
  char		*ptr;			/* Pointer into username */


  if (!p || !username)
    return (NULL);

  strlcpy(match.username, username, sizeof(match.username));
  if ((ptr = strchr(match.username, '@')) != NULL)
    *ptr = '\0';			/* Strip @domain/@KDC */

  if ((q = (cupsd_quota_t *)cupsArrayFind(p->quotas, &match)) != NULL)
    return (q);
  else
    return (add_quota(p, username));
}