Exemple #1
0
int 
AclCheckPermWin(struct acluser *u, int mode, struct win *w)
{
  int ok;

  if (mode < 0 || mode >= ACL_BITS_PER_WIN)
    return -1;
  if (EffectiveAclUser)
    {
      debug1("AclCheckPermWin: WARNING user %s overridden!\n", u->u_name);
      u = EffectiveAclUser;
    }
  ok = ACLBYTE(w->w_userbits[mode], u->u_id) & ACLBIT(u->u_id);
  debug3("AclCheckPermWin(%s, %d, %d) = ", u->u_name, mode, w->w_number);

  if (!ok)
    {
      struct aclusergroup **g = &u->u_group;
      struct acluser *saved_eff = EffectiveAclUser;

      EffectiveAclUser = NULL;
      while (*g)
        {
	  if (!AclCheckPermWin((*g)->u, mode, w))
	    break;
	  g = &(*g)->next;
	}
      EffectiveAclUser = saved_eff;
      if (*g)
        ok = 1;
    }
  debug1("%d\n", !ok);
  return !ok;
}
Exemple #2
0
static int gl_Display_row(ListData *ldata, ListRow *lrow)
{
	Display *d = lrow->data;
	char tbuf[80];
	static char *blockstates[5] = { "nb", "NB", "Z<", "Z>", "BL" };
	Window *w = d->d_fore;
	struct mchar m_current = mchar_blank;
	m_current.attr = A_BD;

	sprintf(tbuf, " %-10.10s%4dx%-4d%10.10s@%-16.16s%s",
		d->d_termname, d->d_width, d->d_height, d->d_user->u_name,
		d->d_usertty,
		(d->d_blocked || d->d_nonblock >= 0) && d->d_blocked <= 4 ? blockstates[d->d_blocked] : "  ");

	if (w) {
		int l = 10 - strlen(w->w_title);
		if (l < 0)
			l = 0;
		sprintf(tbuf + strlen(tbuf), "%3d(%.10s)%*s%c%c%c%c", w->w_number, w->w_title, l, "",
			/* w->w_dlist->next */ 0 ? '&' : ' ',
			/*
			 * The rwx triple:
			 * -,r,R      no read, read, read only due to foreign wlock
			 * -,.,w,W    no write, write suppressed by foreign wlock,
			 *            write, own wlock
			 * -,x        no execute, execute
			 */
			(AclCheckPermWin(d->d_user, ACL_READ, w) ? '-' :
			 ((w->w_wlock == WLOCK_OFF || d->d_user == w->w_wlockuser) ?
			  'r' : 'R')),
			(AclCheckPermWin(d->d_user, ACL_READ, w) ? '-' :
			 ((w->w_wlock == WLOCK_OFF) ? 'w' :
			  ((d->d_user == w->w_wlockuser) ? 'W' : 'v'))),
			(AclCheckPermWin(d->d_user, ACL_READ, w) ? '-' : 'x')
		    );
	}
	leftline(tbuf, lrow->y, lrow == ldata->selected ? &mchar_so : d == display ? &m_current : 0);

	return 1;
}