idsktune.c 90 KB

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