idsktune.c 90 KB

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