idsktune.c 92 KB

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