idsktune.c 85 KB

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