~ubuntu-branches/ubuntu/oneiric/pam/oneiric-proposed

« back to all changes in this revision

Viewing changes to debian/patches-applied/hurd_no_setfsuid

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2011-02-17 16:15:47 UTC
  • mfrom: (3.2.15 sid)
  • Revision ID: james.westby@ubuntu.com-20110217161547-afxi0yboxvn18a5t
Tags: 1.1.2-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/libpam-modules.postinst: Add PATH to /etc/environment if it's
    not present there or in /etc/security/pam_env.conf. (should send to
    Debian).
  - debian/libpam0g.postinst: only ask questions during update-manager when
    there are non-default services running.
  - debian/patches-applied/series: Ubuntu patches are as below ...
  - debian/patches-applied/ubuntu-rlimit_nice_correction: Explicitly
    initialise RLIMIT_NICE rather than relying on the kernel limits.
  - Change Vcs-Bzr to point at the Ubuntu branch.
  - debian/patches-applied/pam_motd-legal-notice: display the contents of
    /etc/legal once, then set a flag in the user's homedir to prevent
    showing it again.
  - debian/update-motd.5, debian/libpam-modules.manpages: add a manpage
    for update-motd, with some best practices and notes of explanation.
  - debian/patches/update-motd-manpage-ref: add a reference in pam_motd(8)
    to update-motd(5)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
Upstream status: superseded by pam_modutil_set_euid proposal
6
6
 
7
 
Index: pam.deb/modules/pam_xauth/pam_xauth.c
 
7
Index: pam.debian/modules/pam_xauth/pam_xauth.c
8
8
===================================================================
9
 
--- pam.deb.orig/modules/pam_xauth/pam_xauth.c
10
 
+++ pam.deb/modules/pam_xauth/pam_xauth.c
 
9
--- pam.debian.orig/modules/pam_xauth/pam_xauth.c
 
10
+++ pam.debian/modules/pam_xauth/pam_xauth.c
11
11
@@ -35,7 +35,9 @@
12
12
 
13
13
 #include "config.h"
18
18
 #include <sys/wait.h>
19
19
 #include <errno.h>
20
20
 #include <fnmatch.h>
21
 
@@ -218,6 +220,9 @@
 
21
@@ -235,6 +237,9 @@
22
22
        FILE *fp;
23
 
        int i;
 
23
        int i, save_errno;
24
24
        uid_t euid;
25
25
+#ifndef HAVE_SYS_FSUID_H
26
26
+       uid_t uid;
28
28
        /* Check this user's <sense> file. */
29
29
        pwd = pam_modutil_getpwnam(pamh, this_user);
30
30
        if (pwd == NULL) {
31
 
@@ -234,9 +239,34 @@
 
31
@@ -251,10 +256,35 @@
32
32
                return PAM_SESSION_ERR;
33
33
        }
34
34
        euid = geteuid();
49
49
+       }
50
50
+#endif
51
51
        fp = fopen(path, "r");
 
52
        save_errno = errno;
52
53
+#ifdef HAVE_SYS_FSUID_H
53
54
        setfsuid(euid);
54
55
+#else
63
64
        if (fp != NULL) {
64
65
                char buf[LINE_MAX], *tmp;
65
66
                /* Scan the file for a list of specs of users to "trust". */
66
 
@@ -306,6 +336,9 @@
 
67
@@ -325,6 +355,9 @@
67
68
        int fd, i, debug = 0;
68
69
        int retval = PAM_SUCCESS;
69
70
        uid_t systemuser = 499, targetuser = 0, euid;
73
74
 
74
75
        /* Parse arguments.  We don't understand many, so no sense in breaking
75
76
         * this into a separate function. */
76
 
@@ -554,7 +587,22 @@
 
77
@@ -573,7 +606,22 @@
77
78
 
78
79
                /* Generate a new file to hold the data. */
79
80
                euid = geteuid();
93
94
+                       }
94
95
+               }
95
96
+#endif
96
 
                
 
97
 
97
98
 #ifdef WITH_SELINUX
