diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | session.c | 48 |
2 files changed, 42 insertions, 10 deletions
@@ -1,3 +1,7 @@ | |||
1 | 20000711 | ||
2 | - (djm) Fixup for AIX getuserattr() support from Tom Bertelson | ||
3 | <tbert@abac.com> | ||
4 | |||
1 | 20000709 | 5 | 20000709 |
2 | - (djm) Only enable PAM_TTY kludge for Linux. Problem report from | 6 | - (djm) Only enable PAM_TTY kludge for Linux. Problem report from |
3 | Kevin Steves <stevesk@sweden.hp.com> | 7 | Kevin Steves <stevesk@sweden.hp.com> |
@@ -799,24 +799,52 @@ void do_pam_environment(char ***env, int *envsize) | |||
799 | void set_limit(char *user, char *soft, char *hard, int resource, int mult) | 799 | void set_limit(char *user, char *soft, char *hard, int resource, int mult) |
800 | { | 800 | { |
801 | struct rlimit rlim; | 801 | struct rlimit rlim; |
802 | rlim_t tlim; | 802 | int slim, hlim; |
803 | int mask; | ||
804 | 803 | ||
805 | getrlimit(resource, &rlim); | 804 | getrlimit(resource, &rlim); |
806 | 805 | ||
807 | tlim = (rlim_t) 0; | 806 | slim = 0; |
808 | if (getuserattr(user, soft, &tlim, SEC_INT) != -1 && tlim) | 807 | if (getuserattr(user, soft, &slim, SEC_INT) != -1) { |
809 | rlim.rlim_cur = tlim * mult; | 808 | if (slim < 0) { |
809 | rlim.rlim_cur = RLIM_INFINITY; | ||
810 | } else if (slim != 0) { | ||
811 | /* See the wackiness below */ | ||
812 | if (rlim.rlim_cur == slim * mult) | ||
813 | slim = 0; | ||
814 | else | ||
815 | rlim.rlim_cur = slim * mult; | ||
816 | } | ||
817 | } | ||
810 | 818 | ||
811 | tlim = (rlim_t) 0; | 819 | hlim = 0; |
812 | if (getuserattr(user, hard, &tlim, SEC_INT) != -1 && tlim) | 820 | if (getuserattr(user, hard, &hlim, SEC_INT) != -1) { |
813 | rlim.rlim_max = tlim * mult; | 821 | if (hlim < 0) { |
822 | rlim.rlim_max = RLIM_INFINITY; | ||
823 | } else if (hlim != 0) { | ||
824 | rlim.rlim_max = hlim * mult; | ||
825 | } | ||
826 | } | ||
814 | 827 | ||
815 | if (rlim.rlim_cur > rlim.rlim_max) | 828 | /* |
829 | * XXX For cpu and fsize the soft limit is set to the hard limit | ||
830 | * if the hard limit is left at its default value and the soft limit | ||
831 | * is changed from its default value, either by requesting it | ||
832 | * (slim == 0) or by setting it to the current default. At least | ||
833 | * that's how rlogind does it. If you're confused you're not alone. | ||
834 | * Bug or feature? AIX 4.3.1.2 | ||
835 | */ | ||
836 | if ((!strcmp(soft, "fsize") || !strcmp(soft, "cpu")) | ||
837 | && hlim == 0 && slim != 0) | ||
838 | rlim.rlim_max = rlim.rlim_cur; | ||
839 | /* A specified hard limit limits the soft limit */ | ||
840 | else if (hlim > 0 && rlim.rlim_cur > rlim.rlim_max) | ||
841 | rlim.rlim_cur = rlim.rlim_max; | ||
842 | /* A soft limit can increase a hard limit */ | ||
843 | else if (rlim.rlim_cur > rlim.rlim_max) | ||
816 | rlim.rlim_max = rlim.rlim_cur; | 844 | rlim.rlim_max = rlim.rlim_cur; |
817 | 845 | ||
818 | if (setrlimit(resource, &rlim) != 0) | 846 | if (setrlimit(resource, &rlim) != 0) |
819 | error("setrlimit(%.10s) failed: %.100s", soft, strerror(errno)) | 847 | error("setrlimit(%.10s) failed: %.100s", soft, strerror(errno)); |
820 | } | 848 | } |
821 | 849 | ||
822 | void set_limits_from_userattr(char *user) | 850 | void set_limits_from_userattr(char *user) |