idsktune.c 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright 2001 Sun Microsystems, Inc.
  3. * Portions copyright 1999, 2001-2004 Netscape Communications Corporation.
  4. * All rights reserved.
  5. * END COPYRIGHT BLOCK **/
  6. /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  7. * Don't forget to update build_date when the patch sets are updated.
  8. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
  9. static char *build_date = "19-MARCH-2004";
  10. #if defined(__FreeBSD__) || defined(__bsdi)
  11. #define IDDS_BSD_INCLUDE 1
  12. #define IDDS_BSD_SYSCTL 1
  13. #endif
  14. #if defined(linux) || defined(__linux) || defined(__linux__)
  15. #define IDDS_LINUX_INCLUDE 1
  16. #define IDDS_LINUX_SYSCTL 1
  17. #endif
  18. #if defined(__sun) || defined(__sun__) || defined(_AIX) || defined(__hppa) || defined(_nec_ews_svr4) || defined(__osf__) || defined(__sgi) || defined(sgi)
  19. #define IDDS_SYSV_INCLUDE 1
  20. #endif
  21. #include <sys/types.h>
  22. #if defined(IDDS_BSD_INCLUDE)
  23. #include <sys/time.h>
  24. #endif
  25. #if !defined(_WIN32) && !defined(__VMS)
  26. #include <sys/resource.h>
  27. #include <unistd.h>
  28. #endif
  29. #include <stdlib.h>
  30. #include <string.h>
  31. #include <errno.h>
  32. #include <ctype.h>
  33. #if !defined(_WIN32) && !defined(__VMS) && !defined(IDDS_LINUX_INCLUDE) && !defined(IDDS_BSD_INCLUDE)
  34. #if defined(__hppa) && defined(f_type)
  35. #undef f_type
  36. #endif
  37. #include <sys/statvfs.h>
  38. #define IDDS_HAVE_STATVFS
  39. #endif
  40. #if defined(_WIN32)
  41. #include <windows.h>
  42. #define MAXPATHLEN 1024
  43. extern char *optarg;
  44. #endif
  45. #if defined(IDDS_SYSV_INCLUDE) || defined(IDDS_BSD_INCLUDE)
  46. #include <sys/utsname.h>
  47. #include <sys/stat.h>
  48. #include <sys/param.h>
  49. #endif
  50. #if defined(__sun) || defined(__sun__) || defined(__osf__) || defined(_nec_ews_svr4) || defined(__sgi) || defined(sgi)
  51. /* not available on HP-UX or AIX */
  52. #include <sys/systeminfo.h>
  53. #endif
  54. #if defined(__sun)
  55. #include <stdio.h>
  56. #include <fcntl.h>
  57. #include <sys/mnttab.h>
  58. #define IDDS_MNTENT mnttab
  59. #define IDDS_MNTENT_DIRNAME mnt_mountp
  60. #define IDDS_MNTENT_OPTIONS mnt_mntopts
  61. #define IDDS_MNTENT_MNTTAB "/etc/mnttab"
  62. #endif
  63. #if defined(IDDS_LINUX_INCLUDE)
  64. #include <sys/vfs.h>
  65. #include <sys/utsname.h>
  66. #include <linux/kernel.h>
  67. #include <linux/sys.h>
  68. #include <sys/time.h>
  69. #include <sys/param.h>
  70. #include <mntent.h>
  71. #define IDDS_MNTENT mntent
  72. #define IDDS_MNTENT_DIRNAME mnt_dir
  73. #define IDDS_MNTENT_OPTIONS mnt_opts
  74. #define IDDS_MNTENT_MNTTAB "/etc/mtab"
  75. #endif
  76. #if defined(__hppa)
  77. #include <sys/pstat.h>
  78. #include <mntent.h>
  79. #define IDDS_MNTENT mntent
  80. #define IDDS_MNTENT_DIRNAME mnt_dir
  81. #define IDDS_MNTENT_OPTIONS mnt_opts
  82. #define IDDS_MNTENT_MNTTAB "/etc/mnttab"
  83. #endif
  84. #if defined(_AIX)
  85. #include <pthread.h>
  86. #include <signal.h>
  87. #include <sys/inttypes.h>
  88. #include <odmi.h>
  89. #include <fstab.h>
  90. struct CuAt {
  91. __long32_t _id;
  92. __long32_t _reserved;
  93. __long32_t _scratch;
  94. char name[16];
  95. char attribute[16];
  96. char value[256];
  97. char type[8];
  98. char generic[8];
  99. char rep[8];
  100. short nls_index;
  101. };
  102. #define CuAt_Descs 7
  103. struct fix {
  104. __long32_t _id;
  105. __long32_t _reserved;
  106. __long32_t _scratch;
  107. char name[16];
  108. char abstract[60];
  109. char type[2];
  110. char *filesets;
  111. char *symptom;
  112. };
  113. #define fix_Descs 5
  114. struct Class CuAt_CLASS[];
  115. extern struct Class fix_CLASS[];
  116. static void idds_aix_odm_get_cuat (char *query,char *buf);
  117. #define IDDS_MNTENT fstab
  118. #define IDDS_MNTENT_DIRNAME fs_file
  119. /* AIX does not have /etc/mnttab */
  120. /* #define IDDS_MNTENT_OPTIONS */
  121. #endif
  122. #if defined(__VMS)
  123. #error "This program is not available for VMS"
  124. #endif
  125. #if defined(__osf__)
  126. #include <unistd.h>
  127. #include <sys/stat.h>
  128. #include <sys/swap.h>
  129. #include <sys/sysinfo.h>
  130. #include <sys/utsname.h>
  131. #include <sys/systeminfo.h>
  132. #include <machine/hal_sysinfo.h>
  133. #include <machine/cpuconf.h>
  134. #include <fstab.h>
  135. #define IDDS_MNTENT fstab
  136. #define IDDS_MNTENT_DIRNAME fs_file
  137. #define IDDS_MNTENT_OPTIONS fs_mntops
  138. #endif
  139. #include "pio.h"
  140. int flag_html = 0;
  141. int flag_debug = 0;
  142. int flag_quick = 0;
  143. int flag_os_bad = 0;
  144. int flag_solaris_9 = 0;
  145. int flag_solaris_8 = 0;
  146. int flag_solaris_7 = 0;
  147. int flag_solaris_26 = 0;
  148. int flag_solaris_251 = 0;
  149. int flag_tru64_40b = 0;
  150. int flag_tru64_tuning_needed = 0;
  151. int solaris_version = 0;
  152. int flag_intel = 0;
  153. int flag_arch_bad = 0;
  154. int phys_mb = 0;
  155. int swap_mb = 0;
  156. int flag_mproc = 0;
  157. int tcp_max_listen = 0;
  158. int flag_nonroot = 0;
  159. int flag_carrier = 0;
  160. int conn_thread = 1;
  161. int maxconn = 0;
  162. int client = 0;
  163. int mem_min = 256;
  164. int mem_rec = 1024;
  165. /* Define name variations on different platforms */
  166. #if defined(__sun)
  167. #define NAME_NDD_CFG_FILE "/etc/init.d/inetinit"
  168. #define NAME_TCP_TIME_WAIT_INTERVAL "tcp_time_wait_interval"
  169. #define NAME_TCP_CONN_REQ_MAX_Q "tcp_conn_req_max_q"
  170. #define NAME_TCP_KEEPALIVE_INTERVAL "tcp_keepalive_interval"
  171. #define NAME_TCP_SMALLEST_ANON_PORT "tcp_smallest_anon_port"
  172. #endif
  173. #if defined(__hppa)
  174. #define NAME_NDD_CFG_FILE "/etc/rc.config.d/nddconf"
  175. #define NAME_TCP_TIME_WAIT_INTERVAL "tcp_time_wait_interval"
  176. #define NAME_TCP_CONN_REQ_MAX_Q "tcp_conn_request_max"
  177. #define NAME_TCP_KEEPALIVE_INTERVAL "tcp_keepalive_interval"
  178. #define NAME_TCP_SMALLEST_ANON_PORT "tcp_smallest_anon_port"
  179. #endif
  180. #if defined(IDDS_LINUX_SYSCTL)
  181. #define NAME_TCP_KEEPALIVE_INTERVAL "net.ipv4.tcp_keepalive_time"
  182. #endif
  183. #if defined(IDDS_BSD_SYSCTL)
  184. #define NAME_TCP_SMALLEST_ANON_PORT "net.inet.ip.portrange.hifirst"
  185. #endif
  186. #if defined(__sun) || defined(__hppa) || defined(IDDS_BSD_SYSCTL) || defined(IDDS_LINUX_SYSCTL)
  187. long ndd_tcp_conn_req_max_q = 0;
  188. long ndd_tcp_conn_req_max_q0 = 0;
  189. long ndd_tcp_rexmit_interval_initial = 0;
  190. long ndd_tcp_slow_start_initial = 0;
  191. long ndd_tcp_keepalive_interval = 0;
  192. long ndd_tcp_time_wait_interval = 0;
  193. long ndd_tcp_smallest_anon_port = 0;
  194. long ndd_tcp_deferred_ack_interval = 0;
  195. long ndd_tcp_ip_abort_cinterval = 0;
  196. long ndd_tcp_ip_abort_interval = 0;
  197. long ndd_tcp_strong_iss = 0;
  198. int hpux_ndd_change_needed = 0;
  199. #endif
  200. char install_dir[MAXPATHLEN];
  201. int avail_root = 0;
  202. int avail_opt = 0;
  203. int max_core = 0;
  204. #if defined(__sun)
  205. #define SUN_NETWORK_DEVICE "/dev/hme"
  206. char solaris_release_string[128];
  207. struct iii_pinfo {
  208. int pnum;
  209. int pver;
  210. int preq;
  211. int sol;
  212. int intel;
  213. int seen;
  214. char *pdesc;
  215. } iii_patches[] = {
  216. #include "sol_patches.c"
  217. /* sol_patches.c is a generated file
  218. if you need to include patches not automatically
  219. generated, please list them individually here
  220. */
  221. {0,0,0,0,0}
  222. };
  223. #endif
  224. #if defined(__hppa)
  225. struct pst_dynamic pst_dyn;
  226. struct pst_static pst_stt;
  227. struct pst_vminfo pst_vmm;
  228. struct iii_pinfo_hp {
  229. char *qpk_name;
  230. char *qpk_version;
  231. char *qpk_desc;
  232. int qpk_yr;
  233. int qpk_mo;
  234. int seen;
  235. } iii_qpk[] = {
  236. #include "hp_patches.c"
  237. /* hp_patches.c is a generated file
  238. if you need to include patches not automatically
  239. generated, please list them individually here
  240. */
  241. {NULL, NULL, NULL, 0, 0, 0}
  242. };
  243. static void hp_check_qpk(void);
  244. #endif
  245. #if defined(_AIX)
  246. static struct ClassElem CuAt_ClassElem[] = {
  247. { "name",ODM_CHAR, 12,16, NULL,NULL,0,NULL ,-1,0},
  248. { "attribute",ODM_CHAR, 28,16, NULL,NULL,0,NULL ,-1,0},
  249. { "value",ODM_CHAR, 44,256, NULL,NULL,0,NULL ,-1,0},
  250. { "type",ODM_CHAR, 300,8, NULL,NULL,0,NULL ,-1,0},
  251. { "generic",ODM_CHAR, 308,8, NULL,NULL,0,NULL ,-1,0},
  252. { "rep",ODM_CHAR, 316,8, NULL,NULL,0,NULL ,-1,0},
  253. { "nls_index",ODM_SHORT, 324, 2, NULL,NULL,0,NULL ,-1,0},
  254. };
  255. static struct ClassElem fix_ClassElem[] = {
  256. { "name",ODM_CHAR, 12,16, NULL,NULL,0,NULL ,-1,0},
  257. { "abstract",ODM_CHAR, 28,60, NULL,NULL,0,NULL ,-1,0},
  258. { "type",ODM_CHAR, 88,2, NULL,NULL,0,NULL ,-1,0},
  259. { "filesets",ODM_VCHAR, 92,64, NULL,NULL,0,NULL ,-1,0},
  260. { "symptom",ODM_VCHAR, 96,64, NULL,NULL,0,NULL ,-1,0},
  261. };
  262. struct StringClxn fix_STRINGS[] = {
  263. "fix.vc", 0,NULL,NULL,0,0,0
  264. };
  265. #ifdef __64BIT__
  266. struct Class CuAt_CLASS[] = {
  267. ODMI_MAGIC, "CuAt", 328, CuAt_Descs, CuAt_ClassElem, NULL,FALSE,NULL,NULL,0,0,NULL,0,"", 0,-ODMI_MAGIC
  268. };
  269. struct Class fix_CLASS[] = {
  270. ODMI_MAGIC, "fix", 100, fix_Descs, fix_ClassElem, fix_STRINGS,FALSE,NULL,NULL,0,0,NULL,0,"", 0,-ODMI_MAGIC
  271. };
  272. #else
  273. struct Class CuAt_CLASS[] = {
  274. ODMI_MAGIC, "CuAt", sizeof(struct CuAt), CuAt_Descs, CuAt_ClassElem, NULL,FALSE,NULL,NULL,0,0,NULL,0,"", 0,-ODMI_MAGIC
  275. };
  276. struct Class fix_CLASS[] = {
  277. ODMI_MAGIC, "fix", sizeof(struct fix), fix_Descs, fix_ClassElem, fix_STRINGS,FALSE,NULL,NULL,0,0,NULL,0,"", 0,-ODMI_MAGIC
  278. };
  279. #endif
  280. void idds_aix_odm_get_cuat (char *query,char *buf)
  281. {
  282. struct CuAt cuat,*cp;
  283. cp = odm_get_first(CuAt_CLASS,query,&cuat);
  284. if (cp == NULL || cp == (struct CuAt *)-1) {
  285. if (flag_debug) {
  286. printf("DEBUG : query of %s failed, error %d\n",query,odmerrno);
  287. }
  288. *buf = '\0';
  289. return;
  290. } else {
  291. if (flag_debug) {
  292. printf("DEBUG : query of %s resulted in %s\n",query,cuat.value);
  293. }
  294. }
  295. strcpy(buf,cuat.value);
  296. }
  297. int idds_aix_odm_get_fix (char *query)
  298. {
  299. struct fix fix,*cp;
  300. cp = odm_get_first(fix_CLASS,query,&fix);
  301. if (cp == NULL || cp == (struct fix *)-1) {
  302. if (flag_debug) {
  303. printf("DEBUG : query of %s failed, error %d\n",query,odmerrno);
  304. }
  305. return 0;
  306. } else {
  307. if (flag_debug) {
  308. printf("DEBUG : query of %s resulted in data\n",query);
  309. }
  310. }
  311. return 1;
  312. }
  313. #define AIX_CHECK_PATCH_CMD "/usr/bin/lslpp -c -L bos.rte.libpthreads bos.rte.libc"
  314. /* called once for each patch
  315. * a is always "bos"
  316. * b is "bos.rte.libpthreads:4.3.3.25: : :C:F:libpthreads Library"
  317. */
  318. /* We assume the patch is in 4.3.3.1 and later. We don't check for AIX 5.0 */
  319. /* Since the next major release after 4.3.3 is 5.0, we assume there won't be a
  320. * 4.10 or a 4.4.10.
  321. */
  322. int aix_check_patch_bos(char *a,char *b)
  323. {
  324. char *c;
  325. char *d;
  326. char *e;
  327. int d3;
  328. int d4;
  329. c = strchr(b,':');
  330. if (c == NULL) return 0;
  331. *c = '\0';
  332. c++;
  333. d = strchr(c,':');
  334. if (d != NULL) *d = '\0';
  335. if (c[0] >= '5') {
  336. /* AIX 5.x */
  337. if (flag_debug) printf("DEBUG : %s is version 5 or later (%s)\n",
  338. b,c);
  339. return 0;
  340. } else if (c[0] != '4') {
  341. /* AIX 3.x or earlier */
  342. printf("ERROR : Incorrect version of %s: %s\n\n",
  343. b,c);
  344. flag_os_bad = 1;
  345. return 0;
  346. } else if (c[2] >= '4') {
  347. /* AIX 4.4 and later */
  348. if (flag_debug) printf("DEBUG : %s is version 4.4 or later (%s)\n",
  349. b,c);
  350. return 0;
  351. } else if (c[2] != '3') {
  352. /* AIX 4.2 and earlier */
  353. printf("ERROR : Incorrect version of %s: %s\n\n",
  354. b,c);
  355. flag_os_bad = 1;
  356. return 0;
  357. }
  358. /* It's 4.3.x.x */
  359. e = strchr(c+4,'.');
  360. if (e != NULL) {
  361. *e = '\0';
  362. e++;
  363. d4 = atoi(e);
  364. } else {
  365. d4 = 0;
  366. }
  367. d3 = atoi(c+4);
  368. if (d3 > 4) {
  369. if (flag_debug) printf("DEBUG : %s is version 4.3.4 or later (%s)\n",
  370. b,c);
  371. return 0;
  372. } else if (d3 < 3) {
  373. printf("ERROR : Incorrect version of %s: %s.%d; must be 4.3.3.1 or later\n\n",
  374. b,c,d4);
  375. flag_os_bad = 1;
  376. return 0;
  377. }
  378. if (d4 >= 27) {
  379. if (flag_debug) printf("DEBUG : %s is version 4.3.3.27 or later (%s.%d)\n",
  380. b,c,d4);
  381. } else if (d4 > 0) {
  382. if (flag_debug) printf("ERROR : Incorrect version of %s: %s.%d; must be 4.3.3.27 or later\n\n",
  383. b,c,d4);
  384. } else { /* d4 = 0 */
  385. printf("ERROR : Incorrect version of %s: %s.%d; must be 4.3.3.1 or later\n\n",
  386. b,c,d4);
  387. flag_os_bad = 1;
  388. }
  389. return 0;
  390. }
  391. struct iii_pio_parsetab ptb_aixpatch[] = {
  392. {"bos", aix_check_patch_bos}
  393. };
  394. static void aix_check_patches(void)
  395. {
  396. if (flag_debug) printf("DEBUG : %s\n",AIX_CHECK_PATCH_CMD);
  397. if (iii_pio_procparse(AIX_CHECK_PATCH_CMD,
  398. III_PIO_SZ(ptb_aixpatch),
  399. ptb_aixpatch) == -1) {
  400. perror(AIX_CHECK_PATCH_CMD);
  401. }
  402. if (flag_os_bad) {
  403. printf("NOTICE : AIX APARs and fixes can be obtained from\n"
  404. " http://service.software.ibm.com/cgi-bin/support/rs6000.support/downloads or \n");
  405. printf(" http://techsupport.services.ibm.com/rs6k/ml.fixes.html\n\n");
  406. }
  407. }
  408. static void idds_aix_pio_get_oslevel(char *osl)
  409. {
  410. FILE *fp;
  411. char *rp;
  412. char rls[128];
  413. int i;
  414. int rm = 0;
  415. osl[0] = '\0';
  416. fp = popen("/usr/bin/oslevel","r");
  417. if (fp == NULL) {
  418. perror("/usr/bin/oslevel");
  419. return;
  420. }
  421. if (fgets(osl,128,fp) == NULL) {
  422. pclose(fp);
  423. return;
  424. }
  425. pclose(fp);
  426. rp = strchr(osl,'\n');
  427. if (rp) *rp = '\0';
  428. i = 0;
  429. for (rp = osl;*rp;rp++) {
  430. if (*rp != '.') {
  431. rls[i] = *rp;
  432. i++;
  433. }
  434. }
  435. rls[i] = '\0';
  436. /* rls now contains a value such as 4330 */
  437. for (i = 1;i<99;i++) {
  438. char rmtest[128];
  439. char ifout[BUFSIZ];
  440. sprintf(rmtest,"name=%s-%02d_AIX_ML",rls,i);
  441. if (idds_aix_odm_get_fix(rmtest) == 0) break;
  442. rm = i;
  443. }
  444. rp = osl + strlen(osl);
  445. sprintf(rp,".%02d",rm);
  446. }
  447. #endif
  448. #if defined(__sun)
  449. static void ids_get_platform_solaris(char *buf)
  450. {
  451. struct utsname u;
  452. char sbuf[128];
  453. FILE *fp;
  454. #if defined(sparc) || defined(__sparc)
  455. int is_u = 0;
  456. sbuf[0] = '\0';
  457. sysinfo(SI_MACHINE,sbuf,128);
  458. if (strcmp(sbuf,"sun4u") == 0) {
  459. is_u = 1;
  460. }
  461. sbuf[0] = '\0';
  462. sysinfo(SI_PLATFORM,sbuf,128);
  463. sprintf(buf,"%ssparc%s-%s-solaris",
  464. is_u ? "u" : "",
  465. sizeof(long) == 4 ? "" : "v9",
  466. sbuf);
  467. #else
  468. #if defined(i386) || defined(__i386)
  469. sprintf(buf,"i386-unknown-solaris");
  470. #else
  471. sprintf(buf,"unknown-unknown-solaris");
  472. #endif /* not i386 */
  473. #endif /* not sparc */
  474. uname(&u);
  475. if (isascii(u.release[0]) && isdigit(u.release[0])) strcat(buf,u.release);
  476. fp = fopen("/etc/release","r");
  477. if (fp != NULL) {
  478. char *rp;
  479. sbuf[0] = '\0';
  480. fgets(sbuf,128,fp);
  481. fclose(fp);
  482. rp = strstr(sbuf,"Solaris");
  483. if (rp) {
  484. rp += 8;
  485. while(*rp != 's' && *rp != '\0') rp++;
  486. if (*rp == 's') {
  487. strcpy(solaris_release_string,rp);
  488. rp = strchr(solaris_release_string,' ');
  489. if (rp) *rp = '\0';
  490. strcat(buf,"_");
  491. strcat(buf,solaris_release_string);
  492. }
  493. }
  494. } else {
  495. if (flag_debug) printf("DEBUG : No /etc/release file\n");
  496. }
  497. }
  498. int sun_check_kern_arch(char *a,char *b)
  499. {
  500. if (strcmp(b,"i86pc") == 0) {
  501. flag_intel = 1;
  502. if (flag_debug) printf("DEBUG : Kernel architecture: i86pc\n");
  503. } else if (strcmp(b,"sun4u") == 0) {
  504. if (flag_debug) printf("DEBUG : Kernel architecture: sun4u\n");
  505. } else {
  506. if (flag_html) printf("<P>\n");
  507. printf("%s: The kernel architecture is %s. Netscape products are optimized\nfor the UltraSPARC architecture and will exhibit poorer performance on earlier\nmachines.\n\n","WARNING",b);
  508. if (flag_html) printf("</P>\n");
  509. flag_arch_bad = 1;
  510. }
  511. return 0;
  512. }
  513. /* This check is now obsolete. See solaris_check_mu() */
  514. int sun_check_release(char *a,char *b)
  515. {
  516. if (flag_html) printf("<P>\n");
  517. if (strcmp(b,"9") == 0 ||
  518. strcmp(b,"5.9") == 0) {
  519. if (flag_debug) printf("DEBUG : Release 5.9\n");
  520. solaris_version = 29;
  521. flag_solaris_9 = 1;
  522. } else if (strcmp(b,"8") == 0 ||
  523. strcmp(b,"5.8") == 0) {
  524. if (flag_debug) printf("DEBUG : Release 5.8\n");
  525. solaris_version = 28;
  526. flag_solaris_8 = 1;
  527. } else if (strcmp(b,"7") == 0 ||
  528. strcmp(b,"5.7") == 0) {
  529. if (flag_debug) printf("DEBUG : Release 5.7\n");
  530. solaris_version = 27;
  531. flag_solaris_7 = 1;
  532. } else if (strcmp(b,"5.6") == 0) {
  533. flag_solaris_26 = 1;
  534. solaris_version = 26;
  535. if (flag_debug) printf("DEBUG : Release 5.6\n");
  536. } else if (strcmp(b,"5.5.1") == 0) {
  537. if (client == 0) {
  538. 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",
  539. "ERROR ");
  540. flag_os_bad = 1;
  541. }
  542. flag_solaris_251 = 1;
  543. solaris_version = 251;
  544. } else if (strcmp(b,"5.5") == 0) {
  545. 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",
  546. "ERROR ");
  547. flag_os_bad = 1;
  548. solaris_version = 25;
  549. } else if (strcmp(b,"5.4") == 0) {
  550. printf("%s: Solaris versions prior to 2.6 are not suitable for running Internet\nservices; upgrading to 2.6 is required.\n\n",
  551. "ERROR ");
  552. flag_os_bad = 1;
  553. solaris_version = 24;
  554. } else if (strcmp(b,"5.3") == 0) {
  555. printf("%s: Solaris 2.3 is not supported.\n\n",
  556. "ERROR ");
  557. flag_os_bad = 1;
  558. } else {
  559. printf("%s: Solaris version %s, as reported by showrev -a, is unrecognized.\n\n",
  560. "NOTICE ",b);
  561. flag_os_bad = 1;
  562. }
  563. if (flag_html) printf("</P>\n");
  564. return 0;
  565. }
  566. /* This check is now obsolete. See solaris_check_mu() instead. */
  567. int sun_check_kern_ver(char *a,char *b)
  568. {
  569. char *rp,*pp;
  570. int pw = 0;
  571. if (flag_html) printf("<P>\n");
  572. rp = strrchr(b,' ');
  573. if (rp == NULL || rp == b) {
  574. printf("NOTICE : Kernel version: \"%s\" not recognized.\n\n",b);
  575. if (flag_html) printf("</P>\n");
  576. return 0;
  577. }
  578. *rp = '\0';
  579. rp++;
  580. pp = strrchr(b,' ');
  581. if (pp == 0) {
  582. printf("NOTICE : Kernel version: \"%s\" not recognized.\n\n",b);
  583. if (flag_html) printf("</P>\n");
  584. return 0;
  585. }
  586. pp++;
  587. if (strcmp(rp,"1997") == 0 ||
  588. strcmp(rp,"1996") == 0) {
  589. printf("%s: This kernel was built in %s %s. Kernel builds prior to\n"
  590. "mid-1998 are lacking many tuning fixes, uprading is strongly recommended.\n\n","ERROR ",pp,rp);
  591. pw = 1;
  592. flag_os_bad = 1;
  593. }
  594. if (flag_solaris_26 && strcmp(rp,"1998") == 0) {
  595. if (strncmp(pp,"Jan",3) == 0 ||
  596. strncmp(pp,"Feb",3) == 0 ||
  597. strncmp(pp,"Mar",3) == 0 ||
  598. strncmp(pp,"Apr",3) == 0) {
  599. printf("%s: This kernel was built in %s %s. Kernel builds prior to\n"
  600. "mid-1998 are lacking many tuning fixes, uprading is strongly recommended.\n\n","WARNING",pp,rp);
  601. pw = 1;
  602. flag_os_bad = 1;
  603. }
  604. }
  605. if (flag_debug && pw == 0) {
  606. printf("DEBUG : Kernel build date %s %s\n",pp,rp);
  607. }
  608. if (flag_html) printf("</P>\n");
  609. return 0;
  610. }
  611. int sun_check_patch(char *a,char *b)
  612. {
  613. char *rp;
  614. int pid = 0;
  615. int pver = 0;
  616. int i;
  617. rp = strchr(b,'O');
  618. if (rp == NULL) {
  619. printf("%s: Cannot parse patch line %s\n","NOTICE ",b);
  620. return 0;
  621. }
  622. *rp = '\0';
  623. rp = strchr(b,'-');
  624. if (b == NULL) {
  625. printf("%s: Cannot parse patch line %s\n","NOTICE ",b);
  626. }
  627. *rp = '\0';
  628. rp++;
  629. pid = atoi(b);
  630. pver = atoi(rp);
  631. for (i = 0; iii_patches[i].pnum != 0; i++) {
  632. if (iii_patches[i].pnum == pid) {
  633. if (iii_patches[i].seen < pver) {
  634. iii_patches[i].seen = pver;
  635. }
  636. break;
  637. }
  638. }
  639. return 0;
  640. }
  641. int sun_check_etcsystem(void)
  642. {
  643. FILE *fp;
  644. char buf[8192];
  645. int pp_set = -1;
  646. int tchs = 0;
  647. fp = fopen("/etc/system","r");
  648. if (fp == NULL) {
  649. perror("/etc/system");
  650. return -1;
  651. }
  652. while(fgets(buf,8192,fp) != NULL) {
  653. char *rp;
  654. rp = strchr(buf,'\n');
  655. if (rp) {
  656. *rp = '\0';
  657. }
  658. if (buf[0] == '*') continue; /* comment */
  659. if (strncmp(buf,"set",3) != 0) continue;
  660. if (flag_debug) printf("DEBUG : saw %s in /etc/system\n",buf);
  661. if (strstr(buf,"priority_paging") != NULL) {
  662. rp = strchr(buf,'=');
  663. if (rp == NULL) continue;
  664. rp++;
  665. while(isspace(*rp)) rp++;
  666. if (*rp == '1') {
  667. pp_set = 1;
  668. } else {
  669. pp_set = 0;
  670. }
  671. } else if (strstr(buf,"tcp:tcp_conn_hash_size") != NULL) {
  672. rp = strchr(buf,'=');
  673. if (rp == NULL) continue;
  674. rp++;
  675. while(isspace(*rp)) rp++;
  676. tchs = atoi(rp);
  677. }
  678. }
  679. fclose(fp);
  680. /* ias tuning recommends setting tcp_conn_hash_size to 8192 XXX */
  681. if (pp_set == 1) {
  682. if (flag_debug) printf("DEBUG : saw priority_paging=1 in /etc/system\n");
  683. } else if (flag_solaris_7) {
  684. if (pp_set == 0) {
  685. printf("NOTICE : priority_paging is set to 0 in /etc/system.\n\n");
  686. } else {
  687. printf("WARNING: priority_paging is not set to 1 in /etc/system. See Sun FAQ 2833.\n\n");
  688. }
  689. }
  690. }
  691. void sun_check_mu(void)
  692. {
  693. if (solaris_release_string[0] == '\0') {
  694. if (flag_debug) printf("DEBUG : No /etc/release line parsed\n");
  695. return;
  696. }
  697. switch(solaris_version) {
  698. case 26:
  699. if (strcmp(solaris_release_string,"s297s_smccServer_37cshwp") == 0) {
  700. printf("NOTICE : This machine appears to be running Solaris 2.6 FCS. Solaris 2.6\nMaintenance Update 2 has been released subsequent to this.\n\n");
  701. } else if (strcmp(solaris_release_string,"s297s_hw2smccDesktop_09") == 0) {
  702. printf("NOTICE : This machine appears to be running Solaris 2.6 3/98. Solaris 2.6\nMaintenance Update 2 has been released subsequent to this.\n\n");
  703. } else if (strcmp(solaris_release_string,"s297s_hw3smccDesktop_09") == 0) {
  704. if (flag_debug) printf("DEBUG : Solaris 2.6 5/98\n");
  705. } else if (strcmp(solaris_release_string,"s297s_smccServer_37cshwp") == 0) {
  706. if (flag_debug) printf("DEBUG : Solaris 2.6 MU2\n");
  707. } else {
  708. if (flag_debug) printf("DEBUG : Solaris 2.6 Unrecognized\n");
  709. }
  710. break;
  711. case 27:
  712. if (strcmp(solaris_release_string,"s998s_SunServer_21al2b") == 0) {
  713. /* FCS */
  714. printf("NOTICE : This machine appears to be running Solaris 7 FCS. Solaris 7 11/99\nhas been released subsequent to this.\n\n");
  715. } else if (strcmp(solaris_release_string,"s998s_u1SunServer_10") == 0) {
  716. printf("NOTICE : This machine appears to be running Solaris 7 3/99. Solaris 7 11/99\nhas been released subsequent to this.\n\n");
  717. } else if (strcmp(solaris_release_string,"s998s_u2SunServer_09") == 0) {
  718. printf("NOTICE : This machine appears to be running Solaris 7 5/99. Solaris 7 11/99\nhas been released subsequent to this.\n\n");
  719. } else if (strcmp(solaris_release_string,"s998s_u3SunServer_11") == 0) {
  720. printf("NOTICE : This machine appears to be running Solaris 7 8/99. Solaris 7 11/99\nhas been released subsequent to this.\n\n");
  721. } else if (strcmp(solaris_release_string,"s998s_u4SunServer_10") == 0) {
  722. if (flag_debug) printf("DEBUG : 11/99\n");
  723. } else {
  724. if (flag_debug) printf("DEBUG : Solaris 7 Unrecognized\n");
  725. }
  726. break;
  727. case 28:
  728. if (strcmp(solaris_release_string,"s28_27b") == 0) {
  729. printf("ERROR : This machine appears to be running Solaris 8 Beta.\n\n");
  730. } else if (strcmp(solaris_release_string,"s28_32d") == 0) {
  731. printf("ERROR : This machine appears to be running Solaris 8 Beta Refresh.\n\n");
  732. } else if (strcmp(solaris_release_string,"s28_38shwp2") == 0) {
  733. printf("NOTICE : This machine appears to be running Solaris 8 FCS. Solaris 8 Update\n4 has been released subsequent to this.\n\n");
  734. } else if (strcmp(solaris_release_string,"s28s_u1wos_08") == 0) {
  735. printf("NOTICE : This machine appears to be running Solaris 8 Update 1. Solaris 8\nUpdate 4 has been released subsequent to this.\n\n");
  736. } else if (strcmp(solaris_release_string,"s28_38shwp2") == 0) {
  737. 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");
  738. } else if (strcmp(solaris_release_string,"s28s_u2wos_11b") == 0) {
  739. printf("NOTICE : This machine appears to be running Solaris 8 Update 2. Solaris 8\nUpdate 4 has been released subsequent to this.\n\n");
  740. } else if (strcmp(solaris_release_string,"s28_38shwp2") == 0) {
  741. 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");
  742. } else if (strcmp(solaris_release_string,"s28s_u3wos_08") == 0) {
  743. printf("NOTICE : This machine appears to be running Solaris 8 Update 3. Solaris 8\nUpdate 4 has been released subsequent to this.\n\n");
  744. } else if (strcmp(solaris_release_string,"s28s_u4wos_03") == 0) {
  745. 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");
  746. } else if (strcmp(solaris_release_string,"s28s_u4wos_08") == 0) {
  747. if (flag_debug) printf("DEBUG : Solaris 8 Update 4 (4/01)\n\n");
  748. } else if (strcmp(solaris_release_string,"s28s_u5wos_08") == 0) {
  749. if (flag_debug) printf("DEBUG : Solaris 8 Update 5\n\n");
  750. } else {
  751. if (flag_debug) printf("DEBUG : Solaris 8 Unrecognized\n");
  752. }
  753. break;
  754. case 29:
  755. if (flag_debug) printf("DEBUG : Solaris 9 Unrecognized\n");
  756. break;
  757. default:
  758. if (flag_debug) printf("DEBUG : Solaris Unrecognized\n");
  759. /* probably pretty old */
  760. break;
  761. }
  762. }
  763. #endif
  764. int check_memsize(char *a,char *b)
  765. {
  766. char *rp;
  767. int mult = 1;
  768. rp = strchr(b,' ');
  769. if (rp == NULL) {
  770. printf("%s: Cannot parse Memory size: line %s\n\n","NOTICE ",b);
  771. return 0;
  772. }
  773. if (!isdigit(*b)) {
  774. printf("%s: Cannot parse Memory size: line %s\n\n","NOTICE ",b);
  775. return 0;
  776. }
  777. *rp = '\0';
  778. rp++;
  779. if (strcmp(rp,"Megabytes") == 0) {
  780. } else if (strcmp(rp,"Gigabytes") == 0) {
  781. mult = 1024;
  782. } else {
  783. printf("%s: Cannot parse Memory size: line %s %s\n\n","NOTICE ",b,rp);
  784. return 0;
  785. }
  786. phys_mb = atoi(b) * mult;
  787. return 0;
  788. }
  789. int check_swapsize(char *a,char *b)
  790. {
  791. char *rp,*kp;
  792. int used, avail;
  793. rp = strchr(b,'=');
  794. if (rp == NULL) {
  795. printf("NOTICE : Cannot parse swap -s output: %s\n", b);
  796. return 0;
  797. }
  798. rp++;
  799. if (isspace(*rp)) rp++;
  800. if (!(isdigit(*rp))) {
  801. printf("NOTICE : Cannot parse swap -s output: %s\n", b);
  802. return 0;
  803. }
  804. kp = strchr(rp,'k');
  805. if (kp == NULL) {
  806. printf("NOTICE : Cannot parse swap -s output: %s\n", b);
  807. return 0;
  808. }
  809. *kp = '\0';
  810. used = atoi(rp);
  811. *kp = 'k';
  812. rp = strchr(b,',');
  813. if (rp == NULL) {
  814. printf("NOTICE : Cannot parse swap -s output: %s\n", b);
  815. return 0;
  816. }
  817. rp++;
  818. if (isspace(*rp)) rp++;
  819. if (!(isdigit(*rp))) {
  820. printf("NOTICE : Cannot parse swap -s output: %s\n", b);
  821. return 0;
  822. }
  823. kp = strchr(rp,'k');
  824. if (kp == NULL) {
  825. printf("NOTICE : Cannot parse swap -s output: %s\n", b);
  826. return 0;
  827. }
  828. *kp = '\0';
  829. avail = atoi(rp);
  830. if (flag_debug) {
  831. printf("DEBUG : swap used %dK avail %dK\n", used, avail);
  832. }
  833. swap_mb = (used+avail)/1024-(phys_mb*7/8);
  834. return 0;
  835. }
  836. #if defined(__sun)
  837. int check_kthread(char *a,char *b)
  838. {
  839. flag_mproc = 1;
  840. return 0;
  841. }
  842. int check_tcpmaxlisten(char *a,char *b)
  843. {
  844. if (flag_os_bad == 1) return 0;
  845. if (client) return 0;
  846. if (flag_html) printf("<P>\n");
  847. if (isdigit(*b)) {
  848. tcp_max_listen = atoi(b);
  849. if (tcp_max_listen <= 1024) {
  850. 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 ");
  851. if (flag_mproc == 0) {
  852. printf("The following line should be added to the file /etc/init.d/inetinit:\n");
  853. if (flag_html) printf("</P><PRE>\n");
  854. printf("echo \"tcp_param_arr+14/W 0t65536\" | adb -kw /dev/ksyms /dev/mem\n");
  855. printf("\n");
  856. if (flag_html) printf("</PRE><P>\n");
  857. } else {
  858. 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");
  859. }
  860. } else if (tcp_max_listen < 65536) {
  861. 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);
  862. if (flag_mproc == 0) {
  863. printf("The value can be raised by adding the following line to the file\n/etc/init.d/inetinit:\n");
  864. if (flag_html) printf("</P><PRE>\n");
  865. printf("echo \"tcp_param_arr+14/W 0t65536\" | adb -kw /dev/ksyms /dev/mem\n");
  866. if (flag_html) printf("</PRE><P>\n");
  867. printf("\n\n");
  868. }
  869. } else {
  870. if (flag_debug) printf("DEBUG : tcp_param_arr+0x14: %d\n",tcp_max_listen);
  871. }
  872. } else if (strcmp(b,"-1") == 0) {
  873. /* OK I guess */
  874. tcp_max_listen = 65535;
  875. } else {
  876. printf("NOTICE : tcp_param_arr+0x14: %s cannot be parsed\n\n", b);
  877. }
  878. if (flag_html) printf("</P>\n");
  879. return 0;
  880. }
  881. struct iii_pio_parsetab ptb_showrev[] = {
  882. {"Release",sun_check_release},
  883. {"Kernel architecture",sun_check_kern_arch},
  884. {"Kernel version",sun_check_kern_ver},
  885. {"Patch",sun_check_patch}
  886. };
  887. struct iii_pio_parsetab ptb_adb[] = {
  888. {" kernel thread at:",check_kthread},
  889. {"tcp_param_arr+0x14",check_tcpmaxlisten}
  890. };
  891. #endif
  892. struct iii_pio_parsetab ptb_prtconf[] = {
  893. {"Memory size",check_memsize}
  894. };
  895. struct iii_pio_parsetab ptb_swap[] = {
  896. {"total",check_swapsize}
  897. };
  898. #if defined(IDDS_LINUX_INCLUDE)
  899. static void
  900. linux_check_release(void)
  901. {
  902. FILE *fp;
  903. char osl[128];
  904. char *cmd = strdup("/bin/uname -r");
  905. if (flag_html) printf("<P>\n");
  906. if (flag_debug) printf("DEBUG : %s\n",cmd);
  907. fp = popen(cmd,"r");
  908. if (fp == NULL) {
  909. perror("popen");
  910. return;
  911. }
  912. if (fgets(osl,128,fp) == NULL) {
  913. printf("WARNING: Cannot determine the kernel number.\n");
  914. pclose(fp);
  915. return;
  916. }
  917. pclose(fp);
  918. if (flag_debug) {
  919. printf("DEBUG : %s\n",osl);
  920. }
  921. if (atoi(strtok(osl, ".")) < 2) {
  922. printf("ERROR: We support kernel version 2.4.7 and higher.\n\n");
  923. flag_os_bad = 1;
  924. return;
  925. }
  926. if (atoi(strtok(NULL, ".")) < 4) {
  927. printf("ERROR: We support kernel version 2.4.7 and higher.\n\n");
  928. flag_os_bad = 1;
  929. return;
  930. }
  931. if (atoi(strtok(NULL, "-")) < 7) {
  932. printf("ERROR: We support kernel version 2.4.7 and higher.\n\n");
  933. flag_os_bad = 1;
  934. return;
  935. }
  936. }
  937. #endif /* IDDS_LINUX_INCLUDE */
  938. #if defined(__osf__)
  939. #ifndef SLS_BUFSIZ
  940. #define SLS_BUFSIZ 8192
  941. #endif
  942. static void ids_get_platform_tru64(char *buf)
  943. {
  944. struct utsname u;
  945. int r,start = 0;
  946. unsigned long pt;
  947. struct cpu_info cpu_info;
  948. char platname[SLS_BUFSIZ];
  949. char *sp;
  950. r = getsysinfo(GSI_CPU_INFO,(caddr_t)&cpu_info,sizeof(struct cpu_info),&start,NULL);
  951. start = 0;
  952. r = getsysinfo(GSI_PLATFORM_NAME,(caddr_t)&platname[0],SLS_BUFSIZ,&start,NULL);
  953. start = 0;
  954. r = getsysinfo(GSI_PROC_TYPE,(caddr_t)&pt,sizeof(long),&start,NULL);
  955. switch(pt & 0xff) {
  956. default:
  957. sprintf(buf,"alpha-");
  958. break;
  959. case EV4_CPU:
  960. sprintf(buf,"alpha_ev4_21064_%dMhz-",cpu_info.mhz);
  961. break;
  962. case EV45_CPU:
  963. sprintf(buf,"alpha_ev4.5_21064_%dMhz-",cpu_info.mhz);
  964. break;
  965. case EV5_CPU:
  966. sprintf(buf,"alpha_ev5_21164_%dMHz-",cpu_info.mhz);
  967. break;
  968. case EV56_CPU:
  969. sprintf(buf,"alpha_ev5.6_21164A_%dMHz-",cpu_info.mhz);
  970. break;
  971. case EV6_CPU:
  972. sprintf(buf,"alpha_ev6_21264_%dMHz-",cpu_info.mhz);
  973. break;
  974. }
  975. sp = buf+strlen(buf);
  976. for (r = 0; platname[r] != '\0';r++) {
  977. if (platname[r] == ' ' || platname[r] == '-') {
  978. *sp = '_';
  979. sp++;
  980. } else {
  981. *sp = platname[r];
  982. sp++;
  983. }
  984. }
  985. sprintf(sp,"-tru64_");
  986. if (uname(&u) == 0) {
  987. strcat(buf,u.release);
  988. strcat(buf,"_");
  989. strcat(buf,u.version);
  990. }
  991. /* XXX GSI_LMF see sys/lmf.h and sys/lmfklic.h */
  992. }
  993. /* returns number of k in swap area */
  994. static int idds_osf_get_swapk (void)
  995. {
  996. int src,i;
  997. struct swaptable *swtab;
  998. int res = 0;
  999. src = swapctl(SC_GETNSWP,NULL);
  1000. if (src < 1) {
  1001. return 0;
  1002. }
  1003. swtab = calloc(1,sizeof(int) + ((src+1) * sizeof(struct swapent)));
  1004. swtab->swt_n = src;
  1005. for (i = 0; i < src; i++) {
  1006. swtab->swt_ent[i].ste_path = calloc(1024,sizeof(char));
  1007. }
  1008. if (swapctl(SC_LIST,swtab) < 0) {
  1009. res = 0;
  1010. } else {
  1011. for (i = 0; i< src; i++) {
  1012. if (swtab->swt_ent[i].ste_flags & ST_INDEL) continue;
  1013. res += (swtab->swt_ent[i].ste_length / 2);
  1014. }
  1015. }
  1016. for (i = 0; i < src; i++) {
  1017. free(swtab->swt_ent[i].ste_path);
  1018. }
  1019. free(swtab);
  1020. return res;
  1021. }
  1022. int idds_osf_get_memk(void)
  1023. {
  1024. int start = 0, physmem = 0,r;
  1025. r = getsysinfo(GSI_PHYSMEM,(caddr_t)&physmem,sizeof(physmem),&start,NULL);
  1026. if (r == -1) {
  1027. return 0;
  1028. }
  1029. return physmem;
  1030. }
  1031. #endif
  1032. static void gen_tests (void)
  1033. {
  1034. #ifndef _WIN32
  1035. uid_t uid;
  1036. #endif
  1037. if (flag_html) printf("<P>\n");
  1038. #if defined(__sun)
  1039. if (flag_debug) printf("DEBUG : /usr/bin/showrev -a\n");
  1040. if (iii_pio_procparse("/usr/bin/showrev -a",
  1041. III_PIO_SZ(ptb_showrev),
  1042. ptb_showrev) == -1) {
  1043. perror("/usr/bin/showrev -a");
  1044. } else {
  1045. int i;
  1046. int pur = 0;
  1047. for (i = 0; iii_patches[i].pnum != 0; i++) {
  1048. if (iii_patches[i].sol == solaris_version &&
  1049. iii_patches[i].intel == flag_intel) {
  1050. if (iii_patches[i].seen >= iii_patches[i].pver) {
  1051. if (flag_debug) {
  1052. printf("DEBUG : Patch %d-%02d, %d-%02d required (%s)\n",
  1053. iii_patches[i].pnum,
  1054. iii_patches[i].seen,
  1055. iii_patches[i].pnum,
  1056. iii_patches[i].pver,
  1057. iii_patches[i].pdesc);
  1058. }
  1059. } else if (iii_patches[i].seen != 0) {
  1060. if (flag_html) printf("<P>\n");
  1061. if (iii_patches[i].preq == 1 || flag_quick == 0) {
  1062. printf("%s: Patch %d-%02d is present, but %d-%02d (%s) is a more recent version.\n\n",
  1063. iii_patches[i].preq ? "ERROR " : "NOTICE ",
  1064. iii_patches[i].pnum,
  1065. iii_patches[i].seen,
  1066. iii_patches[i].pnum,
  1067. iii_patches[i].pver,
  1068. iii_patches[i].pdesc);
  1069. pur++;
  1070. if (flag_carrier || iii_patches[i].preq) flag_os_bad = 1;
  1071. }
  1072. if (flag_html) printf("</P>\n");
  1073. } else {
  1074. if (flag_html) printf("<P>\n");
  1075. if (iii_patches[i].preq) {
  1076. printf("%s: Patch %d-%02d (%s) is required but not installed.\n\n",
  1077. "ERROR ",
  1078. iii_patches[i].pnum,
  1079. iii_patches[i].pver,
  1080. iii_patches[i].pdesc);
  1081. flag_os_bad = 1;
  1082. pur++;
  1083. } else {
  1084. if (flag_quick == 0) {
  1085. printf("%s: Patch %d-%02d (%s) is not installed.\n\n",
  1086. "NOTICE ",
  1087. iii_patches[i].pnum,
  1088. iii_patches[i].pver,
  1089. iii_patches[i].pdesc);
  1090. pur++;
  1091. }
  1092. }
  1093. if (flag_html) printf("</P>\n");
  1094. }
  1095. } else if (iii_patches[i].seen) {
  1096. if (flag_html) printf("<P>\n");
  1097. printf("%s: Patch %d-%d seen on Solaris %d (%s) but intended for\nSolaris %d %s.\n\n",
  1098. "WARNING",
  1099. iii_patches[i].pnum,
  1100. iii_patches[i].seen,
  1101. solaris_version,
  1102. flag_intel ? "(Intel)" : "",
  1103. iii_patches[i].sol,
  1104. iii_patches[i].intel ? "(Intel)" : "");
  1105. if (flag_html) printf("</P>\n");
  1106. pur++;
  1107. }
  1108. } /* for */
  1109. if (pur) {
  1110. 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");
  1111. }
  1112. }
  1113. sun_check_mu();
  1114. #endif
  1115. #if defined(IDDS_LINUX_INCLUDE)
  1116. linux_check_release();
  1117. #endif
  1118. #if defined(_AIX)
  1119. aix_check_patches();
  1120. #endif
  1121. #if !defined(_WIN32)
  1122. if (access("/usr/sbin/prtconf",X_OK) == 0) {
  1123. if (flag_debug) printf("DEBUG : /usr/sbin/prtconf\n");
  1124. if (iii_pio_procparse("/usr/sbin/prtconf",
  1125. III_PIO_SZ(ptb_prtconf),
  1126. ptb_prtconf) == -1) {
  1127. perror("/usr/sbin/prtconf");
  1128. }
  1129. }
  1130. #endif
  1131. #if defined(__osf__)
  1132. phys_mb = (idds_osf_get_memk())/1024;
  1133. #else
  1134. #if defined(_AIX)
  1135. if (1) {
  1136. char buf[BUFSIZ];
  1137. unsigned long l;
  1138. idds_aix_odm_get_cuat("attribute=realmem",buf);
  1139. if (buf) {
  1140. phys_mb = atoi(buf);
  1141. phys_mb = (phys_mb /1024) * (PAGESIZE / 1024);
  1142. }
  1143. l = psdanger(0);
  1144. swap_mb = PAGESIZE/1024;
  1145. swap_mb = swap_mb * (l / 1024);
  1146. }
  1147. #else
  1148. #if defined(_SC_PHYS_PAGES)
  1149. if (1) {
  1150. int pk,l;
  1151. pk = sysconf(_SC_PAGESIZE);
  1152. pk /= 1024;
  1153. l = sysconf(_SC_PHYS_PAGES);
  1154. if (l < 0) l = 0;
  1155. phys_mb = (l * pk) / 1024;
  1156. }
  1157. #else
  1158. #if defined(__hppa)
  1159. hp_check_qpk();
  1160. if (pstat_getdynamic(&pst_dyn,sizeof(pst_dyn),1,0) == -1 ||
  1161. pstat_getstatic(&pst_stt,sizeof(pst_stt),1,0) == -1 ||
  1162. pstat_getvminfo(&pst_vmm,sizeof(pst_vmm),1,0) == -1) {
  1163. perror("pstat_getdynamic");
  1164. } else {
  1165. if (flag_debug) {
  1166. printf("DEBUG : Static info\n");
  1167. printf("DEBUG : Physical memory size %d\n",pst_stt.physical_memory);
  1168. printf("DEBUG : Page size %d\n",pst_stt.page_size);
  1169. printf("DEBUG : Max nfile %d\n",pst_stt.pst_max_nfile);
  1170. printf("DEBUG : Dynamic info\n");
  1171. printf("DEBUG : Physical memory size %d\n",pst_dyn.psd_rm);
  1172. printf("DEBUG : Virtual Memory size %d\n",pst_dyn.psd_vm);
  1173. printf("DEBUG : Physical memory size %d active\n",pst_dyn.psd_arm);
  1174. printf("DEBUG : Virtual Memory size %d active\n",pst_dyn.psd_avm);
  1175. printf("DEBUG : Processors %d\n",pst_dyn.psd_proc_cnt);
  1176. printf("DEBUG : VM Info\n");
  1177. printf("DEBUG : Pages on disk backing %d\n",pst_vmm.psv_swapspc_cnt);
  1178. printf("DEBUG : Max pages on disk backing %d\n",pst_vmm.psv_swapspc_max);
  1179. }
  1180. phys_mb = pst_stt.page_size / 1024;
  1181. phys_mb = phys_mb * (pst_stt.physical_memory / 1024);
  1182. swap_mb = pst_stt.page_size / 1024;
  1183. swap_mb = swap_mb * (pst_vmm.psv_swapspc_cnt / 1024);
  1184. }
  1185. #else
  1186. #if defined(IDDS_BSD_SYSCTL)
  1187. /* phys_mb from hw.physmem / 1048576 */
  1188. /* swap_mb from vm.stats.vm.v_page_count * v_page_size / 1048576 */
  1189. #endif
  1190. #endif
  1191. #endif
  1192. #endif
  1193. #endif
  1194. if (flag_html) printf("<P>\n");
  1195. if (phys_mb != 0 && phys_mb < mem_min) {
  1196. 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,
  1197. mem_min, mem_rec);
  1198. flag_arch_bad = 1;
  1199. } else if (phys_mb != 0 && phys_mb < mem_rec) {
  1200. printf("%s: %dMB of physical memory is available on the system. %dMB is recommended for best performance on large production system.\n\n",
  1201. "WARNING",
  1202. phys_mb,mem_rec);
  1203. } else if (flag_debug) {
  1204. printf("DEBUG : Memory size %d\n",phys_mb);
  1205. }
  1206. if (flag_html) printf("</P>\n");
  1207. #if !defined(_WIN32)
  1208. if (access("/usr/sbin/swap",X_OK) == 0) {
  1209. if (flag_debug) printf("DEBUG : /usr/sbin/swap -s\n");
  1210. if (iii_pio_procparse("/usr/sbin/swap -s",
  1211. III_PIO_SZ(ptb_swap),
  1212. ptb_swap) == -1) {
  1213. perror("/usr/sbin/swap -s");
  1214. }
  1215. }
  1216. #endif
  1217. #if defined(__osf__)
  1218. swap_mb = (idds_osf_get_swapk()) / 1024;
  1219. #else
  1220. #if defined(IDDS_LINUX_INCLUDE)
  1221. if (1) {
  1222. struct sysinfo linux_si;
  1223. if (sysinfo(&linux_si) == 0) {
  1224. swap_mb = linux_si.totalswap / 1048576;
  1225. }
  1226. }
  1227. #endif
  1228. #endif
  1229. if (client == 0 && swap_mb < 0) {
  1230. if (flag_html) printf("<P>\n");
  1231. printf("%s: There is less swap space than physical memory.\n\n",
  1232. "ERROR ");
  1233. if (flag_html) printf("</P>\n");
  1234. } else if (client == 0 && swap_mb && swap_mb < phys_mb) {
  1235. #if defined(_AIX) || defined(__hppa) || defined(__sun)
  1236. #else
  1237. if (flag_html) printf("<P>\n");
  1238. printf("%s: There is %dMB of physical memory but only %dMB of swap space.\n\n",
  1239. "ERROR ",
  1240. phys_mb,swap_mb);
  1241. if (flag_html) printf("</P>\n");
  1242. #endif
  1243. } else {
  1244. if (flag_debug) printf("DEBUG : %d MB swap configured\n", swap_mb);
  1245. }
  1246. #ifndef _WIN32
  1247. uid = getuid();
  1248. if (uid != 0) {
  1249. uid = geteuid();
  1250. }
  1251. #endif
  1252. #if defined(__sun)
  1253. if (uid != 0) {
  1254. if (flag_html) printf("<P>\n");
  1255. if (flag_quick == 0) {
  1256. 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");
  1257. }
  1258. flag_nonroot = 1;
  1259. if (flag_html) printf("</P>\n");
  1260. }
  1261. #endif
  1262. #if defined(__sun)
  1263. if (flag_quick == 0 && flag_nonroot == 0) {
  1264. if (flag_debug) printf("DEBUG : adb\n");
  1265. if (iii_pio_procparse("/usr/bin/echo \"tcp_param_arr+14/D\" | /usr/bin/adb -k /dev/ksyms /dev/mem",
  1266. III_PIO_SZ(ptb_adb),
  1267. ptb_adb) == -1) {
  1268. perror("adb");
  1269. }
  1270. }
  1271. sun_check_etcsystem();
  1272. #endif
  1273. #ifndef _WIN32
  1274. if (uid != 0) {
  1275. printf("\n");
  1276. }
  1277. #endif
  1278. if (flag_html) printf("</P>\n");
  1279. }
  1280. #if defined(__sun) || defined(__hppa) || defined(IDDS_BSD_SYSCTL) || defined(IDDS_LINUX_SYSCTL)
  1281. static int ndd_get_tcp (char *a,long *vPtr)
  1282. {
  1283. char buf[8192];
  1284. #if defined(__sun)
  1285. sprintf(buf,"/usr/sbin/ndd /dev/tcp %s",a);
  1286. #else
  1287. #if defined(__hppa)
  1288. sprintf(buf,"/usr/bin/ndd /dev/tcp %s",a);
  1289. #else
  1290. #if defined(IDDS_BSD_SYSCTL) || defined(IDDS_LINUX_SYSCTL)
  1291. sprintf(buf,"/sbin/sysctl -n %s",a);
  1292. #else
  1293. sprintf(buf,"ndd /dev/tcp %s",a);
  1294. #endif
  1295. #endif
  1296. #endif
  1297. if (flag_debug) printf("DEBUG : %s\n",buf);
  1298. if (iii_pio_getnum(buf,vPtr) == -1) {
  1299. if (flag_solaris_251) {
  1300. if (strcmp(a,"tcp_conn_req_max_q0") == 0 ||
  1301. strcmp(a,"tcp_conn_req_max_q") == 0 ||
  1302. strcmp(a,"tcp_slow_start_initial") == 0) {
  1303. return -1;
  1304. }
  1305. }
  1306. printf("NOTICE : %s failed\n",buf);
  1307. return -1;
  1308. }
  1309. return 0;
  1310. }
  1311. #endif
  1312. #if defined(__sun)
  1313. static int patch_get_ver(int n)
  1314. {
  1315. int i;
  1316. for (i = 0;iii_patches[i].pnum != 0; i++) {
  1317. if (iii_patches[i].pnum == n) {
  1318. return iii_patches[i].seen;
  1319. }
  1320. }
  1321. return 0;
  1322. }
  1323. #endif
  1324. #if defined(__osf__)
  1325. int tru64_check_tcbhashsize(char *a,char *b)
  1326. {
  1327. int i;
  1328. if (strcmp(b,"unknown attribute") == 0) {
  1329. printf("WARNING: TCP tuning parameters are missing.\n\n");
  1330. return 0;
  1331. }
  1332. i = atoi(b);
  1333. if (i < 32) {
  1334. printf("WARNING: The inet tuning parameter tcbhashsize is set too low (%d),\nand should be raised to between 512 and 1024.\n\n",i);
  1335. flag_tru64_tuning_needed = 1;
  1336. } else if (i < 512) {
  1337. printf("NOTICE : The inet tuning parameter tcbhashsize is set too low (%d),\nand should be raised to between 512 and 1024.\n\n",i);
  1338. flag_tru64_tuning_needed = 1;
  1339. } else {
  1340. if (flag_debug) printf("DEBUG : tcbhashsize %d\n",i);
  1341. }
  1342. return 0;
  1343. }
  1344. int tru64_check_present_smp(char *a,char *b)
  1345. {
  1346. if (strcmp(b,"unknown attribute") == 0) {
  1347. printf("WARNING: If this is a multiprocessor system, additional tuning patches need\nto be installed, as sysconfig -q inet tuning parameter %s is missing.\n",
  1348. a);
  1349. printf("NOTICE : If this is a uniprocessor system, the above warning can be ignored.\n\n");
  1350. } else {
  1351. if (flag_debug) printf("DEBUG : %s %s\n", a, b);
  1352. }
  1353. return 0;
  1354. }
  1355. int tru64_check_msl(char *a,char *b)
  1356. {
  1357. int i;
  1358. if (strcmp(b,"unknown attribute") == 0) {
  1359. printf("WARNING: TCP tuning parameters are missing.\n\n");
  1360. return 0;
  1361. }
  1362. i = atoi(b);
  1363. if (i >= 60) {
  1364. printf("NOTICE : If running in a LAN or private network, the inet tcp_msl value can be\nreduced from %d (%d seconds) to increase performance.\n\n",
  1365. i, i/2);
  1366. flag_tru64_tuning_needed = 1;
  1367. }
  1368. return 0;
  1369. }
  1370. int tru64_check_present_client(char *a,char *b)
  1371. {
  1372. if (strcmp(b,"unknown attribute") == 0) {
  1373. printf("ERROR : This system is lacking necessary tuning patches. Upgrade to 4.0E\nor later is required.\n\n");
  1374. flag_os_bad = 1;
  1375. } else {
  1376. if (flag_debug) {
  1377. printf("DEBUG : %s %s\n",a,b);
  1378. }
  1379. }
  1380. return 0;
  1381. }
  1382. int tru64_check_conn(char *a,char *b)
  1383. {
  1384. int i;
  1385. i = atoi(b);
  1386. if (strcmp(a,"somaxconn") == 0 && i && i < 32767) {
  1387. printf("NOTICE : Increasing the socket tuning parameter somaxconn from %d to 65500\n is recommended.\n\n",i);
  1388. flag_tru64_tuning_needed = 1;
  1389. }
  1390. if (flag_debug) printf("DEBUG : %s %s\n",a,b);
  1391. return 0;
  1392. }
  1393. int tru64_check_threads(char *a,char *b)
  1394. {
  1395. int i;
  1396. i = atoi(b);
  1397. if (i < 512) {
  1398. printf("WARNING: The proc tuning parameter max-threads-per-user should be raised from\n%d to at least 512.\n\n",i);
  1399. flag_tru64_tuning_needed = 1;
  1400. } else {
  1401. if (flag_debug) printf("DEBUG : %s %s\n",a,b);
  1402. }
  1403. return 0;
  1404. }
  1405. struct iii_pio_parsetab ptb_sysconfig_inet[] = {
  1406. {"tcbhashsize ",tru64_check_tcbhashsize},
  1407. {"tcbhashnum ",tru64_check_present_smp},
  1408. {"ipqs ",tru64_check_present_smp},
  1409. {"tcp_msl ",tru64_check_msl},
  1410. {"ipport_userreserved_min ",tru64_check_present_client}
  1411. };
  1412. struct iii_pio_parsetab ptb_sysconfig_socket[] = {
  1413. {"sominconn ",tru64_check_conn},
  1414. {"somaxconn ",tru64_check_conn}
  1415. };
  1416. struct iii_pio_parsetab ptb_sysconfig_proc[] = {
  1417. {"max-threads-per-user ",tru64_check_threads}
  1418. };
  1419. static void sysconfig_tests (void)
  1420. {
  1421. struct utsname u;
  1422. if (uname(&u) == 0) {
  1423. if ((u.release[0] == 'T' || u.release[0] == 'V') && u.release[1] == '5') {
  1424. if (flag_debug) printf("DEBUG : Tru64 UNIX %s %s\n",
  1425. u.release,u.version);
  1426. } else if (strcmp(u.release,"V4.0") == 0) {
  1427. int iv;
  1428. /* Digital UNIX 4.x */
  1429. iv = atoi(u.version);
  1430. if (iv < 564) {
  1431. printf("ERROR : Digital UNIX versions prior to 4.0D are not supported as they lack\nnecessary kernel tuning parameters. Upgrade to 4.0E or later.\n\n");
  1432. flag_tru64_40b = 1;
  1433. flag_os_bad = 1;
  1434. } else if (iv < 878) {
  1435. printf("WARNING: Tru64 UNIX versions prior to 4.0D require a patch to provide \noptimal Internet performance.\n\n");
  1436. flag_tru64_40b = 1;
  1437. } else {
  1438. if (flag_debug) printf("DEBUG : Digital UNIX %s %s\n",
  1439. u.release,u.version);
  1440. }
  1441. } else if (u.release[0] == 'V' && u.release[1] == '3') {
  1442. printf("ERROR : Digital UNIX versions prior to 4.0D are not supported as they lack\nnecessary kernel tuning parameters. Upgrade to 4.0E or later.\n\n");
  1443. flag_os_bad = 1;
  1444. } else {
  1445. printf("%s: Tru64 UNIX release %s is not recognized.\n",
  1446. "NOTICE ", u.release);
  1447. }
  1448. }
  1449. /* inet subsystem raise tcbhashsize from 32/512 to 1024 */
  1450. /* inet subsystem raise tcbhashnum to 16 if multiprocessor, also ipqs
  1451. * not on 4.0D */
  1452. /* inet subsystem lower tcp_msl from 60 (30 secs) if on LAN */
  1453. /* client: inet subsystem raise ipport_userreserved_min from 5000 to 65000
  1454. * requires E or later */
  1455. if (iii_pio_procparse("/sbin/sysconfig -q inet",
  1456. III_PIO_SZ(ptb_sysconfig_inet),
  1457. ptb_sysconfig_inet) == -1) {
  1458. perror("/sbin/sysconfig");
  1459. }
  1460. /* socket raise sominconn to 65535 */
  1461. /* socket subsystem raise somaxconn from 1024 to 32767 */
  1462. if (iii_pio_procparse("/sbin/sysconfig -q socket",
  1463. III_PIO_SZ(ptb_sysconfig_socket),
  1464. ptb_sysconfig_socket) == -1) {
  1465. perror("/sbin/sysconfig");
  1466. }
  1467. /* proc max-threads-per-user from 256 to 512 or 4096 */
  1468. if (iii_pio_procparse("/sbin/sysconfig -q proc",
  1469. III_PIO_SZ(ptb_sysconfig_proc),
  1470. ptb_sysconfig_proc) == -1) {
  1471. perror("/sbin/sysconfig");
  1472. }
  1473. if (1) {
  1474. printf("NOTICE : More information on tuning is available on the web from Compaq at\nhttp://www.unix.digital.com/internet/tuning.htm\n\n");
  1475. printf("NOTICE : Additional performance recommendations can be obtained from the\nsys_check kit from Compaq, located at the following web site:\nftp://ftp.digital.com/pub/DEC/IAS/sys_check/sys_check.html\n\n");
  1476. }
  1477. }
  1478. #endif
  1479. #if defined(__hppa)
  1480. #include <dirent.h>
  1481. #define HP_PATCH_DIR "/var/adm/sw/products"
  1482. char *mo_lookup[] =
  1483. {
  1484. "January",
  1485. "February",
  1486. "March",
  1487. "April",
  1488. "May",
  1489. "June",
  1490. "July",
  1491. "August",
  1492. "September",
  1493. "October",
  1494. "November",
  1495. "December",
  1496. NULL
  1497. };
  1498. static int month_lookup(char *month)
  1499. {
  1500. int i;
  1501. for (i = 0; mo_lookup[i]; i++)
  1502. {
  1503. if (!strcmp(month, mo_lookup[i]))
  1504. return i+1;
  1505. }
  1506. }
  1507. static void hp_check_index(char *index_path, char *desc, int yr, int mo)
  1508. {
  1509. FILE *fp = fopen(index_path, "r");
  1510. char buf[BUFSIZ];
  1511. if (NULL == fp)
  1512. {
  1513. printf("ERROR: Failed to open Patch info file %s\n", index_path);
  1514. return;
  1515. }
  1516. while (fgets(buf, BUFSIZ, fp))
  1517. {
  1518. if (!strncmp(buf, "title", 5))
  1519. {
  1520. char *p;
  1521. char *datep = NULL;
  1522. if (p = strstr(buf, desc))
  1523. {
  1524. if (NULL != p)
  1525. {
  1526. /* found */
  1527. datep = strrchr(buf, ',');
  1528. if (!datep)
  1529. {
  1530. /* printf("WARNING: No date found: %s\n", datep);*/
  1531. continue;
  1532. }
  1533. datep++;
  1534. while (*datep == ' ' || *datep == '\t') datep++;
  1535. p = strchr(datep, ' ');
  1536. if (p)
  1537. {
  1538. char *q = p + 1;
  1539. while (*q == ' ' || *q == '\t') q++;
  1540. if (isdigit(*q))
  1541. {
  1542. char *qq;
  1543. int my_year;
  1544. for (qq = q; qq && *qq && isdigit(*qq); qq++) ;
  1545. if (qq && *qq)
  1546. *qq = '\0';
  1547. my_year = atoi(q);
  1548. if (my_year < yr)
  1549. {
  1550. printf("ERROR : %s, %s is older than the supported QPK of %s %d\n\n",
  1551. desc, datep, mo_lookup[mo-1], yr);
  1552. }
  1553. else if (my_year == yr)
  1554. {
  1555. int my_month;
  1556. *p = '\0';
  1557. my_month = month_lookup(datep);
  1558. *p = ' ';
  1559. if (my_month < mo)
  1560. {
  1561. printf("ERROR : %s, %s is older than the supported QPK of %s %d\n\n",
  1562. desc, datep, mo_lookup[mo-1], yr);
  1563. }
  1564. #ifdef QPK_DEBUG
  1565. else
  1566. {
  1567. printf("NOTICE: %s: Date %s is NO older than %d/%d\n",
  1568. desc, datep, mo, yr);
  1569. }
  1570. #endif
  1571. }
  1572. #ifdef QPK_DEBUG
  1573. else
  1574. {
  1575. printf("NOTICE: %s: Date %s is NO older than %d/%d\n",
  1576. desc, datep, mo, yr);
  1577. }
  1578. #endif
  1579. }
  1580. else
  1581. {
  1582. printf("WARNING: Bad formatted date: %s\n", datep);
  1583. }
  1584. }
  1585. }
  1586. }
  1587. }
  1588. }
  1589. fclose(fp);
  1590. }
  1591. static void hp_check_qpk()
  1592. {
  1593. char fbuf[MAXPATHLEN];
  1594. int i,pm= 0;
  1595. int not_su = 0;
  1596. int found = 0;
  1597. DIR *prod_dir = NULL;
  1598. struct dirent *dp = NULL;
  1599. if (access(HP_PATCH_DIR,X_OK) == -1) {
  1600. 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");
  1601. not_su = 1;
  1602. return;
  1603. }
  1604. for (i = 0; iii_qpk[i].qpk_name; i++)
  1605. {
  1606. prod_dir = opendir(HP_PATCH_DIR);
  1607. if (!prod_dir)
  1608. {
  1609. printf("ERROR : Patch directory %s has a problem.\n\n", HP_PATCH_DIR);
  1610. return;
  1611. }
  1612. found = 0;
  1613. while ((dp = readdir(prod_dir)) != NULL)
  1614. {
  1615. int len = strlen(iii_qpk[i].qpk_name);
  1616. if (strncmp(dp->d_name, iii_qpk[i].qpk_name, len) == 0)
  1617. {
  1618. /* matched */
  1619. found=1;
  1620. sprintf(fbuf, "%s/%s/pfiles/INDEX", HP_PATCH_DIR, dp->d_name);
  1621. if (access(fbuf, R_OK) == -1)
  1622. {
  1623. printf("WARNING : Patch info file %s does not exist or not readable.\n\n", fbuf);
  1624. }
  1625. else
  1626. {
  1627. hp_check_index(fbuf, iii_qpk[i].qpk_desc, iii_qpk[i].qpk_yr, iii_qpk[i].qpk_mo);
  1628. }
  1629. }
  1630. }
  1631. if(found==0)
  1632. {
  1633. printf("ERROR : Patch %s (%s) was not found.\n\n",iii_qpk[i].qpk_name,iii_qpk[i].qpk_desc);
  1634. }
  1635. (void) closedir(prod_dir);
  1636. }
  1637. }
  1638. static void hp_pthreads_tests(void)
  1639. {
  1640. unsigned long tmax,omax;
  1641. long cpu64;
  1642. cpu64 = sysconf(_SC_HW_32_64_CAPABLE);
  1643. if (_SYSTEM_SUPPORTS_LP64OS(cpu64) == 0) {
  1644. printf("WARNING: This system does not support 64 bit operating systems.\n\n");
  1645. } else {
  1646. if (flag_debug) printf("DEBUG : _SC_HW_32_64_CAPABLE 0x%x\n",cpu64);
  1647. }
  1648. tmax = sysconf(_SC_THREAD_THREADS_MAX);
  1649. if (tmax < 128) {
  1650. printf("WARNING: only %d threads are available in a process.\n", tmax);
  1651. printf("NOTICE : use sam Kernel Configuration Parameters to change max_thread_proc\n");
  1652. printf("and nkthreads as needed.\n\n");
  1653. } else {
  1654. if (flag_debug) printf("DEBUG : HP-UX max threads %ld\n", tmax);
  1655. }
  1656. /* XXX set ncallout (max number of pending timeouts ) to 128 + NPROC */
  1657. /* set maxfiles to at least 120 */
  1658. omax = sysconf(_SC_OPEN_MAX);
  1659. if (omax < 120) {
  1660. printf("WARNING: only %d files can be opened at once in a process.\n",omax);
  1661. printf("NOTICE : use sam Kernel Configuration Parameters to change maxfiles.\n");
  1662. } else {
  1663. if (flag_debug) printf("DEBUG : HP-UX maxfiles %ld\n", omax);
  1664. }
  1665. }
  1666. #endif
  1667. #if defined(__sun)
  1668. static void sun_check_network_device(void)
  1669. {
  1670. int devfd;
  1671. char buf[8192];
  1672. long ls;
  1673. if (flag_intel || flag_arch_bad || flag_os_bad) return;
  1674. devfd = open(SUN_NETWORK_DEVICE,O_RDONLY);
  1675. if (devfd == -1) {
  1676. switch (errno) {
  1677. case EACCES:
  1678. if (flag_debug) printf("DEBUG : got EACCES opening %s\n",
  1679. SUN_NETWORK_DEVICE);
  1680. break;
  1681. case ENOENT:
  1682. if (flag_debug) printf("DEBUG : got ENOENT opening %s\n",
  1683. SUN_NETWORK_DEVICE);
  1684. break;
  1685. default:
  1686. if (flag_debug) printf("DEBUG : got %d opening %s\n",
  1687. errno,SUN_NETWORK_DEVICE);
  1688. }
  1689. return;
  1690. } else {
  1691. close(devfd);
  1692. }
  1693. sprintf(buf,"/usr/sbin/ndd %s link_speed",SUN_NETWORK_DEVICE);
  1694. if (flag_debug) printf("DEBUG : %s\n",buf);
  1695. if (iii_pio_getnum(buf,&ls) == -1) {
  1696. if (flag_debug) printf("DEBUG : %s link_speed variable not available\n",
  1697. SUN_NETWORK_DEVICE);
  1698. } else {
  1699. /* XXX look at link speed */
  1700. if (flag_debug) printf("DEBUG : %s link_speed is %d\n",
  1701. SUN_NETWORK_DEVICE,ls);
  1702. }
  1703. }
  1704. #endif
  1705. #if defined(__sun) || defined(__hppa) || defined(IDDS_BSD_SYSCTL) || defined(IDDS_LINUX_SYSCTL)
  1706. static void ndd_tests (void)
  1707. {
  1708. if (flag_html) printf("<P>\n");
  1709. #if defined(IDDS_LINUX_SYSCTL)
  1710. /* following linux sysctls are TBD:
  1711. net.ipv4.tcp_max_syn_backlog, net.ipv4.tcp_fin_timeout
  1712. tcp_retries2 and tcp_retries
  1713. */
  1714. #endif
  1715. #if !defined(IDDS_BSD_SYSCTL) && !defined(IDDS_LINUX_SYSCTL)
  1716. {
  1717. char *name_tcp_time_wait_interval;
  1718. if (!flag_solaris_26) {
  1719. name_tcp_time_wait_interval = NAME_TCP_TIME_WAIT_INTERVAL;
  1720. } else {
  1721. name_tcp_time_wait_interval = "tcp_close_wait_interval";
  1722. }
  1723. if (ndd_get_tcp(name_tcp_time_wait_interval, &ndd_tcp_time_wait_interval) == 0) {
  1724. if (ndd_tcp_time_wait_interval >= 240000) {
  1725. if (flag_html) printf("<P>\n");
  1726. printf("%s: The %s is set to %d milliseconds (%d seconds).\n"
  1727. "This value should be reduced to allow for more simultaneous connections\n"
  1728. "to the server.\n",
  1729. flag_carrier ? "ERROR " : "WARNING",
  1730. name_tcp_time_wait_interval,
  1731. ndd_tcp_time_wait_interval,
  1732. ndd_tcp_time_wait_interval/1000);
  1733. #ifdef NAME_NDD_CFG_FILE
  1734. printf("A line similar to the following\nshould be added to the %s file:\n", NAME_NDD_CFG_FILE);
  1735. if (flag_html) printf("</P><PRE>\n");
  1736. printf("ndd -set /dev/tcp %s %d\n\n", name_tcp_time_wait_interval, 30000);
  1737. if (flag_html) printf("</PRE><P>\n");
  1738. #endif
  1739. if (flag_carrier) flag_os_bad = 1;
  1740. } else if (ndd_tcp_time_wait_interval < 10000) {
  1741. if (flag_html) printf("<P>\n");
  1742. printf("WARNING: The %s is set to %d milliseconds. Values below\n30000 may cause problems.\n\n",
  1743. name_tcp_time_wait_interval, ndd_tcp_time_wait_interval);
  1744. if (flag_html) printf("</P>\n");
  1745. } else {
  1746. if (flag_debug) {
  1747. printf("DEBUG : %s %d\n", name_tcp_time_wait_interval, ndd_tcp_time_wait_interval);
  1748. }
  1749. }
  1750. }
  1751. }
  1752. #if defined(__sun)
  1753. if (client == 0) {
  1754. if (ndd_get_tcp("tcp_conn_req_max_q0",&ndd_tcp_conn_req_max_q0) == 0) {
  1755. if (ndd_tcp_conn_req_max_q0 < 1024) {
  1756. if (flag_html) printf("<P>\n");
  1757. printf("ERROR : The tcp_conn_req_max_q0 value is too low, %d.\n\n",
  1758. ndd_tcp_conn_req_max_q0);
  1759. if (flag_solaris_251) {
  1760. printf("ERROR : Patches %s and %s may need to be applied.\n\n",
  1761. flag_intel ? "103631-10" : "103630-13",
  1762. flag_intel ? "103581-18" : "103582-18");
  1763. }
  1764. if (flag_html) printf("</P>\n");
  1765. } else if (ndd_tcp_conn_req_max_q0 >= (flag_carrier ? 10240 : 1024)) {
  1766. if (flag_debug) {
  1767. printf("DEBUG : tcp_conn_req_max_q0 %d\n",
  1768. ndd_tcp_conn_req_max_q0);
  1769. }
  1770. } else {
  1771. if (flag_html) printf("<P>\n");
  1772. 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",
  1773. ndd_tcp_conn_req_max_q0);
  1774. if (flag_html) printf("</P><PRE>\n");
  1775. printf("ndd -set /dev/tcp tcp_conn_req_max_q0 65536\n");
  1776. if (flag_html) printf("</PRE><P>\n");
  1777. if (tcp_max_listen == 1024) {
  1778. printf("Raising this to a value larger than 1024 may require that adb be used first\nto change the maximum setting.\n");
  1779. }
  1780. if (flag_html) printf("</P>\n");
  1781. printf("\n");
  1782. }
  1783. if (tcp_max_listen && ndd_tcp_conn_req_max_q0 > tcp_max_listen) {
  1784. if (flag_html) printf("<P>\n");
  1785. printf("WARNING: tcp_conn_req_max_q0 is larger than the kernel will allow.\n\n");
  1786. if (flag_html) printf("</P>\n");
  1787. }
  1788. } else {
  1789. if (flag_solaris_251) {
  1790. if (flag_html) printf("<P>\n");
  1791. 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",
  1792. flag_intel ? "103581-18" : "103582-18");
  1793. if (flag_html) printf("</P>\n");
  1794. }
  1795. }
  1796. }
  1797. #endif
  1798. if (client == 0) {
  1799. int recommended_tcp_conn_req_max = 128;
  1800. if (ndd_get_tcp(NAME_TCP_CONN_REQ_MAX_Q, &ndd_tcp_conn_req_max_q) == 0) {
  1801. if (flag_html) printf("<P>\n");
  1802. if (ndd_tcp_conn_req_max_q < recommended_tcp_conn_req_max) {
  1803. printf("ERROR : The NDD %s value %d is lower than the recommended minimum, %d.\n\n",
  1804. NAME_TCP_CONN_REQ_MAX_Q, ndd_tcp_conn_req_max_q, recommended_tcp_conn_req_max);
  1805. if (flag_solaris_251) {
  1806. printf("ERROR : Patches %s and %s may need to be applied.\n\n",
  1807. flag_intel ? "103631-10" : "103630-13",
  1808. flag_intel ? "103581-18" : "103582-18");
  1809. }
  1810. } else if (ndd_tcp_conn_req_max_q >= ndd_tcp_conn_req_max_q0) {
  1811. if (flag_debug) {
  1812. printf("DEBUG : %s %d\n", NAME_TCP_CONN_REQ_MAX_Q, ndd_tcp_conn_req_max_q);
  1813. }
  1814. } else {
  1815. printf("NOTICE : The %s value is currently %d, which will limit the\nvalue of listen backlog which can be configured. ",
  1816. NAME_TCP_CONN_REQ_MAX_Q, ndd_tcp_conn_req_max_q);
  1817. #ifdef NAME_NDD_CFG_FILE
  1818. printf("It can be raised by adding\nto %s, after any adb command, a line similar to:\n", NAME_NDD_CFG_FILE);
  1819. if (flag_html) printf("</P><PRE>\n");
  1820. printf("ndd -set /dev/tcp %s %d\n", NAME_TCP_CONN_REQ_MAX_Q, ndd_tcp_conn_req_max_q0);
  1821. if (flag_html) printf("</PRE><P>\n");
  1822. #endif
  1823. if (tcp_max_listen == 1024) {
  1824. printf("Raising this to a value larger than 1024 may require that adb be used first\nto change the maximum setting.\n");
  1825. }
  1826. printf("\n");
  1827. }
  1828. if (flag_html) printf("</P><P>\n");
  1829. if (tcp_max_listen && ndd_tcp_conn_req_max_q > tcp_max_listen) {
  1830. printf("WARNING: %s (value %d) is larger than the kernel will allow.\n\n", NAME_TCP_CONN_REQ_MAX_Q, ndd_tcp_conn_req_max_q);
  1831. }
  1832. if (flag_html) printf("</P><P>\n");
  1833. } else {
  1834. if (flag_solaris_251) {
  1835. if (flag_html) printf("</P><P>\n");
  1836. 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",
  1837. flag_intel ? "103581-18" : "103582-18");
  1838. if (flag_html) printf("</P><P>\n");
  1839. }
  1840. }
  1841. }
  1842. #endif
  1843. /* end of Solaris/HP-only code */
  1844. if (client == 0) {
  1845. if (ndd_get_tcp(NAME_TCP_KEEPALIVE_INTERVAL, &ndd_tcp_keepalive_interval) == 0) {
  1846. #if defined(IDDS_LINUX_SYSCTL)
  1847. ndd_tcp_keepalive_interval *= 1000; /* seconds to milliseconds */
  1848. #endif
  1849. if (ndd_tcp_keepalive_interval) {
  1850. if (solaris_version == 25 || solaris_version == 24) {
  1851. if (flag_html) printf("</P><P>\n");
  1852. 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);
  1853. if (flag_html) printf("</P><P>\n");
  1854. } else if (flag_solaris_251) {
  1855. if (flag_html) printf("</P><P>\n");
  1856. 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",
  1857. NAME_TCP_KEEPALIVE_INTERVAL, ndd_tcp_keepalive_interval/1000);
  1858. if (flag_html) printf("</P><P>\n");
  1859. } else {
  1860. if (ndd_tcp_keepalive_interval < 60000) {
  1861. if (flag_html) printf("</P><P>\n");
  1862. printf("NOTICE : The %s is set to %ld milliseconds\n(%ld seconds). This may cause excessive retransmissions in WAN\nenvironments.\n\n",
  1863. NAME_TCP_KEEPALIVE_INTERVAL,
  1864. ndd_tcp_keepalive_interval,
  1865. ndd_tcp_keepalive_interval/1000);
  1866. if (flag_html) printf("</P><P>\n");
  1867. } else if (ndd_tcp_keepalive_interval > 600000) {
  1868. if (flag_html) printf("</P><P>\n");
  1869. printf("NOTICE : The %s is set to %ld milliseconds\n(%ld minutes). This may cause temporary server congestion from lost\nclient connections.\n\n",
  1870. NAME_TCP_KEEPALIVE_INTERVAL,
  1871. ndd_tcp_keepalive_interval,
  1872. ndd_tcp_keepalive_interval / 60000);
  1873. if (flag_html) printf("</P><P>\n");
  1874. #ifdef NAME_NDD_CFG_FILE
  1875. printf("A line similar to the following should be added to %s:\n", NAME_NDD_CFG_FILE);
  1876. if (flag_html) printf("</P><PRE>\n");
  1877. printf("ndd -set /dev/tcp %s %d\n\n", NAME_TCP_KEEPALIVE_INTERVAL, 600000);
  1878. if (flag_html) printf("</PRE><P>\n");
  1879. #endif
  1880. } else if (flag_debug) {
  1881. printf("DEBUG : %s %ld (%ld seconds)\n",
  1882. NAME_TCP_KEEPALIVE_INTERVAL,
  1883. ndd_tcp_keepalive_interval,
  1884. ndd_tcp_keepalive_interval / 1000);
  1885. }
  1886. }
  1887. } else {
  1888. if (flag_solaris_251) {
  1889. if (flag_html) printf("</P><P>\n");
  1890. 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);
  1891. if (flag_html) printf("</P><P>\n");
  1892. } else {
  1893. if (flag_html) printf("</P><P>\n");
  1894. #ifdef NAME_NDD_CFG_FILE
  1895. printf("NOTICE : The %s is currently not set. This could result in\neventual server congestion. The interval can be set by adding the following\ncommand to %s:\n",NAME_TCP_KEEPALIVE_INTERVAL, NAME_NDD_CFG_FILE);
  1896. if (flag_html) printf("</P><PRE>\n");
  1897. printf("ndd -set /dev/tcp %s 60000\n",NAME_TCP_KEEPALIVE_INTERVAL);
  1898. if (flag_html) printf("</PRE><P>\n");
  1899. #endif
  1900. printf("\n");
  1901. }
  1902. }
  1903. }
  1904. }
  1905. #if !defined(IDDS_LINUX_SYSCTL)
  1906. if (ndd_get_tcp("tcp_rexmit_interval_initial",
  1907. &ndd_tcp_rexmit_interval_initial) == 0) {
  1908. if (ndd_tcp_rexmit_interval_initial > 2000) {
  1909. if (flag_html) printf("</P><P>\n");
  1910. 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",
  1911. ndd_tcp_rexmit_interval_initial,
  1912. ndd_tcp_rexmit_interval_initial/1000);
  1913. if (flag_html) printf("</P><P>\n");
  1914. #ifdef NAME_NDD_CFG_FILE
  1915. if (client) {
  1916. printf("NOTICE : For testing on a LAN or high speed WAN, this interval can be reduced\n"
  1917. "by adding to %s file:\n", NAME_NDD_CFG_FILE);
  1918. } else {
  1919. printf("NOTICE : If the directory service is intended only for LAN or private \n"
  1920. "high-speed WAN environment, this interval can be reduced by adding to\n"
  1921. "%s file:\n", NAME_NDD_CFG_FILE);
  1922. }
  1923. if (flag_html) printf("</P><PRE>\n");
  1924. printf("ndd -set /dev/tcp tcp_rexmit_interval_initial 500\n\n");
  1925. if (flag_html) printf("</PRE><P>\n");
  1926. #endif
  1927. } else {
  1928. if (flag_html) printf("</P><P>\n");
  1929. printf("NOTICE : The tcp_rexmit_interval_initial is currently set to %ld\n"
  1930. "milliseconds (%ld seconds). This may cause excessive retransmission on the\n"
  1931. "Internet.\n\n",
  1932. ndd_tcp_rexmit_interval_initial,
  1933. ndd_tcp_rexmit_interval_initial/1000);
  1934. if (flag_html) printf("</P><P>\n");
  1935. }
  1936. }
  1937. #endif
  1938. #if !defined(IDDS_LINUX_SYSCTL)
  1939. if (ndd_get_tcp("tcp_ip_abort_cinterval", &ndd_tcp_ip_abort_cinterval) == 0) {
  1940. if (ndd_tcp_ip_abort_cinterval > 10000) {
  1941. if (flag_html) printf("</P><P>\n");
  1942. printf("NOTICE : The NDD tcp_ip_abort_cinterval is currently set to %ld\n"
  1943. "milliseconds (%ld seconds). This may cause long delays in establishing\n"
  1944. "outgoing connections if the destination server is down.\n\n",
  1945. ndd_tcp_ip_abort_cinterval,
  1946. ndd_tcp_ip_abort_cinterval/1000);
  1947. if (flag_html) printf("</P><P>\n");
  1948. #ifdef NAME_NDD_CFG_FILE
  1949. printf("NOTICE : If the directory service is intended only for LAN or private \n"
  1950. "high-speed WAN environment, this interval can be reduced by adding to\n"
  1951. "%s file:\n", NAME_NDD_CFG_FILE);
  1952. if (flag_html) printf("</P><PRE>\n");
  1953. printf("ndd -set /dev/tcp tcp_ip_abort_cinterval 10000\n\n");
  1954. if (flag_html) printf("</PRE><P>\n");
  1955. #endif
  1956. }
  1957. }
  1958. if (ndd_get_tcp("tcp_ip_abort_interval", &ndd_tcp_ip_abort_interval) == 0) {
  1959. if (ndd_tcp_ip_abort_cinterval > 60000) {
  1960. if (flag_html) printf("</P><P>\n");
  1961. 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",
  1962. ndd_tcp_ip_abort_cinterval,
  1963. ndd_tcp_ip_abort_cinterval/1000);
  1964. if (flag_html) printf("</P><P>\n");
  1965. #ifdef NAME_NDD_CFG_FILE
  1966. printf("NOTICE : If the directory service is intended only for LAN or private \nhigh-speed WAN environment, this interval can be reduced by adding to\n%s:\n", NAME_NDD_CFG_FILE);
  1967. if (flag_html) printf("</P><PRE>\n");
  1968. printf("ndd -set /dev/tcp tcp_ip_abort_interval 60000\n\n");
  1969. if (flag_html) printf("</PRE><P>\n");
  1970. #endif
  1971. }
  1972. }
  1973. #endif
  1974. #if defined(__sun)
  1975. if (ndd_get_tcp("tcp_strong_iss",
  1976. &ndd_tcp_strong_iss) == 0) {
  1977. switch(ndd_tcp_strong_iss) {
  1978. case 0:
  1979. if (flag_debug) printf("DEBUG : tcp_strong_iss 0\n");
  1980. break;
  1981. case 1:
  1982. if (flag_debug) printf("DEBUG : tcp_strong_iss 1\n");
  1983. 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");
  1984. if (flag_html) printf("</P><PRE>\n");
  1985. printf("ndd -set /dev/tcp tcp_strong_iss 2\n\n");
  1986. if (flag_html) printf("</PRE><P>\n");
  1987. break;
  1988. case 2:
  1989. if (flag_debug) printf("DEBUG : tcp_strong_iss 2\n");
  1990. break;
  1991. }
  1992. } else {
  1993. if (flag_debug) printf("DEBUG : tcp_strong_iss not found\n");
  1994. }
  1995. #endif
  1996. /* Linux uses net.ipv4.ip_local_port_range = 1024 4999 */
  1997. #if !defined(IDDS_LINUX_SYSCTL)
  1998. if (ndd_get_tcp(NAME_TCP_SMALLEST_ANON_PORT,
  1999. &ndd_tcp_smallest_anon_port) == 0) {
  2000. if (ndd_tcp_smallest_anon_port >= 32768) {
  2001. int aport = 65536-ndd_tcp_smallest_anon_port;
  2002. if (flag_html) printf("</P><P>\n");
  2003. printf("%s: The NDD %s is currently %ld. This allows a\nmaximum of %ld simultaneous connections. ",
  2004. (flag_carrier || aport <= 16384) ? "ERROR " : "NOTICE ",
  2005. NAME_TCP_SMALLEST_ANON_PORT,
  2006. ndd_tcp_smallest_anon_port,
  2007. 65536 - ndd_tcp_smallest_anon_port);
  2008. if (flag_carrier) flag_os_bad = 1;
  2009. #ifdef NAME_NDD_CFG_FILE
  2010. printf("More ports can be made available by\nadding a line to %s:\n", NAME_NDD_CFG_FILE);
  2011. if (flag_html) printf("</P><PRE>\n");
  2012. printf("ndd -set /dev/tcp tcp_smallest_anon_port 8192\n");
  2013. if (flag_html) printf("</PRE><P>\n");
  2014. #endif
  2015. printf("\n");
  2016. } else {
  2017. if (flag_debug) {
  2018. printf("DEBUG : %s %ld\n", NAME_TCP_SMALLEST_ANON_PORT,
  2019. ndd_tcp_smallest_anon_port);
  2020. }
  2021. }
  2022. }
  2023. #endif
  2024. #if defined(__sun)
  2025. if (ndd_get_tcp("tcp_slow_start_initial",&ndd_tcp_slow_start_initial) == 0) {
  2026. if (ndd_tcp_slow_start_initial == 2 || ndd_tcp_slow_start_initial == 4) {
  2027. if (flag_debug) printf("DEBUG : tcp_slow_start_initial %ld\n",
  2028. ndd_tcp_slow_start_initial);
  2029. } else if (ndd_tcp_slow_start_initial == 1) {
  2030. if (client == 0) {
  2031. if (flag_html) printf("</P><P>\n");
  2032. 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.");
  2033. printf("This line can be added to the /etc/init.d/inetinit file:\n");
  2034. if (flag_html) printf("</P><PRE>\n");
  2035. printf("ndd -set /dev/tcp tcp_slow_start_initial 2\n");
  2036. if (flag_html) printf("</PRE><P>\n");
  2037. printf("\n");
  2038. }
  2039. } else {
  2040. printf("NOTICE : Unrecognized tcp_slow_start_initial value %ld\n\n",
  2041. ndd_tcp_slow_start_initial);
  2042. }
  2043. } else {
  2044. if (flag_solaris_251) {
  2045. int cpv;
  2046. cpv = patch_get_ver(flag_intel ? 103581: 103582);
  2047. if (flag_html) printf("</P><P>\n");
  2048. 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",
  2049. flag_intel ? "103581-15" : "103582-15",
  2050. cpv == 0 ? "this or a later version of this " : "a later version of this ");
  2051. if (flag_html) printf("</P><P>\n");
  2052. }
  2053. }
  2054. #endif
  2055. #if defined(IDDS_BSD_SYSCTL)
  2056. if (1) {
  2057. if (ndd_get_tcp("net.inet.tcp.delayed_ack",&ndd_tcp_deferred_ack_interval) == 0) {
  2058. if (ndd_tcp_deferred_ack_interval > 0) {
  2059. 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");
  2060. } else {
  2061. if (flag_debug) printf("DEBUG : ndd /dev/tcp tcp_deferred_ack_interval %ld\n", ndd_tcp_deferred_ack_interval);
  2062. }
  2063. }
  2064. }
  2065. #endif
  2066. #if defined(__sun) || defined(__hppa)
  2067. if (1) {
  2068. if (ndd_get_tcp("tcp_deferred_ack_interval",&ndd_tcp_deferred_ack_interval) == 0) {
  2069. if (ndd_tcp_deferred_ack_interval > 5) {
  2070. 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",
  2071. flag_carrier ? "ERROR " : "WARNING",
  2072. ndd_tcp_deferred_ack_interval);
  2073. if (flag_carrier) flag_os_bad = 1;
  2074. #ifdef NAME_NDD_CFG_FILE
  2075. printf("This line can be added to the %s file:\n", NAME_NDD_CFG_FILE);
  2076. if (flag_html) printf("</P><PRE>\n");
  2077. printf("ndd -set /dev/tcp tcp_deferred_ack_interval 5\n");
  2078. if (flag_html) printf("</PRE><P>\n");
  2079. #endif
  2080. printf("\n");
  2081. } else {
  2082. if (flag_debug) printf("DEBUG : ndd /dev/tcp tcp_deferred_ack_interval %ld\n", ndd_tcp_deferred_ack_interval);
  2083. }
  2084. }
  2085. }
  2086. #endif
  2087. /* must be root to see
  2088. * ip_forward_src_routed, ip_forward_directed_broadcasts,
  2089. * ip_forwarding XXX
  2090. */
  2091. #if defined(__sun)
  2092. sun_check_network_device();
  2093. #endif
  2094. #if !defined(IDDS_LINUX_SYSCTL)
  2095. if (hpux_ndd_change_needed) {
  2096. printf("NOTICE : ndd settings can be placed in /etc/rc.config.d/nddconf\n\n");
  2097. }
  2098. #endif
  2099. if (flag_html) printf("</P>\n");
  2100. }
  2101. #endif
  2102. static int get_disk_avail(char *dir)
  2103. {
  2104. #if defined(__sun)
  2105. char cmd[8192];
  2106. FILE *fp;
  2107. char buf[8192];
  2108. if (client) return 0;
  2109. sprintf(cmd,"df -b %s",dir);
  2110. if (flag_debug) printf("DEBUG : %s\n",cmd);
  2111. fp = popen(cmd,"r");
  2112. if (fp == NULL) {
  2113. perror("popen");
  2114. return -1;
  2115. }
  2116. while (fgets(buf,8192,fp) != NULL) {
  2117. char *rp;
  2118. int i;
  2119. rp = strchr(buf,'\n');
  2120. if (rp) {
  2121. *rp = '\0';
  2122. }
  2123. if (strncmp(buf,"Filesystem",10) == 0) {
  2124. continue;
  2125. }
  2126. if (strncmp(buf,"df: ",4) == 0) {
  2127. printf("ERROR : %s\n\n", buf);
  2128. fclose(fp);
  2129. return -1;
  2130. }
  2131. rp = strchr(buf,':');
  2132. if (rp) {
  2133. *rp = '\0';
  2134. if (flag_html) printf("<P>\n");
  2135. printf("ERROR : %s partition is on file system mounted from %s, not local.\n\n",dir,buf);
  2136. if (flag_html) printf("</P>\n");
  2137. fclose(fp);
  2138. return -1;
  2139. }
  2140. rp = strchr(buf,' ');
  2141. if (rp == NULL) {
  2142. rp = strchr(buf,'\t');
  2143. }
  2144. if (rp == NULL) continue;
  2145. while(isspace(*rp)) rp++;
  2146. if (!isdigit(*rp)) {
  2147. continue;
  2148. }
  2149. i = atoi(rp);
  2150. fclose(fp);
  2151. return (i / 1024);
  2152. }
  2153. fclose (fp);
  2154. #else
  2155. #if defined(IDDS_HAVE_STATVFS)
  2156. struct statvfs vfs;
  2157. if (statvfs(dir,&vfs) == 0) {
  2158. return ((vfs.f_bfree * (vfs.f_bsize / 1024)) / 1024);
  2159. }
  2160. #else
  2161. #if defined(IDDS_LINUX_INCLUDE)
  2162. struct statfs sfs;
  2163. if (statfs(dir,&sfs) == 0) {
  2164. return ((sfs.f_bfree * (sfs.f_bsize / 1024)) / 1024);
  2165. }
  2166. #else
  2167. #if defined(_WIN32)
  2168. /* could use GetDiskFreeSpaceEx */
  2169. #endif
  2170. #endif
  2171. #endif
  2172. #endif
  2173. return -1;
  2174. }
  2175. /* return 0 if fsmnt is a longer subset of reqdir than mntbuf */
  2176. static int mntdir_matches(char *reqdir,int reqlen,char *fsmnt,char *mntbuf)
  2177. {
  2178. int cml;
  2179. int pml;
  2180. cml = strlen(fsmnt);
  2181. pml = strlen(mntbuf);
  2182. /* incoming file system is 'below' */
  2183. if (reqlen < cml) {
  2184. if (flag_debug) printf("DEBUG : mntdir_matches want %s < input %s\n",
  2185. reqdir, fsmnt);
  2186. return -1;
  2187. }
  2188. if (reqlen == cml && strcmp(reqdir,fsmnt) == 0) {
  2189. /* exact match */
  2190. if (flag_debug) printf("DEBUG : reqlen %d == cml %d\n", reqlen, cml);
  2191. strcpy(mntbuf,fsmnt);
  2192. return 0;
  2193. }
  2194. /* assert reqlen >= cml */
  2195. if (strncmp(fsmnt,reqdir,cml) != 0) {
  2196. if (flag_debug) printf("DEBUG : fsmnt %s != reqdir %s\n", fsmnt, reqdir);
  2197. return -1;
  2198. }
  2199. if (reqdir[cml] != '/' && cml > 1) {
  2200. if (flag_debug) printf("DEBUG : fsmnt %s: reqdir %s is %c not / \n",
  2201. fsmnt, reqdir, reqdir[cml]);
  2202. return -1;
  2203. }
  2204. if (pml > cml) {
  2205. if (flag_debug) printf("DEBUG : pml %d > cml %d\n", pml, cml);
  2206. return -1;
  2207. }
  2208. if (flag_debug) printf("DEBUG : replacing %s with %s\n", mntbuf, fsmnt);
  2209. strcpy(mntbuf,fsmnt);
  2210. return 0;
  2211. }
  2212. /* check that the file system has largefiles on HP */
  2213. static int check_fs_options(char *reqdir,char mntbuf[MAXPATHLEN])
  2214. {
  2215. #if defined(IDDS_MNTENT_DIRNAME)
  2216. FILE *fp = NULL;
  2217. int found = -1;
  2218. int any_found = 0;
  2219. int reqlen = strlen(reqdir);
  2220. char optbuf[BUFSIZ];
  2221. if (client == 1) return -1;
  2222. mntbuf[0] = '\0';
  2223. optbuf[0] = '\0';
  2224. #if defined(IDDS_MNTENT_MNTTAB)
  2225. fp = fopen(IDDS_MNTENT_MNTTAB,"r");
  2226. if (fp == NULL) {
  2227. perror(IDDS_MNTENT_MNTTAB);
  2228. return -1;
  2229. }
  2230. #endif
  2231. while(1) {
  2232. struct IDDS_MNTENT *mep;
  2233. #if defined(__sun)
  2234. struct IDDS_MNTENT m;
  2235. mep = &m;
  2236. if (getmntent(fp,mep) != 0) break;
  2237. #else
  2238. #if defined(__hppa) || defined(IDDS_LINUX_INCLUDE)
  2239. mep = getmntent(fp);
  2240. if (mep == NULL) break;
  2241. #else
  2242. #if !defined(IDDS_MNTENT_MNTTAB)
  2243. /* not quite the same, but Tru64 and AIX don't have getmntent */
  2244. mep = getfsent();
  2245. if (mep == NULL) break;
  2246. #else
  2247. break;
  2248. #endif
  2249. #endif
  2250. #endif
  2251. if (mntdir_matches(reqdir,reqlen,mep->IDDS_MNTENT_DIRNAME,mntbuf) == 0) {
  2252. found = 0;
  2253. #if defined(IDDS_MNTENT_OPTIONS)
  2254. strcpy(optbuf,mep->IDDS_MNTENT_OPTIONS);
  2255. #else
  2256. strcpy(optbuf,"");
  2257. #endif
  2258. if (flag_debug) printf("DEBUG : file system %s matches %s with options %s\n",
  2259. mntbuf, reqdir, optbuf);
  2260. } else {
  2261. #if defined(IDDS_MNTENT_OPTIONS)
  2262. if (strstr(mep->IDDS_MNTENT_OPTIONS,"nolargefiles") != NULL) {
  2263. } else if (strstr(mep->IDDS_MNTENT_OPTIONS,"largefiles") != NULL) {
  2264. if (flag_debug) printf("DEBUG : file system %s allows largefiles\n",
  2265. mep->IDDS_MNTENT_DIRNAME);
  2266. any_found++;
  2267. }
  2268. #endif
  2269. }
  2270. }
  2271. if (fp) fclose (fp);
  2272. #if defined(__hppa)
  2273. if (found == 0) {
  2274. int largefile_missing = 0;
  2275. if (strstr(optbuf,"nolargefiles") != NULL) {
  2276. largefile_missing = 1;
  2277. } else if (strstr(optbuf,"largefiles") == NULL) {
  2278. largefile_missing = 1;
  2279. }
  2280. if (largefile_missing) {
  2281. if (any_found == 0) {
  2282. printf("WARNING: largefiles option is not present on mount of %s, \nfiles may be limited to 2GB in size.\n\n", mntbuf);
  2283. } else {
  2284. 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);
  2285. }
  2286. }
  2287. } else {
  2288. if (any_found == 0) {
  2289. printf("WARNING: no file system mounted with largefiles option.\n\n");
  2290. }
  2291. }
  2292. #endif
  2293. return found;
  2294. #else
  2295. return -1;
  2296. #endif
  2297. }
  2298. static void check_disk_quota(char mntbuf[MAXPATHLEN])
  2299. {
  2300. #if defined(__sun)
  2301. char qfname[MAXPATHLEN];
  2302. struct stat sbuf;
  2303. sprintf(qfname,"%s/quotas",mntbuf);
  2304. if (stat(qfname,&sbuf) == 0 || errno == EACCES) {
  2305. printf("NOTICE : quotas are present on file system %s.\n\n",mntbuf);
  2306. }
  2307. #endif
  2308. }
  2309. static void disk_tests(void)
  2310. {
  2311. #ifndef _WIN32
  2312. struct rlimit r;
  2313. #endif
  2314. char mntbuf[MAXPATHLEN];
  2315. if (client) return;
  2316. avail_root = get_disk_avail("/");
  2317. if (flag_debug) printf("DEBUG : %dMB available on /\n",avail_root);
  2318. if (flag_html) printf("<P>\n");
  2319. if (avail_root != -1 && avail_root < 2) {
  2320. if (flag_html) printf("</P><P>\n");
  2321. printf("ERROR : / partition is full\n");
  2322. flag_os_bad = 1;
  2323. if (flag_html) printf("</P><P>\n");
  2324. }
  2325. #if defined(RLIMIT_CORE)
  2326. getrlimit(RLIMIT_CORE,&r);
  2327. if (flag_debug) printf("DEBUG : RLIMIT_CORE is %ld, %ld\n", r.rlim_cur, r.rlim_max);
  2328. if (r.rlim_cur == -1 || r.rlim_cur >= 2147483647) {
  2329. if (swap_mb <2048) {
  2330. max_core = swap_mb;
  2331. } else {
  2332. max_core = 2048;
  2333. }
  2334. } else {
  2335. max_core = r.rlim_max / (1024*1024);
  2336. }
  2337. if (phys_mb) {
  2338. if (max_core > (phys_mb + swap_mb)) {
  2339. max_core = phys_mb + swap_mb;
  2340. }
  2341. }
  2342. #endif
  2343. if (avail_root != -1 && max_core > avail_root && flag_quick == 0) {
  2344. if (flag_html) printf("</P><P>\n");
  2345. 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",
  2346. avail_root, max_core);
  2347. if (flag_html) printf("</P><P>\n");
  2348. }
  2349. if (install_dir[0] == '\0') {
  2350. #if defined(_WIN32)
  2351. /* TBD */
  2352. #else
  2353. if (access("/usr/netscape",X_OK) == 0) {
  2354. sprintf(install_dir,"/usr/netscape");
  2355. } else {
  2356. sprintf(install_dir,"/opt");
  2357. }
  2358. #endif
  2359. }
  2360. if (check_fs_options(install_dir,mntbuf) == 0) {
  2361. } else {
  2362. strcpy(mntbuf,install_dir);
  2363. }
  2364. avail_opt = get_disk_avail(mntbuf);
  2365. if (flag_debug) printf("DEBUG : %dMB available on %s\n",
  2366. avail_opt,mntbuf);
  2367. if (avail_opt != -1) {
  2368. if (flag_html) printf("</P><P>\n");
  2369. if (avail_opt < 2) {
  2370. printf("ERROR : %s partition is full.\n",mntbuf);
  2371. } else if (avail_opt < 100) {
  2372. printf("NOTICE : %s partition has only %dMB free.\n",mntbuf,avail_opt);
  2373. }
  2374. if (flag_html) printf("</P><P>\n");
  2375. }
  2376. check_disk_quota(mntbuf);
  2377. if (flag_html) printf("</P>\n");
  2378. }
  2379. #if 0
  2380. /* The function hasn't been used. #if 0 to get rid of compiler warning */
  2381. static int get_disk_usage(char *s)
  2382. {
  2383. #ifndef _WIN32
  2384. char cmd[8192];
  2385. char buf[8192];
  2386. FILE *fp;
  2387. int i;
  2388. sprintf(cmd,"du -s -k %s",s);
  2389. if (flag_debug) printf("DEBUG : du -s -k %s\n",s);
  2390. fp = popen(cmd,"r");
  2391. if (fp == NULL) {
  2392. perror("du");
  2393. return 0;
  2394. }
  2395. buf[0] = '\0';
  2396. fgets(buf,8192,fp);
  2397. fclose (fp);
  2398. i = atoi(buf);
  2399. return (i / 1024);
  2400. #else
  2401. return 0;
  2402. #endif
  2403. }
  2404. #endif
  2405. static void check_mem_size(int ro,char *rn)
  2406. {
  2407. #ifndef _WIN32
  2408. struct rlimit r;
  2409. int rprev;
  2410. long m_mb;
  2411. int m_change_needed = 0;
  2412. getrlimit(ro,&r);
  2413. rprev = r.rlim_cur;
  2414. r.rlim_cur = r.rlim_max;
  2415. setrlimit(ro,&r);
  2416. getrlimit(ro,&r);
  2417. if (flag_debug) printf("DEBUG : %s (%d) max %d prev %d.\n",
  2418. rn, ro, (int)r.rlim_cur, rprev);
  2419. #if defined(__alpha) || defined(__ALPHA)
  2420. if (r.rlim_cur <= 0L) return;
  2421. #endif
  2422. if (r.rlim_cur <= 0) return;
  2423. m_mb = r.rlim_cur / 1048576;
  2424. if (m_mb < mem_min) { /* 64 MB */
  2425. printf("ERROR : processes are limited by %s to %ld MB in size.\n",
  2426. rn, m_mb);
  2427. m_change_needed = 1;
  2428. flag_os_bad = 1;
  2429. } else if (m_mb <= mem_rec) {
  2430. printf("WARNING: processes are limited by %s to %ld MB in size.\n",
  2431. rn, m_mb);
  2432. m_change_needed = 1;
  2433. }
  2434. if (m_change_needed) {
  2435. #if defined(__hppa)
  2436. printf("NOTICE : use sam Kernel Configuration Parameters to change maxdsiz parameter.\n");
  2437. #endif
  2438. printf("\n");
  2439. }
  2440. #endif
  2441. }
  2442. static void limits_tests(void)
  2443. {
  2444. #ifndef _WIN32
  2445. struct rlimit r;
  2446. #if defined(RLIMIT_NOFILE)
  2447. getrlimit(RLIMIT_NOFILE,&r);
  2448. if (r.rlim_max <= 1024) {
  2449. if (flag_html) printf("<P>\n");
  2450. if (flag_carrier) {
  2451. printf("ERROR : There are only %ld file descriptors (hard limit) available, which\nlimit the number of simultaneous connections. ",r.rlim_max);
  2452. flag_os_bad = 1;
  2453. } else {
  2454. printf("WARNING: There are only %ld file descriptors (hard limit) available, which\nlimit the number of simultaneous connections. ",r.rlim_max);
  2455. }
  2456. #if defined(__sun)
  2457. printf("Additional file descriptors,\nup to 65536, are available by adding to /etc/system a line like\n");
  2458. if (flag_html) printf("</P><PRE>\n");
  2459. printf("set rlim_fd_max=4096\n");
  2460. if (flag_html) printf("</PRE><P>\n");
  2461. #else
  2462. #if defined(__hppa)
  2463. printf("Additional file descriptors,\nup to 60000, are available by editing /stand/system and regenerating the kernel.\n");
  2464. if (flag_html) printf("</P><PRE>\n");
  2465. printf("maxfiles_lim 4096\n");
  2466. if (flag_html) printf("</PRE><P>\n");
  2467. #else
  2468. printf("\n");
  2469. #endif
  2470. #endif
  2471. printf("\n");
  2472. if (flag_html) printf("</P>\n");
  2473. } else {
  2474. if (flag_debug) printf("DEBUG : %ld descriptors (hard limit) available.\n",
  2475. r.rlim_max);
  2476. }
  2477. if (r.rlim_cur <= 1024) {
  2478. if (flag_html) printf("<P>\n");
  2479. if (flag_carrier) {
  2480. printf("ERROR : There are only %ld file descriptors (soft limit) available, which\nlimit the number of simultaneous connections. ",r.rlim_cur);
  2481. flag_os_bad = 1;
  2482. } else {
  2483. printf("WARNING: There are only %ld file descriptors (soft limit) available, which\nlimit the number of simultaneous connections. ",r.rlim_cur);
  2484. }
  2485. #if defined(__sun) || defined(__hppa)
  2486. 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);
  2487. if (flag_html) printf("</P><PRE>\n");
  2488. printf("ulimit -n 4096\n");
  2489. if (flag_html) printf("</PRE><P>\n");
  2490. #else
  2491. printf("\n");
  2492. #endif
  2493. printf("\n");
  2494. if (flag_html) printf("</P>\n");
  2495. } else {
  2496. if (flag_debug) printf("DEBUG : %ld descriptors (soft limit) available.\n",
  2497. r.rlim_cur);
  2498. }
  2499. #endif
  2500. #if defined(RLIMIT_DATA)
  2501. check_mem_size(RLIMIT_DATA,"RLIMIT_DATA");
  2502. #endif
  2503. #if defined(RLIMIT_VMEM)
  2504. check_mem_size(RLIMIT_VMEM,"RLIMIT_VMEM");
  2505. #endif
  2506. #if defined(RLIMIT_AS)
  2507. check_mem_size(RLIMIT_AS,"RLIMIT_AS");
  2508. #endif
  2509. #endif
  2510. }
  2511. /*
  2512. *** return the type of platform on which the software is running.
  2513. ***/
  2514. static void ids_get_platform(char *buf)
  2515. {
  2516. #if defined(IDDS_LINUX_INCLUDE) || defined(__osf__) || defined(_AIX) || defined(__hppa) || defined(IDDS_BSD_INCLUDE)
  2517. struct utsname u;
  2518. #endif
  2519. #if defined(_WIN32)
  2520. SYSTEM_INFO sysinfo;
  2521. OSVERSIONINFO osinfo;
  2522. char osbuf[128];
  2523. #endif
  2524. #if defined(__hppa) || defined(_AIX)
  2525. char model[128];
  2526. char procstr[128];
  2527. char oslevel[128];
  2528. #endif
  2529. #if defined(__hppa)
  2530. long cpuvers, cputype;
  2531. #endif
  2532. #if defined(_WIN32)
  2533. osinfo.dwOSVersionInfoSize = sizeof(osinfo);
  2534. GetSystemInfo(&sysinfo);
  2535. sprintf(osbuf,"win32");
  2536. if (GetVersionEx(&osinfo) != 0) {
  2537. if (osinfo.dwPlatformId == VER_PLATFORM_WIN32_NT) {
  2538. sprintf(osbuf,"winnt%d.%d.%d",
  2539. osinfo.dwMajorVersion,
  2540. osinfo.dwMinorVersion,
  2541. osinfo.dwBuildNumber);
  2542. if (osinfo.szCSDVersion[0]) {
  2543. strcat(osbuf," (");
  2544. strcat(osbuf,osinfo.szCSDVersion);
  2545. strcat(osbuf,")");
  2546. }
  2547. }
  2548. }
  2549. switch(sysinfo.wProcessorArchitecture) {
  2550. case PROCESSOR_ARCHITECTURE_INTEL:
  2551. sprintf(buf,"i%d86-unknown-%s",sysinfo.wProcessorLevel,osbuf);
  2552. break;
  2553. case PROCESSOR_ARCHITECTURE_ALPHA:
  2554. sprintf(buf,"alpha%d-unknown-%s",
  2555. sysinfo.wProcessorLevel,osbuf);
  2556. break;
  2557. case PROCESSOR_ARCHITECTURE_MIPS:
  2558. sprintf(buf,"mips-unknown-%s",osbuf);
  2559. break;
  2560. case PROCESSOR_ARCHITECTURE_PPC:
  2561. sprintf(buf,"ppc-unknown-%s",osbuf);
  2562. break;
  2563. case PROCESSOR_ARCHITECTURE_UNKNOWN:
  2564. sprintf(buf,"unknown-unknown-%s",osbuf);
  2565. break;
  2566. }
  2567. #else
  2568. #if defined(IDDS_LINUX_INCLUDE)
  2569. if (uname(&u) == 0) {
  2570. sprintf(buf,"%s-unknown-linux%s",
  2571. u.machine,u.release);
  2572. } else {
  2573. sprintf(buf,"i386-unknown-linux");
  2574. }
  2575. #else
  2576. #if defined(__sun)
  2577. ids_get_platform_solaris(buf);
  2578. #else
  2579. #if defined(_AIX)
  2580. if (getenv("ODMPATH") == NULL) {
  2581. putenv("ODMPATH=/usr/lib/objrepos:/etc/objrepos");
  2582. }
  2583. /* i386, powerpc, rs6000 */
  2584. idds_aix_odm_get_cuat("name=proc0",procstr);
  2585. idds_aix_odm_get_cuat("attribute=modelname",model);
  2586. oslevel[0] = '\0';
  2587. idds_aix_pio_get_oslevel(oslevel);
  2588. if (uname(&u) == 0) {
  2589. if (oslevel[0]) {
  2590. sprintf(buf,"%s-%s-%s%s",
  2591. procstr[0] ? procstr : "unknown" ,
  2592. model[0] ? model : "ibm",
  2593. u.sysname,oslevel);
  2594. } else {
  2595. sprintf(buf,"%s-%s-%s%s.%s",
  2596. procstr[0] ? procstr : "unknown" ,
  2597. model[0] ? model : "ibm",
  2598. u.sysname,u.version,u.release);
  2599. }
  2600. } else {
  2601. sprintf(buf,"%s-unknown-aix", procstr[0] ? procstr : "unknown");
  2602. }
  2603. #else
  2604. #if defined(IDDS_BSD_INCLUDE)
  2605. uname(&u);
  2606. sprintf(buf,"%s-unknown-%s%s",
  2607. u.machine,u.sysname,u.release);
  2608. #else
  2609. #if defined(__hppa)
  2610. uname(&u);
  2611. confstr(_CS_MACHINE_MODEL,model,128);
  2612. cpuvers = sysconf(_SC_CPU_VERSION);
  2613. cputype = sysconf(_SC_CPU_CHIP_TYPE);
  2614. switch(cpuvers) {
  2615. case CPU_PA_RISC1_0:
  2616. sprintf(procstr,"hppa1.0/%d",cputype);
  2617. break;
  2618. case CPU_PA_RISC1_1:
  2619. sprintf(procstr,"hppa1.1/%d",cputype);
  2620. break;
  2621. case CPU_PA_RISC1_2:
  2622. sprintf(procstr,"hppa1.2/%d",cputype);
  2623. break;
  2624. case CPU_PA_RISC2_0:
  2625. sprintf(procstr,"hppa2.0/%d",cputype);
  2626. break;
  2627. default:
  2628. sprintf(procstr,"hppa_0x%x/%d",cpuvers,cputype);
  2629. break;
  2630. }
  2631. sprintf(buf,"%s-hp%s-hpux_%s",procstr,model,u.release);
  2632. #else
  2633. #if defined(__VMS)
  2634. #if defined (__ALPHA)
  2635. sprintf(buf,"alpha-dec-vms");
  2636. #else
  2637. sprintf(buf,"vax-dec-vms");
  2638. #endif
  2639. #else
  2640. #if defined(__osf__)
  2641. #if defined(__alpha) || defined(__ALPHA)
  2642. ids_get_platform_tru64(buf);
  2643. #else
  2644. sprintf(buf,"unknown-unknown-osf");
  2645. #endif
  2646. #else
  2647. #if defined(SI_HW_PROVIDER) && defined(SI_MACHINE) && defined(SI_SYSNAME) && defined(SI_RELEASE)
  2648. if (1) {
  2649. char *bp;
  2650. sysinfo(SI_MACHINE,buf,64);
  2651. bp = buf + strlen(buf);
  2652. *bp = '-';
  2653. bp++;
  2654. sysinfo(SI_HW_PROVIDER,bp,64);
  2655. bp = bp + strlen(bp);
  2656. *bp = '-';
  2657. bp++;
  2658. sysinfo(SI_SYSNAME,bp,64);
  2659. bp = bp + strlen(bp);
  2660. sysinfo(SI_RELEASE,bp,64);
  2661. }
  2662. #else
  2663. #if defined(SI_MACHINE)
  2664. sysinfo(SI_MACHINE,buf,64);
  2665. strcat(buf,"-unknown-unknown");
  2666. #else
  2667. sprintf(buf,"unknown");
  2668. #endif /* has SI_HW_PROVIDER */
  2669. #endif /* has SI_MACHINE */
  2670. #endif /* OSF */
  2671. #endif /* VMS */
  2672. #endif /* HPUX */
  2673. #endif /* FREEBSD */
  2674. #endif /* AIX */
  2675. #endif /* SUN */
  2676. #endif /* LINUX */
  2677. #endif /* WIN32 */
  2678. }
  2679. static int count_processors(void)
  2680. {
  2681. int nproc = 0;
  2682. #if defined(_SC_NPROCESSORS_ONLN) && !defined(__osf__)
  2683. nproc = sysconf(_SC_NPROCESSORS_ONLN);
  2684. #endif
  2685. #if defined(_WIN32)
  2686. SYSTEM_INFO sysinfo;
  2687. GetSystemInfo(&sysinfo);
  2688. nproc = sysinfo.dwNumberOfProcessors;
  2689. #endif
  2690. #if defined(IDDS_BSD_SYSCTL) && defined(__FreeBSD__)
  2691. int fblen = sizeof(int);
  2692. int tmp;
  2693. sysctlbyname("hw.ncpu",&nproc,&fblen,NULL,0);
  2694. #endif
  2695. #if defined(__osf__)
  2696. struct cpu_info cpu_info;
  2697. int start = 0;
  2698. cpu_info.cpus_in_box = 0;
  2699. getsysinfo(GSI_CPU_INFO,(caddr_t)&cpu_info,sizeof(struct cpu_info),&start,NULL);
  2700. nproc = cpu_info.cpus_in_box;
  2701. #endif
  2702. return nproc;
  2703. }
  2704. static void usage(char *av)
  2705. {
  2706. printf("usage: %s [-q] [-D] [-v] [-c] [-i installdir]\n",av);
  2707. printf(" -q dsktune only reports essential settings\n");
  2708. printf(" -c dsktune only reports tuning information for client machines\n");
  2709. printf(" -D dsktune also reports the commands executed\n");
  2710. printf(" -v dsktune only reports its release version date\n");
  2711. printf(" -i specify alternate server installation directory\n");
  2712. printf("\n");
  2713. exit(1);
  2714. }
  2715. static void print_version(void)
  2716. {
  2717. printf("%s\n",build_date);
  2718. exit(1);
  2719. }
  2720. int main(int argc,char *argv[])
  2721. {
  2722. int i;
  2723. #ifdef _WIN32
  2724. #else
  2725. while((i = getopt(argc,argv,"DvHqcCi:")) != EOF) {
  2726. switch(i) {
  2727. case 'D':
  2728. flag_debug = 1;
  2729. break;
  2730. case 'H':
  2731. flag_html = 1;
  2732. break;
  2733. case 'v':
  2734. print_version();
  2735. break;
  2736. case 'q':
  2737. flag_quick = 1;
  2738. break;
  2739. case 'c':
  2740. client = 1;
  2741. break;
  2742. case 'C':
  2743. flag_carrier = 1;
  2744. break;
  2745. case 'i':
  2746. strcpy(install_dir,optarg);
  2747. break;
  2748. default:
  2749. usage(argv[0]);
  2750. break;
  2751. }
  2752. }
  2753. #endif
  2754. #if defined(_AIX)
  2755. if (1) {
  2756. char *s = getenv("ODMPATH");
  2757. if (s == NULL) {
  2758. putenv("ODMPATH=/usr/lib/objrepos:/etc/objrepos");
  2759. }
  2760. }
  2761. #endif
  2762. if (flag_quick == 0) {
  2763. char sysbuf[BUFSIZ];
  2764. int nproc;
  2765. if (flag_html) printf("<P>\n");
  2766. printf("Netscape Directory Server system tuning analysis version %s.\n\n", build_date);
  2767. ids_get_platform(sysbuf);
  2768. nproc = count_processors();
  2769. if (nproc == 1) {
  2770. printf("NOTICE : System is %s (1 processor).\n\n",sysbuf);
  2771. } else if (nproc > 1) {
  2772. printf("NOTICE : System is %s (%d processors).\n\n",sysbuf,nproc);
  2773. } else {
  2774. printf("NOTICE : System is %s.\n\n",sysbuf);
  2775. }
  2776. if (flag_html) printf("</P>\n");
  2777. }
  2778. gen_tests();
  2779. #if defined(__sun) || defined(__hppa) || defined(IDDS_BSD_SYSCTL) || defined(IDDS_LINUX_SYSCTL)
  2780. ndd_tests();
  2781. #endif
  2782. #if defined(__hppa)
  2783. hp_pthreads_tests();
  2784. #endif
  2785. #if defined(__osf__)
  2786. sysconfig_tests();
  2787. #endif
  2788. limits_tests();
  2789. disk_tests();
  2790. if (flag_os_bad || flag_arch_bad) {
  2791. if (flag_html) printf("<P>\n");
  2792. printf("ERROR : The above errors MUST be corrected before proceeding.\n\n");
  2793. if (flag_html) printf("</P>\n");
  2794. exit(1);
  2795. }
  2796. exit(0);
  2797. return 0;
  2798. }