diff -uNr orig/suexec.c new/suexec.c --- orig/suexec.c Thu Apr 11 00:00:00 2002 +++ new/suexec.c Sat Jan 31 01:18:29 2004 @@ -90,6 +90,7 @@ #include #include +#include #include "suexec.h" @@ -279,6 +280,7 @@ struct group *gr; /* group entry holder */ struct stat dir_info; /* directory info holder */ struct stat prg_info; /* program info holder */ + double current_la[3]; /* load average */ prog = argv[0]; /* @@ -341,6 +343,22 @@ target_uname = argv[1]; target_gname = argv[2]; cmd = argv[3]; + + + /* + * Check current Load Average + */ + + if( getloadavg(current_la, 3) != -1 ){ + if ((current_la[0] >= LA1_MAX) + && (current_la[1] >= LA5_MAX) + && (current_la[2] >= LA15_MAX)){ + + log_err("crit: load_average overflow (%.2f, %.2f, %.2f), service blocked (%s: %s).\n", + current_la[1], current_la[2], current_la[3], target_uname, cmd); + exit(122); + } + } /* * Check to see if the user running this program diff -uNr orig/suexec.h new/suexec.h --- orig/suexec.h Sat Jan 31 01:15:18 2004 +++ new/suexec.h Sat Jan 31 00:40:14 2004 @@ -141,4 +141,19 @@ #define SAFE_PATH "/usr/local/bin:/usr/bin:/bin" #endif +/* + * LA1_MAX, LA5_MAX, LA15_MAX -- Maximum allowed Load Average to run CGI executables. + * + */ + +#ifndef LA1_MAX +#define LA1_MAX 10.0 +#endif +#ifndef LA5_MAX +#define LA5_MAX 5.0 +#endif +#ifndef LA15_MAX +#define LA15_MAX 1.0 +#endif + #endif /* _SUEXEC_H */