98
99
                if (is_selinux_enabled() > 0) {
99
 
@@ -584,7 +632,17 @@
 
100
@@ -603,7 +651,17 @@
100
101
                save_errno = errno;
101
102
 #endif
102
103
 
114
115
                if (fd == -1) {
115
116
                        errno = save_errno;
116
117
                        pam_syslog(pamh, LOG_ERR,
 
118
@@ -614,10 +672,35 @@
 
119
                }
 
120
                /* Set permissions on the new file and dispose of the
 
121
                 * descriptor. */
 
122
+#ifdef HAVE_SYS_FSUID_H
 
123
                setfsuid(tpwd->pw_uid);
 
124
+#else
 
125
+               uid = getuid();
 
126
+               if (uid == tpwd->pw_uid)
 
127
+                       setreuid(euid, uid);
 
128
+               else {
 
129
+                       setreuid(0, -1);
 
130
+                       if (setreuid(-1, uid) == -1) {
 
131
+                               setreuid(-1, 0);
 
132
+                               setreuid(0, -1);
 
133
+                               if (setreuid(-1, tpwd->pw_uid))
 
134
+                                       return PAM_CRED_INSUFFICIENT;
 
135
+                       }
 
136
+               }
 
137
+#endif
 
138
                if (fchown(fd, tpwd->pw_uid, tpwd->pw_gid) < 0)
 
139
                  pam_syslog (pamh, LOG_ERR, "fchown: %m");
 
140
+#ifdef HAVE_SYS_FSUID_H
 
141
                setfsuid(euid);
 
142
+#else
 
143
+               if (uid == tpwd->pw_uid)
 
144
+                       setreuid(uid, euid);
 
145
+               else {
 
146
+                       if (setreuid(-1, 0) == -1)
 
147
+                               setreuid(uid, -1);
 
148
+                       setreuid(-1, euid);
 
149
+               }
 
150
+#endif
 
151
                close(fd);
 
152
 
 
153
                /* Get a copy of the filename to save as a data item for
 
154
@@ -718,6 +801,9 @@
 
155
        struct passwd *tpwd;
 
156
        uid_t unlinkuid, euid;
 
157
        unlinkuid = euid = geteuid ();
 
158
+#ifndef HAVE_SYS_FSUID_H
 
159
+       uid_t uid;
 
160
+#endif
 
161
 
 
162
        if (pam_get_user(pamh, &user, NULL) != PAM_SUCCESS)
 
163
                pam_syslog(pamh, LOG_ERR, "error determining target user's name");
 
164
@@ -759,9 +845,34 @@
 
165
                                       (char*)cookiefile);
 
166
                        }
 
167
                        /* NFS with root_squash requires non-root user */
 
168
+#ifdef HAVE_SYS_FSUID_H
 
169
                        setfsuid (unlinkuid);
 
170
+#else
 
171
+                       uid = getuid();
 
172
+                       if (uid == unlinkuid)
 
173
+                               setreuid(euid, uid);
 
174
+                       else {
 
175
+                               setreuid(0, -1);
 
176
+                               if (setreuid(-1, uid) == -1) {
 
177
+                                       setreuid(-1, 0);
 
178
+                                       setreuid(0, -1);
 
179
+                                       if (setreuid(-1, unlinkuid))
 
180
+                                               return PAM_CRED_INSUFFICIENT;
 
181
+                               }
 
182
+                       }
 
183
+#endif
 
184
                        unlink((char*)cookiefile);
 
185
+#ifdef HAVE_SYS_FSUID_H
 
186
                        setfsuid (euid);
 
187
+#else
 
188
+                       if (uid == unlinkuid)
 
189
+                               setreuid(uid, euid);
 
190
+                       else {
 
191
+                               if (setreuid(-1, 0) == -1)
 
192
+                                       setreuid(uid, -1);
 
193
+                               setreuid(-1, euid);
 
194
+                       }
 
195
+#endif
 
196
                        *((char*)cookiefile) = '\0';
 
197
                }
 
198
        }
 
199
Index: pam.debian/modules/pam_env/pam_env.c
 
200
===================================================================
 
201
--- pam.debian.orig/modules/pam_env/pam_env.c
 
202
+++ pam.debian/modules/pam_env/pam_env.c
 
203
@@ -23,7 +23,9 @@
 
204
 #include <string.h>
 
205
 #include <syslog.h>
 
