diff options
Diffstat (limited to 'session.c')
-rw-r--r-- | session.c | 111 |
1 files changed, 1 insertions, 110 deletions
@@ -67,21 +67,6 @@ RCSID("$OpenBSD: session.c,v 1.126 2002/02/14 23:28:00 markus Exp $"); | |||
67 | #define is_winnt (GetVersion() < 0x80000000) | 67 | #define is_winnt (GetVersion() < 0x80000000) |
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | /* AIX limits */ | ||
71 | #if defined(HAVE_GETUSERATTR) && !defined(S_UFSIZE_HARD) && defined(S_UFSIZE) | ||
72 | # define S_UFSIZE_HARD S_UFSIZE "_hard" | ||
73 | # define S_UCPU_HARD S_UCPU "_hard" | ||
74 | # define S_UDATA_HARD S_UDATA "_hard" | ||
75 | # define S_USTACK_HARD S_USTACK "_hard" | ||
76 | # define S_URSS_HARD S_URSS "_hard" | ||
77 | # define S_UCORE_HARD S_UCORE "_hard" | ||
78 | # define S_UNOFILE_HARD S_UNOFILE "_hard" | ||
79 | #endif | ||
80 | |||
81 | #ifdef _AIX | ||
82 | # include <uinfo.h> | ||
83 | #endif | ||
84 | |||
85 | /* types */ | 70 | /* types */ |
86 | 71 | ||
87 | #define TTYSZ 64 | 72 | #define TTYSZ 64 |
@@ -898,85 +883,6 @@ void copy_environment(char **source, char ***env, u_int *envsize) | |||
898 | } | 883 | } |
899 | } | 884 | } |
900 | 885 | ||
901 | #if defined(HAVE_GETUSERATTR) | ||
902 | /* | ||
903 | * AIX-specific login initialisation | ||
904 | */ | ||
905 | void set_limit(char *user, char *soft, char *hard, int resource, int mult) | ||
906 | { | ||
907 | struct rlimit rlim; | ||
908 | int slim, hlim; | ||
909 | |||
910 | getrlimit(resource, &rlim); | ||
911 | |||
912 | slim = 0; | ||
913 | if (getuserattr(user, soft, &slim, SEC_INT) != -1) { | ||
914 | if (slim < 0) { | ||
915 | rlim.rlim_cur = RLIM_INFINITY; | ||
916 | } else if (slim != 0) { | ||
917 | /* See the wackiness below */ | ||
918 | if (rlim.rlim_cur == slim * mult) | ||
919 | slim = 0; | ||
920 | else | ||
921 | rlim.rlim_cur = slim * mult; | ||
922 | } | ||
923 | } | ||
924 | |||
925 | hlim = 0; | ||
926 | if (getuserattr(user, hard, &hlim, SEC_INT) != -1) { | ||
927 | if (hlim < 0) { | ||
928 | rlim.rlim_max = RLIM_INFINITY; | ||
929 | } else if (hlim != 0) { | ||
930 | rlim.rlim_max = hlim * mult; | ||
931 | } | ||
932 | } | ||
933 | |||
934 | /* | ||
935 | * XXX For cpu and fsize the soft limit is set to the hard limit | ||
936 | * if the hard limit is left at its default value and the soft limit | ||
937 | * is changed from its default value, either by requesting it | ||
938 | * (slim == 0) or by setting it to the current default. At least | ||
939 | * that's how rlogind does it. If you're confused you're not alone. | ||
940 | * Bug or feature? AIX 4.3.1.2 | ||
941 | */ | ||
942 | if ((!strcmp(soft, "fsize") || !strcmp(soft, "cpu")) | ||
943 | && hlim == 0 && slim != 0) | ||
944 | rlim.rlim_max = rlim.rlim_cur; | ||
945 | /* A specified hard limit limits the soft limit */ | ||
946 | else if (hlim > 0 && rlim.rlim_cur > rlim.rlim_max) | ||
947 | rlim.rlim_cur = rlim.rlim_max; | ||
948 | /* A soft limit can increase a hard limit */ | ||
949 | else if (rlim.rlim_cur > rlim.rlim_max) | ||
950 | rlim.rlim_max = rlim.rlim_cur; | ||
951 | |||
952 | if (setrlimit(resource, &rlim) != 0) | ||
953 | error("setrlimit(%.10s) failed: %.100s", soft, strerror(errno)); | ||
954 | } | ||
955 | |||
956 | void set_limits_from_userattr(char *user) | ||
957 | { | ||
958 | int mask; | ||
959 | char buf[16]; | ||
960 | |||
961 | set_limit(user, S_UFSIZE, S_UFSIZE_HARD, RLIMIT_FSIZE, 512); | ||
962 | set_limit(user, S_UCPU, S_UCPU_HARD, RLIMIT_CPU, 1); | ||
963 | set_limit(user, S_UDATA, S_UDATA_HARD, RLIMIT_DATA, 512); | ||
964 | set_limit(user, S_USTACK, S_USTACK_HARD, RLIMIT_STACK, 512); | ||
965 | set_limit(user, S_URSS, S_URSS_HARD, RLIMIT_RSS, 512); | ||
966 | set_limit(user, S_UCORE, S_UCORE_HARD, RLIMIT_CORE, 512); | ||
967 | #if defined(S_UNOFILE) | ||
968 | set_limit(user, S_UNOFILE, S_UNOFILE_HARD, RLIMIT_NOFILE, 1); | ||
969 | #endif | ||
970 | |||
971 | if (getuserattr(user, S_UMASK, &mask, SEC_INT) != -1) { | ||
972 | /* Convert decimal to octal */ | ||
973 | (void) snprintf(buf, sizeof(buf), "%d", mask); | ||
974 | if (sscanf(buf, "%o", &mask) == 1) | ||
975 | umask(mask); | ||
976 | } | ||
977 | } | ||
978 | #endif /* defined(HAVE_GETUSERATTR) */ | ||
979 | |||
980 | /* | 886 | /* |
981 | * Performs common processing for the child, such as setting up the | 887 | * Performs common processing for the child, such as setting up the |
982 | * environment, closing extra file descriptors, setting the user and group | 888 | * environment, closing extra file descriptors, setting the user and group |
@@ -1082,22 +988,7 @@ do_child(Session *s, const char *command) | |||
1082 | irix_setusercontext(pw); | 988 | irix_setusercontext(pw); |
1083 | # endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */ | 989 | # endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */ |
1084 | #ifdef _AIX | 990 | #ifdef _AIX |
1085 | /* | 991 | aix_usrinfo(s) |
1086 | * AIX has a "usrinfo" area where logname and | ||
1087 | * other stuff is stored - a few applications | ||
1088 | * actually use this and die if it's not set | ||
1089 | */ | ||
1090 | if (s->ttyfd == -1) | ||
1091 | s->tty[0] = '\0'; | ||
1092 | cp = xmalloc(22 + strlen(s->tty) + | ||
1093 | 2 * strlen(pw->pw_name)); | ||
1094 | i = sprintf(cp, "LOGNAME=%s%cNAME=%s%cTTY=%s%c%c", | ||
1095 | pw->pw_name, 0, pw->pw_name, 0, s->tty, 0, 0); | ||
1096 | if (usrinfo(SETUINFO, cp, i) == -1) | ||
1097 | fatal("Couldn't set usrinfo: %s", | ||
1098 | strerror(errno)); | ||
1099 | debug3("AIX/UsrInfo: set len %d", i); | ||
1100 | xfree(cp); | ||
1101 | #endif | 992 | #endif |
1102 | 993 | ||
1103 | /* Permanently switch to the desired uid. */ | 994 | /* Permanently switch to the desired uid. */ |