idsktune.c 90 KB

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