206
 #include <sys/stat.h>
 
207
+#ifdef HAVE_SYS_FSUID_H
 
208
 #include <sys/fsuid.h>
 
209
+#endif
 
210
 #include <sys/types.h>
 
211
 #include <unistd.h>
 
212
 
 
213
@@ -792,9 +794,37 @@
 
214
        }
 
215
       if (stat(envpath, &statbuf) == 0) {
 
216
        uid_t euid = geteuid();
 
217
+
 
218
+#ifdef HAVE_SYS_FSUID_H
 
219
         setfsuid (user_entry->pw_uid);
 
220
+#else
 
221
+       uid_t uid = getuid();
 
222
+       if (uid == user_entry->pw_uid)
 
223
+         setreuid(euid, uid);
 
224
+       else {
 
225
+         setreuid(0, -1);
 
226
+         if (setreuid(-1, uid) == -1) {
 
227
+           setreuid(-1, 0);
 
228
+           setreuid(0, -1);
 
229
+           setreuid(-1, user_entry->pw_uid);
 
230
+           /* If this fails we didn't have root privs anyway, so we fall
 
231
+              through; not the safest, but no different from what we do in
 
232
+              the setfsuid() case. */
 
233
+         }
 
234
+       }
 
235
+#endif
 
236
         retval = _parse_config_file(pamh, envpath);
 
237
+#ifdef HAVE_SYS_FSUID_H
 
238
        setfsuid (euid);
 
239
+#else
 
240
+       if (uid == user_entry->pw_uid)
 
241
+         setreuid(uid, euid);
 
242
+       else {
 
243
+         if (setreuid(-1, 0) == 0)
 
244
+           setreuid(uid, -1);
 
245
+         setreuid(-1, euid);
 
246
+       }
 
247
+#endif
 
248
         if (retval == PAM_IGNORE)
 
249
           retval = PAM_SUCCESS;
 
250
       }
 
251
Index: pam.debian/modules/pam_mail/pam_mail.c
 
252
===================================================================
 
253
--- pam.debian.orig/modules/pam_mail/pam_mail.c
 
254
+++ pam.debian/modules/pam_mail/pam_mail.c
 
255
@@ -17,7 +17,9 @@
 
256
 #include <syslog.h>
 
257
 #include <sys/stat.h>
 
258
 #include <sys/types.h>
 
259
+#ifdef HAVE_SYS_FSUID_H
 
260
 #include <sys/fsuid.h>
 
261
+#endif
 
262
 #include <unistd.h>
 
263
 #include <dirent.h>
 
264
 #include <errno.h>
 
265
@@ -446,9 +448,37 @@
 
266
        || (!est && (ctrl & PAM_LOGOUT_TOO))) {
 
267
         uid_t euid = geteuid();
 
268
 
 
269
+#ifdef HAVE_SYS_FSUID_H
 
270
         setfsuid (pwd->pw_uid);
 
271
+#else
 
272
+       uid_t uid = getuid();
 
273
+
 
274
+       if (uid == pwd->pw_uid)
 
275
+         setreuid(euid, uid);
 
276
+       else {
 
277
+         setreuid(0, -1);
 
278
+         if (setreuid(-1, uid) == -1) {
 
279
+           setreuid(-1, 0);
 
280
+           setreuid(0, -1);
 
281
+           setreuid(-1, pwd->pw_uid);
 
282
+           /* If this fails we didn't have root privs anyway, so we fall
 
283
+              through; not the safest, but no different from what we do in
 
284
+              the setfsuid() case. */
 
285
+         }
 
286
+       }
 
287
+#endif
 
288
        type = get_mail_status(pamh, ctrl, folder);
 
289
+#ifdef HAVE_SYS_FSUID_H
 
290
        setfsuid (euid);
 
291
+#else
 
292
+       if (uid == pwd->pw_uid)
 
293
+         setreuid(uid, euid);
 
294
+       else {
 
295
+         if (setreuid(-1, 0) == 0)
 
296
+           setreuid(uid, -1);
 
297
+         setreuid(-1, euid);
 
298
+       }
 
299
+#endif
 
300
 
 
301
        if (type != 0) {
 
302
            retval = report_mail(pamh, ctrl, type, folder);