/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Copyright (C) 2005 Cluster File Systems, Inc.
+ * GPL HEADER START
*
- * Author: Lai Siyao <lsy@clusterfs.com>
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
*
- * This file is part of Lustre, http://www.lustre.org.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
*
- * Lustre is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
*
- * Lustre is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * lustre/obdfilter/filter_capa.c
*
- * You should have received a copy of the GNU General Public License
- * along with Lustre; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * Author: Lai Siyao <lsy@clusterfs.com>
*/
#define DEBUG_SUBSYSTEM S_FILTER
#include "filter_internal.h"
-/*
- * FIXME
- * keep this as simple as possible. we suppose the blacklist usually
- * be empry or very short (<5), since long term blacklist should be
- * done on MDS side. A more sophisticated blacklist will be implemented
- * later.
- *
- * note blacklist didn't take effect when OSS capability disabled. this
- * looks reasonable to me.
- */
-#define BLACKLIST_MAX (32)
-static int nblacklist = 0;
-static uid_t blacklist[BLACKLIST_MAX];
-static spinlock_t blacklist_lock = SPIN_LOCK_UNLOCKED;
-
-int blacklist_display(char *buf, int bufsize)
-{
- char one[16];
- int i;
- LASSERT(buf);
-
- buf[0] = '\0';
- spin_lock(&blacklist_lock);
- for (i = 0; i < nblacklist; i++) {
- snprintf(one, 16, "%u\n", blacklist[i]);
- strncat(buf, one, bufsize);
- }
- spin_unlock(&blacklist_lock);
- return strnlen(buf, bufsize);
-}
-
-void blacklist_add(uid_t uid)
-{
- int i;
-
- spin_lock(&blacklist_lock);
- if (nblacklist == BLACKLIST_MAX) {
- CERROR("can't add more in blacklist\n");
- spin_unlock(&blacklist_lock);
- return;
- }
-
- for (i = 0; i < nblacklist; i++) {
- if (blacklist[i] == uid) {
- spin_unlock(&blacklist_lock);
- return;
- }
- }
-
- blacklist[nblacklist++] = uid;
- spin_unlock(&blacklist_lock);
-}
-
-void blacklist_del(uid_t uid)
-{
- int i;
-
- spin_lock(&blacklist_lock);
- for (i = 0; i < nblacklist; i++) {
- if (blacklist[i] == uid) {
- nblacklist--;
- while (i < nblacklist) {
- blacklist[i] = blacklist[i+1];
- i++;
- }
- spin_unlock(&blacklist_lock);
- return;
- }
- }
- spin_unlock(&blacklist_lock);
-}
-
-static int blacklist_check(uid_t uid)
-{
- int i, rc = 0;
-
- spin_lock(&blacklist_lock);
- for (i = 0; i < nblacklist; i++) {
- if (blacklist[i] == uid) {
- rc = 1;
- break;
- }
- }
- spin_unlock(&blacklist_lock);
- return rc;
-}
-
static inline __u32 filter_ck_keyid(struct filter_capa_key *key)
{
return key->k_key.lk_keyid;
OBD_ALLOC_PTR(k);
if (!k)
RETURN(-ENOMEM);
- INIT_LIST_HEAD(&k->k_list);
+ CFS_INIT_LIST_HEAD(&k->k_list);
}
spin_lock(&capa_lock);
RETURN(-EACCES);
}
- if (blacklist_check(capa->lc_uid)) {
- DEBUG_CAPA(D_ERROR, capa, "uid %u found in blacklist,",
- capa->lc_uid);
- RETURN(-EACCES);
- }
-
-#warning "enable fid check in filter_auth_capa() when fid stored in OSS object"
-
if (opc == CAPA_OPC_OSS_READ) {
if (!(capa->lc_opc & CAPA_OPC_OSS_RW))
rc = -EACCES;