configure.ac 153 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682
  1. #
  2. # Copyright (c) 1999-2004 Damien Miller
  3. #
  4. # Permission to use, copy, modify, and distribute this software for any
  5. # purpose with or without fee is hereby granted, provided that the above
  6. # copyright notice and this permission notice appear in all copies.
  7. #
  8. # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. AC_INIT([OpenSSH], [Portable], [foreign], [openssh-unix-dev@mindrot.org])
  16. AC_CONFIG_MACRO_DIR([m4])
  17. AC_CONFIG_SRCDIR([ssh.c])
  18. AC_LANG([C])
  19. AC_CONFIG_HEADERS([config.h])
  20. AC_PROG_CC([cc gcc clang])
  21. # XXX relax this after reimplementing logit() etc.
  22. AC_MSG_CHECKING([if $CC supports C99-style variadic macros])
  23. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  24. int f(int a, int b, int c) { return a + b + c; }
  25. #define F(a, ...) f(a, __VA_ARGS__)
  26. ]], [[return F(1, 2, -3);]])],
  27. [ AC_MSG_RESULT([yes]) ],
  28. [ AC_MSG_ERROR([*** OpenSSH requires support for C99-style variadic macros]) ]
  29. )
  30. AC_CANONICAL_HOST
  31. AC_C_BIGENDIAN
  32. # Checks for programs.
  33. AC_PROG_AWK
  34. AC_PROG_CPP
  35. AC_PROG_RANLIB
  36. AC_PROG_INSTALL
  37. AC_PROG_EGREP
  38. AC_PROG_MKDIR_P
  39. AC_CHECK_TOOLS([AR], [ar])
  40. AC_PATH_PROG([CAT], [cat])
  41. AC_PATH_PROG([KILL], [kill])
  42. AC_PATH_PROG([SED], [sed])
  43. AC_PATH_PROG([TEST_MINUS_S_SH], [bash])
  44. AC_PATH_PROG([TEST_MINUS_S_SH], [ksh])
  45. AC_PATH_PROG([TEST_MINUS_S_SH], [sh])
  46. AC_PATH_PROG([SH], [sh])
  47. AC_PATH_PROG([GROFF], [groff])
  48. AC_PATH_PROG([NROFF], [nroff awf])
  49. AC_PATH_PROG([MANDOC], [mandoc])
  50. AC_SUBST([TEST_SHELL], [sh])
  51. dnl select manpage formatter to be used to build "cat" format pages.
  52. if test "x$MANDOC" != "x" ; then
  53. MANFMT="$MANDOC"
  54. elif test "x$NROFF" != "x" ; then
  55. MANFMT="$NROFF -mandoc"
  56. elif test "x$GROFF" != "x" ; then
  57. MANFMT="$GROFF -mandoc -Tascii"
  58. else
  59. AC_MSG_WARN([no manpage formatter found])
  60. MANFMT="false"
  61. fi
  62. AC_SUBST([MANFMT])
  63. dnl for buildpkg.sh
  64. AC_PATH_PROG([PATH_GROUPADD_PROG], [groupadd], [groupadd],
  65. [/usr/sbin${PATH_SEPARATOR}/etc])
  66. AC_PATH_PROG([PATH_USERADD_PROG], [useradd], [useradd],
  67. [/usr/sbin${PATH_SEPARATOR}/etc])
  68. AC_CHECK_PROG([MAKE_PACKAGE_SUPPORTED], [pkgmk], [yes], [no])
  69. if test -x /sbin/sh; then
  70. AC_SUBST([STARTUP_SCRIPT_SHELL], [/sbin/sh])
  71. else
  72. AC_SUBST([STARTUP_SCRIPT_SHELL], [/bin/sh])
  73. fi
  74. # System features
  75. AC_SYS_LARGEFILE
  76. if test -z "$AR" ; then
  77. AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
  78. fi
  79. AC_PATH_PROG([PATH_PASSWD_PROG], [passwd])
  80. if test ! -z "$PATH_PASSWD_PROG" ; then
  81. AC_DEFINE_UNQUOTED([_PATH_PASSWD_PROG], ["$PATH_PASSWD_PROG"],
  82. [Full path of your "passwd" program])
  83. fi
  84. dnl Since autoconf doesn't support it very well, we no longer allow users to
  85. dnl override LD, however keeping the hook here for now in case there's a use
  86. dnl use case we overlooked and someone needs to re-enable it. Unless a good
  87. dnl reason is found we'll be removing this in future.
  88. LD="$CC"
  89. AC_SUBST([LD])
  90. AC_C_INLINE
  91. AC_CHECK_DECL([LLONG_MAX], [have_llong_max=1], , [#include <limits.h>])
  92. AC_CHECK_DECL([LONG_LONG_MAX], [have_long_long_max=1], , [#include <limits.h>])
  93. AC_CHECK_DECL([SYSTR_POLICY_KILL], [have_systr_policy_kill=1], , [
  94. #include <sys/types.h>
  95. #include <sys/param.h>
  96. #include <dev/systrace.h>
  97. ])
  98. AC_CHECK_DECL([RLIMIT_NPROC],
  99. [AC_DEFINE([HAVE_RLIMIT_NPROC], [], [sys/resource.h has RLIMIT_NPROC])], , [
  100. #include <sys/types.h>
  101. #include <sys/resource.h>
  102. ])
  103. AC_CHECK_DECL([PR_SET_NO_NEW_PRIVS], [have_linux_no_new_privs=1], , [
  104. #include <sys/types.h>
  105. #include <linux/prctl.h>
  106. ])
  107. openssl=yes
  108. AC_ARG_WITH([openssl],
  109. [ --without-openssl Disable use of OpenSSL; use only limited internal crypto **EXPERIMENTAL** ],
  110. [ if test "x$withval" = "xno" ; then
  111. openssl=no
  112. fi
  113. ]
  114. )
  115. AC_MSG_CHECKING([whether OpenSSL will be used for cryptography])
  116. if test "x$openssl" = "xyes" ; then
  117. AC_MSG_RESULT([yes])
  118. AC_DEFINE_UNQUOTED([WITH_OPENSSL], [1], [use libcrypto for cryptography])
  119. else
  120. AC_MSG_RESULT([no])
  121. fi
  122. use_stack_protector=1
  123. use_toolchain_hardening=1
  124. AC_ARG_WITH([stackprotect],
  125. [ --without-stackprotect Don't use compiler's stack protection], [
  126. if test "x$withval" = "xno"; then
  127. use_stack_protector=0
  128. fi ])
  129. AC_ARG_WITH([hardening],
  130. [ --without-hardening Don't use toolchain hardening flags], [
  131. if test "x$withval" = "xno"; then
  132. use_toolchain_hardening=0
  133. fi ])
  134. # We use -Werror for the tests only so that we catch warnings like "this is
  135. # on by default" for things like -fPIE.
  136. AC_MSG_CHECKING([if $CC supports -Werror])
  137. saved_CFLAGS="$CFLAGS"
  138. CFLAGS="$CFLAGS -Werror"
  139. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])],
  140. [ AC_MSG_RESULT([yes])
  141. WERROR="-Werror"],
  142. [ AC_MSG_RESULT([no])
  143. WERROR="" ]
  144. )
  145. CFLAGS="$saved_CFLAGS"
  146. if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
  147. OSSH_CHECK_CFLAG_COMPILE([-pipe])
  148. OSSH_CHECK_CFLAG_COMPILE([-Wunknown-warning-option])
  149. OSSH_CHECK_CFLAG_COMPILE([-Wno-error=format-truncation])
  150. OSSH_CHECK_CFLAG_COMPILE([-Qunused-arguments])
  151. OSSH_CHECK_CFLAG_COMPILE([-Wall])
  152. OSSH_CHECK_CFLAG_COMPILE([-Wextra])
  153. OSSH_CHECK_CFLAG_COMPILE([-Wpointer-arith])
  154. OSSH_CHECK_CFLAG_COMPILE([-Wuninitialized])
  155. OSSH_CHECK_CFLAG_COMPILE([-Wsign-compare])
  156. OSSH_CHECK_CFLAG_COMPILE([-Wformat-security])
  157. OSSH_CHECK_CFLAG_COMPILE([-Wsizeof-pointer-memaccess])
  158. OSSH_CHECK_CFLAG_COMPILE([-Wpointer-sign], [-Wno-pointer-sign])
  159. OSSH_CHECK_CFLAG_COMPILE([-Wunused-parameter], [-Wno-unused-parameter])
  160. OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result])
  161. OSSH_CHECK_CFLAG_COMPILE([-Wimplicit-fallthrough])
  162. OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
  163. if test "x$use_toolchain_hardening" = "x1"; then
  164. OSSH_CHECK_CFLAG_COMPILE([-mretpoline]) # clang
  165. OSSH_CHECK_LDFLAG_LINK([-Wl,-z,retpolineplt])
  166. OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2])
  167. OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro])
  168. OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now])
  169. OSSH_CHECK_LDFLAG_LINK([-Wl,-z,noexecstack])
  170. # NB. -ftrapv expects certain support functions to be present in
  171. # the compiler library (libgcc or similar) to detect integer operations
  172. # that can overflow. We must check that the result of enabling it
  173. # actually links. The test program compiled/linked includes a number
  174. # of integer operations that should exercise this.
  175. OSSH_CHECK_CFLAG_LINK([-ftrapv])
  176. fi
  177. AC_MSG_CHECKING([gcc version])
  178. GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
  179. case $GCC_VER in
  180. 1.*) no_attrib_nonnull=1 ;;
  181. 2.8* | 2.9*)
  182. no_attrib_nonnull=1
  183. ;;
  184. 2.*) no_attrib_nonnull=1 ;;
  185. *) ;;
  186. esac
  187. AC_MSG_RESULT([$GCC_VER])
  188. AC_MSG_CHECKING([if $CC accepts -fno-builtin-memset])
  189. saved_CFLAGS="$CFLAGS"
  190. CFLAGS="$CFLAGS -fno-builtin-memset"
  191. AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <string.h> ]],
  192. [[ char b[10]; memset(b, 0, sizeof(b)); ]])],
  193. [ AC_MSG_RESULT([yes]) ],
  194. [ AC_MSG_RESULT([no])
  195. CFLAGS="$saved_CFLAGS" ]
  196. )
  197. # -fstack-protector-all doesn't always work for some GCC versions
  198. # and/or platforms, so we test if we can. If it's not supported
  199. # on a given platform gcc will emit a warning so we use -Werror.
  200. if test "x$use_stack_protector" = "x1"; then
  201. for t in -fstack-protector-strong -fstack-protector-all \
  202. -fstack-protector; do
  203. AC_MSG_CHECKING([if $CC supports $t])
  204. saved_CFLAGS="$CFLAGS"
  205. saved_LDFLAGS="$LDFLAGS"
  206. CFLAGS="$CFLAGS $t -Werror"
  207. LDFLAGS="$LDFLAGS $t -Werror"
  208. AC_LINK_IFELSE(
  209. [AC_LANG_PROGRAM([[
  210. #include <stdio.h>
  211. int func (int t) {char b[100]; snprintf(b,sizeof b,"%d",t); return t;}
  212. ]],
  213. [[
  214. char x[256];
  215. snprintf(x, sizeof(x), "XXX%d", func(1));
  216. ]])],
  217. [ AC_MSG_RESULT([yes])
  218. CFLAGS="$saved_CFLAGS $t"
  219. LDFLAGS="$saved_LDFLAGS $t"
  220. AC_MSG_CHECKING([if $t works])
  221. AC_RUN_IFELSE(
  222. [AC_LANG_PROGRAM([[
  223. #include <stdio.h>
  224. int func (int t) {char b[100]; snprintf(b,sizeof b,"%d",t); return t;}
  225. ]],
  226. [[
  227. char x[256];
  228. snprintf(x, sizeof(x), "XXX%d", func(1));
  229. ]])],
  230. [ AC_MSG_RESULT([yes])
  231. break ],
  232. [ AC_MSG_RESULT([no]) ],
  233. [ AC_MSG_WARN([cross compiling: cannot test])
  234. break ]
  235. )
  236. ],
  237. [ AC_MSG_RESULT([no]) ]
  238. )
  239. CFLAGS="$saved_CFLAGS"
  240. LDFLAGS="$saved_LDFLAGS"
  241. done
  242. fi
  243. if test -z "$have_llong_max"; then
  244. # retry LLONG_MAX with -std=gnu99, needed on some Linuxes
  245. unset ac_cv_have_decl_LLONG_MAX
  246. saved_CFLAGS="$CFLAGS"
  247. CFLAGS="$CFLAGS -std=gnu99"
  248. AC_CHECK_DECL([LLONG_MAX],
  249. [have_llong_max=1],
  250. [CFLAGS="$saved_CFLAGS"],
  251. [#include <limits.h>]
  252. )
  253. fi
  254. fi
  255. AC_MSG_CHECKING([if compiler allows __attribute__ on return types])
  256. AC_COMPILE_IFELSE(
  257. [AC_LANG_PROGRAM([[
  258. #include <stdlib.h>
  259. __attribute__((__unused__)) static void foo(void){return;}]],
  260. [[ exit(0); ]])],
  261. [ AC_MSG_RESULT([yes]) ],
  262. [ AC_MSG_RESULT([no])
  263. AC_DEFINE(NO_ATTRIBUTE_ON_RETURN_TYPE, 1,
  264. [compiler does not accept __attribute__ on return types]) ]
  265. )
  266. AC_MSG_CHECKING([if compiler allows __attribute__ prototype args])
  267. AC_COMPILE_IFELSE(
  268. [AC_LANG_PROGRAM([[
  269. #include <stdlib.h>
  270. typedef void foo(const char *, ...) __attribute__((format(printf, 1, 2)));]],
  271. [[ exit(0); ]])],
  272. [ AC_MSG_RESULT([yes]) ],
  273. [ AC_MSG_RESULT([no])
  274. AC_DEFINE(NO_ATTRIBUTE_ON_PROTOTYPE_ARGS, 1,
  275. [compiler does not accept __attribute__ on prototype args]) ]
  276. )
  277. AC_MSG_CHECKING([if compiler supports variable length arrays])
  278. AC_COMPILE_IFELSE(
  279. [AC_LANG_PROGRAM([[#include <stdlib.h>]],
  280. [[ int i; for (i=0; i<3; i++){int a[i]; a[i-1]=0;} exit(0); ]])],
  281. [ AC_MSG_RESULT([yes])
  282. AC_DEFINE(VARIABLE_LENGTH_ARRAYS, [1],
  283. [compiler supports variable length arrays]) ],
  284. [ AC_MSG_RESULT([no]) ]
  285. )
  286. if test "x$no_attrib_nonnull" != "x1" ; then
  287. AC_DEFINE([HAVE_ATTRIBUTE__NONNULL__], [1], [Have attribute nonnull])
  288. fi
  289. AC_ARG_WITH([rpath],
  290. [ --without-rpath Disable auto-added -R linker paths],
  291. [
  292. if test "x$withval" = "xno" ; then
  293. rpath_opt=""
  294. elif test "x$withval" = "xyes" ; then
  295. rpath_opt="-R"
  296. else
  297. rpath_opt="$withval"
  298. fi
  299. ]
  300. )
  301. # Allow user to specify flags
  302. AC_ARG_WITH([cflags],
  303. [ --with-cflags Specify additional flags to pass to compiler],
  304. [
  305. if test -n "$withval" && test "x$withval" != "xno" && \
  306. test "x${withval}" != "xyes"; then
  307. CFLAGS="$CFLAGS $withval"
  308. fi
  309. ]
  310. )
  311. AC_ARG_WITH([cflags-after],
  312. [ --with-cflags-after Specify additional flags to pass to compiler after configure],
  313. [
  314. if test -n "$withval" && test "x$withval" != "xno" && \
  315. test "x${withval}" != "xyes"; then
  316. CFLAGS_AFTER="$withval"
  317. fi
  318. ]
  319. )
  320. AC_ARG_WITH([cppflags],
  321. [ --with-cppflags Specify additional flags to pass to preprocessor] ,
  322. [
  323. if test -n "$withval" && test "x$withval" != "xno" && \
  324. test "x${withval}" != "xyes"; then
  325. CPPFLAGS="$CPPFLAGS $withval"
  326. fi
  327. ]
  328. )
  329. AC_ARG_WITH([ldflags],
  330. [ --with-ldflags Specify additional flags to pass to linker],
  331. [
  332. if test -n "$withval" && test "x$withval" != "xno" && \
  333. test "x${withval}" != "xyes"; then
  334. LDFLAGS="$LDFLAGS $withval"
  335. fi
  336. ]
  337. )
  338. AC_ARG_WITH([ldflags-after],
  339. [ --with-ldflags-after Specify additional flags to pass to linker after configure],
  340. [
  341. if test -n "$withval" && test "x$withval" != "xno" && \
  342. test "x${withval}" != "xyes"; then
  343. LDFLAGS_AFTER="$withval"
  344. fi
  345. ]
  346. )
  347. AC_ARG_WITH([libs],
  348. [ --with-libs Specify additional libraries to link with],
  349. [
  350. if test -n "$withval" && test "x$withval" != "xno" && \
  351. test "x${withval}" != "xyes"; then
  352. LIBS="$LIBS $withval"
  353. fi
  354. ]
  355. )
  356. AC_ARG_WITH([Werror],
  357. [ --with-Werror Build main code with -Werror],
  358. [
  359. if test -n "$withval" && test "x$withval" != "xno"; then
  360. werror_flags="-Werror"
  361. if test "x${withval}" != "xyes"; then
  362. werror_flags="$withval"
  363. fi
  364. fi
  365. ]
  366. )
  367. AC_CHECK_HEADERS([ \
  368. blf.h \
  369. bstring.h \
  370. crypt.h \
  371. crypto/sha2.h \
  372. dirent.h \
  373. endian.h \
  374. elf.h \
  375. err.h \
  376. features.h \
  377. fcntl.h \
  378. floatingpoint.h \
  379. fnmatch.h \
  380. getopt.h \
  381. glob.h \
  382. ia.h \
  383. iaf.h \
  384. ifaddrs.h \
  385. inttypes.h \
  386. langinfo.h \
  387. limits.h \
  388. locale.h \
  389. login.h \
  390. maillock.h \
  391. ndir.h \
  392. net/if_tun.h \
  393. netdb.h \
  394. netgroup.h \
  395. pam/pam_appl.h \
  396. paths.h \
  397. poll.h \
  398. pty.h \
  399. readpassphrase.h \
  400. rpc/types.h \
  401. security/pam_appl.h \
  402. sha2.h \
  403. shadow.h \
  404. stddef.h \
  405. stdint.h \
  406. string.h \
  407. strings.h \
  408. sys/bitypes.h \
  409. sys/byteorder.h \
  410. sys/bsdtty.h \
  411. sys/cdefs.h \
  412. sys/dir.h \
  413. sys/file.h \
  414. sys/mman.h \
  415. sys/label.h \
  416. sys/ndir.h \
  417. sys/poll.h \
  418. sys/prctl.h \
  419. sys/pstat.h \
  420. sys/ptrace.h \
  421. sys/random.h \
  422. sys/select.h \
  423. sys/stat.h \
  424. sys/stream.h \
  425. sys/stropts.h \
  426. sys/strtio.h \
  427. sys/statvfs.h \
  428. sys/sysmacros.h \
  429. sys/time.h \
  430. sys/timers.h \
  431. sys/vfs.h \
  432. time.h \
  433. tmpdir.h \
  434. ttyent.h \
  435. ucred.h \
  436. unistd.h \
  437. usersec.h \
  438. util.h \
  439. utime.h \
  440. utmp.h \
  441. utmpx.h \
  442. vis.h \
  443. wchar.h \
  444. ])
  445. # On some platforms (eg SunOS4) sys/audit.h requires sys/[time|types|label.h]
  446. # to be included first.
  447. AC_CHECK_HEADERS([sys/audit.h], [], [], [
  448. #ifdef HAVE_SYS_TIME_H
  449. # include <sys/time.h>
  450. #endif
  451. #ifdef HAVE_SYS_TYPES_H
  452. # include <sys/types.h>
  453. #endif
  454. #ifdef HAVE_SYS_LABEL_H
  455. # include <sys/label.h>
  456. #endif
  457. ])
  458. # sys/capsicum.h requires sys/types.h
  459. AC_CHECK_HEADERS([sys/capsicum.h], [], [], [
  460. #ifdef HAVE_SYS_TYPES_H
  461. # include <sys/types.h>
  462. #endif
  463. ])
  464. # net/route.h requires sys/socket.h and sys/types.h.
  465. # sys/sysctl.h also requires sys/param.h
  466. AC_CHECK_HEADERS([net/route.h sys/sysctl.h], [], [], [
  467. #ifdef HAVE_SYS_TYPES_H
  468. # include <sys/types.h>
  469. #endif
  470. #include <sys/param.h>
  471. #include <sys/socket.h>
  472. ])
  473. # lastlog.h requires sys/time.h to be included first on Solaris
  474. AC_CHECK_HEADERS([lastlog.h], [], [], [
  475. #ifdef HAVE_SYS_TIME_H
  476. # include <sys/time.h>
  477. #endif
  478. ])
  479. # sys/ptms.h requires sys/stream.h to be included first on Solaris
  480. AC_CHECK_HEADERS([sys/ptms.h], [], [], [
  481. #ifdef HAVE_SYS_STREAM_H
  482. # include <sys/stream.h>
  483. #endif
  484. ])
  485. # login_cap.h requires sys/types.h on NetBSD
  486. AC_CHECK_HEADERS([login_cap.h], [], [], [
  487. #include <sys/types.h>
  488. ])
  489. # older BSDs need sys/param.h before sys/mount.h
  490. AC_CHECK_HEADERS([sys/mount.h], [], [], [
  491. #include <sys/param.h>
  492. ])
  493. # Android requires sys/socket.h to be included before sys/un.h
  494. AC_CHECK_HEADERS([sys/un.h], [], [], [
  495. #include <sys/types.h>
  496. #include <sys/socket.h>
  497. ])
  498. # Messages for features tested for in target-specific section
  499. SIA_MSG="no"
  500. SPC_MSG="no"
  501. SP_MSG="no"
  502. SPP_MSG="no"
  503. # Support for Solaris/Illumos privileges (this test is used by both
  504. # the --with-solaris-privs option and --with-sandbox=solaris).
  505. SOLARIS_PRIVS="no"
  506. # Check for some target-specific stuff
  507. case "$host" in
  508. *-*-aix*)
  509. # Some versions of VAC won't allow macro redefinitions at
  510. # -qlanglevel=ansi, and autoconf 2.60 sometimes insists on using that
  511. # particularly with older versions of vac or xlc.
  512. # It also throws errors about null macro arguments, but these are
  513. # not fatal.
  514. AC_MSG_CHECKING([if compiler allows macro redefinitions])
  515. AC_COMPILE_IFELSE(
  516. [AC_LANG_PROGRAM([[
  517. #define testmacro foo
  518. #define testmacro bar]],
  519. [[ exit(0); ]])],
  520. [ AC_MSG_RESULT([yes]) ],
  521. [ AC_MSG_RESULT([no])
  522. CC="`echo $CC | sed 's/-qlanglvl\=ansi//g'`"
  523. CFLAGS="`echo $CFLAGS | sed 's/-qlanglvl\=ansi//g'`"
  524. CPPFLAGS="`echo $CPPFLAGS | sed 's/-qlanglvl\=ansi//g'`"
  525. ]
  526. )
  527. AC_MSG_CHECKING([how to specify blibpath for linker ($LD)])
  528. if (test -z "$blibpath"); then
  529. blibpath="/usr/lib:/lib"
  530. fi
  531. saved_LDFLAGS="$LDFLAGS"
  532. if test "$GCC" = "yes"; then
  533. flags="-Wl,-blibpath: -Wl,-rpath, -blibpath:"
  534. else
  535. flags="-blibpath: -Wl,-blibpath: -Wl,-rpath,"
  536. fi
  537. for tryflags in $flags ;do
  538. if (test -z "$blibflags"); then
  539. LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
  540. AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
  541. [blibflags=$tryflags], [])
  542. fi
  543. done
  544. if (test -z "$blibflags"); then
  545. AC_MSG_RESULT([not found])
  546. AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
  547. else
  548. AC_MSG_RESULT([$blibflags])
  549. fi
  550. LDFLAGS="$saved_LDFLAGS"
  551. dnl Check for authenticate. Might be in libs.a on older AIXes
  552. AC_CHECK_FUNC([authenticate], [AC_DEFINE([WITH_AIXAUTHENTICATE], [1],
  553. [Define if you want to enable AIX4's authenticate function])],
  554. [AC_CHECK_LIB([s], [authenticate],
  555. [ AC_DEFINE([WITH_AIXAUTHENTICATE])
  556. LIBS="$LIBS -ls"
  557. ])
  558. ])
  559. dnl Check for various auth function declarations in headers.
  560. AC_CHECK_DECLS([authenticate, loginrestrictions, loginsuccess,
  561. passwdexpired, setauthdb], , , [#include <usersec.h>])
  562. dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
  563. AC_CHECK_DECLS([loginfailed],
  564. [AC_MSG_CHECKING([if loginfailed takes 4 arguments])
  565. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <usersec.h> ]],
  566. [[ (void)loginfailed("user","host","tty",0); ]])],
  567. [AC_MSG_RESULT([yes])
  568. AC_DEFINE([AIX_LOGINFAILED_4ARG], [1],
  569. [Define if your AIX loginfailed() function
  570. takes 4 arguments (AIX >= 5.2)])], [AC_MSG_RESULT([no])
  571. ])],
  572. [],
  573. [#include <usersec.h>]
  574. )
  575. AC_CHECK_FUNCS([getgrset setauthdb])
  576. AC_CHECK_DECL([F_CLOSEM],
  577. AC_DEFINE([HAVE_FCNTL_CLOSEM], [1], [Use F_CLOSEM fcntl for closefrom]),
  578. [],
  579. [ #include <limits.h>
  580. #include <fcntl.h> ]
  581. )
  582. check_for_aix_broken_getaddrinfo=1
  583. AC_DEFINE([SETEUID_BREAKS_SETUID], [1],
  584. [Define if your platform breaks doing a seteuid before a setuid])
  585. AC_DEFINE([BROKEN_SETREUID], [1], [Define if your setreuid() is broken])
  586. AC_DEFINE([BROKEN_SETREGID], [1], [Define if your setregid() is broken])
  587. dnl AIX handles lastlog as part of its login message
  588. AC_DEFINE([DISABLE_LASTLOG], [1], [Define if you don't want to use lastlog])
  589. AC_DEFINE([LOGIN_NEEDS_UTMPX], [1],
  590. [Some systems need a utmpx entry for /bin/login to work])
  591. AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
  592. [Define to a Set Process Title type if your system is
  593. supported by bsd-setproctitle.c])
  594. AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
  595. [AIX 5.2 and 5.3 (and presumably newer) require this])
  596. AC_DEFINE([PTY_ZEROREAD], [1], [read(1) can return 0 for a non-closed fd])
  597. AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
  598. AC_DEFINE([BROKEN_STRNDUP], 1, [strndup broken, see APAR IY61211])
  599. AC_DEFINE([BROKEN_STRNLEN], 1, [strnlen broken, see APAR IY62551])
  600. ;;
  601. *-*-android*)
  602. AC_DEFINE([DISABLE_UTMP], [1], [Define if you don't want to use utmp])
  603. AC_DEFINE([DISABLE_WTMP], [1], [Define if you don't want to use wtmp])
  604. ;;
  605. *-*-cygwin*)
  606. check_for_libcrypt_later=1
  607. LIBS="$LIBS /usr/lib/textreadmode.o"
  608. AC_DEFINE([HAVE_CYGWIN], [1], [Define if you are on Cygwin])
  609. AC_DEFINE([USE_PIPES], [1], [Use PIPES instead of a socketpair()])
  610. AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
  611. [Define to disable UID restoration test])
  612. AC_DEFINE([DISABLE_SHADOW], [1],
  613. [Define if you want to disable shadow passwords])
  614. AC_DEFINE([NO_X11_UNIX_SOCKETS], [1],
  615. [Define if X11 doesn't support AF_UNIX sockets on that system])
  616. AC_DEFINE([DISABLE_FD_PASSING], [1],
  617. [Define if your platform needs to skip post auth
  618. file descriptor passing])
  619. AC_DEFINE([SSH_IOBUFSZ], [65535], [Windows is sensitive to read buffer size])
  620. AC_DEFINE([FILESYSTEM_NO_BACKSLASH], [1], [File names may not contain backslash characters])
  621. # Cygwin defines optargs, optargs as declspec(dllimport) for historical
  622. # reasons which cause compile warnings, so we disable those warnings.
  623. OSSH_CHECK_CFLAG_COMPILE([-Wno-attributes])
  624. ;;
  625. *-*-dgux*)
  626. AC_DEFINE([IP_TOS_IS_BROKEN], [1],
  627. [Define if your system choked on IP TOS setting])
  628. AC_DEFINE([SETEUID_BREAKS_SETUID])
  629. AC_DEFINE([BROKEN_SETREUID])
  630. AC_DEFINE([BROKEN_SETREGID])
  631. ;;
  632. *-*-darwin*)
  633. use_pie=auto
  634. AC_MSG_CHECKING([if we have working getaddrinfo])
  635. AC_RUN_IFELSE([AC_LANG_SOURCE([[
  636. #include <mach-o/dyld.h>
  637. #include <stdlib.h>
  638. main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
  639. exit(0);
  640. else
  641. exit(1);
  642. }
  643. ]])],
  644. [AC_MSG_RESULT([working])],
  645. [AC_MSG_RESULT([buggy])
  646. AC_DEFINE([BROKEN_GETADDRINFO], [1],
  647. [getaddrinfo is broken (if present)])
  648. ],
  649. [AC_MSG_RESULT([assume it is working])])
  650. AC_DEFINE([SETEUID_BREAKS_SETUID])
  651. AC_DEFINE([BROKEN_SETREUID])
  652. AC_DEFINE([BROKEN_SETREGID])
  653. AC_DEFINE([BROKEN_GLOB], [1], [OS X glob does not do what we expect])
  654. AC_DEFINE_UNQUOTED([BIND_8_COMPAT], [1],
  655. [Define if your resolver libs need this for getrrsetbyname])
  656. AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
  657. AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
  658. [Use tunnel device compatibility to OpenBSD])
  659. AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
  660. [Prepend the address family to IP tunnel traffic])
  661. m4_pattern_allow([AU_IPv])
  662. AC_CHECK_DECL([AU_IPv4], [],
  663. AC_DEFINE([AU_IPv4], [0], [System only supports IPv4 audit records])
  664. [#include <bsm/audit.h>]
  665. AC_DEFINE([LASTLOG_WRITE_PUTUTXLINE], [1],
  666. [Define if pututxline updates lastlog too])
  667. )
  668. AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
  669. [Define to a Set Process Title type if your system is
  670. supported by bsd-setproctitle.c])
  671. AC_CHECK_FUNCS([sandbox_init])
  672. AC_CHECK_HEADERS([sandbox.h])
  673. AC_CHECK_LIB([sandbox], [sandbox_apply], [
  674. SSHDLIBS="$SSHDLIBS -lsandbox"
  675. ])
  676. # proc_pidinfo()-based closefrom() replacement.
  677. AC_CHECK_HEADERS([libproc.h])
  678. AC_CHECK_FUNCS([proc_pidinfo])
  679. ;;
  680. *-*-dragonfly*)
  681. SSHDLIBS="$SSHDLIBS -lcrypt"
  682. TEST_MALLOC_OPTIONS="AFGJPRX"
  683. ;;
  684. *-*-haiku*)
  685. LIBS="$LIBS -lbsd "
  686. CFLAGS="$CFLAGS -D_BSD_SOURCE"
  687. AC_CHECK_LIB([network], [socket])
  688. AC_DEFINE([HAVE_U_INT64_T])
  689. AC_DEFINE([DISABLE_UTMPX], [1], [no utmpx])
  690. MANTYPE=man
  691. ;;
  692. *-*-hpux*)
  693. # first we define all of the options common to all HP-UX releases
  694. CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
  695. IPADDR_IN_DISPLAY=yes
  696. AC_DEFINE([USE_PIPES])
  697. AC_DEFINE([LOGIN_NEEDS_UTMPX])
  698. AC_DEFINE([LOCKED_PASSWD_STRING], ["*"],
  699. [String used in /etc/passwd to denote locked account])
  700. AC_DEFINE([SPT_TYPE], [SPT_PSTAT])
  701. AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
  702. maildir="/var/mail"
  703. LIBS="$LIBS -lsec"
  704. AC_CHECK_LIB([xnet], [t_error], ,
  705. [AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])])
  706. # next, we define all of the options specific to major releases
  707. case "$host" in
  708. *-*-hpux10*)
  709. if test -z "$GCC"; then
  710. CFLAGS="$CFLAGS -Ae"
  711. fi
  712. ;;
  713. *-*-hpux11*)
  714. AC_DEFINE([PAM_SUN_CODEBASE], [1],
  715. [Define if you are using Solaris-derived PAM which
  716. passes pam_messages to the conversation function
  717. with an extra level of indirection])
  718. AC_DEFINE([DISABLE_UTMP], [1],
  719. [Define if you don't want to use utmp])
  720. AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
  721. check_for_hpux_broken_getaddrinfo=1
  722. check_for_conflicting_getspnam=1
  723. ;;
  724. esac
  725. # lastly, we define options specific to minor releases
  726. case "$host" in
  727. *-*-hpux10.26)
  728. AC_DEFINE([HAVE_SECUREWARE], [1],
  729. [Define if you have SecureWare-based
  730. protected password database])
  731. disable_ptmx_check=yes
  732. LIBS="$LIBS -lsecpw"
  733. ;;
  734. esac
  735. ;;
  736. *-*-irix5*)
  737. PATH="$PATH:/usr/etc"
  738. AC_DEFINE([BROKEN_INET_NTOA], [1],
  739. [Define if you system's inet_ntoa is busted
  740. (e.g. Irix gcc issue)])
  741. AC_DEFINE([SETEUID_BREAKS_SETUID])
  742. AC_DEFINE([BROKEN_SETREUID])
  743. AC_DEFINE([BROKEN_SETREGID])
  744. AC_DEFINE([WITH_ABBREV_NO_TTY], [1],
  745. [Define if you shouldn't strip 'tty' from your
  746. ttyname in [uw]tmp])
  747. AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
  748. ;;
  749. *-*-irix6*)
  750. PATH="$PATH:/usr/etc"
  751. AC_DEFINE([WITH_IRIX_ARRAY], [1],
  752. [Define if you have/want arrays
  753. (cluster-wide session management, not C arrays)])
  754. AC_DEFINE([WITH_IRIX_PROJECT], [1],
  755. [Define if you want IRIX project management])
  756. AC_DEFINE([WITH_IRIX_AUDIT], [1],
  757. [Define if you want IRIX audit trails])
  758. AC_CHECK_FUNC([jlimit_startjob], [AC_DEFINE([WITH_IRIX_JOBS], [1],
  759. [Define if you want IRIX kernel jobs])])
  760. AC_DEFINE([BROKEN_INET_NTOA])
  761. AC_DEFINE([SETEUID_BREAKS_SETUID])
  762. AC_DEFINE([BROKEN_SETREUID])
  763. AC_DEFINE([BROKEN_SETREGID])
  764. AC_DEFINE([BROKEN_UPDWTMPX], [1], [updwtmpx is broken (if present)])
  765. AC_DEFINE([WITH_ABBREV_NO_TTY])
  766. AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
  767. ;;
  768. *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
  769. check_for_libcrypt_later=1
  770. AC_DEFINE([PAM_TTY_KLUDGE])
  771. AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"])
  772. AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
  773. AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
  774. AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
  775. ;;
  776. *-*-linux*)
  777. no_dev_ptmx=1
  778. use_pie=auto
  779. check_for_libcrypt_later=1
  780. check_for_openpty_ctty_bug=1
  781. dnl Target SUSv3/POSIX.1-2001 plus BSD specifics.
  782. dnl _DEFAULT_SOURCE is the new name for _BSD_SOURCE
  783. CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE"
  784. AC_DEFINE([PAM_TTY_KLUDGE], [1],
  785. [Work around problematic Linux PAM modules handling of PAM_TTY])
  786. AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"],
  787. [String used in /etc/passwd to denote locked account])
  788. AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
  789. AC_DEFINE([LINK_OPNOTSUPP_ERRNO], [EPERM],
  790. [Define to whatever link() returns for "not supported"
  791. if it doesn't return EOPNOTSUPP.])
  792. AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
  793. AC_DEFINE([USE_BTMP])
  794. AC_DEFINE([LINUX_OOM_ADJUST], [1], [Adjust Linux out-of-memory killer])
  795. inet6_default_4in6=yes
  796. case `uname -r` in
  797. 1.*|2.0.*)
  798. AC_DEFINE([BROKEN_CMSG_TYPE], [1],
  799. [Define if cmsg_type is not passed correctly])
  800. ;;
  801. esac
  802. # tun(4) forwarding compat code
  803. AC_CHECK_HEADERS([linux/if_tun.h])
  804. if test "x$ac_cv_header_linux_if_tun_h" = "xyes" ; then
  805. AC_DEFINE([SSH_TUN_LINUX], [1],
  806. [Open tunnel devices the Linux tun/tap way])
  807. AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
  808. [Use tunnel device compatibility to OpenBSD])
  809. AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
  810. [Prepend the address family to IP tunnel traffic])
  811. fi
  812. AC_CHECK_HEADER([linux/if.h],
  813. AC_DEFINE([SYS_RDOMAIN_LINUX], [1],
  814. [Support routing domains using Linux VRF]), [], [
  815. #ifdef HAVE_SYS_TYPES_H
  816. # include <sys/types.h>
  817. #endif
  818. ])
  819. AC_CHECK_HEADERS([linux/seccomp.h linux/filter.h linux/audit.h], [],
  820. [], [#include <linux/types.h>])
  821. # Obtain MIPS ABI
  822. case "$host" in
  823. mips*)
  824. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  825. #if _MIPS_SIM != _ABIO32
  826. #error
  827. #endif
  828. ]])],[mips_abi="o32"],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  829. #if _MIPS_SIM != _ABIN32
  830. #error
  831. #endif
  832. ]])],[mips_abi="n32"],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  833. #if _MIPS_SIM != _ABI64
  834. #error
  835. #endif
  836. ]])],[mips_abi="n64"],[AC_MSG_ERROR([unknown MIPS ABI])
  837. ])
  838. ])
  839. ])
  840. ;;
  841. esac
  842. AC_MSG_CHECKING([for seccomp architecture])
  843. seccomp_audit_arch=
  844. case "$host" in
  845. x86_64-*)
  846. seccomp_audit_arch=AUDIT_ARCH_X86_64
  847. ;;
  848. i*86-*)
  849. seccomp_audit_arch=AUDIT_ARCH_I386
  850. ;;
  851. arm*-*)
  852. seccomp_audit_arch=AUDIT_ARCH_ARM
  853. ;;
  854. aarch64*-*)
  855. seccomp_audit_arch=AUDIT_ARCH_AARCH64
  856. ;;
  857. s390x-*)
  858. seccomp_audit_arch=AUDIT_ARCH_S390X
  859. ;;
  860. s390-*)
  861. seccomp_audit_arch=AUDIT_ARCH_S390
  862. ;;
  863. powerpc64-*)
  864. seccomp_audit_arch=AUDIT_ARCH_PPC64
  865. ;;
  866. powerpc64le-*)
  867. seccomp_audit_arch=AUDIT_ARCH_PPC64LE
  868. ;;
  869. mips-*)
  870. seccomp_audit_arch=AUDIT_ARCH_MIPS
  871. ;;
  872. mipsel-*)
  873. seccomp_audit_arch=AUDIT_ARCH_MIPSEL
  874. ;;
  875. mips64-*)
  876. case "$mips_abi" in
  877. "n32")
  878. seccomp_audit_arch=AUDIT_ARCH_MIPS64N32
  879. ;;
  880. "n64")
  881. seccomp_audit_arch=AUDIT_ARCH_MIPS64
  882. ;;
  883. esac
  884. ;;
  885. mips64el-*)
  886. case "$mips_abi" in
  887. "n32")
  888. seccomp_audit_arch=AUDIT_ARCH_MIPSEL64N32
  889. ;;
  890. "n64")
  891. seccomp_audit_arch=AUDIT_ARCH_MIPSEL64
  892. ;;
  893. esac
  894. ;;
  895. riscv64-*)
  896. seccomp_audit_arch=AUDIT_ARCH_RISCV64
  897. ;;
  898. esac
  899. if test "x$seccomp_audit_arch" != "x" ; then
  900. AC_MSG_RESULT(["$seccomp_audit_arch"])
  901. AC_DEFINE_UNQUOTED([SECCOMP_AUDIT_ARCH], [$seccomp_audit_arch],
  902. [Specify the system call convention in use])
  903. else
  904. AC_MSG_RESULT([architecture not supported])
  905. fi
  906. ;;
  907. mips-sony-bsd|mips-sony-newsos4)
  908. AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to acquire controlling tty])
  909. SONY=1
  910. ;;
  911. *-*-netbsd*)
  912. check_for_libcrypt_before=1
  913. if test "x$withval" != "xno" ; then
  914. rpath_opt="-R"
  915. fi
  916. CPPFLAGS="$CPPFLAGS -D_OPENBSD_SOURCE"
  917. AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
  918. AC_CHECK_HEADER([net/if_tap.h], ,
  919. AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
  920. AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
  921. [Prepend the address family to IP tunnel traffic])
  922. TEST_MALLOC_OPTIONS="AJRX"
  923. AC_DEFINE([BROKEN_READ_COMPARISON], [1],
  924. [NetBSD read function is sometimes redirected, breaking atomicio comparisons against it])
  925. ;;
  926. *-*-freebsd*)
  927. check_for_libcrypt_later=1
  928. AC_DEFINE([LOCKED_PASSWD_PREFIX], ["*LOCKED*"], [Account locked with pw(1)])
  929. AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
  930. AC_CHECK_HEADER([net/if_tap.h], ,
  931. AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
  932. AC_DEFINE([BROKEN_GLOB], [1], [FreeBSD glob does not do what we need])
  933. TEST_MALLOC_OPTIONS="AJRX"
  934. # Preauth crypto occasionally uses file descriptors for crypto offload
  935. # and will crash if they cannot be opened.
  936. AC_DEFINE([SANDBOX_SKIP_RLIMIT_NOFILE], [1],
  937. [define if setrlimit RLIMIT_NOFILE breaks things])
  938. ;;
  939. *-*-bsdi*)
  940. AC_DEFINE([SETEUID_BREAKS_SETUID])
  941. AC_DEFINE([BROKEN_SETREUID])
  942. AC_DEFINE([BROKEN_SETREGID])
  943. ;;
  944. *-next-*)
  945. conf_lastlog_location="/usr/adm/lastlog"
  946. conf_utmp_location=/etc/utmp
  947. conf_wtmp_location=/usr/adm/wtmp
  948. maildir=/usr/spool/mail
  949. AC_DEFINE([HAVE_NEXT], [1], [Define if you are on NeXT])
  950. AC_DEFINE([USE_PIPES])
  951. AC_DEFINE([BROKEN_SAVED_UIDS], [1], [Needed for NeXT])
  952. ;;
  953. *-*-openbsd*)
  954. use_pie=auto
  955. AC_DEFINE([HAVE_ATTRIBUTE__SENTINEL__], [1], [OpenBSD's gcc has sentinel])
  956. AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD's gcc has bounded])
  957. AC_DEFINE([SSH_TUN_OPENBSD], [1], [Open tunnel devices the OpenBSD way])
  958. AC_DEFINE([SYSLOG_R_SAFE_IN_SIGHAND], [1],
  959. [syslog_r function is safe to use in in a signal handler])
  960. TEST_MALLOC_OPTIONS="AFGJPRX"
  961. ;;
  962. *-*-solaris*)
  963. if test "x$withval" != "xno" ; then
  964. rpath_opt="-R"
  965. fi
  966. AC_DEFINE([PAM_SUN_CODEBASE])
  967. AC_DEFINE([LOGIN_NEEDS_UTMPX])
  968. AC_DEFINE([PAM_TTY_KLUDGE])
  969. AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
  970. [Define if pam_chauthtok wants real uid set
  971. to the unpriv'ed user])
  972. AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
  973. # Pushing STREAMS modules will cause sshd to acquire a controlling tty.
  974. AC_DEFINE([SSHD_ACQUIRES_CTTY], [1],
  975. [Define if sshd somehow reacquires a controlling TTY
  976. after setsid()])
  977. AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd
  978. in case the name is longer than 8 chars])
  979. AC_DEFINE([BROKEN_TCGETATTR_ICANON], [1], [tcgetattr with ICANON may hang])
  980. external_path_file=/etc/default/login
  981. # hardwire lastlog location (can't detect it on some versions)
  982. conf_lastlog_location="/var/adm/lastlog"
  983. AC_MSG_CHECKING([for obsolete utmp and wtmp in solaris2.x])
  984. sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
  985. if test "$sol2ver" -ge 8; then
  986. AC_MSG_RESULT([yes])
  987. AC_DEFINE([DISABLE_UTMP])
  988. AC_DEFINE([DISABLE_WTMP], [1],
  989. [Define if you don't want to use wtmp])
  990. else
  991. AC_MSG_RESULT([no])
  992. fi
  993. AC_CHECK_FUNCS([setpflags])
  994. AC_CHECK_FUNCS([setppriv])
  995. AC_CHECK_FUNCS([priv_basicset])
  996. AC_CHECK_HEADERS([priv.h])
  997. AC_ARG_WITH([solaris-contracts],
  998. [ --with-solaris-contracts Enable Solaris process contracts (experimental)],
  999. [
  1000. AC_CHECK_LIB([contract], [ct_tmpl_activate],
  1001. [ AC_DEFINE([USE_SOLARIS_PROCESS_CONTRACTS], [1],
  1002. [Define if you have Solaris process contracts])
  1003. LIBS="$LIBS -lcontract"
  1004. SPC_MSG="yes" ], )
  1005. ],
  1006. )
  1007. AC_ARG_WITH([solaris-projects],
  1008. [ --with-solaris-projects Enable Solaris projects (experimental)],
  1009. [
  1010. AC_CHECK_LIB([project], [setproject],
  1011. [ AC_DEFINE([USE_SOLARIS_PROJECTS], [1],
  1012. [Define if you have Solaris projects])
  1013. LIBS="$LIBS -lproject"
  1014. SP_MSG="yes" ], )
  1015. ],
  1016. )
  1017. AC_ARG_WITH([solaris-privs],
  1018. [ --with-solaris-privs Enable Solaris/Illumos privileges (experimental)],
  1019. [
  1020. AC_MSG_CHECKING([for Solaris/Illumos privilege support])
  1021. if test "x$ac_cv_func_setppriv" = "xyes" -a \
  1022. "x$ac_cv_header_priv_h" = "xyes" ; then
  1023. SOLARIS_PRIVS=yes
  1024. AC_MSG_RESULT([found])
  1025. AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
  1026. [Define to disable UID restoration test])
  1027. AC_DEFINE([USE_SOLARIS_PRIVS], [1],
  1028. [Define if you have Solaris privileges])
  1029. SPP_MSG="yes"
  1030. else
  1031. AC_MSG_RESULT([not found])
  1032. AC_MSG_ERROR([*** must have support for Solaris privileges to use --with-solaris-privs])
  1033. fi
  1034. ],
  1035. )
  1036. TEST_SHELL=$SHELL # let configure find us a capable shell
  1037. ;;
  1038. *-*-sunos4*)
  1039. CPPFLAGS="$CPPFLAGS -DSUNOS4"
  1040. AC_CHECK_FUNCS([getpwanam])
  1041. AC_DEFINE([PAM_SUN_CODEBASE])
  1042. conf_utmp_location=/etc/utmp
  1043. conf_wtmp_location=/var/adm/wtmp
  1044. conf_lastlog_location=/var/adm/lastlog
  1045. AC_DEFINE([USE_PIPES])
  1046. AC_DEFINE([DISABLE_UTMPX], [1], [no utmpx])
  1047. ;;
  1048. *-ncr-sysv*)
  1049. LIBS="$LIBS -lc89"
  1050. AC_DEFINE([USE_PIPES])
  1051. AC_DEFINE([SSHD_ACQUIRES_CTTY])
  1052. AC_DEFINE([SETEUID_BREAKS_SETUID])
  1053. AC_DEFINE([BROKEN_SETREUID])
  1054. AC_DEFINE([BROKEN_SETREGID])
  1055. ;;
  1056. *-sni-sysv*)
  1057. # /usr/ucblib MUST NOT be searched on ReliantUNIX
  1058. AC_CHECK_LIB([dl], [dlsym], ,)
  1059. # -lresolv needs to be at the end of LIBS or DNS lookups break
  1060. AC_CHECK_LIB([resolv], [res_query], [ LIBS="$LIBS -lresolv" ])
  1061. IPADDR_IN_DISPLAY=yes
  1062. AC_DEFINE([USE_PIPES])
  1063. AC_DEFINE([IP_TOS_IS_BROKEN])
  1064. AC_DEFINE([SETEUID_BREAKS_SETUID])
  1065. AC_DEFINE([BROKEN_SETREUID])
  1066. AC_DEFINE([BROKEN_SETREGID])
  1067. AC_DEFINE([SSHD_ACQUIRES_CTTY])
  1068. external_path_file=/etc/default/login
  1069. # /usr/ucblib/libucb.a no longer needed on ReliantUNIX
  1070. # Attention: always take care to bind libsocket and libnsl before libc,
  1071. # otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
  1072. ;;
  1073. # UnixWare 1.x, UnixWare 2.x, and others based on code from Univel.
  1074. *-*-sysv4.2*)
  1075. AC_DEFINE([USE_PIPES])
  1076. AC_DEFINE([SETEUID_BREAKS_SETUID])
  1077. AC_DEFINE([BROKEN_SETREUID])
  1078. AC_DEFINE([BROKEN_SETREGID])
  1079. AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd])
  1080. AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
  1081. TEST_SHELL=$SHELL # let configure find us a capable shell
  1082. ;;
  1083. # UnixWare 7.x, OpenUNIX 8
  1084. *-*-sysv5*)
  1085. CPPFLAGS="$CPPFLAGS -Dvsnprintf=_xvsnprintf -Dsnprintf=_xsnprintf"
  1086. AC_DEFINE([UNIXWARE_LONG_PASSWORDS], [1], [Support passwords > 8 chars])
  1087. AC_DEFINE([USE_PIPES])
  1088. AC_DEFINE([SETEUID_BREAKS_SETUID])
  1089. AC_DEFINE([BROKEN_GETADDRINFO])
  1090. AC_DEFINE([BROKEN_SETREUID])
  1091. AC_DEFINE([BROKEN_SETREGID])
  1092. AC_DEFINE([PASSWD_NEEDS_USERNAME])
  1093. AC_DEFINE([BROKEN_TCGETATTR_ICANON])
  1094. TEST_SHELL=$SHELL # let configure find us a capable shell
  1095. check_for_libcrypt_later=1
  1096. case "$host" in
  1097. *-*-sysv5SCO_SV*) # SCO OpenServer 6.x
  1098. maildir=/var/spool/mail
  1099. AC_DEFINE([BROKEN_UPDWTMPX])
  1100. AC_CHECK_LIB([prot], [getluid], [ LIBS="$LIBS -lprot"
  1101. AC_CHECK_FUNCS([getluid setluid], , , [-lprot])
  1102. ], , )
  1103. ;;
  1104. *) AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
  1105. ;;
  1106. esac
  1107. ;;
  1108. *-*-sysv*)
  1109. ;;
  1110. # SCO UNIX and OEM versions of SCO UNIX
  1111. *-*-sco3.2v4*)
  1112. AC_MSG_ERROR("This Platform is no longer supported.")
  1113. ;;
  1114. # SCO OpenServer 5.x
  1115. *-*-sco3.2v5*)
  1116. if test -z "$GCC"; then
  1117. CFLAGS="$CFLAGS -belf"
  1118. fi
  1119. LIBS="$LIBS -lprot -lx -ltinfo -lm"
  1120. no_dev_ptmx=1
  1121. AC_DEFINE([USE_PIPES])
  1122. AC_DEFINE([HAVE_SECUREWARE])
  1123. AC_DEFINE([DISABLE_SHADOW])
  1124. AC_DEFINE([DISABLE_FD_PASSING])
  1125. AC_DEFINE([SETEUID_BREAKS_SETUID])
  1126. AC_DEFINE([BROKEN_GETADDRINFO])
  1127. AC_DEFINE([BROKEN_SETREUID])
  1128. AC_DEFINE([BROKEN_SETREGID])
  1129. AC_DEFINE([WITH_ABBREV_NO_TTY])
  1130. AC_DEFINE([BROKEN_UPDWTMPX])
  1131. AC_DEFINE([PASSWD_NEEDS_USERNAME])
  1132. AC_CHECK_FUNCS([getluid setluid])
  1133. MANTYPE=man
  1134. TEST_SHELL=$SHELL # let configure find us a capable shell
  1135. SKIP_DISABLE_LASTLOG_DEFINE=yes
  1136. ;;
  1137. *-dec-osf*)
  1138. AC_MSG_CHECKING([for Digital Unix SIA])
  1139. no_osfsia=""
  1140. AC_ARG_WITH([osfsia],
  1141. [ --with-osfsia Enable Digital Unix SIA],
  1142. [
  1143. if test "x$withval" = "xno" ; then
  1144. AC_MSG_RESULT([disabled])
  1145. no_osfsia=1
  1146. fi
  1147. ],
  1148. )
  1149. if test -z "$no_osfsia" ; then
  1150. if test -f /etc/sia/matrix.conf; then
  1151. AC_MSG_RESULT([yes])
  1152. AC_DEFINE([HAVE_OSF_SIA], [1],
  1153. [Define if you have Digital Unix Security
  1154. Integration Architecture])
  1155. AC_DEFINE([DISABLE_LOGIN], [1],
  1156. [Define if you don't want to use your
  1157. system's login() call])
  1158. AC_DEFINE([DISABLE_FD_PASSING])
  1159. LIBS="$LIBS -lsecurity -ldb -lm -laud"
  1160. SIA_MSG="yes"
  1161. else
  1162. AC_MSG_RESULT([no])
  1163. AC_DEFINE([LOCKED_PASSWD_SUBSTR], ["Nologin"],
  1164. [String used in /etc/passwd to denote locked account])
  1165. fi
  1166. fi
  1167. AC_DEFINE([BROKEN_GETADDRINFO])
  1168. AC_DEFINE([SETEUID_BREAKS_SETUID])
  1169. AC_DEFINE([BROKEN_SETREUID])
  1170. AC_DEFINE([BROKEN_SETREGID])
  1171. AC_DEFINE([BROKEN_READV_COMPARISON], [1], [Can't do comparisons on readv])
  1172. ;;
  1173. *-*-nto-qnx*)
  1174. AC_DEFINE([USE_PIPES])
  1175. AC_DEFINE([NO_X11_UNIX_SOCKETS])
  1176. AC_DEFINE([DISABLE_LASTLOG])
  1177. AC_DEFINE([SSHD_ACQUIRES_CTTY])
  1178. AC_DEFINE([BROKEN_SHADOW_EXPIRE], [1], [QNX shadow support is broken])
  1179. enable_etc_default_login=no # has incompatible /etc/default/login
  1180. case "$host" in
  1181. *-*-nto-qnx6*)
  1182. AC_DEFINE([DISABLE_FD_PASSING])
  1183. ;;
  1184. esac
  1185. ;;
  1186. *-*-ultrix*)
  1187. AC_DEFINE([BROKEN_GETGROUPS], [1], [getgroups(0,NULL) will return -1])
  1188. AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to for controlling tty])
  1189. AC_DEFINE([HAVE_SYS_SYSLOG_H], [1], [Force use of sys/syslog.h on Ultrix])
  1190. AC_DEFINE([DISABLE_UTMPX], [1], [Disable utmpx])
  1191. # DISABLE_FD_PASSING so that we call setpgrp as root, otherwise we
  1192. # don't get a controlling tty.
  1193. AC_DEFINE([DISABLE_FD_PASSING], [1], [Need to call setpgrp as root])
  1194. # On Ultrix some headers are not protected against multiple includes,
  1195. # so we create wrappers and put it where the compiler will find it.
  1196. AC_MSG_WARN([creating compat wrappers for headers])
  1197. mkdir -p netinet
  1198. for header in netinet/ip.h netdb.h resolv.h; do
  1199. name=`echo $header | tr 'a-z/.' 'A-Z__'`
  1200. cat >$header <<EOD
  1201. #ifndef _SSH_COMPAT_${name}
  1202. #define _SSH_COMPAT_${name}
  1203. #include "/usr/include/${header}"
  1204. #endif
  1205. EOD
  1206. done
  1207. ;;
  1208. *-*-lynxos)
  1209. CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"
  1210. AC_DEFINE([BROKEN_SETVBUF], [1],
  1211. [LynxOS has broken setvbuf() implementation])
  1212. ;;
  1213. esac
  1214. AC_MSG_CHECKING([compiler and flags for sanity])
  1215. AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <stdlib.h> ]], [[ exit(0); ]])],
  1216. [ AC_MSG_RESULT([yes]) ],
  1217. [
  1218. AC_MSG_RESULT([no])
  1219. AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
  1220. ],
  1221. [ AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
  1222. )
  1223. dnl Checks for header files.
  1224. # Checks for libraries.
  1225. AC_CHECK_FUNC([setsockopt], , [AC_CHECK_LIB([socket], [setsockopt])])
  1226. dnl IRIX and Solaris 2.5.1 have dirname() in libgen
  1227. AC_CHECK_FUNCS([dirname], [AC_CHECK_HEADERS([libgen.h])] , [
  1228. AC_CHECK_LIB([gen], [dirname], [
  1229. AC_CACHE_CHECK([for broken dirname],
  1230. ac_cv_have_broken_dirname, [
  1231. save_LIBS="$LIBS"
  1232. LIBS="$LIBS -lgen"
  1233. AC_RUN_IFELSE(
  1234. [AC_LANG_SOURCE([[
  1235. #include <libgen.h>
  1236. #include <string.h>
  1237. #include <stdlib.h>
  1238. int main(int argc, char **argv) {
  1239. char *s, buf[32];
  1240. strncpy(buf,"/etc", 32);
  1241. s = dirname(buf);
  1242. if (!s || strncmp(s, "/", 32) != 0) {
  1243. exit(1);
  1244. } else {
  1245. exit(0);
  1246. }
  1247. }
  1248. ]])],
  1249. [ ac_cv_have_broken_dirname="no" ],
  1250. [ ac_cv_have_broken_dirname="yes" ],
  1251. [ ac_cv_have_broken_dirname="no" ],
  1252. )
  1253. LIBS="$save_LIBS"
  1254. ])
  1255. if test "x$ac_cv_have_broken_dirname" = "xno" ; then
  1256. LIBS="$LIBS -lgen"
  1257. AC_DEFINE([HAVE_DIRNAME])
  1258. AC_CHECK_HEADERS([libgen.h])
  1259. fi
  1260. ])
  1261. ])
  1262. AC_CHECK_FUNC([getspnam], ,
  1263. [AC_CHECK_LIB([gen], [getspnam], [LIBS="$LIBS -lgen"])])
  1264. AC_SEARCH_LIBS([basename], [gen], [AC_DEFINE([HAVE_BASENAME], [1],
  1265. [Define if you have the basename function.])])
  1266. dnl zlib defaults to enabled
  1267. zlib=yes
  1268. AC_ARG_WITH([zlib],
  1269. [ --with-zlib=PATH Use zlib in PATH],
  1270. [ if test "x$withval" = "xno" ; then
  1271. zlib=no
  1272. elif test "x$withval" != "xyes"; then
  1273. if test -d "$withval/lib"; then
  1274. if test -n "${rpath_opt}"; then
  1275. LDFLAGS="-L${withval}/lib ${rpath_opt}${withval}/lib ${LDFLAGS}"
  1276. else
  1277. LDFLAGS="-L${withval}/lib ${LDFLAGS}"
  1278. fi
  1279. else
  1280. if test -n "${rpath_opt}"; then
  1281. LDFLAGS="-L${withval} ${rpath_opt}${withval} ${LDFLAGS}"
  1282. else
  1283. LDFLAGS="-L${withval} ${LDFLAGS}"
  1284. fi
  1285. fi
  1286. if test -d "$withval/include"; then
  1287. CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
  1288. else
  1289. CPPFLAGS="-I${withval} ${CPPFLAGS}"
  1290. fi
  1291. fi ]
  1292. )
  1293. AC_MSG_CHECKING([for zlib])
  1294. if test "x${zlib}" = "xno"; then
  1295. AC_MSG_RESULT([no])
  1296. else
  1297. AC_MSG_RESULT([yes])
  1298. AC_DEFINE([WITH_ZLIB], [1], [Enable zlib])
  1299. AC_CHECK_HEADER([zlib.h], ,[AC_MSG_ERROR([*** zlib.h missing - please install first or check config.log ***])])
  1300. AC_CHECK_LIB([z], [deflate], ,
  1301. [
  1302. saved_CPPFLAGS="$CPPFLAGS"
  1303. saved_LDFLAGS="$LDFLAGS"
  1304. save_LIBS="$LIBS"
  1305. dnl Check default zlib install dir
  1306. if test -n "${rpath_opt}"; then
  1307. LDFLAGS="-L/usr/local/lib ${rpath_opt}/usr/local/lib ${saved_LDFLAGS}"
  1308. else
  1309. LDFLAGS="-L/usr/local/lib ${saved_LDFLAGS}"
  1310. fi
  1311. CPPFLAGS="-I/usr/local/include ${saved_CPPFLAGS}"
  1312. LIBS="$LIBS -lz"
  1313. AC_TRY_LINK_FUNC([deflate], [AC_DEFINE([HAVE_LIBZ])],
  1314. [
  1315. AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***])
  1316. ]
  1317. )
  1318. ]
  1319. )
  1320. AC_ARG_WITH([zlib-version-check],
  1321. [ --without-zlib-version-check Disable zlib version check],
  1322. [ if test "x$withval" = "xno" ; then
  1323. zlib_check_nonfatal=1
  1324. fi
  1325. ]
  1326. )
  1327. AC_MSG_CHECKING([for possibly buggy zlib])
  1328. AC_RUN_IFELSE([AC_LANG_PROGRAM([[
  1329. #include <stdio.h>
  1330. #include <stdlib.h>
  1331. #include <zlib.h>
  1332. ]],
  1333. [[
  1334. int a=0, b=0, c=0, d=0, n, v;
  1335. n = sscanf(ZLIB_VERSION, "%d.%d.%d.%d", &a, &b, &c, &d);
  1336. if (n != 3 && n != 4)
  1337. exit(1);
  1338. v = a*1000000 + b*10000 + c*100 + d;
  1339. fprintf(stderr, "found zlib version %s (%d)\n", ZLIB_VERSION, v);
  1340. /* 1.1.4 is OK */
  1341. if (a == 1 && b == 1 && c >= 4)
  1342. exit(0);
  1343. /* 1.2.3 and up are OK */
  1344. if (v >= 1020300)
  1345. exit(0);
  1346. exit(2);
  1347. ]])],
  1348. AC_MSG_RESULT([no]),
  1349. [ AC_MSG_RESULT([yes])
  1350. if test -z "$zlib_check_nonfatal" ; then
  1351. AC_MSG_ERROR([*** zlib too old - check config.log ***
  1352. Your reported zlib version has known security problems. It's possible your
  1353. vendor has fixed these problems without changing the version number. If you
  1354. are sure this is the case, you can disable the check by running
  1355. "./configure --without-zlib-version-check".
  1356. If you are in doubt, upgrade zlib to version 1.2.3 or greater.
  1357. See http://www.gzip.org/zlib/ for details.])
  1358. else
  1359. AC_MSG_WARN([zlib version may have security problems])
  1360. fi
  1361. ],
  1362. [ AC_MSG_WARN([cross compiling: not checking zlib version]) ]
  1363. )
  1364. fi
  1365. dnl UnixWare 2.x
  1366. AC_CHECK_FUNC([strcasecmp],
  1367. [], [ AC_CHECK_LIB([resolv], [strcasecmp], [LIBS="$LIBS -lresolv"]) ]
  1368. )
  1369. AC_CHECK_FUNCS([utimes],
  1370. [], [ AC_CHECK_LIB([c89], [utimes], [AC_DEFINE([HAVE_UTIMES])
  1371. LIBS="$LIBS -lc89"]) ]
  1372. )
  1373. dnl Checks for libutil functions
  1374. AC_CHECK_HEADERS([bsd/libutil.h libutil.h])
  1375. AC_SEARCH_LIBS([fmt_scaled], [util bsd])
  1376. AC_SEARCH_LIBS([scan_scaled], [util bsd])
  1377. AC_SEARCH_LIBS([login], [util bsd])
  1378. AC_SEARCH_LIBS([logout], [util bsd])
  1379. AC_SEARCH_LIBS([logwtmp], [util bsd])
  1380. AC_SEARCH_LIBS([openpty], [util bsd])
  1381. AC_SEARCH_LIBS([updwtmp], [util bsd])
  1382. AC_CHECK_FUNCS([fmt_scaled scan_scaled login logout openpty updwtmp logwtmp])
  1383. # On some platforms, inet_ntop and gethostbyname may be found in libresolv
  1384. # or libnsl.
  1385. AC_SEARCH_LIBS([inet_ntop], [resolv nsl])
  1386. AC_SEARCH_LIBS([gethostbyname], [resolv nsl])
  1387. # Some Linux distribtions ship the BSD libc hashing functions in
  1388. # separate libraries.
  1389. AC_SEARCH_LIBS([SHA256Update], [md bsd])
  1390. # "Particular Function Checks"
  1391. # see https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Functions.html
  1392. AC_FUNC_STRFTIME
  1393. AC_FUNC_MALLOC
  1394. AC_FUNC_REALLOC
  1395. # autoconf doesn't have AC_FUNC_CALLOC so fake it if malloc returns NULL;
  1396. AC_MSG_CHECKING([if calloc(0, N) returns non-null])
  1397. AC_RUN_IFELSE(
  1398. [AC_LANG_PROGRAM(
  1399. [[ #include <stdlib.h> ]],
  1400. [[ void *p = calloc(0, 1); exit(p == NULL); ]]
  1401. )],
  1402. [ func_calloc_0_nonnull=yes ],
  1403. [ func_calloc_0_nonnull=no ],
  1404. [ AC_MSG_WARN([cross compiling: assuming same as malloc])
  1405. func_calloc_0_nonnull="$ac_cv_func_malloc_0_nonnull"]
  1406. )
  1407. AC_MSG_RESULT([$func_calloc_0_nonnull])
  1408. if test "x$func_calloc_0_nonnull" = "xyes"; then
  1409. AC_DEFINE(HAVE_CALLOC, 1, [calloc(0, x) returns non-null])
  1410. else
  1411. AC_DEFINE(HAVE_CALLOC, 0, [calloc(0, x) returns NULL])
  1412. AC_DEFINE(calloc, rpl_calloc,
  1413. [Define to rpl_calloc if the replacement function should be used.])
  1414. fi
  1415. # Check for ALTDIRFUNC glob() extension
  1416. AC_MSG_CHECKING([for GLOB_ALTDIRFUNC support])
  1417. AC_EGREP_CPP([FOUNDIT],
  1418. [
  1419. #include <glob.h>
  1420. #ifdef GLOB_ALTDIRFUNC
  1421. FOUNDIT
  1422. #endif
  1423. ],
  1424. [
  1425. AC_DEFINE([GLOB_HAS_ALTDIRFUNC], [1],
  1426. [Define if your system glob() function has
  1427. the GLOB_ALTDIRFUNC extension])
  1428. AC_MSG_RESULT([yes])
  1429. ],
  1430. [
  1431. AC_MSG_RESULT([no])
  1432. ]
  1433. )
  1434. # Check for g.gl_matchc glob() extension
  1435. AC_MSG_CHECKING([for gl_matchc field in glob_t])
  1436. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]],
  1437. [[ glob_t g; g.gl_matchc = 1; ]])],
  1438. [
  1439. AC_DEFINE([GLOB_HAS_GL_MATCHC], [1],
  1440. [Define if your system glob() function has
  1441. gl_matchc options in glob_t])
  1442. AC_MSG_RESULT([yes])
  1443. ], [
  1444. AC_MSG_RESULT([no])
  1445. ])
  1446. # Check for g.gl_statv glob() extension
  1447. AC_MSG_CHECKING([for gl_statv and GLOB_KEEPSTAT extensions for glob])
  1448. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]], [[
  1449. #ifndef GLOB_KEEPSTAT
  1450. #error "glob does not support GLOB_KEEPSTAT extension"
  1451. #endif
  1452. glob_t g;
  1453. g.gl_statv = NULL;
  1454. ]])],
  1455. [
  1456. AC_DEFINE([GLOB_HAS_GL_STATV], [1],
  1457. [Define if your system glob() function has
  1458. gl_statv options in glob_t])
  1459. AC_MSG_RESULT([yes])
  1460. ], [
  1461. AC_MSG_RESULT([no])
  1462. ])
  1463. AC_CHECK_DECLS([GLOB_NOMATCH], , , [#include <glob.h>])
  1464. AC_CHECK_DECL([VIS_ALL], ,
  1465. AC_DEFINE(BROKEN_STRNVIS, 1, [missing VIS_ALL]), [#include <vis.h>])
  1466. AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
  1467. AC_RUN_IFELSE(
  1468. [AC_LANG_PROGRAM([[
  1469. #include <sys/types.h>
  1470. #include <dirent.h>
  1471. #include <stdlib.h>
  1472. ]],
  1473. [[
  1474. struct dirent d;
  1475. exit(sizeof(d.d_name)<=sizeof(char));
  1476. ]])],
  1477. [AC_MSG_RESULT([yes])],
  1478. [
  1479. AC_MSG_RESULT([no])
  1480. AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME], [1],
  1481. [Define if your struct dirent expects you to
  1482. allocate extra space for d_name])
  1483. ],
  1484. [
  1485. AC_MSG_WARN([cross compiling: assuming BROKEN_ONE_BYTE_DIRENT_D_NAME])
  1486. AC_DEFINE([BROKEN_ONE_BYTE_DIRENT_D_NAME])
  1487. ]
  1488. )
  1489. AC_MSG_CHECKING([for /proc/pid/fd directory])
  1490. if test -d "/proc/$$/fd" ; then
  1491. AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd])
  1492. AC_MSG_RESULT([yes])
  1493. else
  1494. AC_MSG_RESULT([no])
  1495. fi
  1496. # Check whether user wants TCP wrappers support
  1497. TCPW_MSG="no"
  1498. AC_ARG_WITH([tcp-wrappers],
  1499. [ --with-tcp-wrappers[[=PATH]] Enable tcpwrappers support (optionally in PATH)],
  1500. [
  1501. if test "x$withval" != "xno" ; then
  1502. saved_LIBS="$LIBS"
  1503. saved_LDFLAGS="$LDFLAGS"
  1504. saved_CPPFLAGS="$CPPFLAGS"
  1505. if test -n "${withval}" && \
  1506. test "x${withval}" != "xyes"; then
  1507. if test -d "${withval}/lib"; then
  1508. if test -n "${need_dash_r}"; then
  1509. LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
  1510. else
  1511. LDFLAGS="-L${withval}/lib ${LDFLAGS}"
  1512. fi
  1513. else
  1514. if test -n "${need_dash_r}"; then
  1515. LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
  1516. else
  1517. LDFLAGS="-L${withval} ${LDFLAGS}"
  1518. fi
  1519. fi
  1520. if test -d "${withval}/include"; then
  1521. CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
  1522. else
  1523. CPPFLAGS="-I${withval} ${CPPFLAGS}"
  1524. fi
  1525. fi
  1526. LIBS="-lwrap $LIBS"
  1527. AC_MSG_CHECKING([for libwrap])
  1528. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  1529. #include <sys/types.h>
  1530. #include <sys/socket.h>
  1531. #include <netinet/in.h>
  1532. #include <tcpd.h>
  1533. int deny_severity = 0, allow_severity = 0;
  1534. ]], [[
  1535. hosts_access(0);
  1536. ]])], [
  1537. AC_MSG_RESULT([yes])
  1538. AC_DEFINE([LIBWRAP], [1],
  1539. [Define if you want
  1540. TCP Wrappers support])
  1541. SSHDLIBS="$SSHDLIBS -lwrap"
  1542. TCPW_MSG="yes"
  1543. ], [
  1544. AC_MSG_ERROR([*** libwrap missing])
  1545. ])
  1546. LIBS="$saved_LIBS"
  1547. fi
  1548. ]
  1549. )
  1550. # Check whether user wants to use ldns
  1551. LDNS_MSG="no"
  1552. AC_ARG_WITH(ldns,
  1553. [ --with-ldns[[=PATH]] Use ldns for DNSSEC support (optionally in PATH)],
  1554. [
  1555. ldns=""
  1556. if test "x$withval" = "xyes" ; then
  1557. AC_PATH_TOOL([LDNSCONFIG], [ldns-config], [no])
  1558. if test "x$LDNSCONFIG" = "xno"; then
  1559. LIBS="-lldns $LIBS"
  1560. ldns=yes
  1561. else
  1562. LIBS="$LIBS `$LDNSCONFIG --libs`"
  1563. CPPFLAGS="$CPPFLAGS `$LDNSCONFIG --cflags`"
  1564. ldns=yes
  1565. fi
  1566. elif test "x$withval" != "xno" ; then
  1567. CPPFLAGS="$CPPFLAGS -I${withval}/include"
  1568. LDFLAGS="$LDFLAGS -L${withval}/lib"
  1569. LIBS="-lldns $LIBS"
  1570. ldns=yes
  1571. fi
  1572. # Verify that it works.
  1573. if test "x$ldns" = "xyes" ; then
  1574. AC_DEFINE(HAVE_LDNS, 1, [Define if you want ldns support])
  1575. LDNS_MSG="yes"
  1576. AC_MSG_CHECKING([for ldns support])
  1577. AC_LINK_IFELSE(
  1578. [AC_LANG_SOURCE([[
  1579. #include <stdio.h>
  1580. #include <stdlib.h>
  1581. #ifdef HAVE_STDINT_H
  1582. # include <stdint.h>
  1583. #endif
  1584. #include <ldns/ldns.h>
  1585. int main() { ldns_status status = ldns_verify_trusted(NULL, NULL, NULL, NULL); status=LDNS_STATUS_OK; exit(0); }
  1586. ]])
  1587. ],
  1588. [AC_MSG_RESULT(yes)],
  1589. [
  1590. AC_MSG_RESULT(no)
  1591. AC_MSG_ERROR([** Incomplete or missing ldns libraries.])
  1592. ])
  1593. fi
  1594. ])
  1595. # Check whether user wants libedit support
  1596. LIBEDIT_MSG="no"
  1597. AC_ARG_WITH([libedit],
  1598. [ --with-libedit[[=PATH]] Enable libedit support for sftp],
  1599. [ if test "x$withval" != "xno" ; then
  1600. if test "x$withval" = "xyes" ; then
  1601. AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
  1602. if test "x$PKGCONFIG" != "xno"; then
  1603. AC_MSG_CHECKING([if $PKGCONFIG knows about libedit])
  1604. if "$PKGCONFIG" libedit; then
  1605. AC_MSG_RESULT([yes])
  1606. use_pkgconfig_for_libedit=yes
  1607. else
  1608. AC_MSG_RESULT([no])
  1609. fi
  1610. fi
  1611. else
  1612. CPPFLAGS="$CPPFLAGS -I${withval}/include"
  1613. if test -n "${rpath_opt}"; then
  1614. LDFLAGS="-L${withval}/lib ${rpath_opt}${withval}/lib ${LDFLAGS}"
  1615. else
  1616. LDFLAGS="-L${withval}/lib ${LDFLAGS}"
  1617. fi
  1618. fi
  1619. if test "x$use_pkgconfig_for_libedit" = "xyes"; then
  1620. LIBEDIT=`$PKGCONFIG --libs libedit`
  1621. CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libedit`"
  1622. else
  1623. LIBEDIT="-ledit -lcurses"
  1624. fi
  1625. OTHERLIBS=`echo $LIBEDIT | sed 's/-ledit//'`
  1626. AC_CHECK_LIB([edit], [el_init],
  1627. [ AC_DEFINE([USE_LIBEDIT], [1], [Use libedit for sftp])
  1628. LIBEDIT_MSG="yes"
  1629. AC_SUBST([LIBEDIT])
  1630. ],
  1631. [ AC_MSG_ERROR([libedit not found]) ],
  1632. [ $OTHERLIBS ]
  1633. )
  1634. AC_MSG_CHECKING([if libedit version is compatible])
  1635. AC_COMPILE_IFELSE(
  1636. [AC_LANG_PROGRAM([[
  1637. #include <histedit.h>
  1638. #include <stdlib.h>
  1639. ]],
  1640. [[
  1641. int i = H_SETSIZE;
  1642. el_init("", NULL, NULL, NULL);
  1643. exit(0);
  1644. ]])],
  1645. [ AC_MSG_RESULT([yes]) ],
  1646. [ AC_MSG_RESULT([no])
  1647. AC_MSG_ERROR([libedit version is not compatible]) ]
  1648. )
  1649. fi ]
  1650. )
  1651. AUDIT_MODULE=none
  1652. AC_ARG_WITH([audit],
  1653. [ --with-audit=module Enable audit support (modules=debug,bsm,linux)],
  1654. [
  1655. AC_MSG_CHECKING([for supported audit module])
  1656. case "$withval" in
  1657. bsm)
  1658. AC_MSG_RESULT([bsm])
  1659. AUDIT_MODULE=bsm
  1660. dnl Checks for headers, libs and functions
  1661. AC_CHECK_HEADERS([bsm/audit.h], [],
  1662. [AC_MSG_ERROR([BSM enabled and bsm/audit.h not found])],
  1663. [
  1664. #ifdef HAVE_TIME_H
  1665. # include <time.h>
  1666. #endif
  1667. ]
  1668. )
  1669. AC_CHECK_LIB([bsm], [getaudit], [],
  1670. [AC_MSG_ERROR([BSM enabled and required library not found])])
  1671. AC_CHECK_FUNCS([getaudit], [],
  1672. [AC_MSG_ERROR([BSM enabled and required function not found])])
  1673. # These are optional
  1674. AC_CHECK_FUNCS([getaudit_addr aug_get_machine])
  1675. AC_DEFINE([USE_BSM_AUDIT], [1], [Use BSM audit module])
  1676. if test "$sol2ver" -ge 11; then
  1677. SSHDLIBS="$SSHDLIBS -lscf"
  1678. AC_DEFINE([BROKEN_BSM_API], [1],
  1679. [The system has incomplete BSM API])
  1680. fi
  1681. ;;
  1682. linux)
  1683. AC_MSG_RESULT([linux])
  1684. AUDIT_MODULE=linux
  1685. dnl Checks for headers, libs and functions
  1686. AC_CHECK_HEADERS([libaudit.h])
  1687. SSHDLIBS="$SSHDLIBS -laudit"
  1688. AC_DEFINE([USE_LINUX_AUDIT], [1], [Use Linux audit module])
  1689. ;;
  1690. debug)
  1691. AUDIT_MODULE=debug
  1692. AC_MSG_RESULT([debug])
  1693. AC_DEFINE([SSH_AUDIT_EVENTS], [1], [Use audit debugging module])
  1694. ;;
  1695. no)
  1696. AC_MSG_RESULT([no])
  1697. ;;
  1698. *)
  1699. AC_MSG_ERROR([Unknown audit module $withval])
  1700. ;;
  1701. esac ]
  1702. )
  1703. AC_ARG_WITH([pie],
  1704. [ --with-pie Build Position Independent Executables if possible], [
  1705. if test "x$withval" = "xno"; then
  1706. use_pie=no
  1707. fi
  1708. if test "x$withval" = "xyes"; then
  1709. use_pie=yes
  1710. fi
  1711. ]
  1712. )
  1713. if test "x$use_pie" = "x"; then
  1714. use_pie=no
  1715. fi
  1716. if test "x$use_toolchain_hardening" != "x1" && test "x$use_pie" = "xauto"; then
  1717. # Turn off automatic PIE when toolchain hardening is off.
  1718. use_pie=no
  1719. fi
  1720. if test "x$use_pie" = "xauto"; then
  1721. # Automatic PIE requires gcc >= 4.x
  1722. AC_MSG_CHECKING([for gcc >= 4.x])
  1723. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  1724. #if !defined(__GNUC__) || __GNUC__ < 4
  1725. #error gcc is too old
  1726. #endif
  1727. ]])],
  1728. [ AC_MSG_RESULT([yes]) ],
  1729. [ AC_MSG_RESULT([no])
  1730. use_pie=no ]
  1731. )
  1732. fi
  1733. if test "x$use_pie" != "xno"; then
  1734. SAVED_CFLAGS="$CFLAGS"
  1735. SAVED_LDFLAGS="$LDFLAGS"
  1736. OSSH_CHECK_CFLAG_COMPILE([-fPIE])
  1737. OSSH_CHECK_LDFLAG_LINK([-pie])
  1738. # We use both -fPIE and -pie or neither.
  1739. AC_MSG_CHECKING([whether both -fPIE and -pie are supported])
  1740. if echo "x $CFLAGS" | grep ' -fPIE' >/dev/null 2>&1 && \
  1741. echo "x $LDFLAGS" | grep ' -pie' >/dev/null 2>&1 ; then
  1742. AC_MSG_RESULT([yes])
  1743. else
  1744. AC_MSG_RESULT([no])
  1745. CFLAGS="$SAVED_CFLAGS"
  1746. LDFLAGS="$SAVED_LDFLAGS"
  1747. fi
  1748. fi
  1749. AC_MSG_CHECKING([whether -fPIC is accepted])
  1750. SAVED_CFLAGS="$CFLAGS"
  1751. CFLAGS="$CFLAGS -fPIC"
  1752. AC_COMPILE_IFELSE(
  1753. [AC_LANG_PROGRAM( [[ #include <stdlib.h> ]], [[ exit(0); ]] )],
  1754. [AC_MSG_RESULT([yes])
  1755. PICFLAG="-fPIC"; ],
  1756. [AC_MSG_RESULT([no])
  1757. PICFLAG=""; ])
  1758. CFLAGS="$SAVED_CFLAGS"
  1759. AC_SUBST([PICFLAG])
  1760. dnl Checks for library functions. Please keep in alphabetical order
  1761. AC_CHECK_FUNCS([ \
  1762. Blowfish_initstate \
  1763. Blowfish_expandstate \
  1764. Blowfish_expand0state \
  1765. Blowfish_stream2word \
  1766. SHA256Update \
  1767. SHA384Update \
  1768. SHA512Update \
  1769. asprintf \
  1770. b64_ntop \
  1771. __b64_ntop \
  1772. b64_pton \
  1773. __b64_pton \
  1774. bcopy \
  1775. bcrypt_pbkdf \
  1776. bindresvport_sa \
  1777. blf_enc \
  1778. bzero \
  1779. cap_rights_limit \
  1780. clock \
  1781. closefrom \
  1782. dirfd \
  1783. endgrent \
  1784. err \
  1785. errx \
  1786. explicit_bzero \
  1787. explicit_memset \
  1788. fchmod \
  1789. fchmodat \
  1790. fchown \
  1791. fchownat \
  1792. flock \
  1793. fnmatch \
  1794. freeaddrinfo \
  1795. freezero \
  1796. fstatfs \
  1797. fstatvfs \
  1798. futimes \
  1799. getaddrinfo \
  1800. getcwd \
  1801. getgrouplist \
  1802. getline \
  1803. getnameinfo \
  1804. getopt \
  1805. getpagesize \
  1806. getpeereid \
  1807. getpeerucred \
  1808. getpgid \
  1809. _getpty \
  1810. getrlimit \
  1811. getrandom \
  1812. getsid \
  1813. getttyent \
  1814. glob \
  1815. group_from_gid \
  1816. inet_aton \
  1817. inet_ntoa \
  1818. inet_ntop \
  1819. innetgr \
  1820. llabs \
  1821. localtime_r \
  1822. login_getcapbool \
  1823. md5_crypt \
  1824. memmem \
  1825. memmove \
  1826. memset_s \
  1827. mkdtemp \
  1828. ngetaddrinfo \
  1829. nsleep \
  1830. ogetaddrinfo \
  1831. openlog_r \
  1832. pledge \
  1833. poll \
  1834. prctl \
  1835. pstat \
  1836. raise \
  1837. readpassphrase \
  1838. reallocarray \
  1839. realpath \
  1840. recvmsg \
  1841. recallocarray \
  1842. rresvport_af \
  1843. sendmsg \
  1844. setdtablesize \
  1845. setegid \
  1846. setenv \
  1847. seteuid \
  1848. setgroupent \
  1849. setgroups \
  1850. setlinebuf \
  1851. setlogin \
  1852. setpassent\
  1853. setpcred \
  1854. setproctitle \
  1855. setregid \
  1856. setreuid \
  1857. setrlimit \
  1858. setsid \
  1859. setvbuf \
  1860. sigaction \
  1861. sigvec \
  1862. snprintf \
  1863. socketpair \
  1864. statfs \
  1865. statvfs \
  1866. strcasestr \
  1867. strdup \
  1868. strerror \
  1869. strlcat \
  1870. strlcpy \
  1871. strmode \
  1872. strndup \
  1873. strnlen \
  1874. strnvis \
  1875. strptime \
  1876. strsignal \
  1877. strtonum \
  1878. strtoll \
  1879. strtoul \
  1880. strtoull \
  1881. swap32 \
  1882. sysconf \
  1883. tcgetpgrp \
  1884. timingsafe_bcmp \
  1885. truncate \
  1886. unsetenv \
  1887. updwtmpx \
  1888. utimensat \
  1889. user_from_uid \
  1890. usleep \
  1891. vasprintf \
  1892. vsnprintf \
  1893. waitpid \
  1894. warn \
  1895. ])
  1896. AC_CHECK_DECLS([bzero, memmem])
  1897. dnl Wide character support.
  1898. AC_CHECK_FUNCS([mblen mbtowc nl_langinfo wcwidth])
  1899. TEST_SSH_UTF8=${TEST_SSH_UTF8:=yes}
  1900. AC_MSG_CHECKING([for utf8 locale support])
  1901. AC_RUN_IFELSE(
  1902. [AC_LANG_PROGRAM([[
  1903. #include <locale.h>
  1904. #include <stdlib.h>
  1905. ]], [[
  1906. char *loc = setlocale(LC_CTYPE, "en_US.UTF-8");
  1907. if (loc != NULL)
  1908. exit(0);
  1909. exit(1);
  1910. ]])],
  1911. AC_MSG_RESULT(yes),
  1912. [AC_MSG_RESULT(no)
  1913. TEST_SSH_UTF8=no],
  1914. AC_MSG_WARN([cross compiling: assuming yes])
  1915. )
  1916. AC_LINK_IFELSE(
  1917. [AC_LANG_PROGRAM(
  1918. [[ #include <ctype.h> ]],
  1919. [[ return (isblank('a')); ]])],
  1920. [AC_DEFINE([HAVE_ISBLANK], [1], [Define if you have isblank(3C).])
  1921. ])
  1922. SCARD_MSG="yes"
  1923. disable_pkcs11=
  1924. AC_ARG_ENABLE([pkcs11],
  1925. [ --disable-pkcs11 disable PKCS#11 support code [no]],
  1926. [
  1927. if test "x$enableval" = "xno" ; then
  1928. disable_pkcs11=1
  1929. SCARD_MSG="no"
  1930. fi
  1931. ]
  1932. )
  1933. disable_sk=
  1934. AC_ARG_ENABLE([security-key],
  1935. [ --disable-security-key disable U2F/FIDO support code [no]],
  1936. [
  1937. if test "x$enableval" = "xno" ; then
  1938. disable_sk=1
  1939. fi
  1940. ]
  1941. )
  1942. enable_sk_internal=
  1943. AC_ARG_WITH([security-key-builtin],
  1944. [ --with-security-key-builtin include builtin U2F/FIDO support],
  1945. [
  1946. if test "x$withval" != "xno" ; then
  1947. enable_sk_internal=yes
  1948. fi
  1949. ]
  1950. )
  1951. test "x$disable_sk" != "x" && enable_sk_internal=""
  1952. AC_SEARCH_LIBS([dlopen], [dl])
  1953. AC_CHECK_FUNCS([dlopen])
  1954. AC_CHECK_DECL([RTLD_NOW], [], [], [#include <dlfcn.h>])
  1955. # Check whether we have a p11-kit, we got default provider on command line
  1956. DEFAULT_PKCS11_PROVIDER_MSG="no"
  1957. AC_ARG_WITH([default-pkcs11-provider],
  1958. [ --with-default-pkcs11-provider[[=PATH]] Use default pkcs11 provider (p11-kit detected by default)],
  1959. [ if test "x$withval" != "xno" && test "x$disable_pkcs11" = "x"; then
  1960. if test "x$withval" = "xyes" ; then
  1961. AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
  1962. if test "x$PKGCONFIG" != "xno"; then
  1963. AC_MSG_CHECKING([if $PKGCONFIG knows about p11-kit])
  1964. if "$PKGCONFIG" "p11-kit-1"; then
  1965. AC_MSG_RESULT([yes])
  1966. use_pkgconfig_for_p11kit=yes
  1967. else
  1968. AC_MSG_RESULT([no])
  1969. fi
  1970. fi
  1971. else
  1972. PKCS11_PATH="${withval}"
  1973. fi
  1974. if test "x$use_pkgconfig_for_p11kit" = "xyes"; then
  1975. PKCS11_PATH=`$PKGCONFIG --variable=proxy_module p11-kit-1`
  1976. fi
  1977. AC_CHECK_FILE("$PKCS11_PATH",
  1978. [ AC_DEFINE_UNQUOTED([PKCS11_DEFAULT_PROVIDER], ["$PKCS11_PATH"], [Path to default PKCS#11 provider (p11-kit proxy)])
  1979. DEFAULT_PKCS11_PROVIDER_MSG="$PKCS11_PATH"
  1980. ],
  1981. [ AC_MSG_ERROR([Requested PKCS11 provided not found]) ]
  1982. )
  1983. else
  1984. AC_MSG_WARN([Needs PKCS11 support to enable default pkcs11 provider])
  1985. fi ]
  1986. )
  1987. # IRIX has a const char return value for gai_strerror()
  1988. AC_CHECK_FUNCS([gai_strerror], [
  1989. AC_DEFINE([HAVE_GAI_STRERROR])
  1990. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  1991. #include <sys/types.h>
  1992. #include <sys/socket.h>
  1993. #include <netdb.h>
  1994. const char *gai_strerror(int);
  1995. ]], [[
  1996. char *str;
  1997. str = gai_strerror(0);
  1998. ]])], [
  1999. AC_DEFINE([HAVE_CONST_GAI_STRERROR_PROTO], [1],
  2000. [Define if gai_strerror() returns const char *])], [])])
  2001. AC_SEARCH_LIBS([nanosleep], [rt posix4], [AC_DEFINE([HAVE_NANOSLEEP], [1],
  2002. [Some systems put nanosleep outside of libc])])
  2003. AC_SEARCH_LIBS([clock_gettime], [rt],
  2004. [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime])])
  2005. dnl check if we need -D_REENTRANT for localtime_r declaration.
  2006. AC_CHECK_DECL([localtime_r], [],
  2007. [ saved_CPPFLAGS="$CPPFLAGS"
  2008. CPPFLAGS="$CPPFLAGS -D_REENTRANT"
  2009. unset ac_cv_have_decl_localtime_r
  2010. AC_CHECK_DECL([localtime_r], [],
  2011. [ CPPFLAGS="$saved_CPPFLAGS" ],
  2012. [ #include <time.h> ]
  2013. )
  2014. ],
  2015. [ #include <time.h> ]
  2016. )
  2017. dnl Make sure prototypes are defined for these before using them.
  2018. AC_CHECK_DECL([strsep],
  2019. [AC_CHECK_FUNCS([strsep])],
  2020. [],
  2021. [
  2022. #ifdef HAVE_STRING_H
  2023. # include <string.h>
  2024. #endif
  2025. ])
  2026. dnl tcsendbreak might be a macro
  2027. AC_CHECK_DECL([tcsendbreak],
  2028. [AC_DEFINE([HAVE_TCSENDBREAK])],
  2029. [AC_CHECK_FUNCS([tcsendbreak])],
  2030. [#include <termios.h>]
  2031. )
  2032. AC_CHECK_DECLS([h_errno], , ,[#include <netdb.h>])
  2033. AC_CHECK_DECLS([SHUT_RD, getpeereid], , ,
  2034. [
  2035. #include <sys/types.h>
  2036. #include <sys/socket.h>
  2037. #include <unistd.h>
  2038. ])
  2039. AC_CHECK_DECLS([O_NONBLOCK], , ,
  2040. [
  2041. #include <sys/types.h>
  2042. #ifdef HAVE_SYS_STAT_H
  2043. # include <sys/stat.h>
  2044. #endif
  2045. #ifdef HAVE_FCNTL_H
  2046. # include <fcntl.h>
  2047. #endif
  2048. ])
  2049. AC_CHECK_DECLS([readv, writev], , , [
  2050. #include <sys/types.h>
  2051. #include <sys/uio.h>
  2052. #include <unistd.h>
  2053. ])
  2054. AC_CHECK_DECLS([MAXSYMLINKS], , , [
  2055. #include <sys/param.h>
  2056. ])
  2057. AC_CHECK_DECLS([offsetof], , , [
  2058. #include <stddef.h>
  2059. ])
  2060. # extra bits for select(2)
  2061. AC_CHECK_DECLS([howmany, NFDBITS], [], [], [[
  2062. #include <sys/param.h>
  2063. #include <sys/types.h>
  2064. #ifdef HAVE_SYS_SYSMACROS_H
  2065. #include <sys/sysmacros.h>
  2066. #endif
  2067. #ifdef HAVE_SYS_SELECT_H
  2068. #include <sys/select.h>
  2069. #endif
  2070. #ifdef HAVE_SYS_TIME_H
  2071. #include <sys/time.h>
  2072. #endif
  2073. #ifdef HAVE_UNISTD_H
  2074. #include <unistd.h>
  2075. #endif
  2076. ]])
  2077. AC_CHECK_TYPES([fd_mask], [], [], [[
  2078. #include <sys/param.h>
  2079. #include <sys/types.h>
  2080. #ifdef HAVE_SYS_SELECT_H
  2081. #include <sys/select.h>
  2082. #endif
  2083. #ifdef HAVE_SYS_TIME_H
  2084. #include <sys/time.h>
  2085. #endif
  2086. #ifdef HAVE_UNISTD_H
  2087. #include <unistd.h>
  2088. #endif
  2089. ]])
  2090. AC_CHECK_FUNCS([setresuid], [
  2091. dnl Some platorms have setresuid that isn't implemented, test for this
  2092. AC_MSG_CHECKING([if setresuid seems to work])
  2093. AC_RUN_IFELSE(
  2094. [AC_LANG_PROGRAM([[
  2095. #include <stdlib.h>
  2096. #include <errno.h>
  2097. ]], [[
  2098. errno=0;
  2099. setresuid(0,0,0);
  2100. if (errno==ENOSYS)
  2101. exit(1);
  2102. else
  2103. exit(0);
  2104. ]])],
  2105. [AC_MSG_RESULT([yes])],
  2106. [AC_DEFINE([BROKEN_SETRESUID], [1],
  2107. [Define if your setresuid() is broken])
  2108. AC_MSG_RESULT([not implemented])],
  2109. [AC_MSG_WARN([cross compiling: not checking setresuid])]
  2110. )
  2111. ])
  2112. AC_CHECK_FUNCS([setresgid], [
  2113. dnl Some platorms have setresgid that isn't implemented, test for this
  2114. AC_MSG_CHECKING([if setresgid seems to work])
  2115. AC_RUN_IFELSE(
  2116. [AC_LANG_PROGRAM([[
  2117. #include <stdlib.h>
  2118. #include <errno.h>
  2119. ]], [[
  2120. errno=0;
  2121. setresgid(0,0,0);
  2122. if (errno==ENOSYS)
  2123. exit(1);
  2124. else
  2125. exit(0);
  2126. ]])],
  2127. [AC_MSG_RESULT([yes])],
  2128. [AC_DEFINE([BROKEN_SETRESGID], [1],
  2129. [Define if your setresgid() is broken])
  2130. AC_MSG_RESULT([not implemented])],
  2131. [AC_MSG_WARN([cross compiling: not checking setresuid])]
  2132. )
  2133. ])
  2134. AC_MSG_CHECKING([for working fflush(NULL)])
  2135. AC_RUN_IFELSE(
  2136. [AC_LANG_PROGRAM([[
  2137. #include <stdio.h>
  2138. #include <stdlib.h>
  2139. ]],
  2140. [[fflush(NULL); exit(0);]])],
  2141. AC_MSG_RESULT([yes]),
  2142. [AC_MSG_RESULT([no])
  2143. AC_DEFINE([FFLUSH_NULL_BUG], [1],
  2144. [define if fflush(NULL) does not work])],
  2145. AC_MSG_WARN([cross compiling: assuming working])
  2146. )
  2147. dnl Checks for time functions
  2148. AC_CHECK_FUNCS([gettimeofday time])
  2149. dnl Checks for utmp functions
  2150. AC_CHECK_FUNCS([endutent getutent getutid getutline pututline setutent])
  2151. AC_CHECK_FUNCS([utmpname])
  2152. dnl Checks for utmpx functions
  2153. AC_CHECK_FUNCS([endutxent getutxent getutxid getutxline getutxuser pututxline])
  2154. AC_CHECK_FUNCS([setutxdb setutxent utmpxname])
  2155. dnl Checks for lastlog functions
  2156. AC_CHECK_FUNCS([getlastlogxbyname])
  2157. AC_CHECK_FUNC([daemon],
  2158. [AC_DEFINE([HAVE_DAEMON], [1], [Define if your libraries define daemon()])],
  2159. [AC_CHECK_LIB([bsd], [daemon],
  2160. [LIBS="$LIBS -lbsd"; AC_DEFINE([HAVE_DAEMON])])]
  2161. )
  2162. AC_CHECK_FUNC([getpagesize],
  2163. [AC_DEFINE([HAVE_GETPAGESIZE], [1],
  2164. [Define if your libraries define getpagesize()])],
  2165. [AC_CHECK_LIB([ucb], [getpagesize],
  2166. [LIBS="$LIBS -lucb"; AC_DEFINE([HAVE_GETPAGESIZE])])]
  2167. )
  2168. # Check for broken snprintf
  2169. if test "x$ac_cv_func_snprintf" = "xyes" ; then
  2170. AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
  2171. AC_RUN_IFELSE(
  2172. [AC_LANG_PROGRAM([[
  2173. #include <stdio.h>
  2174. #include <stdlib.h>
  2175. ]],
  2176. [[
  2177. char b[5];
  2178. snprintf(b,5,"123456789");
  2179. exit(b[4]!='\0');
  2180. ]])],
  2181. [AC_MSG_RESULT([yes])],
  2182. [
  2183. AC_MSG_RESULT([no])
  2184. AC_DEFINE([BROKEN_SNPRINTF], [1],
  2185. [Define if your snprintf is busted])
  2186. AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
  2187. ],
  2188. [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
  2189. )
  2190. fi
  2191. if test "x$ac_cv_func_snprintf" = "xyes" ; then
  2192. AC_MSG_CHECKING([whether snprintf understands %zu])
  2193. AC_RUN_IFELSE(
  2194. [AC_LANG_PROGRAM([[
  2195. #include <sys/types.h>
  2196. #include <stdio.h>
  2197. #include <stdlib.h>
  2198. #include <string.h>
  2199. ]],
  2200. [[
  2201. size_t a = 1, b = 2;
  2202. char z[128];
  2203. snprintf(z, sizeof z, "%zu%zu", a, b);
  2204. exit(strcmp(z, "12"));
  2205. ]])],
  2206. [AC_MSG_RESULT([yes])],
  2207. [
  2208. AC_MSG_RESULT([no])
  2209. AC_DEFINE([BROKEN_SNPRINTF], [1],
  2210. [snprintf does not understand %zu])
  2211. ],
  2212. [ AC_MSG_WARN([cross compiling: Assuming working snprintf()]) ]
  2213. )
  2214. fi
  2215. # We depend on vsnprintf returning the right thing on overflow: the
  2216. # number of characters it tried to create (as per SUSv3)
  2217. if test "x$ac_cv_func_vsnprintf" = "xyes" ; then
  2218. AC_MSG_CHECKING([whether vsnprintf returns correct values on overflow])
  2219. AC_RUN_IFELSE(
  2220. [AC_LANG_PROGRAM([[
  2221. #include <sys/types.h>
  2222. #include <stdio.h>
  2223. #include <stdarg.h>
  2224. int x_snprintf(char *str, size_t count, const char *fmt, ...)
  2225. {
  2226. size_t ret;
  2227. va_list ap;
  2228. va_start(ap, fmt);
  2229. ret = vsnprintf(str, count, fmt, ap);
  2230. va_end(ap);
  2231. return ret;
  2232. }
  2233. ]], [[
  2234. char x[1];
  2235. if (x_snprintf(x, 1, "%s %d", "hello", 12345) != 11)
  2236. return 1;
  2237. if (x_snprintf(NULL, 0, "%s %d", "hello", 12345) != 11)
  2238. return 1;
  2239. return 0;
  2240. ]])],
  2241. [AC_MSG_RESULT([yes])],
  2242. [
  2243. AC_MSG_RESULT([no])
  2244. AC_DEFINE([BROKEN_SNPRINTF], [1],
  2245. [Define if your snprintf is busted])
  2246. AC_MSG_WARN([****** Your vsnprintf() function is broken, complain to your vendor])
  2247. ],
  2248. [ AC_MSG_WARN([cross compiling: Assuming working vsnprintf()]) ]
  2249. )
  2250. fi
  2251. # On systems where [v]snprintf is broken, but is declared in stdio,
  2252. # check that the fmt argument is const char * or just char *.
  2253. # This is only useful for when BROKEN_SNPRINTF
  2254. AC_MSG_CHECKING([whether snprintf can declare const char *fmt])
  2255. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  2256. #include <stdio.h>
  2257. int snprintf(char *a, size_t b, const char *c, ...) { return 0; }
  2258. ]], [[
  2259. snprintf(0, 0, 0);
  2260. ]])],
  2261. [AC_MSG_RESULT([yes])
  2262. AC_DEFINE([SNPRINTF_CONST], [const],
  2263. [Define as const if snprintf() can declare const char *fmt])],
  2264. [AC_MSG_RESULT([no])
  2265. AC_DEFINE([SNPRINTF_CONST], [/* not const */])])
  2266. # Check for missing getpeereid (or equiv) support
  2267. NO_PEERCHECK=""
  2268. if test "x$ac_cv_func_getpeereid" != "xyes" -a "x$ac_cv_func_getpeerucred" != "xyes"; then
  2269. AC_MSG_CHECKING([whether system supports SO_PEERCRED getsockopt])
  2270. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  2271. #include <sys/types.h>
  2272. #include <sys/socket.h>]], [[int i = SO_PEERCRED;]])],
  2273. [ AC_MSG_RESULT([yes])
  2274. AC_DEFINE([HAVE_SO_PEERCRED], [1], [Have PEERCRED socket option])
  2275. ], [AC_MSG_RESULT([no])
  2276. NO_PEERCHECK=1
  2277. ])
  2278. fi
  2279. dnl make sure that openpty does not reacquire controlling terminal
  2280. if test ! -z "$check_for_openpty_ctty_bug"; then
  2281. AC_MSG_CHECKING([if openpty correctly handles controlling tty])
  2282. AC_RUN_IFELSE(
  2283. [AC_LANG_PROGRAM([[
  2284. #include <stdio.h>
  2285. #include <stdlib.h>
  2286. #include <unistd.h>
  2287. #include <sys/fcntl.h>
  2288. #include <sys/types.h>
  2289. #include <sys/wait.h>
  2290. ]], [[
  2291. pid_t pid;
  2292. int fd, ptyfd, ttyfd, status;
  2293. pid = fork();
  2294. if (pid < 0) { /* failed */
  2295. exit(1);
  2296. } else if (pid > 0) { /* parent */
  2297. waitpid(pid, &status, 0);
  2298. if (WIFEXITED(status))
  2299. exit(WEXITSTATUS(status));
  2300. else
  2301. exit(2);
  2302. } else { /* child */
  2303. close(0); close(1); close(2);
  2304. setsid();
  2305. openpty(&ptyfd, &ttyfd, NULL, NULL, NULL);
  2306. fd = open("/dev/tty", O_RDWR | O_NOCTTY);
  2307. if (fd >= 0)
  2308. exit(3); /* Acquired ctty: broken */
  2309. else
  2310. exit(0); /* Did not acquire ctty: OK */
  2311. }
  2312. ]])],
  2313. [
  2314. AC_MSG_RESULT([yes])
  2315. ],
  2316. [
  2317. AC_MSG_RESULT([no])
  2318. AC_DEFINE([SSHD_ACQUIRES_CTTY])
  2319. ],
  2320. [
  2321. AC_MSG_RESULT([cross-compiling, assuming yes])
  2322. ]
  2323. )
  2324. fi
  2325. if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
  2326. test "x$check_for_hpux_broken_getaddrinfo" = "x1"; then
  2327. AC_MSG_CHECKING([if getaddrinfo seems to work])
  2328. AC_RUN_IFELSE(
  2329. [AC_LANG_PROGRAM([[
  2330. #include <stdio.h>
  2331. #include <stdlib.h>
  2332. #include <sys/socket.h>
  2333. #include <netdb.h>
  2334. #include <errno.h>
  2335. #include <netinet/in.h>
  2336. #define TEST_PORT "2222"
  2337. ]], [[
  2338. int err, sock;
  2339. struct addrinfo *gai_ai, *ai, hints;
  2340. char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
  2341. memset(&hints, 0, sizeof(hints));
  2342. hints.ai_family = PF_UNSPEC;
  2343. hints.ai_socktype = SOCK_STREAM;
  2344. hints.ai_flags = AI_PASSIVE;
  2345. err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
  2346. if (err != 0) {
  2347. fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
  2348. exit(1);
  2349. }
  2350. for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
  2351. if (ai->ai_family != AF_INET6)
  2352. continue;
  2353. err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
  2354. sizeof(ntop), strport, sizeof(strport),
  2355. NI_NUMERICHOST|NI_NUMERICSERV);
  2356. if (err != 0) {
  2357. if (err == EAI_SYSTEM)
  2358. perror("getnameinfo EAI_SYSTEM");
  2359. else
  2360. fprintf(stderr, "getnameinfo failed: %s\n",
  2361. gai_strerror(err));
  2362. exit(2);
  2363. }
  2364. sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
  2365. if (sock < 0)
  2366. perror("socket");
  2367. if (bind(sock, ai->ai_addr, ai->ai_addrlen) < 0) {
  2368. if (errno == EBADF)
  2369. exit(3);
  2370. }
  2371. }
  2372. exit(0);
  2373. ]])],
  2374. [
  2375. AC_MSG_RESULT([yes])
  2376. ],
  2377. [
  2378. AC_MSG_RESULT([no])
  2379. AC_DEFINE([BROKEN_GETADDRINFO])
  2380. ],
  2381. [
  2382. AC_MSG_RESULT([cross-compiling, assuming yes])
  2383. ]
  2384. )
  2385. fi
  2386. if test "x$ac_cv_func_getaddrinfo" = "xyes" && \
  2387. test "x$check_for_aix_broken_getaddrinfo" = "x1"; then
  2388. AC_MSG_CHECKING([if getaddrinfo seems to work])
  2389. AC_RUN_IFELSE(
  2390. [AC_LANG_PROGRAM([[
  2391. #include <stdio.h>
  2392. #include <stdlib.h>
  2393. #include <sys/socket.h>
  2394. #include <netdb.h>
  2395. #include <errno.h>
  2396. #include <netinet/in.h>
  2397. #define TEST_PORT "2222"
  2398. ]], [[
  2399. int err, sock;
  2400. struct addrinfo *gai_ai, *ai, hints;
  2401. char ntop[NI_MAXHOST], strport[NI_MAXSERV], *name = NULL;
  2402. memset(&hints, 0, sizeof(hints));
  2403. hints.ai_family = PF_UNSPEC;
  2404. hints.ai_socktype = SOCK_STREAM;
  2405. hints.ai_flags = AI_PASSIVE;
  2406. err = getaddrinfo(name, TEST_PORT, &hints, &gai_ai);
  2407. if (err != 0) {
  2408. fprintf(stderr, "getaddrinfo failed (%s)", gai_strerror(err));
  2409. exit(1);
  2410. }
  2411. for (ai = gai_ai; ai != NULL; ai = ai->ai_next) {
  2412. if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
  2413. continue;
  2414. err = getnameinfo(ai->ai_addr, ai->ai_addrlen, ntop,
  2415. sizeof(ntop), strport, sizeof(strport),
  2416. NI_NUMERICHOST|NI_NUMERICSERV);
  2417. if (ai->ai_family == AF_INET && err != 0) {
  2418. perror("getnameinfo");
  2419. exit(2);
  2420. }
  2421. }
  2422. exit(0);
  2423. ]])],
  2424. [
  2425. AC_MSG_RESULT([yes])
  2426. AC_DEFINE([AIX_GETNAMEINFO_HACK], [1],
  2427. [Define if you have a getaddrinfo that fails
  2428. for the all-zeros IPv6 address])
  2429. ],
  2430. [
  2431. AC_MSG_RESULT([no])
  2432. AC_DEFINE([BROKEN_GETADDRINFO])
  2433. ],
  2434. [
  2435. AC_MSG_RESULT([cross-compiling, assuming no])
  2436. ]
  2437. )
  2438. fi
  2439. if test "x$ac_cv_func_getaddrinfo" = "xyes"; then
  2440. AC_CHECK_DECLS(AI_NUMERICSERV, , ,
  2441. [#include <sys/types.h>
  2442. #include <sys/socket.h>
  2443. #include <netdb.h>])
  2444. fi
  2445. if test "x$check_for_conflicting_getspnam" = "x1"; then
  2446. AC_MSG_CHECKING([for conflicting getspnam in shadow.h])
  2447. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  2448. #include <shadow.h>
  2449. #include <stdlib.h>
  2450. ]],
  2451. [[ exit(0); ]])],
  2452. [
  2453. AC_MSG_RESULT([no])
  2454. ],
  2455. [
  2456. AC_MSG_RESULT([yes])
  2457. AC_DEFINE([GETSPNAM_CONFLICTING_DEFS], [1],
  2458. [Conflicting defs for getspnam])
  2459. ]
  2460. )
  2461. fi
  2462. dnl NetBSD added an strnvis and unfortunately made it incompatible with the
  2463. dnl existing one in OpenBSD and Linux's libbsd (the former having existed
  2464. dnl for over ten years). Despite this incompatibility being reported during
  2465. dnl development (see http://gnats.netbsd.org/44977) they still shipped it.
  2466. dnl Even more unfortunately FreeBSD and later MacOS picked up this incompatible
  2467. dnl implementation. Try to detect this mess, and assume the only safe option
  2468. dnl if we're cross compiling.
  2469. dnl
  2470. dnl OpenBSD, 2001: strnvis(char *dst, const char *src, size_t dlen, int flag);
  2471. dnl NetBSD: 2012, strnvis(char *dst, size_t dlen, const char *src, int flag);
  2472. if test "x$ac_cv_func_strnvis" = "xyes"; then
  2473. AC_MSG_CHECKING([for working strnvis])
  2474. AC_RUN_IFELSE(
  2475. [AC_LANG_PROGRAM([[
  2476. #include <signal.h>
  2477. #include <stdlib.h>
  2478. #include <string.h>
  2479. #include <unistd.h>
  2480. #include <vis.h>
  2481. static void sighandler(int sig) { _exit(1); }
  2482. ]], [[
  2483. char dst[16];
  2484. signal(SIGSEGV, sighandler);
  2485. if (strnvis(dst, "src", 4, 0) && strcmp(dst, "src") == 0)
  2486. exit(0);
  2487. exit(1)
  2488. ]])],
  2489. [AC_MSG_RESULT([yes])],
  2490. [AC_MSG_RESULT([no])
  2491. AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis detected broken])],
  2492. [AC_MSG_WARN([cross compiling: assuming broken])
  2493. AC_DEFINE([BROKEN_STRNVIS], [1], [strnvis assumed broken])]
  2494. )
  2495. fi
  2496. AC_MSG_CHECKING([if SA_RESTARTed signals interrupt select()])
  2497. AC_RUN_IFELSE(
  2498. [AC_LANG_PROGRAM([[
  2499. #ifdef HAVE_SYS_SELECT
  2500. # include <sys/select.h>
  2501. #endif
  2502. #include <sys/types.h>
  2503. #include <sys/time.h>
  2504. #include <stdlib.h>
  2505. #include <signal.h>
  2506. #include <unistd.h>
  2507. static void sighandler(int sig) { }
  2508. ]], [[
  2509. int r;
  2510. pid_t pid;
  2511. struct sigaction sa;
  2512. sa.sa_handler = sighandler;
  2513. sa.sa_flags = SA_RESTART;
  2514. (void)sigaction(SIGTERM, &sa, NULL);
  2515. if ((pid = fork()) == 0) { /* child */
  2516. pid = getppid();
  2517. sleep(1);
  2518. kill(pid, SIGTERM);
  2519. sleep(1);
  2520. if (getppid() == pid) /* if parent did not exit, shoot it */
  2521. kill(pid, SIGKILL);
  2522. exit(0);
  2523. } else { /* parent */
  2524. r = select(0, NULL, NULL, NULL, NULL);
  2525. }
  2526. exit(r == -1 ? 0 : 1);
  2527. ]])],
  2528. [AC_MSG_RESULT([yes])],
  2529. [AC_MSG_RESULT([no])
  2530. AC_DEFINE([NO_SA_RESTART], [1],
  2531. [SA_RESTARTed signals do no interrupt select])],
  2532. [AC_MSG_WARN([cross compiling: assuming yes])]
  2533. )
  2534. AC_CHECK_FUNCS([getpgrp],[
  2535. AC_MSG_CHECKING([if getpgrp accepts zero args])
  2536. AC_COMPILE_IFELSE(
  2537. [AC_LANG_PROGRAM([[$ac_includes_default]], [[ getpgrp(); ]])],
  2538. [ AC_MSG_RESULT([yes])
  2539. AC_DEFINE([GETPGRP_VOID], [1], [getpgrp takes zero args])],
  2540. [ AC_MSG_RESULT([no])
  2541. AC_DEFINE([GETPGRP_VOID], [0], [getpgrp takes one arg])]
  2542. )
  2543. ])
  2544. # Search for OpenSSL
  2545. saved_CPPFLAGS="$CPPFLAGS"
  2546. saved_LDFLAGS="$LDFLAGS"
  2547. AC_ARG_WITH([ssl-dir],
  2548. [ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
  2549. [
  2550. if test "x$openssl" = "xno" ; then
  2551. AC_MSG_ERROR([cannot use --with-ssl-dir when OpenSSL disabled])
  2552. fi
  2553. if test "x$withval" != "xno" ; then
  2554. case "$withval" in
  2555. # Relative paths
  2556. ./*|../*) withval="`pwd`/$withval"
  2557. esac
  2558. if test -d "$withval/lib"; then
  2559. if test -n "${rpath_opt}"; then
  2560. LDFLAGS="-L${withval}/lib ${rpath_opt}${withval}/lib ${LDFLAGS}"
  2561. else
  2562. LDFLAGS="-L${withval}/lib ${LDFLAGS}"
  2563. fi
  2564. elif test -d "$withval/lib64"; then
  2565. if test -n "${rpath_opt}"; then
  2566. LDFLAGS="-L${withval}/lib64 ${rpath_opt}${withval}/lib64 ${LDFLAGS}"
  2567. else
  2568. LDFLAGS="-L${withval}/lib64 ${LDFLAGS}"
  2569. fi
  2570. else
  2571. if test -n "${rpath_opt}"; then
  2572. LDFLAGS="-L${withval} ${rpath_opt}${withval} ${LDFLAGS}"
  2573. else
  2574. LDFLAGS="-L${withval} ${LDFLAGS}"
  2575. fi
  2576. fi
  2577. if test -d "$withval/include"; then
  2578. CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
  2579. else
  2580. CPPFLAGS="-I${withval} ${CPPFLAGS}"
  2581. fi
  2582. fi
  2583. ]
  2584. )
  2585. AC_ARG_WITH([openssl-header-check],
  2586. [ --without-openssl-header-check Disable OpenSSL version consistency check],
  2587. [
  2588. if test "x$withval" = "xno" ; then
  2589. openssl_check_nonfatal=1
  2590. fi
  2591. ]
  2592. )
  2593. openssl_engine=no
  2594. AC_ARG_WITH([ssl-engine],
  2595. [ --with-ssl-engine Enable OpenSSL (hardware) ENGINE support ],
  2596. [
  2597. if test "x$withval" != "xno" ; then
  2598. if test "x$openssl" = "xno" ; then
  2599. AC_MSG_ERROR([cannot use --with-ssl-engine when OpenSSL disabled])
  2600. fi
  2601. openssl_engine=yes
  2602. fi
  2603. ]
  2604. )
  2605. if test "x$openssl" = "xyes" ; then
  2606. LIBS="-lcrypto $LIBS"
  2607. AC_TRY_LINK_FUNC([RAND_add], ,
  2608. [AC_MSG_ERROR([*** working libcrypto not found, check config.log])])
  2609. AC_CHECK_HEADER([openssl/opensslv.h], ,
  2610. [AC_MSG_ERROR([*** OpenSSL headers missing - please install first or check config.log ***])])
  2611. # Determine OpenSSL header version
  2612. AC_MSG_CHECKING([OpenSSL header version])
  2613. AC_RUN_IFELSE(
  2614. [AC_LANG_PROGRAM([[
  2615. #include <stdlib.h>
  2616. #include <stdio.h>
  2617. #include <string.h>
  2618. #include <openssl/opensslv.h>
  2619. #define DATA "conftest.sslincver"
  2620. ]], [[
  2621. FILE *fd;
  2622. int rc;
  2623. fd = fopen(DATA,"w");
  2624. if(fd == NULL)
  2625. exit(1);
  2626. if ((rc = fprintf(fd, "%08lx (%s)\n",
  2627. (unsigned long)OPENSSL_VERSION_NUMBER,
  2628. OPENSSL_VERSION_TEXT)) < 0)
  2629. exit(1);
  2630. exit(0);
  2631. ]])],
  2632. [
  2633. ssl_header_ver=`cat conftest.sslincver`
  2634. AC_MSG_RESULT([$ssl_header_ver])
  2635. ],
  2636. [
  2637. AC_MSG_RESULT([not found])
  2638. AC_MSG_ERROR([OpenSSL version header not found.])
  2639. ],
  2640. [
  2641. AC_MSG_WARN([cross compiling: not checking])
  2642. ]
  2643. )
  2644. # Determining OpenSSL library version is version dependent.
  2645. AC_CHECK_FUNCS([OpenSSL_version OpenSSL_version_num])
  2646. # Determine OpenSSL library version
  2647. AC_MSG_CHECKING([OpenSSL library version])
  2648. AC_RUN_IFELSE(
  2649. [AC_LANG_PROGRAM([[
  2650. #include <stdio.h>
  2651. #include <stdlib.h>
  2652. #include <string.h>
  2653. #include <openssl/opensslv.h>
  2654. #include <openssl/crypto.h>
  2655. #define DATA "conftest.ssllibver"
  2656. ]], [[
  2657. FILE *fd;
  2658. int rc;
  2659. fd = fopen(DATA,"w");
  2660. if(fd == NULL)
  2661. exit(1);
  2662. #ifndef OPENSSL_VERSION
  2663. # define OPENSSL_VERSION SSLEAY_VERSION
  2664. #endif
  2665. #ifndef HAVE_OPENSSL_VERSION
  2666. # define OpenSSL_version SSLeay_version
  2667. #endif
  2668. #ifndef HAVE_OPENSSL_VERSION_NUM
  2669. # define OpenSSL_version_num SSLeay
  2670. #endif
  2671. if ((rc = fprintf(fd, "%08lx (%s)\n",
  2672. (unsigned long)OpenSSL_version_num(),
  2673. OpenSSL_version(OPENSSL_VERSION))) < 0)
  2674. exit(1);
  2675. exit(0);
  2676. ]])],
  2677. [
  2678. ssl_library_ver=`cat conftest.ssllibver`
  2679. # Check version is supported.
  2680. case "$ssl_library_ver" in
  2681. 10000*|0*)
  2682. AC_MSG_ERROR([OpenSSL >= 1.0.1 required (have "$ssl_library_ver")])
  2683. ;;
  2684. 100*) ;; # 1.0.x
  2685. 101000[[0123456]]*)
  2686. # https://github.com/openssl/openssl/pull/4613
  2687. AC_MSG_ERROR([OpenSSL 1.1.x versions prior to 1.1.0g have a bug that breaks their use with OpenSSH (have "$ssl_library_ver")])
  2688. ;;
  2689. 101*) ;; # 1.1.x
  2690. 200*) ;; # LibreSSL
  2691. 300*) ;; # OpenSSL development branch.
  2692. *)
  2693. AC_MSG_ERROR([Unknown/unsupported OpenSSL version ("$ssl_library_ver")])
  2694. ;;
  2695. esac
  2696. AC_MSG_RESULT([$ssl_library_ver])
  2697. ],
  2698. [
  2699. AC_MSG_RESULT([not found])
  2700. AC_MSG_ERROR([OpenSSL library not found.])
  2701. ],
  2702. [
  2703. AC_MSG_WARN([cross compiling: not checking])
  2704. ]
  2705. )
  2706. # Sanity check OpenSSL headers
  2707. AC_MSG_CHECKING([whether OpenSSL's headers match the library])
  2708. AC_RUN_IFELSE(
  2709. [AC_LANG_PROGRAM([[
  2710. #include <stdlib.h>
  2711. #include <string.h>
  2712. #include <openssl/opensslv.h>
  2713. #include <openssl/crypto.h>
  2714. ]], [[
  2715. #ifndef HAVE_OPENSSL_VERSION_NUM
  2716. # define OpenSSL_version_num SSLeay
  2717. #endif
  2718. exit(OpenSSL_version_num() == OPENSSL_VERSION_NUMBER ? 0 : 1);
  2719. ]])],
  2720. [
  2721. AC_MSG_RESULT([yes])
  2722. ],
  2723. [
  2724. AC_MSG_RESULT([no])
  2725. if test "x$openssl_check_nonfatal" = "x"; then
  2726. AC_MSG_ERROR([Your OpenSSL headers do not match your
  2727. library. Check config.log for details.
  2728. If you are sure your installation is consistent, you can disable the check
  2729. by running "./configure --without-openssl-header-check".
  2730. Also see contrib/findssl.sh for help identifying header/library mismatches.
  2731. ])
  2732. else
  2733. AC_MSG_WARN([Your OpenSSL headers do not match your
  2734. library. Check config.log for details.
  2735. Also see contrib/findssl.sh for help identifying header/library mismatches.])
  2736. fi
  2737. ],
  2738. [
  2739. AC_MSG_WARN([cross compiling: not checking])
  2740. ]
  2741. )
  2742. AC_MSG_CHECKING([if programs using OpenSSL functions will link])
  2743. AC_LINK_IFELSE(
  2744. [AC_LANG_PROGRAM([[ #include <openssl/err.h> ]],
  2745. [[ ERR_load_crypto_strings(); ]])],
  2746. [
  2747. AC_MSG_RESULT([yes])
  2748. ],
  2749. [
  2750. AC_MSG_RESULT([no])
  2751. saved_LIBS="$LIBS"
  2752. LIBS="$LIBS -ldl"
  2753. AC_MSG_CHECKING([if programs using OpenSSL need -ldl])
  2754. AC_LINK_IFELSE(
  2755. [AC_LANG_PROGRAM([[ #include <openssl/err.h> ]],
  2756. [[ ERR_load_crypto_strings(); ]])],
  2757. [
  2758. AC_MSG_RESULT([yes])
  2759. ],
  2760. [
  2761. AC_MSG_RESULT([no])
  2762. LIBS="$saved_LIBS"
  2763. ]
  2764. )
  2765. ]
  2766. )
  2767. AC_CHECK_FUNCS([ \
  2768. BN_is_prime_ex \
  2769. DSA_generate_parameters_ex \
  2770. EVP_CIPHER_CTX_ctrl \
  2771. EVP_DigestFinal_ex \
  2772. EVP_DigestInit_ex \
  2773. EVP_MD_CTX_cleanup \
  2774. EVP_MD_CTX_copy_ex \
  2775. EVP_MD_CTX_init \
  2776. HMAC_CTX_init \
  2777. RSA_generate_key_ex \
  2778. RSA_get_default_method \
  2779. EVP_KDF_CTX_new_id \
  2780. ])
  2781. # OpenSSL_add_all_algorithms may be a macro.
  2782. AC_CHECK_FUNC(OpenSSL_add_all_algorithms,
  2783. AC_DEFINE(HAVE_OPENSSL_ADD_ALL_ALGORITHMS, 1, [as a function]),
  2784. AC_CHECK_DECL(OpenSSL_add_all_algorithms,
  2785. AC_DEFINE(HAVE_OPENSSL_ADD_ALL_ALGORITHMS, 1, [as a macro]), ,
  2786. [[#include <openssl/evp.h>]]
  2787. )
  2788. )
  2789. # LibreSSL/OpenSSL 1.1x API
  2790. AC_CHECK_FUNCS([ \
  2791. OPENSSL_init_crypto \
  2792. DH_get0_key \
  2793. DH_get0_pqg \
  2794. DH_set0_key \
  2795. DH_set_length \
  2796. DH_set0_pqg \
  2797. DSA_get0_key \
  2798. DSA_get0_pqg \
  2799. DSA_set0_key \
  2800. DSA_set0_pqg \
  2801. DSA_SIG_get0 \
  2802. DSA_SIG_set0 \
  2803. ECDSA_SIG_get0 \
  2804. ECDSA_SIG_set0 \
  2805. EVP_CIPHER_CTX_iv \
  2806. EVP_CIPHER_CTX_iv_noconst \
  2807. EVP_CIPHER_CTX_get_iv \
  2808. EVP_CIPHER_CTX_get_updated_iv \
  2809. EVP_CIPHER_CTX_set_iv \
  2810. RSA_get0_crt_params \
  2811. RSA_get0_factors \
  2812. RSA_get0_key \
  2813. RSA_set0_crt_params \
  2814. RSA_set0_factors \
  2815. RSA_set0_key \
  2816. RSA_meth_free \
  2817. RSA_meth_dup \
  2818. RSA_meth_set1_name \
  2819. RSA_meth_get_finish \
  2820. RSA_meth_set_priv_enc \
  2821. RSA_meth_set_priv_dec \
  2822. RSA_meth_set_finish \
  2823. EVP_PKEY_get0_RSA \
  2824. EVP_MD_CTX_new \
  2825. EVP_MD_CTX_free \
  2826. EVP_chacha20 \
  2827. ])
  2828. if test "x$openssl_engine" = "xyes" ; then
  2829. AC_MSG_CHECKING([for OpenSSL ENGINE support])
  2830. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  2831. #include <openssl/engine.h>
  2832. ]], [[
  2833. ENGINE_load_builtin_engines();
  2834. ENGINE_register_all_complete();
  2835. ]])],
  2836. [ AC_MSG_RESULT([yes])
  2837. AC_DEFINE([USE_OPENSSL_ENGINE], [1],
  2838. [Enable OpenSSL engine support])
  2839. ], [ AC_MSG_ERROR([OpenSSL ENGINE support not found])
  2840. ])
  2841. fi
  2842. # Check for OpenSSL without EVP_aes_{192,256}_cbc
  2843. AC_MSG_CHECKING([whether OpenSSL has broken AES support])
  2844. AC_LINK_IFELSE(
  2845. [AC_LANG_PROGRAM([[
  2846. #include <stdlib.h>
  2847. #include <string.h>
  2848. #include <openssl/evp.h>
  2849. ]], [[
  2850. exit(EVP_aes_192_cbc() == NULL || EVP_aes_256_cbc() == NULL);
  2851. ]])],
  2852. [
  2853. AC_MSG_RESULT([no])
  2854. ],
  2855. [
  2856. AC_MSG_RESULT([yes])
  2857. AC_DEFINE([OPENSSL_LOBOTOMISED_AES], [1],
  2858. [libcrypto is missing AES 192 and 256 bit functions])
  2859. ]
  2860. )
  2861. # Check for OpenSSL with EVP_aes_*ctr
  2862. AC_MSG_CHECKING([whether OpenSSL has AES CTR via EVP])
  2863. AC_LINK_IFELSE(
  2864. [AC_LANG_PROGRAM([[
  2865. #include <stdlib.h>
  2866. #include <string.h>
  2867. #include <openssl/evp.h>
  2868. ]], [[
  2869. exit(EVP_aes_128_ctr() == NULL ||
  2870. EVP_aes_192_cbc() == NULL ||
  2871. EVP_aes_256_cbc() == NULL);
  2872. ]])],
  2873. [
  2874. AC_MSG_RESULT([yes])
  2875. AC_DEFINE([OPENSSL_HAVE_EVPCTR], [1],
  2876. [libcrypto has EVP AES CTR])
  2877. ],
  2878. [
  2879. AC_MSG_RESULT([no])
  2880. ]
  2881. )
  2882. # Check for OpenSSL with EVP_aes_*gcm
  2883. AC_MSG_CHECKING([whether OpenSSL has AES GCM via EVP])
  2884. AC_LINK_IFELSE(
  2885. [AC_LANG_PROGRAM([[
  2886. #include <stdlib.h>
  2887. #include <string.h>
  2888. #include <openssl/evp.h>
  2889. ]], [[
  2890. exit(EVP_aes_128_gcm() == NULL ||
  2891. EVP_aes_256_gcm() == NULL ||
  2892. EVP_CTRL_GCM_SET_IV_FIXED == 0 ||
  2893. EVP_CTRL_GCM_IV_GEN == 0 ||
  2894. EVP_CTRL_GCM_SET_TAG == 0 ||
  2895. EVP_CTRL_GCM_GET_TAG == 0 ||
  2896. EVP_CIPHER_CTX_ctrl(NULL, 0, 0, NULL) == 0);
  2897. ]])],
  2898. [
  2899. AC_MSG_RESULT([yes])
  2900. AC_DEFINE([OPENSSL_HAVE_EVPGCM], [1],
  2901. [libcrypto has EVP AES GCM])
  2902. ],
  2903. [
  2904. AC_MSG_RESULT([no])
  2905. unsupported_algorithms="$unsupported_cipers \
  2906. aes128-gcm@openssh.com \
  2907. aes256-gcm@openssh.com"
  2908. ]
  2909. )
  2910. AC_MSG_CHECKING([if EVP_DigestUpdate returns an int])
  2911. AC_LINK_IFELSE(
  2912. [AC_LANG_PROGRAM([[
  2913. #include <stdlib.h>
  2914. #include <string.h>
  2915. #include <openssl/evp.h>
  2916. ]], [[
  2917. if(EVP_DigestUpdate(NULL, NULL,0))
  2918. exit(0);
  2919. ]])],
  2920. [
  2921. AC_MSG_RESULT([yes])
  2922. ],
  2923. [
  2924. AC_MSG_RESULT([no])
  2925. AC_DEFINE([OPENSSL_EVP_DIGESTUPDATE_VOID], [1],
  2926. [Define if EVP_DigestUpdate returns void])
  2927. ]
  2928. )
  2929. # Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
  2930. # because the system crypt() is more featureful.
  2931. if test "x$check_for_libcrypt_before" = "x1"; then
  2932. AC_CHECK_LIB([crypt], [crypt])
  2933. fi
  2934. # Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
  2935. # version in OpenSSL.
  2936. if test "x$check_for_libcrypt_later" = "x1"; then
  2937. AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
  2938. fi
  2939. AC_CHECK_FUNCS([crypt DES_crypt])
  2940. # Check for SHA256, SHA384 and SHA512 support in OpenSSL
  2941. AC_CHECK_FUNCS([EVP_sha256 EVP_sha384 EVP_sha512])
  2942. # Check complete ECC support in OpenSSL
  2943. AC_MSG_CHECKING([whether OpenSSL has NID_X9_62_prime256v1])
  2944. AC_LINK_IFELSE(
  2945. [AC_LANG_PROGRAM([[
  2946. #include <openssl/ec.h>
  2947. #include <openssl/ecdh.h>
  2948. #include <openssl/ecdsa.h>
  2949. #include <openssl/evp.h>
  2950. #include <openssl/objects.h>
  2951. #include <openssl/opensslv.h>
  2952. ]], [[
  2953. EC_KEY *e = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
  2954. const EVP_MD *m = EVP_sha256(); /* We need this too */
  2955. ]])],
  2956. [ AC_MSG_RESULT([yes])
  2957. enable_nistp256=1 ],
  2958. [ AC_MSG_RESULT([no]) ]
  2959. )
  2960. AC_MSG_CHECKING([whether OpenSSL has NID_secp384r1])
  2961. AC_LINK_IFELSE(
  2962. [AC_LANG_PROGRAM([[
  2963. #include <openssl/ec.h>
  2964. #include <openssl/ecdh.h>
  2965. #include <openssl/ecdsa.h>
  2966. #include <openssl/evp.h>
  2967. #include <openssl/objects.h>
  2968. #include <openssl/opensslv.h>
  2969. ]], [[
  2970. EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp384r1);
  2971. const EVP_MD *m = EVP_sha384(); /* We need this too */
  2972. ]])],
  2973. [ AC_MSG_RESULT([yes])
  2974. enable_nistp384=1 ],
  2975. [ AC_MSG_RESULT([no]) ]
  2976. )
  2977. AC_MSG_CHECKING([whether OpenSSL has NID_secp521r1])
  2978. AC_LINK_IFELSE(
  2979. [AC_LANG_PROGRAM([[
  2980. #include <openssl/ec.h>
  2981. #include <openssl/ecdh.h>
  2982. #include <openssl/ecdsa.h>
  2983. #include <openssl/evp.h>
  2984. #include <openssl/objects.h>
  2985. #include <openssl/opensslv.h>
  2986. ]], [[
  2987. EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
  2988. const EVP_MD *m = EVP_sha512(); /* We need this too */
  2989. ]])],
  2990. [ AC_MSG_RESULT([yes])
  2991. AC_MSG_CHECKING([if OpenSSL's NID_secp521r1 is functional])
  2992. AC_RUN_IFELSE(
  2993. [AC_LANG_PROGRAM([[
  2994. #include <stdlib.h>
  2995. #include <openssl/ec.h>
  2996. #include <openssl/ecdh.h>
  2997. #include <openssl/ecdsa.h>
  2998. #include <openssl/evp.h>
  2999. #include <openssl/objects.h>
  3000. #include <openssl/opensslv.h>
  3001. ]],[[
  3002. EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1);
  3003. const EVP_MD *m = EVP_sha512(); /* We need this too */
  3004. exit(e == NULL || m == NULL);
  3005. ]])],
  3006. [ AC_MSG_RESULT([yes])
  3007. enable_nistp521=1 ],
  3008. [ AC_MSG_RESULT([no]) ],
  3009. [ AC_MSG_WARN([cross-compiling: assuming yes])
  3010. enable_nistp521=1 ]
  3011. )],
  3012. AC_MSG_RESULT([no])
  3013. )
  3014. COMMENT_OUT_ECC="#no ecc#"
  3015. TEST_SSH_ECC=no
  3016. if test x$enable_nistp256 = x1 || test x$enable_nistp384 = x1 || \
  3017. test x$enable_nistp521 = x1; then
  3018. AC_DEFINE(OPENSSL_HAS_ECC, [1], [OpenSSL has ECC])
  3019. AC_CHECK_FUNCS([EC_KEY_METHOD_new])
  3020. openssl_ecc=yes
  3021. else
  3022. openssl_ecc=no
  3023. fi
  3024. if test x$enable_nistp256 = x1; then
  3025. AC_DEFINE([OPENSSL_HAS_NISTP256], [1],
  3026. [libcrypto has NID_X9_62_prime256v1])
  3027. TEST_SSH_ECC=yes
  3028. COMMENT_OUT_ECC=""
  3029. else
  3030. unsupported_algorithms="$unsupported_algorithms \
  3031. ecdsa-sha2-nistp256 \
  3032. ecdh-sha2-nistp256 \
  3033. ecdsa-sha2-nistp256-cert-v01@openssh.com"
  3034. fi
  3035. if test x$enable_nistp384 = x1; then
  3036. AC_DEFINE([OPENSSL_HAS_NISTP384], [1], [libcrypto has NID_secp384r1])
  3037. TEST_SSH_ECC=yes
  3038. COMMENT_OUT_ECC=""
  3039. else
  3040. unsupported_algorithms="$unsupported_algorithms \
  3041. ecdsa-sha2-nistp384 \
  3042. ecdh-sha2-nistp384 \
  3043. ecdsa-sha2-nistp384-cert-v01@openssh.com"
  3044. fi
  3045. if test x$enable_nistp521 = x1; then
  3046. AC_DEFINE([OPENSSL_HAS_NISTP521], [1], [libcrypto has NID_secp521r1])
  3047. TEST_SSH_ECC=yes
  3048. COMMENT_OUT_ECC=""
  3049. else
  3050. unsupported_algorithms="$unsupported_algorithms \
  3051. ecdh-sha2-nistp521 \
  3052. ecdsa-sha2-nistp521 \
  3053. ecdsa-sha2-nistp521-cert-v01@openssh.com"
  3054. fi
  3055. AC_SUBST([TEST_SSH_ECC])
  3056. AC_SUBST([COMMENT_OUT_ECC])
  3057. else
  3058. AC_CHECK_LIB([crypt], [crypt], [LIBS="$LIBS -lcrypt"])
  3059. AC_CHECK_FUNCS([crypt])
  3060. fi
  3061. # PKCS11/U2F depend on OpenSSL and dlopen().
  3062. enable_pkcs11=yes
  3063. enable_sk=yes
  3064. if test "x$openssl" != "xyes" ; then
  3065. enable_pkcs11="disabled; missing libcrypto"
  3066. enable_sk="disabled; missing libcrypto"
  3067. fi
  3068. if test "x$openssl_ecc" != "xyes" ; then
  3069. enable_sk="disabled; OpenSSL has no ECC support"
  3070. fi
  3071. if test "x$ac_cv_func_dlopen" != "xyes" ; then
  3072. enable_pkcs11="disabled; missing dlopen(3)"
  3073. enable_sk="disabled; missing dlopen(3)"
  3074. fi
  3075. if test "x$ac_cv_have_decl_RTLD_NOW" != "xyes" ; then
  3076. enable_pkcs11="disabled; missing RTLD_NOW"
  3077. enable_sk="disabled; missing RTLD_NOW"
  3078. fi
  3079. if test ! -z "$disable_pkcs11" ; then
  3080. enable_pkcs11="disabled by user"
  3081. fi
  3082. if test ! -z "$disable_sk" ; then
  3083. enable_sk="disabled by user"
  3084. fi
  3085. AC_MSG_CHECKING([whether to enable PKCS11])
  3086. if test "x$enable_pkcs11" = "xyes" ; then
  3087. AC_DEFINE([ENABLE_PKCS11], [], [Enable for PKCS#11 support])
  3088. fi
  3089. AC_MSG_RESULT([$enable_pkcs11])
  3090. AC_MSG_CHECKING([whether to enable U2F])
  3091. if test "x$enable_sk" = "xyes" ; then
  3092. AC_DEFINE([ENABLE_SK], [], [Enable for U2F/FIDO support])
  3093. AC_SUBST(SK_DUMMY_LIBRARY, [regress/misc/sk-dummy/sk-dummy.so])
  3094. else
  3095. # Do not try to build sk-dummy library.
  3096. AC_SUBST(SK_DUMMY_LIBRARY, [""])
  3097. fi
  3098. AC_MSG_RESULT([$enable_sk])
  3099. # Now check for built-in security key support.
  3100. if test "x$enable_sk" = "xyes" -a "x$enable_sk_internal" = "xyes" ; then
  3101. AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
  3102. use_pkgconfig_for_libfido2=
  3103. if test "x$PKGCONFIG" != "xno"; then
  3104. AC_MSG_CHECKING([if $PKGCONFIG knows about libfido2])
  3105. if "$PKGCONFIG" libfido2; then
  3106. AC_MSG_RESULT([yes])
  3107. use_pkgconfig_for_libfido2=yes
  3108. else
  3109. AC_MSG_RESULT([no])
  3110. fi
  3111. fi
  3112. if test "x$use_pkgconfig_for_libfido2" = "xyes"; then
  3113. LIBFIDO2=`$PKGCONFIG --libs libfido2`
  3114. CPPFLAGS="$CPPFLAGS `$PKGCONFIG --cflags libfido2`"
  3115. else
  3116. LIBFIDO2="-lfido2 -lcbor"
  3117. fi
  3118. OTHERLIBS=`echo $LIBFIDO2 | sed 's/-lfido2//'`
  3119. AC_CHECK_LIB([fido2], [fido_init],
  3120. [
  3121. AC_SUBST([LIBFIDO2])
  3122. AC_DEFINE([ENABLE_SK_INTERNAL], [],
  3123. [Enable for built-in U2F/FIDO support])
  3124. enable_sk="built-in"
  3125. ], [ AC_MSG_ERROR([no usable libfido2 found]) ],
  3126. [ $OTHERLIBS ]
  3127. )
  3128. saved_LIBS="$LIBS"
  3129. LIBS="$LIBS $LIBFIDO2"
  3130. AC_CHECK_FUNCS([ \
  3131. fido_cred_prot \
  3132. fido_cred_set_prot \
  3133. fido_dev_get_touch_begin \
  3134. fido_dev_get_touch_status \
  3135. fido_dev_supports_cred_prot \
  3136. ])
  3137. LIBS="$saved_LIBS"
  3138. AC_CHECK_HEADER([fido.h], [],
  3139. AC_MSG_ERROR([missing fido.h from libfido2]))
  3140. AC_CHECK_HEADER([fido/credman.h], [],
  3141. AC_MSG_ERROR([missing fido/credman.h from libfido2]),
  3142. [#include <fido.h>]
  3143. )
  3144. fi
  3145. AC_CHECK_FUNCS([ \
  3146. arc4random \
  3147. arc4random_buf \
  3148. arc4random_stir \
  3149. arc4random_uniform \
  3150. ])
  3151. saved_LIBS="$LIBS"
  3152. AC_CHECK_LIB([iaf], [ia_openinfo], [
  3153. LIBS="$LIBS -liaf"
  3154. AC_CHECK_FUNCS([set_id], [SSHDLIBS="$SSHDLIBS -liaf"
  3155. AC_DEFINE([HAVE_LIBIAF], [1],
  3156. [Define if system has libiaf that supports set_id])
  3157. ])
  3158. ])
  3159. LIBS="$saved_LIBS"
  3160. ### Configure cryptographic random number support
  3161. # Check whether OpenSSL seeds itself
  3162. if test "x$openssl" = "xyes" ; then
  3163. AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
  3164. AC_RUN_IFELSE(
  3165. [AC_LANG_PROGRAM([[
  3166. #include <stdlib.h>
  3167. #include <string.h>
  3168. #include <openssl/rand.h>
  3169. ]], [[
  3170. exit(RAND_status() == 1 ? 0 : 1);
  3171. ]])],
  3172. [
  3173. OPENSSL_SEEDS_ITSELF=yes
  3174. AC_MSG_RESULT([yes])
  3175. ],
  3176. [
  3177. AC_MSG_RESULT([no])
  3178. ],
  3179. [
  3180. AC_MSG_WARN([cross compiling: assuming yes])
  3181. # This is safe, since we will fatal() at runtime if
  3182. # OpenSSL is not seeded correctly.
  3183. OPENSSL_SEEDS_ITSELF=yes
  3184. ]
  3185. )
  3186. fi
  3187. # PRNGD TCP socket
  3188. AC_ARG_WITH([prngd-port],
  3189. [ --with-prngd-port=PORT read entropy from PRNGD/EGD TCP localhost:PORT],
  3190. [
  3191. case "$withval" in
  3192. no)
  3193. withval=""
  3194. ;;
  3195. [[0-9]]*)
  3196. ;;
  3197. *)
  3198. AC_MSG_ERROR([You must specify a numeric port number for --with-prngd-port])
  3199. ;;
  3200. esac
  3201. if test ! -z "$withval" ; then
  3202. PRNGD_PORT="$withval"
  3203. AC_DEFINE_UNQUOTED([PRNGD_PORT], [$PRNGD_PORT],
  3204. [Port number of PRNGD/EGD random number socket])
  3205. fi
  3206. ]
  3207. )
  3208. # PRNGD Unix domain socket
  3209. AC_ARG_WITH([prngd-socket],
  3210. [ --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
  3211. [
  3212. case "$withval" in
  3213. yes)
  3214. withval="/var/run/egd-pool"
  3215. ;;
  3216. no)
  3217. withval=""
  3218. ;;
  3219. /*)
  3220. ;;
  3221. *)
  3222. AC_MSG_ERROR([You must specify an absolute path to the entropy socket])
  3223. ;;
  3224. esac
  3225. if test ! -z "$withval" ; then
  3226. if test ! -z "$PRNGD_PORT" ; then
  3227. AC_MSG_ERROR([You may not specify both a PRNGD/EGD port and socket])
  3228. fi
  3229. if test ! -r "$withval" ; then
  3230. AC_MSG_WARN([Entropy socket is not readable])
  3231. fi
  3232. PRNGD_SOCKET="$withval"
  3233. AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"],
  3234. [Location of PRNGD/EGD random number socket])
  3235. fi
  3236. ],
  3237. [
  3238. # Check for existing socket only if we don't have a random device already
  3239. if test "x$OPENSSL_SEEDS_ITSELF" != "xyes" ; then
  3240. AC_MSG_CHECKING([for PRNGD/EGD socket])
  3241. # Insert other locations here
  3242. for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
  3243. if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
  3244. PRNGD_SOCKET="$sock"
  3245. AC_DEFINE_UNQUOTED([PRNGD_SOCKET], ["$PRNGD_SOCKET"])
  3246. break;
  3247. fi
  3248. done
  3249. if test ! -z "$PRNGD_SOCKET" ; then
  3250. AC_MSG_RESULT([$PRNGD_SOCKET])
  3251. else
  3252. AC_MSG_RESULT([not found])
  3253. fi
  3254. fi
  3255. ]
  3256. )
  3257. # Which randomness source do we use?
  3258. if test ! -z "$PRNGD_PORT" ; then
  3259. RAND_MSG="PRNGd port $PRNGD_PORT"
  3260. elif test ! -z "$PRNGD_SOCKET" ; then
  3261. RAND_MSG="PRNGd socket $PRNGD_SOCKET"
  3262. elif test ! -z "$OPENSSL_SEEDS_ITSELF" ; then
  3263. AC_DEFINE([OPENSSL_PRNG_ONLY], [1],
  3264. [Define if you want the OpenSSL internally seeded PRNG only])
  3265. RAND_MSG="OpenSSL internal ONLY"
  3266. elif test "x$openssl" = "xno" ; then
  3267. AC_MSG_WARN([OpenSSH will use /dev/urandom as a source of random numbers. It will fail if this device is not supported or accessible])
  3268. else
  3269. AC_MSG_ERROR([OpenSSH has no source of random numbers. Please configure OpenSSL with an entropy source or re-run configure using one of the --with-prngd-port or --with-prngd-socket options])
  3270. fi
  3271. # Check for PAM libs
  3272. PAM_MSG="no"
  3273. AC_ARG_WITH([pam],
  3274. [ --with-pam Enable PAM support ],
  3275. [
  3276. if test "x$withval" != "xno" ; then
  3277. if test "x$ac_cv_header_security_pam_appl_h" != "xyes" && \
  3278. test "x$ac_cv_header_pam_pam_appl_h" != "xyes" ; then
  3279. AC_MSG_ERROR([PAM headers not found])
  3280. fi
  3281. saved_LIBS="$LIBS"
  3282. AC_CHECK_LIB([dl], [dlopen], , )
  3283. AC_CHECK_LIB([pam], [pam_set_item], , [AC_MSG_ERROR([*** libpam missing])])
  3284. AC_CHECK_FUNCS([pam_getenvlist])
  3285. AC_CHECK_FUNCS([pam_putenv])
  3286. LIBS="$saved_LIBS"
  3287. PAM_MSG="yes"
  3288. SSHDLIBS="$SSHDLIBS -lpam"
  3289. KEYCATLIBS="$KEYCATLIBS -lpam"
  3290. AC_DEFINE([USE_PAM], [1],
  3291. [Define if you want to enable PAM support])
  3292. if test $ac_cv_lib_dl_dlopen = yes; then
  3293. case "$LIBS" in
  3294. *-ldl*)
  3295. # libdl already in LIBS
  3296. ;;
  3297. *)
  3298. SSHDLIBS="$SSHDLIBS -ldl"
  3299. KEYCATLIBS="$KEYCATLIBS -ldl"
  3300. ;;
  3301. esac
  3302. fi
  3303. fi
  3304. ]
  3305. )
  3306. AC_ARG_WITH([pam-service],
  3307. [ --with-pam-service=name Specify PAM service name ],
  3308. [
  3309. if test "x$withval" != "xno" && \
  3310. test "x$withval" != "xyes" ; then
  3311. AC_DEFINE_UNQUOTED([SSHD_PAM_SERVICE],
  3312. ["$withval"], [sshd PAM service name])
  3313. fi
  3314. ]
  3315. )
  3316. # Check for older PAM
  3317. if test "x$PAM_MSG" = "xyes" ; then
  3318. # Check PAM strerror arguments (old PAM)
  3319. AC_MSG_CHECKING([whether pam_strerror takes only one argument])
  3320. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  3321. #include <stdlib.h>
  3322. #if defined(HAVE_SECURITY_PAM_APPL_H)
  3323. #include <security/pam_appl.h>
  3324. #elif defined (HAVE_PAM_PAM_APPL_H)
  3325. #include <pam/pam_appl.h>
  3326. #endif
  3327. ]], [[
  3328. (void)pam_strerror((pam_handle_t *)NULL, -1);
  3329. ]])], [AC_MSG_RESULT([no])], [
  3330. AC_DEFINE([HAVE_OLD_PAM], [1],
  3331. [Define if you have an old version of PAM
  3332. which takes only one argument to pam_strerror])
  3333. AC_MSG_RESULT([yes])
  3334. PAM_MSG="yes (old library)"
  3335. ])
  3336. fi
  3337. case "$host" in
  3338. *-*-cygwin*)
  3339. SSH_PRIVSEP_USER=CYGWIN_SSH_PRIVSEP_USER
  3340. ;;
  3341. *)
  3342. SSH_PRIVSEP_USER=sshd
  3343. ;;
  3344. esac
  3345. AC_ARG_WITH([privsep-user],
  3346. [ --with-privsep-user=user Specify non-privileged user for privilege separation],
  3347. [
  3348. if test -n "$withval" && test "x$withval" != "xno" && \
  3349. test "x${withval}" != "xyes"; then
  3350. SSH_PRIVSEP_USER=$withval
  3351. fi
  3352. ]
  3353. )
  3354. if test "x$SSH_PRIVSEP_USER" = "xCYGWIN_SSH_PRIVSEP_USER" ; then
  3355. AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], [CYGWIN_SSH_PRIVSEP_USER],
  3356. [Cygwin function to fetch non-privileged user for privilege separation])
  3357. else
  3358. AC_DEFINE_UNQUOTED([SSH_PRIVSEP_USER], ["$SSH_PRIVSEP_USER"],
  3359. [non-privileged user for privilege separation])
  3360. fi
  3361. AC_SUBST([SSH_PRIVSEP_USER])
  3362. if test "x$have_linux_no_new_privs" = "x1" ; then
  3363. AC_CHECK_DECL([SECCOMP_MODE_FILTER], [have_seccomp_filter=1], , [
  3364. #include <sys/types.h>
  3365. #include <linux/seccomp.h>
  3366. ])
  3367. fi
  3368. if test "x$have_seccomp_filter" = "x1" ; then
  3369. AC_MSG_CHECKING([kernel for seccomp_filter support])
  3370. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  3371. #include <errno.h>
  3372. #include <elf.h>
  3373. #include <linux/audit.h>
  3374. #include <linux/seccomp.h>
  3375. #include <stdlib.h>
  3376. #include <sys/prctl.h>
  3377. ]],
  3378. [[ int i = $seccomp_audit_arch;
  3379. errno = 0;
  3380. prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, NULL, 0, 0);
  3381. exit(errno == EFAULT ? 0 : 1); ]])],
  3382. [ AC_MSG_RESULT([yes]) ], [
  3383. AC_MSG_RESULT([no])
  3384. # Disable seccomp filter as a target
  3385. have_seccomp_filter=0
  3386. ]
  3387. )
  3388. fi
  3389. # Decide which sandbox style to use
  3390. sandbox_arg=""
  3391. AC_ARG_WITH([sandbox],
  3392. [ --with-sandbox=style Specify privilege separation sandbox (no, capsicum, darwin, rlimit, seccomp_filter, systrace, pledge)],
  3393. [
  3394. if test "x$withval" = "xyes" ; then
  3395. sandbox_arg=""
  3396. else
  3397. sandbox_arg="$withval"
  3398. fi
  3399. ]
  3400. )
  3401. # Some platforms (seems to be the ones that have a kernel poll(2)-type
  3402. # function with which they implement select(2)) use an extra file descriptor
  3403. # when calling select(2), which means we can't use the rlimit sandbox.
  3404. AC_MSG_CHECKING([if select works with descriptor rlimit])
  3405. AC_RUN_IFELSE(
  3406. [AC_LANG_PROGRAM([[
  3407. #include <sys/types.h>
  3408. #ifdef HAVE_SYS_TIME_H
  3409. # include <sys/time.h>
  3410. #endif
  3411. #include <sys/resource.h>
  3412. #ifdef HAVE_SYS_SELECT_H
  3413. # include <sys/select.h>
  3414. #endif
  3415. #include <errno.h>
  3416. #include <fcntl.h>
  3417. #include <stdlib.h>
  3418. ]],[[
  3419. struct rlimit rl_zero;
  3420. int fd, r;
  3421. fd_set fds;
  3422. struct timeval tv;
  3423. fd = open("/dev/null", O_RDONLY);
  3424. FD_ZERO(&fds);
  3425. FD_SET(fd, &fds);
  3426. rl_zero.rlim_cur = rl_zero.rlim_max = 0;
  3427. setrlimit(RLIMIT_FSIZE, &rl_zero);
  3428. setrlimit(RLIMIT_NOFILE, &rl_zero);
  3429. tv.tv_sec = 1;
  3430. tv.tv_usec = 0;
  3431. r = select(fd+1, &fds, NULL, NULL, &tv);
  3432. exit (r == -1 ? 1 : 0);
  3433. ]])],
  3434. [AC_MSG_RESULT([yes])
  3435. select_works_with_rlimit=yes],
  3436. [AC_MSG_RESULT([no])
  3437. select_works_with_rlimit=no],
  3438. [AC_MSG_WARN([cross compiling: assuming yes])
  3439. select_works_with_rlimit=yes]
  3440. )
  3441. AC_MSG_CHECKING([if setrlimit(RLIMIT_NOFILE,{0,0}) works])
  3442. AC_RUN_IFELSE(
  3443. [AC_LANG_PROGRAM([[
  3444. #include <sys/types.h>
  3445. #ifdef HAVE_SYS_TIME_H
  3446. # include <sys/time.h>
  3447. #endif
  3448. #include <sys/resource.h>
  3449. #include <errno.h>
  3450. #include <stdlib.h>
  3451. ]],[[
  3452. struct rlimit rl_zero;
  3453. int r;
  3454. rl_zero.rlim_cur = rl_zero.rlim_max = 0;
  3455. r = setrlimit(RLIMIT_NOFILE, &rl_zero);
  3456. exit (r == -1 ? 1 : 0);
  3457. ]])],
  3458. [AC_MSG_RESULT([yes])
  3459. rlimit_nofile_zero_works=yes],
  3460. [AC_MSG_RESULT([no])
  3461. rlimit_nofile_zero_works=no],
  3462. [AC_MSG_WARN([cross compiling: assuming yes])
  3463. rlimit_nofile_zero_works=yes]
  3464. )
  3465. AC_MSG_CHECKING([if setrlimit RLIMIT_FSIZE works])
  3466. AC_RUN_IFELSE(
  3467. [AC_LANG_PROGRAM([[
  3468. #include <sys/types.h>
  3469. #include <sys/resource.h>
  3470. #include <stdlib.h>
  3471. ]],[[
  3472. struct rlimit rl_zero;
  3473. rl_zero.rlim_cur = rl_zero.rlim_max = 0;
  3474. exit(setrlimit(RLIMIT_FSIZE, &rl_zero) != 0);
  3475. ]])],
  3476. [AC_MSG_RESULT([yes])],
  3477. [AC_MSG_RESULT([no])
  3478. AC_DEFINE(SANDBOX_SKIP_RLIMIT_FSIZE, 1,
  3479. [setrlimit RLIMIT_FSIZE works])],
  3480. [AC_MSG_WARN([cross compiling: assuming yes])]
  3481. )
  3482. if test "x$sandbox_arg" = "xpledge" || \
  3483. ( test -z "$sandbox_arg" && test "x$ac_cv_func_pledge" = "xyes" ) ; then
  3484. test "x$ac_cv_func_pledge" != "xyes" && \
  3485. AC_MSG_ERROR([pledge sandbox requires pledge(2) support])
  3486. SANDBOX_STYLE="pledge"
  3487. AC_DEFINE([SANDBOX_PLEDGE], [1], [Sandbox using pledge(2)])
  3488. elif test "x$sandbox_arg" = "xsystrace" || \
  3489. ( test -z "$sandbox_arg" && test "x$have_systr_policy_kill" = "x1" ) ; then
  3490. test "x$have_systr_policy_kill" != "x1" && \
  3491. AC_MSG_ERROR([systrace sandbox requires systrace headers and SYSTR_POLICY_KILL support])
  3492. SANDBOX_STYLE="systrace"
  3493. AC_DEFINE([SANDBOX_SYSTRACE], [1], [Sandbox using systrace(4)])
  3494. elif test "x$sandbox_arg" = "xdarwin" || \
  3495. ( test -z "$sandbox_arg" && test "x$ac_cv_func_sandbox_init" = "xyes" && \
  3496. test "x$ac_cv_header_sandbox_h" = "xyes") ; then
  3497. test "x$ac_cv_func_sandbox_init" != "xyes" -o \
  3498. "x$ac_cv_header_sandbox_h" != "xyes" && \
  3499. AC_MSG_ERROR([Darwin seatbelt sandbox requires sandbox.h and sandbox_init function])
  3500. SANDBOX_STYLE="darwin"
  3501. AC_DEFINE([SANDBOX_DARWIN], [1], [Sandbox using Darwin sandbox_init(3)])
  3502. elif test "x$sandbox_arg" = "xseccomp_filter" || \
  3503. ( test -z "$sandbox_arg" && \
  3504. test "x$have_seccomp_filter" = "x1" && \
  3505. test "x$ac_cv_header_elf_h" = "xyes" && \
  3506. test "x$ac_cv_header_linux_audit_h" = "xyes" && \
  3507. test "x$ac_cv_header_linux_filter_h" = "xyes" && \
  3508. test "x$seccomp_audit_arch" != "x" && \
  3509. test "x$have_linux_no_new_privs" = "x1" && \
  3510. test "x$ac_cv_func_prctl" = "xyes" ) ; then
  3511. test "x$seccomp_audit_arch" = "x" && \
  3512. AC_MSG_ERROR([seccomp_filter sandbox not supported on $host])
  3513. test "x$have_linux_no_new_privs" != "x1" && \
  3514. AC_MSG_ERROR([seccomp_filter sandbox requires PR_SET_NO_NEW_PRIVS])
  3515. test "x$have_seccomp_filter" != "x1" && \
  3516. AC_MSG_ERROR([seccomp_filter sandbox requires seccomp headers])
  3517. test "x$ac_cv_func_prctl" != "xyes" && \
  3518. AC_MSG_ERROR([seccomp_filter sandbox requires prctl function])
  3519. SANDBOX_STYLE="seccomp_filter"
  3520. AC_DEFINE([SANDBOX_SECCOMP_FILTER], [1], [Sandbox using seccomp filter])
  3521. elif test "x$sandbox_arg" = "xcapsicum" || \
  3522. ( test -z "$sandbox_arg" && \
  3523. test "x$ac_cv_header_sys_capsicum_h" = "xyes" && \
  3524. test "x$ac_cv_func_cap_rights_limit" = "xyes") ; then
  3525. test "x$ac_cv_header_sys_capsicum_h" != "xyes" && \
  3526. AC_MSG_ERROR([capsicum sandbox requires sys/capsicum.h header])
  3527. test "x$ac_cv_func_cap_rights_limit" != "xyes" && \
  3528. AC_MSG_ERROR([capsicum sandbox requires cap_rights_limit function])
  3529. SANDBOX_STYLE="capsicum"
  3530. AC_DEFINE([SANDBOX_CAPSICUM], [1], [Sandbox using capsicum])
  3531. elif test "x$sandbox_arg" = "xrlimit" || \
  3532. ( test -z "$sandbox_arg" && test "x$ac_cv_func_setrlimit" = "xyes" && \
  3533. test "x$select_works_with_rlimit" = "xyes" && \
  3534. test "x$rlimit_nofile_zero_works" = "xyes" ) ; then
  3535. test "x$ac_cv_func_setrlimit" != "xyes" && \
  3536. AC_MSG_ERROR([rlimit sandbox requires setrlimit function])
  3537. test "x$select_works_with_rlimit" != "xyes" && \
  3538. AC_MSG_ERROR([rlimit sandbox requires select to work with rlimit])
  3539. SANDBOX_STYLE="rlimit"
  3540. AC_DEFINE([SANDBOX_RLIMIT], [1], [Sandbox using setrlimit(2)])
  3541. elif test "x$sandbox_arg" = "xsolaris" || \
  3542. ( test -z "$sandbox_arg" && test "x$SOLARIS_PRIVS" = "xyes" ) ; then
  3543. SANDBOX_STYLE="solaris"
  3544. AC_DEFINE([SANDBOX_SOLARIS], [1], [Sandbox using Solaris/Illumos privileges])
  3545. elif test -z "$sandbox_arg" || test "x$sandbox_arg" = "xno" || \
  3546. test "x$sandbox_arg" = "xnone" || test "x$sandbox_arg" = "xnull" ; then
  3547. SANDBOX_STYLE="none"
  3548. AC_DEFINE([SANDBOX_NULL], [1], [no privsep sandboxing])
  3549. else
  3550. AC_MSG_ERROR([unsupported --with-sandbox])
  3551. fi
  3552. # Cheap hack to ensure NEWS-OS libraries are arranged right.
  3553. if test ! -z "$SONY" ; then
  3554. LIBS="$LIBS -liberty";
  3555. fi
  3556. # Check for long long datatypes
  3557. AC_CHECK_TYPES([long long, unsigned long long, long double])
  3558. # Check datatype sizes
  3559. AC_CHECK_SIZEOF([short int])
  3560. AC_CHECK_SIZEOF([int])
  3561. AC_CHECK_SIZEOF([long int])
  3562. AC_CHECK_SIZEOF([long long int])
  3563. # Sanity check long long for some platforms (AIX)
  3564. if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
  3565. ac_cv_sizeof_long_long_int=0
  3566. fi
  3567. # compute LLONG_MIN and LLONG_MAX if we don't know them.
  3568. if test -z "$have_llong_max" && test -z "$have_long_long_max"; then
  3569. AC_MSG_CHECKING([for max value of long long])
  3570. AC_RUN_IFELSE(
  3571. [AC_LANG_PROGRAM([[
  3572. #include <stdio.h>
  3573. #include <stdlib.h>
  3574. /* Why is this so damn hard? */
  3575. #ifdef __GNUC__
  3576. # undef __GNUC__
  3577. #endif
  3578. #define __USE_ISOC99
  3579. #include <limits.h>
  3580. #define DATA "conftest.llminmax"
  3581. #define my_abs(a) ((a) < 0 ? ((a) * -1) : (a))
  3582. /*
  3583. * printf in libc on some platforms (eg old Tru64) does not understand %lld so
  3584. * we do this the hard way.
  3585. */
  3586. static int
  3587. fprint_ll(FILE *f, long long n)
  3588. {
  3589. unsigned int i;
  3590. int l[sizeof(long long) * 8];
  3591. if (n < 0)
  3592. if (fprintf(f, "-") < 0)
  3593. return -1;
  3594. for (i = 0; n != 0; i++) {
  3595. l[i] = my_abs(n % 10);
  3596. n /= 10;
  3597. }
  3598. do {
  3599. if (fprintf(f, "%d", l[--i]) < 0)
  3600. return -1;
  3601. } while (i != 0);
  3602. if (fprintf(f, " ") < 0)
  3603. return -1;
  3604. return 0;
  3605. }
  3606. ]], [[
  3607. FILE *f;
  3608. long long i, llmin, llmax = 0;
  3609. if((f = fopen(DATA,"w")) == NULL)
  3610. exit(1);
  3611. #if defined(LLONG_MIN) && defined(LLONG_MAX)
  3612. fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
  3613. llmin = LLONG_MIN;
  3614. llmax = LLONG_MAX;
  3615. #else
  3616. fprintf(stderr, "Calculating LLONG_MIN and LLONG_MAX\n");
  3617. /* This will work on one's complement and two's complement */
  3618. for (i = 1; i > llmax; i <<= 1, i++)
  3619. llmax = i;
  3620. llmin = llmax + 1LL; /* wrap */
  3621. #endif
  3622. /* Sanity check */
  3623. if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax
  3624. || llmax - 1 > llmax || llmin == llmax || llmin == 0
  3625. || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) {
  3626. fprintf(f, "unknown unknown\n");
  3627. exit(2);
  3628. }
  3629. if (fprint_ll(f, llmin) < 0)
  3630. exit(3);
  3631. if (fprint_ll(f, llmax) < 0)
  3632. exit(4);
  3633. if (fclose(f) < 0)
  3634. exit(5);
  3635. exit(0);
  3636. ]])],
  3637. [
  3638. llong_min=`$AWK '{print $1}' conftest.llminmax`
  3639. llong_max=`$AWK '{print $2}' conftest.llminmax`
  3640. AC_MSG_RESULT([$llong_max])
  3641. AC_DEFINE_UNQUOTED([LLONG_MAX], [${llong_max}LL],
  3642. [max value of long long calculated by configure])
  3643. AC_MSG_CHECKING([for min value of long long])
  3644. AC_MSG_RESULT([$llong_min])
  3645. AC_DEFINE_UNQUOTED([LLONG_MIN], [${llong_min}LL],
  3646. [min value of long long calculated by configure])
  3647. ],
  3648. [
  3649. AC_MSG_RESULT([not found])
  3650. ],
  3651. [
  3652. AC_MSG_WARN([cross compiling: not checking])
  3653. ]
  3654. )
  3655. fi
  3656. AC_CHECK_DECLS([UINT32_MAX], , , [[
  3657. #ifdef HAVE_SYS_LIMITS_H
  3658. # include <sys/limits.h>
  3659. #endif
  3660. #ifdef HAVE_LIMITS_H
  3661. # include <limits.h>
  3662. #endif
  3663. #ifdef HAVE_STDINT_H
  3664. # include <stdint.h>
  3665. #endif
  3666. ]])
  3667. # More checks for data types
  3668. AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
  3669. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
  3670. [[ u_int a; a = 1;]])],
  3671. [ ac_cv_have_u_int="yes" ], [ ac_cv_have_u_int="no"
  3672. ])
  3673. ])
  3674. if test "x$ac_cv_have_u_int" = "xyes" ; then
  3675. AC_DEFINE([HAVE_U_INT], [1], [define if you have u_int data type])
  3676. have_u_int=1
  3677. fi
  3678. AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
  3679. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
  3680. [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
  3681. [ ac_cv_have_intxx_t="yes" ], [ ac_cv_have_intxx_t="no"
  3682. ])
  3683. ])
  3684. if test "x$ac_cv_have_intxx_t" = "xyes" ; then
  3685. AC_DEFINE([HAVE_INTXX_T], [1], [define if you have intxx_t data type])
  3686. have_intxx_t=1
  3687. fi
  3688. if (test -z "$have_intxx_t" && \
  3689. test "x$ac_cv_header_stdint_h" = "xyes")
  3690. then
  3691. AC_MSG_CHECKING([for intXX_t types in stdint.h])
  3692. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
  3693. [[ int8_t a; int16_t b; int32_t c; a = b = c = 1;]])],
  3694. [
  3695. AC_DEFINE([HAVE_INTXX_T])
  3696. AC_MSG_RESULT([yes])
  3697. ], [ AC_MSG_RESULT([no])
  3698. ])
  3699. fi
  3700. AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
  3701. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  3702. #include <sys/types.h>
  3703. #ifdef HAVE_STDINT_H
  3704. # include <stdint.h>
  3705. #endif
  3706. #include <sys/socket.h>
  3707. #ifdef HAVE_SYS_BITYPES_H
  3708. # include <sys/bitypes.h>
  3709. #endif
  3710. ]], [[
  3711. int64_t a; a = 1;
  3712. ]])],
  3713. [ ac_cv_have_int64_t="yes" ], [ ac_cv_have_int64_t="no"
  3714. ])
  3715. ])
  3716. if test "x$ac_cv_have_int64_t" = "xyes" ; then
  3717. AC_DEFINE([HAVE_INT64_T], [1], [define if you have int64_t data type])
  3718. fi
  3719. AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
  3720. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
  3721. [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
  3722. [ ac_cv_have_u_intxx_t="yes" ], [ ac_cv_have_u_intxx_t="no"
  3723. ])
  3724. ])
  3725. if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
  3726. AC_DEFINE([HAVE_U_INTXX_T], [1], [define if you have u_intxx_t data type])
  3727. have_u_intxx_t=1
  3728. fi
  3729. if test -z "$have_u_intxx_t" ; then
  3730. AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
  3731. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/socket.h> ]],
  3732. [[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;]])],
  3733. [
  3734. AC_DEFINE([HAVE_U_INTXX_T])
  3735. AC_MSG_RESULT([yes])
  3736. ], [ AC_MSG_RESULT([no])
  3737. ])
  3738. fi
  3739. AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
  3740. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
  3741. [[ u_int64_t a; a = 1;]])],
  3742. [ ac_cv_have_u_int64_t="yes" ], [ ac_cv_have_u_int64_t="no"
  3743. ])
  3744. ])
  3745. if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
  3746. AC_DEFINE([HAVE_U_INT64_T], [1], [define if you have u_int64_t data type])
  3747. have_u_int64_t=1
  3748. fi
  3749. if (test -z "$have_u_int64_t" && \
  3750. test "x$ac_cv_header_sys_bitypes_h" = "xyes")
  3751. then
  3752. AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
  3753. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/bitypes.h> ]],
  3754. [[ u_int64_t a; a = 1]])],
  3755. [
  3756. AC_DEFINE([HAVE_U_INT64_T])
  3757. AC_MSG_RESULT([yes])
  3758. ], [ AC_MSG_RESULT([no])
  3759. ])
  3760. fi
  3761. if test -z "$have_u_intxx_t" ; then
  3762. AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
  3763. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  3764. #include <sys/types.h>
  3765. ]], [[
  3766. uint8_t a;
  3767. uint16_t b;
  3768. uint32_t c;
  3769. a = b = c = 1;
  3770. ]])],
  3771. [ ac_cv_have_uintxx_t="yes" ], [ ac_cv_have_uintxx_t="no"
  3772. ])
  3773. ])
  3774. if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
  3775. AC_DEFINE([HAVE_UINTXX_T], [1],
  3776. [define if you have uintxx_t data type])
  3777. fi
  3778. fi
  3779. if (test -z "$have_uintxx_t" && \
  3780. test "x$ac_cv_header_stdint_h" = "xyes")
  3781. then
  3782. AC_MSG_CHECKING([for uintXX_t types in stdint.h])
  3783. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <stdint.h> ]],
  3784. [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
  3785. [
  3786. AC_DEFINE([HAVE_UINTXX_T])
  3787. AC_MSG_RESULT([yes])
  3788. ], [ AC_MSG_RESULT([no])
  3789. ])
  3790. fi
  3791. if (test -z "$have_uintxx_t" && \
  3792. test "x$ac_cv_header_inttypes_h" = "xyes")
  3793. then
  3794. AC_MSG_CHECKING([for uintXX_t types in inttypes.h])
  3795. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <inttypes.h> ]],
  3796. [[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;]])],
  3797. [
  3798. AC_DEFINE([HAVE_UINTXX_T])
  3799. AC_MSG_RESULT([yes])
  3800. ], [ AC_MSG_RESULT([no])
  3801. ])
  3802. fi
  3803. if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
  3804. test "x$ac_cv_header_sys_bitypes_h" = "xyes")
  3805. then
  3806. AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
  3807. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  3808. #include <sys/bitypes.h>
  3809. ]], [[
  3810. int8_t a; int16_t b; int32_t c;
  3811. u_int8_t e; u_int16_t f; u_int32_t g;
  3812. a = b = c = e = f = g = 1;
  3813. ]])],
  3814. [
  3815. AC_DEFINE([HAVE_U_INTXX_T])
  3816. AC_DEFINE([HAVE_INTXX_T])
  3817. AC_MSG_RESULT([yes])
  3818. ], [AC_MSG_RESULT([no])
  3819. ])
  3820. fi
  3821. AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
  3822. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
  3823. [[ u_char foo; foo = 125; ]])],
  3824. [ ac_cv_have_u_char="yes" ], [ ac_cv_have_u_char="no"
  3825. ])
  3826. ])
  3827. if test "x$ac_cv_have_u_char" = "xyes" ; then
  3828. AC_DEFINE([HAVE_U_CHAR], [1], [define if you have u_char data type])
  3829. fi
  3830. AC_CHECK_TYPES([intmax_t, uintmax_t], , , [
  3831. #include <sys/types.h>
  3832. #ifdef HAVE_STDINT_H
  3833. # include <stdint.h>
  3834. #endif
  3835. ])
  3836. TYPE_SOCKLEN_T
  3837. AC_CHECK_TYPES([sig_atomic_t], , , [#include <signal.h>])
  3838. AC_CHECK_TYPES([fsblkcnt_t, fsfilcnt_t], , , [
  3839. #include <sys/types.h>
  3840. #ifdef HAVE_SYS_BITYPES_H
  3841. #include <sys/bitypes.h>
  3842. #endif
  3843. #ifdef HAVE_SYS_STATFS_H
  3844. #include <sys/statfs.h>
  3845. #endif
  3846. #ifdef HAVE_SYS_STATVFS_H
  3847. #include <sys/statvfs.h>
  3848. #endif
  3849. ])
  3850. AC_CHECK_MEMBERS([struct statfs.f_files, struct statfs.f_flags], [], [], [[
  3851. #include <sys/param.h>
  3852. #include <sys/types.h>
  3853. #ifdef HAVE_SYS_BITYPES_H
  3854. #include <sys/bitypes.h>
  3855. #endif
  3856. #ifdef HAVE_SYS_STATFS_H
  3857. #include <sys/statfs.h>
  3858. #endif
  3859. #ifdef HAVE_SYS_STATVFS_H
  3860. #include <sys/statvfs.h>
  3861. #endif
  3862. #ifdef HAVE_SYS_VFS_H
  3863. #include <sys/vfs.h>
  3864. #endif
  3865. #ifdef HAVE_SYS_MOUNT_H
  3866. #include <sys/mount.h>
  3867. #endif
  3868. ]])
  3869. AC_CHECK_TYPES([in_addr_t, in_port_t], , ,
  3870. [#include <sys/types.h>
  3871. #include <netinet/in.h>])
  3872. AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
  3873. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
  3874. [[ size_t foo; foo = 1235; ]])],
  3875. [ ac_cv_have_size_t="yes" ], [ ac_cv_have_size_t="no"
  3876. ])
  3877. ])
  3878. if test "x$ac_cv_have_size_t" = "xyes" ; then
  3879. AC_DEFINE([HAVE_SIZE_T], [1], [define if you have size_t data type])
  3880. fi
  3881. AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
  3882. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
  3883. [[ ssize_t foo; foo = 1235; ]])],
  3884. [ ac_cv_have_ssize_t="yes" ], [ ac_cv_have_ssize_t="no"
  3885. ])
  3886. ])
  3887. if test "x$ac_cv_have_ssize_t" = "xyes" ; then
  3888. AC_DEFINE([HAVE_SSIZE_T], [1], [define if you have ssize_t data type])
  3889. fi
  3890. AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
  3891. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <time.h> ]],
  3892. [[ clock_t foo; foo = 1235; ]])],
  3893. [ ac_cv_have_clock_t="yes" ], [ ac_cv_have_clock_t="no"
  3894. ])
  3895. ])
  3896. if test "x$ac_cv_have_clock_t" = "xyes" ; then
  3897. AC_DEFINE([HAVE_CLOCK_T], [1], [define if you have clock_t data type])
  3898. fi
  3899. AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
  3900. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  3901. #include <sys/types.h>
  3902. #include <sys/socket.h>
  3903. ]], [[ sa_family_t foo; foo = 1235; ]])],
  3904. [ ac_cv_have_sa_family_t="yes" ],
  3905. [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  3906. #include <sys/types.h>
  3907. #include <sys/socket.h>
  3908. #include <netinet/in.h>
  3909. ]], [[ sa_family_t foo; foo = 1235; ]])],
  3910. [ ac_cv_have_sa_family_t="yes" ],
  3911. [ ac_cv_have_sa_family_t="no" ]
  3912. )
  3913. ])
  3914. ])
  3915. if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
  3916. AC_DEFINE([HAVE_SA_FAMILY_T], [1],
  3917. [define if you have sa_family_t data type])
  3918. fi
  3919. AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
  3920. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
  3921. [[ pid_t foo; foo = 1235; ]])],
  3922. [ ac_cv_have_pid_t="yes" ], [ ac_cv_have_pid_t="no"
  3923. ])
  3924. ])
  3925. if test "x$ac_cv_have_pid_t" = "xyes" ; then
  3926. AC_DEFINE([HAVE_PID_T], [1], [define if you have pid_t data type])
  3927. fi
  3928. AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
  3929. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> ]],
  3930. [[ mode_t foo; foo = 1235; ]])],
  3931. [ ac_cv_have_mode_t="yes" ], [ ac_cv_have_mode_t="no"
  3932. ])
  3933. ])
  3934. if test "x$ac_cv_have_mode_t" = "xyes" ; then
  3935. AC_DEFINE([HAVE_MODE_T], [1], [define if you have mode_t data type])
  3936. fi
  3937. AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
  3938. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  3939. #include <sys/types.h>
  3940. #include <sys/socket.h>
  3941. ]], [[ struct sockaddr_storage s; ]])],
  3942. [ ac_cv_have_struct_sockaddr_storage="yes" ],
  3943. [ ac_cv_have_struct_sockaddr_storage="no"
  3944. ])
  3945. ])
  3946. if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
  3947. AC_DEFINE([HAVE_STRUCT_SOCKADDR_STORAGE], [1],
  3948. [define if you have struct sockaddr_storage data type])
  3949. fi
  3950. AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
  3951. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  3952. #include <sys/types.h>
  3953. #include <netinet/in.h>
  3954. ]], [[ struct sockaddr_in6 s; s.sin6_family = 0; ]])],
  3955. [ ac_cv_have_struct_sockaddr_in6="yes" ],
  3956. [ ac_cv_have_struct_sockaddr_in6="no"
  3957. ])
  3958. ])
  3959. if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
  3960. AC_DEFINE([HAVE_STRUCT_SOCKADDR_IN6], [1],
  3961. [define if you have struct sockaddr_in6 data type])
  3962. fi
  3963. AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
  3964. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  3965. #include <sys/types.h>
  3966. #include <netinet/in.h>
  3967. ]], [[ struct in6_addr s; s.s6_addr[0] = 0; ]])],
  3968. [ ac_cv_have_struct_in6_addr="yes" ],
  3969. [ ac_cv_have_struct_in6_addr="no"
  3970. ])
  3971. ])
  3972. if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
  3973. AC_DEFINE([HAVE_STRUCT_IN6_ADDR], [1],
  3974. [define if you have struct in6_addr data type])
  3975. dnl Now check for sin6_scope_id
  3976. AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], , ,
  3977. [
  3978. #ifdef HAVE_SYS_TYPES_H
  3979. #include <sys/types.h>
  3980. #endif
  3981. #include <netinet/in.h>
  3982. ])
  3983. fi
  3984. AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
  3985. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  3986. #include <sys/types.h>
  3987. #include <sys/socket.h>
  3988. #include <netdb.h>
  3989. ]], [[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ]])],
  3990. [ ac_cv_have_struct_addrinfo="yes" ],
  3991. [ ac_cv_have_struct_addrinfo="no"
  3992. ])
  3993. ])
  3994. if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
  3995. AC_DEFINE([HAVE_STRUCT_ADDRINFO], [1],
  3996. [define if you have struct addrinfo data type])
  3997. fi
  3998. AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
  3999. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/time.h> ]],
  4000. [[ struct timeval tv; tv.tv_sec = 1;]])],
  4001. [ ac_cv_have_struct_timeval="yes" ],
  4002. [ ac_cv_have_struct_timeval="no"
  4003. ])
  4004. ])
  4005. if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
  4006. AC_DEFINE([HAVE_STRUCT_TIMEVAL], [1], [define if you have struct timeval])
  4007. have_struct_timeval=1
  4008. fi
  4009. AC_CACHE_CHECK([for struct timespec], ac_cv_have_struct_timespec, [
  4010. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  4011. #ifdef HAVE_SYS_TIME_H
  4012. # include <sys/time.h>
  4013. #endif
  4014. #ifdef HAVE_TIME_H
  4015. # include <time.h>
  4016. #endif
  4017. ]],
  4018. [[ struct timespec ts; ts.tv_sec = 1;]])],
  4019. [ ac_cv_have_struct_timespec="yes" ],
  4020. [ ac_cv_have_struct_timespec="no"
  4021. ])
  4022. ])
  4023. if test "x$ac_cv_have_struct_timespec" = "xyes" ; then
  4024. AC_DEFINE([HAVE_STRUCT_TIMESPEC], [1], [define if you have struct timespec])
  4025. have_struct_timespec=1
  4026. fi
  4027. # We need int64_t or else certain parts of the compile will fail.
  4028. if test "x$ac_cv_have_int64_t" = "xno" && \
  4029. test "x$ac_cv_sizeof_long_int" != "x8" && \
  4030. test "x$ac_cv_sizeof_long_long_int" = "x0" ; then
  4031. echo "OpenSSH requires int64_t support. Contact your vendor or install"
  4032. echo "an alternative compiler (I.E., GCC) before continuing."
  4033. echo ""
  4034. exit 1;
  4035. else
  4036. dnl test snprintf (broken on SCO w/gcc)
  4037. AC_RUN_IFELSE(
  4038. [AC_LANG_SOURCE([[
  4039. #include <stdio.h>
  4040. #include <stdlib.h>
  4041. #include <string.h>
  4042. #ifdef HAVE_SNPRINTF
  4043. main()
  4044. {
  4045. char buf[50];
  4046. char expected_out[50];
  4047. int mazsize = 50 ;
  4048. #if (SIZEOF_LONG_INT == 8)
  4049. long int num = 0x7fffffffffffffff;
  4050. #else
  4051. long long num = 0x7fffffffffffffffll;
  4052. #endif
  4053. strcpy(expected_out, "9223372036854775807");
  4054. snprintf(buf, mazsize, "%lld", num);
  4055. if(strcmp(buf, expected_out) != 0)
  4056. exit(1);
  4057. exit(0);
  4058. }
  4059. #else
  4060. main() { exit(0); }
  4061. #endif
  4062. ]])], [ true ], [ AC_DEFINE([BROKEN_SNPRINTF]) ],
  4063. AC_MSG_WARN([cross compiling: Assuming working snprintf()])
  4064. )
  4065. fi
  4066. dnl Checks for structure members
  4067. OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmp.h], [HAVE_HOST_IN_UTMP])
  4068. OSSH_CHECK_HEADER_FOR_FIELD([ut_host], [utmpx.h], [HAVE_HOST_IN_UTMPX])
  4069. OSSH_CHECK_HEADER_FOR_FIELD([syslen], [utmpx.h], [HAVE_SYSLEN_IN_UTMPX])
  4070. OSSH_CHECK_HEADER_FOR_FIELD([ut_pid], [utmp.h], [HAVE_PID_IN_UTMP])
  4071. OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmp.h], [HAVE_TYPE_IN_UTMP])
  4072. OSSH_CHECK_HEADER_FOR_FIELD([ut_type], [utmpx.h], [HAVE_TYPE_IN_UTMPX])
  4073. OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmp.h], [HAVE_TV_IN_UTMP])
  4074. OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmp.h], [HAVE_ID_IN_UTMP])
  4075. OSSH_CHECK_HEADER_FOR_FIELD([ut_id], [utmpx.h], [HAVE_ID_IN_UTMPX])
  4076. OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmp.h], [HAVE_ADDR_IN_UTMP])
  4077. OSSH_CHECK_HEADER_FOR_FIELD([ut_addr], [utmpx.h], [HAVE_ADDR_IN_UTMPX])
  4078. OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmp.h], [HAVE_ADDR_V6_IN_UTMP])
  4079. OSSH_CHECK_HEADER_FOR_FIELD([ut_addr_v6], [utmpx.h], [HAVE_ADDR_V6_IN_UTMPX])
  4080. OSSH_CHECK_HEADER_FOR_FIELD([ut_exit], [utmp.h], [HAVE_EXIT_IN_UTMP])
  4081. OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmp.h], [HAVE_TIME_IN_UTMP])
  4082. OSSH_CHECK_HEADER_FOR_FIELD([ut_time], [utmpx.h], [HAVE_TIME_IN_UTMPX])
  4083. OSSH_CHECK_HEADER_FOR_FIELD([ut_tv], [utmpx.h], [HAVE_TV_IN_UTMPX])
  4084. OSSH_CHECK_HEADER_FOR_FIELD([ut_ss], [utmpx.h], [HAVE_SS_IN_UTMPX])
  4085. AC_CHECK_MEMBERS([struct stat.st_blksize])
  4086. AC_CHECK_MEMBERS([struct stat.st_mtim])
  4087. AC_CHECK_MEMBERS([struct stat.st_mtime])
  4088. AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_class,
  4089. struct passwd.pw_change, struct passwd.pw_expire],
  4090. [], [], [[
  4091. #include <sys/types.h>
  4092. #include <pwd.h>
  4093. ]])
  4094. AC_CHECK_MEMBER([struct __res_state.retrans], [], [AC_DEFINE([__res_state], [state],
  4095. [Define if we don't have struct __res_state in resolv.h])],
  4096. [[
  4097. #include <stdio.h>
  4098. #if HAVE_SYS_TYPES_H
  4099. # include <sys/types.h>
  4100. #endif
  4101. #include <netinet/in.h>
  4102. #include <arpa/nameser.h>
  4103. #include <resolv.h>
  4104. ]])
  4105. AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
  4106. ac_cv_have_ss_family_in_struct_ss, [
  4107. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  4108. #include <sys/types.h>
  4109. #include <sys/socket.h>
  4110. ]], [[ struct sockaddr_storage s; s.ss_family = 1; ]])],
  4111. [ ac_cv_have_ss_family_in_struct_ss="yes" ],
  4112. [ ac_cv_have_ss_family_in_struct_ss="no" ])
  4113. ])
  4114. if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
  4115. AC_DEFINE([HAVE_SS_FAMILY_IN_SS], [1], [Fields in struct sockaddr_storage])
  4116. fi
  4117. AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
  4118. ac_cv_have___ss_family_in_struct_ss, [
  4119. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  4120. #include <sys/types.h>
  4121. #include <sys/socket.h>
  4122. ]], [[ struct sockaddr_storage s; s.__ss_family = 1; ]])],
  4123. [ ac_cv_have___ss_family_in_struct_ss="yes" ],
  4124. [ ac_cv_have___ss_family_in_struct_ss="no"
  4125. ])
  4126. ])
  4127. if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
  4128. AC_DEFINE([HAVE___SS_FAMILY_IN_SS], [1],
  4129. [Fields in struct sockaddr_storage])
  4130. fi
  4131. dnl make sure we're using the real structure members and not defines
  4132. AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
  4133. ac_cv_have_accrights_in_msghdr, [
  4134. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  4135. #include <sys/types.h>
  4136. #include <sys/socket.h>
  4137. #include <sys/uio.h>
  4138. #include <stdlib.h>
  4139. ]], [[
  4140. #ifdef msg_accrights
  4141. #error "msg_accrights is a macro"
  4142. exit(1);
  4143. #endif
  4144. struct msghdr m;
  4145. m.msg_accrights = 0;
  4146. exit(0);
  4147. ]])],
  4148. [ ac_cv_have_accrights_in_msghdr="yes" ],
  4149. [ ac_cv_have_accrights_in_msghdr="no" ]
  4150. )
  4151. ])
  4152. if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
  4153. AC_DEFINE([HAVE_ACCRIGHTS_IN_MSGHDR], [1],
  4154. [Define if your system uses access rights style
  4155. file descriptor passing])
  4156. fi
  4157. AC_MSG_CHECKING([if struct statvfs.f_fsid is integral type])
  4158. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  4159. #include <sys/param.h>
  4160. #include <sys/stat.h>
  4161. #ifdef HAVE_SYS_TIME_H
  4162. # include <sys/time.h>
  4163. #endif
  4164. #ifdef HAVE_SYS_MOUNT_H
  4165. #include <sys/mount.h>
  4166. #endif
  4167. #ifdef HAVE_SYS_STATVFS_H
  4168. #include <sys/statvfs.h>
  4169. #endif
  4170. ]], [[ struct statvfs s; s.f_fsid = 0; ]])],
  4171. [ AC_MSG_RESULT([yes]) ],
  4172. [ AC_MSG_RESULT([no])
  4173. AC_MSG_CHECKING([if fsid_t has member val])
  4174. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  4175. #include <sys/types.h>
  4176. #include <sys/statvfs.h>
  4177. ]], [[ fsid_t t; t.val[0] = 0; ]])],
  4178. [ AC_MSG_RESULT([yes])
  4179. AC_DEFINE([FSID_HAS_VAL], [1], [fsid_t has member val]) ],
  4180. [ AC_MSG_RESULT([no]) ])
  4181. AC_MSG_CHECKING([if f_fsid has member __val])
  4182. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  4183. #include <sys/types.h>
  4184. #include <sys/statvfs.h>
  4185. ]], [[ fsid_t t; t.__val[0] = 0; ]])],
  4186. [ AC_MSG_RESULT([yes])
  4187. AC_DEFINE([FSID_HAS___VAL], [1], [fsid_t has member __val]) ],
  4188. [ AC_MSG_RESULT([no]) ])
  4189. ])
  4190. AC_CACHE_CHECK([for msg_control field in struct msghdr],
  4191. ac_cv_have_control_in_msghdr, [
  4192. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  4193. #include <sys/types.h>
  4194. #include <sys/socket.h>
  4195. #include <sys/uio.h>
  4196. #include <stdlib.h>
  4197. ]], [[
  4198. #ifdef msg_control
  4199. #error "msg_control is a macro"
  4200. exit(1);
  4201. #endif
  4202. struct msghdr m;
  4203. m.msg_control = 0;
  4204. exit(0);
  4205. ]])],
  4206. [ ac_cv_have_control_in_msghdr="yes" ],
  4207. [ ac_cv_have_control_in_msghdr="no" ]
  4208. )
  4209. ])
  4210. if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
  4211. AC_DEFINE([HAVE_CONTROL_IN_MSGHDR], [1],
  4212. [Define if your system uses ancillary data style
  4213. file descriptor passing])
  4214. fi
  4215. AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
  4216. AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
  4217. [[ extern char *__progname; printf("%s", __progname); ]])],
  4218. [ ac_cv_libc_defines___progname="yes" ],
  4219. [ ac_cv_libc_defines___progname="no"
  4220. ])
  4221. ])
  4222. if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
  4223. AC_DEFINE([HAVE___PROGNAME], [1], [Define if libc defines __progname])
  4224. fi
  4225. AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
  4226. AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
  4227. [[ printf("%s", __FUNCTION__); ]])],
  4228. [ ac_cv_cc_implements___FUNCTION__="yes" ],
  4229. [ ac_cv_cc_implements___FUNCTION__="no"
  4230. ])
  4231. ])
  4232. if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
  4233. AC_DEFINE([HAVE___FUNCTION__], [1],
  4234. [Define if compiler implements __FUNCTION__])
  4235. fi
  4236. AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
  4237. AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
  4238. [[ printf("%s", __func__); ]])],
  4239. [ ac_cv_cc_implements___func__="yes" ],
  4240. [ ac_cv_cc_implements___func__="no"
  4241. ])
  4242. ])
  4243. if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
  4244. AC_DEFINE([HAVE___func__], [1], [Define if compiler implements __func__])
  4245. fi
  4246. AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
  4247. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  4248. #include <stdarg.h>
  4249. va_list x,y;
  4250. ]], [[ va_copy(x,y); ]])],
  4251. [ ac_cv_have_va_copy="yes" ],
  4252. [ ac_cv_have_va_copy="no"
  4253. ])
  4254. ])
  4255. if test "x$ac_cv_have_va_copy" = "xyes" ; then
  4256. AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists])
  4257. fi
  4258. AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [
  4259. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  4260. #include <stdarg.h>
  4261. va_list x,y;
  4262. ]], [[ __va_copy(x,y); ]])],
  4263. [ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no"
  4264. ])
  4265. ])
  4266. if test "x$ac_cv_have___va_copy" = "xyes" ; then
  4267. AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists])
  4268. fi
  4269. AC_CACHE_CHECK([whether getopt has optreset support],
  4270. ac_cv_have_getopt_optreset, [
  4271. AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]],
  4272. [[ extern int optreset; optreset = 0; ]])],
  4273. [ ac_cv_have_getopt_optreset="yes" ],
  4274. [ ac_cv_have_getopt_optreset="no"
  4275. ])
  4276. ])
  4277. if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
  4278. AC_DEFINE([HAVE_GETOPT_OPTRESET], [1],
  4279. [Define if your getopt(3) defines and uses optreset])
  4280. fi
  4281. AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
  4282. AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
  4283. [[ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);]])],
  4284. [ ac_cv_libc_defines_sys_errlist="yes" ],
  4285. [ ac_cv_libc_defines_sys_errlist="no"
  4286. ])
  4287. ])
  4288. if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
  4289. AC_DEFINE([HAVE_SYS_ERRLIST], [1],
  4290. [Define if your system defines sys_errlist[]])
  4291. fi
  4292. AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
  4293. AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
  4294. [[ extern int sys_nerr; printf("%i", sys_nerr);]])],
  4295. [ ac_cv_libc_defines_sys_nerr="yes" ],
  4296. [ ac_cv_libc_defines_sys_nerr="no"
  4297. ])
  4298. ])
  4299. if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
  4300. AC_DEFINE([HAVE_SYS_NERR], [1], [Define if your system defines sys_nerr])
  4301. fi
  4302. # Check libraries needed by DNS fingerprint support
  4303. AC_SEARCH_LIBS([getrrsetbyname], [resolv],
  4304. [AC_DEFINE([HAVE_GETRRSETBYNAME], [1],
  4305. [Define if getrrsetbyname() exists])],
  4306. [
  4307. # Needed by our getrrsetbyname()
  4308. AC_SEARCH_LIBS([res_query], [resolv])
  4309. AC_SEARCH_LIBS([dn_expand], [resolv])
  4310. AC_MSG_CHECKING([if res_query will link])
  4311. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  4312. #include <sys/types.h>
  4313. #include <netinet/in.h>
  4314. #include <arpa/nameser.h>
  4315. #include <netdb.h>
  4316. #include <resolv.h>
  4317. ]], [[
  4318. res_query (0, 0, 0, 0, 0);
  4319. ]])],
  4320. AC_MSG_RESULT([yes]),
  4321. [AC_MSG_RESULT([no])
  4322. saved_LIBS="$LIBS"
  4323. LIBS="$LIBS -lresolv"
  4324. AC_MSG_CHECKING([for res_query in -lresolv])
  4325. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  4326. #include <sys/types.h>
  4327. #include <netinet/in.h>
  4328. #include <arpa/nameser.h>
  4329. #include <netdb.h>
  4330. #include <resolv.h>
  4331. ]], [[
  4332. res_query (0, 0, 0, 0, 0);
  4333. ]])],
  4334. [AC_MSG_RESULT([yes])],
  4335. [LIBS="$saved_LIBS"
  4336. AC_MSG_RESULT([no])])
  4337. ])
  4338. AC_CHECK_FUNCS([_getshort _getlong])
  4339. AC_CHECK_DECLS([_getshort, _getlong], , ,
  4340. [#include <sys/types.h>
  4341. #include <arpa/nameser.h>])
  4342. AC_CHECK_MEMBER([HEADER.ad],
  4343. [AC_DEFINE([HAVE_HEADER_AD], [1],
  4344. [Define if HEADER.ad exists in arpa/nameser.h])], ,
  4345. [#include <arpa/nameser.h>])
  4346. ])
  4347. AC_MSG_CHECKING([if struct __res_state _res is an extern])
  4348. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  4349. #include <stdio.h>
  4350. #if HAVE_SYS_TYPES_H
  4351. # include <sys/types.h>
  4352. #endif
  4353. #include <netinet/in.h>
  4354. #include <arpa/nameser.h>
  4355. #include <resolv.h>
  4356. extern struct __res_state _res;
  4357. ]], [[
  4358. struct __res_state *volatile p = &_res; /* force resolution of _res */
  4359. return 0;
  4360. ]],)],
  4361. [AC_MSG_RESULT([yes])
  4362. AC_DEFINE([HAVE__RES_EXTERN], [1],
  4363. [Define if you have struct __res_state _res as an extern])
  4364. ],
  4365. [ AC_MSG_RESULT([no]) ]
  4366. )
  4367. # Check whether user wants SELinux support
  4368. SELINUX_MSG="no"
  4369. LIBSELINUX=""
  4370. AC_ARG_WITH([selinux],
  4371. [ --with-selinux Enable SELinux support],
  4372. [ if test "x$withval" != "xno" ; then
  4373. save_LIBS="$LIBS"
  4374. AC_DEFINE([WITH_SELINUX], [1],
  4375. [Define if you want SELinux support.])
  4376. SELINUX_MSG="yes"
  4377. AC_CHECK_HEADER([selinux/selinux.h], ,
  4378. AC_MSG_ERROR([SELinux support requires selinux.h header]))
  4379. AC_CHECK_LIB([selinux], [setexeccon],
  4380. [ LIBSELINUX="-lselinux"
  4381. LIBS="$LIBS -lselinux"
  4382. ],
  4383. AC_MSG_ERROR([SELinux support requires libselinux library]))
  4384. AC_CHECK_FUNCS([getseuserbyname get_default_context_with_level])
  4385. LIBS="$save_LIBS $LIBSELINUX"
  4386. fi ]
  4387. )
  4388. AC_SUBST([SSHDLIBS])
  4389. AC_SUBST([KEYCATLIBS])
  4390. # Check whether user wants Kerberos 5 support
  4391. KRB5_MSG="no"
  4392. AC_ARG_WITH([kerberos5],
  4393. [ --with-kerberos5=PATH Enable Kerberos 5 support],
  4394. [ if test "x$withval" != "xno" ; then
  4395. if test "x$withval" = "xyes" ; then
  4396. KRB5ROOT="/usr/local"
  4397. else
  4398. KRB5ROOT=${withval}
  4399. fi
  4400. AC_DEFINE([KRB5], [1], [Define if you want Kerberos 5 support])
  4401. KRB5_MSG="yes"
  4402. AC_PATH_TOOL([KRB5CONF], [krb5-config],
  4403. [$KRB5ROOT/bin/krb5-config],
  4404. [$KRB5ROOT/bin:$PATH])
  4405. if test -x $KRB5CONF ; then
  4406. K5CFLAGS="`$KRB5CONF --cflags`"
  4407. K5LIBS="`$KRB5CONF --libs`"
  4408. CPPFLAGS="$CPPFLAGS $K5CFLAGS"
  4409. AC_MSG_CHECKING([for gssapi support])
  4410. if $KRB5CONF | grep gssapi >/dev/null ; then
  4411. AC_MSG_RESULT([yes])
  4412. AC_DEFINE([GSSAPI], [1],
  4413. [Define this if you want GSSAPI
  4414. support in the version 2 protocol])
  4415. GSSCFLAGS="`$KRB5CONF --cflags gssapi`"
  4416. GSSLIBS="`$KRB5CONF --libs gssapi`"
  4417. CPPFLAGS="$CPPFLAGS $GSSCFLAGS"
  4418. else
  4419. AC_MSG_RESULT([no])
  4420. fi
  4421. AC_MSG_CHECKING([whether we are using Heimdal])
  4422. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
  4423. ]], [[ char *tmp = heimdal_version; ]])],
  4424. [ AC_MSG_RESULT([yes])
  4425. AC_DEFINE([HEIMDAL], [1],
  4426. [Define this if you are using the Heimdal
  4427. version of Kerberos V5]) ],
  4428. [AC_MSG_RESULT([no])
  4429. ])
  4430. else
  4431. CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
  4432. LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
  4433. AC_MSG_CHECKING([whether we are using Heimdal])
  4434. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <krb5.h>
  4435. ]], [[ char *tmp = heimdal_version; ]])],
  4436. [ AC_MSG_RESULT([yes])
  4437. AC_DEFINE([HEIMDAL])
  4438. K5LIBS="-lkrb5"
  4439. K5LIBS="$K5LIBS -lcom_err -lasn1"
  4440. AC_CHECK_LIB([roken], [net_write],
  4441. [K5LIBS="$K5LIBS -lroken"])
  4442. AC_CHECK_LIB([des], [des_cbc_encrypt],
  4443. [K5LIBS="$K5LIBS -ldes"])
  4444. ], [ AC_MSG_RESULT([no])
  4445. K5LIBS="-lkrb5 -lk5crypto -lcom_err"
  4446. ])
  4447. AC_SEARCH_LIBS([dn_expand], [resolv])
  4448. AC_CHECK_LIB([gssapi_krb5], [gss_init_sec_context],
  4449. [ AC_DEFINE([GSSAPI])
  4450. GSSLIBS="-lgssapi_krb5" ],
  4451. [ AC_CHECK_LIB([gssapi], [gss_init_sec_context],
  4452. [ AC_DEFINE([GSSAPI])
  4453. GSSLIBS="-lgssapi" ],
  4454. [ AC_CHECK_LIB([gss], [gss_init_sec_context],
  4455. [ AC_DEFINE([GSSAPI])
  4456. GSSLIBS="-lgss" ],
  4457. AC_MSG_WARN([Cannot find any suitable gss-api library - build may fail]))
  4458. ])
  4459. ])
  4460. AC_CHECK_HEADER([gssapi.h], ,
  4461. [ unset ac_cv_header_gssapi_h
  4462. CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
  4463. AC_CHECK_HEADERS([gssapi.h], ,
  4464. AC_MSG_WARN([Cannot find any suitable gss-api header - build may fail])
  4465. )
  4466. ]
  4467. )
  4468. oldCPP="$CPPFLAGS"
  4469. CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include/gssapi"
  4470. AC_CHECK_HEADER([gssapi_krb5.h], ,
  4471. [ CPPFLAGS="$oldCPP" ])
  4472. fi
  4473. if test -n "${rpath_opt}" ; then
  4474. LDFLAGS="$LDFLAGS ${rpath_opt}${KRB5ROOT}/lib"
  4475. fi
  4476. if test ! -z "$blibpath" ; then
  4477. blibpath="$blibpath:${KRB5ROOT}/lib"
  4478. fi
  4479. AC_CHECK_HEADERS([gssapi.h gssapi/gssapi.h])
  4480. AC_CHECK_HEADERS([gssapi_krb5.h gssapi/gssapi_krb5.h])
  4481. AC_CHECK_HEADERS([gssapi_generic.h gssapi/gssapi_generic.h])
  4482. AC_SEARCH_LIBS([k_hasafs], [kafs], [AC_DEFINE([USE_AFS], [1],
  4483. [Define this if you want to use libkafs' AFS support])])
  4484. AC_CHECK_DECLS([GSS_C_NT_HOSTBASED_SERVICE], [], [], [[
  4485. #ifdef HAVE_GSSAPI_H
  4486. # include <gssapi.h>
  4487. #elif defined(HAVE_GSSAPI_GSSAPI_H)
  4488. # include <gssapi/gssapi.h>
  4489. #endif
  4490. #ifdef HAVE_GSSAPI_GENERIC_H
  4491. # include <gssapi_generic.h>
  4492. #elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H)
  4493. # include <gssapi/gssapi_generic.h>
  4494. #endif
  4495. ]])
  4496. saved_LIBS="$LIBS"
  4497. LIBS="$LIBS $K5LIBS"
  4498. AC_CHECK_FUNCS([krb5_cc_new_unique krb5_get_error_message krb5_free_error_message])
  4499. LIBS="$saved_LIBS"
  4500. fi
  4501. ]
  4502. )
  4503. AC_SUBST([GSSLIBS])
  4504. AC_SUBST([K5LIBS])
  4505. # Check whether user wants systemd support
  4506. SYSTEMD_MSG="no"
  4507. AC_ARG_WITH(systemd,
  4508. [ --with-systemd Enable systemd support],
  4509. [ if test "x$withval" != "xno" ; then
  4510. AC_PATH_TOOL([PKGCONFIG], [pkg-config], [no])
  4511. if test "$PKGCONFIG" != "no"; then
  4512. AC_MSG_CHECKING([for libsystemd])
  4513. if $PKGCONFIG --exists libsystemd; then
  4514. SYSTEMD_CFLAGS=`$PKGCONFIG --cflags libsystemd`
  4515. SYSTEMD_LIBS=`$PKGCONFIG --libs libsystemd`
  4516. CPPFLAGS="$CPPFLAGS $SYSTEMD_CFLAGS"
  4517. SSHDLIBS="$SSHDLIBS $SYSTEMD_LIBS"
  4518. AC_MSG_RESULT([yes])
  4519. AC_DEFINE(HAVE_SYSTEMD, 1, [Define if you want systemd support.])
  4520. SYSTEMD_MSG="yes"
  4521. else
  4522. AC_MSG_RESULT([no])
  4523. fi
  4524. fi
  4525. fi ]
  4526. )
  4527. # Looking for programs, paths and files
  4528. PRIVSEP_PATH=/var/empty
  4529. AC_ARG_WITH([privsep-path],
  4530. [ --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
  4531. [
  4532. if test -n "$withval" && test "x$withval" != "xno" && \
  4533. test "x${withval}" != "xyes"; then
  4534. PRIVSEP_PATH=$withval
  4535. fi
  4536. ]
  4537. )
  4538. AC_SUBST([PRIVSEP_PATH])
  4539. AC_ARG_WITH([xauth],
  4540. [ --with-xauth=PATH Specify path to xauth program ],
  4541. [
  4542. if test -n "$withval" && test "x$withval" != "xno" && \
  4543. test "x${withval}" != "xyes"; then
  4544. xauth_path=$withval
  4545. fi
  4546. ],
  4547. [
  4548. TestPath="$PATH"
  4549. TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
  4550. TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
  4551. TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
  4552. TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
  4553. AC_PATH_PROG([xauth_path], [xauth], , [$TestPath])
  4554. if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
  4555. xauth_path="/usr/openwin/bin/xauth"
  4556. fi
  4557. ]
  4558. )
  4559. STRIP_OPT=-s
  4560. AC_ARG_ENABLE([strip],
  4561. [ --disable-strip Disable calling strip(1) on install],
  4562. [
  4563. if test "x$enableval" = "xno" ; then
  4564. STRIP_OPT=
  4565. fi
  4566. ]
  4567. )
  4568. AC_SUBST([STRIP_OPT])
  4569. if test -z "$xauth_path" ; then
  4570. XAUTH_PATH="undefined"
  4571. AC_SUBST([XAUTH_PATH])
  4572. else
  4573. AC_DEFINE_UNQUOTED([XAUTH_PATH], ["$xauth_path"],
  4574. [Define if xauth is found in your path])
  4575. XAUTH_PATH=$xauth_path
  4576. AC_SUBST([XAUTH_PATH])
  4577. fi
  4578. dnl # --with-maildir=/path/to/mail gets top priority.
  4579. dnl # if maildir is set in the platform case statement above we use that.
  4580. dnl # Otherwise we run a program to get the dir from system headers.
  4581. dnl # We first look for _PATH_MAILDIR then MAILDIR then _PATH_MAIL
  4582. dnl # If we find _PATH_MAILDIR we do nothing because that is what
  4583. dnl # session.c expects anyway. Otherwise we set to the value found
  4584. dnl # stripping any trailing slash. If for some strage reason our program
  4585. dnl # does not find what it needs, we default to /var/spool/mail.
  4586. # Check for mail directory
  4587. AC_ARG_WITH([maildir],
  4588. [ --with-maildir=/path/to/mail Specify your system mail directory],
  4589. [
  4590. if test "X$withval" != X && test "x$withval" != xno && \
  4591. test "x${withval}" != xyes; then
  4592. AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$withval"],
  4593. [Set this to your mail directory if you do not have _PATH_MAILDIR])
  4594. fi
  4595. ],[
  4596. if test "X$maildir" != "X"; then
  4597. AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
  4598. else
  4599. AC_MSG_CHECKING([Discovering system mail directory])
  4600. AC_RUN_IFELSE(
  4601. [AC_LANG_PROGRAM([[
  4602. #include <stdio.h>
  4603. #include <stdlib.h>
  4604. #include <string.h>
  4605. #ifdef HAVE_PATHS_H
  4606. #include <paths.h>
  4607. #endif
  4608. #ifdef HAVE_MAILLOCK_H
  4609. #include <maillock.h>
  4610. #endif
  4611. #define DATA "conftest.maildir"
  4612. ]], [[
  4613. FILE *fd;
  4614. int rc;
  4615. fd = fopen(DATA,"w");
  4616. if(fd == NULL)
  4617. exit(1);
  4618. #if defined (_PATH_MAILDIR)
  4619. if ((rc = fprintf(fd ,"_PATH_MAILDIR:%s\n", _PATH_MAILDIR)) <0)
  4620. exit(1);
  4621. #elif defined (MAILDIR)
  4622. if ((rc = fprintf(fd ,"MAILDIR:%s\n", MAILDIR)) <0)
  4623. exit(1);
  4624. #elif defined (_PATH_MAIL)
  4625. if ((rc = fprintf(fd ,"_PATH_MAIL:%s\n", _PATH_MAIL)) <0)
  4626. exit(1);
  4627. #else
  4628. exit (2);
  4629. #endif
  4630. exit(0);
  4631. ]])],
  4632. [
  4633. maildir_what=`awk -F: '{print $1}' conftest.maildir`
  4634. maildir=`awk -F: '{print $2}' conftest.maildir \
  4635. | sed 's|/$||'`
  4636. AC_MSG_RESULT([Using: $maildir from $maildir_what])
  4637. if test "x$maildir_what" != "x_PATH_MAILDIR"; then
  4638. AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
  4639. fi
  4640. ],
  4641. [
  4642. if test "X$ac_status" = "X2";then
  4643. # our test program didn't find it. Default to /var/spool/mail
  4644. AC_MSG_RESULT([Using: default value of /var/spool/mail])
  4645. AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["/var/spool/mail"])
  4646. else
  4647. AC_MSG_RESULT([*** not found ***])
  4648. fi
  4649. ],
  4650. [
  4651. AC_MSG_WARN([cross compiling: use --with-maildir=/path/to/mail])
  4652. ]
  4653. )
  4654. fi
  4655. ]
  4656. ) # maildir
  4657. if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes"; then
  4658. AC_MSG_WARN([cross compiling: Disabling /dev/ptmx test])
  4659. disable_ptmx_check=yes
  4660. fi
  4661. if test -z "$no_dev_ptmx" ; then
  4662. if test "x$disable_ptmx_check" != "xyes" ; then
  4663. AC_CHECK_FILE(["/dev/ptmx"],
  4664. [
  4665. AC_DEFINE_UNQUOTED([HAVE_DEV_PTMX], [1],
  4666. [Define if you have /dev/ptmx])
  4667. have_dev_ptmx=1
  4668. ]
  4669. )
  4670. fi
  4671. fi
  4672. if test ! -z "$cross_compiling" && test "x$cross_compiling" != "xyes"; then
  4673. AC_CHECK_FILE(["/dev/ptc"],
  4674. [
  4675. AC_DEFINE_UNQUOTED([HAVE_DEV_PTS_AND_PTC], [1],
  4676. [Define if you have /dev/ptc])
  4677. have_dev_ptc=1
  4678. ]
  4679. )
  4680. else
  4681. AC_MSG_WARN([cross compiling: Disabling /dev/ptc test])
  4682. fi
  4683. # Options from here on. Some of these are preset by platform above
  4684. AC_ARG_WITH([mantype],
  4685. [ --with-mantype=man|cat|doc Set man page type],
  4686. [
  4687. case "$withval" in
  4688. man|cat|doc)
  4689. MANTYPE=$withval
  4690. ;;
  4691. *)
  4692. AC_MSG_ERROR([invalid man type: $withval])
  4693. ;;
  4694. esac
  4695. ]
  4696. )
  4697. if test -z "$MANTYPE"; then
  4698. if ${MANDOC} ${srcdir}/ssh.1 >/dev/null 2>&1; then
  4699. MANTYPE=doc
  4700. elif ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
  4701. MANTYPE=doc
  4702. elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
  4703. MANTYPE=man
  4704. else
  4705. MANTYPE=cat
  4706. fi
  4707. fi
  4708. AC_SUBST([MANTYPE])
  4709. if test "$MANTYPE" = "doc"; then
  4710. mansubdir=man;
  4711. else
  4712. mansubdir=$MANTYPE;
  4713. fi
  4714. AC_SUBST([mansubdir])
  4715. # Check whether to enable MD5 passwords
  4716. MD5_MSG="no"
  4717. AC_ARG_WITH([md5-passwords],
  4718. [ --with-md5-passwords Enable use of MD5 passwords],
  4719. [
  4720. if test "x$withval" != "xno" ; then
  4721. AC_DEFINE([HAVE_MD5_PASSWORDS], [1],
  4722. [Define if you want to allow MD5 passwords])
  4723. MD5_MSG="yes"
  4724. fi
  4725. ]
  4726. )
  4727. # Whether to disable shadow password support
  4728. AC_ARG_WITH([shadow],
  4729. [ --without-shadow Disable shadow password support],
  4730. [
  4731. if test "x$withval" = "xno" ; then
  4732. AC_DEFINE([DISABLE_SHADOW])
  4733. disable_shadow=yes
  4734. fi
  4735. ]
  4736. )
  4737. if test -z "$disable_shadow" ; then
  4738. AC_MSG_CHECKING([if the systems has expire shadow information])
  4739. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  4740. #include <sys/types.h>
  4741. #include <shadow.h>
  4742. struct spwd sp;
  4743. ]], [[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ]])],
  4744. [ sp_expire_available=yes ], [
  4745. ])
  4746. if test "x$sp_expire_available" = "xyes" ; then
  4747. AC_MSG_RESULT([yes])
  4748. AC_DEFINE([HAS_SHADOW_EXPIRE], [1],
  4749. [Define if you want to use shadow password expire field])
  4750. else
  4751. AC_MSG_RESULT([no])
  4752. fi
  4753. fi
  4754. # Use ip address instead of hostname in $DISPLAY
  4755. if test ! -z "$IPADDR_IN_DISPLAY" ; then
  4756. DISPLAY_HACK_MSG="yes"
  4757. AC_DEFINE([IPADDR_IN_DISPLAY], [1],
  4758. [Define if you need to use IP address
  4759. instead of hostname in $DISPLAY])
  4760. else
  4761. DISPLAY_HACK_MSG="no"
  4762. AC_ARG_WITH([ipaddr-display],
  4763. [ --with-ipaddr-display Use ip address instead of hostname in $DISPLAY],
  4764. [
  4765. if test "x$withval" != "xno" ; then
  4766. AC_DEFINE([IPADDR_IN_DISPLAY])
  4767. DISPLAY_HACK_MSG="yes"
  4768. fi
  4769. ]
  4770. )
  4771. fi
  4772. # check for /etc/default/login and use it if present.
  4773. AC_ARG_ENABLE([etc-default-login],
  4774. [ --disable-etc-default-login Disable using PATH from /etc/default/login [no]],
  4775. [ if test "x$enableval" = "xno"; then
  4776. AC_MSG_NOTICE([/etc/default/login handling disabled])
  4777. etc_default_login=no
  4778. else
  4779. etc_default_login=yes
  4780. fi ],
  4781. [ if test ! -z "$cross_compiling" && test "x$cross_compiling" = "xyes";
  4782. then
  4783. AC_MSG_WARN([cross compiling: not checking /etc/default/login])
  4784. etc_default_login=no
  4785. else
  4786. etc_default_login=yes
  4787. fi ]
  4788. )
  4789. if test "x$etc_default_login" != "xno"; then
  4790. AC_CHECK_FILE(["/etc/default/login"],
  4791. [ external_path_file=/etc/default/login ])
  4792. if test "x$external_path_file" = "x/etc/default/login"; then
  4793. AC_DEFINE([HAVE_ETC_DEFAULT_LOGIN], [1],
  4794. [Define if your system has /etc/default/login])
  4795. fi
  4796. fi
  4797. dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
  4798. if test $ac_cv_func_login_getcapbool = "yes" && \
  4799. test $ac_cv_header_login_cap_h = "yes" ; then
  4800. external_path_file=/etc/login.conf
  4801. fi
  4802. # Whether to mess with the default path
  4803. SERVER_PATH_MSG="(default)"
  4804. AC_ARG_WITH([default-path],
  4805. [ --with-default-path= Specify default $PATH environment for server],
  4806. [
  4807. if test "x$external_path_file" = "x/etc/login.conf" ; then
  4808. AC_MSG_WARN([
  4809. --with-default-path=PATH has no effect on this system.
  4810. Edit /etc/login.conf instead.])
  4811. elif test "x$withval" != "xno" ; then
  4812. if test ! -z "$external_path_file" ; then
  4813. AC_MSG_WARN([
  4814. --with-default-path=PATH will only be used if PATH is not defined in
  4815. $external_path_file .])
  4816. fi
  4817. user_path="$withval"
  4818. SERVER_PATH_MSG="$withval"
  4819. fi
  4820. ],
  4821. [ if test "x$external_path_file" = "x/etc/login.conf" ; then
  4822. AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
  4823. else
  4824. if test ! -z "$external_path_file" ; then
  4825. AC_MSG_WARN([
  4826. If PATH is defined in $external_path_file, ensure the path to scp is included,
  4827. otherwise scp will not work.])
  4828. fi
  4829. AC_RUN_IFELSE(
  4830. [AC_LANG_PROGRAM([[
  4831. /* find out what STDPATH is */
  4832. #include <stdio.h>
  4833. #include <stdlib.h>
  4834. #ifdef HAVE_PATHS_H
  4835. # include <paths.h>
  4836. #endif
  4837. #ifndef _PATH_STDPATH
  4838. # ifdef _PATH_USERPATH /* Irix */
  4839. # define _PATH_STDPATH _PATH_USERPATH
  4840. # else
  4841. # define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
  4842. # endif
  4843. #endif
  4844. #include <sys/types.h>
  4845. #include <sys/stat.h>
  4846. #include <fcntl.h>
  4847. #define DATA "conftest.stdpath"
  4848. ]], [[
  4849. FILE *fd;
  4850. int rc;
  4851. fd = fopen(DATA,"w");
  4852. if(fd == NULL)
  4853. exit(1);
  4854. if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
  4855. exit(1);
  4856. exit(0);
  4857. ]])],
  4858. [ user_path=`cat conftest.stdpath` ],
  4859. [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
  4860. [ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
  4861. )
  4862. # make sure $bindir is in USER_PATH so scp will work
  4863. t_bindir="${bindir}"
  4864. while echo "${t_bindir}" | egrep '\$\{|NONE/' >/dev/null 2>&1; do
  4865. t_bindir=`eval echo ${t_bindir}`
  4866. case $t_bindir in
  4867. NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
  4868. esac
  4869. case $t_bindir in
  4870. NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
  4871. esac
  4872. done
  4873. echo $user_path | grep ":$t_bindir" > /dev/null 2>&1
  4874. if test $? -ne 0 ; then
  4875. echo $user_path | grep "^$t_bindir" > /dev/null 2>&1
  4876. if test $? -ne 0 ; then
  4877. user_path=$user_path:$t_bindir
  4878. AC_MSG_RESULT([Adding $t_bindir to USER_PATH so scp will work])
  4879. fi
  4880. fi
  4881. fi ]
  4882. )
  4883. if test "x$external_path_file" != "x/etc/login.conf" ; then
  4884. AC_DEFINE_UNQUOTED([USER_PATH], ["$user_path"], [Specify default $PATH])
  4885. AC_SUBST([user_path])
  4886. fi
  4887. # Set superuser path separately to user path
  4888. AC_ARG_WITH([superuser-path],
  4889. [ --with-superuser-path= Specify different path for super-user],
  4890. [
  4891. if test -n "$withval" && test "x$withval" != "xno" && \
  4892. test "x${withval}" != "xyes"; then
  4893. AC_DEFINE_UNQUOTED([SUPERUSER_PATH], ["$withval"],
  4894. [Define if you want a different $PATH
  4895. for the superuser])
  4896. superuser_path=$withval
  4897. fi
  4898. ]
  4899. )
  4900. AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
  4901. IPV4_IN6_HACK_MSG="no"
  4902. AC_ARG_WITH(4in6,
  4903. [ --with-4in6 Check for and convert IPv4 in IPv6 mapped addresses],
  4904. [
  4905. if test "x$withval" != "xno" ; then
  4906. AC_MSG_RESULT([yes])
  4907. AC_DEFINE([IPV4_IN_IPV6], [1],
  4908. [Detect IPv4 in IPv6 mapped addresses
  4909. and treat as IPv4])
  4910. IPV4_IN6_HACK_MSG="yes"
  4911. else
  4912. AC_MSG_RESULT([no])
  4913. fi
  4914. ], [
  4915. if test "x$inet6_default_4in6" = "xyes"; then
  4916. AC_MSG_RESULT([yes (default)])
  4917. AC_DEFINE([IPV4_IN_IPV6])
  4918. IPV4_IN6_HACK_MSG="yes"
  4919. else
  4920. AC_MSG_RESULT([no (default)])
  4921. fi
  4922. ]
  4923. )
  4924. # Whether to enable BSD auth support
  4925. BSD_AUTH_MSG=no
  4926. AC_ARG_WITH([bsd-auth],
  4927. [ --with-bsd-auth Enable BSD auth support],
  4928. [
  4929. if test "x$withval" != "xno" ; then
  4930. AC_DEFINE([BSD_AUTH], [1],
  4931. [Define if you have BSD auth support])
  4932. BSD_AUTH_MSG=yes
  4933. fi
  4934. ]
  4935. )
  4936. # Where to place sshd.pid
  4937. piddir=/var/run
  4938. # make sure the directory exists
  4939. if test ! -d $piddir ; then
  4940. piddir=`eval echo ${sysconfdir}`
  4941. case $piddir in
  4942. NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
  4943. esac
  4944. fi
  4945. AC_ARG_WITH([pid-dir],
  4946. [ --with-pid-dir=PATH Specify location of sshd.pid file],
  4947. [
  4948. if test -n "$withval" && test "x$withval" != "xno" && \
  4949. test "x${withval}" != "xyes"; then
  4950. piddir=$withval
  4951. if test ! -d $piddir ; then
  4952. AC_MSG_WARN([** no $piddir directory on this system **])
  4953. fi
  4954. fi
  4955. ]
  4956. )
  4957. AC_DEFINE_UNQUOTED([_PATH_SSH_PIDDIR], ["$piddir"],
  4958. [Specify location of ssh.pid])
  4959. AC_SUBST([piddir])
  4960. dnl allow user to disable some login recording features
  4961. AC_ARG_ENABLE([lastlog],
  4962. [ --disable-lastlog disable use of lastlog even if detected [no]],
  4963. [
  4964. if test "x$enableval" = "xno" ; then
  4965. AC_DEFINE([DISABLE_LASTLOG])
  4966. fi
  4967. ]
  4968. )
  4969. AC_ARG_ENABLE([utmp],
  4970. [ --disable-utmp disable use of utmp even if detected [no]],
  4971. [
  4972. if test "x$enableval" = "xno" ; then
  4973. AC_DEFINE([DISABLE_UTMP])
  4974. fi
  4975. ]
  4976. )
  4977. AC_ARG_ENABLE([utmpx],
  4978. [ --disable-utmpx disable use of utmpx even if detected [no]],
  4979. [
  4980. if test "x$enableval" = "xno" ; then
  4981. AC_DEFINE([DISABLE_UTMPX], [1],
  4982. [Define if you don't want to use utmpx])
  4983. fi
  4984. ]
  4985. )
  4986. AC_ARG_ENABLE([wtmp],
  4987. [ --disable-wtmp disable use of wtmp even if detected [no]],
  4988. [
  4989. if test "x$enableval" = "xno" ; then
  4990. AC_DEFINE([DISABLE_WTMP])
  4991. fi
  4992. ]
  4993. )
  4994. AC_ARG_ENABLE([wtmpx],
  4995. [ --disable-wtmpx disable use of wtmpx even if detected [no]],
  4996. [
  4997. if test "x$enableval" = "xno" ; then
  4998. AC_DEFINE([DISABLE_WTMPX], [1],
  4999. [Define if you don't want to use wtmpx])
  5000. fi
  5001. ]
  5002. )
  5003. AC_ARG_ENABLE([libutil],
  5004. [ --disable-libutil disable use of libutil (login() etc.) [no]],
  5005. [
  5006. if test "x$enableval" = "xno" ; then
  5007. AC_DEFINE([DISABLE_LOGIN])
  5008. fi
  5009. ]
  5010. )
  5011. AC_ARG_ENABLE([pututline],
  5012. [ --disable-pututline disable use of pututline() etc. ([uw]tmp) [no]],
  5013. [
  5014. if test "x$enableval" = "xno" ; then
  5015. AC_DEFINE([DISABLE_PUTUTLINE], [1],
  5016. [Define if you don't want to use pututline()
  5017. etc. to write [uw]tmp])
  5018. fi
  5019. ]
  5020. )
  5021. AC_ARG_ENABLE([pututxline],
  5022. [ --disable-pututxline disable use of pututxline() etc. ([uw]tmpx) [no]],
  5023. [
  5024. if test "x$enableval" = "xno" ; then
  5025. AC_DEFINE([DISABLE_PUTUTXLINE], [1],
  5026. [Define if you don't want to use pututxline()
  5027. etc. to write [uw]tmpx])
  5028. fi
  5029. ]
  5030. )
  5031. AC_ARG_WITH([lastlog],
  5032. [ --with-lastlog=FILE|DIR specify lastlog location [common locations]],
  5033. [
  5034. if test "x$withval" = "xno" ; then
  5035. AC_DEFINE([DISABLE_LASTLOG])
  5036. elif test -n "$withval" && test "x${withval}" != "xyes"; then
  5037. conf_lastlog_location=$withval
  5038. fi
  5039. ]
  5040. )
  5041. dnl lastlog, [uw]tmpx? detection
  5042. dnl NOTE: set the paths in the platform section to avoid the
  5043. dnl need for command-line parameters
  5044. dnl lastlog and [uw]tmp are subject to a file search if all else fails
  5045. dnl lastlog detection
  5046. dnl NOTE: the code itself will detect if lastlog is a directory
  5047. AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
  5048. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  5049. #include <sys/types.h>
  5050. #include <utmp.h>
  5051. #ifdef HAVE_LASTLOG_H
  5052. # include <lastlog.h>
  5053. #endif
  5054. #ifdef HAVE_PATHS_H
  5055. # include <paths.h>
  5056. #endif
  5057. #ifdef HAVE_LOGIN_H
  5058. # include <login.h>
  5059. #endif
  5060. ]], [[ char *lastlog = LASTLOG_FILE; ]])],
  5061. [ AC_MSG_RESULT([yes]) ],
  5062. [
  5063. AC_MSG_RESULT([no])
  5064. AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
  5065. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  5066. #include <sys/types.h>
  5067. #include <utmp.h>
  5068. #ifdef HAVE_LASTLOG_H
  5069. # include <lastlog.h>
  5070. #endif
  5071. #ifdef HAVE_PATHS_H
  5072. # include <paths.h>
  5073. #endif
  5074. ]], [[ char *lastlog = _PATH_LASTLOG; ]])],
  5075. [ AC_MSG_RESULT([yes]) ],
  5076. [
  5077. AC_MSG_RESULT([no])
  5078. system_lastlog_path=no
  5079. ])
  5080. ])
  5081. if test -z "$conf_lastlog_location"; then
  5082. if test x"$system_lastlog_path" = x"no" ; then
  5083. for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
  5084. if (test -d "$f" || test -f "$f") ; then
  5085. conf_lastlog_location=$f
  5086. fi
  5087. done
  5088. if test -z "$conf_lastlog_location"; then
  5089. AC_MSG_WARN([** Cannot find lastlog **])
  5090. dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
  5091. fi
  5092. fi
  5093. fi
  5094. if test -n "$conf_lastlog_location"; then
  5095. AC_DEFINE_UNQUOTED([CONF_LASTLOG_FILE], ["$conf_lastlog_location"],
  5096. [Define if you want to specify the path to your lastlog file])
  5097. fi
  5098. dnl utmp detection
  5099. AC_MSG_CHECKING([if your system defines UTMP_FILE])
  5100. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  5101. #include <sys/types.h>
  5102. #include <utmp.h>
  5103. #ifdef HAVE_PATHS_H
  5104. # include <paths.h>
  5105. #endif
  5106. ]], [[ char *utmp = UTMP_FILE; ]])],
  5107. [ AC_MSG_RESULT([yes]) ],
  5108. [ AC_MSG_RESULT([no])
  5109. system_utmp_path=no
  5110. ])
  5111. if test -z "$conf_utmp_location"; then
  5112. if test x"$system_utmp_path" = x"no" ; then
  5113. for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
  5114. if test -f $f ; then
  5115. conf_utmp_location=$f
  5116. fi
  5117. done
  5118. if test -z "$conf_utmp_location"; then
  5119. AC_DEFINE([DISABLE_UTMP])
  5120. fi
  5121. fi
  5122. fi
  5123. if test -n "$conf_utmp_location"; then
  5124. AC_DEFINE_UNQUOTED([CONF_UTMP_FILE], ["$conf_utmp_location"],
  5125. [Define if you want to specify the path to your utmp file])
  5126. fi
  5127. dnl wtmp detection
  5128. AC_MSG_CHECKING([if your system defines WTMP_FILE])
  5129. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  5130. #include <sys/types.h>
  5131. #include <utmp.h>
  5132. #ifdef HAVE_PATHS_H
  5133. # include <paths.h>
  5134. #endif
  5135. ]], [[ char *wtmp = WTMP_FILE; ]])],
  5136. [ AC_MSG_RESULT([yes]) ],
  5137. [ AC_MSG_RESULT([no])
  5138. system_wtmp_path=no
  5139. ])
  5140. if test -z "$conf_wtmp_location"; then
  5141. if test x"$system_wtmp_path" = x"no" ; then
  5142. for f in /usr/adm/wtmp /var/log/wtmp; do
  5143. if test -f $f ; then
  5144. conf_wtmp_location=$f
  5145. fi
  5146. done
  5147. if test -z "$conf_wtmp_location"; then
  5148. AC_DEFINE([DISABLE_WTMP])
  5149. fi
  5150. fi
  5151. fi
  5152. if test -n "$conf_wtmp_location"; then
  5153. AC_DEFINE_UNQUOTED([CONF_WTMP_FILE], ["$conf_wtmp_location"],
  5154. [Define if you want to specify the path to your wtmp file])
  5155. fi
  5156. dnl wtmpx detection
  5157. AC_MSG_CHECKING([if your system defines WTMPX_FILE])
  5158. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  5159. #include <sys/types.h>
  5160. #include <utmp.h>
  5161. #ifdef HAVE_UTMPX_H
  5162. #include <utmpx.h>
  5163. #endif
  5164. #ifdef HAVE_PATHS_H
  5165. # include <paths.h>
  5166. #endif
  5167. ]], [[ char *wtmpx = WTMPX_FILE; ]])],
  5168. [ AC_MSG_RESULT([yes]) ],
  5169. [ AC_MSG_RESULT([no])
  5170. system_wtmpx_path=no
  5171. ])
  5172. if test -z "$conf_wtmpx_location"; then
  5173. if test x"$system_wtmpx_path" = x"no" ; then
  5174. AC_DEFINE([DISABLE_WTMPX])
  5175. fi
  5176. else
  5177. AC_DEFINE_UNQUOTED([CONF_WTMPX_FILE], ["$conf_wtmpx_location"],
  5178. [Define if you want to specify the path to your wtmpx file])
  5179. fi
  5180. if test ! -z "$blibpath" ; then
  5181. LDFLAGS="$LDFLAGS $blibflags$blibpath"
  5182. AC_MSG_WARN([Please check and edit blibpath in LDFLAGS in Makefile])
  5183. fi
  5184. AC_CHECK_MEMBER([struct lastlog.ll_line], [], [
  5185. if test x$SKIP_DISABLE_LASTLOG_DEFINE != "xyes" ; then
  5186. AC_DEFINE([DISABLE_LASTLOG])
  5187. fi
  5188. ], [
  5189. #ifdef HAVE_SYS_TYPES_H
  5190. #include <sys/types.h>
  5191. #endif
  5192. #ifdef HAVE_UTMP_H
  5193. #include <utmp.h>
  5194. #endif
  5195. #ifdef HAVE_UTMPX_H
  5196. #include <utmpx.h>
  5197. #endif
  5198. #ifdef HAVE_LASTLOG_H
  5199. #include <lastlog.h>
  5200. #endif
  5201. ])
  5202. AC_CHECK_MEMBER([struct utmp.ut_line], [], [
  5203. AC_DEFINE([DISABLE_UTMP])
  5204. AC_DEFINE([DISABLE_WTMP])
  5205. ], [
  5206. #ifdef HAVE_SYS_TYPES_H
  5207. #include <sys/types.h>
  5208. #endif
  5209. #ifdef HAVE_UTMP_H
  5210. #include <utmp.h>
  5211. #endif
  5212. #ifdef HAVE_UTMPX_H
  5213. #include <utmpx.h>
  5214. #endif
  5215. #ifdef HAVE_LASTLOG_H
  5216. #include <lastlog.h>
  5217. #endif
  5218. ])
  5219. dnl Adding -Werror to CFLAGS early prevents configure tests from running.
  5220. dnl Add now.
  5221. CFLAGS="$CFLAGS $werror_flags"
  5222. if test "x$ac_cv_func_getaddrinfo" != "xyes" ; then
  5223. TEST_SSH_IPV6=no
  5224. else
  5225. TEST_SSH_IPV6=yes
  5226. fi
  5227. AC_CHECK_DECL([BROKEN_GETADDRINFO], [TEST_SSH_IPV6=no])
  5228. AC_SUBST([TEST_SSH_IPV6], [$TEST_SSH_IPV6])
  5229. AC_SUBST([TEST_SSH_UTF8], [$TEST_SSH_UTF8])
  5230. AC_SUBST([TEST_MALLOC_OPTIONS], [$TEST_MALLOC_OPTIONS])
  5231. AC_SUBST([UNSUPPORTED_ALGORITHMS], [$unsupported_algorithms])
  5232. AC_SUBST([DEPEND], [$(cat $srcdir/.depend)])
  5233. CFLAGS="${CFLAGS} ${CFLAGS_AFTER}"
  5234. LDFLAGS="${LDFLAGS} ${LDFLAGS_AFTER}"
  5235. # Make a copy of CFLAGS/LDFLAGS without PIE options.
  5236. LDFLAGS_NOPIE=`echo "$LDFLAGS" | sed 's/ -pie//'`
  5237. CFLAGS_NOPIE=`echo "$CFLAGS" | sed 's/ -fPIE//'`
  5238. AC_SUBST([LDFLAGS_NOPIE])
  5239. AC_SUBST([CFLAGS_NOPIE])
  5240. AC_EXEEXT
  5241. AC_CONFIG_FILES([Makefile buildpkg.sh opensshd.init openssh.xml \
  5242. openbsd-compat/Makefile openbsd-compat/regress/Makefile \
  5243. survey.sh])
  5244. AC_OUTPUT
  5245. # Print summary of options
  5246. # Someone please show me a better way :)
  5247. A=`eval echo ${prefix}` ; A=`eval echo ${A}`
  5248. B=`eval echo ${bindir}` ; B=`eval echo ${B}`
  5249. C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
  5250. D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
  5251. E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
  5252. F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
  5253. G=`eval echo ${piddir}` ; G=`eval echo ${G}`
  5254. H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
  5255. I=`eval echo ${user_path}` ; I=`eval echo ${I}`
  5256. J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
  5257. echo ""
  5258. echo "OpenSSH has been configured with the following options:"
  5259. echo " User binaries: $B"
  5260. echo " System binaries: $C"
  5261. echo " Configuration files: $D"
  5262. echo " Askpass program: $E"
  5263. echo " Manual pages: $F"
  5264. echo " PID file: $G"
  5265. echo " Privilege separation chroot path: $H"
  5266. if test "x$external_path_file" = "x/etc/login.conf" ; then
  5267. echo " At runtime, sshd will use the path defined in $external_path_file"
  5268. echo " Make sure the path to scp is present, otherwise scp will not work"
  5269. else
  5270. echo " sshd default user PATH: $I"
  5271. if test ! -z "$external_path_file"; then
  5272. echo " (If PATH is set in $external_path_file it will be used instead. If"
  5273. echo " used, ensure the path to scp is present, otherwise scp will not work.)"
  5274. fi
  5275. fi
  5276. if test ! -z "$superuser_path" ; then
  5277. echo " sshd superuser user PATH: $J"
  5278. fi
  5279. echo " Manpage format: $MANTYPE"
  5280. echo " PAM support: $PAM_MSG"
  5281. echo " OSF SIA support: $SIA_MSG"
  5282. echo " KerberosV support: $KRB5_MSG"
  5283. echo " SELinux support: $SELINUX_MSG"
  5284. echo " TCP Wrappers support: $TCPW_MSG"
  5285. echo " MD5 password support: $MD5_MSG"
  5286. echo " libedit support: $LIBEDIT_MSG"
  5287. echo " libldns support: $LDNS_MSG"
  5288. echo " Solaris process contract support: $SPC_MSG"
  5289. echo " Solaris project support: $SP_MSG"
  5290. echo " Solaris privilege support: $SPP_MSG"
  5291. echo " systemd support: $SYSTEMD_MSG"
  5292. echo " IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
  5293. echo " Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
  5294. echo " BSD Auth support: $BSD_AUTH_MSG"
  5295. echo " Random number source: $RAND_MSG"
  5296. echo " Privsep sandbox style: $SANDBOX_STYLE"
  5297. echo " PKCS#11 support: $enable_pkcs11"
  5298. echo " Default PKCS#11 provider: $DEFAULT_PKCS11_PROVIDER_MSG"
  5299. echo " U2F/FIDO support: $enable_sk"
  5300. echo ""
  5301. echo " Host: ${host}"
  5302. echo " Compiler: ${CC}"
  5303. echo " Compiler flags: ${CFLAGS}"
  5304. echo "Preprocessor flags: ${CPPFLAGS}"
  5305. echo " Linker flags: ${LDFLAGS}"
  5306. echo " Libraries: ${LIBS}"
  5307. if test ! -z "${SSHDLIBS}"; then
  5308. echo " +for sshd: ${SSHDLIBS}"
  5309. fi
  5310. if test ! -z "${KEYCATLIBS}"; then
  5311. echo " +for ssh-keycat: ${KEYCATLIBS}"
  5312. fi
  5313. echo ""
  5314. if test "x$MAKE_PACKAGE_SUPPORTED" = "xyes" ; then
  5315. echo "SVR4 style packages are supported with \"make package\""
  5316. echo ""
  5317. fi
  5318. if test "x$PAM_MSG" = "xyes" ; then
  5319. echo "PAM is enabled. You may need to install a PAM control file "
  5320. echo "for sshd, otherwise password authentication may fail. "
  5321. echo "Example PAM control files can be found in the contrib/ "
  5322. echo "subdirectory"
  5323. echo ""
  5324. fi
  5325. if test ! -z "$NO_PEERCHECK" ; then
  5326. echo "WARNING: the operating system that you are using does not"
  5327. echo "appear to support getpeereid(), getpeerucred() or the"
  5328. echo "SO_PEERCRED getsockopt() option. These facilities are used to"
  5329. echo "enforce security checks to prevent unauthorised connections to"
  5330. echo "ssh-agent. Their absence increases the risk that a malicious"
  5331. echo "user can connect to your agent."
  5332. echo ""
  5333. fi
  5334. if test "$AUDIT_MODULE" = "bsm" ; then
  5335. echo "WARNING: BSM audit support is currently considered EXPERIMENTAL."
  5336. echo "See the Solaris section in README.platform for details."
  5337. fi