diff options
Diffstat (limited to 'debian')
-rw-r--r-- | debian/changelog | 4 | ||||
-rw-r--r-- | debian/patches/user-group-modes.patch | 41 |
2 files changed, 37 insertions, 8 deletions
diff --git a/debian/changelog b/debian/changelog index a27f3b57f..60d985e2f 100644 --- a/debian/changelog +++ b/debian/changelog | |||
@@ -9,6 +9,10 @@ openssh (1:5.5p1-4) UNRELEASED; urgency=low | |||
9 | group-writable, provided that the group in question contains only the | 9 | group-writable, provided that the group in question contains only the |
10 | file's owner; this extends a patch previously applied to ~/.ssh/config | 10 | file's owner; this extends a patch previously applied to ~/.ssh/config |
11 | (closes: #581919). | 11 | (closes: #581919). |
12 | * Check primary group memberships as well as supplementary group | ||
13 | memberships, and only allow group-writability by groups with exactly one | ||
14 | member, as zero-member groups are typically used by setgid binaries | ||
15 | rather than being user-private groups (closes: #581697). | ||
12 | 16 | ||
13 | -- Colin Watson <cjwatson@debian.org> Tue, 04 May 2010 13:32:17 +0100 | 17 | -- Colin Watson <cjwatson@debian.org> Tue, 04 May 2010 13:32:17 +0100 |
14 | 18 | ||
diff --git a/debian/patches/user-group-modes.patch b/debian/patches/user-group-modes.patch index 8cf862049..164b8ec81 100644 --- a/debian/patches/user-group-modes.patch +++ b/debian/patches/user-group-modes.patch | |||
@@ -109,7 +109,7 @@ Index: b/misc.c | |||
109 | #ifdef SSH_TUN_OPENBSD | 109 | #ifdef SSH_TUN_OPENBSD |
110 | #include <net/if.h> | 110 | #include <net/if.h> |
111 | #endif | 111 | #endif |
112 | @@ -638,6 +639,30 @@ | 112 | @@ -638,6 +639,55 @@ |
113 | } | 113 | } |
114 | 114 | ||
115 | int | 115 | int |
@@ -117,22 +117,47 @@ Index: b/misc.c | |||
117 | +{ | 117 | +{ |
118 | + if (st->st_uid != 0 && st->st_uid != uid) | 118 | + if (st->st_uid != 0 && st->st_uid != uid) |
119 | + return 0; | 119 | + return 0; |
120 | + if ((st->st_mode & 002) != 0) | ||
121 | + return 0; | ||
120 | + if ((st->st_mode & 020) != 0) { | 122 | + if ((st->st_mode & 020) != 0) { |
121 | + /* If the file is group-writable, the group in question must | 123 | + /* If the file is group-writable, the group in question must |
122 | + * have at most one member, namely the file's owner. | 124 | + * have exactly one member, namely the file's owner. |
125 | + * (Zero-member groups are typically used by setgid | ||
126 | + * binaries, and are unlikely to be suitable.) | ||
123 | + */ | 127 | + */ |
124 | + struct passwd *pw = getpwuid(st->st_uid); | 128 | + struct passwd *pw; |
125 | + struct group *gr = getgrgid(st->st_gid); | 129 | + struct group *gr; |
126 | + if (!pw || !gr) | 130 | + int members = 0; |
131 | + | ||
132 | + gr = getgrgid(st->st_gid); | ||
133 | + if (!gr) | ||
134 | + return 0; | ||
135 | + | ||
136 | + /* Check primary group memberships. */ | ||
137 | + while ((pw = getpwent()) != NULL) { | ||
138 | + if (pw->pw_gid == gr->gr_gid) { | ||
139 | + ++members; | ||
140 | + if (pw->pw_uid != uid) | ||
141 | + return 0; | ||
142 | + } | ||
143 | + } | ||
144 | + endpwent(); | ||
145 | + | ||
146 | + pw = getpwuid(st->st_uid); | ||
147 | + if (!pw) | ||
127 | + return 0; | 148 | + return 0; |
128 | + else if (gr->gr_mem[0]) { | 149 | + |
150 | + /* Check supplementary group memberships. */ | ||
151 | + if (gr->gr_mem[0]) { | ||
152 | + ++members; | ||
129 | + if (strcmp(pw->pw_name, gr->gr_mem[0]) || | 153 | + if (strcmp(pw->pw_name, gr->gr_mem[0]) || |
130 | + gr->gr_mem[1]) | 154 | + gr->gr_mem[1]) |
131 | + return 0; | 155 | + return 0; |
132 | + } | 156 | + } |
157 | + | ||
158 | + if (!members) | ||
159 | + return 0; | ||
133 | + } | 160 | + } |
134 | + if ((st->st_mode & 002) != 0) | ||
135 | + return 0; | ||
136 | + return 1; | 161 | + return 1; |
137 | +} | 162 | +} |
138 | + | 163 | + |