limits.c (ba174a5e38b1ab764c4a36ef4dd83e80c4add148) | limits.c (2966d28c322dcfa4b9db2558da0b91839e7798b9) |
---|---|
1/*- 2 * Copyright (c) 1997 by 3 * David L. Nugent <davidn@blaze.net.au> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, is permitted provided that the following conditions 8 * are met: --- 230 unchanged lines hidden (view full) --- 239main(int argc, char *argv[]) 240{ 241 char *p, *cls = NULL; 242 char *cleanenv[1]; 243 struct passwd * pwd = NULL; 244 int rcswhich, shelltype; 245 int i, num_limits = 0; 246 int ch, doeval = 0, doall = 0; | 1/*- 2 * Copyright (c) 1997 by 3 * David L. Nugent <davidn@blaze.net.au> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, is permitted provided that the following conditions 8 * are met: --- 230 unchanged lines hidden (view full) --- 239main(int argc, char *argv[]) 240{ 241 char *p, *cls = NULL; 242 char *cleanenv[1]; 243 struct passwd * pwd = NULL; 244 int rcswhich, shelltype; 245 int i, num_limits = 0; 246 int ch, doeval = 0, doall = 0; |
247 int rtrn; |
|
247 login_cap_t * lc = NULL; 248 enum { ANY=0, SOFT=1, HARD=2, BOTH=3, DISPLAYONLY=4 } type = ANY; 249 enum { RCSUNKNOWN=0, RCSSET=1, RCSSEL=2 } todo = RCSUNKNOWN; 250 int which_limits[RLIM_NLIMITS]; 251 rlim_t set_limits[RLIM_NLIMITS]; 252 struct rlimit limits[RLIM_NLIMITS]; 253 254 /* init resource tables */ --- 139 unchanged lines hidden (view full) --- 394 if (doeval) { 395 warnx("-e cannot be used with `cmd' option"); 396 usage(); 397 } 398 399 login_close(lc); 400 401 /* set leading environment variables, like eval(1) */ | 248 login_cap_t * lc = NULL; 249 enum { ANY=0, SOFT=1, HARD=2, BOTH=3, DISPLAYONLY=4 } type = ANY; 250 enum { RCSUNKNOWN=0, RCSSET=1, RCSSEL=2 } todo = RCSUNKNOWN; 251 int which_limits[RLIM_NLIMITS]; 252 rlim_t set_limits[RLIM_NLIMITS]; 253 struct rlimit limits[RLIM_NLIMITS]; 254 255 /* init resource tables */ --- 139 unchanged lines hidden (view full) --- 395 if (doeval) { 396 warnx("-e cannot be used with `cmd' option"); 397 usage(); 398 } 399 400 login_close(lc); 401 402 /* set leading environment variables, like eval(1) */ |
402 while (*argv && (p = strchr(*argv, '='))) 403 (void)setenv(*argv++, ++p, 1); | 403 while (*argv && (p = strchr(*argv, '='))) { 404 *p = '\0'; 405 rtrn = setenv(*argv++, p + 1, 1); 406 *p = '='; 407 if (rtrn == -1) 408 err(EXIT_FAILURE, "setenv %s", *argv); 409 } |
404 405 /* Set limits */ 406 for (rcswhich = 0; rcswhich < RLIM_NLIMITS; rcswhich++) { 407 if (doall || num_limits == 0 || which_limits[rcswhich] != 0) 408 if (setrlimit(rcswhich, &limits[rcswhich]) == -1) 409 err(1, "setrlimit %s", resources[rcswhich].cap); 410 } 411 --- 242 unchanged lines hidden --- | 410 411 /* Set limits */ 412 for (rcswhich = 0; rcswhich < RLIM_NLIMITS; rcswhich++) { 413 if (doall || num_limits == 0 || which_limits[rcswhich] != 0) 414 if (setrlimit(rcswhich, &limits[rcswhich]) == -1) 415 err(1, "setrlimit %s", resources[rcswhich].cap); 416 } 417 --- 242 unchanged lines hidden --- |