idsktune.c 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  13. * Don't forget to update build_date when the patch sets are updated.
  14. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
  15. static char *build_date = "23-FEBRUARY-2012";
  16. #if defined(linux) || defined(__linux) || defined(__linux__)
  17. #define IDDS_LINUX_INCLUDE 1
  18. #define IDDS_LINUX_SYSCTL 1
  19. #endif
  20. #if defined(__sun) || defined(__sun__)|| defined(__hpux)
  21. #define IDDS_SYSV_INCLUDE 1
  22. #endif
  23. #include <sys/types.h>
  24. #if !defined(__VMS)
  25. #include <sys/resource.h>
  26. #include <unistd.h>
  27. #endif
  28. #include <stdlib.h>
  29. #include <string.h>
  30. #include <errno.h>
  31. #include <ctype.h>
  32. #if !defined(__VMS) && !defined(IDDS_LINUX_INCLUDE)
  33. #if defined(__hpux) && defined(f_type)
  34. #undef f_type
  35. #endif
  36. #include <sys/statvfs.h>
  37. #define IDDS_HAVE_STATVFS
  38. #endif
  39. #if defined(IDDS_SYSV_INCLUDE) || defined(IDDS_BSD_INCLUDE)
  40. #include <sys/utsname.h>
  41. #include <sys/stat.h>
  42. #include <sys/param.h>
  43. #endif
  44. #if defined(__sun) || defined(__sun__)
  45. /* not available on HP-UX or AIX */
  46. #include <sys/systeminfo.h>
  47. #endif
  48. #if defined(__sun)
  49. #include <stdio.h>
  50. #include <fcntl.h>
  51. #include <sys/mnttab.h>
  52. #define IDDS_MNTENT mnttab
  53. #define IDDS_MNTENT_DIRNAME mnt_mountp
  54. #define IDDS_MNTENT_OPTIONS mnt_mntopts
  55. #define IDDS_MNTENT_MNTTAB "/etc/mnttab"
  56. #endif
  57. #if defined(IDDS_LINUX_INCLUDE)
  58. #include <sys/vfs.h>
  59. #include <sys/utsname.h>
  60. #include <linux/kernel.h>
  61. #include <sys/time.h>
  62. #include <sys/param.h>
  63. #include <mntent.h>
  64. #include <sys/sysinfo.h>
  65. #define IDDS_MNTENT mntent
  66. #define IDDS_MNTENT_DIRNAME mnt_dir
  67. #define IDDS_MNTENT_OPTIONS mnt_opts
  68. #define IDDS_MNTENT_MNTTAB "/etc/mtab"
  69. #endif
  70. #if defined(__hpux)
  71. #include <sys/pstat.h>
  72. #include <mntent.h>
  73. #define IDDS_MNTENT mntent
  74. #define IDDS_MNTENT_DIRNAME mnt_dir
  75. #define IDDS_MNTENT_OPTIONS mnt_opts
  76. #define IDDS_MNTENT_MNTTAB "/etc/mnttab"
  77. #endif
  78. #if defined(__VMS)
  79. #error "This program is not available for VMS"
  80. #endif
  81. #if defined(__osf__)
  82. #include <unistd.h>
  83. #include <sys/stat.h>
  84. #include <sys/swap.h>
  85. #include <sys/sysinfo.h>
  86. #include <sys/utsname.h>
  87. #include <sys/systeminfo.h>
  88. #include <machine/hal_sysinfo.h>
  89. #include <machine/cpuconf.h>
  90. #include <fstab.h>
  91. #define IDDS_MNTENT fstab
  92. #define IDDS_MNTENT_DIRNAME fs_file
  93. #define IDDS_MNTENT_OPTIONS fs_mntops
  94. #endif
  95. #include "pio.h"
  96. int flag_html = 0;
  97. int flag_debug = 0;
  98. int flag_quick = 0;
  99. int flag_os_bad = 0;
  100. int flag_solaris_9 = 0;
  101. int flag_solaris_8 = 0;
  102. int flag_solaris_7 = 0;
  103. int flag_solaris_26 = 0;
  104. int flag_solaris_251 = 0;
  105. int flag_tru64_40b = 0;
  106. int flag_tru64_tuning_needed = 0;
  107. int solaris_version = 0;
  108. int flag_intel = 0;
  109. int flag_arch_bad = 0;
  110. int phys_mb = 0;
  111. int swap_mb = 0;
  112. int flag_mproc = 0;
  113. int tcp_max_listen = 0;
  114. int flag_nonroot = 0;
  115. int flag_carrier = 0;
  116. int flag_warnings = 0;
  117. int conn_thread = 1;
  118. int maxconn = 0;
  119. int client = 0;
  120. int mem_min = 256;
  121. int mem_rec = 1024;
  122. /* Define name variations on different platforms */
  123. #if defined(__sun)
  124. #define NAME_NDD_CFG_FILE "/etc/init.d/inetinit"
  125. #define NAME_TCP_TIME_WAIT_INTERVAL "tcp_time_wait_interval"
  126. #define NAME_TCP_CONN_REQ_MAX_Q "tcp_conn_req_max_q"
  127. #define NAME_TCP_KEEPALIVE_INTERVAL "tcp_keepalive_interval"
  128. #define NAME_TCP_SMALLEST_ANON_PORT "tcp_smallest_anon_port"
  129. #endif
  130. #if defined(__hpux)
  131. #define NAME_NDD_CFG_FILE "/etc/rc.config.d/nddconf"
  132. #define NAME_TCP_TIME_WAIT_INTERVAL "tcp_time_wait_interval"
  133. #define NAME_TCP_CONN_REQ_MAX_Q "tcp_conn_request_max"
  134. #define NAME_TCP_KEEPALIVE_INTERVAL "tcp_keepalive_interval"
  135. #define NAME_TCP_SMALLEST_ANON_PORT "tcp_smallest_anon_port"
  136. #endif
  137. #if defined(IDDS_LINUX_SYSCTL)
  138. #define NAME_TCP_KEEPALIVE_INTERVAL "net.ipv4.tcp_keepalive_time"
  139. #endif
  140. #if defined(__sun) || defined(__hpux) || defined(IDDS_LINUX_SYSCTL)
  141. long ndd_tcp_conn_req_max_q = 0;
  142. long ndd_tcp_conn_req_max_q0 = 0;
  143. long ndd_tcp_rexmit_interval_initial = 0;
  144. long ndd_tcp_slow_start_initial = 0;
  145. long ndd_tcp_keepalive_interval = 0;
  146. long ndd_tcp_time_wait_interval = 0;
  147. long ndd_tcp_smallest_anon_port = 0;
  148. long ndd_tcp_deferred_ack_interval = 0;
  149. long ndd_tcp_ip_abort_cinterval = 0;
  150. long ndd_tcp_ip_abort_interval = 0;
  151. long ndd_tcp_strong_iss = 0;
  152. int hpux_ndd_change_needed = 0;
  153. #endif
  154. char install_dir[MAXPATHLEN];
  155. int avail_root = 0;
  156. int avail_opt = 0;
  157. int max_core = 0;
  158. #if defined(__sun)
  159. #define SUN_NETWORK_DEVICE "/dev/hme"
  160. char solaris_release_string[128];
  161. struct iii_pinfo {
  162. int pnum;
  163. int pver;
  164. int preq;
  165. int sol;
  166. int intel;
  167. int seen;
  168. char *pdesc;
  169. } iii_patches[] = {
  170. #include "sol_patches.c"
  171. /* sol_patches.c is a generated file
  172. if you need to include patches not automatically
  173. generated, please list them individually here
  174. */
  175. {0,0,0,0,0}
  176. };
  177. #endif
  178. #if defined(__hpux)
  179. struct pst_dynamic pst_dyn;
  180. struct pst_static pst_stt;
  181. struct pst_vminfo pst_vmm;
  182. struct iii_pinfo_hp {
  183. char *qpk_name;
  184. char *qpk_version;
  185. char *qpk_desc;
  186. int qpk_yr;
  187. int qpk_mo;
  188. int seen;
  189. } iii_qpk[] = {
  190. #include "hp_patches.c"
  191. /* hp_patches.c is a generated file
  192. if you need to include patches not automatically
  193. generated, please list them individually here
  194. */
  195. {NULL, NULL, NULL, 0, 0, 0}
  196. };
  197. static void hp_check_qpk(void);
  198. #endif
  199. #if defined(__sun)
  200. static void ids_get_platform_solaris(char *buf)
  201. {
  202. struct utsname u;
  203. char sbuf[128];
  204. FILE *fp;
  205. #if defined(sparc) || defined(__sparc)
  206. int is_u = 0;
  207. sbuf[0] = '\0';
  208. sysinfo(SI_MACHINE,sbuf,128);
  209. if (strcmp(sbuf,"sun4u") == 0) {
  210. is_u = 1;
  211. }
  212. sbuf[0] = '\0';
  213. sysinfo(SI_PLATFORM,sbuf,128);
  214. sprintf(buf,"%ssparc%s-%s-solaris",
  215. is_u ? "u" : "",
  216. sizeof(long) == 4 ? "" : "v9",
  217. sbuf);
  218. #else
  219. #if defined(i386) || defined(__i386)
  220. sprintf(buf,"i386-unknown-solaris");
  221. #else
  222. sprintf(buf,"unknown-unknown-solaris");
  223. #endif /* not i386 */
  224. #endif /* not sparc */
  225. uname(&u);
  226. if (isascii(u.release[0]) && isdigit(u.release[0])) strcat(buf,u.release);
  227. fp = fopen("/etc/release","r");
  228. if (fp != NULL) {
  229. char *rp;
  230. sbuf[0] = '\0';
  231. fgets(sbuf,128,fp);
  232. fclose(fp);
  233. rp = strstr(sbuf,"Solaris");
  234. if (rp) {
  235. rp += 8;
  236. while(*rp != 's' && *rp != '\0') rp++;
  237. if (*rp == 's') {
  238. strcpy(solaris_release_string,rp);
  239. rp = strchr(solaris_release_string,' ');
  240. if (rp) *rp = '\0';
  241. strcat(buf,"_");
  242. strcat(buf,solaris_release_string);
  243. }
  244. }
  245. } else {
  246. if (flag_debug) printf("DEBUG : No /etc/release file\n");
  247. }
  248. }
  249. int sun_check_kern_arch(char *a,char *b)
  250. {
  251. if (strcmp(b,"i86pc") == 0) {
  252. flag_intel = 1;
  253. if (flag_debug) printf("DEBUG : Kernel architecture: i86pc\n");
  254. } else if (strcmp(b,"sun4u") == 0) {
  255. if (flag_debug) printf("DEBUG : Kernel architecture: sun4u\n");
  256. } else {
  257. if (flag_html) printf("<P>\n");
  258. printf("%s: The kernel architecture is %s. " VENDOR " products are optimized\nfor the UltraSPARC architecture and will exhibit poorer performance on earlier\nmachines.\n\n","WARNING",b);
  259. if (flag_html) printf("</P>\n");
  260. flag_arch_bad = 1;
  261. flag_warnings++;
  262. }
  263. return 0;
  264. }
  265. /* This check is now obsolete. See solaris_check_mu() */
  266. int sun_check_release(char *a,char *b)
  267. {
  268. if (flag_html) printf("<P>\n");
  269. if (strcmp(b,"9") == 0 ||
  270. strcmp(b,"5.9") == 0) {
  271. if (flag_debug) printf("DEBUG : Release 5.9\n");
  272. solaris_version = 29;
  273. flag_solaris_9 = 1;
  274. } else if (strcmp(b,"8") == 0 ||
  275. strcmp(b,"5.8") == 0) {
  276. if (flag_debug) printf("DEBUG : Release 5.8\n");
  277. solaris_version = 28;
  278. flag_solaris_8 = 1;
  279. } else if (strcmp(b,"7") == 0 ||
  280. strcmp(b,"5.7") == 0) {
  281. if (flag_debug) printf("DEBUG : Release 5.7\n");
  282. solaris_version = 27;
  283. flag_solaris_7 = 1;
  284. } else if (strcmp(b,"5.6") == 0) {
  285. flag_solaris_26 = 1;
  286. solaris_version = 26;
  287. if (flag_debug) printf("DEBUG : Release 5.6\n");
  288. } else if (strcmp(b,"5.5.1") == 0) {
  289. if (client == 0) {
  290. printf("%s: Solaris versions prior to 2.6 are not suitable for running Internet\nservices; upgrading to 2.6 or later is required.\n\n",
  291. "ERROR ");
  292. flag_os_bad = 1;
  293. }
  294. flag_solaris_251 = 1;
  295. solaris_version = 251;
  296. } else if (strcmp(b,"5.5") == 0) {
  297. printf("%s: Solaris versions prior to 2.6 are not suitable for running Internet\nservices; upgrading to 2.6 or later is required.\n\n",
  298. "ERROR ");
  299. flag_os_bad = 1;
  300. solaris_version = 25;
  301. } else if (strcmp(b,"5.4") == 0) {
  302. printf("%s: Solaris versions prior to 2.6 are not suitable for running Internet\nservices; upgrading to 2.6 is required.\n\n",
  303. "ERROR ");
  304. flag_os_bad = 1;
  305. solaris_version = 24;
  306. } else if (strcmp(b,"5.3") == 0) {
  307. printf("%s: Solaris 2.3 is not supported.\n\n",
  308. "ERROR ");
  309. flag_os_bad = 1;
  310. } else {
  311. printf("%s: Solaris version %s, as reported by showrev -a, is unrecognized.\n\n",
  312. "NOTICE ",b);
  313. flag_os_bad = 1;
  314. }
  315. if (flag_html) printf("</P>\n");
  316. return 0;
  317. }
  318. /* This check is now obsolete. See solaris_check_mu() instead. */
  319. int sun_check_kern_ver(char *a,char *b)
  320. {
  321. char *rp,*pp;
  322. int pw = 0;
  323. if (flag_html) printf("<P>\n");
  324. rp = strrchr(b,' ');
  325. if (rp == NULL || rp == b) {
  326. printf("NOTICE : Kernel version: \"%s\" not recognized.\n\n",b);
  327. if (flag_html) printf("</P>\n");
  328. return 0;
  329. }
  330. *rp = '\0';
  331. rp++;
  332. pp = strrchr(b,' ');
  333. if (pp == 0) {
  334. printf("NOTICE : Kernel version: \"%s\" not recognized.\n\n",b);
  335. if (flag_html) printf("</P>\n");
  336. return 0;
  337. }
  338. pp++;
  339. if (strcmp(rp,"1997") == 0 ||
  340. strcmp(rp,"1996") == 0) {
  341. printf("%s: This kernel was built in %s %s. Kernel builds prior to\n"
  342. "mid-1998 are lacking many tuning fixes, uprading is strongly recommended.\n\n","ERROR ",pp,rp);
  343. pw = 1;
  344. flag_os_bad = 1;
  345. }
  346. if (flag_solaris_26 && strcmp(rp,"1998") == 0) {
  347. if (strncmp(pp,"Jan",3) == 0 ||
  348. strncmp(pp,"Feb",3) == 0 ||
  349. strncmp(pp,"Mar",3) == 0 ||
  350. strncmp(pp,"Apr",3) == 0) {
  351. printf("%s: This kernel was built in %s %s. Kernel builds prior to\n"
  352. "mid-1998 are lacking many tuning fixes, uprading is strongly recommended.\n\n","WARNING",pp,rp);
  353. pw = 1;
  354. flag_os_bad = 1;
  355. flag_warnings++;
  356. }
  357. }
  358. if (flag_debug && pw == 0) {
  359. printf("DEBUG : Kernel build date %s %s\n",pp,rp);
  360. }
  361. if (flag_html) printf("</P>\n");
  362. return 0;
  363. }
  364. int sun_check_patch(char *a,char *b)
  365. {
  366. char *rp;
  367. int pid = 0;
  368. int pver = 0;
  369. int i;
  370. rp = strchr(b,'O');
  371. if (rp == NULL) {
  372. printf("%s: Cannot parse patch line %s\n","NOTICE ",b);
  373. return 0;
  374. }
  375. *rp = '\0';
  376. rp = strchr(b,'-');
  377. if (b == NULL) {
  378. printf("%s: Cannot parse patch line %s\n","NOTICE ",b);
  379. }
  380. *rp = '\0';
  381. rp++;
  382. pid = atoi(b);
  383. pver = atoi(rp);
  384. for (i = 0; iii_patches[i].pnum != 0; i++) {
  385. if (iii_patches[i].pnum == pid) {
  386. if (iii_patches[i].seen < pver) {
  387. iii_patches[i].seen = pver;
  388. }
  389. break;
  390. }
  391. }
  392. return 0;
  393. }
  394. int sun_check_etcsystem(void)
  395. {
  396. FILE *fp;
  397. char buf[8192];
  398. int pp_set = -1;
  399. int tchs = 0;
  400. fp = fopen("/etc/system","r");
  401. if (fp == NULL) {
  402. perror("/etc/system");
  403. return -1;
  404. }
  405. while(fgets(buf,8192,fp) != NULL) {
  406. char *rp;
  407. rp = strchr(buf,'\n');
  408. if (rp) {
  409. *rp = '\0';
  410. }
  411. if (buf[0] == '*') continue; /* comment */
  412. if (strncmp(buf,"set",3) != 0) continue;
  413. if (flag_debug) printf("DEBUG : saw %s in /etc/system\n",buf);
  414. if (strstr(buf,"priority_paging") != NULL) {
  415. rp = strchr(buf,'=');
  416. if (rp == NULL) continue;
  417. rp++;
  418. while(isspace(*rp)) rp++;
  419. if (*rp == '1') {
  420. pp_set = 1;
  421. } else {
  422. pp_set = 0;
  423. }
  424. } else if (strstr(buf,"tcp:tcp_conn_hash_size") != NULL) {
  425. rp = strchr(buf,'=');
  426. if (rp == NULL) continue;
  427. rp++;
  428. while(isspace(*rp)) rp++;
  429. tchs = atoi(rp);
  430. }
  431. }
  432. fclose(fp);
  433. /* ias tuning recommends setting tcp_conn_hash_size to 8192 XXX */
  434. if (pp_set == 1) {
  435. if (flag_debug) printf("DEBUG : saw priority_paging=1 in /etc/system\n");
  436. } else if (flag_solaris_7) {
  437. if (pp_set == 0) {
  438. printf("NOTICE : priority_paging is set to 0 in /etc/system.\n\n");
  439. } else {
  440. printf("WARNING: priority_paging is not set to 1 in /etc/system. See Sun FAQ 2833.\n\n");
  441. flag_warnings++;
  442. }
  443. }
  444. }
  445. void sun_check_mu(void)
  446. {
  447. if (solaris_release_string[0] == '\0') {
  448. if (flag_debug) printf("DEBUG : No /etc/release line parsed\n");
  449. return;
  450. }
  451. switch(solaris_version) {
  452. case 28:
  453. if (strcmp(solaris_release_string,"s28_27b") == 0) {
  454. printf("ERROR : This machine appears to be running Solaris 8 Beta.\n\n");
  455. } else if (strcmp(solaris_release_string,"s28_32d") == 0) {
  456. printf("ERROR : This machine appears to be running Solaris 8 Beta Refresh.\n\n");
  457. } else if (strcmp(solaris_release_string,"s28_38shwp2") == 0) {
  458. printf("NOTICE : This machine appears to be running Solaris 8 FCS. Solaris 8 Update\n4 has been released subsequent to this.\n\n");
  459. } else if (strcmp(solaris_release_string,"s28s_u1wos_08") == 0) {
  460. printf("NOTICE : This machine appears to be running Solaris 8 Update 1. Solaris 8\nUpdate 4 has been released subsequent to this.\n\n");
  461. } else if (strcmp(solaris_release_string,"s28_38shwp2") == 0) {
  462. printf("NOTICE : This machine appears to be running Solaris 8 Maint Update 1.\nSolaris 8 Update 4 has been released subsequent to this.\n\n");
  463. } else if (strcmp(solaris_release_string,"s28s_u2wos_11b") == 0) {
  464. printf("NOTICE : This machine appears to be running Solaris 8 Update 2. Solaris 8\nUpdate 4 has been released subsequent to this.\n\n");
  465. } else if (strcmp(solaris_release_string,"s28_38shwp2") == 0) {
  466. printf("NOTICE : This machine appears to be running Solaris 8 Maint Update 2.\nSolaris 8 Update 4 has been released subsequent to this.\n\n");
  467. } else if (strcmp(solaris_release_string,"s28s_u3wos_08") == 0) {
  468. printf("NOTICE : This machine appears to be running Solaris 8 Update 3. Solaris 8\nUpdate 4 has been released subsequent to this.\n\n");
  469. } else if (strcmp(solaris_release_string,"s28s_u4wos_03") == 0) {
  470. printf("ERROR : This machine appears to be running Solaris 8 Update 4 BETA. Solaris 8\nUpdate 4 has been released subsequent to this.\n\n");
  471. } else if (strcmp(solaris_release_string,"s28s_u4wos_08") == 0) {
  472. if (flag_debug) printf("DEBUG : Solaris 8 Update 4 (4/01)\n\n");
  473. } else if (strcmp(solaris_release_string,"s28s_u5wos_08") == 0) {
  474. if (flag_debug) printf("DEBUG : Solaris 8 Update 5\n\n");
  475. } else {
  476. if (flag_debug) printf("DEBUG : Solaris 8 Unrecognized\n");
  477. }
  478. break;
  479. case 29:
  480. if (flag_debug) printf("DEBUG : Solaris 9 Unrecognized\n");
  481. break;
  482. default:
  483. if (flag_debug) printf("DEBUG : Solaris Unrecognized\n");
  484. /* probably pretty old */
  485. break;
  486. }
  487. }
  488. #endif
  489. int check_memsize(char *a,char *b)
  490. {
  491. char *rp;
  492. int mult = 1;
  493. rp = strchr(b,' ');
  494. if (rp == NULL) {
  495. printf("%s: Cannot parse Memory size: line %s\n\n","NOTICE ",b);
  496. return 0;
  497. }
  498. if (!isdigit(*b)) {
  499. printf("%s: Cannot parse Memory size: line %s\n\n","NOTICE ",b);
  500. return 0;
  501. }
  502. *rp = '\0';
  503. rp++;
  504. if (strcmp(rp,"Megabytes") == 0) {
  505. } else if (strcmp(rp,"Gigabytes") == 0) {
  506. mult = 1024;
  507. } else {
  508. printf("%s: Cannot parse Memory size: line %s %s\n\n","NOTICE ",b,rp);
  509. return 0;
  510. }
  511. phys_mb = atoi(b) * mult;
  512. return 0;
  513. }
  514. int check_swapsize(char *a,char *b)
  515. {
  516. char *rp,*kp;
  517. int used, avail;
  518. rp = strchr(b,'=');
  519. if (rp == NULL) {
  520. printf("NOTICE : Cannot parse swap -s output: %s\n", b);
  521. return 0;
  522. }
  523. rp++;
  524. if (isspace(*rp)) rp++;
  525. if (!(isdigit(*rp))) {
  526. printf("NOTICE : Cannot parse swap -s output: %s\n", b);
  527. return 0;
  528. }
  529. kp = strchr(rp,'k');
  530. if (kp == NULL) {
  531. printf("NOTICE : Cannot parse swap -s output: %s\n", b);
  532. return 0;
  533. }
  534. *kp = '\0';
  535. used = atoi(rp);
  536. *kp = 'k';
  537. rp = strchr(b,',');
  538. if (rp == NULL) {
  539. printf("NOTICE : Cannot parse swap -s output: %s\n", b);
  540. return 0;
  541. }
  542. rp++;
  543. if (isspace(*rp)) rp++;
  544. if (!(isdigit(*rp))) {
  545. printf("NOTICE : Cannot parse swap -s output: %s\n", b);
  546. return 0;
  547. }
  548. kp = strchr(rp,'k');
  549. if (kp == NULL) {
  550. printf("NOTICE : Cannot parse swap -s output: %s\n", b);
  551. return 0;
  552. }
  553. *kp = '\0';
  554. avail = atoi(rp);
  555. if (flag_debug) {
  556. printf("DEBUG : swap used %dK avail %dK\n", used, avail);
  557. }
  558. swap_mb = (used+avail)/1024-(phys_mb*7/8);
  559. return 0;
  560. }
  561. #if defined(__sun)
  562. int check_kthread(char *a,char *b)
  563. {
  564. flag_mproc = 1;
  565. return 0;
  566. }
  567. int check_tcpmaxlisten(char *a,char *b)
  568. {
  569. if (flag_os_bad == 1) return 0;
  570. if (client) return 0;
  571. if (flag_html) printf("<P>\n");
  572. if (isdigit(*b)) {
  573. tcp_max_listen = atoi(b);
  574. if (tcp_max_listen <= 1024) {
  575. printf("%s: The kernel has been configured with a maximum of 1024 for the listen\nbacklog queue size. This will prevent it from being raised with ndd.\n","ERROR ");
  576. if (flag_mproc == 0) {
  577. printf("The following line should be added to the file /etc/init.d/inetinit:\n");
  578. if (flag_html) printf("</P><PRE>\n");
  579. printf("echo \"tcp_param_arr+14/W 0t65536\" | adb -kw /dev/ksyms /dev/mem\n");
  580. printf("\n");
  581. if (flag_html) printf("</PRE><P>\n");
  582. } else {
  583. printf("As this is a multiprocessor, contact your Solaris support representative for\ninformation on changing the parameter at tcp_param_arr+14, as documented in\nSun Security Bulletin #00136 section B.1.\n\n");
  584. }
  585. } else if (tcp_max_listen < 65536) {
  586. printf("%s: The kernel has a configured limit of %d for the maximum listen\nbacklog queue size. Setting a value larger than this with ndd will not have\nan effect.\n","WARNING",tcp_max_listen);
  587. flag_warnings++;
  588. if (flag_mproc == 0) {
  589. printf("The value can be raised by adding the following line to the file\n/etc/init.d/inetinit:\n");
  590. if (flag_html) printf("</P><PRE>\n");
  591. printf("echo \"tcp_param_arr+14/W 0t65536\" | adb -kw /dev/ksyms /dev/mem\n");
  592. if (flag_html) printf("</PRE><P>\n");
  593. printf("\n\n");
  594. }
  595. } else {
  596. if (flag_debug) printf("DEBUG : tcp_param_arr+0x14: %d\n",tcp_max_listen);
  597. }
  598. } else if (strcmp(b,"-1") == 0) {
  599. /* OK I guess */
  600. tcp_max_listen = 65535;
  601. } else {
  602. printf("NOTICE : tcp_param_arr+0x14: %s cannot be parsed\n\n", b);
  603. }
  604. if (flag_html) printf("</P>\n");
  605. return 0;
  606. }
  607. struct iii_pio_parsetab ptb_showrev[] = {
  608. {"Release",sun_check_release},
  609. {"Kernel architecture",sun_check_kern_arch},
  610. {"Kernel version",sun_check_kern_ver},
  611. {"Patch",sun_check_patch}
  612. };
  613. struct iii_pio_parsetab ptb_adb[] = {
  614. {" kernel thread at:",check_kthread},
  615. {"tcp_param_arr+0x14",check_tcpmaxlisten}
  616. };
  617. #endif
  618. struct iii_pio_parsetab ptb_prtconf[] = {
  619. {"Memory size",check_memsize}
  620. };
  621. struct iii_pio_parsetab ptb_swap[] = {
  622. {"total",check_swapsize}
  623. };
  624. #if defined(IDDS_LINUX_INCLUDE)
  625. static void
  626. linux_check_release(void)
  627. {
  628. FILE *fp;
  629. char osl[128];
  630. char *cmd = strdup("/bin/uname -r");
  631. int major = 0;
  632. int minor = 0;
  633. int revision = 0;
  634. if (cmd == NULL) {
  635. printf("ERROR: Unable to allocate memory\n");
  636. goto done;
  637. }
  638. if (flag_html) printf("<P>\n");
  639. if (flag_debug) printf("DEBUG : %s\n",cmd);
  640. fp = popen(cmd,"r");
  641. if (fp == NULL) {
  642. perror("popen");
  643. goto done;
  644. }
  645. if (fgets(osl,128,fp) == NULL) {
  646. printf("WARNING: Cannot determine the kernel number.\n");
  647. pclose(fp);
  648. flag_warnings++;
  649. goto done;
  650. }
  651. pclose(fp);
  652. if (flag_debug) {
  653. printf("DEBUG : %s\n",osl);
  654. }
  655. major = atoi(strtok(osl, "."));
  656. minor = atoi(strtok(NULL, "."));
  657. revision = atoi(strtok(NULL, "-"));
  658. if (major < 2) {
  659. printf("ERROR: We support kernel version 2.4.7 and higher.\n\n");
  660. flag_os_bad = 1;
  661. goto done;
  662. } else if (major == 2) {
  663. if (minor < 4) {
  664. printf("ERROR: We support kernel version 2.4.7 and higher.\n\n");
  665. flag_os_bad = 1;
  666. goto done;
  667. } else if (minor == 4) {
  668. if (revision < 7) {
  669. printf("ERROR: We support kernel version 2.4.7 and higher.\n\n");
  670. flag_os_bad = 1;
  671. goto done;
  672. }
  673. }
  674. }
  675. done:
  676. if (cmd) free(cmd);
  677. }
  678. #endif /* IDDS_LINUX_INCLUDE */
  679. static void gen_tests (void)
  680. {
  681. uid_t uid;
  682. if (flag_html) printf("<P>\n");
  683. #if defined(__sun)
  684. if (flag_debug) printf("DEBUG : /usr/bin/showrev -a\n");
  685. if (iii_pio_procparse("/usr/bin/showrev -a",
  686. III_PIO_SZ(ptb_showrev),
  687. ptb_showrev) == -1) {
  688. perror("/usr/bin/showrev -a");
  689. } else {
  690. int i;
  691. int pur = 0;
  692. for (i = 0; iii_patches[i].pnum != 0; i++) {
  693. if (iii_patches[i].sol == solaris_version &&
  694. iii_patches[i].intel == flag_intel) {
  695. if (iii_patches[i].seen >= iii_patches[i].pver) {
  696. if (flag_debug) {
  697. printf("DEBUG : Patch %d-%02d, %d-%02d required (%s)\n",
  698. iii_patches[i].pnum,
  699. iii_patches[i].seen,
  700. iii_patches[i].pnum,
  701. iii_patches[i].pver,
  702. iii_patches[i].pdesc);
  703. }
  704. } else if (iii_patches[i].seen != 0) {
  705. if (flag_html) printf("<P>\n");
  706. if (iii_patches[i].preq == 1 || flag_quick == 0) {
  707. printf("%s: Patch %d-%02d is present, but %d-%02d (%s) is a more recent version.\n\n",
  708. iii_patches[i].preq ? "ERROR " : "NOTICE ",
  709. iii_patches[i].pnum,
  710. iii_patches[i].seen,
  711. iii_patches[i].pnum,
  712. iii_patches[i].pver,
  713. iii_patches[i].pdesc);
  714. pur++;
  715. if (flag_carrier || iii_patches[i].preq) flag_os_bad = 1;
  716. }
  717. if (flag_html) printf("</P>\n");
  718. } else {
  719. if (flag_html) printf("<P>\n");
  720. if (iii_patches[i].preq) {
  721. printf("%s: Patch %d-%02d (%s) is required but not installed.\n\n",
  722. "ERROR ",
  723. iii_patches[i].pnum,
  724. iii_patches[i].pver,
  725. iii_patches[i].pdesc);
  726. flag_os_bad = 1;
  727. pur++;
  728. } else {
  729. if (flag_quick == 0) {
  730. printf("%s: Patch %d-%02d (%s) is not installed.\n\n",
  731. "NOTICE ",
  732. iii_patches[i].pnum,
  733. iii_patches[i].pver,
  734. iii_patches[i].pdesc);
  735. pur++;
  736. }
  737. }
  738. if (flag_html) printf("</P>\n");
  739. }
  740. } else if (iii_patches[i].seen) {
  741. if (flag_html) printf("<P>\n");
  742. printf("%s: Patch %d-%d seen on Solaris %d (%s) but intended for\nSolaris %d %s.\n\n",
  743. "WARNING",
  744. iii_patches[i].pnum,
  745. iii_patches[i].seen,
  746. solaris_version,
  747. flag_intel ? "(Intel)" : "",
  748. iii_patches[i].sol,
  749. iii_patches[i].intel ? "(Intel)" : "");
  750. if (flag_html) printf("</P>\n");
  751. pur++;
  752. flag_warnings++;
  753. }
  754. } /* for */
  755. if (pur) {
  756. printf("NOTICE : Solaris patches can be obtained from http://sunsolve.sun.com or your\nSolaris support representative. Solaris patches listed as required by the\nJRE are located at http://www.sun.com/software/solaris/jre/download.html or\ncan be obtained from your Solaris support representative.\n\n");
  757. }
  758. }
  759. sun_check_mu();
  760. #endif
  761. #if defined(IDDS_LINUX_INCLUDE)
  762. linux_check_release();
  763. #endif
  764. if (access("/usr/sbin/prtconf",X_OK) == 0) {
  765. if (flag_debug) printf("DEBUG : /usr/sbin/prtconf\n");
  766. if (iii_pio_procparse("/usr/sbin/prtconf", III_PIO_SZ(ptb_prtconf),
  767. ptb_prtconf) == -1) {
  768. perror("/usr/sbin/prtconf");
  769. }
  770. }
  771. #if defined(__hpux)
  772. hp_check_qpk();
  773. if (pstat_getdynamic(&pst_dyn,sizeof(pst_dyn),1,0) == -1 ||
  774. pstat_getstatic(&pst_stt,sizeof(pst_stt),1,0) == -1 ||
  775. pstat_getvminfo(&pst_vmm,sizeof(pst_vmm),1,0) == -1) {
  776. perror("pstat_getdynamic");
  777. } else {
  778. if (flag_debug) {
  779. printf("DEBUG : Static info\n");
  780. printf("DEBUG : Physical memory size %lu\n",pst_stt.physical_memory);
  781. printf("DEBUG : Page size %lu\n",pst_stt.page_size);
  782. printf("DEBUG : Max nfile %lu\n",pst_stt.pst_max_nfile);
  783. printf("DEBUG : Dynamic info\n");
  784. printf("DEBUG : Physical memory size %lu\n",pst_dyn.psd_rm);
  785. printf("DEBUG : Virtual Memory size %lu\n",pst_dyn.psd_vm);
  786. printf("DEBUG : Physical memory size %lu active\n",pst_dyn.psd_arm);
  787. printf("DEBUG : Virtual Memory size %lu active\n",pst_dyn.psd_avm);
  788. printf("DEBUG : Processors %lu\n",pst_dyn.psd_proc_cnt);
  789. printf("DEBUG : VM Info\n");
  790. printf("DEBUG : Pages on disk backing %lu\n",pst_vmm.psv_swapspc_cnt);
  791. printf("DEBUG : Max pages on disk backing %lu\n",pst_vmm.psv_swapspc_max);
  792. }
  793. phys_mb = pst_stt.page_size / 1024;
  794. phys_mb = phys_mb * (pst_stt.physical_memory / 1024);
  795. swap_mb = pst_stt.page_size / 1024;
  796. swap_mb = swap_mb * (pst_vmm.psv_swapspc_cnt / 1024);
  797. }
  798. #else
  799. #if defined(IDDS_BSD_SYSCTL)
  800. /* phys_mb from hw.physmem / 1048576 */
  801. /* swap_mb from vm.stats.vm.v_page_count * v_page_size / 1048576 */
  802. #endif
  803. #endif
  804. if (flag_html) printf("<P>\n");
  805. if (phys_mb != 0 && phys_mb < mem_min) {
  806. printf("%s: Only %dMB of physical memory is available on the system. %dMB is the\nrecommended minimum. %dMB is recommended for best performance on large production system.\n\n","ERROR ",phys_mb,
  807. mem_min, mem_rec);
  808. flag_arch_bad = 1;
  809. } else if (phys_mb != 0 && phys_mb < mem_rec) {
  810. printf("%s: %dMB of physical memory is available on the system. %dMB is recommended for best performance on large production system.\n\n",
  811. "WARNING",
  812. phys_mb,mem_rec);
  813. flag_warnings++;
  814. } else if (flag_debug) {
  815. printf("DEBUG : Memory size %d\n",phys_mb);
  816. }
  817. if (flag_html) printf("</P>\n");
  818. if (access("/usr/sbin/swap",X_OK) == 0) {
  819. if (flag_debug) printf("DEBUG : /usr/sbin/swap -s\n");
  820. if (iii_pio_procparse("/usr/sbin/swap -s",
  821. III_PIO_SZ(ptb_swap),
  822. ptb_swap) == -1) {
  823. perror("/usr/sbin/swap -s");
  824. }
  825. }
  826. #if defined(IDDS_LINUX_INCLUDE)
  827. if (1) {
  828. struct sysinfo linux_si;
  829. if (sysinfo(&linux_si) == 0) {
  830. swap_mb = linux_si.totalswap * (linux_si.mem_unit / 1024) / 1024;
  831. }
  832. }
  833. #endif
  834. if (client == 0 && swap_mb < 0) {
  835. if (flag_html) printf("<P>\n");
  836. printf("%s: There is less swap space than physical memory.\n\n",
  837. "ERROR ");
  838. if (flag_html) printf("</P>\n");
  839. } else if (client == 0 && swap_mb && swap_mb < phys_mb) {
  840. #if defined(__hpux) || defined(__sun)
  841. #else
  842. if (flag_html) printf("<P>\n");
  843. printf("%s: There is %dMB of physical memory but only %dMB of swap space.\n\n",
  844. "ERROR ",
  845. phys_mb,swap_mb);
  846. if (flag_html) printf("</P>\n");
  847. #endif
  848. } else {
  849. if (flag_debug) printf("DEBUG : %d MB swap configured\n", swap_mb);
  850. }
  851. uid = getuid();
  852. if (uid != 0) {
  853. uid = geteuid();
  854. }
  855. #if defined(__sun)
  856. if (uid != 0) {
  857. if (flag_html) printf("<P>\n");
  858. if (flag_quick == 0) {
  859. printf("WARNING: This program should be run by the superuser to collect kernel\ninformation on the overriding maximum backlog queue size and IP tuning.\n\n");
  860. flag_warnings++;
  861. }
  862. flag_nonroot = 1;
  863. if (flag_html) printf("</P>\n");
  864. }
  865. #endif
  866. #if defined(__sun)
  867. if (flag_quick == 0 && flag_nonroot == 0) {
  868. if (flag_debug) printf("DEBUG : adb\n");
  869. if (iii_pio_procparse("/usr/bin/echo \"tcp_param_arr+14/D\" | /usr/bin/adb -k /dev/ksyms /dev/mem",
  870. III_PIO_SZ(ptb_adb),
  871. ptb_adb) == -1) {
  872. perror("adb");
  873. }
  874. }
  875. sun_check_etcsystem();
  876. #endif
  877. if (uid != 0) {
  878. printf("\n");
  879. }
  880. if (flag_html) printf("</P>\n");
  881. }
  882. #if defined(__sun) || defined(__hpux) || defined(IDDS_LINUX_SYSCTL)
  883. static int ndd_get_tcp (char *a,long *vPtr)
  884. {
  885. char buf[8192];
  886. #if defined(__sun)
  887. sprintf(buf,"/usr/sbin/ndd /dev/tcp %s",a);
  888. #else
  889. #if defined(__hpux)
  890. sprintf(buf,"/usr/bin/ndd /dev/tcp %s",a);
  891. #else
  892. #if defined(IDDS_LINUX_SYSCTL)
  893. sprintf(buf,"/sbin/sysctl -n %s",a);
  894. #else
  895. sprintf(buf,"ndd /dev/tcp %s",a);
  896. #endif
  897. #endif
  898. #endif
  899. if (flag_debug) printf("DEBUG : %s\n",buf);
  900. if (iii_pio_getnum(buf,vPtr) == -1) {
  901. if (flag_solaris_251) {
  902. if (strcmp(a,"tcp_conn_req_max_q0") == 0 ||
  903. strcmp(a,"tcp_conn_req_max_q") == 0 ||
  904. strcmp(a,"tcp_slow_start_initial") == 0) {
  905. return -1;
  906. }
  907. }
  908. printf("NOTICE : %s failed\n",buf);
  909. return -1;
  910. }
  911. return 0;
  912. }
  913. #endif
  914. #if defined(__sun)
  915. static int patch_get_ver(int n)
  916. {
  917. int i;
  918. for (i = 0;iii_patches[i].pnum != 0; i++) {
  919. if (iii_patches[i].pnum == n) {
  920. return iii_patches[i].seen;
  921. }
  922. }
  923. return 0;
  924. }
  925. #endif
  926. #if defined(__hpux)
  927. #include <dirent.h>
  928. #define HP_PATCH_DIR "/var/adm/sw/products"
  929. char *mo_lookup[] =
  930. {
  931. "January",
  932. "February",
  933. "March",
  934. "April",
  935. "May",
  936. "June",
  937. "July",
  938. "August",
  939. "September",
  940. "October",
  941. "November",
  942. "December",
  943. NULL
  944. };
  945. static int month_lookup(char *month)
  946. {
  947. int i;
  948. for (i = 0; mo_lookup[i]; i++)
  949. {
  950. if (!strcmp(month, mo_lookup[i]))
  951. return i+1;
  952. }
  953. return 0; /* error */
  954. }
  955. static void hp_check_index(char *index_path, char *desc, int yr, int mo)
  956. {
  957. FILE *fp = fopen(index_path, "r");
  958. char buf[BUFSIZ];
  959. if (NULL == fp)
  960. {
  961. printf("ERROR: Failed to open Patch info file %s\n", index_path);
  962. return;
  963. }
  964. while (fgets(buf, BUFSIZ, fp))
  965. {
  966. if (!strncmp(buf, "title", 5))
  967. {
  968. char *p;
  969. char *datep = NULL;
  970. if (p = strstr(buf, desc))
  971. {
  972. if (NULL != p)
  973. {
  974. /* found */
  975. datep = strrchr(buf, ',');
  976. if (!datep)
  977. {
  978. /* printf("WARNING: No date found: %s\n", datep);*/
  979. continue;
  980. }
  981. datep++;
  982. while (*datep == ' ' || *datep == '\t') datep++;
  983. p = strchr(datep, ' ');
  984. if (p)
  985. {
  986. char *q = p + 1;
  987. while (*q == ' ' || *q == '\t') q++;
  988. if (isdigit(*q))
  989. {
  990. char *qq;
  991. int my_year;
  992. for (qq = q; qq && *qq && isdigit(*qq); qq++) ;
  993. if (qq && *qq)
  994. *qq = '\0';
  995. my_year = atoi(q);
  996. if (my_year < yr)
  997. {
  998. printf("ERROR : %s, %s is older than the supported QPK of %s %d\n\n",
  999. desc, datep, mo_lookup[mo-1], yr);
  1000. }
  1001. else if (my_year == yr)
  1002. {
  1003. int my_month;
  1004. *p = '\0';
  1005. my_month = month_lookup(datep);
  1006. *p = ' ';
  1007. if (my_month < mo)
  1008. {
  1009. printf("ERROR : %s, %s is older than the supported QPK of %s %d\n\n",
  1010. desc, datep, mo_lookup[mo-1], yr);
  1011. }
  1012. #ifdef QPK_DEBUG
  1013. else
  1014. {
  1015. printf("NOTICE: %s: Date %s is NO older than %d/%d\n",
  1016. desc, datep, mo, yr);
  1017. }
  1018. #endif
  1019. }
  1020. #ifdef QPK_DEBUG
  1021. else
  1022. {
  1023. printf("NOTICE: %s: Date %s is NO older than %d/%d\n",
  1024. desc, datep, mo, yr);
  1025. }
  1026. #endif
  1027. }
  1028. else
  1029. {
  1030. printf("WARNING: Bad formatted date: %s\n", datep);
  1031. flag_warnings++;
  1032. }
  1033. }
  1034. }
  1035. }
  1036. }
  1037. }
  1038. fclose(fp);
  1039. }
  1040. static void hp_check_qpk()
  1041. {
  1042. char fbuf[MAXPATHLEN];
  1043. int i,pm= 0;
  1044. int found = 0;
  1045. DIR *prod_dir = NULL;
  1046. struct dirent *dp = NULL;
  1047. if (access(HP_PATCH_DIR,X_OK) == -1) {
  1048. printf("\nWARNING : Only the superuser can check which patches are installed. You must\nrun dsktune as root to ensure the necessary patches are present. If required\npatches are not present, the server may not function correctly.\n\n");
  1049. flag_warnings++;
  1050. return;
  1051. }
  1052. for (i = 0; iii_qpk[i].qpk_name; i++)
  1053. {
  1054. prod_dir = opendir(HP_PATCH_DIR);
  1055. if (!prod_dir)
  1056. {
  1057. printf("ERROR : Patch directory %s has a problem.\n\n", HP_PATCH_DIR);
  1058. return;
  1059. }
  1060. found = 0;
  1061. while ((dp = readdir(prod_dir)) != NULL)
  1062. {
  1063. int len = strlen(iii_qpk[i].qpk_name);
  1064. if (strncmp(dp->d_name, iii_qpk[i].qpk_name, len) == 0)
  1065. {
  1066. /* matched */
  1067. found=1;
  1068. sprintf(fbuf, "%s/%s/pfiles/INDEX", HP_PATCH_DIR, dp->d_name);
  1069. if (access(fbuf, R_OK) == -1)
  1070. {
  1071. printf("WARNING : Patch info file %s does not exist or not readable.\n\n", fbuf);
  1072. flag_warnings++;
  1073. }
  1074. else
  1075. {
  1076. hp_check_index(fbuf, iii_qpk[i].qpk_desc, iii_qpk[i].qpk_yr, iii_qpk[i].qpk_mo);
  1077. }
  1078. }
  1079. }
  1080. if(found==0)
  1081. {
  1082. printf("ERROR : Patch %s (%s) was not found.\n\n",iii_qpk[i].qpk_name,iii_qpk[i].qpk_desc);
  1083. }
  1084. (void) closedir(prod_dir);
  1085. }
  1086. }
  1087. static void hp_pthreads_tests(void)
  1088. {
  1089. unsigned long tmax,omax;
  1090. long cpu64;
  1091. cpu64 = sysconf(_SC_HW_32_64_CAPABLE);
  1092. if (_SYSTEM_SUPPORTS_LP64OS(cpu64) == 0) {
  1093. printf("WARNING: This system does not support 64 bit operating systems.\n\n");
  1094. flag_warnings++;
  1095. } else {
  1096. if (flag_debug) printf("DEBUG : _SC_HW_32_64_CAPABLE 0x%lx\n",cpu64);
  1097. }
  1098. tmax = sysconf(_SC_THREAD_THREADS_MAX);
  1099. if (tmax < 128) {
  1100. printf("WARNING: only %lu threads are available in a process.\n", tmax);
  1101. printf("NOTICE : use kmtune or sam Kernel Configuration Parameters to change max_thread_proc\n");
  1102. printf("and nkthreads as needed.\n\n");
  1103. flag_warnings++;
  1104. } else {
  1105. if (flag_debug) printf("DEBUG : HP-UX max threads %lu\n", tmax);
  1106. }
  1107. /* XXX set ncallout (max number of pending timeouts ) to 128 + NPROC */
  1108. /* set maxfiles to at least 120 */
  1109. omax = sysconf(_SC_OPEN_MAX);
  1110. if (omax < 120) {
  1111. printf("WARNING: only %lu files can be opened at once in a process.\n",omax);
  1112. printf("NOTICE : use kmtune or sam Kernel Configuration Parameters to change maxfiles.\n");
  1113. flag_warnings++;
  1114. } else {
  1115. if (flag_debug) printf("DEBUG : HP-UX maxfiles %ld\n", omax);
  1116. }
  1117. }
  1118. #endif
  1119. #if defined(__sun)
  1120. static void sun_check_network_device(void)
  1121. {
  1122. int devfd;
  1123. char buf[8192];
  1124. long ls;
  1125. if (flag_intel || flag_arch_bad || flag_os_bad) return;
  1126. devfd = open(SUN_NETWORK_DEVICE,O_RDONLY);
  1127. if (devfd == -1) {
  1128. switch (errno) {
  1129. case EACCES:
  1130. if (flag_debug) printf("DEBUG : got EACCES opening %s\n",
  1131. SUN_NETWORK_DEVICE);
  1132. break;
  1133. case ENOENT:
  1134. if (flag_debug) printf("DEBUG : got ENOENT opening %s\n",
  1135. SUN_NETWORK_DEVICE);
  1136. break;
  1137. default:
  1138. if (flag_debug) printf("DEBUG : got %d opening %s\n",
  1139. errno,SUN_NETWORK_DEVICE);
  1140. }
  1141. return;
  1142. } else {
  1143. close(devfd);
  1144. }
  1145. sprintf(buf,"/usr/sbin/ndd %s link_speed",SUN_NETWORK_DEVICE);
  1146. if (flag_debug) printf("DEBUG : %s\n",buf);
  1147. if (iii_pio_getnum(buf,&ls) == -1) {
  1148. if (flag_debug) printf("DEBUG : %s link_speed variable not available\n",
  1149. SUN_NETWORK_DEVICE);
  1150. } else {
  1151. /* XXX look at link speed */
  1152. if (flag_debug) printf("DEBUG : %s link_speed is %d\n",
  1153. SUN_NETWORK_DEVICE,ls);
  1154. }
  1155. }
  1156. #endif
  1157. #if defined(__sun) || defined(__hpux)|| defined(IDDS_LINUX_SYSCTL)
  1158. static void ndd_tests (void)
  1159. {
  1160. if (flag_html) printf("<P>\n");
  1161. #if defined(IDDS_LINUX_SYSCTL)
  1162. /* following linux sysctls are TBD:
  1163. net.ipv4.tcp_max_syn_backlog, net.ipv4.tcp_fin_timeout
  1164. tcp_retries2 and tcp_retries
  1165. */
  1166. #endif
  1167. #if !defined(IDDS_BSD_SYSCTL) && !defined(IDDS_LINUX_SYSCTL)
  1168. {
  1169. char *name_tcp_time_wait_interval;
  1170. if (!flag_solaris_26) {
  1171. name_tcp_time_wait_interval = NAME_TCP_TIME_WAIT_INTERVAL;
  1172. } else {
  1173. name_tcp_time_wait_interval = "tcp_close_wait_interval";
  1174. }
  1175. if (ndd_get_tcp(name_tcp_time_wait_interval, &ndd_tcp_time_wait_interval) == 0) {
  1176. if (ndd_tcp_time_wait_interval >= 240000) {
  1177. if (flag_html) printf("<P>\n");
  1178. printf("%s: The %s is set to %ld milliseconds (%ld seconds).\n"
  1179. "This value should be reduced to allow for more simultaneous connections\n"
  1180. "to the server.\n",
  1181. flag_carrier ? "ERROR " : "WARNING",
  1182. name_tcp_time_wait_interval,
  1183. ndd_tcp_time_wait_interval,
  1184. ndd_tcp_time_wait_interval/1000);
  1185. #ifdef NAME_NDD_CFG_FILE
  1186. printf("An entry similar to the following\nshould be added to the %s file:\n", NAME_NDD_CFG_FILE);
  1187. if (flag_html) printf("</P><PRE>\n");
  1188. printf("TRANSPORT_NAME[10]=tcp\n");
  1189. printf("NDD_NAME[10]=%s\n", name_tcp_time_wait_interval);
  1190. printf("NDD_VALUE[10]=%d\n\n", 30000);
  1191. if (flag_html) printf("</PRE><P>\n");
  1192. #endif
  1193. if (flag_carrier) {
  1194. flag_os_bad = 1;
  1195. } else {
  1196. flag_warnings++;
  1197. }
  1198. } else if (ndd_tcp_time_wait_interval < 10000) {
  1199. if (flag_html) printf("<P>\n");
  1200. printf("WARNING: The %s is set to %ld milliseconds. Values below\n30000 may cause problems.\n\n",
  1201. name_tcp_time_wait_interval, ndd_tcp_time_wait_interval);
  1202. if (flag_html) printf("</P>\n");
  1203. flag_warnings++;
  1204. } else {
  1205. if (flag_debug) {
  1206. printf("DEBUG : %s %ld\n", name_tcp_time_wait_interval, ndd_tcp_time_wait_interval);
  1207. }
  1208. }
  1209. }
  1210. }
  1211. #if defined(__sun)
  1212. if (client == 0) {
  1213. if (ndd_get_tcp("tcp_conn_req_max_q0",&ndd_tcp_conn_req_max_q0) == 0) {
  1214. if (ndd_tcp_conn_req_max_q0 < 1024) {
  1215. if (flag_html) printf("<P>\n");
  1216. printf("ERROR : The tcp_conn_req_max_q0 value is too low, %d.\n\n",
  1217. ndd_tcp_conn_req_max_q0);
  1218. if (flag_solaris_251) {
  1219. printf("ERROR : Patches %s and %s may need to be applied.\n\n",
  1220. flag_intel ? "103631-10" : "103630-13",
  1221. flag_intel ? "103581-18" : "103582-18");
  1222. }
  1223. if (flag_html) printf("</P>\n");
  1224. } else if (ndd_tcp_conn_req_max_q0 >= (flag_carrier ? 10240 : 1024)) {
  1225. if (flag_debug) {
  1226. printf("DEBUG : tcp_conn_req_max_q0 %d\n",
  1227. ndd_tcp_conn_req_max_q0);
  1228. }
  1229. } else {
  1230. if (flag_html) printf("<P>\n");
  1231. printf("WARNING: The tcp_conn_req_max_q0 value is currently %d, which will limit the\nvalue of listen backlog which can be configured. It can be raised by adding\nto /etc/init.d/inetinit, after any adb command, a line similar to:\n",
  1232. ndd_tcp_conn_req_max_q0);
  1233. if (flag_html) printf("</P><PRE>\n");
  1234. printf("ndd -set /dev/tcp tcp_conn_req_max_q0 65536\n");
  1235. if (flag_html) printf("</PRE><P>\n");
  1236. if (tcp_max_listen == 1024) {
  1237. printf("Raising this to a value larger than 1024 may require that adb be used first\nto change the maximum setting.\n");
  1238. }
  1239. if (flag_html) printf("</P>\n");
  1240. printf("\n");
  1241. flag_warnings++;
  1242. }
  1243. if (tcp_max_listen && ndd_tcp_conn_req_max_q0 > tcp_max_listen) {
  1244. if (flag_html) printf("<P>\n");
  1245. printf("WARNING: tcp_conn_req_max_q0 is larger than the kernel will allow.\n\n");
  1246. if (flag_html) printf("</P>\n");
  1247. }
  1248. } else {
  1249. if (flag_solaris_251) {
  1250. if (flag_html) printf("<P>\n");
  1251. printf("ERROR : Solaris tuning parameters were improved in patch %s for\nSolaris 2.5.1 which introduces a fix for the SYN flood attack. Installing\nthis patch is strongly recommended.\n\n",
  1252. flag_intel ? "103581-18" : "103582-18");
  1253. if (flag_html) printf("</P>\n");
  1254. }
  1255. }
  1256. }
  1257. #endif
  1258. if (client == 0) {
  1259. int recommended_tcp_conn_req_max = 128;
  1260. if (ndd_get_tcp(NAME_TCP_CONN_REQ_MAX_Q, &ndd_tcp_conn_req_max_q) == 0) {
  1261. if (flag_html) printf("<P>\n");
  1262. if (ndd_tcp_conn_req_max_q < recommended_tcp_conn_req_max) {
  1263. printf("ERROR : The NDD %s value %ld is lower than the recommended minimum, %d.\n\n",
  1264. NAME_TCP_CONN_REQ_MAX_Q, ndd_tcp_conn_req_max_q, recommended_tcp_conn_req_max);
  1265. if (flag_solaris_251) {
  1266. printf("ERROR : Patches %s and %s may need to be applied.\n\n",
  1267. flag_intel ? "103631-10" : "103630-13",
  1268. flag_intel ? "103581-18" : "103582-18");
  1269. }
  1270. } else if (ndd_tcp_conn_req_max_q >= ndd_tcp_conn_req_max_q0) {
  1271. if (flag_debug) {
  1272. printf("DEBUG : %s %ld\n", NAME_TCP_CONN_REQ_MAX_Q, ndd_tcp_conn_req_max_q);
  1273. }
  1274. } else {
  1275. printf("NOTICE : The %s value is currently %ld, which will limit the\nvalue of listen backlog which can be configured. ",
  1276. NAME_TCP_CONN_REQ_MAX_Q, ndd_tcp_conn_req_max_q);
  1277. #ifdef NAME_NDD_CFG_FILE
  1278. printf("It can be raised by adding\nto %s, after any adb command, an entry similar to:\n", NAME_NDD_CFG_FILE);
  1279. if (flag_html) printf("</P><PRE>\n");
  1280. printf("TRANSPORT_NAME[10]=tcp\n");
  1281. printf("NDD_NAME[10]=%s\n", NAME_TCP_CONN_REQ_MAX_Q);
  1282. printf("NDD_VALUE[10]=%ld\n\n", ndd_tcp_conn_req_max_q0);
  1283. if (flag_html) printf("</PRE><P>\n");
  1284. #endif
  1285. if (tcp_max_listen == 1024) {
  1286. printf("Raising this to a value larger than 1024 may require that adb be used first\nto change the maximum setting.\n");
  1287. }
  1288. printf("\n");
  1289. }
  1290. if (flag_html) printf("</P><P>\n");
  1291. if (tcp_max_listen && ndd_tcp_conn_req_max_q > tcp_max_listen) {
  1292. printf("WARNING: %s (value %ld) is larger than the kernel will allow.\n\n", NAME_TCP_CONN_REQ_MAX_Q, ndd_tcp_conn_req_max_q);
  1293. flag_warnings++;
  1294. }
  1295. if (flag_html) printf("</P><P>\n");
  1296. } else {
  1297. if (flag_solaris_251) {
  1298. if (flag_html) printf("</P><P>\n");
  1299. printf("ERROR : Solaris tuning parameters were improved in patch %s for\nSolaris 2.5.1 which introduces a fix for the SYN flood attack. Installing\nthis patch is strongly recommended.\n\n",
  1300. flag_intel ? "103581-18" : "103582-18");
  1301. if (flag_html) printf("</P><P>\n");
  1302. }
  1303. }
  1304. }
  1305. #endif
  1306. /* end of Solaris/HP-only code */
  1307. if (client == 0) {
  1308. if (ndd_get_tcp(NAME_TCP_KEEPALIVE_INTERVAL, &ndd_tcp_keepalive_interval) == 0) {
  1309. #if defined(IDDS_LINUX_SYSCTL)
  1310. ndd_tcp_keepalive_interval *= 1000; /* seconds to milliseconds */
  1311. #endif
  1312. if (ndd_tcp_keepalive_interval) {
  1313. if (solaris_version == 25 || solaris_version == 24) {
  1314. if (flag_html) printf("</P><P>\n");
  1315. printf("ERROR : The %s should not be set on versions of Solaris\nprior to 2.6 as thery contain a bug that causes infinite transmission.\n\n",NAME_TCP_KEEPALIVE_INTERVAL);
  1316. if (flag_html) printf("</P><P>\n");
  1317. } else if (flag_solaris_251) {
  1318. if (flag_html) printf("</P><P>\n");
  1319. printf("WARNING: There may be a bug in Solaris 2.5.1 which causes infinite\nretransmission when the %s (%ld s) is set. As there is\nno known fix, upgrading to Solaris 2.6 or later is recommended.\n\n",
  1320. NAME_TCP_KEEPALIVE_INTERVAL, ndd_tcp_keepalive_interval/1000);
  1321. if (flag_html) printf("</P><P>\n");
  1322. flag_warnings++;
  1323. } else {
  1324. if (ndd_tcp_keepalive_interval < 60000) {
  1325. if (flag_html) printf("</P><P>\n");
  1326. printf("NOTICE : The %s is set to %ld milliseconds\n(%ld seconds). This may cause excessive retransmissions in WAN\nenvironments.\n\n",
  1327. NAME_TCP_KEEPALIVE_INTERVAL,
  1328. ndd_tcp_keepalive_interval,
  1329. ndd_tcp_keepalive_interval/1000);
  1330. if (flag_html) printf("</P><P>\n");
  1331. } else if (ndd_tcp_keepalive_interval > 600000) {
  1332. if (flag_html) printf("</P><P>\n");
  1333. printf("NOTICE : The %s is set to %ld milliseconds\n(%ld minutes). This may cause temporary server congestion from lost\nclient connections.\n\n",
  1334. NAME_TCP_KEEPALIVE_INTERVAL,
  1335. ndd_tcp_keepalive_interval,
  1336. ndd_tcp_keepalive_interval / 60000);
  1337. if (flag_html) printf("</P><P>\n");
  1338. #ifdef NAME_NDD_CFG_FILE
  1339. printf("An entry similar to the following should be added to %s:\n", NAME_NDD_CFG_FILE);
  1340. if (flag_html) printf("</P><PRE>\n");
  1341. printf("TRANSPORT_NAME[10]=tcp\n");
  1342. printf("NDD_NAME[10]=%s\n", NAME_TCP_KEEPALIVE_INTERVAL);
  1343. printf("NDD_VALUE[10]=%d\n\n", 600000);
  1344. if (flag_html) printf("</PRE><P>\n");
  1345. #endif
  1346. } else if (flag_debug) {
  1347. printf("DEBUG : %s %ld (%ld seconds)\n",
  1348. NAME_TCP_KEEPALIVE_INTERVAL,
  1349. ndd_tcp_keepalive_interval,
  1350. ndd_tcp_keepalive_interval / 1000);
  1351. }
  1352. }
  1353. } else {
  1354. if (flag_solaris_251) {
  1355. if (flag_html) printf("</P><P>\n");
  1356. printf("NOTICE : The %s is currently not set. Setting this value\nshould only be done on Solaris 2.6 or later, due to a bug in earlier versions\nof Solaris.\n\n",NAME_TCP_KEEPALIVE_INTERVAL);
  1357. if (flag_html) printf("</P><P>\n");
  1358. } else {
  1359. if (flag_html) printf("</P><P>\n");
  1360. #ifdef NAME_NDD_CFG_FILE
  1361. printf("NOTICE : The %s is currently not set. This could result in\neventual server congestion. The interval can be set by adding an entry similar to the following to %s:\n",NAME_TCP_KEEPALIVE_INTERVAL, NAME_NDD_CFG_FILE);
  1362. if (flag_html) printf("</P><PRE>\n");
  1363. printf("TRANSPORT_NAME[10]=tcp\n");
  1364. printf("NDD_NAME[10]=%s\n", NAME_TCP_KEEPALIVE_INTERVAL);
  1365. printf("NDD_VALUE[10]=%d\n\n", 60000);
  1366. if (flag_html) printf("</PRE><P>\n");
  1367. #endif
  1368. printf("\n");
  1369. }
  1370. }
  1371. }
  1372. }
  1373. #if !defined(IDDS_LINUX_SYSCTL)
  1374. if (ndd_get_tcp("tcp_rexmit_interval_initial",
  1375. &ndd_tcp_rexmit_interval_initial) == 0) {
  1376. if (ndd_tcp_rexmit_interval_initial > 2000) {
  1377. if (flag_html) printf("</P><P>\n");
  1378. printf("NOTICE : The NDD tcp_rexmit_interval_initial is currently set to %ld\nmilliseconds (%ld seconds). This may cause packet loss for clients on\nSolaris 2.5.1 due to a bug in that version of Solaris. If the clients\nare not using Solaris 2.5.1, no problems should occur.\n\n",
  1379. ndd_tcp_rexmit_interval_initial,
  1380. ndd_tcp_rexmit_interval_initial/1000);
  1381. if (flag_html) printf("</P><P>\n");
  1382. #ifdef NAME_NDD_CFG_FILE
  1383. if (client) {
  1384. printf("NOTICE : For testing on a LAN or high speed WAN, this interval can be reduced\n"
  1385. "by adding an entry similar to the following to %s file:\n", NAME_NDD_CFG_FILE);
  1386. } else {
  1387. printf("NOTICE : If the directory service is intended only for LAN or private \n"
  1388. "high-speed WAN environment, this interval can be reduced by adding an\n"
  1389. "entry similar to the following to %s file:\n", NAME_NDD_CFG_FILE);
  1390. }
  1391. if (flag_html) printf("</P><PRE>\n");
  1392. printf("TRANSPORT_NAME[10]=tcp\n");
  1393. printf("NDD_NAME[10]=tcp_rexmit_interval_initial\n");
  1394. printf("NDD_VALUE[10]=%d\n\n", 500);
  1395. if (flag_html) printf("</PRE><P>\n");
  1396. #endif
  1397. } else {
  1398. if (flag_html) printf("</P><P>\n");
  1399. printf("NOTICE : The tcp_rexmit_interval_initial is currently set to %ld\n"
  1400. "milliseconds (%ld seconds). This may cause excessive retransmission on the\n"
  1401. "Internet.\n\n",
  1402. ndd_tcp_rexmit_interval_initial,
  1403. ndd_tcp_rexmit_interval_initial/1000);
  1404. if (flag_html) printf("</P><P>\n");
  1405. }
  1406. }
  1407. #endif
  1408. #if !defined(IDDS_LINUX_SYSCTL)
  1409. if (ndd_get_tcp("tcp_ip_abort_cinterval", &ndd_tcp_ip_abort_cinterval) == 0) {
  1410. if (ndd_tcp_ip_abort_cinterval > 10000) {
  1411. if (flag_html) printf("</P><P>\n");
  1412. printf("NOTICE : The NDD tcp_ip_abort_cinterval is currently set to %ld\n"
  1413. "milliseconds (%ld seconds). This may cause long delays in establishing\n"
  1414. "outgoing connections if the destination server is down.\n\n",
  1415. ndd_tcp_ip_abort_cinterval,
  1416. ndd_tcp_ip_abort_cinterval/1000);
  1417. if (flag_html) printf("</P><P>\n");
  1418. #ifdef NAME_NDD_CFG_FILE
  1419. printf("NOTICE : If the directory service is intended only for LAN or private \n"
  1420. "high-speed WAN environment, this interval can be reduced by adding an entry\n"
  1421. "similar to the following to %s file:\n", NAME_NDD_CFG_FILE);
  1422. if (flag_html) printf("</P><PRE>\n");
  1423. printf("TRANSPORT_NAME[10]=tcp\n");
  1424. printf("NDD_NAME[10]=tcp_ip_abort_cinterval\n");
  1425. printf("NDD_VALUE[10]=%d\n\n", 10000);
  1426. if (flag_html) printf("</PRE><P>\n");
  1427. #endif
  1428. }
  1429. }
  1430. if (ndd_get_tcp("tcp_ip_abort_interval", &ndd_tcp_ip_abort_interval) == 0) {
  1431. if (ndd_tcp_ip_abort_cinterval > 60000) {
  1432. if (flag_html) printf("</P><P>\n");
  1433. printf("NOTICE : The NDD tcp_ip_abort_interval is currently set to %ld\nmilliseconds (%ld seconds). This may cause long delays in detecting\nconnection failure if the destination server is down.\n\n",
  1434. ndd_tcp_ip_abort_cinterval,
  1435. ndd_tcp_ip_abort_cinterval/1000);
  1436. if (flag_html) printf("</P><P>\n");
  1437. #ifdef NAME_NDD_CFG_FILE
  1438. printf("NOTICE : If the directory service is intended only for LAN or private \nhigh-speed WAN environment, this interval can be reduced by adding an entry\nsimilar to the following to %s:\n", NAME_NDD_CFG_FILE);
  1439. if (flag_html) printf("</P><PRE>\n");
  1440. printf("TRANSPORT_NAME[10]=tcp\n");
  1441. printf("NDD_NAME[10]=tcp_ip_abort_interval\n");
  1442. printf("NDD_VALUE[10]=%d\n\n", 60000);
  1443. if (flag_html) printf("</PRE><P>\n");
  1444. #endif
  1445. }
  1446. }
  1447. #endif
  1448. #if defined(__sun)
  1449. if (ndd_get_tcp("tcp_strong_iss",
  1450. &ndd_tcp_strong_iss) == 0) {
  1451. switch(ndd_tcp_strong_iss) {
  1452. case 0:
  1453. if (flag_debug) printf("DEBUG : tcp_strong_iss 0\n");
  1454. break;
  1455. case 1:
  1456. if (flag_debug) printf("DEBUG : tcp_strong_iss 1\n");
  1457. printf("NOTICE : The TCP initial sequence number generation is not based on RFC 1948.\nIf this directory service is intended for external access, add the following\nto /etc/init.d/inetinit:\n");
  1458. if (flag_html) printf("</P><PRE>\n");
  1459. printf("ndd -set /dev/tcp tcp_strong_iss 2\n\n");
  1460. if (flag_html) printf("</PRE><P>\n");
  1461. break;
  1462. case 2:
  1463. if (flag_debug) printf("DEBUG : tcp_strong_iss 2\n");
  1464. break;
  1465. }
  1466. } else {
  1467. if (flag_debug) printf("DEBUG : tcp_strong_iss not found\n");
  1468. }
  1469. #endif
  1470. /* Linux uses net.ipv4.ip_local_port_range = 1024 4999 */
  1471. #if !defined(IDDS_LINUX_SYSCTL)
  1472. if (ndd_get_tcp(NAME_TCP_SMALLEST_ANON_PORT,
  1473. &ndd_tcp_smallest_anon_port) == 0) {
  1474. if (ndd_tcp_smallest_anon_port >= 32768) {
  1475. int aport = 65536-ndd_tcp_smallest_anon_port;
  1476. if (flag_html) printf("</P><P>\n");
  1477. printf("%s: The NDD %s is currently %ld. This allows a\nmaximum of %ld simultaneous connections. ",
  1478. (flag_carrier || aport <= 16384) ? "ERROR " : "NOTICE ",
  1479. NAME_TCP_SMALLEST_ANON_PORT,
  1480. ndd_tcp_smallest_anon_port,
  1481. 65536 - ndd_tcp_smallest_anon_port);
  1482. if (flag_carrier) flag_os_bad = 1;
  1483. #ifdef NAME_NDD_CFG_FILE
  1484. printf("More ports can be made available by\nadding an entry similar to\nthe following to %s:\n", NAME_NDD_CFG_FILE);
  1485. if (flag_html) printf("</P><PRE>\n");
  1486. printf("TRANSPORT_NAME[10]=tcp\n");
  1487. printf("NDD_NAME[10]=tcp_smallest_anon_port\n");
  1488. printf("NDD_VALUE[10]=%d\n\n", 8192);
  1489. if (flag_html) printf("</PRE><P>\n");
  1490. #endif
  1491. printf("\n");
  1492. } else {
  1493. if (flag_debug) {
  1494. printf("DEBUG : %s %ld\n", NAME_TCP_SMALLEST_ANON_PORT,
  1495. ndd_tcp_smallest_anon_port);
  1496. }
  1497. }
  1498. }
  1499. #endif
  1500. #if defined(__sun)
  1501. if (ndd_get_tcp("tcp_slow_start_initial",&ndd_tcp_slow_start_initial) == 0) {
  1502. if (ndd_tcp_slow_start_initial == 2 || ndd_tcp_slow_start_initial == 4) {
  1503. if (flag_debug) printf("DEBUG : tcp_slow_start_initial %ld\n",
  1504. ndd_tcp_slow_start_initial);
  1505. } else if (ndd_tcp_slow_start_initial == 1) {
  1506. if (client == 0) {
  1507. if (flag_html) printf("</P><P>\n");
  1508. printf("NOTICE : tcp_slow_start_initial is currently 1. If clients are running on\nWindows TCP/IP stack, improved performance may be obtained by changing this\nvalue to 2.");
  1509. printf("This line can be added to the /etc/init.d/inetinit file:\n");
  1510. if (flag_html) printf("</P><PRE>\n");
  1511. printf("ndd -set /dev/tcp tcp_slow_start_initial 2\n");
  1512. if (flag_html) printf("</PRE><P>\n");
  1513. printf("\n");
  1514. }
  1515. } else {
  1516. printf("NOTICE : Unrecognized tcp_slow_start_initial value %ld\n\n",
  1517. ndd_tcp_slow_start_initial);
  1518. }
  1519. } else {
  1520. if (flag_solaris_251) {
  1521. int cpv;
  1522. cpv = patch_get_ver(flag_intel ? 103581: 103582);
  1523. if (flag_html) printf("</P><P>\n");
  1524. printf("ERROR : Solaris tuning parameters were improved in patch %s for\nSolaris 2.5.1 which introduces the tcp_slow_start_initial variable. Installing\n%spatch is strongly recommended.\n\n",
  1525. flag_intel ? "103581-15" : "103582-15",
  1526. cpv == 0 ? "this or a later version of this " : "a later version of this ");
  1527. if (flag_html) printf("</P><P>\n");
  1528. }
  1529. }
  1530. #endif
  1531. #if defined(IDDS_BSD_SYSCTL)
  1532. if (1) {
  1533. if (ndd_get_tcp("net.inet.tcp.delayed_ack",&ndd_tcp_deferred_ack_interval) == 0) {
  1534. if (ndd_tcp_deferred_ack_interval > 0) {
  1535. printf("WARNING: net.inet.tcp.delayed_ack is currently set. This will\ncause FreeBSD to insert artificial delays in the LDAP protocol. It should\nbe reduced during load testing.\n");
  1536. flag_warnings++;
  1537. } else {
  1538. if (flag_debug) printf("DEBUG : ndd /dev/tcp tcp_deferred_ack_interval %ld\n", ndd_tcp_deferred_ack_interval);
  1539. }
  1540. }
  1541. }
  1542. #endif
  1543. #if defined(__sun) || defined(__hpux)
  1544. if (1) {
  1545. if (ndd_get_tcp("tcp_deferred_ack_interval",&ndd_tcp_deferred_ack_interval) == 0) {
  1546. if (ndd_tcp_deferred_ack_interval > 5) {
  1547. printf("%s: tcp_deferred_ack_interval is currently %ld milliseconds. This will\ncause the operating system to insert artificial delays in the LDAP protocol. It should\nbe reduced during load testing.\n",
  1548. flag_carrier ? "ERROR " : "WARNING",
  1549. ndd_tcp_deferred_ack_interval);
  1550. if (flag_carrier) {
  1551. flag_os_bad = 1;
  1552. } else {
  1553. flag_warnings++;
  1554. }
  1555. #ifdef NAME_NDD_CFG_FILE
  1556. printf("An entry similar to the following can be\nadded to the %s file:\n", NAME_NDD_CFG_FILE);
  1557. if (flag_html) printf("</P><PRE>\n");
  1558. printf("TRANSPORT_NAME[10]=tcp\n");
  1559. printf("NDD_NAME[10]=tcp_deferred_ack_interval\n");
  1560. printf("NDD_VALUE[10]=%d\n\n", 5);
  1561. if (flag_html) printf("</PRE><P>\n");
  1562. #endif
  1563. printf("\n");
  1564. } else {
  1565. if (flag_debug) printf("DEBUG : ndd /dev/tcp tcp_deferred_ack_interval %ld\n", ndd_tcp_deferred_ack_interval);
  1566. }
  1567. }
  1568. }
  1569. #endif
  1570. /* must be root to see
  1571. * ip_forward_src_routed, ip_forward_directed_broadcasts,
  1572. * ip_forwarding XXX
  1573. */
  1574. #if defined(__sun)
  1575. sun_check_network_device();
  1576. #endif
  1577. #if !defined(IDDS_LINUX_SYSCTL)
  1578. if (hpux_ndd_change_needed) {
  1579. printf("NOTICE : ndd settings can be placed in /etc/rc.config.d/nddconf\n\n");
  1580. }
  1581. #endif
  1582. if (flag_html) printf("</P>\n");
  1583. }
  1584. #endif
  1585. static int get_disk_avail(char *dir)
  1586. {
  1587. #if defined(__sun)
  1588. char cmd[8192];
  1589. FILE *fp;
  1590. char buf[8192];
  1591. if (client) return 0;
  1592. sprintf(cmd,"df -b %s",dir);
  1593. if (flag_debug) printf("DEBUG : %s\n",cmd);
  1594. fp = popen(cmd,"r");
  1595. if (fp == NULL) {
  1596. perror("popen");
  1597. return -1;
  1598. }
  1599. while (fgets(buf,8192,fp) != NULL) {
  1600. char *rp;
  1601. int i;
  1602. rp = strchr(buf,'\n');
  1603. if (rp) {
  1604. *rp = '\0';
  1605. }
  1606. if (strncmp(buf,"Filesystem",10) == 0) {
  1607. continue;
  1608. }
  1609. if (strncmp(buf,"df: ",4) == 0) {
  1610. printf("ERROR : %s\n\n", buf);
  1611. fclose(fp);
  1612. return -1;
  1613. }
  1614. rp = strchr(buf,':');
  1615. if (rp) {
  1616. *rp = '\0';
  1617. if (flag_html) printf("<P>\n");
  1618. printf("ERROR : %s partition is on file system mounted from %s, not local.\n\n",dir,buf);
  1619. if (flag_html) printf("</P>\n");
  1620. fclose(fp);
  1621. return -1;
  1622. }
  1623. rp = strchr(buf,' ');
  1624. if (rp == NULL) {
  1625. rp = strchr(buf,'\t');
  1626. }
  1627. if (rp == NULL) continue;
  1628. while(isspace(*rp)) rp++;
  1629. if (!isdigit(*rp)) {
  1630. continue;
  1631. }
  1632. i = atoi(rp);
  1633. fclose(fp);
  1634. return (i / 1024);
  1635. }
  1636. fclose (fp);
  1637. #else
  1638. #if defined(IDDS_HAVE_STATVFS)
  1639. struct statvfs vfs;
  1640. if (statvfs(dir,&vfs) == 0) {
  1641. return ((vfs.f_bfree * (vfs.f_bsize / 1024)) / 1024);
  1642. }
  1643. #else
  1644. #if defined(IDDS_LINUX_INCLUDE)
  1645. struct statfs sfs;
  1646. if (statfs(dir,&sfs) == 0) {
  1647. return ((sfs.f_bfree * (sfs.f_bsize / 1024)) / 1024);
  1648. }
  1649. #endif
  1650. #endif
  1651. #endif
  1652. return -1;
  1653. }
  1654. /* return 0 if fsmnt is a longer subset of reqdir than mntbuf */
  1655. static int mntdir_matches(char *reqdir,int reqlen,char *fsmnt,char *mntbuf)
  1656. {
  1657. int cml;
  1658. int pml;
  1659. cml = strlen(fsmnt);
  1660. pml = strlen(mntbuf);
  1661. /* incoming file system is 'below' */
  1662. if (reqlen < cml) {
  1663. if (flag_debug) printf("DEBUG : mntdir_matches want %s < input %s\n",
  1664. reqdir, fsmnt);
  1665. return -1;
  1666. }
  1667. if (reqlen == cml && strcmp(reqdir,fsmnt) == 0) {
  1668. /* exact match */
  1669. if (flag_debug) printf("DEBUG : reqlen %d == cml %d\n", reqlen, cml);
  1670. strcpy(mntbuf,fsmnt);
  1671. return 0;
  1672. }
  1673. /* assert reqlen >= cml */
  1674. if (strncmp(fsmnt,reqdir,cml) != 0) {
  1675. if (flag_debug) printf("DEBUG : fsmnt %s != reqdir %s\n", fsmnt, reqdir);
  1676. return -1;
  1677. }
  1678. if (reqdir[cml] != '/' && cml > 1) {
  1679. if (flag_debug) printf("DEBUG : fsmnt %s: reqdir %s is %c not / \n",
  1680. fsmnt, reqdir, reqdir[cml]);
  1681. return -1;
  1682. }
  1683. if (pml > cml) {
  1684. if (flag_debug) printf("DEBUG : pml %d > cml %d\n", pml, cml);
  1685. return -1;
  1686. }
  1687. if (flag_debug) printf("DEBUG : replacing %s with %s\n", mntbuf, fsmnt);
  1688. strcpy(mntbuf,fsmnt);
  1689. return 0;
  1690. }
  1691. /* check that the file system has largefiles on HP */
  1692. static int check_fs_options(char *reqdir,char mntbuf[MAXPATHLEN])
  1693. {
  1694. #if defined(IDDS_MNTENT_DIRNAME)
  1695. FILE *fp = NULL;
  1696. int found = -1;
  1697. int any_found = 0;
  1698. int reqlen = strlen(reqdir);
  1699. char optbuf[BUFSIZ];
  1700. if (client == 1) return -1;
  1701. mntbuf[0] = '\0';
  1702. optbuf[0] = '\0';
  1703. #if defined(IDDS_MNTENT_MNTTAB)
  1704. fp = fopen(IDDS_MNTENT_MNTTAB,"r");
  1705. if (fp == NULL) {
  1706. perror(IDDS_MNTENT_MNTTAB);
  1707. return -1;
  1708. }
  1709. #endif
  1710. while(1) {
  1711. struct IDDS_MNTENT *mep;
  1712. #if defined(__sun)
  1713. struct IDDS_MNTENT m;
  1714. mep = &m;
  1715. if (getmntent(fp,mep) != 0) break;
  1716. #else
  1717. #if defined(__hpux) || defined(IDDS_LINUX_INCLUDE)
  1718. mep = getmntent(fp);
  1719. if (mep == NULL) break;
  1720. #else
  1721. #if !defined(IDDS_MNTENT_MNTTAB)
  1722. /* not quite the same, but Tru64 and AIX don't have getmntent */
  1723. mep = getfsent();
  1724. if (mep == NULL) break;
  1725. #else
  1726. break;
  1727. #endif
  1728. #endif
  1729. #endif
  1730. if (mntdir_matches(reqdir,reqlen,mep->IDDS_MNTENT_DIRNAME,mntbuf) == 0) {
  1731. found = 0;
  1732. #if defined(IDDS_MNTENT_OPTIONS)
  1733. strncpy(optbuf,mep->IDDS_MNTENT_OPTIONS,sizeof(optbuf));
  1734. optbuf[sizeof(optbuf)-1] = '\0';
  1735. #else
  1736. strcpy(optbuf,"");
  1737. #endif
  1738. if (flag_debug) printf("DEBUG : file system %s matches %s with options %s\n",
  1739. mntbuf, reqdir, optbuf);
  1740. } else {
  1741. #if defined(IDDS_MNTENT_OPTIONS)
  1742. if (strstr(mep->IDDS_MNTENT_OPTIONS,"nolargefiles") != NULL) {
  1743. } else if (strstr(mep->IDDS_MNTENT_OPTIONS,"largefiles") != NULL) {
  1744. if (flag_debug) printf("DEBUG : file system %s allows largefiles\n",
  1745. mep->IDDS_MNTENT_DIRNAME);
  1746. any_found++;
  1747. }
  1748. #endif
  1749. }
  1750. }
  1751. if (fp) fclose (fp);
  1752. #if defined(__hpux)
  1753. if (found == 0) {
  1754. int largefile_missing = 0;
  1755. if (strstr(optbuf,"nolargefiles") != NULL) {
  1756. largefile_missing = 1;
  1757. } else if (strstr(optbuf,"largefiles") == NULL) {
  1758. largefile_missing = 1;
  1759. }
  1760. if (largefile_missing) {
  1761. if (any_found == 0) {
  1762. printf("WARNING: largefiles option is not present on mount of %s, \nfiles may be limited to 2GB in size.\n\n", mntbuf);
  1763. } else {
  1764. printf("WARNING: largefiles option is not present on mount of %s, \nalthough it is present on other file systems. Files on the %s\nfile system will be limited to 2GB in size.\n\n", mntbuf, mntbuf);
  1765. }
  1766. flag_warnings++;
  1767. }
  1768. } else {
  1769. if (any_found == 0) {
  1770. printf("WARNING: no file system mounted with largefiles option.\n\n");
  1771. flag_warnings++;
  1772. }
  1773. }
  1774. #endif
  1775. return found;
  1776. #else
  1777. return -1;
  1778. #endif
  1779. }
  1780. static void check_disk_quota(char mntbuf[MAXPATHLEN])
  1781. {
  1782. #if defined(__sun)
  1783. char qfname[MAXPATHLEN];
  1784. struct stat sbuf;
  1785. sprintf(qfname,"%s/quotas",mntbuf);
  1786. if (stat(qfname,&sbuf) == 0 || errno == EACCES) {
  1787. printf("NOTICE : quotas are present on file system %s.\n\n",mntbuf);
  1788. }
  1789. #endif
  1790. }
  1791. static void disk_tests(void)
  1792. {
  1793. struct rlimit r;
  1794. char mntbuf[MAXPATHLEN];
  1795. if (client) return;
  1796. avail_root = get_disk_avail("/");
  1797. if (flag_debug) printf("DEBUG : %dMB available on /\n",avail_root);
  1798. if (flag_html) printf("<P>\n");
  1799. if (avail_root != -1 && avail_root < 2) {
  1800. if (flag_html) printf("</P><P>\n");
  1801. printf("ERROR : / partition is full\n");
  1802. flag_os_bad = 1;
  1803. if (flag_html) printf("</P><P>\n");
  1804. }
  1805. #if defined(RLIMIT_CORE)
  1806. getrlimit(RLIMIT_CORE,&r);
  1807. if (flag_debug) printf("DEBUG : RLIMIT_CORE is %ld, %ld\n", r.rlim_cur, r.rlim_max);
  1808. if (r.rlim_cur == (unsigned long)-1 || r.rlim_cur >= 2147483647) {
  1809. if (swap_mb <2048) {
  1810. max_core = swap_mb;
  1811. } else {
  1812. max_core = 2048;
  1813. }
  1814. } else {
  1815. max_core = r.rlim_max / (1024*1024);
  1816. }
  1817. if (phys_mb) {
  1818. if (max_core > (phys_mb + swap_mb)) {
  1819. max_core = phys_mb + swap_mb;
  1820. }
  1821. }
  1822. #endif
  1823. if (avail_root != -1 && max_core > avail_root && flag_quick == 0) {
  1824. if (flag_html) printf("</P><P>\n");
  1825. printf("NOTICE : / partition has less space available, %dMB, than the largest \nallowable core file size of %dMB. A daemon process which dumps core could\ncause the root partition to be filled.\n\n",
  1826. avail_root, max_core);
  1827. if (flag_html) printf("</P><P>\n");
  1828. }
  1829. if (install_dir[0] == '\0') {
  1830. if (access("/usr/" VENDOR,X_OK) == 0) {
  1831. sprintf(install_dir,"/usr/" VENDOR);
  1832. } else {
  1833. sprintf(install_dir,"/opt");
  1834. }
  1835. }
  1836. if (check_fs_options(install_dir,mntbuf) == 0) {
  1837. } else {
  1838. strcpy(mntbuf,install_dir);
  1839. }
  1840. avail_opt = get_disk_avail(mntbuf);
  1841. if (flag_debug) printf("DEBUG : %dMB available on %s\n",
  1842. avail_opt,mntbuf);
  1843. if (avail_opt != -1) {
  1844. if (flag_html) printf("</P><P>\n");
  1845. if (avail_opt < 2) {
  1846. printf("ERROR : %s partition is full.\n",mntbuf);
  1847. } else if (avail_opt < 100) {
  1848. printf("NOTICE : %s partition has only %dMB free.\n",mntbuf,avail_opt);
  1849. }
  1850. if (flag_html) printf("</P><P>\n");
  1851. }
  1852. check_disk_quota(mntbuf);
  1853. if (flag_html) printf("</P>\n");
  1854. }
  1855. #if 0
  1856. /* The function hasn't been used. #if 0 to get rid of compiler warning */
  1857. static int get_disk_usage(char *s)
  1858. {
  1859. char cmd[8192];
  1860. char buf[8192];
  1861. FILE *fp;
  1862. int i;
  1863. sprintf(cmd,"du -s -k %s",s);
  1864. if (flag_debug) printf("DEBUG : du -s -k %s\n",s);
  1865. fp = popen(cmd,"r");
  1866. if (fp == NULL) {
  1867. perror("du");
  1868. return 0;
  1869. }
  1870. buf[0] = '\0';
  1871. fgets(buf,8192,fp);
  1872. fclose (fp);
  1873. i = atoi(buf);
  1874. return (i / 1024);
  1875. }
  1876. #endif
  1877. static void check_mem_size(int ro,char *rn)
  1878. {
  1879. struct rlimit r;
  1880. int rprev;
  1881. long m_mb;
  1882. int m_change_needed = 0;
  1883. getrlimit(ro,&r);
  1884. rprev = r.rlim_cur;
  1885. r.rlim_cur = r.rlim_max;
  1886. setrlimit(ro,&r);
  1887. getrlimit(ro,&r);
  1888. if (flag_debug) printf("DEBUG : %s (%d) max %d prev %d.\n",
  1889. rn, ro, (int)r.rlim_cur, rprev);
  1890. #if defined(__alpha) || defined(__ALPHA)
  1891. if (r.rlim_cur <= 0L) return;
  1892. #endif
  1893. if (r.rlim_cur <= 0) return;
  1894. m_mb = r.rlim_cur / 1048576;
  1895. if (m_mb < mem_min) { /* 64 MB */
  1896. printf("ERROR : processes are limited by %s to %ld MB in size.\n",
  1897. rn, m_mb);
  1898. m_change_needed = 1;
  1899. flag_os_bad = 1;
  1900. } else if (m_mb <= mem_rec) {
  1901. printf("WARNING: processes are limited by %s to %ld MB in size.\n",
  1902. rn, m_mb);
  1903. m_change_needed = 1;
  1904. flag_warnings++;
  1905. }
  1906. if (m_change_needed) {
  1907. #if defined(__hpux)
  1908. printf("NOTICE : use kmtune or sam Kernel Configuration Parameters to change the maxdsiz\nand maxdsiz_64bit parameters.\n");
  1909. #endif
  1910. printf("\n");
  1911. }
  1912. }
  1913. static void limits_tests(void)
  1914. {
  1915. struct rlimit r;
  1916. #if defined(RLIMIT_NOFILE)
  1917. getrlimit(RLIMIT_NOFILE,&r);
  1918. if (r.rlim_max <= 1024) {
  1919. if (flag_html) printf("<P>\n");
  1920. if (flag_carrier) {
  1921. printf("ERROR : There are only %ld file descriptors (hard limit) available, which\nlimit the number of simultaneous connections. ",r.rlim_max);
  1922. flag_os_bad = 1;
  1923. } else {
  1924. printf("WARNING: There are only %ld file descriptors (hard limit) available, which\nlimit the number of simultaneous connections. ",r.rlim_max);
  1925. flag_warnings++;
  1926. }
  1927. #if defined(__sun)
  1928. printf("Additional file descriptors,\nup to 65536, are available by adding to /etc/system a line like\n");
  1929. if (flag_html) printf("</P><PRE>\n");
  1930. printf("set rlim_fd_max=4096\n");
  1931. if (flag_html) printf("</PRE><P>\n");
  1932. #else
  1933. #if defined(__hpux)
  1934. printf("Additional file descriptors,\nup to 60000, are available by editing /stand/system and regenerating the kernel.\n");
  1935. if (flag_html) printf("</P><PRE>\n");
  1936. printf("maxfiles_lim 4096\n");
  1937. if (flag_html) printf("</PRE><P>\n");
  1938. #else
  1939. printf("\n");
  1940. #endif
  1941. #endif
  1942. printf("\n");
  1943. if (flag_html) printf("</P>\n");
  1944. } else {
  1945. if (flag_debug) printf("DEBUG : %ld descriptors (hard limit) available.\n",
  1946. r.rlim_max);
  1947. }
  1948. if (r.rlim_cur <= 1024) {
  1949. if (flag_html) printf("<P>\n");
  1950. if (flag_carrier) {
  1951. printf("ERROR : There are only %ld file descriptors (soft limit) available, which\nlimit the number of simultaneous connections. ",r.rlim_cur);
  1952. flag_os_bad = 1;
  1953. } else {
  1954. printf("WARNING: There are only %ld file descriptors (soft limit) available, which\nlimit the number of simultaneous connections. ",r.rlim_cur);
  1955. flag_warnings++;
  1956. }
  1957. #if defined(__sun) || defined(__hpux)
  1958. printf("Additional file descriptors,\nup to %ld (hard limit), are available by issuing \'ulimit\' (\'limit\' for tcsh)\ncommand with proper arguments.\n", r.rlim_max);
  1959. if (flag_html) printf("</P><PRE>\n");
  1960. printf("ulimit -n 4096\n");
  1961. if (flag_html) printf("</PRE><P>\n");
  1962. #else
  1963. printf("\n");
  1964. #endif
  1965. printf("\n");
  1966. if (flag_html) printf("</P>\n");
  1967. } else {
  1968. if (flag_debug) printf("DEBUG : %ld descriptors (soft limit) available.\n",
  1969. r.rlim_cur);
  1970. }
  1971. #endif
  1972. #if defined(RLIMIT_DATA)
  1973. check_mem_size(RLIMIT_DATA,"RLIMIT_DATA");
  1974. #endif
  1975. #if defined(RLIMIT_VMEM)
  1976. check_mem_size(RLIMIT_VMEM,"RLIMIT_VMEM");
  1977. #endif
  1978. #if defined(RLIMIT_AS)
  1979. check_mem_size(RLIMIT_AS,"RLIMIT_AS");
  1980. #endif
  1981. }
  1982. /*
  1983. *** return the type of platform on which the software is running.
  1984. ***/
  1985. static void ids_get_platform(char *buf)
  1986. {
  1987. #if defined(IDDS_LINUX_INCLUDE) || defined(__osf__) || defined(__hpux) || defined(IDDS_BSD_INCLUDE)
  1988. struct utsname u;
  1989. #endif
  1990. #if defined(__hpux)
  1991. char model[128];
  1992. char procstr[128];
  1993. char oslevel[128];
  1994. #endif
  1995. #if defined(__hpux)
  1996. long cpuvers, cputype;
  1997. #endif
  1998. #if defined(IDDS_LINUX_INCLUDE)
  1999. if (uname(&u) == 0) {
  2000. sprintf(buf,"%s-unknown-linux%s",
  2001. u.machine,u.release);
  2002. } else {
  2003. sprintf(buf,"i386-unknown-linux");
  2004. }
  2005. #else
  2006. #if defined(__sun)
  2007. ids_get_platform_solaris(buf);
  2008. #elif defined(IDDS_BSD_INCLUDE)
  2009. uname(&u);
  2010. sprintf(buf,"%s-unknown-%s%s",
  2011. u.machine,u.sysname,u.release);
  2012. #elif defined(__hpux)
  2013. uname(&u);
  2014. confstr(_CS_MACHINE_MODEL,model,128);
  2015. cpuvers = sysconf(_SC_CPU_VERSION);
  2016. cputype = sysconf(_SC_CPU_CHIP_TYPE);
  2017. switch(cpuvers) {
  2018. case CPU_PA_RISC1_0:
  2019. sprintf(procstr,"hppa1.0/%ld",cputype);
  2020. break;
  2021. case CPU_PA_RISC1_1:
  2022. sprintf(procstr,"hppa1.1/%ld",cputype);
  2023. break;
  2024. case CPU_PA_RISC1_2:
  2025. sprintf(procstr,"hppa1.2/%ld",cputype);
  2026. break;
  2027. case CPU_PA_RISC2_0:
  2028. sprintf(procstr,"hppa2.0/%ld",cputype);
  2029. break;
  2030. #if defined(__ia64)
  2031. case CPU_IA64_ARCHREV_0:
  2032. sprintf(procstr,"hpia0/%ld",cputype);
  2033. break;
  2034. #endif
  2035. default:
  2036. sprintf(procstr,"hppa_0x%lx/%ld",cpuvers,cputype);
  2037. break;
  2038. }
  2039. sprintf(buf,"%s-hp%s-hpux_%s",procstr,model,u.release);
  2040. #else
  2041. #if defined(__VMS)
  2042. #if defined (__ALPHA)
  2043. sprintf(buf,"alpha-dec-vms");
  2044. #else
  2045. sprintf(buf,"vax-dec-vms");
  2046. #endif
  2047. #else
  2048. #if defined(__osf__)
  2049. #if defined(__alpha) || defined(__ALPHA)
  2050. ids_get_platform_tru64(buf);
  2051. #else
  2052. sprintf(buf,"unknown-unknown-osf");
  2053. #endif
  2054. #else
  2055. #if defined(SI_HW_PROVIDER) && defined(SI_MACHINE) && defined(SI_SYSNAME) && defined(SI_RELEASE)
  2056. if (1) {
  2057. char *bp;
  2058. sysinfo(SI_MACHINE,buf,64);
  2059. bp = buf + strlen(buf);
  2060. *bp = '-';
  2061. bp++;
  2062. sysinfo(SI_HW_PROVIDER,bp,64);
  2063. bp = bp + strlen(bp);
  2064. *bp = '-';
  2065. bp++;
  2066. sysinfo(SI_SYSNAME,bp,64);
  2067. bp = bp + strlen(bp);
  2068. sysinfo(SI_RELEASE,bp,64);
  2069. }
  2070. #else
  2071. #if defined(SI_MACHINE)
  2072. sysinfo(SI_MACHINE,buf,64);
  2073. strcat(buf,"-unknown-unknown");
  2074. #else
  2075. sprintf(buf,"unknown");
  2076. #endif /* has SI_HW_PROVIDER */
  2077. #endif /* has SI_MACHINE */
  2078. #endif /* OSF */
  2079. #endif /* VMS */
  2080. #endif /* HPUX */
  2081. #endif /* FREEBSD */
  2082. }
  2083. static int count_processors(void)
  2084. {
  2085. int nproc = 0;
  2086. nproc = sysconf(_SC_NPROCESSORS_ONLN);
  2087. return nproc;
  2088. }
  2089. static void usage(char *av)
  2090. {
  2091. printf("usage: %s [-q] [-D] [-v] [-c] [-i installdir]\n",av);
  2092. printf(" -q dsktune only reports essential settings\n");
  2093. printf(" -c dsktune only reports tuning information for client machines\n");
  2094. printf(" -D dsktune also reports the commands executed\n");
  2095. printf(" -v dsktune only reports its release version date\n");
  2096. printf(" -i specify alternate server installation directory\n");
  2097. printf("\n");
  2098. exit(1);
  2099. }
  2100. static void print_version(void)
  2101. {
  2102. printf("%s\n",build_date);
  2103. exit(1);
  2104. }
  2105. int main(int argc,char *argv[])
  2106. {
  2107. int i;
  2108. while((i = getopt(argc,argv,"DvHqcCi:")) != EOF) {
  2109. switch(i) {
  2110. case 'D':
  2111. flag_debug = 1;
  2112. break;
  2113. case 'H':
  2114. flag_html = 1;
  2115. break;
  2116. case 'v':
  2117. print_version();
  2118. break;
  2119. case 'q':
  2120. flag_quick = 1;
  2121. break;
  2122. case 'c':
  2123. client = 1;
  2124. break;
  2125. case 'C':
  2126. flag_carrier = 1;
  2127. break;
  2128. case 'i':
  2129. strncpy(install_dir,optarg,sizeof(install_dir));
  2130. install_dir[sizeof(install_dir)-1] = '\0';
  2131. break;
  2132. default:
  2133. usage(argv[0]);
  2134. break;
  2135. }
  2136. }
  2137. if (flag_quick == 0) {
  2138. char sysbuf[BUFSIZ];
  2139. int nproc;
  2140. if (flag_html) printf("<P>\n");
  2141. printf(CAPBRAND " Directory Server system tuning analysis version %s.\n\n", build_date);
  2142. ids_get_platform(sysbuf);
  2143. nproc = count_processors();
  2144. if (nproc == 1) {
  2145. printf("NOTICE : System is %s (1 processor).\n\n",sysbuf);
  2146. } else if (nproc > 1) {
  2147. printf("NOTICE : System is %s (%d processors).\n\n",sysbuf,nproc);
  2148. } else {
  2149. printf("NOTICE : System is %s.\n\n",sysbuf);
  2150. }
  2151. if (flag_html) printf("</P>\n");
  2152. }
  2153. gen_tests();
  2154. #if defined(__sun) || defined(__hpux) || defined(IDDS_LINUX_SYSCTL)
  2155. ndd_tests();
  2156. #endif
  2157. #if defined(__hpux)
  2158. hp_pthreads_tests();
  2159. #endif
  2160. limits_tests();
  2161. disk_tests();
  2162. if (flag_os_bad || flag_arch_bad) {
  2163. if (flag_html) printf("<P>\n");
  2164. printf("ERROR : The above errors MUST be corrected before proceeding.\n\n");
  2165. if (flag_html) printf("</P>\n");
  2166. exit(1);
  2167. } else if (flag_warnings) {
  2168. if (flag_html) printf("<P>\n");
  2169. printf("WARNING : The warning messages above should be reviewed before proceeding.\n\n");
  2170. if (flag_html) printf("</P>\n");
  2171. exit(1);
  2172. }
  2173. exit(0);
  2174. return 0;
  2175. }