From: Patrick McHardy <kaber@trash.net>
To: Netfilter Development Mailinglist <netfilter-devel@lists.netfilter.org>
Subject: [RFC][PATCH]: match supplementary gids in owner match
Date: Thu, 17 Jul 2003 15:38:46 +0200 [thread overview]
Message-ID: <3F16A6E6.8060900@trash.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 410 bytes --]
This patch adds support for matching supplementary gids to the owner match.
I wrote it for someone else, i haven't even tested it. According to him,
it works as
expected. If someone likes it, feel free to add to pom. I was thinking
about making
an extra flag so normal behaviour would be as before and matching
supplementary
gid matching would be optional. If someone wants this, just tell me.
Bye
Patrick
[-- Attachment #2: ipt_owner-supgids.diff --]
[-- Type: text/plain, Size: 1531 bytes --]
===== net/ipv4/netfilter/ipt_owner.c 1.3 vs edited =====
--- 1.3/net/ipv4/netfilter/ipt_owner.c Thu Aug 8 16:55:29 2002
+++ edited/net/ipv4/netfilter/ipt_owner.c Mon Jul 14 19:25:36 2003
@@ -109,6 +109,49 @@
}
static int
+match_gid(const struct sk_buff *skb, gid_t gid)
+{
+ struct task_struct *p;
+ struct files_struct *files;
+ int i;
+
+ /* direct match */
+ if (gid == skb->sk->socket->file->f_gid)
+ return 1;
+
+ /* find owner of socket and check supplementary gids */
+ read_lock(&tasklist_lock);
+ for_each_task(p) {
+ /* racy, owner could have called setfsgid */
+ if (p->fsgid != skb->sk->socket->file->f_gid)
+ continue;
+
+ task_lock(p);
+ files = p->files;
+ if(files) {
+ read_lock(&files->file_lock);
+ for (i=0; i < files->max_fds; i++) {
+ if (fcheck_files(files, i) == skb->sk->socket->file) {
+ int j, ret = 0;
+ read_unlock(&files->file_lock);
+ for (j = 0; j < p->ngroups; j++)
+ if (p->groups[j] == gid) {
+ ret = 1;
+ break;
+ }
+ task_unlock(p);
+ read_unlock(&tasklist_lock);
+ return ret;
+ }
+ }
+ read_unlock(&files->file_lock);
+ }
+ task_unlock(p);
+ }
+ read_unlock(&tasklist_lock);
+ return 0;
+}
+static int
match(const struct sk_buff *skb,
const struct net_device *in,
const struct net_device *out,
@@ -130,7 +173,7 @@
}
if(info->match & IPT_OWNER_GID) {
- if((skb->sk->socket->file->f_gid != info->gid) ^
+ if(!match_gid(skb, info->gid) ^
!!(info->invert & IPT_OWNER_GID))
return 0;
}
reply other threads:[~2003-07-17 13:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3F16A6E6.8060900@trash.net \
--to=kaber@trash.net \
--cc=netfilter-devel@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.