~ubuntu-branches/ubuntu/quantal/pam/quantal

« back to all changes in this revision

Viewing changes to debian/patches-applied/027_pam_limits_better_init_allow_explicit_root

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2011-08-18 16:41:18 UTC
  • mfrom: (3.2.18 sid)
  • Revision ID: james.westby@ubuntu.com-20110818164118-cf7d03vgguzzzwxc
Tags: 1.1.3-2ubuntu1
* Merge with Debian to get bug fix for unknown kernel rlimits. 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.
  - Change Vcs-Bzr to point at the Ubuntu branch.
  - 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.
  - 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)
  - debian/libpam0g.postinst: drop kdm from the list of services to
    restart.
  - debian/libpam0g.postinst: check if gdm is actually running before
    trying to reload it.
  - debian/local/common-session{,-noninteractive}: Enable pam_umask by
    default, now that the umask setting is gone from /etc/profile.
  - debian/local/pam-auth-update: Add the new md5sums for pam_umask addition.
  - add debian/patches-applied/pam_umask_usergroups_from_login.defs.patch:
    Deprecate pam_unix' explicit "usergroups" option and instead read it
    from /etc/login.def's "USERGROUP_ENAB" option if umask is only defined
    there. This restores compatibility with the pre-PAM behaviour of login.
    (Closes: #583958)
* Dropped changes:
  - debian/patches-applied/027_pam_limits_better_init_allow_explicit_root:
    no need to bump the hard limit for number of file descriptors any more
    since we read kernel limits directly now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
Bug-Debian: http://bugs.debian.org/63230
20
20
Bug-Debian: http://bugs.debian.org/620302
21
21
Forwarded: https://fedorahosted.org/pipermail/pam-developers/2011-March/000017.html
22
 
Index: pam.deb/modules/pam_limits/pam_limits.c
 
22
Index: pam-debian/modules/pam_limits/pam_limits.c
23
23
===================================================================
24
 
--- pam.deb.orig/modules/pam_limits/pam_limits.c
25
 
+++ pam.deb/modules/pam_limits/pam_limits.c
 
24
--- pam-debian.orig/modules/pam_limits/pam_limits.c
 
25
+++ pam-debian/modules/pam_limits/pam_limits.c
26
26
@@ -45,15 +45,24 @@
27
27
 #include <libaudit.h>
28
28
 #endif
67
67
     int login_limit;     /* the max logins limit */
68
68
     int login_limit_def; /* which entry set the login limit */
69
69
     int flag_numsyslogins; /* whether to limit logins only for a
70
 
@@ -291,13 +302,154 @@
 
70
@@ -291,13 +302,155 @@
71
71
     return 0;
72
72
 }
73
73
 
141
141
+        item = line + pos + 1; \
142
142
+}
143
143
+
144
 
+static void parse_kernel_limits(pam_handle_t *pamh, struct pam_limit_s *pl)
 
144
+static void parse_kernel_limits(pam_handle_t *pamh, struct pam_limit_s *pl, int ctrl)
145
145
+{
146
146
+    int i, maxlen = 0;
147
147
+    FILE *limitsfile;
193
193
+
194
194
+        i = str2rlimit(name);
195
195
+        if (i < 0 || i >= RLIM_NLIMITS) {
196
 
+            pam_syslog(pamh, LOG_DEBUG, "Unknown kernel rlimit '%s' ignored", name);
 
196
+            if (ctrl & PAM_DEBUG_ARG)
 
197
+                pam_syslog(pamh, LOG_DEBUG, "Unknown kernel rlimit '%s' ignored", name);
197
198
+            continue;
198
199
+        }
199
200
+        pl->limits[i].limit.rlim_cur = str2rlim_t(soft);
204
205
+    fclose(limitsfile);
205
206
+}
206
207
+
207
 
+static int init_limits(pam_handle_t *pamh, struct pam_limit_s *pl)
 
208
+static int init_limits(pam_handle_t *pamh, struct pam_limit_s *pl, int ctrl)
208
209
 {
209
210
     int i;
210
211
     int retval = PAM_SUCCESS;
223
224
     for(i = 0; i < RLIM_NLIMITS; i++) {
224
225
        int r = getrlimit(i, &pl->limits[i].limit);
225
226
        if (r == -1) {
226
 
@@ -312,6 +464,71 @@
 
227
@@ -312,6 +465,71 @@
227
228
        }
228
229
     }
229
230
 
230
231
+#ifdef __linux__
231
 
+    parse_kernel_limits(pamh, pl);
 
232
+    parse_kernel_limits(pamh, pl, ctrl);
232
233
+#endif
233
234
+
234
235
+    for(i = 0; i < RLIM_NLIMITS; i++) {
282
283
+                   break;
283
284
+               case RLIMIT_NOFILE:
284
285
+                   pl->limits[i].limit.rlim_cur = 1024;
285
 
+                   pl->limits[i].limit.rlim_max = 4096;
 
286
+                   pl->limits[i].limit.rlim_max = 1024;
286
287
+                   break;
287
288
+               default:
288
289
+                   pl->limits[i].src_soft = LIMITS_DEF_NONE;
295
296
     errno = 0;
296
297
     pl->priority = getpriority (PRIO_PROCESS, 0);
297
298
     if (pl->priority == -1 && errno != 0)
298
 
@@ -591,7 +808,7 @@
 
299
@@ -591,7 +809,7 @@
299
300
 
300
301
             if (strcmp(uname, domain) == 0) /* this user have a limit */
301
302
                 process_limit(pamh, LIMITS_DEF_USER, ltype, item, value, ctrl, pl);
304
305
                    if (ctrl & PAM_DEBUG_ARG) {
305
306
                        pam_syslog(pamh, LOG_DEBUG,
306
307
                                   "checking if %s is in group %s",
307
 
@@ -600,7 +817,7 @@
 
308
@@ -600,7 +818,7 @@
308
309
                 if (pam_modutil_user_in_group_nam_nam(pamh, uname, domain+1))
309
310
                     process_limit(pamh, LIMITS_DEF_GROUP, ltype, item, value, ctrl,
310
311
                                  pl);
313
314
                    if (ctrl & PAM_DEBUG_ARG) {
314
315
                        pam_syslog(pamh, LOG_DEBUG,
315
316
                                   "checking if %s is in group %s",
316
 
@@ -614,7 +831,7 @@
 
317
@@ -614,7 +832,7 @@
317
318
                     process_limit(pamh, LIMITS_DEF_ALLGROUP, ltype, item, value, ctrl,
318
319
                                  pl);
319
320
                }
322
323
                 process_limit(pamh, LIMITS_DEF_DEFAULT, ltype, item, value, ctrl,
323
324
                              pl);
324
325
        } else if (i == 2 && ltype[0] == '-') { /* Probably a no-limit line */
325
 
@@ -649,6 +866,12 @@
326
 
     int status;
327
 
     int retval = LIMITED_OK;
328
 
 
329
 
+    if (uid == 0) {
330
 
+        /* do not impose +ve priority limits on the superuser */
331
 
+        if (pl->priority > 0)
332
 
+            pl->priority = 0;
333
 
+    }
334
 
+
335
 
     for (i=0, status=LIMITED_OK; i<RLIM_NLIMITS; i++) {
336
 
       int res;
337
 
 
338
 
@@ -743,12 +966,14 @@
 
326
@@ -743,12 +961,14 @@
339
327
         return PAM_USER_UNKNOWN;
340
328
     }
341
329
 
342
330
-    retval = init_limits(pl);
343
 
+    retval = init_limits(pamh, pl);
 
331
+    retval = init_limits(pamh, pl, ctrl);
344
332
     if (retval != PAM_SUCCESS) {
345
333
         pam_syslog(pamh, LOG_WARNING, "cannot initialize");
346
334
         return PAM_ABORT;
351
339
     retval = parse_config_file(pamh, pwd->pw_name, ctrl, pl);
352
340
     if (retval == PAM_IGNORE) {
353
341
        D(("the configuration file ('%s') has an applicable '<domain> -' entry", CONF_FILE));
354
 
Index: pam.deb/modules/pam_limits/limits.conf
 
342
Index: pam-debian/modules/pam_limits/limits.conf
355
343
===================================================================
356
 
--- pam.deb.orig/modules/pam_limits/limits.conf
357
 
+++ pam.deb/modules/pam_limits/limits.conf
 
344
--- pam-debian.orig/modules/pam_limits/limits.conf
 
345
+++ pam-debian/modules/pam_limits/limits.conf
358
346
@@ -11,6 +11,9 @@
359
347
 #        - the wildcard *, for default entry
360
348
 #        - the wildcard %, can be also used with %group syntax,
373
361
 #*               hard    rss             10000
374
362
 #@student        hard    nproc           20
375
363
 #@faculty        soft    nproc           20
376
 
Index: pam.deb/modules/pam_limits/limits.conf.5.xml
 
364
Index: pam-debian/modules/pam_limits/limits.conf.5.xml
377
365
===================================================================
378
 
--- pam.deb.orig/modules/pam_limits/limits.conf.5.xml
379
 
+++ pam.deb/modules/pam_limits/limits.conf.5.xml
 
366
--- pam-debian.orig/modules/pam_limits/limits.conf.5.xml
 
367
+++ pam-debian/modules/pam_limits/limits.conf.5.xml
380
368
@@ -57,6 +57,11 @@
381
369
               </para>
382
370
             </listitem>
397
385
 *               hard    rss             10000
398
386
 @student        hard    nproc           20
399
387
 @faculty        soft    nproc           20
400
 
Index: pam.deb/modules/pam_limits/limits.conf.5
 
388
Index: pam-debian/modules/pam_limits/limits.conf.5
401
389
===================================================================
402
 
--- pam.deb.orig/modules/pam_limits/limits.conf.5
403
 
+++ pam.deb/modules/pam_limits/limits.conf.5
 
390
--- pam-debian.orig/modules/pam_limits/limits.conf.5
 
391
+++ pam-debian/modules/pam_limits/limits.conf.5
404
392
@@ -93,6 +93,11 @@
405
393
 \fI%group\fR
406
394
 syntax\&.
421
409
 *               hard    rss             10000
422
410
 @student        hard    nproc           20
423
411
 @faculty        soft    nproc           20
424
 
Index: pam.deb/modules/pam_limits/README
 
412
Index: pam-debian/modules/pam_limits/README
425
413
===================================================================
426
 
--- pam.deb.orig/modules/pam_limits/README
427
 
+++ pam.deb/modules/pam_limits/README
 
414
--- pam-debian.orig/modules/pam_limits/README
 
415
+++ pam-debian/modules/pam_limits/README
428
416
@@ -55,6 +55,7 @@
429
417
 limits.conf.
430
418